test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackMCQuality.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TrackMCQuality
4 // Class: TrackMCQuality
5 //
13 //
14 // Original Author: Jean-Roch Vlimant
15 // Created: Fri Mar 27 15:19:03 CET 2009
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
32 
35 
38 
39 //
40 // class decleration
41 //
42 
44  public:
45  explicit TrackMCQuality(const edm::ParameterSet&);
47 
48  private:
49  virtual void beginJob() override ;
50  virtual void produce(edm::Event&, const edm::EventSetup&) override;
51  virtual void endJob() override ;
52 
53  // ----------member data ---------------------------
54 
59 };
60 
61 //
62 // constants, enums and typedefs
63 //
64 
65 
66 //
67 // static data member definitions
68 //
69 
70 //
71 // constructors and destructor
72 //
74  label_tr(pset.getParameter< edm::InputTag >("label_tr")),
75  label_tp(pset.getParameter< edm::InputTag >("label_tp")),
76  associator(pset.getParameter< std::string >("associator"))
77 {
78 
79  produces<reco::TrackCollection>();
80 }
81 
82 
84 {
85 }
86 
87 
88 //
89 // member functions
90 //
91 
92 // ------------ method called to produce the data ------------
93 void
95 {
96 
98 
99 
100  using namespace edm;
103 
104  Handle<edm::View<reco::Track> > trackCollection;
105  iEvent.getByLabel (label_tr, trackCollection );
106 
107  reco::RecoToSimCollection recSimColl=theAssociator->associateRecoToSim(trackCollection,
108  TPCollection,
109  &iEvent,&iSetup);
110 
111  //then loop the track collection
112  std::auto_ptr<reco::TrackCollection> outTracks(new reco::TrackCollection(trackCollection->size()));
113 
114  for (unsigned int iT=0;iT!=trackCollection->size();++iT){
115  edm::RefToBase<reco::Track> track(trackCollection, iT);
116  bool matched=false;
117  //find it in the map
118  if (recSimColl.find(track)!=recSimColl.end()){
119  // you can get the data if you want
120  std::vector<std::pair<TrackingParticleRef, double> > tp= recSimColl[track];
121  matched=true;
122  }
123  else{
124  matched=false;
125  }
126 
127  //copy the track into the new container
128  (*outTracks)[iT] = reco::Track(*track);
129  if (matched){
130  (*outTracks)[iT].setQuality(reco::TrackBase::qualitySize); //is not assigned to any quality. use it as a fake/matched flag
131  }
132  }
133 
134  iEvent.put(outTracks);
135 }
136 
137 // ------------ method called once each job just before starting event loop ------------
138 void
140 {
141 }
142 
143 // ------------ method called once each job just after ending the event loop ------------
144 void
146 }
147 
148 //define this as a plug-in
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
virtual void endJob() override
std::string associator
TrackMCQuality(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
edm::InputTag label_tr
edm::InputTag label_tp
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
virtual void beginJob() override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< TrackAssociatorBase > theAssociator
virtual void produce(edm::Event &, const edm::EventSetup &) override