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.
: tracer_(p), tracks_(p.getUntrackedParameter<edm::InputTag>("trackProducer")), genParticles_(p.getUntrackedParameter<edm::InputTag>("genParticles")) { produces<GenParticleMatch>(); }
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, alignCSCRings::e, TrackHistory::evaluate(), Exception, f, edm::helper::Filler< Map >::fill(), spr::find(), HistoryBase::genParticle(), configurableAnalysis::GenParticle, genParticleCandidates2GenParticles_cfi::genParticles, genParticles_, edm::Event::getByLabel(), i, edm::helper::Filler< Map >::insert(), edm::errors::InvalidReference, match(), n, TrackHistory::newEvent(), edm::Event::put(), tracer_, testEve_cfg::tracks, and tracks_.
{ Handle<View<Track> > tracks; evt.getByLabel(tracks_, tracks); Handle<vector<int> > barCodes; evt.getByLabel(genParticles_, barCodes); Handle<GenParticleCollection> genParticles; evt.getByLabel(genParticles_, genParticles); auto_ptr<GenParticleMatch> match(new GenParticleMatch(GenParticleRefProd(genParticles))); GenParticleMatch::Filler filler(*match); size_t n = tracks->size(); vector<int> indices(n,-1); tracer_.newEvent(evt, es); for (size_t i = 0; i < n; ++ i ) { RefToBase<Track> track(tracks, i); if (tracer_.evaluate(track)) { const HepMC::GenParticle * particle = tracer_.genParticle(); if (particle) { int barCode = particle->barcode(); vector<int>::const_iterator b = barCodes->begin(), e = barCodes->end(), f = find( b, e, barCode ); if (f == e) throw edm::Exception(errors::InvalidReference) << "found matching particle with barcode" << *f << " which has not been found in " << genParticles_; indices[i] = *f; } } } filler.insert(tracks, indices.begin(), indices.end()); filler.fill(); evt.put(match); }
edm::InputTag GenTrackMatcher::genParticles_ [private] |
Definition at line 30 of file GenTrackMatcher.cc.
Referenced by produce().
TrackHistory GenTrackMatcher::tracer_ [private] |
Definition at line 29 of file GenTrackMatcher.cc.
Referenced by produce().
edm::InputTag GenTrackMatcher::tracks_ [private] |
Definition at line 30 of file GenTrackMatcher.cc.
Referenced by produce().