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 
34 
37 
38 //
39 // class decleration
40 //
41 
43  public:
44  explicit TrackMCQuality(const edm::ParameterSet&);
46 
47  private:
48  virtual void beginJob() override ;
49  virtual void produce(edm::Event&, const edm::EventSetup&) override;
50  virtual void endJob() override ;
51 
52  // ----------member data ---------------------------
53 
57 };
58 
59 //
60 // constants, enums and typedefs
61 //
62 
63 
64 //
65 // static data member definitions
66 //
67 
68 //
69 // constructors and destructor
70 //
72  label_tr(pset.getParameter< edm::InputTag >("label_tr")),
73  label_tp(pset.getParameter< edm::InputTag >("label_tp")),
74  label_associator(pset.getParameter< edm::InputTag >("associator"))
75 {
76  consumes<reco::TrackToTrackingParticleAssociator>(label_associator);
77  consumes<TrackingParticleCollection>(label_tp);
78  consumes<edm::View<reco::Track> >(label_tr);
79 
80  produces<reco::TrackCollection>();
81 }
82 
83 
85 {
86 }
87 
88 
89 //
90 // member functions
91 //
92 
93 // ------------ method called to produce the data ------------
94 void
96 {
97 
98  using namespace edm;
100  iEvent.getByLabel(label_associator,associator);
101 
104 
107 
108  reco::RecoToSimCollection recSimColl=associator->associateRecoToSim(trackCollection,
109  TPCollection);
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){
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
edm::InputTag label_associator
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
virtual void endJob() override
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:113
virtual void beginJob() override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
virtual void produce(edm::Event &, const edm::EventSetup &) override