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