Geant4  10.02.p03
CML2SDWithVoxels Class Reference

#include <ML2SDWithVoxels.hh>

Inheritance diagram for CML2SDWithVoxels:
Collaboration diagram for CML2SDWithVoxels:

Public Member Functions

 CML2SDWithVoxels (G4String name, G4int saving_in_ROG_Voxels_every_events, G4int seed, G4String ROGOutFile, G4bool bSaveROG, G4ThreeVector centre, G4ThreeVector halfSize, G4int NumberOfVoxelsAlongX, G4int NumberOfVoxelsAlongY, G4int NumberOfVoxelsAlongZ)
 
 ~CML2SDWithVoxels (void)
 
G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *ROHist)
 
void Initialize (G4HCofThisEvent *)
 
void EndOfEvent (G4HCofThisEvent *)
 
G4int getTotalNumberOfEvents ()
 
void setActive (G4bool act)
 
void save ()
 
void setRecycling (int recycling)
 
void setVolumeNameIdLink (std::vector< SvolumeNameId > volNameIdLink)
 
void resetVoxelsSingle ()
 
void setFullOutFileDataSingle (G4String val)
 
- Public Member Functions inherited from G4VSensitiveDetector
 G4VSensitiveDetector (G4String name)
 
 G4VSensitiveDetector (const G4VSensitiveDetector &right)
 
virtual ~G4VSensitiveDetector ()
 
G4VSensitiveDetectoroperator= (const G4VSensitiveDetector &right)
 
G4int operator== (const G4VSensitiveDetector &right) const
 
G4int operator!= (const G4VSensitiveDetector &right) const
 
virtual void clear ()
 
virtual void DrawAll ()
 
virtual void PrintAll ()
 
G4bool Hit (G4Step *aStep)
 
void SetROgeometry (G4VReadOutGeometry *value)
 
void SetFilter (G4VSDFilter *value)
 
G4int GetNumberOfCollections () const
 
G4String GetCollectionName (G4int id) const
 
void SetVerboseLevel (G4int vl)
 
void Activate (G4bool activeFlag)
 
G4bool isActive () const
 
G4String GetName () const
 
G4String GetPathName () const
 
G4String GetFullPathName () const
 
G4VReadOutGeometryGetROgeometry () const
 
G4VSDFilterGetFilter () const
 
virtual G4VSensitiveDetectorClone () const
 

Private Member Functions

void saveData (G4String Filename, Svoxel ***voxels)
 
G4int getIdFromVolumeName (G4String name)
 

Private Attributes

G4ThreeVector halfSize
 
G4ThreeVector centre
 
G4ThreeVector pos
 
G4double halfXVoxelDimensionX
 
G4double halfXVoxelDimensionY
 
G4double halfXVoxelDimensionZ
 
G4int NumberOfVoxelsAlongX
 
G4int NumberOfVoxelsAlongY
 
G4int NumberOfVoxelsAlongZ
 
Svoxel *** voxelsSum
 
Svoxel *** voxelsSingle
 
G4String fullOutFileData
 
G4String fullOutFileDataSingle
 
G4int nTotalEvents
 
G4int nSingleTotalEvents
 
G4int nParticle
 
G4int nParticleValatile
 
G4int saving_in_ROG_Voxels_every_events
 
G4int nRecycling
 
G4bool bActive
 
G4bool bSaveROG
 
G4double voxelMass
 
G4double density
 
G4double voxelVolume
 
std::vector< SvolumeNameIdvolumeNameIdLink
 

Additional Inherited Members

- Protected Member Functions inherited from G4VSensitiveDetector
virtual G4int GetCollectionID (G4int i)
 
- Protected Attributes inherited from G4VSensitiveDetector
G4CollectionNameVector collectionName
 
G4String SensitiveDetectorName
 
G4String thePathName
 
G4String fullPathName
 
G4int verboseLevel
 
G4bool active
 
G4VReadOutGeometryROgeometry
 
G4VSDFilterfilter
 

Detailed Description

Definition at line 55 of file ML2SDWithVoxels.hh.

Constructor & Destructor Documentation

◆ CML2SDWithVoxels()

CML2SDWithVoxels::CML2SDWithVoxels ( G4String  name,
G4int  saving_in_ROG_Voxels_every_events,
G4int  seed,
G4String  ROGOutFile,
G4bool  bSaveROG,
G4ThreeVector  centre,
G4ThreeVector  halfSize,
G4int  NumberOfVoxelsAlongX,
G4int  NumberOfVoxelsAlongY,
G4int  NumberOfVoxelsAlongZ 
)

Definition at line 49 of file ML2SDWithVoxels.cc.

54 {
56  bSaveROG=bROG;
57  bActive=true;
58  nParticle=0;
60  nTotalEvents=0;
62  density=1.;
63  voxelVolume=0.;
64  voxelMass=0.;
65  nRecycling=1;
66 
67  G4String seedName;
68  char a[10];
69  sprintf(a,"%d", seed);
70  seedName=(G4String)a;
71 
72  fullOutFileData=ROGOutFile+"_"+seedName+".txt";
74  if(bSaveROG)
75  {
76  centre=ctr;
77  halfSize=hSiz;
84 
86 
87 // voxels to store and save the sum of the geometry configurations
89  for (int ix=0; ix< NumberOfVoxelsAlongX; ix++)
90  {
92  for (int iy=0; iy< NumberOfVoxelsAlongY; iy++)
93  {
95  for (int iz=0; iz< NumberOfVoxelsAlongZ; iz++)
96  {
97  voxelsSum[ix][iy][iz].volumeId=-1;
98  voxelsSum[ix][iy][iz].depEnergy=0.;
99  voxelsSum[ix][iy][iz].depEnergy2=0.;
100  voxelsSum[ix][iy][iz].depEnergyNorm=0.;
101  voxelsSum[ix][iy][iz].depEnergyNormError=0.;
102  voxelsSum[ix][iy][iz].expDose=0.;
104  voxelsSum[ix][iy][iz].pos.set(2.*(ix)*halfXVoxelDimensionX -halfSize.getX()+halfXVoxelDimensionX + centre.getX(),
105  2.*(iy)*halfXVoxelDimensionY -halfSize.getY()+halfXVoxelDimensionY + centre.getY(),
106  2.*(iz)*halfXVoxelDimensionZ -halfSize.getZ()+halfXVoxelDimensionZ + centre.getZ());
107  voxelsSum[ix][iy][iz].nEvents=0;
108  }
109  }
110  }
111 
112 
113 // voxels to store and save the single geometry configuration
115  for (int ix=0; ix< NumberOfVoxelsAlongX; ix++)
116  {
118  for (int iy=0; iy< NumberOfVoxelsAlongY; iy++)
119  {
121  for (int iz=0; iz< NumberOfVoxelsAlongZ; iz++)
122  {
123  voxelsSingle[ix][iy][iz].volumeId=-1;
124  voxelsSingle[ix][iy][iz].depEnergy=0.;
125  voxelsSingle[ix][iy][iz].depEnergy2=0.;
126  voxelsSingle[ix][iy][iz].depEnergyNorm=0.;
127  voxelsSingle[ix][iy][iz].depEnergyNormError=0.;
128  voxelsSingle[ix][iy][iz].expDose=0.;
130  voxelsSingle[ix][iy][iz].pos.set(2.*(ix)*halfXVoxelDimensionX -halfSize.getX()+halfXVoxelDimensionX + centre.getX(),
131  2.*(iy)*halfXVoxelDimensionY -halfSize.getY()+halfXVoxelDimensionY + centre.getY(),
132  2.*(iz)*halfXVoxelDimensionZ -halfSize.getZ()+halfXVoxelDimensionZ + centre.getZ());
133  voxelsSingle[ix][iy][iz].nEvents=0;
134  }
135  }
136  }
137  }
138 }
void set(double x, double y, double z)
G4int nEvents
G4double depEnergyNorm
G4double depEnergy
G4double depEnergy2
G4int volumeId
G4double expDose
G4double halfXVoxelDimensionX
double getY() const
G4ThreeVector pos
double getX() const
G4double iz
Definition: TRTMaterials.hh:39
G4String fullOutFileDataSingle
G4double depEnergyNormError
G4double halfXVoxelDimensionZ
G4double halfXVoxelDimensionY
double getZ() const
Svoxel *** voxelsSingle
G4VSensitiveDetector(G4String name)
G4String fullOutFileData
G4ThreeVector halfSize
Svoxel *** voxelsSum
G4int saving_in_ROG_Voxels_every_events
Here is the call graph for this function:

◆ ~CML2SDWithVoxels()

CML2SDWithVoxels::~CML2SDWithVoxels ( void  )

Definition at line 140 of file ML2SDWithVoxels.cc.

141 {
142  if(bSaveROG)
143  {
144  delete [] voxelsSum;
145  delete [] voxelsSingle;
146  }
147 }
Svoxel *** voxelsSingle
Svoxel *** voxelsSum

Member Function Documentation

◆ EndOfEvent()

void CML2SDWithVoxels::EndOfEvent ( G4HCofThisEvent )
inlinevirtual

Reimplemented from G4VSensitiveDetector.

Definition at line 62 of file ML2SDWithVoxels.hh.

62 {}

◆ getIdFromVolumeName()

G4int CML2SDWithVoxels::getIdFromVolumeName ( G4String  name)
private

Definition at line 210 of file ML2SDWithVoxels.cc.

211 {
212  for (int i=0; i<(int)volumeNameIdLink.size(); i++)
213  {
214  if (volumeNameIdLink[i].volumeName==name)
215  {
216  return volumeNameIdLink[i].volumeId;
217  break;
218  }
219  }
220  return -1;
221 }
std::vector< SvolumeNameId > volumeNameIdLink
Here is the caller graph for this function:

◆ getTotalNumberOfEvents()

G4int CML2SDWithVoxels::getTotalNumberOfEvents ( )
inline

Definition at line 63 of file ML2SDWithVoxels.hh.

63 {return nTotalEvents;}
Here is the caller graph for this function:

◆ Initialize()

void CML2SDWithVoxels::Initialize ( G4HCofThisEvent )
inlinevirtual

Reimplemented from G4VSensitiveDetector.

Definition at line 61 of file ML2SDWithVoxels.hh.

61 {}

◆ ProcessHits()

G4bool CML2SDWithVoxels::ProcessHits ( G4Step *  aStep,
G4TouchableHistory ROHist 
)
virtual

Implements G4VSensitiveDetector.

Definition at line 172 of file ML2SDWithVoxels.cc.

173 {
174 
175  if (bActive)
176  {
177  G4double energyDep = aStep->GetTotalEnergyDeposit();
178  if (bSaveROG && energyDep>0.)
179  {
180  G4int ix, iy, iz;
181  G4String volumeName;
182 
183  ix=ROHist->GetReplicaNumber(2);
184  iy=ROHist->GetReplicaNumber(0);
185  iz=ROHist->GetReplicaNumber(1);
186 
187  density=aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial()->GetDensity();
188 
190  energyDep/=voxelMass*nRecycling;
191  voxelsSum[ix][iy][iz].volumeId=getIdFromVolumeName(aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial()->GetName());
192  voxelsSum[ix][iy][iz].depEnergy+=energyDep;
193  voxelsSum[ix][iy][iz].depEnergy2+=energyDep*energyDep;
194  voxelsSum[ix][iy][iz].nEvents++;
195 
196  voxelsSingle[ix][iy][iz].volumeId=getIdFromVolumeName(aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial()->GetName());
197  voxelsSingle[ix][iy][iz].depEnergy+=energyDep;
198  voxelsSingle[ix][iy][iz].depEnergy2+=energyDep*energyDep;
199  voxelsSingle[ix][iy][iz].nEvents++;
200  nTotalEvents++;
203  {
204  save();
205  }
206  }
207  }
208  return true;
209 }
G4int nEvents
G4double depEnergy
G4double depEnergy2
G4int volumeId
int G4int
Definition: G4Types.hh:78
G4double iz
Definition: TRTMaterials.hh:39
G4int GetReplicaNumber(G4int depth=0) const
G4int getIdFromVolumeName(G4String name)
Svoxel *** voxelsSingle
double G4double
Definition: G4Types.hh:76
Svoxel *** voxelsSum
G4int saving_in_ROG_Voxels_every_events
Here is the call graph for this function:

◆ resetVoxelsSingle()

void CML2SDWithVoxels::resetVoxelsSingle ( )

Definition at line 148 of file ML2SDWithVoxels.cc.

149 {
150  for (int ix=0; ix< NumberOfVoxelsAlongX; ix++)
151  {
152  for (int iy=0; iy< NumberOfVoxelsAlongY; iy++)
153  {
154  for (int iz=0; iz< NumberOfVoxelsAlongZ; iz++)
155  {
156  voxelsSingle[ix][iy][iz].volumeId=-1;
157  voxelsSingle[ix][iy][iz].depEnergy=0.;
158  voxelsSingle[ix][iy][iz].depEnergy2=0.;
159  voxelsSingle[ix][iy][iz].depEnergyNorm=0.;
160  voxelsSingle[ix][iy][iz].depEnergyNormError=0.;
161  voxelsSingle[ix][iy][iz].expDose=0.;
166  voxelsSingle[ix][iy][iz].nEvents=0;
167  }
168  }
169  }
171 }
void set(double x, double y, double z)
G4int nEvents
G4double depEnergyNorm
G4ThreeVector centre
G4double depEnergy
G4ThreeVector halfSize
G4double depEnergy2
G4int volumeId
G4double expDose
G4double halfXVoxelDimensionX
double getY() const
G4ThreeVector pos
double getX() const
G4double iz
Definition: TRTMaterials.hh:39
G4double depEnergyNormError
G4double halfXVoxelDimensionZ
G4double halfXVoxelDimensionY
double getZ() const
Svoxel *** voxelsSingle
G4ThreeVector halfSize
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

void CML2SDWithVoxels::save ( )

Definition at line 222 of file ML2SDWithVoxels.cc.

223 {
224 std::cout<< "n. of events collected in the whole ROG phantom for all geometries: "<< nTotalEvents<< G4endl;
225 std::cout<< "n. of events collected in the whole ROG phantom for the current geometry: "<< nSingleTotalEvents<< G4endl;
226  if (nTotalEvents>0)
228  if (nSingleTotalEvents>0)
230 }
G4String fullOutFileDataSingle
void saveData(G4String Filename, Svoxel ***voxels)
Svoxel *** voxelsSingle
#define G4endl
Definition: G4ios.hh:61
G4String fullOutFileData
Svoxel *** voxelsSum
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveData()

void CML2SDWithVoxels::saveData ( G4String  Filename,
Svoxel ***  voxels 
)
private

Definition at line 231 of file ML2SDWithVoxels.cc.

232 {
233  std::ofstream out;
234  out.open(Filename, std::ios::out);
235  out << "Sensitive Detector-Voxels. Total number of events, [mm]->centreX centreY centreZ HalfSizeX HalfSizeY HalfSizeZ minX maxX, minY maxY, minZ maxZ, Dx, Dy, Dz, nX, nY, nZ: \n";
236  out <<nTotalEvents<<'\t';
237  out <<centre.getX()/mm << '\t' << centre.getY()/mm<< '\t'<< centre.getZ()/mm<<'\t';
238  out <<halfSize.getX()/mm << '\t' << halfSize.getY()/mm <<'\t'<< halfSize.getZ()/mm<<'\t';
239  out <<(centre.getX()-halfSize.getX())/mm<<'\t'<<(centre.getX()+halfSize.getX())/mm<<'\t';
240  out <<(centre.getY()-halfSize.getY())/mm<<'\t'<<(centre.getY()+halfSize.getY())/mm<<'\t';
241  out <<(centre.getZ()-halfSize.getZ())/mm<<'\t'<<(centre.getZ()+halfSize.getZ())/mm<<'\t';
244  out << "Number of physical volumes: "<< volumeNameIdLink.size() << '\n';
245  for (int i=0; i<(int)volumeNameIdLink.size(); i++)
246  {
247  out << volumeNameIdLink[i].volumeName <<'\t'<< volumeNameIdLink[i].volumeId << G4endl;
248  }
249 
250 
251  out << "Phys Volume x [mm], y [mm], z [mm], ix, iy, iz, Dose [Gy], Dose2 [Gy^2], nEvents" << G4endl;
252 
253  for (int ix=0; ix< NumberOfVoxelsAlongX; ix++)
254  {
255  for (int iy=0; iy< NumberOfVoxelsAlongY; iy++)
256  {
257  for (int iz=0; iz< NumberOfVoxelsAlongZ; iz++)
258  {
259  if (voxels[ix][iy][iz].nEvents>0)
260  {
261  out << voxels[ix][iy][iz].volumeId << '\t';
262  out << voxels[ix][iy][iz].pos.getX()/mm << '\t';
263  out << voxels[ix][iy][iz].pos.getY()/mm << '\t';
264  out << voxels[ix][iy][iz].pos.getZ()/mm << '\t';
265  out << ix << '\t';
266  out << iy << '\t';
267  out << iz << '\t';
268  out << voxels[ix][iy][iz].depEnergy/(joule/kg) << '\t';
269  out << voxels[ix][iy][iz].depEnergy2/((joule/kg)*(joule/kg)) << '\t';
270  out << voxels[ix][iy][iz].nEvents << G4endl;
271  }
272  }
273  }
274  }
275  out.close();
276 
277 }
G4int nEvents
G4ThreeVector centre
G4double depEnergy
G4ThreeVector halfSize
G4double depEnergy2
G4int volumeId
std::vector< SvolumeNameId > volumeNameIdLink
static const double joule
Definition: G4SIunits.hh:201
G4double halfXVoxelDimensionX
double getY() const
G4ThreeVector pos
double getX() const
G4double iz
Definition: TRTMaterials.hh:39
static const double kg
Definition: G4SIunits.hh:179
G4double halfXVoxelDimensionZ
G4double halfXVoxelDimensionY
double getZ() const
#define G4endl
Definition: G4ios.hh:61
static const double mm
Definition: G4SIunits.hh:114
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setActive()

void CML2SDWithVoxels::setActive ( G4bool  act)
inline

Definition at line 64 of file ML2SDWithVoxels.hh.

64 {bActive=act;}
Here is the call graph for this function:

◆ setFullOutFileDataSingle()

void CML2SDWithVoxels::setFullOutFileDataSingle ( G4String  val)

Definition at line 278 of file ML2SDWithVoxels.cc.

279 {
280  unsigned int ind = fullOutFileData.find(".txt");
281  G4String onlyName=fullOutFileData.substr( 0, ind);
282  if (val=="")
283  {
284  static unsigned int indGeom=0;
285  char cT[5];
286  sprintf(cT,"%d",indGeom);
287  fullOutFileDataSingle=onlyName+"Single_"+G4String(cT)+".txt";
288  indGeom++;
289  }
290  else
291  {
292  fullOutFileDataSingle=onlyName+val+".txt";
293  }
294 }
G4String fullOutFileDataSingle
G4String fullOutFileData
Here is the caller graph for this function:

◆ setRecycling()

void CML2SDWithVoxels::setRecycling ( int  recycling)
inline

Definition at line 66 of file ML2SDWithVoxels.hh.

66 {nRecycling=recycling;}

◆ setVolumeNameIdLink()

void CML2SDWithVoxels::setVolumeNameIdLink ( std::vector< SvolumeNameId volNameIdLink)
inline

Definition at line 67 of file ML2SDWithVoxels.hh.

67 {volumeNameIdLink=volNameIdLink;}
std::vector< SvolumeNameId > volumeNameIdLink
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bActive

G4bool CML2SDWithVoxels::bActive
private

Definition at line 81 of file ML2SDWithVoxels.hh.

◆ bSaveROG

G4bool CML2SDWithVoxels::bSaveROG
private

Definition at line 81 of file ML2SDWithVoxels.hh.

◆ centre

G4ThreeVector CML2SDWithVoxels::centre
private

Definition at line 74 of file ML2SDWithVoxels.hh.

◆ density

G4double CML2SDWithVoxels::density
private

Definition at line 82 of file ML2SDWithVoxels.hh.

◆ fullOutFileData

G4String CML2SDWithVoxels::fullOutFileData
private

Definition at line 79 of file ML2SDWithVoxels.hh.

◆ fullOutFileDataSingle

G4String CML2SDWithVoxels::fullOutFileDataSingle
private

Definition at line 79 of file ML2SDWithVoxels.hh.

◆ halfSize

G4ThreeVector CML2SDWithVoxels::halfSize
private

Definition at line 74 of file ML2SDWithVoxels.hh.

◆ halfXVoxelDimensionX

G4double CML2SDWithVoxels::halfXVoxelDimensionX
private

Definition at line 76 of file ML2SDWithVoxels.hh.

◆ halfXVoxelDimensionY

G4double CML2SDWithVoxels::halfXVoxelDimensionY
private

Definition at line 76 of file ML2SDWithVoxels.hh.

◆ halfXVoxelDimensionZ

G4double CML2SDWithVoxels::halfXVoxelDimensionZ
private

Definition at line 76 of file ML2SDWithVoxels.hh.

◆ nParticle

G4int CML2SDWithVoxels::nParticle
private

Definition at line 80 of file ML2SDWithVoxels.hh.

◆ nParticleValatile

G4int CML2SDWithVoxels::nParticleValatile
private

Definition at line 80 of file ML2SDWithVoxels.hh.

◆ nRecycling

G4int CML2SDWithVoxels::nRecycling
private

Definition at line 80 of file ML2SDWithVoxels.hh.

◆ nSingleTotalEvents

G4int CML2SDWithVoxels::nSingleTotalEvents
private

Definition at line 80 of file ML2SDWithVoxels.hh.

◆ nTotalEvents

G4int CML2SDWithVoxels::nTotalEvents
private

Definition at line 80 of file ML2SDWithVoxels.hh.

◆ NumberOfVoxelsAlongX

G4int CML2SDWithVoxels::NumberOfVoxelsAlongX
private

Definition at line 77 of file ML2SDWithVoxels.hh.

◆ NumberOfVoxelsAlongY

G4int CML2SDWithVoxels::NumberOfVoxelsAlongY
private

Definition at line 77 of file ML2SDWithVoxels.hh.

◆ NumberOfVoxelsAlongZ

G4int CML2SDWithVoxels::NumberOfVoxelsAlongZ
private

Definition at line 77 of file ML2SDWithVoxels.hh.

◆ pos

G4ThreeVector CML2SDWithVoxels::pos
private

Definition at line 75 of file ML2SDWithVoxels.hh.

◆ saving_in_ROG_Voxels_every_events

G4int CML2SDWithVoxels::saving_in_ROG_Voxels_every_events
private

Definition at line 80 of file ML2SDWithVoxels.hh.

◆ volumeNameIdLink

std::vector<SvolumeNameId> CML2SDWithVoxels::volumeNameIdLink
private

Definition at line 83 of file ML2SDWithVoxels.hh.

◆ voxelMass

G4double CML2SDWithVoxels::voxelMass
private

Definition at line 82 of file ML2SDWithVoxels.hh.

◆ voxelsSingle

Svoxel *** CML2SDWithVoxels::voxelsSingle
private

Definition at line 78 of file ML2SDWithVoxels.hh.

◆ voxelsSum

Svoxel*** CML2SDWithVoxels::voxelsSum
private

Definition at line 78 of file ML2SDWithVoxels.hh.

◆ voxelVolume

G4double CML2SDWithVoxels::voxelVolume
private

Definition at line 82 of file ML2SDWithVoxels.hh.


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