CMS 3D CMS Logo

TrackAssociatorEDProducer.cc
Go to the documentation of this file.
1 //
2 // Original Author: Stefano Magni
3 // Created: Fri Mar 9 10:52:11 CET 2007
4 //
5 //
6 
7 
8 // system include files
9 #include <memory>
10 #include <string>
11 
12 // user include files
14 
17 
19 
21 
23 
26 
28 
29 
30 
31 //
32 // class decleration
33 //
34 
36 public:
38  ~TrackAssociatorEDProducer() override;
39 
40 private:
41  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
42 
44 
48 
49 };
50 
52  theIgnoremissingtrackcollection(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection",false))
53 {
54  produces<reco::SimToRecoCollection>();
55  produces<reco::RecoToSimCollection>();
56 
57  TPCollectionToken_ = consumes<TrackingParticleCollection>(pset.getParameter< edm::InputTag >("label_tp"));
58  trackCollectionToken_ = consumes<edm::View<reco::Track> >(pset.getParameter< edm::InputTag >("label_tr"));
59  associatorToken_ = consumes<reco::TrackToTrackingParticleAssociator>(pset.getParameter<edm::InputTag>("associator") );
60 
61 }
62 
63 
65 
66 }
67 
68 
69 //
70 // member functions
71 //
72 
73 // ------------ method called to produce the data ------------
74 void
76  using namespace edm;
77 
79  iEvent.getByToken(associatorToken_,theAssociator);
80 
82  iEvent.getByToken(TPCollectionToken_,TPCollection);
83 
85  bool trackAvailable = iEvent.getByToken(trackCollectionToken_, trackCollection );
86 
87  std::unique_ptr<reco::RecoToSimCollection> rts;
88  std::unique_ptr<reco::SimToRecoCollection> str;
89 
90  if (theIgnoremissingtrackcollection && !trackAvailable){
91  //the track collection is not in the event and we're being told to ignore this.
92  //do not output anything to the event, other wise this would be considered as inefficiency.
93  } else {
94  //associate tracks
95  LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
96  reco::RecoToSimCollection recSimColl=theAssociator->associateRecoToSim(trackCollection,
97  TPCollection);
98 
99  LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
100  reco::SimToRecoCollection simRecColl=theAssociator->associateSimToReco(trackCollection,
101  TPCollection);
102 
103  rts.reset(new reco::RecoToSimCollection(recSimColl));
104  str.reset(new reco::SimToRecoCollection(simRecColl));
105 
106  iEvent.put(std::move(rts));
107  iEvent.put(std::move(str));
108  }
109 }
110 
111 //define this as a plug-in
edm::EDGetTokenT< edm::View< reco::Track > > trackCollectionToken_
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TrackAssociatorEDProducer(const edm::ParameterSet &)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
int iEvent
Definition: GenABIO.cc:230
#define LogTrace(id)
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > associatorToken_
HLT enums.
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
#define str(s)
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< TrackingParticleCollection > TPCollectionToken_