CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
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:
39 
40 private:
41  virtual 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 
83 
85  bool trackAvailable = iEvent.getByToken(trackCollectionToken_, trackCollection );
86 
87  std::auto_ptr<reco::RecoToSimCollection> rts;
88  std::auto_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(rts);
107  iEvent.put(str);
108  }
109 }
110 
111 //define this as a plug-in
edm::EDGetTokenT< edm::View< reco::Track > > trackCollectionToken_
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TrackAssociatorEDProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
#define LogTrace(id)
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > associatorToken_
virtual void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
volatile std::atomic< bool > shutdown_flag false
edm::EDGetTokenT< TrackingParticleCollection > TPCollectionToken_