GGS(GenericGEANT4Simulation)Software  2.6.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Protected Attributes
GGSIntHit Class Reference

Definition of GGS Integrated Hit. More...

#include <GGSIntHit.h>

Inheritance diagram for GGSIntHit:
Inheritance graph
[legend]
Collaboration diagram for GGSIntHit:
Collaboration graph
[legend]

Public Member Functions

 GGSIntHit (const std::vector< G4double > &timeBins)
 Constructor. More...
 
 ~GGSIntHit ()
 Destructor.
 
 GGSIntHit (const GGSIntHit &right)
 Copy constructor. More...
 
const GGSIntHitoperator= (const GGSIntHit &right)
 Assignment operator. More...
 
int operator== (const GGSIntHit &right) const
 Comparison operator. More...
 
void * operator new (size_t size)
 Operator new. More...
 
void operator delete (void *aHit)
 Operator delete. More...
 
virtual void AddStep (const G4Step &step)
 Adds a step to the particle hit. More...
 
void SetVolume (const G4VPhysicalVolume *volume)
 Setter for volume. More...
 
void SetPosHitsStorage (bool flag)
 Turn on or off the storage of position hits. More...
 
void SetPartHitsStorage (bool flag)
 Turn on or off the storage of particle hits. More...
 
void SetAbsTranslation (const G4ThreeVector &pos)
 Set the position in global coordinates of the sensitive element. More...
 
void SetID (G4int id)
 Setter for volume ID. More...
 
G4double GetTotalEnergyDep () const
 Energy release getter. More...
 
const std::vector< G4double > & GetEnergyDep () const
 Energy release getter. More...
 
G4double GetTime () const
 Time getter. More...
 
const std::vector< G4double > & GetTimeBins () const
 Time bins getter. More...
 
G4double GetPathLength () const
 Path length getter. More...
 
const G4VPhysicalVolume * GetVolume ()
 Getter for volume. More...
 
GGSPartHitsCollectionGetPartHits ()
 Getter of container of particle hits. More...
 
const G4ThreeVector & GetAbsTranslation ()
 Getter of absolute position of sensitive element. More...
 
G4int GetID ()
 Getter for volume ID. More...
 

Protected Attributes

std::vector< G4double > _eDep
 
std::vector< G4double > _timeBins
 
G4double _time
 
G4double _pathLength
 
const G4VPhysicalVolume * _volume
 
G4ThreeVector _absTranslation
 
G4int _id
 
bool _isReset
 
GGSPartHitsCollection_partHits
 
bool _storePosHits
 

Detailed Description

Definition of GGS Integrated Hit.

An integrated hits is associated to a sensitive physical volume. It carries informations about the whole energy released on that volume by all the particles traversing it during an event.

Definition at line 31 of file GGSIntHit.h.

Constructor & Destructor Documentation

GGSIntHit::GGSIntHit ( const std::vector< G4double > &  timeBins)

Constructor.

Parameters
timeBinsThe time bins in which integrated hits will be accumulated.

Definition at line 12 of file GGSIntHit.cpp.

12  :
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 }
GGSIntHit::GGSIntHit ( const GGSIntHit right)

Copy constructor.

Parameters
rightThe object to be copied into current one.

Definition at line 26 of file GGSIntHit.cpp.

26  :
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 }
G4THitsCollection< GGSPartHit > GGSPartHitsCollection
Alias for G4 template hits collection for GGSPartHit.
Definition: GGSPartHit.h:259

Member Function Documentation

void GGSIntHit::AddStep ( const G4Step &  step)
virtual

Adds a step to the particle hit.

This method adds a step to the integrated hit. The integrated hit integral quantities (scoring value and path length) will be incremented by the corresponding step quantities.

If SetPartHitsStorage has been previously called to enable the storage of particle hits, then the step will be added also to its corresponding particle hit object. The same for SetPosHitsStorage relatively to storage of position hits.

Parameters
stepThe step to be added.

Definition at line 104 of file GGSIntHit.cpp.

104  {
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 }
const G4ThreeVector& GGSIntHit::GetAbsTranslation ( )
inline

Getter of absolute position of sensitive element.

Returns
The position of the sensitive element associated to the hit in global coordinates.

Definition at line 242 of file GGSIntHit.h.

242  {
243  return _absTranslation;
244  }
const std::vector<G4double>& GGSIntHit::GetEnergyDep ( ) const
inline

Energy release getter.

Returns
The energy release for each time bin.

Definition at line 186 of file GGSIntHit.h.

186  {
187  return _eDep;
188  }
G4int GGSIntHit::GetID ( )
inline

Getter for volume ID.

Returns
The ID of the volume (i.e., touchable) associated to the hit.

Definition at line 250 of file GGSIntHit.h.

250  {
251  return _id;
252  }
GGSPartHitsCollection* GGSIntHit::GetPartHits ( )
inline

Getter of container of particle hits.

Returns
pointer to the particle hit container (NULL if storage of particle hits has not been previously turned on by calling SetPartHitsStorage).

Definition at line 234 of file GGSIntHit.h.

234  {
235  return _partHits;
236  }
G4double GGSIntHit::GetPathLength ( ) const
inline

Path length getter.

Returns
The total path length of particles traversing the volume.

Definition at line 216 of file GGSIntHit.h.

216  {
217  return _pathLength;
218  }
G4double GGSIntHit::GetTime ( ) const
inline

Time getter.

Returns
The time of first energy deposit.

Definition at line 194 of file GGSIntHit.h.

194  {
195  return _time;
196  }
const std::vector<G4double>& GGSIntHit::GetTimeBins ( ) const
inline

Time bins getter.

The returned vector contains the time bins. Element 0 is the ending time of first bin (which always starts at time 0); last element is the ending time of last bin but one, which corresponds to start time of last bin (last bin always ends at the end of event).

Returns
The time binning for energy deposit.

Definition at line 208 of file GGSIntHit.h.

208  {
209  return _timeBins;
210  }
G4double GGSIntHit::GetTotalEnergyDep ( ) const
inline

Energy release getter.

Returns
The total energy release.

Definition at line 178 of file GGSIntHit.h.

178  {
179  return accumulate(_eDep.begin(), _eDep.end(), 0.);
180  }
const G4VPhysicalVolume* GGSIntHit::GetVolume ( )
inline

Getter for volume.

Returns
The physical volume associated to the hit.

Definition at line 224 of file GGSIntHit.h.

224  {
225  return _volume;
226  }
void GGSIntHit::operator delete ( void *  aHit)
inline

Operator delete.

This implementation uses G4Allocator.

Parameters
aHitThe current hit to be deleted.
See Also
GGSIntHitAllocator.

Definition at line 287 of file GGSIntHit.h.

287  {
288  GGSIntHitAllocator->FreeSingle((GGSIntHit*) aHit);
289 }
G4Allocator< GGSIntHit > * GGSIntHitAllocator
Alias for G4 template memory allocator for GGSIntHit.
Definition: GGSIntHit.cpp:7
Definition of GGS Integrated Hit.
Definition: GGSIntHit.h:31
void * GGSIntHit::operator new ( size_t  size)
inline

Operator new.

This implementation uses G4Allocator.

Parameters
sizeUnused (needed by the interface).
See Also
GGSIntHitAllocator.

Definition at line 279 of file GGSIntHit.h.

279  {
280  void* aHit;
281  aHit = (void*) GGSIntHitAllocator->MallocSingle();
282  return aHit;
283 }
G4Allocator< GGSIntHit > * GGSIntHitAllocator
Alias for G4 template memory allocator for GGSIntHit.
Definition: GGSIntHit.cpp:7
const GGSIntHit & GGSIntHit::operator= ( const GGSIntHit right)

Assignment operator.

Parameters
rightThe object to be assigned to current one.
Returns
The new current object.

Definition at line 47 of file GGSIntHit.cpp.

47  {
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 }
int GGSIntHit::operator== ( const GGSIntHit right) const

Comparison operator.

Parameters
rightRHS of comparison.
Returns
true if LHS==RHS.

Definition at line 70 of file GGSIntHit.cpp.

70  {
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 }
void GGSIntHit::SetAbsTranslation ( const G4ThreeVector &  pos)
inline

Set the position in global coordinates of the sensitive element.

Parameters
posAbsolute position of the sensitive element associated to the hit.

Definition at line 136 of file GGSIntHit.h.

136  {
137  _absTranslation = pos;
138  }
void GGSIntHit::SetID ( G4int  id)
inline

Setter for volume ID.

An integer identification code for the sensitive volume (i.e. touchable). For output on Root files with GGSRootFileService it is necessary that each volume have a unique (name, ID) pair. This ID must then be set appropriately in order to have a unique (name, ID) for each sensitive volume.

Replicated volumes as G4PVReplica produce many touchables (sensitive volumes), each with a different replica number. However, if a G4PVReplica is placed multiple times (via multiple placements of a G4PVPlacement whose associated logical volume is filled by the G4PVReplica) then all the touchables will have the name of the G4PVReplica, but they will not have different IDs since touchable 0 will have replica number equal to 0 in all its placements. Since it is not possible to manually set a different replica number for each touchable, the absolute ID must be computed in order to be unique for each touchable. As an example, the current implementation in GGSIntHitSD::ProcessHits uses the copy number of the mother G4PVPlacement in order to compute a unique ID for each touchable as:

ID = touchableCopyNumber + touchableMultiplicity*motherCopyNumber

In this way, a replicate volume with 10 touchables placed many times will generate ID=0 for the first placement of the first touchable and ID=10 for the second placement of the first touchable, and so on (as long as each G4PVPlacement have different copy number; this must be ensured by the user in the implementation of the geometry). This numbering scheme for replicated volumes may be reused by other sensitive detectors, although it is not mandatory as long as each sensitive touchable has a unique (name, ID) pair.

It is responsibility of the sensitive detector class to properly fill this field.

Parameters
IDThe ID of the volume (i.e., touchable) associated to the hit.

Definition at line 170 of file GGSIntHit.h.

170  {
171  _id = id;
172  }
void GGSIntHit::SetPartHitsStorage ( bool  flag)

Turn on or off the storage of particle hits.

Steps added to integrated hit by AddStep are by default not stored. This method enables or disables step storage as GGSPartHit objects (i.e., integration of steps over the sensitive volume for each particle).

Calling this method with "false" parameter will automatically disable position hits storage, i.e., it will call SetPosHitsStorage(false).

Parameters
flagif true, steps will be stored as particle hits.

Definition at line 144 of file GGSIntHit.cpp.

144  {
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 }
G4THitsCollection< GGSPartHit > GGSPartHitsCollection
Alias for G4 template hits collection for GGSPartHit.
Definition: GGSPartHit.h:259
void GGSIntHit::SetPosHitsStorage ( bool  flag)

Turn on or off the storage of position hits.

Steps can be stored as position hits. If this method is called with "true" parameter, each particle hit associated to the integrated hit will contain its related position hits.

Calling this method with "true" parameter will automatically enable particle hits storage, i.e., it will call SetPartHitsStorage(true).

Parameters
flagif true, steps will be stored as position hits.
See Also
SetPartHitsStorage
GGSPartHit::SetPosHitsStorage

Definition at line 125 of file GGSIntHit.cpp.

125  {
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 }
void SetPosHitsStorage(bool flag)
Turn on or off the storage of position hits.
Definition: GGSIntHit.cpp:125
void SetPartHitsStorage(bool flag)
Turn on or off the storage of particle hits.
Definition: GGSIntHit.cpp:144
void GGSIntHit::SetVolume ( const G4VPhysicalVolume *  volume)
inline

Setter for volume.

Parameters
nameThe physical volume associated to the hit.

Definition at line 99 of file GGSIntHit.h.

99  {
100  _volume = volume;
101  }

The documentation for this class was generated from the following files: