CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TrackHistory Class Reference

This class traces the simulated and generated history of a given track. More...

#include <TrackHistory.h>

Inheritance diagram for TrackHistory:
HistoryBase

Public Member Functions

bool evaluate (TrackingParticleRef tpr)
 Evaluate track history using a TrackingParticleRef. More...
 
bool evaluate (reco::TrackBaseRef)
 Evaluate reco::Track history using a given association. More...
 
const std::pair< TrackingParticleRef, double > getMatchedTrackingParticle () const
 
void newEvent (const edm::Event &, const edm::EventSetup &)
 Pre-process event information (for accessing reconstruction information) More...
 
double quality () const
 
const reco::TrackBaseRefrecoTrack () const
 Return a reference to the reconstructed track. More...
 
 TrackHistory (const edm::ParameterSet &, edm::ConsumesCollector &&)
 Constructor by pset. More...
 
- Public Member Functions inherited from HistoryBase
void depth (int d)
 Set the depth of the history. More...
 
bool evaluate (TrackingParticleRef tpr)
 Evaluate track history using a TrackingParticleRef. More...
 
bool evaluate (TrackingVertexRef tvr)
 Evaluate track history using a TrackingParticleRef. More...
 
const HepMC::GenParticle * genParticle () const
 
GenParticleTrail const & genParticleTrail () const
 Return all generated particle (HepMC::GenParticle) in the history. More...
 
GenVertexTrail const & genVertexTrail () const
 Return all generated vertex in the history. More...
 
 HistoryBase ()
 
const reco::GenParticlerecoGenParticle () const
 
RecoGenParticleTrail const & recoGenParticleTrail () const
 Return all reco::GenParticle in the history. More...
 
const TrackingParticleRefsimParticle () const
 Return the initial tracking particle from the history. More...
 
SimParticleTrail const & simParticleTrail () const
 Return all the simulated particle in the history. More...
 
const TrackingVertexRefsimVertex () const
 Return the initial tracking vertex from the history. More...
 
SimVertexTrail const & simVertexTrail () const
 Return all the simulated vertices in the history. More...
 

Private Attributes

bool bestMatchByMaxValue_
 
bool enableRecoToSim_
 
bool enableSimToReco_
 
bool newEvent_
 
double quality_
 
reco::RecoToSimCollection recoToSim_
 
reco::TrackBaseRef recotrack_
 
reco::SimToRecoCollection simToReco_
 
edm::InputTag trackAssociator_
 
TrackingParticleRef trackingParticle_
 
edm::InputTag trackingTruth_
 
edm::InputTag trackProducer_
 

Additional Inherited Members

- Public Types inherited from HistoryBase
typedef std::vector< const HepMC::GenParticle * > GenParticleTrail
 HepMC::GenParticle trail type. More...
 
typedef std::vector< const HepMC::GenVertex * > GenVertexTrail
 GenVertex trail type. More...
 
typedef std::set< const HepMC::GenVertex * > GenVertexTrailHelper
 GenVertex trail helper type. More...
 
typedef std::vector< const reco::GenParticle * > RecoGenParticleTrail
 reco::GenParticle trail type. More...
 
typedef std::set< const reco::GenParticle * > RecoGenParticleTrailHelper
 reco::GenParticle trail helper type. More...
 
typedef std::vector< TrackingParticleRefSimParticleTrail
 SimParticle trail type. More...
 
typedef std::vector< TrackingVertexRefSimVertexTrail
 SimVertex trail type. More...
 
- Protected Attributes inherited from HistoryBase
GenParticleTrail genParticleTrail_
 
GenVertexTrail genVertexTrail_
 
GenVertexTrailHelper genVertexTrailHelper_
 
RecoGenParticleTrail recoGenParticleTrail_
 
RecoGenParticleTrailHelper recoGenParticleTrailHelper_
 
SimParticleTrail simParticleTrail_
 
SimVertexTrail simVertexTrail_
 

Detailed Description

This class traces the simulated and generated history of a given track.

Definition at line 17 of file TrackHistory.h.

Constructor & Destructor Documentation

TrackHistory::TrackHistory ( const edm::ParameterSet config,
edm::ConsumesCollector &&  collector 
)

Constructor by pset.

Definition at line 5 of file TrackHistory.cc.

References bestMatchByMaxValue_, enableRecoToSim_, enableSimToReco_, edm::ParameterSet::getUntrackedParameter(), or, quality_, trackAssociator_, trackingTruth_, and trackProducer_.

5  : HistoryBase() {
6  // Name of the track collection
7  trackProducer_ = config.getUntrackedParameter<edm::InputTag>("trackProducer");
9 
10  // Name of the traking pariticle collection
11  trackingTruth_ = config.getUntrackedParameter<edm::InputTag>("trackingTruth");
13 
14  // Track association record
15  trackAssociator_ = config.getUntrackedParameter<edm::InputTag>("trackAssociator");
16 
17  // Association by max. value
18  bestMatchByMaxValue_ = config.getUntrackedParameter<bool>("bestMatchByMaxValue");
19 
20  // Enable RecoToSim association
21  enableRecoToSim_ = config.getUntrackedParameter<bool>("enableRecoToSim");
22 
23  // Enable SimToReco association
24  enableSimToReco_ = config.getUntrackedParameter<bool>("enableSimToReco");
25 
26  if (enableRecoToSim_ or enableSimToReco_) {
28  }
29 
30  quality_ = 0.;
31 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< TrackingParticle > TrackingParticleCollection
bool enableSimToReco_
Definition: TrackHistory.h:73
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::InputTag trackProducer_
Definition: TrackHistory.h:77
bool enableRecoToSim_
Definition: TrackHistory.h:73
edm::InputTag trackAssociator_
Definition: TrackHistory.h:81
double quality_
Definition: TrackHistory.h:75
bool bestMatchByMaxValue_
Definition: TrackHistory.h:71
edm::InputTag trackingTruth_
Definition: TrackHistory.h:79

Member Function Documentation

bool TrackHistory::evaluate ( TrackingParticleRef  tpr)
inline

Evaluate track history using a TrackingParticleRef.

Definition at line 37 of file TrackHistory.h.

References bestMatchByMaxValue_, enableSimToReco_, HistoryBase::evaluate(), match(), quality_, recotrack_, mps_fire::result, and simToReco_.

Referenced by TrackClassifier::evaluate(), and GenTrackMatcher::produce().

37  {
38  if (enableSimToReco_) {
39  std::pair<reco::TrackBaseRef, double> result = match(tpr, simToReco_, bestMatchByMaxValue_);
40  recotrack_ = result.first;
41  quality_ = result.second;
42  }
43  return HistoryBase::evaluate(tpr);
44  }
bool enableSimToReco_
Definition: TrackHistory.h:73
reco::SimToRecoCollection simToReco_
Definition: TrackHistory.h:89
double quality_
Definition: TrackHistory.h:75
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: HistoryBase.h:96
bool bestMatchByMaxValue_
Definition: TrackHistory.h:71
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
reco::TrackBaseRef recotrack_
Definition: TrackHistory.h:83
bool TrackHistory::evaluate ( reco::TrackBaseRef  tr)

Evaluate reco::Track history using a given association.

Definition at line 57 of file TrackHistory.cc.

References bestMatchByMaxValue_, enableRecoToSim_, HistoryBase::evaluate(), edm::Ref< C, T, F >::isNull(), match(), quality_, recoToSim_, recotrack_, mps_fire::result, and trackingParticle_.

57  {
58  if (!enableRecoToSim_)
59  return false;
60 
61  std::pair<TrackingParticleRef, double> result = match(tr, recoToSim_, bestMatchByMaxValue_);
62 
63  TrackingParticleRef tpr(result.first);
64  quality_ = result.second;
65  trackingParticle_ = tpr;
66 
67  if (!tpr.isNull()) {
69 
70  recotrack_ = tr;
71 
72  return true;
73  }
74 
75  return false;
76 }
reco::RecoToSimCollection recoToSim_
Definition: TrackHistory.h:87
TrackingParticleRef trackingParticle_
Definition: TrackHistory.h:85
bool enableRecoToSim_
Definition: TrackHistory.h:73
double quality_
Definition: TrackHistory.h:75
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: HistoryBase.h:96
bool bestMatchByMaxValue_
Definition: TrackHistory.h:71
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
reco::TrackBaseRef recotrack_
Definition: TrackHistory.h:83
const std::pair<TrackingParticleRef, double> TrackHistory::getMatchedTrackingParticle ( ) const
inline

Definition at line 58 of file TrackHistory.h.

References quality_, mps_fire::result, and trackingParticle_.

Referenced by BDHadronTrackMonitoringAnalyzer::analyze().

58  {
59  std::pair<TrackingParticleRef, double> result;
60  result.first = trackingParticle_;
61  result.second = quality_;
62 
63  return result;
64  }
TrackingParticleRef trackingParticle_
Definition: TrackHistory.h:85
double quality_
Definition: TrackHistory.h:75
void TrackHistory::newEvent ( const edm::Event event,
const edm::EventSetup setup 
)

Pre-process event information (for accessing reconstruction information)

Definition at line 33 of file TrackHistory.cc.

References reco::TrackToTrackingParticleAssociator::associateRecoToSim(), reco::TrackToTrackingParticleAssociator::associateSimToReco(), ctfWithMaterialTrackMCMatch_cfi::associator, enableRecoToSim_, enableSimToReco_, recoToSim_, simToReco_, trackAssociator_, duplicaterechits_cfi::trackCollection, trackingTruth_, and trackProducer_.

Referenced by TrackClassifier::newEvent(), and GenTrackMatcher::produce().

33  {
35  // Track collection
37  event.getByLabel(trackProducer_, trackCollection);
38 
39  // Tracking particle information
41  event.getByLabel(trackingTruth_, TPCollection);
42 
43  // Get the track associator
45  event.getByLabel(trackAssociator_, associator);
46 
47  // Calculate the map between recotracks -> tp
48  if (enableRecoToSim_)
49  recoToSim_ = associator->associateRecoToSim(trackCollection, TPCollection);
50 
51  // Calculate the map between recotracks <- tp
52  if (enableSimToReco_)
53  simToReco_ = associator->associateSimToReco(trackCollection, TPCollection);
54  }
55 }
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
bool enableSimToReco_
Definition: TrackHistory.h:73
reco::SimToRecoCollection simToReco_
Definition: TrackHistory.h:89
edm::InputTag trackProducer_
Definition: TrackHistory.h:77
reco::RecoToSimCollection recoToSim_
Definition: TrackHistory.h:87
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
bool enableRecoToSim_
Definition: TrackHistory.h:73
edm::InputTag trackAssociator_
Definition: TrackHistory.h:81
edm::InputTag trackingTruth_
Definition: TrackHistory.h:79
double TrackHistory::quality ( void  ) const
inline

Definition at line 66 of file TrackHistory.h.

References quality_.

66 { return quality_; }
double quality_
Definition: TrackHistory.h:75
const reco::TrackBaseRef& TrackHistory::recoTrack ( ) const
inline

Return a reference to the reconstructed track.

Definition at line 55 of file TrackHistory.h.

References recotrack_.

Referenced by TrackClassifier::evaluate().

55 { return recotrack_; }
reco::TrackBaseRef recotrack_
Definition: TrackHistory.h:83

Member Data Documentation

bool TrackHistory::bestMatchByMaxValue_
private

Definition at line 71 of file TrackHistory.h.

Referenced by evaluate(), and TrackHistory().

bool TrackHistory::enableRecoToSim_
private

Definition at line 73 of file TrackHistory.h.

Referenced by evaluate(), newEvent(), and TrackHistory().

bool TrackHistory::enableSimToReco_
private

Definition at line 73 of file TrackHistory.h.

Referenced by evaluate(), newEvent(), and TrackHistory().

bool TrackHistory::newEvent_
private

Definition at line 69 of file TrackHistory.h.

double TrackHistory::quality_
private

Definition at line 75 of file TrackHistory.h.

Referenced by evaluate(), getMatchedTrackingParticle(), quality(), and TrackHistory().

reco::RecoToSimCollection TrackHistory::recoToSim_
private

Definition at line 87 of file TrackHistory.h.

Referenced by evaluate(), and newEvent().

reco::TrackBaseRef TrackHistory::recotrack_
private

Definition at line 83 of file TrackHistory.h.

Referenced by evaluate(), and recoTrack().

reco::SimToRecoCollection TrackHistory::simToReco_
private

Definition at line 89 of file TrackHistory.h.

Referenced by evaluate(), and newEvent().

edm::InputTag TrackHistory::trackAssociator_
private

Definition at line 81 of file TrackHistory.h.

Referenced by newEvent(), and TrackHistory().

TrackingParticleRef TrackHistory::trackingParticle_
private

Definition at line 85 of file TrackHistory.h.

Referenced by evaluate(), and getMatchedTrackingParticle().

edm::InputTag TrackHistory::trackingTruth_
private

Definition at line 79 of file TrackHistory.h.

Referenced by newEvent(), and TrackHistory().

edm::InputTag TrackHistory::trackProducer_
private

Definition at line 77 of file TrackHistory.h.

Referenced by newEvent(), and TrackHistory().