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::TrackHistory ( const edm::ParameterSet config,
edm::ConsumesCollector &&  collector 
)

Constructor by pset.

Definition at line 4 of file TrackHistory.cc.

References bestMatchByMaxValue_, enableRecoToSim_, enableSimToReco_, or, quality_, trackAssociator_, trackingTruth_, and trackProducer_.

4  : HistoryBase() {
5  // Name of the track collection
6  trackProducer_ = config.getUntrackedParameter<edm::InputTag>("trackProducer");
8 
9  // Name of the traking pariticle collection
10  trackingTruth_ = config.getUntrackedParameter<edm::InputTag>("trackingTruth");
12 
13  // Track association record
14  trackAssociator_ = config.getUntrackedParameter<edm::InputTag>("trackAssociator");
15 
16  // Association by max. value
17  bestMatchByMaxValue_ = config.getUntrackedParameter<bool>("bestMatchByMaxValue");
18 
19  // Enable RecoToSim association
20  enableRecoToSim_ = config.getUntrackedParameter<bool>("enableRecoToSim");
21 
22  // Enable SimToReco association
23  enableSimToReco_ = config.getUntrackedParameter<bool>("enableSimToReco");
24 
27  }
28 
29  quality_ = 0.;
30 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: config.py:1
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
std::vector< TrackingParticle > TrackingParticleCollection

Member Function Documentation

◆ evaluate() [1/2]

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

◆ evaluate() [2/2]

bool TrackHistory::evaluate ( reco::TrackBaseRef  tr)

Evaluate reco::Track history using a given association.

Definition at line 56 of file TrackHistory.cc.

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

56  {
57  if (!enableRecoToSim_)
58  return false;
59 
60  std::pair<TrackingParticleRef, double> result = match(tr, recoToSim_, bestMatchByMaxValue_);
61 
62  TrackingParticleRef tpr(result.first);
63  quality_ = result.second;
64  trackingParticle_ = tpr;
65 
66  if (!tpr.isNull()) {
68 
69  recotrack_ = tr;
70 
71  return true;
72  }
73 
74  return false;
75 }
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

◆ getMatchedTrackingParticle()

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

◆ newEvent()

void TrackHistory::newEvent ( const edm::Event event,
const edm::EventSetup setup 
)

Pre-process event information (for accessing reconstruction information)

Definition at line 32 of file TrackHistory.cc.

References LCToCPAssociation_cfi::associator, enableRecoToSim_, enableSimToReco_, recoToSim_, simToReco_, trackAssociator_, JetHT_cfg::trackCollection, trackingTruth_, and trackProducer_.

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

32  {
34  // Track collection
36  event.getByLabel(trackProducer_, trackCollection);
37 
38  // Tracking particle information
40  event.getByLabel(trackingTruth_, TPCollection);
41 
42  // Get the track associator
44  event.getByLabel(trackAssociator_, associator);
45 
46  // Calculate the map between recotracks -> tp
47  if (enableRecoToSim_)
48  recoToSim_ = associator->associateRecoToSim(trackCollection, TPCollection);
49 
50  // Calculate the map between recotracks <- tp
51  if (enableSimToReco_)
52  simToReco_ = associator->associateSimToReco(trackCollection, TPCollection);
53  }
54 }
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
trackCollection
Definition: JetHT_cfg.py:51
bool enableRecoToSim_
Definition: TrackHistory.h:73
edm::InputTag trackAssociator_
Definition: TrackHistory.h:81
edm::InputTag trackingTruth_
Definition: TrackHistory.h:79

◆ quality()

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

◆ recoTrack()

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

◆ bestMatchByMaxValue_

bool TrackHistory::bestMatchByMaxValue_
private

Definition at line 71 of file TrackHistory.h.

Referenced by evaluate(), and TrackHistory().

◆ enableRecoToSim_

bool TrackHistory::enableRecoToSim_
private

Definition at line 73 of file TrackHistory.h.

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

◆ enableSimToReco_

bool TrackHistory::enableSimToReco_
private

Definition at line 73 of file TrackHistory.h.

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

◆ newEvent_

bool TrackHistory::newEvent_
private

Definition at line 69 of file TrackHistory.h.

◆ quality_

double TrackHistory::quality_
private

Definition at line 75 of file TrackHistory.h.

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

◆ recoToSim_

reco::RecoToSimCollection TrackHistory::recoToSim_
private

Definition at line 87 of file TrackHistory.h.

Referenced by evaluate(), and newEvent().

◆ recotrack_

reco::TrackBaseRef TrackHistory::recotrack_
private

Definition at line 83 of file TrackHistory.h.

Referenced by evaluate(), and recoTrack().

◆ simToReco_

reco::SimToRecoCollection TrackHistory::simToReco_
private

Definition at line 89 of file TrackHistory.h.

Referenced by evaluate(), and newEvent().

◆ trackAssociator_

edm::InputTag TrackHistory::trackAssociator_
private

Definition at line 81 of file TrackHistory.h.

Referenced by newEvent(), and TrackHistory().

◆ trackingParticle_

TrackingParticleRef TrackHistory::trackingParticle_
private

Definition at line 85 of file TrackHistory.h.

Referenced by evaluate(), and getMatchedTrackingParticle().

◆ trackingTruth_

edm::InputTag TrackHistory::trackingTruth_
private

Definition at line 79 of file TrackHistory.h.

Referenced by newEvent(), and TrackHistory().

◆ trackProducer_

edm::InputTag TrackHistory::trackProducer_
private

Definition at line 77 of file TrackHistory.h.

Referenced by newEvent(), and TrackHistory().