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 
55  SimParticleTrail const &simParticleTrail() const { return simParticleTrail_; }
56 
58  GenVertexTrail const &genVertexTrail() const { return genVertexTrail_; }
59 
61  GenParticleTrail const &genParticleTrail() const { return genParticleTrail_; }
62 
64  RecoGenParticleTrail const &recoGenParticleTrail() const { return recoGenParticleTrail_; }
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
116  GenVertexTrail genVertexTrail_;
117  GenParticleTrail genParticleTrail_;
118  RecoGenParticleTrail recoGenParticleTrail_;
119  SimVertexTrail simVertexTrail_;
120  SimParticleTrail simParticleTrail_;
121 
122  // Helper function to speedup search
123  GenVertexTrailHelper genVertexTrailHelper_;
124  RecoGenParticleTrailHelper recoGenParticleTrailHelper_;
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();
155  recoGenParticleTrailHelper_.clear();
156  genVertexTrailHelper_.clear();
157  }
158 
160  resetTrails();
161  simParticleTrail_.push_back(tpr);
162  }
163 };
164 
165 #endif
std::set< const HepMC::GenVertex * > GenVertexTrailHelper
GenVertex trail helper type.
Definition: HistoryBase.h:27
RecoGenParticleTrail recoGenParticleTrail_
Definition: HistoryBase.h:118
void resetTrails()
Reset trail functions.
Definition: HistoryBase.h:149
const reco::GenParticle * recoGenParticle() const
Definition: HistoryBase.h:82
SimVertexTrail const & simVertexTrail() const
Return all the simulated vertices in the history.
Definition: HistoryBase.h:52
const TrackingParticleRef & simParticle() const
Return the initial tracking particle from the history.
Definition: HistoryBase.h:67
SimVertexTrail simVertexTrail_
Definition: HistoryBase.h:119
std::vector< const HepMC::GenParticle * > GenParticleTrail
HepMC::GenParticle trail type.
Definition: HistoryBase.h:15
std::vector< const reco::GenParticle * > RecoGenParticleTrail
reco::GenParticle trail type.
Definition: HistoryBase.h:18
GenVertexTrail genVertexTrail_
Definition: HistoryBase.h:116
void traceGenHistory(HepMC::GenParticle const *)
Definition: HistoryBase.cc:31
GenVertexTrailHelper genVertexTrailHelper_
Definition: HistoryBase.h:123
std::set< const reco::GenParticle * > RecoGenParticleTrailHelper
reco::GenParticle trail helper type.
Definition: HistoryBase.h:21
void resetTrails(TrackingParticleRef tpr)
Definition: HistoryBase.h:159
void traceRecoGenHistory(reco::GenParticle const *)
Definition: HistoryBase.cc:7
std::vector< const HepMC::GenVertex * > GenVertexTrail
GenVertex trail type.
Definition: HistoryBase.h:24
d
Definition: ztail.py:151
const TrackingVertexRef & simVertex() const
Return the initial tracking vertex from the history.
Definition: HistoryBase.h:70
SimParticleTrail simParticleTrail_
Definition: HistoryBase.h:120
Base class to all the history types.
Definition: HistoryBase.h:12
SimParticleTrail const & simParticleTrail() const
Return all the simulated particle in the history.
Definition: HistoryBase.h:55
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: HistoryBase.h:96
void depth(int d)
Set the depth of the history.
Definition: HistoryBase.h:49
bool evaluate(TrackingVertexRef tvr)
Evaluate track history using a TrackingParticleRef.
Definition: HistoryBase.h:109
bool traceSimHistory(TrackingParticleRef const &, int)
Definition: HistoryBase.cc:57
RecoGenParticleTrailHelper recoGenParticleTrailHelper_
Definition: HistoryBase.h:124
GenVertexTrail const & genVertexTrail() const
Return all generated vertex in the history.
Definition: HistoryBase.h:58
RecoGenParticleTrail const & recoGenParticleTrail() const
Return all reco::GenParticle in the history.
Definition: HistoryBase.h:64
std::vector< TrackingVertexRef > SimVertexTrail
SimVertex trail type.
Definition: HistoryBase.h:33
GenParticleTrail genParticleTrail_
Definition: HistoryBase.h:117
GenParticleTrail const & genParticleTrail() const
Return all generated particle (HepMC::GenParticle) in the history.
Definition: HistoryBase.h:61
const HepMC::GenParticle * genParticle() const
Definition: HistoryBase.h:74
std::vector< TrackingParticleRef > SimParticleTrail
SimParticle trail type.
Definition: HistoryBase.h:30