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 // $Id: TrackAssociatorEDProducer.cc,v 1.6 2009/02/03 17:31:24 vlimant Exp $
5 //
6 //
7 
8 
9 // system include files
10 #include <memory>
11 #include <string>
12 
13 // user include files
15 
18 
20 
22 
25 
28 
29 //
30 // class decleration
31 //
32 
34 public:
37 
38 private:
39  virtual void beginJob() {}
40  virtual void produce(edm::Event&, const edm::EventSetup&);
41  virtual void endJob() ;
42 
44  bool first;
47  std::string associator;
49 };
50 
52  first(true),
53  label_tr(pset.getParameter< edm::InputTag >("label_tr")),
54  label_tp(pset.getParameter< edm::InputTag >("label_tp")),
55  associator(pset.getParameter< std::string >("associator")),
56  theIgnoremissingtrackcollection(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection",false))
57 {
58  produces<reco::SimToRecoCollection>();
59  produces<reco::RecoToSimCollection>();
60 }
61 
62 
64 
65 }
66 
67 
68 //
69 // member functions
70 //
71 
72 // ------------ method called to produce the data ------------
73 void
75  using namespace edm;
76  if(first){
78  first = false;
79  }
82 
83  Handle<edm::View<reco::Track> > trackCollection;
84  bool trackAvailable = iEvent.getByLabel (label_tr, trackCollection );
85 
86  std::auto_ptr<reco::RecoToSimCollection> rts;
87  std::auto_ptr<reco::SimToRecoCollection> str;
88 
89  if (theIgnoremissingtrackcollection && !trackAvailable){
90  //the track collection is not in the event and we're being told to ignore this.
91  //do not output anything to the event, other wise this would be considered as inefficiency.
92  }else{
93  //associate tracks
94  LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
95  reco::RecoToSimCollection recSimColl=theAssociator->associateRecoToSim(trackCollection,
97  &iEvent);
98  LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
99  reco::SimToRecoCollection simRecColl=theAssociator->associateSimToReco(trackCollection,
100  TPCollection,
101  &iEvent);
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 // ------------ method called once each job just before starting event loop ------------
112 
113 // ------------ method called once each job just after ending the event loop ------------
114 void
116 }
117 
118 //define this as a plug-in
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TrackAssociatorEDProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
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:84
bool first
Definition: L1TdeRCT.cc:79
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55