GGS(GenericGEANT4Simulation)Software  2.6.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
GGSTHits.cpp
Go to the documentation of this file.
1 /*
2  * GGSTHits.cpp
3  *
4  * Created on: 17 Aug 2011
5  * Author: Nicola Mori
6  */
7 
11 
12 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
13 /* ******************************* *
14  * GGSTPosHit class implementation *
15  * ******************************* */
16 
17 ClassImp(GGSTPosHit)
18 
19 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
20 
22  TObject(), eDep(0.), time(0.), pathLength(0.), startEnergy(0.) {
23 
24  startPoint[0] = startPoint[1] = startPoint[2] = 0.;
25  endPoint[0] = endPoint[1] = endPoint[2] = 0.;
26  startMomentum[0] = startMomentum[1] = startMomentum[2] = 0.;
27 }
28 
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 
31 void GGSTPosHit::Clear(Option_t *) {
32  eDep = 0.;
33  time = 0.;
34  pathLength = 0.;
35  startPoint[0] = startPoint[1] = startPoint[2] = 0.;
36  endPoint[0] = endPoint[1] = endPoint[2] = 0.;
37  startMomentum[0] = startMomentum[1] = startMomentum[2] = 0.;
38  startEnergy = 0.;
39 }
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
44 
45  if (this != &right) {
46  eDep = right.eDep;
47  time = right.time;
48  pathLength = right.pathLength;
49  startPoint[0] = right.startPoint[0];
50  startPoint[1] = right.startPoint[1];
51  startPoint[2] = right.startPoint[2];
52  endPoint[0] = right.endPoint[0];
53  endPoint[1] = right.endPoint[1];
54  endPoint[2] = right.endPoint[2];
55  startMomentum[0] = right.startMomentum[0];
56  startMomentum[1] = right.startMomentum[1];
57  startMomentum[2] = right.startMomentum[2];
58  startEnergy = right.startEnergy;
59  }
60  return *this;
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 /* ******************************* *
65  * GGSTPartHit class implementation *
66  * ******************************* */
67 
68 ClassImp(GGSTPartHit)
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73  TObject(), eDep(0.), time(0.), pathLength(0.), entranceEnergy(0.), trackID(-1), parentID(-2), particlePdg(0), _posHits(
74  NULL), _posHitIndex(0) {
75 
76  entrancePoint[0] = entrancePoint[1] = entrancePoint[2] = 0.;
77  exitPoint[0] = exitPoint[1] = exitPoint[2] = 0.;
78  entranceMomentum[0] = entranceMomentum[1] = entranceMomentum[2] = 0.;
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84  // Position hits array is managed externally (by GGSTClonesArrayService during the
85  // transient->persistent transformation in GGSHitsAction or by the TObjArray container
86  // during data readout). So it must not be destroyed here.
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
91 void GGSTPartHit::Clear(Option_t *) {
92  eDep = 0.;
93  time = 0.;
94  pathLength = 0.;
95  entrancePoint[0] = entrancePoint[1] = entrancePoint[2] = 0.;
96  exitPoint[0] = exitPoint[1] = exitPoint[2] = 0.;
98  trackID = -1;
99  parentID = -2;
100  particlePdg = 0;
101  if (_posHits)
102  _posHits->Clear("C");
103  _posHitIndex = 0;
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
107 
108 /*
109  * Assignment operator: commented out because of this:
110  *
111  * TODO: How to handle the posHits array?
112  *
113  * 1) Copy address: does not create an independent partHit
114  * 2) Allocate a new one and fill: would need a delete in destructor, but it should not delete
115  * when the posHit is the one read from Root file
116  *
117 
118  const GGSTPartHit& GGSTPartHit::operator=(const GGSTPartHit& right) {
119 
120  if (this != &right) {
121  eDep = right.eDep;
122  time = right.time;
123  pathLength = right.pathLength;
124  entrancePoint[0] = right.entrancePoint[0];
125  entrancePoint[1] = right.entrancePoint[1];
126  entrancePoint[2] = right.entrancePoint[2];
127  exitPoint[0] = right.exitPoint[0];
128  exitPoint[1] = right.exitPoint[1];
129  exitPoint[2] = right.exitPoint[2];
130  entranceMomentum[0] = right.entranceMomentum[0];
131  entranceMomentum[1] = right.entranceMomentum[1];
132  entranceMomentum[2] = right.entranceMomentum[2];
133  trackID = right.trackID;
134  parentID = right.parentID;
135  particlePdg = right.particlePdg;
136 
137  }
138 
139  return *this;
140  }
141  */
142 
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
144 #include <iostream>
145 
147  std::cout << "+++++++ GGSTPartHit::Dump +++++++\n";
148  std::cout << " trackID: " << trackID << "\n";
149  std::cout << " parentID: " << parentID << "\n";
150  std::cout << " particlePdg: " << particlePdg << "\n";
151  std::cout << " -------------\n";
152  std::cout << " eDep: " << eDep << "\n";
153  std::cout << " time: " << time << "\n";
154  std::cout << " pathLength: " << pathLength << "\n";
155  std::cout << " time: " << time << "\n";
156  std::cout << " entrancePoint: " << entrancePoint[0] << " " << entrancePoint[1] << " " << entrancePoint[2] << "\n";
157  std::cout << " exitPoint: " << exitPoint[0] << " " << exitPoint[1] << " " << exitPoint[2] << "\n";
158  std::cout << " entranceMomentum: " << entranceMomentum[0] << " " << entranceMomentum[1] << " " << entranceMomentum[2]
159  << "\n";
160 
161  std::cout << "+++++++++++++++++++++++++++++++++\n" << std::endl;
162 }
163 
164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165 
167  if (_posHits)
168  return (_posHits->GetEntries());
169  else
170  return 0;
171 }
172 
173 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
174 
175 GGSTPosHit *GGSTPartHit::GetPosHit(unsigned int iHit) {
176  static GGSTPosHit *hit = NULL;
177  if (_posHits) {
178  hit = (GGSTPosHit*) (_posHits->At(iHit));
179  return hit;
180  }
181  return NULL;
182 }
183 
184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
185 /* ******************************* *
186  * GGSTIntHit class implementation *
187  * ******************************* */
188 
189 ClassImp(GGSTIntHit)
190 
191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
192 
194  TObject(), eDep(0.), eDepTimeBin(), time(0), _volumeIndex(0), _partHits(NULL), _hitDetInfo(NULL), _hitVolInfo(NULL) {
195 }
196 
197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
198 
200  // Particle hits array is managed externally (by GGSTClonesArrayService during the
201  // transient->persistent transformation in GGSHitsAction or by the TObjArray container
202  // during data readout). So it must not be destroyed here.
203 }
204 
205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
206 
207 void GGSTIntHit::Clear(Option_t *) {
208  eDep = 0.;
209  eDepTimeBin.Reset();
210  time = 0.;
211  _volumeIndex = 0;
212  if (_partHits)
213  _partHits->Clear("C");
214 }
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217 /*
218  * Assignment operator: commented out because of this:
219  *
220  * TODO: How to handle the partHits array?
221  *
222  * 1) Copy address: does not create an independent intHit
223  * 2) Allocate a new one and fill: would need a delete in destructor, but it should not delete
224  * when the partHit is the one read from Root file
225  *
226  const GGSTIntHit& GGSTIntHit::operator=(const GGSTIntHit& right) {
227 
228  eDep = right.eDep;
229  eDepTimeBin = right.eDepTimeBin;
230  time = right.time;
231  pathLength = right.pathLength;
232  volumeName = right.volumeName;
233 
234  return *this;
235  }
236  */
237 
238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
240  if (_partHits)
241  return (_partHits->GetEntries());
242  else
243  return 0;
244 }
245 
246 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
247 
248 GGSTPartHit *GGSTIntHit::GetPartHit(unsigned int iHit) {
249  static GGSTPartHit *hit = NULL;
250  if (_partHits) {
251  hit = (GGSTPartHit*) (_partHits->At(iHit));
252  return hit;
253  }
254  return NULL;
255 }
256 
257 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Float_t startMomentum[3]
Start momentum.
Definition: GGSTHits.h:42
Float_t eDep
Total deposited energy.
Definition: GGSTHits.h:37
~GGSTIntHit()
Destructor.
Definition: GGSTHits.cpp:199
Float_t time
Time of the hit.
Definition: GGSTHits.h:38
void DumpHit()
Prints members values on standard output.
Definition: GGSTHits.cpp:146
void Clear(Option_t *)
Resets data members.
Definition: GGSTHits.cpp:31
GGSTPosHit * GetPosHit(unsigned int iHit)
Get the specified position hit.
Definition: GGSTHits.cpp:175
Float_t pathLength
Path length of the hit.
Definition: GGSTHits.h:39
Float_t eDep
Deposited energy (transient).
Definition: GGSTHits.h:164
Float_t startEnergy
Start kinetic energy.
Definition: GGSTHits.h:43
Float_t entrancePoint[3]
Entrance point.
Definition: GGSTHits.h:88
Float_t time
Time of the hit.
Definition: GGSTHits.h:86
Float_t pathLength
Path length of the hit.
Definition: GGSTHits.h:87
Class to store G4 particle hits.
Definition: GGSTHits.h:82
Int_t trackID
GEANT4 track ID.
Definition: GGSTHits.h:92
void Clear(Option_t *)
Resets data members.
Definition: GGSTHits.cpp:91
~GGSTPartHit()
Destructor.
Definition: GGSTHits.cpp:83
Float_t time
Time of the hit (in ns).
Definition: GGSTHits.h:166
Float_t eDep
Deposited energy.
Definition: GGSTHits.h:85
void Clear(Option_t *)
Resets data members.
Definition: GGSTHits.cpp:207
const GGSTPosHit & operator=(const GGSTPosHit &)
Assignment operator.
Definition: GGSTHits.cpp:43
Int_t GetNPartHits()
Gets the number of particle hits.
Definition: GGSTHits.cpp:239
Class to store G4 position hits.
Definition: GGSTHits.h:34
TArrayF eDepTimeBin
Energy deposit in each time bin.
Definition: GGSTHits.h:165
Class to store G4 position hits.
Definition: GGSTHits.h:160
Int_t particlePdg
Particle PDG ID.
Definition: GGSTHits.h:94
Float_t startPoint[3]
Start point.
Definition: GGSTHits.h:40
Float_t exitPoint[3]
Exit point.
Definition: GGSTHits.h:89
Int_t GetNPosHits()
Gets the number of position hits.
Definition: GGSTHits.cpp:166
Int_t parentID
GEANT4 parent ID.
Definition: GGSTHits.h:93
Float_t entranceMomentum[3]
Entrance momentum.
Definition: GGSTHits.h:90
GGSTPartHit * GetPartHit(unsigned int iHit)
Get the specified particle hit.
Definition: GGSTHits.cpp:248
Float_t endPoint[3]
End point.
Definition: GGSTHits.h:41