ParticleHistory.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief A "chain" of particles associated with production of
3 /// a Particle in a ParticleList.
4 ///
5 /// \author seligman@nevis.columbia.edu
6 /// \date
7 ////////////////////////////////////////////////////////////////////////
8 
9 /// A container for a chain of particles in an event. It's meant as
10 /// a convenience for looking at a sequence of particles within a
11 /// sim::ParticeList.
12 
13 /// Here's an example to illustrate the purpose and use of a
14 /// list. Assume a pi+ is a primary particle in an event whose decay
15 /// is modeled like this:
16 
17 /// TrackID Particle
18 /// 2 pi+
19 /// 101 nu_mu
20 /// 102 mu+
21 /// 341 nu_mu_bar
22 /// 342 nu_e
23 /// 343 e+
24 
25 /// I'm playing around with the ParticleNavigator for the event, and I'm
26 /// interested in what produced track ID 343, which is an e+. I can
27 /// use the ParticleHistory class to quickly go through the production
28 /// chain:
29 
30 /// sim::ParticleNavigator* particleNav = // ... from somewhere
31 /// int trackID = 343;
32 /// const sim::ParticleHistory particleHistory( particleNav, trackID );
33 /// for ( int i = 0; i != particleHistory.size(); ++i )
34 /// {
35 /// const sim::Particle* particle = particleHistory[i];
36 /// // ...
37 /// }
38 
39 /// In the above example:
40 /// particleHistory.size() == 3
41 /// particleHistory[0] points to the particle with track ID 2
42 /// particleHistory[1] points to the particle with track ID 102
43 /// particleHistory[2] points to the particle with track ID 343
44 
45 /// So as you go through a ParticleHistory "array," the first element
46 /// is a primary particle in the event, and the last element is the
47 /// particle you used to create the history.
48 
49 /// ParticleHistory looks like a vector< const sim::Particle* >, with the
50 /// following additions:
51 
52 /// - a ParticleNavigator() method that returns a ParticleNavigator* to the
53 /// object that's associated with the history.
54 
55 /// - an EndParticleID() method that returns the track ID of the last
56 /// particle in the chain; that is, it's the second argument in the
57 /// constructor.
58 
59 /// - Print() and operator<< methods for ROOT display and ease of
60 /// debugging.
61 
62 /// TECHNICAL NOTES:
63 
64 /// ParticleHistory behaves mostly like a vector, but it's actually a
65 /// deque. This means that you can't assume that &particleHistory[0]
66 /// is a continugous array of Particle*. If those two sentences mean
67 /// nothing to you, don't worry about it; this only matters to folks
68 /// familiar with STL.
69 
70 /// A given ParticleHistory object is associated with the ParticleNavigator
71 /// used to create it. If you delete the ParticleNavigator (by reading in a
72 /// new event, for example) then the contents of the corresponding
73 /// ParticleHistory object(s) are garbage.
74 
75 /// If you create a ParticleHistory object like this:
76 /// const sim::ParticleHistory ph(particleNav,1123);
77 /// and there is no track 1123 in the particle list, then ph.size()==0.
78 
79 /// particleHistory[0] is not necessarily a primary particle in the
80 /// event. It's possible for a production chain to be broken due to
81 /// simulation cuts. The first element just represents as far back we
82 /// can go in the production chain given the ParticleNavigator.
83 #ifndef SIM_PARTICLEHISTORY_H
84 #define SIM_PARTICLEHISTORY_H
85 
86 #include <deque>
87 #include <iostream>
88 
89 #include "Simulation/Particle.h"
90 
91 namespace sim
92 {
93  // Forward declaration
94  class ParticleNavigator;
95 
96  class ParticleHistory : public std::deque< const sim::Particle* >
97  {
98  public:
99 
100  // Constructor and destructor
101  ParticleHistory( const sim::ParticleNavigator* nav, const int trackID );
102  virtual ~ParticleHistory();
103 
104  // For which particle was this history generated?
105  int EndParticleID() const { return m_trackID; }
106 
107  // With which ParticleNavigator is this history associated?
109 
110  // Provide a ROOT-compatible print method. (However, this class
111  // does not inherit from TObject, so it can't be read or written
112  // via ROOT I/O.)
113  virtual void Print() const;
114  friend std::ostream& operator<< ( std::ostream& output, const ParticleHistory& );
115 
116  private:
117  const sim::ParticleNavigator* m_particleNav; ///< The ParticleNavigator associated with this chain.
118  int m_trackID; ///< The particle for which a history was created.
119  };
120 
121 } // namespace sim
122 
123 #endif // SIM_PARTICLEHISTORY_H
124 /////////////////////////////////////////////////////////////////////////////
ofstream output
const sim::ParticleNavigator * ParticleNavigator() const
virtual void Print() const
int EndParticleID() const
int m_trackID
The particle for which a history was created.
Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event...
Definition: FillTruth.h:16
ParticleHistory(const sim::ParticleNavigator *nav, const int trackID)
const sim::ParticleNavigator * m_particleNav
The ParticleNavigator associated with this chain.
Int_t trackID
Definition: plot.C:84
friend std::ostream & operator<<(std::ostream &output, const ParticleHistory &)