Public Member Functions | |
MCTrackMatcher (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 | |
std::string | associator_ |
edm::InputTag | genParticles_ |
edm::InputTag | trackingParticles_ |
edm::InputTag | tracks_ |
Definition at line 15 of file MCTrackMatcher.cc.
typedef edm::Association<reco::GenParticleCollection> MCTrackMatcher::GenParticleMatch [private] |
Definition at line 24 of file MCTrackMatcher.cc.
MCTrackMatcher::MCTrackMatcher | ( | const edm::ParameterSet & | p | ) |
constructor
Definition at line 39 of file MCTrackMatcher.cc.
: associator_(p.getParameter<string>("associator")), tracks_(p.getParameter<InputTag>("tracks")), genParticles_( p.getParameter<InputTag>("genParticles")), trackingParticles_( p.getParameter<InputTag>("trackingParticles")) { produces<GenParticleMatch>(); }
void MCTrackMatcher::produce | ( | edm::Event & | evt, |
const edm::EventSetup & | es | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 47 of file MCTrackMatcher.cc.
References TrackAssociatorBase::associateRecoToSim(), associator_, b, alignCSCRings::e, edm::AssociationMap< Tag >::end(), Exception, f, edm::helper::Filler< Map >::fill(), spr::find(), edm::AssociationMap< Tag >::find(), configurableAnalysis::GenParticle, genParticleCandidates2GenParticles_cfi::genParticles, genParticles_, edm::EventSetup::get(), edm::Event::getByLabel(), i, edm::helper::Filler< Map >::insert(), edm::errors::InvalidReference, j, match(), n, AlCaHLTBitMon_ParallelJobs::p, edm::ESHandle< T >::product(), edm::Event::put(), trackingParticlesFastSim_cfi::trackingParticles, trackingParticles_, testEve_cfg::tracks, and tracks_.
{ ESHandle<TrackAssociatorBase> assoc; es.get<TrackAssociatorRecord>().get(associator_,assoc); const TrackAssociatorBase * associator = assoc.product(); Handle<View<Track> > tracks; evt.getByLabel(tracks_, tracks); Handle<TrackingParticleCollection> trackingParticles; evt.getByLabel(trackingParticles_,trackingParticles); Handle<vector<int> > barCodes; evt.getByLabel(genParticles_,barCodes ); Handle<GenParticleCollection> genParticles; evt.getByLabel(genParticles_, genParticles ); RecoToSimCollection associations = associator->associateRecoToSim ( tracks, trackingParticles, & evt ); auto_ptr<GenParticleMatch> match(new GenParticleMatch(GenParticleRefProd(genParticles))); GenParticleMatch::Filler filler(*match); size_t n = tracks->size(); vector<int> indices(n,-1); for (size_t i = 0; i < n; ++ i ) { RefToBase<Track> track(tracks, i); RecoToSimCollection::const_iterator f = associations.find(track); if ( f != associations.end() ) { TrackingParticleRef tp = f->val.front().first; const HepMC::GenParticle * particle = 0; TrackingParticle::genp_iterator j, b = tp->genParticle_begin(), e = tp->genParticle_end(); for( j = b; j != e; ++ j ) { const HepMC::GenParticle * p = j->get(); if (p->status() == 1) { particle = p; break; } } if( particle != 0 ) { 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); }
std::string MCTrackMatcher::associator_ [private] |
Definition at line 22 of file MCTrackMatcher.cc.
Referenced by produce().
edm::InputTag MCTrackMatcher::genParticles_ [private] |
Definition at line 23 of file MCTrackMatcher.cc.
Referenced by produce().
Definition at line 23 of file MCTrackMatcher.cc.
Referenced by produce().
edm::InputTag MCTrackMatcher::tracks_ [private] |
Definition at line 23 of file MCTrackMatcher.cc.
Referenced by produce().