Public Member Functions | |
GenTrackMatcher (const edm::ParameterSet &) | |
constructor | |
Private Types | |
typedef edm::Association < reco::GenParticleCollection > | GenParticleMatch |
Private Member Functions | |
void | produce (edm::Event &evt, const edm::EventSetup &es) |
Private Attributes | |
edm::InputTag | genParticles_ |
TrackHistory | tracer_ |
edm::InputTag | tracks_ |
Definition at line 21 of file GenTrackMatcher.cc.
typedef edm::Association<reco::GenParticleCollection> GenTrackMatcher::GenParticleMatch [private] |
Definition at line 31 of file GenTrackMatcher.cc.
GenTrackMatcher::GenTrackMatcher | ( | const edm::ParameterSet & | p | ) |
constructor
Definition at line 44 of file GenTrackMatcher.cc.
00044 : 00045 tracer_(p), 00046 tracks_(p.getUntrackedParameter<edm::InputTag>("trackProducer")), 00047 genParticles_(p.getUntrackedParameter<edm::InputTag>("genParticles")) 00048 { 00049 produces<GenParticleMatch>(); 00050 }
void GenTrackMatcher::produce | ( | edm::Event & | evt, | |
const edm::EventSetup & | es | |||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 52 of file GenTrackMatcher.cc.
References b, e, TrackHistory::evaluate(), f, edm::helper::Filler< Map >::fill(), find(), TrackHistory::genParticle(), genParticles_cfi::genParticles, genParticles_, edm::Event::getByLabel(), i, edm::helper::Filler< Map >::insert(), edm::errors::InvalidReference, edm::match(), n, TrackHistory::newEvent(), edm::Event::put(), tracer_, track, tracks, and tracks_.
00053 { 00054 Handle<View<Track> > tracks; 00055 evt.getByLabel(tracks_, tracks); 00056 Handle<vector<int> > barCodes; 00057 evt.getByLabel(genParticles_, barCodes); 00058 Handle<GenParticleCollection> genParticles; 00059 evt.getByLabel(genParticles_, genParticles); 00060 auto_ptr<GenParticleMatch> match(new GenParticleMatch(GenParticleRefProd(genParticles))); 00061 GenParticleMatch::Filler filler(*match); 00062 size_t n = tracks->size(); 00063 vector<int> indices(n,-1); 00064 tracer_.newEvent(evt, es); 00065 for (size_t i = 0; i < n; ++ i ) 00066 { 00067 RefToBase<Track> track(tracks, i); 00068 if (tracer_.evaluate(track)) 00069 { 00070 const HepMC::GenParticle * particle = tracer_.genParticle(); 00071 if (particle) 00072 { 00073 int barCode = particle->barcode(); 00074 vector<int>::const_iterator b = barCodes->begin(), e = barCodes->end(), f = find( b, e, barCode ); 00075 if (f == e) throw edm::Exception(errors::InvalidReference) 00076 << "found matching particle with barcode" << *f 00077 << " which has not been found in " << genParticles_; 00078 indices[i] = *f; 00079 } 00080 } 00081 } 00082 filler.insert(tracks, indices.begin(), indices.end()); 00083 filler.fill(); 00084 evt.put(match); 00085 }
edm::InputTag GenTrackMatcher::genParticles_ [private] |
TrackHistory GenTrackMatcher::tracer_ [private] |
edm::InputTag GenTrackMatcher::tracks_ [private] |