GGS(GenericGEANT4Simulation)Software  2.6.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
GGSIntHit.cpp
1 // ************************************************************
2 
3 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
4 
6 
7 G4Allocator<GGSIntHit> *GGSIntHitAllocator = new G4Allocator<GGSIntHit>;
8 RegisterIntHit(GGSIntHit);
9 
10 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
11 
12 GGSIntHit::GGSIntHit(const std::vector<G4double> &timeBins) :
13  _eDep(timeBins.size() + 1, 0.), _timeBins(timeBins), _time(-1.), _pathLength(0.), _volume(NULL), _absTranslation(0.,
14  0., 0.), _id(-1), _isReset(true), _partHits(
15  NULL), _storePosHits(false) {
16 }
17 
18 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
19 
21  delete _partHits;
22 }
23 
24 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
25 
27  G4VHit(), _timeBins(right._timeBins) {
28  _eDep = right._eDep;
29  _time = right._time;
30  _pathLength = right._pathLength;
31  _volume = right._volume;
32  _absTranslation = right._absTranslation;
33  _id = right._id;
34  _isReset = right._isReset;
35 
36  if (right._partHits == NULL) {
37  _partHits = NULL;
38  }
39  else
40  _partHits = new GGSPartHitsCollection(*right._partHits);
41 
42  _storePosHits = right._storePosHits;
43 }
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
46 
48  if (this != &right) {
49  _eDep = right._eDep;
50  _timeBins = right._timeBins;
51  _time = right._time;
52  _pathLength = right._pathLength;
53  _volume = right._volume;
54  _absTranslation = right._absTranslation;
55  _id = right._id;
56  _isReset = right._isReset;
57  if (right._partHits == NULL) {
58  delete _partHits;
59  _partHits = NULL;
60  }
61  else
62  *_partHits = *(right._partHits);
63  _storePosHits = right._storePosHits;
64  }
65  return *this;
66 }
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
69 
70 int GGSIntHit::operator==(const GGSIntHit& right) const {
71  if ((_eDep == right._eDep) && //
72  (_timeBins == right._timeBins) && //
73  (_time == right._time) && //
74  (_pathLength == right._pathLength) && //
75  (_volume == right._volume) && //
76  (_absTranslation == right._absTranslation) && //
77  (_id == right._id) && //
78  (_isReset == right._isReset)) {
79  if (_partHits != NULL) {
80  if (right._partHits != NULL) {
81  return (*_partHits == *(right._partHits));
82  }
83 
84  else {
85  return false;
86  }
87  }
88  else {
89  if (right._partHits != NULL) {
90  return false;
91  }
92  else {
93  return true;
94  }
95  }
96  }
97  else
98  return false;
99 
100 }
101 
102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
103 
104 void GGSIntHit::AddStep(const G4Step &step) {
105  static const std::string routineName("GGSIntHit::AddStep");
106  // Find current bin
107  unsigned int currBin = 0;
108  while (currBin < _eDep.size() - 1 && step.GetPreStepPoint()->GetGlobalTime() > _timeBins[currBin]) {
109  currBin++;
110  }
111 
112  // Increment energy deposit
113  _eDep[currBin] += step.GetTotalEnergyDeposit();
114  _pathLength += step.GetStepLength();
115 
116  if (_isReset) {
117  // First step for this integrated hit: store initial values
118  _isReset = false;
119  _time = step.GetPreStepPoint()->GetGlobalTime();
120  }
121 }
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
124 
126 
127  if (flag == true) {
128  _storePosHits = true;
129  SetPartHitsStorage(true);
130 
131  }
132  else {
133  _storePosHits = false;
134  if (_partHits) {
135  for (G4int i = 0; i < _partHits->entries(); i++) {
136  ((*_partHits)[i])->SetPosHitsStorage(false);
137  }
138  }
139  }
140 }
141 
142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
143 
145 
146  if (flag == true) {
147  if (!_partHits) {
148  _partHits = new GGSPartHitsCollection;
149  }
150  }
151  else {
152  _storePosHits = false;
153  delete _partHits;
154  _partHits = NULL;
155  }
156 }
157 
158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
virtual void AddStep(const G4Step &step)
Adds a step to the particle hit.
Definition: GGSIntHit.cpp:104
G4Allocator< GGSIntHit > * GGSIntHitAllocator
Alias for G4 template memory allocator for GGSIntHit.
Definition: GGSIntHit.cpp:7
~GGSIntHit()
Destructor.
Definition: GGSIntHit.cpp:20
void SetPosHitsStorage(bool flag)
Turn on or off the storage of position hits.
Definition: GGSIntHit.cpp:125
const GGSIntHit & operator=(const GGSIntHit &right)
Assignment operator.
Definition: GGSIntHit.cpp:47
GGSIntHit(const std::vector< G4double > &timeBins)
Constructor.
Definition: GGSIntHit.cpp:12
G4THitsCollection< GGSPartHit > GGSPartHitsCollection
Alias for G4 template hits collection for GGSPartHit.
Definition: GGSPartHit.h:259
Definition of GGS Integrated Hit.
Definition: GGSIntHit.h:31
int operator==(const GGSIntHit &right) const
Comparison operator.
Definition: GGSIntHit.cpp:70
void SetPartHitsStorage(bool flag)
Turn on or off the storage of particle hits.
Definition: GGSIntHit.cpp:144