EveIdCalculator.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief Interface for calculating the "ultimate mother" of a particle in a simulated event.
3 ///
4 /// \author seligman@nevis.columbia.edu
5 /// \date
6 ////////////////////////////////////////////////////////////////////////
7 
8 /// This is the base class for an algorithm to calculate the "eve
9 /// ID". This begs two questions:
10 
11 /// - What is an eve ID?
12 
13 /// - What does it mean to be a base class?
14 
15 /// The "eve ID" is the ultimate "mother" of a particle in a shower
16 /// produced by the detector simulation. Consider the following
17 /// example chain of particles:
18 
19 /// TrackID Particle "Mother"
20 /// 2 pi+ 0
21 /// 101 nu_mu 2
22 /// 102 mu+ 2
23 /// 341 nu_mu_bar 102
24 /// 342 nu_e 102
25 /// 343 e+ 102
26 /// 1022 gamma 343
27 /// 1123 e+ 1022
28 /// 1124 e- 1022
29 
30 /// The "mother" (or parent) particle of track ID 1123 is 1022; the
31 /// "mother" of track ID 102 is 2. The mother of ID 2 is 0 because it
32 /// is a primary particle, created by the event generator instead of
33 /// the detector simulation.
34 
35 /// The track IDs were originally assigned by the simulation. Each
36 /// particle is stored in a sim::Particle object. All of the particles
37 /// for a given event are stored in a sim::ParticleNavigator object.
38 
39 /// When you are studying an event, especially one with many primary
40 /// particles, it can be helpful to go up the decay chain, from
41 /// "child" to mother to "grand-mother", to eventually the ultimate
42 /// mother particle of the chain. The track ID of the ultimate mother
43 /// is the "eve ID".
44 
45 /// In the above example, if we want the eve ID to refer to primary
46 /// particles, the eve ID of track ID 1123 is 2.
47 
48 /// This class is never called directly. Instead, it's invoked
49 /// indirectly via the sim::ParticleNavigator class. For example:
50 
51 /// const sim::ParticleNavigator* particleList = // ... from somewhere
52 /// int trackID = // ... an ID you select according to some criteria
53 /// int eveID = particleList->EveId( trackID );
54 
55 /// The class below defines the eve ID to be a primary particle that
56 /// comes from the event. But what if you want a different definition
57 /// of the ultimate mother; for example, perhaps you only want to go
58 /// up the chain of particles for basic e-m showers, but stop at more
59 /// significant physics; for example, in the chain above, you might
60 /// want the eve ID of track 1123 to be 343, since all the particles
61 /// descended from 343 are part of the same e-m shower.
62 
63 /// You can override the default calculation of this class (the "base"
64 /// calculation) with one of your own. For an example of how to do
65 /// this, see EmEveIdCalculator.h.
66 
67 /// (If you're familiar with design patterns, this base class
68 /// implements the Template Method. No, this has nothing to do with
69 /// C++ templates; see "Design Patterns" by Gemma et al., or
70 /// "Effective C++" by Scott Meyers.)
71 
72 #ifndef SIM_EveIdCalculator_H
73 #define SIM_EveIdCalculator_H
74 
75 #include <map>
76 
77 namespace sim {
78 
79  // Forward declaration
80  class ParticleNavigator;
81 
83  {
84  public:
85 
86  /// Constructor and destructor
88  virtual ~EveIdCalculator();
89 
90  /// Initialize this calculator for a particular ParticleNavigator.
91  void Init( const sim::ParticleNavigator* list );
92 
93  /// Accessor: For which ParticleNavigator does this calculator generate
94  /// results?
96 
97  /// The main eve ID calculation method. This is the reason why we
98  /// use the Template Method for this class: because no matter what
99  /// the core eve ID calculation is, we want to perform the
100  /// following an additional task:
101 
102  /// To save on time, keep the results of previous eve ID
103  /// calculations for the current particle list. Only do the
104  /// complete eve ID calculation if we haven't done it already for
105  /// a given track ID.
106  int CalculateEveId( const int trackID );
107 
108  protected:
109  /// This is the core method to calculate the eve ID. If another
110  /// class is going to override the default calculation, this the
111  /// method that must be implemented.
112  virtual int DoCalculateEveId( const int trackID );
113 
114  const sim::ParticleNavigator* m_particleNav; ///< The ParticleNavigator associated with the eve ID calculation.
115 
116  private:
117  /// Keep track of the previous eve IDs for the current ParticleNavigator.
118  typedef std::map< int, int > m_previousNav_t;
119  typedef m_previousNav_t::const_iterator m_previousNav_ptr;
120  m_previousNav_t m_previousNav; ///< The results of previous eve ID calculations for the current ParticleNavigator.
121  };
122 
123 } // namespace sim
124 
125 #endif // SIM_EveIdCalculator_H
const sim::ParticleNavigator * ParticleNavigator() const
virtual int DoCalculateEveId(const int trackID)
const sim::ParticleNavigator * m_particleNav
The ParticleNavigator associated with the eve ID calculation.
m_previousNav_t::const_iterator m_previousNav_ptr
int CalculateEveId(const int trackID)
void Init(const sim::ParticleNavigator *list)
Initialize this calculator for a particular ParticleNavigator.
m_previousNav_t m_previousNav
The results of previous eve ID calculations for the current ParticleNavigator.
Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event...
Definition: FillTruth.h:16
EveIdCalculator()
Constructor and destructor.
std::map< int, int > m_previousNav_t
Keep track of the previous eve IDs for the current ParticleNavigator.
Int_t trackID
Definition: plot.C:84