CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
GenTrackMatcher Class Reference
Inheritance diagram for GenTrackMatcher:
edm::stream::EDProducer<>

Public Member Functions

 GenTrackMatcher (const edm::ParameterSet &)
 constructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

typedef edm::Association
< reco::GenParticleCollection
GenParticleMatch
 

Private Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es) override
 

Private Attributes

edm::EDGetTokenT< vector< int > > genParticleInts_
 
edm::EDGetTokenT
< GenParticleCollection
genParticles_
 
TrackHistory tracer_
 
edm::EDGetTokenT< View< Track > > tracks_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Author
Luca Lista, INFN
Victor E. Bazterra, UIC

Definition at line 22 of file GenTrackMatcher.cc.

Member Typedef Documentation

Definition at line 33 of file GenTrackMatcher.cc.

Constructor & Destructor Documentation

GenTrackMatcher::GenTrackMatcher ( const edm::ParameterSet p)

constructor

Definition at line 42 of file GenTrackMatcher.cc.

43  : tracer_(p, consumesCollector()),
44  tracks_(consumes<View<Track>>(p.getUntrackedParameter<edm::InputTag>("trackProducer"))),
45  genParticles_(consumes<GenParticleCollection>(p.getUntrackedParameter<edm::InputTag>("genParticles"))),
46  genParticleInts_(consumes<vector<int>>(p.getUntrackedParameter<edm::InputTag>("genParticles"))) {
47  produces<GenParticleMatch>();
48 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< GenParticleCollection > genParticles_
edm::EDGetTokenT< vector< int > > genParticleInts_
edm::EDGetTokenT< View< Track > > tracks_
TrackHistory tracer_

Member Function Documentation

void GenTrackMatcher::produce ( edm::Event evt,
const edm::EventSetup es 
)
overrideprivate

Definition at line 50 of file GenTrackMatcher.cc.

References b, alignCSCRings::e, TrackHistory::evaluate(), Exception, validate-o2o-wbm::f, edm::helper::Filler< Map >::fill(), spr::find(), GenParticle::GenParticle, HistoryBase::genParticle(), genParticleCandidates2GenParticles_cfi::genParticles, genParticles_, edm::Event::getByToken(), mps_fire::i, dqmdumpme::indices, edm::helper::Filler< Map >::insert(), edm::errors::InvalidReference, HLT_FULL_cff::labels, match(), edm::ProductLabels::module, eostools::move(), dqmiodumpmetadata::n, TrackHistory::newEvent(), edm::Event::put(), tracer_, HLT_FULL_cff::track, tracks, and tracks_.

50  {
52  evt.getByToken(tracks_, tracks);
53  Handle<vector<int>> barCodes;
54  evt.getByToken(genParticles_, barCodes);
56  evt.getByToken(genParticles_, genParticles);
57  unique_ptr<GenParticleMatch> match(new GenParticleMatch(GenParticleRefProd(genParticles)));
59  size_t n = tracks->size();
60  vector<int> indices(n, -1);
61  tracer_.newEvent(evt, es);
62  for (size_t i = 0; i < n; ++i) {
63  RefToBase<Track> track(tracks, i);
64  if (tracer_.evaluate(track)) {
65  const HepMC::GenParticle *particle = tracer_.genParticle();
66  if (particle) {
67  int barCode = particle->barcode();
68  vector<int>::const_iterator b = barCodes->begin(), e = barCodes->end(), f = find(b, e, barCode);
69  if (f == e) {
71  labelsForToken(genParticles_, labels);
73  << "found matching particle with barcode" << *f << " which has not been found in " << labels.module;
74  }
75  indices[i] = *f;
76  }
77  }
78  }
79  filler.insert(tracks, indices.begin(), indices.end());
80  filler.fill();
81  evt.put(std::move(match));
82 }
void newEvent(const edm::Event &, const edm::EventSetup &)
Pre-process event information (for accessing reconstruction information)
Definition: TrackHistory.cc:32
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::RefProd< GenParticleCollection > GenParticleRefProd
persistent reference to a GenParticle collection
auto const & tracks
cannot be loose
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
def move
Definition: eostools.py:511
edm::EDGetTokenT< GenParticleCollection > genParticles_
char const * module
Definition: ProductLabels.h:5
double b
Definition: hdecay.h:118
edm::EDGetTokenT< View< Track > > tracks_
TrackHistory tracer_
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: TrackHistory.h:37
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
list indices
Definition: dqmdumpme.py:50
edm::Association< reco::GenParticleCollection > GenParticleMatch
const HepMC::GenParticle * genParticle() const
Definition: HistoryBase.h:74

Member Data Documentation

edm::EDGetTokenT<vector<int> > GenTrackMatcher::genParticleInts_
private

Definition at line 32 of file GenTrackMatcher.cc.

edm::EDGetTokenT<GenParticleCollection> GenTrackMatcher::genParticles_
private

Definition at line 31 of file GenTrackMatcher.cc.

Referenced by produce().

TrackHistory GenTrackMatcher::tracer_
private

Definition at line 29 of file GenTrackMatcher.cc.

Referenced by produce().

edm::EDGetTokenT<View<Track> > GenTrackMatcher::tracks_
private

Definition at line 30 of file GenTrackMatcher.cc.

Referenced by produce().