CMS 3D CMS Logo

HistoryBase.h
Go to the documentation of this file.
1 #ifndef HistoryBase_h
2 #define HistoryBase_h
3 
4 #include <set>
5 
10 
12 class HistoryBase {
13 public:
15  typedef std::vector<const HepMC::GenParticle *> GenParticleTrail;
16 
18  typedef std::vector<const reco::GenParticle *> RecoGenParticleTrail;
19 
21  typedef std::set<const reco::GenParticle *> RecoGenParticleTrailHelper;
22 
24  typedef std::vector<const HepMC::GenVertex *> GenVertexTrail;
25 
27  typedef std::set<const HepMC::GenVertex *> GenVertexTrailHelper;
28 
30  typedef std::vector<TrackingParticleRef> SimParticleTrail;
31 
33  typedef std::vector<TrackingVertexRef> SimVertexTrail;
34 
35  // Default constructor
37  // Default depth
38  depth_ = -1;
39  }
40 
42  /* Set TrackHistory to given depth. Positive values
43  constrain the number of TrackingVertex visit in the history.
44  Negatives values set the limit of the iteration over generated
45  information i.e. (-1 -> status 1 or -2 -> status 2 particles).
46 
47  /param[in] depth the history
48  */
49  void depth(int d) { depth_ = d; }
50 
52  SimVertexTrail const &simVertexTrail() const { return simVertexTrail_; }
53 
56 
58  GenVertexTrail const &genVertexTrail() const { return genVertexTrail_; }
59 
62 
65 
67  const TrackingParticleRef &simParticle() const { return simParticleTrail_[0]; }
68 
70  const TrackingVertexRef &simVertex() const { return simVertexTrail_[0]; }
71 
75  if (genParticleTrail_.empty())
76  return nullptr;
77  return genParticleTrail_[genParticleTrail_.size() - 1];
78  }
79 
83  if (recoGenParticleTrail_.empty())
84  return nullptr;
86  }
87 
89  /* Return false when the history cannot be determined upto a given depth.
90  If not depth is pass to the function no restriction are apply to it.
91 
92  /param[in] TrackingParticleRef of a simulated track
93  /param[in] depth of the track history
94  /param[out] boolean that is true when history can be determined
95  */
97  resetTrails(tpr);
98  return traceSimHistory(tpr, depth_);
99  }
100 
102  /* Return false when the history cannot be determined upto a given depth.
103  If not depth is pass to the function no restriction are apply to it.
104 
105  /param[in] TrackingVertexRef of a simulated vertex
106  /param[in] depth of the track history
107  /param[out] boolean that is true when history can be determined
108  */
110  resetTrails();
111  return traceSimHistory(tvr, depth_);
112  }
113 
114 protected:
115  // History cointainers
121 
122  // Helper function to speedup search
125 
126 private:
127  int depth_;
128 
131  bool traceSimHistory(TrackingParticleRef const &, int);
132 
135  bool traceSimHistory(TrackingVertexRef const &, int);
136 
139  void traceGenHistory(HepMC::GenParticle const *);
140 
144 
146  void traceGenHistory(HepMC::GenVertex const *);
147 
149  void resetTrails() {
150  simParticleTrail_.clear();
151  simVertexTrail_.clear();
152  genVertexTrail_.clear();
153  genParticleTrail_.clear();
154  recoGenParticleTrail_.clear();
156  genVertexTrailHelper_.clear();
157  }
158 
160  resetTrails();
161  simParticleTrail_.push_back(tpr);
162  }
163 };
164 
165 #endif
HistoryBase::genParticleTrail_
GenParticleTrail genParticleTrail_
Definition: HistoryBase.h:117
HistoryBase::SimParticleTrail
std::vector< TrackingParticleRef > SimParticleTrail
SimParticle trail type.
Definition: HistoryBase.h:30
HistoryBase::recoGenParticle
const reco::GenParticle * recoGenParticle() const
Definition: HistoryBase.h:82
reco::GenParticle
Definition: GenParticle.h:21
HistoryBase::recoGenParticleTrail_
RecoGenParticleTrail recoGenParticleTrail_
Definition: HistoryBase.h:118
HistoryBase::GenParticleTrail
std::vector< const HepMC::GenParticle * > GenParticleTrail
HepMC::GenParticle trail type.
Definition: HistoryBase.h:15
HistoryBase::recoGenParticleTrail
const RecoGenParticleTrail & recoGenParticleTrail() const
Return all reco::GenParticle in the history.
Definition: HistoryBase.h:64
TrackingVertex.h
HistoryBase::RecoGenParticleTrail
std::vector< const reco::GenParticle * > RecoGenParticleTrail
reco::GenParticle trail type.
Definition: HistoryBase.h:18
HistoryBase::traceGenHistory
void traceGenHistory(HepMC::GenParticle const *)
Definition: HistoryBase.cc:31
HistoryBase::simVertexTrail_
SimVertexTrail simVertexTrail_
Definition: HistoryBase.h:119
HistoryBase::resetTrails
void resetTrails()
Reset trail functions.
Definition: HistoryBase.h:149
edm::Ref< TrackingParticleCollection >
HistoryBase::resetTrails
void resetTrails(TrackingParticleRef tpr)
Definition: HistoryBase.h:159
TrackingVertexContainer.h
HistoryBase::RecoGenParticleTrailHelper
std::set< const reco::GenParticle * > RecoGenParticleTrailHelper
reco::GenParticle trail helper type.
Definition: HistoryBase.h:21
HistoryBase::traceRecoGenHistory
void traceRecoGenHistory(reco::GenParticle const *)
Definition: HistoryBase.cc:7
HistoryBase::simVertexTrail
const SimVertexTrail & simVertexTrail() const
Return all the simulated vertices in the history.
Definition: HistoryBase.h:52
HistoryBase::GenVertexTrail
std::vector< const HepMC::GenVertex * > GenVertexTrail
GenVertex trail type.
Definition: HistoryBase.h:24
HistoryBase::genParticleTrail
const GenParticleTrail & genParticleTrail() const
Return all generated particle (HepMC::GenParticle) in the history.
Definition: HistoryBase.h:61
HistoryBase::simVertex
const TrackingVertexRef & simVertex() const
Return the initial tracking vertex from the history.
Definition: HistoryBase.h:70
HistoryBase::genVertexTrailHelper_
GenVertexTrailHelper genVertexTrailHelper_
Definition: HistoryBase.h:123
HistoryBase::genVertexTrail
const GenVertexTrail & genVertexTrail() const
Return all generated vertex in the history.
Definition: HistoryBase.h:58
HistoryBase::genVertexTrail_
GenVertexTrail genVertexTrail_
Definition: HistoryBase.h:116
HistoryBase::HistoryBase
HistoryBase()
Definition: HistoryBase.h:36
HistoryBase::genParticle
const HepMC::GenParticle * genParticle() const
Definition: HistoryBase.h:74
HistoryBase
Base class to all the history types.
Definition: HistoryBase.h:12
HistoryBase::simParticleTrail_
SimParticleTrail simParticleTrail_
Definition: HistoryBase.h:120
HistoryBase::simParticle
const TrackingParticleRef & simParticle() const
Return the initial tracking particle from the history.
Definition: HistoryBase.h:67
TrackingParticle.h
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
HistoryBase::simParticleTrail
const SimParticleTrail & simParticleTrail() const
Return all the simulated particle in the history.
Definition: HistoryBase.h:55
TrackingParticleFwd.h
HistoryBase::depth_
int depth_
Definition: HistoryBase.h:127
ztail.d
d
Definition: ztail.py:151
HistoryBase::evaluate
bool evaluate(TrackingVertexRef tvr)
Evaluate track history using a TrackingParticleRef.
Definition: HistoryBase.h:109
HistoryBase::evaluate
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: HistoryBase.h:96
HistoryBase::recoGenParticleTrailHelper_
RecoGenParticleTrailHelper recoGenParticleTrailHelper_
Definition: HistoryBase.h:124
HistoryBase::traceSimHistory
bool traceSimHistory(TrackingParticleRef const &, int)
Definition: HistoryBase.cc:57
HistoryBase::depth
void depth(int d)
Set the depth of the history.
Definition: HistoryBase.h:49
HistoryBase::GenVertexTrailHelper
std::set< const HepMC::GenVertex * > GenVertexTrailHelper
GenVertex trail helper type.
Definition: HistoryBase.h:27
HistoryBase::SimVertexTrail
std::vector< TrackingVertexRef > SimVertexTrail
SimVertex trail type.
Definition: HistoryBase.h:33