@@ -41,7 +41,7 @@ using SimHitTPAssociationList = TrackAssociatorByPositionImpl::SimHitTPAssociati
4141class TrackAssociatorByPositionProducer : public edm ::global::EDProducer<> {
4242public:
4343 explicit TrackAssociatorByPositionProducer (const edm::ParameterSet&);
44- ~TrackAssociatorByPositionProducer () override ;
44+ ~TrackAssociatorByPositionProducer () override = default ;
4545
4646 static void fillDescriptions (edm::ConfigurationDescriptions& descriptions);
4747
@@ -50,7 +50,9 @@ class TrackAssociatorByPositionProducer : public edm::global::EDProducer<> {
5050
5151 // ----------member data ---------------------------
5252 edm::EDGetTokenT<SimHitTPAssociationList> theSimHitTpMapToken;
53- std::string thePname;
53+ edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropagatorToken;
54+ edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> theGeometryToken;
55+ edm::EDPutTokenT<reco::TrackToTrackingParticleAssociator> thePutToken;
5456 double theQminCut;
5557 double theQCut;
5658 double thePositionMinimumDistance;
@@ -59,10 +61,6 @@ class TrackAssociatorByPositionProducer : public edm::global::EDProducer<> {
5961 bool theConsiderAllSimHits;
6062};
6163
62- //
63- // constants, enums and typedefs
64- //
65-
6664//
6765// static data member definitions
6866//
@@ -85,21 +83,15 @@ static TrackAssociatorByPositionImpl::Method parseMethodName(const std::string&
8583//
8684TrackAssociatorByPositionProducer::TrackAssociatorByPositionProducer (const edm::ParameterSet& iConfig)
8785 : theSimHitTpMapToken{consumes<SimHitTPAssociationList>(iConfig.getParameter <edm::InputTag>(" simHitTpMapTag" ))},
88- thePname{iConfig.getParameter <std::string>(" propagator" )},
86+ thePropagatorToken{esConsumes (edm::ESInputTag (" " , iConfig.getParameter <std::string>(" propagator" )))},
87+ theGeometryToken{esConsumes ()},
88+ thePutToken{produces<reco::TrackToTrackingParticleAssociator>()},
8989 theQminCut{iConfig.getParameter <double >(" QminCut" )},
9090 theQCut{iConfig.getParameter <double >(" QCut" )},
9191 thePositionMinimumDistance{iConfig.getParameter <double >(" positionMinimumDistance" )},
9292 theMethod{parseMethodName (iConfig.getParameter <std::string>(" method" ))},
9393 theMinIfNoMatch{iConfig.getParameter <bool >(" MinIfNoMatch" )},
94- theConsiderAllSimHits{iConfig.getParameter <bool >(" ConsiderAllSimHits" )} {
95- // register your products
96- produces<reco::TrackToTrackingParticleAssociator>();
97- }
98-
99- TrackAssociatorByPositionProducer::~TrackAssociatorByPositionProducer () {
100- // do anything here that needs to be done at desctruction time
101- // (e.g. close files, deallocate resources etc.)
102- }
94+ theConsiderAllSimHits{iConfig.getParameter <bool >(" ConsiderAllSimHits" )} {}
10395
10496//
10597// member functions
@@ -109,33 +101,17 @@ TrackAssociatorByPositionProducer::~TrackAssociatorByPositionProducer() {
109101void TrackAssociatorByPositionProducer::produce (edm::StreamID,
110102 edm::Event& iEvent,
111103 const edm::EventSetup& iSetup) const {
112- using namespace edm ;
113-
114- Handle<SimHitTPAssociationList> assocList;
115- iEvent.getByToken (theSimHitTpMapToken, assocList);
116-
117- edm::ESHandle<Propagator> theP;
118- iSetup.get <TrackingComponentsRecord>().get (thePname, theP);
119-
120- edm::ESHandle<GlobalTrackingGeometry> theG;
121- iSetup.get <GlobalTrackingGeometryRecord>().get (theG);
122-
123- std::unique_ptr<reco::TrackToTrackingParticleAssociatorBaseImpl> impl{
124- new TrackAssociatorByPositionImpl (iEvent.productGetter (),
125- theG.product (),
126- theP.product (),
127- assocList.product (),
128- theQminCut,
129- theQCut,
130- thePositionMinimumDistance,
131- theMethod,
132- theMinIfNoMatch,
133- theConsiderAllSimHits)};
134-
135- std::unique_ptr<reco::TrackToTrackingParticleAssociator> toPut{
136- new reco::TrackToTrackingParticleAssociator (std::move (impl))};
137-
138- iEvent.put (std::move (toPut));
104+ iEvent.emplace (thePutToken,
105+ std::make_unique<TrackAssociatorByPositionImpl>(iEvent.productGetter (),
106+ &iSetup.getData (theGeometryToken),
107+ &iSetup.getData (thePropagatorToken),
108+ &iEvent.get (theSimHitTpMapToken),
109+ theQminCut,
110+ theQCut,
111+ thePositionMinimumDistance,
112+ theMethod,
113+ theMinIfNoMatch,
114+ theConsiderAllSimHits));
139115}
140116
141117// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
0 commit comments