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 // system include files
8 #include <memory>
9 #include <string>
10 
11 // user include files
13 
16 
18 
20 
22 
25 
27 
28 //
29 // class decleration
30 //
31 
33 public:
35  ~TrackAssociatorEDProducer() override;
36 
37 private:
38  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
39 
41 
45 };
46 
48  : theIgnoremissingtrackcollection(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection", false)) {
49  produces<reco::SimToRecoCollection>();
50  produces<reco::RecoToSimCollection>();
51 
52  TPCollectionToken_ = consumes<TrackingParticleCollection>(pset.getParameter<edm::InputTag>("label_tp"));
53  trackCollectionToken_ = consumes<edm::View<reco::Track>>(pset.getParameter<edm::InputTag>("label_tr"));
54  associatorToken_ = consumes<reco::TrackToTrackingParticleAssociator>(pset.getParameter<edm::InputTag>("associator"));
55 }
56 
58 
59 //
60 // member functions
61 //
62 
63 // ------------ method called to produce the data ------------
65  using namespace edm;
66 
68  iEvent.getByToken(associatorToken_, theAssociator);
69 
71  iEvent.getByToken(TPCollectionToken_, TPCollection);
72 
74  bool trackAvailable = iEvent.getByToken(trackCollectionToken_, trackCollection);
75 
76  std::unique_ptr<reco::RecoToSimCollection> rts;
77  std::unique_ptr<reco::SimToRecoCollection> str;
78 
79  if (theIgnoremissingtrackcollection && !trackAvailable) {
80  // the track collection is not in the event and we're being told to ignore
81  // this. do not output anything to the event, other wise this would be
82  // considered as inefficiency.
83  } else {
84  // associate tracks
85  LogTrace("TrackValidator") << "Calling associateRecoToSim method"
86  << "\n";
87  reco::RecoToSimCollection recSimColl = theAssociator->associateRecoToSim(trackCollection, TPCollection);
88 
89  LogTrace("TrackValidator") << "Calling associateSimToReco method"
90  << "\n";
91  reco::SimToRecoCollection simRecColl = theAssociator->associateSimToReco(trackCollection, TPCollection);
92 
93  rts.reset(new reco::RecoToSimCollection(recSimColl));
94  str.reset(new reco::SimToRecoCollection(simRecColl));
95 
96  iEvent.put(std::move(rts));
97  iEvent.put(std::move(str));
98  }
99 }
100 
101 // define this as a plug-in
edm::EDGetTokenT< edm::View< reco::Track > > trackCollectionToken_
T getParameter(std::string const &) const
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
TrackAssociatorEDProducer(const edm::ParameterSet &)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
#define LogTrace(id)
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > associatorToken_
HLT enums.
#define str(s)
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< TrackingParticleCollection > TPCollectionToken_