All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCTruthParticleHistory.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file MCTruthParticleHistory.h
3 /// \brief A "chain" of particles associated with production of a Particle in a ParticleList.
4 ///
5 /// \version $Id: MCTruthParticleHistory.h,v 1.1 2010/04/29 15:38:01 seligman Exp $
6 /// \author seligman@nevis.columbia.edu
7 ////////////////////////////////////////////////////////////////////////
8 ///
9 
10 /// A container for a chain of particles in an event. It's a meant as
11 /// a convenience for looking at a sequence of particles within a
12 /// sim::ParticeList.
13 
14 /// Here's an example to illustrate the purpose and use of a
15 /// list. Assume a pi+ is a primary particle in an event whose decay
16 /// is modeled like this:
17 
18 /// TrackID Particle
19 /// 2 pi+
20 /// 101 nu_mu
21 /// 102 mu+
22 /// 341 nu_mu_bar
23 /// 342 nu_e
24 /// 343 e+
25 
26 /// I'm playing around with the ParticleList for the event, and I'm
27 /// interested in what produced track ID 343, which is an e+. I can
28 /// use the MCTruthParticleHistory class to quickly go through the production
29 /// chain:
30 
31 /// sim::ParticleList* particleList = // ... from somewhere
32 /// int trackID = 343;
33 /// const sim::MCTruthParticleHistory MCTruthParticleHistory( particleList, trackID );
34 /// for ( int i = 0; i != MCTruthParticleHistory.size(); ++i )
35 /// {
36 /// const simb::MCParticle* particle = MCTruthParticleHistory[i];
37 /// // ...
38 /// }
39 
40 /// In the above example:
41 /// MCTruthParticleHistory.size() == 3
42 /// MCTruthParticleHistory[0] points to the particle with track ID 2
43 /// MCTruthParticleHistory[1] points to the particle with track ID 102
44 /// MCTruthParticleHistory[2] points to the particle with track ID 343
45 
46 /// So as you go through a MCTruthParticleHistory "array," the first element
47 /// is a primary particle in the event, and the last element is the
48 /// particle you used to create the history.
49 
50 /// MCTruthParticleHistory looks like a vector< const simb::MCParticle* >, with the
51 /// following additions:
52 
53 /// - a ParticleList() method that returns a ParticleList* to the
54 /// object that's associated with the history.
55 
56 /// - an EndParticleID() method that returns the track ID of the last
57 /// particle in the chain; that is, it's the second argument in the
58 /// constructor.
59 
60 /// - operator<< method for ROOT display and ease of debugging.
61 
62 /// TECHNICAL NOTES:
63 
64 /// MCTruthParticleHistory behaves mostly like a vector, but it's actually a
65 /// deque. This means that you can't assume that &MCTruthParticleHistory[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 MCTruthParticleHistory object is associated with the ParticleList
71 /// used to create it. If you delete the ParticleList (by reading in a
72 /// new event, for example) then the contents of the corresponding
73 /// MCTruthParticleHistory object(s) are garbage.
74 
75 /// If you create a MCTruthParticleHistory object like this:
76 /// const sim::MCTruthParticleHistory ph(particleList,1123);
77 /// and there is no track 1123 in the particle list, then ph.size()==0.
78 
79 /// MCTruthParticleHistory[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 ParticleList.
83 
84 #ifndef TRUTH_MCTruthParticleHistory_H
85 #define TRUTH_MCTruthParticleHistory_H
86 
87 #include "nusimdata/SimulationBase/MCParticle.h"
88 
89 #include <deque>
90 #include <iostream>
91 
92 namespace truth {
93 
94 // Forward declaration
95 class ParticleList;
96 
97 class MCTruthParticleHistory : public std::deque< const simb::MCParticle* >
98 {
99 public:
100 
101  // Constructor and destructor
102  MCTruthParticleHistory( const MCTruthParticleList* list, const int trackID );
103  virtual ~MCTruthParticleHistory();
104 
105  // For which particle was this history generated?
106  int EndParticleID() const { return m_trackID; }
107 
108  // With which ParticleList is this history associated?
110 
111  friend std::ostream& operator<< ( std::ostream& output, const MCTruthParticleHistory& );
112 
113 private:
114  const MCTruthParticleList* m_particleList; ///> The ParticleList associated with this chain.
115  int m_trackID; ///> The particle for which a history was created.
116 };
117 
118 } // namespace sim
119 
120 #endif // SIM_MCTruthParticleHistory_H
int m_trackID
The ParticleList associated with this chain.
const MCTruthParticleList * ParticleList() const
const MCTruthParticleList * m_particleList
MCTruthParticleHistory(const MCTruthParticleList *list, const int trackID)
friend std::ostream & operator<<(std::ostream &output, const MCTruthParticleHistory &)
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
list
Definition: file_to_url.sh:28