TG4Trajectory.h
Go to the documentation of this file.
1 #ifndef TG4Trajectory_hxx_seen
2 #define TG4Trajectory_hxx_seen
3 
4 #include <string>
5 #include <vector>
6 
7 #include <TVector3.h>
8 #include <TLorentzVector.h>
9 #include <TObject.h>
10 
11 namespace EDepSim {class PersistencyManager;}
12 class TG4Trajectory;
14 
15 /// A container for all of the trajectory information. The trajectory
16 /// container is indexed by the trajectory TrackId so that
17 /// (container[index].TrackId==index). That means that you can access the
18 /// parent trajectory using container[traj.ParentId].
19 typedef std::vector<TG4Trajectory> TG4TrajectoryContainer;
20 
21 /// A class to save a G4 trajectory into a root output file without linking to
22 /// geant. A trajectory is the truth information about the path of a particle
23 /// through the G4 simulation. It saves the parent trajectory that generated
24 /// this particle, the initial momentum of the particle, and the path followed
25 /// by the particle in the detector.
26 class TG4Trajectory : public TObject {
28 public:
29  typedef std::vector<TG4TrajectoryPoint> TrajectoryPoints;
30 
32  : TrackId(-1), ParentId(-1),
33  Name("none"), PDGCode(0),
34  InitialMomentum(0,0,0,0) {}
35 
36  virtual ~TG4Trajectory();
37 
38  /// The TrackId of this trajectory.
39  int GetTrackId() const {return TrackId;}
40 
41  /// The unique Id of the parent trajectory (The TrackId of the parent).
42  int GetParentId() const {return ParentId;}
43 
44  /// The name of the particle.
45  const char* GetName() const {return Name.c_str();}
46 
47  /// The PDG encoding of the particle.
48  int GetPDGCode() const {return PDGCode;}
49 
50  /// The initial momentum of the particle
51  const TLorentzVector& GetInitialMomentum() const {return InitialMomentum;}
52 
53  /// The trajectory points for this trajectory.
54  TrajectoryPoints Points;
55 
56 // The public fields are deprecated but still supported by default in the
57 // current version.
58 #define EDEPSIM_USE_PUBLIC_FIELDS
59 
60 #if defined(EDEPSIM_USE_PUBLIC_FIELDS)&&!defined(EDEPSIM_FORCE_PRIVATE_FIELDS)&&!defined(__CINT__)
61 public:
62 #ifdef EDEPSIM_WARN_PUBLIC_FIELDS
63 #warning Using deprecated public fields. Please consider using the accessor. For example, to access PrimaryId, use GetPrimaryId().
64 #endif
65 #else
66 private:
67 #endif
68 
69  /// The TrackId of this trajectory.
70  Int_t TrackId;
71 
72  /// The unique Id of the parent trajectory (The TrackId of the parent).
73  Int_t ParentId;
74 
75  /// The name of the particle.
77 
78  /// The PDG encoding of the particle.
79  Int_t PDGCode;
80 
81  /// The initial momentum of the particle
82  TLorentzVector InitialMomentum;
83 
85 };
86 
87 
88 /// A class to save a G4 trajectory point into a root output file without
89 /// linking to geant. The trajectory point is saved in a TG4Trajectory as a
90 /// way to record the path of a particle through the detector. This is the
91 /// truth information about the particles which were tracked, but is not a
92 /// good record of the energy deposition. Use the TG4HitSegment objects for a
93 /// record of the energy deposition.
94 class TG4TrajectoryPoint : public TObject {
96 public:
98  : Position(0,0,0,0), Momentum(0,0,0),
99  Process(0), Subprocess(0) {}
100 
101  virtual ~TG4TrajectoryPoint();
102 
103  /// Process types copied from the G4 definitions so that this can be
104  /// compiled without having geant4 installed. Check the exact definitions
105  /// are in the geant4 documentation, but the (important) names are pretty
106  /// self explanatory. The definitions can be found in the geant4 include
107  /// file named G4ProcessType.hh.
109  kProcessNotDefined = 0,
110  kProcessTransportation = 1,
111  kProcessElectromagetic = 2 ,
112  kProcessOptical = 3,
113  kProcessHadronic = 4,
114  kProcessPhotoLeptonHadron = 5,
115  kProcessDecay = 6,
116  kProcessGeneral = 7,
117  kProcessParameterization = 8,
118  kProcessUserDefined = 9
119  };
120 
121  /// Several important process sub-types as defined by geant4. These are
122  /// copied so that reading the files does not directly depend on having
123  /// geant4 installed. Check the geant4 documentation for the
124  /// documentation, but most of the names are fairly self explanatory. The
125  /// definitions are mostly found in the geant4 include files named
126  /// G4HadronicProcessType.hh and G4EmProcessSubType.hh
128  // EM subtypes for charged particles.
129  kSubtypeEMCoulombScattering = 1,
130  kSubtypeEMIonization = 2,
131  kSubtypeEMBremsstrahlung = 3,
132  kSubtypeEMPairProdByCharged = 4,
133  kSubtypeEMNuclearStopping = 8,
134 
135  // EM subtypes for photons
136  kSubtypeEMMultipleScattering = 10,
137  kSubtypeEMPhotoelectric = 12,
138  kSubtypeEMComptonScattering = 13,
139  kSubtypeEMGammaConversion = 14,
140 
141  // Hadronic subtypes
142  kSubtypeHadronElastic = 111,
143  kSubtypeHadronInelastic = 121,
144  kSubtypeHadronCapture = 131,
145  kSubtypeHadronChargeExchange = 161,
146 
147  // General subtypes
148  kSubtypeGeneralStepLimit = 401,
149  };
150 
151  /// The position of this trajectory point.
152  const TLorentzVector& GetPosition() const {return Position;}
153 
154  /// The momentum of the particle at this trajectory point.
155  const TVector3& GetMomentum() const {return Momentum;}
156 
157  /// The interaction process type associated with this trajectory point.
158  /// The possible values are defined in the G4ProcessType enum.
159  int GetProcess() const {return Process;}
160 
161  /// The interaction process type associated with this trajectory point.
162  /// The possible values are defined in the G4ProcessSubtype enum.
163  int GetSubprocess() const {return Subprocess;}
164 
165 #if defined(EDEPSIM_USE_PUBLIC_FIELDS)&&!defined(EDEPSIM_FORCE_PRIVATE_FIELDS)&&!defined(__CINT__)
166 public:
167 #ifdef EDEPSIM_WARN_PUBLIC_FIELDS
168 #warning Using deprecated public fields. Please consider using the accessor. For example, to access PrimaryId, use GetPrimaryId().
169 #endif
170 #else
171 private:
172 #endif
173 
174  /// The position of this trajectory point.
175  TLorentzVector Position;
176 
177  /// The momentum of the particle at this trajectory point.
178  TVector3 Momentum;
179 
180  /// The interaction process type associated with this trajectory point.
181  /// The possible values are defined in the G4ProcessType enum.
182  Int_t Process;
183 
184  /// The interaction process type associated with this trajectory point.
185  /// The possible values are defined in the G4ProcessSubtype enum.
186  Int_t Subprocess;
187 
189 };
190 #endif
TLorentzVector InitialMomentum
The initial momentum of the particle.
Definition: TG4Trajectory.h:82
int GetProcess() const
std::vector< TG4TrajectoryPoint > TrajectoryPoints
Definition: TG4Trajectory.h:29
std::string string
Definition: nybbler.cc:12
int GetPDGCode() const
The PDG encoding of the particle.
Definition: TG4Trajectory.h:48
int GetTrackId() const
The TrackId of this trajectory.
Definition: TG4Trajectory.h:39
ChannelGroupService::Name Name
std::vector< TG4Trajectory > TG4TrajectoryContainer
Definition: TG4Trajectory.h:13
TrajectoryPoints Points
The trajectory points for this trajectory.
Definition: TG4Trajectory.h:54
Int_t PDGCode
The PDG encoding of the particle.
Definition: TG4Trajectory.h:79
int GetSubprocess() const
const TLorentzVector & GetInitialMomentum() const
The initial momentum of the particle.
Definition: TG4Trajectory.h:51
Int_t ParentId
The unique Id of the parent trajectory (The TrackId of the parent).
Definition: TG4Trajectory.h:73
TVector3 Momentum
The momentum of the particle at this trajectory point.
Construct a module from components.
Definition: TG4HitSegment.h:10
const TLorentzVector & GetPosition() const
The position of this trajectory point.
int GetParentId() const
The unique Id of the parent trajectory (The TrackId of the parent).
Definition: TG4Trajectory.h:42
const TVector3 & GetMomentum() const
The momentum of the particle at this trajectory point.
std::string Name
The name of the particle.
Definition: TG4Trajectory.h:76
const char * GetName() const
The name of the particle.
Definition: TG4Trajectory.h:45
Int_t TrackId
The TrackId of this trajectory.
Definition: TG4Trajectory.h:70
TG4Trajectory(void)
Definition: TG4Trajectory.h:31
TLorentzVector Position
The position of this trajectory point.