CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
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
edm::EDGetTokenT< edm::View< reco::Track > > trackCollectionToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackAssociatorEDProducer(const edm::ParameterSet &)
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
tuple trackCollection
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > associatorToken_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
#define str(s)
edm::EDGetTokenT< TrackingParticleCollection > TPCollectionToken_