GGS(GenericGEANT4Simulation)Software  2.7.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 UserInit (G4Step *aStep)
 User initialization of hit global properties. 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 32 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.

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

Copy constructor.

Parameters
rightThe object to be copied into current one.

Definition at line 22 of file GGSIntHit.cpp.

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

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 93 of file GGSIntHit.cpp.

93  {
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 }
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 232 of file GGSIntHit.h.

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

Energy release getter.

Returns
The energy release for each time bin.

Definition at line 188 of file GGSIntHit.h.

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

Getter for volume ID.

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

Definition at line 238 of file GGSIntHit.h.

238 { return _id; }
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 226 of file GGSIntHit.h.

226 { return _partHits; }
G4double GGSIntHit::GetPathLength ( ) const
inline

Path length getter.

Returns
The total path length of particles traversing the volume.

Definition at line 212 of file GGSIntHit.h.

212 { return _pathLength; }
G4double GGSIntHit::GetTime ( ) const
inline

Time getter.

Returns
The time of first energy deposit.

Definition at line 194 of file GGSIntHit.h.

194 { return _time; }
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 206 of file GGSIntHit.h.

206 { return _timeBins; }
G4double GGSIntHit::GetTotalEnergyDep ( ) const
inline

Energy release getter.

Returns
The total energy release.

Definition at line 182 of file GGSIntHit.h.

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

Getter for volume.

Returns
The physical volume associated to the hit.

Definition at line 218 of file GGSIntHit.h.

218 { return _volume; }
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 271 of file GGSIntHit.h.

271 { GGSIntHitAllocator->FreeSingle((GGSIntHit *)aHit); }
G4Allocator< GGSIntHit > * GGSIntHitAllocator
Alias for G4 template memory allocator for GGSIntHit.
Definition: GGSIntHit.cpp:7
Definition of GGS Integrated Hit.
Definition: GGSIntHit.h:32
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 263 of file GGSIntHit.h.

263  {
264  void *aHit;
265  aHit = (void *)GGSIntHitAllocator->MallocSingle();
266  return aHit;
267 }
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 41 of file GGSIntHit.cpp.

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

Comparison operator.

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

Definition at line 63 of file GGSIntHit.cpp.

63  {
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 }
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 144 of file GGSIntHit.h.

144 { _absTranslation = pos; }
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 176 of file GGSIntHit.h.

176 { _id = id; }
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 132 of file GGSIntHit.cpp.

132  {
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 }
G4THitsCollection< GGSPartHit > GGSPartHitsCollection
Alias for G4 template hits collection for GGSPartHit.
Definition: GGSPartHit.h:238
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 114 of file GGSIntHit.cpp.

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

Setter for volume.

Parameters
nameThe physical volume associated to the hit.

Definition at line 109 of file GGSIntHit.h.

109 { _volume = volume; }
virtual void GGSIntHit::UserInit ( G4Step *  aStep)
inlinevirtual

User initialization of hit global properties.

This method is called by GGSIntHitSD after initializing the hit object just after its creation, before calling AddStep. Users can override this method in custom hit classes to perform additional custom initialization. The #aStep argument is the simulation step at which the hit is created.

Parameters
aStepThe step at which the hit has been created.

Definition at line 89 of file GGSIntHit.h.

89 { GGS_IGNORE_VAR(aStep); }
void GGS_IGNORE_VAR(const T &)
Small utility to avoid compiler warnings for unused methods.
Definition: GGSMiscUtils.h:14

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