GGS(GenericGEANT4Simulation)Software  2.7.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
GGSPartHit.cpp
1 // ************************************************************
2 
3 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
4 
6 
7 G4Allocator<GGSPartHit> GGSPartHitAllocator;
8 RegisterPartHit(GGSPartHit);
9 
10 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
11 
13  : _eDep(0.), _time(-1.), _pathLength(0.), _entrancePoint(0., 0., 0.), _exitPoint(0., 0., 0.),
14  _entranceMomentum(0., 0., 0.), _entranceEnergy(0.), _trackID(-1), _parentID(-2), _particlePdg(0), _isReset(true),
15  _posHits(NULL) {}
16 
17 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
18 
19 GGSPartHit::~GGSPartHit() { delete _posHits; }
20 
21 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
22 
23 GGSPartHit::GGSPartHit(const GGSPartHit &right) : G4VHit() {
24  _eDep = right._eDep;
25  _time = right._time;
26  _pathLength = right._pathLength;
27  _entrancePoint = right._entrancePoint;
28  _exitPoint = right._exitPoint;
29  _entranceMomentum = right._entranceMomentum;
30  _entranceEnergy = right._entranceEnergy;
31  _trackID = right._trackID;
32  _parentID = right._parentID;
33  _particlePdg = right._particlePdg;
34  _isReset = right._isReset;
35 
36  if (right._posHits == NULL) {
37  _posHits = NULL;
38  } else
39  _posHits = new GGSPosHitsCollection(*right._posHits);
40 }
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
43 
45  if (this != &right) {
46  _eDep = right._eDep;
47  _time = right._time;
48  _pathLength = right._pathLength;
49  _entrancePoint = right._entrancePoint;
50  _exitPoint = right._exitPoint;
51  _entranceMomentum = right._entranceMomentum;
52  _entranceEnergy = right._entranceEnergy;
53  _trackID = right._trackID;
54  _parentID = right._parentID;
55  _particlePdg = right._particlePdg;
56  _isReset = right._isReset;
57  if (right._posHits == NULL) {
58  delete _posHits;
59  _posHits = NULL;
60  } else
61  *_posHits = *(right._posHits);
62  }
63  return *this;
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
67 
68 bool GGSPartHit::operator==(const GGSPartHit &right) const {
69  if ((_eDep == right._eDep) && //
70  (_time == right._time) && //
71  (_pathLength == right._pathLength) && //
72  (_entrancePoint == right._entrancePoint) && //
73  (_exitPoint == right._exitPoint) && //
74  (_entranceMomentum == right._entranceMomentum) && //
75  (_entranceEnergy == right._entranceEnergy) && //
76  (_trackID == right._trackID) && //
77  (_parentID == right._parentID) && //
78  (_particlePdg == right._particlePdg)) {
79 
80  if (_posHits != NULL) {
81  if (right._posHits != NULL) {
82  return (*_posHits == *(right._posHits));
83  }
84 
85  else {
86  return false;
87  }
88  } else {
89  if (right._posHits != NULL) {
90  return false;
91  } else {
92  return true;
93  }
94  }
95  } else
96  return false;
97 }
98 
99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
100 
101 void GGSPartHit::AddStep(const G4Step &step) {
102  _eDep += step.GetTotalEnergyDeposit();
103  _pathLength += step.GetStepLength();
104  _exitPoint = step.GetPostStepPoint()->GetPosition();
105 
106  if (_isReset) {
107  // First step for this particle hit: store initial values
108  _isReset = false;
109  _time = step.GetPreStepPoint()->GetGlobalTime();
110  _entrancePoint = step.GetPreStepPoint()->GetPosition();
111  _entranceMomentum = step.GetPreStepPoint()->GetMomentum();
112  _entranceEnergy = step.GetPreStepPoint()->GetKineticEnergy();
113  _trackID = step.GetTrack()->GetTrackID();
114  _parentID = step.GetTrack()->GetParentID();
115  _particlePdg = step.GetTrack()->GetDefinition()->GetPDGEncoding();
116  }
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
120 
122 
123  if (flag == true) {
124  if (!_posHits)
125  _posHits = new GGSPosHitsCollection;
126  } else {
127  if (_posHits) {
128  delete _posHits;
129  _posHits = NULL;
130  }
131  }
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4THitsCollection< GGSPosHit > GGSPosHitsCollection
Alias for G4 template hits collection for GGSPosHit.
Definition: GGSPosHit.h:194
virtual void AddStep(const G4Step &step)
Adds a step to the particle hit.
Definition: GGSPartHit.cpp:101
GGSPartHit()
Constructor.
Definition: GGSPartHit.cpp:12
bool operator==(const GGSPartHit &right) const
Comparison operator.
Definition: GGSPartHit.cpp:68
Definition of GGS Particle Hit.
Definition: GGSPartHit.h:36
~GGSPartHit()
Destructor.
Definition: GGSPartHit.cpp:19
void SetPosHitsStorage(bool flag)
Turn on or off the storage of position hits.
Definition: GGSPartHit.cpp:121
const GGSPartHit & operator=(const GGSPartHit &right)
Assignment operator.
Definition: GGSPartHit.cpp:44
G4Allocator< GGSPartHit > GGSPartHitAllocator
Alias for G4 template memory allocator for GGSPartHit.
Definition: GGSPartHit.cpp:7