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 
24 
27 
28 //
29 // class decleration
30 //
31 
33 public:
36 
37 private:
38  virtual void beginJob() override {}
39  virtual void produce(edm::Event&, const edm::EventSetup&) override;
40  virtual void endJob() override ;
41 
43  bool first;
48 };
49 
51  first(true),
52  label_tr(pset.getParameter< edm::InputTag >("label_tr")),
53  label_tp(pset.getParameter< edm::InputTag >("label_tp")),
54  associator(pset.getParameter< std::string >("associator")),
55  theIgnoremissingtrackcollection(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection",false))
56 {
57  produces<reco::SimToRecoCollection>();
58  produces<reco::RecoToSimCollection>();
59 }
60 
61 
63 
64 }
65 
66 
67 //
68 // member functions
69 //
70 
71 // ------------ method called to produce the data ------------
72 void
74  using namespace edm;
75  if(first){
77  first = false;
78  }
81 
82  Handle<edm::View<reco::Track> > trackCollection;
83  bool trackAvailable = iEvent.getByLabel (label_tr, trackCollection );
84 
85  std::auto_ptr<reco::RecoToSimCollection> rts;
86  std::auto_ptr<reco::SimToRecoCollection> str;
87 
88  if (theIgnoremissingtrackcollection && !trackAvailable){
89  //the track collection is not in the event and we're being told to ignore this.
90  //do not output anything to the event, other wise this would be considered as inefficiency.
91  }else{
92  //associate tracks
93  LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
94  reco::RecoToSimCollection recSimColl=theAssociator->associateRecoToSim(trackCollection,
96  &iEvent, &iSetup);
97  LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
98  reco::SimToRecoCollection simRecColl=theAssociator->associateSimToReco(trackCollection,
99  TPCollection,
100  &iEvent, &iSetup);
101 
102  rts.reset(new reco::RecoToSimCollection(recSimColl));
103  str.reset(new reco::SimToRecoCollection(simRecColl));
104 
105  iEvent.put(rts);
106  iEvent.put(str);
107  }
108 }
109 
110 // ------------ method called once each job just before starting event loop ------------
111 
112 // ------------ method called once each job just after ending the event loop ------------
113 void
115 }
116 
117 //define this as a plug-in
virtual void beginJob() override
virtual void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TrackAssociatorEDProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
edm::ESHandle< TrackAssociatorBase > theAssociator
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool first
Definition: L1TdeRCT.cc:79
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
volatile std::atomic< bool > shutdown_flag false