CMS 3D CMS Logo

GenTrackMatcher.cc
Go to the documentation of this file.
1 
13 
14 namespace edm {
15  class ParameterSet;
16 }
17 
18 using namespace edm;
19 using namespace std;
20 using namespace reco;
21 
23 public:
26 
27 private:
28  void produce(edm::Event &evt, const edm::EventSetup &es) override;
34 };
35 
41 
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 }
49 
50 void GenTrackMatcher::produce(Event &evt, const EventSetup &es) {
53  Handle<vector<int>> barCodes;
54  evt.getByToken(genParticles_, barCodes);
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) {
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 }
83 
85 
bTagCombinedSVVariables_cff.indices
indices
Definition: bTagCombinedSVVariables_cff.py:67
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
GenTrackMatcher::genParticleInts_
edm::EDGetTokenT< vector< int > > genParticleInts_
Definition: GenTrackMatcher.cc:32
Handle.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
edm::Association::Filler
Definition: Association.h:78
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::errors::InvalidReference
Definition: EDMException.h:39
ESHandle.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
TrackHistory::newEvent
void newEvent(const edm::Event &, const edm::EventSetup &)
Pre-process event information (for accessing reconstruction information)
Definition: TrackHistory.cc:33
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
GenTrackMatcher::produce
void produce(edm::Event &evt, const edm::EventSetup &es) override
Definition: GenTrackMatcher.cc:50
EDProducer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
Association.h
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
GenParticle.h
EDMException.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::Track
Definition: Track.h:27
TrackHistory.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
GenTrackMatcher::genParticles_
edm::EDGetTokenT< GenParticleCollection > genParticles_
Definition: GenTrackMatcher.cc:31
b
double b
Definition: hdecay.h:118
edm::View
Definition: CaloClusterFwd.h:14
GenTrackMatcher
Definition: GenTrackMatcher.cc:22
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
HistoryBase::genParticle
const HepMC::GenParticle * genParticle() const
Definition: HistoryBase.h:74
createfilelist.int
int
Definition: createfilelist.py:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::Association
Definition: Association.h:18
edm::EventSetup
Definition: EventSetup.h:57
GenTrackMatcher::GenTrackMatcher
GenTrackMatcher(const edm::ParameterSet &)
constructor
Definition: GenTrackMatcher.cc:42
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
GenTrackMatcher::GenParticleMatch
edm::Association< reco::GenParticleCollection > GenParticleMatch
Definition: GenTrackMatcher.cc:33
GenTrackMatcher::tracer_
TrackHistory tracer_
Definition: GenTrackMatcher.cc:29
Exception
Definition: hltDiff.cc:246
TrackHistory
This class traces the simulated and generated history of a given track.
Definition: TrackHistory.h:17
edm::RefToBase
Definition: AssociativeIterator.h:54
TrackHistory::evaluate
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: TrackHistory.h:37
ParameterSet.h
GenTrackMatcher::tracks_
edm::EDGetTokenT< View< Track > > tracks_
Definition: GenTrackMatcher.cc:30
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ProductLabels
Definition: ProductLabels.h:4
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
reco::GenParticleRefProd
edm::RefProd< GenParticleCollection > GenParticleRefProd
persistent reference to a GenParticle collection
Definition: GenParticleFwd.h:23