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 
23 
25 
26 //
27 // class decleration
28 //
29 
31 public:
33  ~TrackAssociatorEDProducer() override;
34 
35 private:
36  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
37 
39 
43 };
44 
46  : theIgnoremissingtrackcollection(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection", false)) {
47  produces<reco::SimToRecoCollection>();
48  produces<reco::RecoToSimCollection>();
49 
50  TPCollectionToken_ = consumes<TrackingParticleCollection>(pset.getParameter<edm::InputTag>("label_tp"));
51  trackCollectionToken_ = consumes<edm::View<reco::Track>>(pset.getParameter<edm::InputTag>("label_tr"));
52  associatorToken_ = consumes<reco::TrackToTrackingParticleAssociator>(pset.getParameter<edm::InputTag>("associator"));
53 }
54 
56 
57 //
58 // member functions
59 //
60 
61 // ------------ method called to produce the data ------------
63  using namespace edm;
64 
66  iEvent.getByToken(associatorToken_, theAssociator);
67 
69  iEvent.getByToken(TPCollectionToken_, TPCollection);
70 
72  bool trackAvailable = iEvent.getByToken(trackCollectionToken_, trackCollection);
73 
74  std::unique_ptr<reco::RecoToSimCollection> rts;
75  std::unique_ptr<reco::SimToRecoCollection> str;
76 
77  if (theIgnoremissingtrackcollection && !trackAvailable) {
78  // the track collection is not in the event and we're being told to ignore
79  // this. do not output anything to the event, other wise this would be
80  // considered as inefficiency.
81  } else {
82  // associate tracks
83  LogTrace("TrackValidator") << "Calling associateRecoToSim method"
84  << "\n";
85  reco::RecoToSimCollection recSimColl = theAssociator->associateRecoToSim(trackCollection, TPCollection);
86 
87  LogTrace("TrackValidator") << "Calling associateSimToReco method"
88  << "\n";
89  reco::SimToRecoCollection simRecColl = theAssociator->associateSimToReco(trackCollection, TPCollection);
90 
91  rts = std::make_unique<reco::RecoToSimCollection>(recSimColl);
92  str = std::make_unique<reco::SimToRecoCollection>(simRecColl);
93 
94  iEvent.put(std::move(rts));
95  iEvent.put(std::move(str));
96  }
97 }
98 
99 // define this as a plug-in
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
edm::EDGetTokenT< edm::View< reco::Track > > trackCollectionToken_
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
TrackAssociatorEDProducer(const edm::ParameterSet &)
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
trackCollection
Definition: JetHT_cfg.py:50
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > associatorToken_
HLT enums.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
#define str(s)
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< TrackingParticleCollection > TPCollectionToken_