Public Member Functions | Private Attributes | List of all members
EDepSim::Trajectory Class Reference

#include <EDepSimTrajectory.hh>

Inheritance diagram for EDepSim::Trajectory:

Public Member Functions

 Trajectory ()
 
 Trajectory (const G4Track *aTrack)
 
 Trajectory (EDepSim::Trajectory &)
 
virtual ~Trajectory ()
 
void * operator new (size_t)
 
void operator delete (void *)
 
int operator== (const EDepSim::Trajectory &right) const
 
G4int GetTrackID () const
 Get the track id described by this trajectory. More...
 
G4int GetParentID () const
 
G4String GetParticleName () const
 Get the particle name. More...
 
G4double GetCharge () const
 Get the particle charge. More...
 
G4int GetPDGEncoding () const
 Get the PDG MC particle number for this particle. More...
 
G4String GetProcessName () const
 Get the interaction process that created the trajectory. More...
 
G4ThreeVector GetInitialMomentum () const
 Get the initial momentum of the particle that created this trajectory. More...
 
G4double GetInitialKineticEnergy () const
 
G4double GetSDEnergyDeposit () const
 Get the amount of energy deposited into a sensitive detector. More...
 
void AddSDEnergyDeposit (double energy)
 Add energy deposited into a sensitive detector. More...
 
G4double GetSDLength () const
 Get the total length of this trajectory that is in a sensitive detector. More...
 
void AddSDLength (double len)
 Add the length that has been deposited into a sensitive detector. More...
 
G4double GetSDTotalEnergyDeposit () const
 
void AddSDDaughterEnergyDeposit (double energy)
 Add energy deposited into a sensitive detector by a daughter. More...
 
G4double GetRange () const
 Get the range of the particle that created this trajectory. More...
 
void MarkTrajectory (bool save=true)
 Mark this trajectory as one that should be saved in the output. More...
 
bool SaveTrajectory () const
 Check if this trajectory should be saved. More...
 
virtual void AppendStep (const G4Step *aStep)
 
virtual int GetPointEntries () const
 Get the number of trajectory points saved with this trajectory. More...
 
virtual G4VTrajectoryPoint * GetPoint (G4int i) const
 Get a particular trajectory point. More...
 
virtual void MergeTrajectory (G4VTrajectory *secondTrajectory)
 
G4ParticleDefinition * GetParticleDefinition () const
 Get the full definition of the particle. More...
 
virtual const std::map< G4String, G4AttDef > * GetAttDefs () const
 
virtual std::vector< G4AttValue > * CreateAttValues () const
 

Private Attributes

TrajectoryPointContainerfPositionRecord
 
G4int fTrackID
 
G4int fParentID
 
G4int fPDGEncoding
 
G4double fPDGCharge
 
G4String fParticleName
 
G4String fProcessName
 
G4ThreeVector fInitialMomentum
 
G4double fSDEnergyDeposit
 
G4double fSDTotalEnergyDeposit
 
G4double fSDLength
 
bool fSaveTrajectory
 

Detailed Description

EDepSim specific trajectory class to save internal bookkeeping information. This keeps track of information about a particular particle track. Important information kept includes how much energy this trajectory has deposited in sensitive detectors, and it can query it's children to find out how much energy they deposited. It also keeps track of the process that created the trajectory, the total length in the sensitive detectors, and points along the trajectory.

Definition at line 28 of file EDepSimTrajectory.hh.

Constructor & Destructor Documentation

EDepSim::Trajectory::Trajectory ( )
EDepSim::Trajectory::Trajectory ( const G4Track *  aTrack)

Definition at line 25 of file EDepSimTrajectory.cc.

25  {
27  // Following is for the first trajectory point
28  fPositionRecord->push_back(new EDepSim::TrajectoryPoint(aTrack));
29  fTrackID = aTrack->GetTrackID();
30  fParentID = aTrack->GetParentID();
31  G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
32  fPDGEncoding = fpParticleDefinition->GetPDGEncoding();
33  fPDGCharge = fpParticleDefinition->GetPDGCharge();
34  fParticleName = fpParticleDefinition->GetParticleName();
35  const G4VProcess* proc = aTrack->GetCreatorProcess();
36  if (proc) fProcessName = proc->GetProcessName();
37  else fProcessName = "primary";
38  fInitialMomentum = aTrack->GetMomentum();
39  fSDEnergyDeposit = 0.0;
41  fSDLength = 0.0;
42  fSaveTrajectory = false;
43 }
TrajectoryPointContainer * fPositionRecord
G4ThreeVector fInitialMomentum
std::vector< G4VTrajectoryPoint * > TrajectoryPointContainer
EDepSim::Trajectory::Trajectory ( EDepSim::Trajectory right)

Definition at line 45 of file EDepSimTrajectory.cc.

45  : G4VTrajectory() {
46  fTrackID = right.fTrackID;
47  fParentID = right.fParentID;
48  fPDGEncoding = right.fPDGEncoding;
49  fPDGCharge = right.fPDGCharge;
51  fProcessName = right.fProcessName;
55  fSDLength = right.fSDLength;
57 
59  for(size_t i=0;i<right.fPositionRecord->size();++i) {
60  EDepSim::TrajectoryPoint* rightPoint
61  = (EDepSim::TrajectoryPoint*)((*(right.fPositionRecord))[i]);
62  fPositionRecord->push_back(new EDepSim::TrajectoryPoint(*rightPoint));
63  }
64 }
TrajectoryPointContainer * fPositionRecord
G4ThreeVector fInitialMomentum
std::vector< G4VTrajectoryPoint * > TrajectoryPointContainer
EDepSim::Trajectory::~Trajectory ( )
virtual

Definition at line 66 of file EDepSimTrajectory.cc.

66  {
67  for(size_t i=0;i<fPositionRecord->size();++i){
68  delete (*fPositionRecord)[i];
69  }
70  fPositionRecord->clear();
71 
72  delete fPositionRecord;
73 }
TrajectoryPointContainer * fPositionRecord

Member Function Documentation

void EDepSim::Trajectory::AddSDDaughterEnergyDeposit ( double  energy)
inline

Add energy deposited into a sensitive detector by a daughter.

Definition at line 90 of file EDepSimTrajectory.hh.

void EDepSim::Trajectory::AddSDEnergyDeposit ( double  energy)
inline

Add energy deposited into a sensitive detector.

Definition at line 72 of file EDepSimTrajectory.hh.

void EDepSim::Trajectory::AddSDLength ( double  len)
inline

Add the length that has been deposited into a sensitive detector.

Definition at line 81 of file EDepSimTrajectory.hh.

81  {
82  fSDLength += len;
83  }
void EDepSim::Trajectory::AppendStep ( const G4Step *  aStep)
virtual

Definition at line 188 of file EDepSimTrajectory.cc.

188  {
190  fPositionRecord->push_back(point);
191 }
TrajectoryPointContainer * fPositionRecord
std::vector< G4AttValue > * EDepSim::Trajectory::CreateAttValues ( ) const
virtual

Definition at line 153 of file EDepSimTrajectory.cc.

153  {
154  std::string c;
155  std::ostringstream s(c);
156 
157  std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
158 
159  s.seekp(std::ios::beg);
160  s << fTrackID << std::ends;
161  values->push_back(G4AttValue("ID",c.c_str(),""));
162 
163  s.seekp(std::ios::beg);
164  s << fParentID << std::ends;
165  values->push_back(G4AttValue("PID",c.c_str(),""));
166 
167  values->push_back(G4AttValue("PN",fParticleName,""));
168 
169  s.seekp(std::ios::beg);
170  s << fPDGCharge << std::ends;
171  values->push_back(G4AttValue("Ch",c.c_str(),""));
172 
173  s.seekp(std::ios::beg);
174  s << fPDGEncoding << std::ends;
175  values->push_back(G4AttValue("PDG",c.c_str(),""));
176 
177  s.seekp(std::ios::beg);
178  s << G4BestUnit(fInitialMomentum,"Energy") << std::ends;
179  values->push_back(G4AttValue("IMom",c.c_str(),""));
180 
181  s.seekp(std::ios::beg);
182  s << GetPointEntries() << std::ends;
183  values->push_back(G4AttValue("NTP",c.c_str(),""));
184 
185  return values;
186 }
std::string string
Definition: nybbler.cc:12
G4ThreeVector fInitialMomentum
Q_UINT16 values[128]
virtual int GetPointEntries() const
Get the number of trajectory points saved with this trajectory.
static QCString * s
Definition: config.cpp:1042
const std::map< G4String, G4AttDef > * EDepSim::Trajectory::GetAttDefs ( ) const
virtual

Definition at line 108 of file EDepSimTrajectory.cc.

108  {
109  G4bool isNew;
110  std::map<G4String,G4AttDef>* store
111  = G4AttDefStore::GetInstance("EDepSim::Trajectory",isNew);
112 
113  if (isNew) {
114  G4String ID("ID");
115  (*store)[ID] = G4AttDef(ID,
116  "Track ID",
117  "Bookkeeping","","G4int");
118 
119  G4String PID("PID");
120  (*store)[PID] = G4AttDef(PID,
121  "Parent ID",
122  "Bookkeeping","","G4int");
123 
124  G4String PN("PN");
125  (*store)[PN] = G4AttDef(PN,
126  "Particle Name",
127  "Physics","","G4String");
128 
129  G4String Ch("Ch");
130  (*store)[Ch] = G4AttDef(Ch,
131  "Charge",
132  "Physics","","G4double");
133 
134  G4String PDG("PDG");
135  (*store)[PDG] = G4AttDef(PDG,
136  "PDG Encoding",
137  "Physics","","G4int");
138 
139  G4String IMom("IMom");
140  (*store)[IMom] = G4AttDef(IMom,
141  "Momentum of track at start of trajectory",
142  "Physics","","G4ThreeVector");
143 
144  G4String NTP("NTP");
145  (*store)[NTP] = G4AttDef(NTP,
146  "No. of points",
147  "Physics","","G4int");
148 
149  }
150  return store;
151 }
unsigned int ID
const uint PDG
Definition: qregexp.cpp:140
G4double EDepSim::Trajectory::GetCharge ( ) const
inline

Get the particle charge.

Definition at line 53 of file EDepSimTrajectory.hh.

53 {return fPDGCharge;}
G4double EDepSim::Trajectory::GetInitialKineticEnergy ( ) const

Get the initial kinetic energy of the particle that created this trajectory.

Definition at line 75 of file EDepSimTrajectory.cc.

75  {
76  const G4ParticleDefinition* p = GetParticleDefinition();
77  double mom = GetInitialMomentum().mag();
78  if (!p) return mom;
79  double mass = p->GetPDGMass();
80  double kin = std::sqrt(mom*mom + mass*mass) - mass;
81  if (kin<0.0) return 0.0;
82  return kin;
83 }
G4ParticleDefinition * GetParticleDefinition() const
Get the full definition of the particle.
G4ThreeVector GetInitialMomentum() const
Get the initial momentum of the particle that created this trajectory.
p
Definition: test.py:223
G4ThreeVector EDepSim::Trajectory::GetInitialMomentum ( ) const
inline

Get the initial momentum of the particle that created this trajectory.

Definition at line 62 of file EDepSimTrajectory.hh.

62 {return fInitialMomentum;}
G4ThreeVector fInitialMomentum
G4int EDepSim::Trajectory::GetParentID ( ) const
inline

Get the track id of the parent of the track described by this trajectory.

Definition at line 47 of file EDepSimTrajectory.hh.

47 {return fParentID;}
G4ParticleDefinition * EDepSim::Trajectory::GetParticleDefinition ( ) const

Get the full definition of the particle.

Definition at line 193 of file EDepSimTrajectory.cc.

193  {
194  return (G4ParticleTable::GetParticleTable()->FindParticle(fParticleName));
195 }
G4String EDepSim::Trajectory::GetParticleName ( ) const
inline

Get the particle name.

Definition at line 50 of file EDepSimTrajectory.hh.

50 {return fParticleName;}
G4int EDepSim::Trajectory::GetPDGEncoding ( ) const
inline

Get the PDG MC particle number for this particle.

Definition at line 56 of file EDepSimTrajectory.hh.

56 {return fPDGEncoding;}
virtual G4VTrajectoryPoint* EDepSim::Trajectory::GetPoint ( G4int  i) const
inlinevirtual

Get a particular trajectory point.

Definition at line 110 of file EDepSimTrajectory.hh.

110  {
111  return (*fPositionRecord)[i];
112  }
TrajectoryPointContainer * fPositionRecord
virtual int EDepSim::Trajectory::GetPointEntries ( ) const
inlinevirtual

Get the number of trajectory points saved with this trajectory.

Definition at line 107 of file EDepSimTrajectory.hh.

107 {return fPositionRecord->size();}
TrajectoryPointContainer * fPositionRecord
G4String EDepSim::Trajectory::GetProcessName ( ) const
inline

Get the interaction process that created the trajectory.

Definition at line 59 of file EDepSimTrajectory.hh.

59 {return fProcessName;}
G4double EDepSim::Trajectory::GetRange ( ) const

Get the range of the particle that created this trajectory.

Definition at line 85 of file EDepSimTrajectory.cc.

85  {
86  if (GetPointEntries()<2) return 0.0;
87  G4ThreeVector first
88  = dynamic_cast<EDepSim::TrajectoryPoint*>(GetPoint(0))->GetPosition();
89  G4ThreeVector last
91  ->GetPosition();
92  return (last - first).mag();
93 }
virtual G4VTrajectoryPoint * GetPoint(G4int i) const
Get a particular trajectory point.
virtual int GetPointEntries() const
Get the number of trajectory points saved with this trajectory.
G4double EDepSim::Trajectory::GetSDEnergyDeposit ( ) const
inline

Get the amount of energy deposited into a sensitive detector.

Definition at line 69 of file EDepSimTrajectory.hh.

69 {return fSDEnergyDeposit;}
G4double EDepSim::Trajectory::GetSDLength ( ) const
inline

Get the total length of this trajectory that is in a sensitive detector.

Definition at line 78 of file EDepSimTrajectory.hh.

78 {return fSDLength;}
G4double EDepSim::Trajectory::GetSDTotalEnergyDeposit ( ) const
inline

Get the total amount of energy deposited into a sensitive detector by this trajectory and all of it's daughters.

Definition at line 87 of file EDepSimTrajectory.hh.

87 {return fSDTotalEnergyDeposit;}
G4int EDepSim::Trajectory::GetTrackID ( ) const
inline

Get the track id described by this trajectory.

Definition at line 43 of file EDepSimTrajectory.hh.

43 {return fTrackID;}
void EDepSim::Trajectory::MarkTrajectory ( bool  save = true)

Mark this trajectory as one that should be saved in the output.

Definition at line 95 of file EDepSimTrajectory.cc.

95  {
96  fSaveTrajectory = true;
97  if (!save) return;
98  // Mark all parents to be saved as well.
99  G4VTrajectory* g4Traj = EDepSim::TrajectoryMap::Get(fParentID);
100  if (!g4Traj) return;
101  EDepSim::Trajectory* traj = dynamic_cast<EDepSim::Trajectory*>(g4Traj);
102  if (!traj) return;
103  // Protect against infinite loops.
104  if (this == traj) return;
105  traj->MarkTrajectory(save);
106 }
void MarkTrajectory(bool save=true)
Mark this trajectory as one that should be saved in the output.
def save(obj, fname)
Definition: root.py:19
static G4VTrajectory * Get(int trackId)
Provide a map between the track id and the trajectory object.
void EDepSim::Trajectory::MergeTrajectory ( G4VTrajectory *  secondTrajectory)
virtual

Definition at line 197 of file EDepSimTrajectory.cc.

197  {
198  if(!secondTrajectory) return;
199  EDepSim::Trajectory* second = (EDepSim::Trajectory*)secondTrajectory;
200  G4int ent = second->GetPointEntries();
201  // initial point of the second trajectory should not be merged
202  for(G4int i=1; i<ent; ++i) {
203  fPositionRecord->push_back((*(second->fPositionRecord))[i]);
204  }
205  delete (*second->fPositionRecord)[0];
206  second->fPositionRecord->clear();
207 }
TrajectoryPointContainer * fPositionRecord
virtual int GetPointEntries() const
Get the number of trajectory points saved with this trajectory.
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
void EDepSim::Trajectory::operator delete ( void *  aTrajectory)
inline

Definition at line 149 of file EDepSimTrajectory.hh.

149  {
150  aTrajAllocator.FreeSingle((EDepSim::Trajectory*)aTrajectory);
151 }
G4DLLIMPORT G4Allocator< EDepSim::Trajectory > aTrajAllocator
void * EDepSim::Trajectory::operator new ( size_t  )
inline

Definition at line 144 of file EDepSimTrajectory.hh.

144  {
145  void* aTrajectory = (void*) aTrajAllocator.MallocSingle();
146  return aTrajectory;
147 }
G4DLLIMPORT G4Allocator< EDepSim::Trajectory > aTrajAllocator
int EDepSim::Trajectory::operator== ( const EDepSim::Trajectory right) const
inline

Definition at line 38 of file EDepSimTrajectory.hh.

38  {
39  return (this==&right);
40  }
bool EDepSim::Trajectory::SaveTrajectory ( ) const
inline

Check if this trajectory should be saved.

Definition at line 101 of file EDepSimTrajectory.hh.

101 { return fSaveTrajectory;}

Member Data Documentation

G4ThreeVector EDepSim::Trajectory::fInitialMomentum
private

Definition at line 131 of file EDepSimTrajectory.hh.

G4int EDepSim::Trajectory::fParentID
private

Definition at line 126 of file EDepSimTrajectory.hh.

G4String EDepSim::Trajectory::fParticleName
private

Definition at line 129 of file EDepSimTrajectory.hh.

G4double EDepSim::Trajectory::fPDGCharge
private

Definition at line 128 of file EDepSimTrajectory.hh.

G4int EDepSim::Trajectory::fPDGEncoding
private

Definition at line 127 of file EDepSimTrajectory.hh.

TrajectoryPointContainer* EDepSim::Trajectory::fPositionRecord
private

Definition at line 124 of file EDepSimTrajectory.hh.

G4String EDepSim::Trajectory::fProcessName
private

Definition at line 130 of file EDepSimTrajectory.hh.

bool EDepSim::Trajectory::fSaveTrajectory
private

Definition at line 135 of file EDepSimTrajectory.hh.

G4double EDepSim::Trajectory::fSDEnergyDeposit
private

Definition at line 132 of file EDepSimTrajectory.hh.

G4double EDepSim::Trajectory::fSDLength
private

Definition at line 134 of file EDepSimTrajectory.hh.

G4double EDepSim::Trajectory::fSDTotalEnergyDeposit
private

Definition at line 133 of file EDepSimTrajectory.hh.

G4int EDepSim::Trajectory::fTrackID
private

Definition at line 125 of file EDepSimTrajectory.hh.


The documentation for this class was generated from the following files: