GGS(GenericGEANT4Simulation)Software  2.7.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
GGSIntHit.h
Go to the documentation of this file.
1 /*
2  * GGSIntHit.h
3  *
4  * Created on: 2010-10-17
5  * Authors: Franz Longo , Elena Vannuccini
6  */
7 
10 #ifndef GGSINTHIT_H
11 #define GGSINTHIT_H
12 
13 #include "G4Allocator.hh"
14 #include "G4THitsCollection.hh"
15 #include "G4ThreeVector.hh"
16 #include "G4VHit.hh"
17 #include "G4VPhysicalVolume.hh"
18 
20 #include "utils/GGSFactory.h"
21 #include "utils/GGSMiscUtils.h"
22 
23 #include <numeric>
24 
32 class GGSIntHit : public G4VHit {
33 public:
38  GGSIntHit(const std::vector<G4double> &timeBins);
39 
41  ~GGSIntHit();
42 
47  GGSIntHit(const GGSIntHit &right);
48 
54  const GGSIntHit &operator=(const GGSIntHit &right);
55 
61  int operator==(const GGSIntHit &right) const;
62 
70  inline void *operator new(size_t size);
71 
79  inline void operator delete(void *aHit);
80 
89  virtual void UserInit(G4Step *aStep) { GGS_IGNORE_VAR(aStep); }
90 
103  virtual void AddStep(const G4Step &step);
104 
109  void SetVolume(const G4VPhysicalVolume *volume) { _volume = volume; }
110 
124  void SetPosHitsStorage(bool flag);
125 
138  void SetPartHitsStorage(bool flag);
139 
144  void SetAbsTranslation(const G4ThreeVector &pos) { _absTranslation = pos; }
145 
176  void SetID(G4int id) { _id = id; }
177 
182  G4double GetTotalEnergyDep() const { return accumulate(_eDep.begin(), _eDep.end(), 0.); }
183 
188  const std::vector<G4double> &GetEnergyDep() const { return _eDep; }
189 
194  G4double GetTime() const { return _time; }
195 
206  const std::vector<G4double> &GetTimeBins() const { return _timeBins; }
207 
212  G4double GetPathLength() const { return _pathLength; }
213 
218  const G4VPhysicalVolume *GetVolume() { return _volume; }
219 
226  GGSPartHitsCollection *GetPartHits() { return _partHits; }
227 
232  const G4ThreeVector &GetAbsTranslation() { return _absTranslation; }
233 
238  G4int GetID() { return _id; }
239 
240 protected:
241  std::vector<G4double> _eDep; // Deposited energy
242  std::vector<G4double> _timeBins; // Time bins
243  G4double _time; // Time of first energy release
244  G4double _pathLength; // Path length of the Hit
245  const G4VPhysicalVolume *_volume;
246  G4ThreeVector _absTranslation;
247  G4int _id;
248 
249  bool _isReset;
250  GGSPartHitsCollection *_partHits;
251  bool _storePosHits;
252 };
253 
254 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
256 typedef G4THitsCollection<GGSIntHit> GGSIntHitsCollection;
257 
259 extern G4Allocator<GGSIntHit> *GGSIntHitAllocator;
260 
261 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
262 
263 inline void *GGSIntHit::operator new(size_t) {
264  void *aHit;
265  aHit = (void *)GGSIntHitAllocator->MallocSingle();
266  return aHit;
267 }
268 
269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
270 
271 inline void GGSIntHit::operator delete(void *aHit) { GGSIntHitAllocator->FreeSingle((GGSIntHit *)aHit); }
272 
273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
274 
275 #include "utils/GGSFactory.h"
276 
279 
280 #define RegisterIntHit(className) \
281  GGSIntHit *className##Builder(const std::vector<G4double> &timeBins) { return new className(timeBins); } \
282  class className##Proxy { \
283  public: \
284  className##Proxy() { GGSIntHitFactory::GetInstance().RegisterBuilder(#className, className##Builder); } \
285  }; \
286  className##Proxy proxyFor##className
287 #endif /* GGSINTHIT_H */
G4double GetTotalEnergyDep() const
Energy release getter.
Definition: GGSIntHit.h:182
virtual void AddStep(const G4Step &step)
Adds a step to the particle hit.
Definition: GGSIntHit.cpp:93
const G4ThreeVector & GetAbsTranslation()
Getter of absolute position of sensitive element.
Definition: GGSIntHit.h:232
G4Allocator< GGSIntHit > * GGSIntHitAllocator
Alias for G4 template memory allocator for GGSIntHit.
Definition: GGSIntHit.cpp:7
~GGSIntHit()
Destructor.
Definition: GGSIntHit.cpp:18
GGSPartHitsCollection * GetPartHits()
Getter of container of particle hits.
Definition: GGSIntHit.h:226
const std::vector< G4double > & GetTimeBins() const
Time bins getter.
Definition: GGSIntHit.h:206
void SetAbsTranslation(const G4ThreeVector &pos)
Set the position in global coordinates of the sensitive element.
Definition: GGSIntHit.h:144
void SetPosHitsStorage(bool flag)
Turn on or off the storage of position hits.
Definition: GGSIntHit.cpp:114
const G4VPhysicalVolume * GetVolume()
Getter for volume.
Definition: GGSIntHit.h:218
void GGS_IGNORE_VAR(const T &)
Small utility to avoid compiler warnings for unused methods.
Definition: GGSMiscUtils.h:14
G4double GetPathLength() const
Path length getter.
Definition: GGSIntHit.h:212
const GGSIntHit & operator=(const GGSIntHit &right)
Assignment operator.
Definition: GGSIntHit.cpp:41
virtual void UserInit(G4Step *aStep)
User initialization of hit global properties.
Definition: GGSIntHit.h:89
Template factory class.
Definition: GGSFactory.h:29
G4int GetID()
Getter for volume ID.
Definition: GGSIntHit.h:238
void SetID(G4int id)
Setter for volume ID.
Definition: GGSIntHit.h:176
G4double GetTime() const
Time getter.
Definition: GGSIntHit.h:194
GGSIntHit(const std::vector< G4double > &timeBins)
Constructor.
Definition: GGSIntHit.cpp:12
void SetVolume(const G4VPhysicalVolume *volume)
Setter for volume.
Definition: GGSIntHit.h:109
G4THitsCollection< GGSIntHit > GGSIntHitsCollection
Alias for G4 template hits collection for GGSIntHit.
Definition: GGSIntHit.h:256
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
const std::vector< G4double > & GetEnergyDep() const
Energy release getter.
Definition: GGSIntHit.h:188
void SetPartHitsStorage(bool flag)
Turn on or off the storage of particle hits.
Definition: GGSIntHit.cpp:132