CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenTrackMatcher.cc
Go to the documentation of this file.
1 
15 
16 namespace edm
17 {
18 class ParameterSet;
19 }
20 
22 {
23 public:
26 
27 private:
28  void produce( edm::Event& evt, const edm::EventSetup& es );
32 };
33 
39 
40 using namespace edm;
41 using namespace std;
42 using namespace reco;
43 
45  tracer_(p),
46  tracks_(p.getUntrackedParameter<edm::InputTag>("trackProducer")),
47  genParticles_(p.getUntrackedParameter<edm::InputTag>("genParticles"))
48 {
49  produces<GenParticleMatch>();
50 }
51 
53 {
55  evt.getByLabel(tracks_, tracks);
56  Handle<vector<int> > barCodes;
57  evt.getByLabel(genParticles_, barCodes);
59  evt.getByLabel(genParticles_, genParticles);
60  auto_ptr<GenParticleMatch> match(new GenParticleMatch(GenParticleRefProd(genParticles)));
61  GenParticleMatch::Filler filler(*match);
62  size_t n = tracks->size();
63  vector<int> indices(n,-1);
64  tracer_.newEvent(evt, es);
65  for (size_t i = 0; i < n; ++ i )
66  {
67  RefToBase<Track> track(tracks, i);
68  if (tracer_.evaluate(track))
69  {
70  const HepMC::GenParticle * particle = tracer_.genParticle();
71  if (particle)
72  {
73  int barCode = particle->barcode();
74  vector<int>::const_iterator b = barCodes->begin(), e = barCodes->end(), f = find( b, e, barCode );
76  << "found matching particle with barcode" << *f
77  << " which has not been found in " << genParticles_;
78  indices[i] = *f;
79  }
80  }
81  }
82  filler.insert(tracks, indices.begin(), indices.end());
83  filler.fill();
84  evt.put(match);
85 }
86 
88 
90 
int i
Definition: DBlmapReader.cc:9
void newEvent(const edm::Event &, const edm::EventSetup &)
Pre-process event information (for accessing reconstruction information)
Definition: TrackHistory.cc:32
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
edm::RefProd< GenParticleCollection > GenParticleRefProd
persistent reference to a GenParticle collection
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
edm::InputTag genParticles_
GenTrackMatcher(const edm::ParameterSet &)
constructor
double f[11][100]
void produce(edm::Event &evt, const edm::EventSetup &es)
This class traces the simulated and generated history of a given track.
Definition: TrackHistory.h:16
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
tuple tracks
Definition: testEve_cfg.py:39
double b
Definition: hdecay.h:120
edm::InputTag tracks_
TrackHistory tracer_
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: TrackHistory.h:39
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
const reco::PFCandidateRefVector & tracks_
edm::Association< reco::GenParticleCollection > GenParticleMatch
const HepMC::GenParticle * genParticle() const
Returns a pointer to most primitive status 1 or 2 particle.
Definition: HistoryBase.h:89