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