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