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