Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
CML2SDWithVoxels Class Reference

#include <ML2SDWithVoxels.hh>

Inheritance diagram for CML2SDWithVoxels:
G4VSensitiveDetector

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 ()
 
const 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
 

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 ( 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.

References test::a, Svoxel::depEnergy, Svoxel::depEnergy2, Svoxel::depEnergyNorm, Svoxel::depEnergyNormError, Svoxel::expDose, CLHEP::Hep3Vector::getX(), CLHEP::Hep3Vector::getY(), CLHEP::Hep3Vector::getZ(), Svoxel::halfSize, iz, Svoxel::nEvents, Svoxel::pos, CLHEP::Hep3Vector::set(), and Svoxel::volumeId.

53 : G4VSensitiveDetector(name),voxelsSum(0), voxelsSingle(0)
54 {
55  saving_in_ROG_Voxels_every_events=voxSave;
56  bSaveROG=bROG;
57  bActive=true;
58  nParticle=0;
59  nParticleValatile=0;
60  nTotalEvents=0;
61  nSingleTotalEvents=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";
73  fullOutFileDataSingle="";
74  if(bSaveROG)
75  {
76  centre=ctr;
77  halfSize=hSiz;
78  NumberOfVoxelsAlongX=NumVX;
79  NumberOfVoxelsAlongY=NumVY;
80  NumberOfVoxelsAlongZ=NumVZ;
81  halfXVoxelDimensionX=halfSize.getX()/NumberOfVoxelsAlongX;
82  halfXVoxelDimensionY=halfSize.getY()/NumberOfVoxelsAlongY;
83  halfXVoxelDimensionZ=halfSize.getZ()/NumberOfVoxelsAlongZ;
84 
85  voxelVolume=halfXVoxelDimensionX*halfXVoxelDimensionY*halfXVoxelDimensionZ*8.;
86 
87 // voxels to store and save the sum of the geometry configurations
88  voxelsSum=new Svoxel**[NumberOfVoxelsAlongX];
89  for (int ix=0; ix< NumberOfVoxelsAlongX; ix++)
90  {
91  voxelsSum[ix]=new Svoxel*[NumberOfVoxelsAlongY];
92  for (int iy=0; iy< NumberOfVoxelsAlongY; iy++)
93  {
94  voxelsSum[ix][iy]=new Svoxel[NumberOfVoxelsAlongZ];
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.;
103  voxelsSum[ix][iy][iz].halfSize.set(halfXVoxelDimensionX, halfXVoxelDimensionY, halfXVoxelDimensionZ);
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
114  voxelsSingle=new Svoxel**[NumberOfVoxelsAlongX];
115  for (int ix=0; ix< NumberOfVoxelsAlongX; ix++)
116  {
117  voxelsSingle[ix]=new Svoxel*[NumberOfVoxelsAlongY];
118  for (int iy=0; iy< NumberOfVoxelsAlongY; iy++)
119  {
120  voxelsSingle[ix][iy]=new Svoxel[NumberOfVoxelsAlongZ];
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.;
129  voxelsSingle[ix][iy][iz].halfSize.set(halfXVoxelDimensionX, halfXVoxelDimensionY, halfXVoxelDimensionZ);
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
double getY() const
G4double expDose
G4double density
Definition: TRTMaterials.hh:39
double getX() const
G4ThreeVector pos
G4double iz
Definition: TRTMaterials.hh:39
G4double depEnergyNormError
double getZ() const
G4VSensitiveDetector(G4String name)
G4ThreeVector halfSize
CML2SDWithVoxels::~CML2SDWithVoxels ( void  )

Definition at line 140 of file ML2SDWithVoxels.cc.

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

Member Function Documentation

void CML2SDWithVoxels::EndOfEvent ( G4HCofThisEvent )
inlinevirtual

Reimplemented from G4VSensitiveDetector.

Definition at line 62 of file ML2SDWithVoxels.hh.

62 {}
G4int CML2SDWithVoxels::getTotalNumberOfEvents ( )
inline

Definition at line 63 of file ML2SDWithVoxels.hh.

Referenced by CML2Ph_FullWater::getTotalNumberOfEvents(), and CML2Ph_BoxInBox::getTotalNumberOfEvents().

63 {return nTotalEvents;}
void CML2SDWithVoxels::Initialize ( G4HCofThisEvent )
inlinevirtual

Reimplemented from G4VSensitiveDetector.

Definition at line 61 of file ML2SDWithVoxels.hh.

61 {}
G4bool CML2SDWithVoxels::ProcessHits ( G4Step aStep,
G4TouchableHistory ROHist 
)
virtual

Implements G4VSensitiveDetector.

Definition at line 172 of file ML2SDWithVoxels.cc.

References Svoxel::depEnergy, Svoxel::depEnergy2, G4Material::GetDensity(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetMaterial(), G4Material::GetName(), G4StepPoint::GetPhysicalVolume(), G4Step::GetPreStepPoint(), G4TouchableHistory::GetReplicaNumber(), G4Step::GetTotalEnergyDeposit(), iz, Svoxel::nEvents, save(), and Svoxel::volumeId.

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 
188 
189  voxelMass=voxelVolume*density;
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++;
201  nSingleTotalEvents++;
202  if (nTotalEvents%saving_in_ROG_Voxels_every_events==0 && nTotalEvents>0)
203  {
204  save();
205  }
206  }
207  }
208  return true;
209 }
G4int nEvents
G4double depEnergy
G4double depEnergy2
G4Material * GetMaterial() const
G4int volumeId
const G4String & GetName() const
Definition: G4Material.hh:176
G4double GetDensity() const
Definition: G4Material.hh:178
int G4int
Definition: G4Types.hh:78
G4StepPoint * GetPreStepPoint() const
G4double density
Definition: TRTMaterials.hh:39
G4VPhysicalVolume * GetPhysicalVolume() const
G4double iz
Definition: TRTMaterials.hh:39
G4int GetReplicaNumber(G4int depth=0) const
G4double GetTotalEnergyDeposit() const
G4LogicalVolume * GetLogicalVolume() const
double G4double
Definition: G4Types.hh:76
void CML2SDWithVoxels::resetVoxelsSingle ( )

Definition at line 148 of file ML2SDWithVoxels.cc.

References Svoxel::depEnergy, Svoxel::depEnergy2, Svoxel::depEnergyNorm, Svoxel::depEnergyNormError, Svoxel::expDose, CLHEP::Hep3Vector::getX(), CLHEP::Hep3Vector::getY(), CLHEP::Hep3Vector::getZ(), Svoxel::halfSize, iz, Svoxel::nEvents, Svoxel::pos, CLHEP::Hep3Vector::set(), and Svoxel::volumeId.

Referenced by CML2PhantomConstruction::applyNewCentre(), and CML2PhantomConstruction::resetSensDet().

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.;
162  voxelsSingle[ix][iy][iz].halfSize.set(halfXVoxelDimensionX, halfXVoxelDimensionY, halfXVoxelDimensionZ);
163  voxelsSingle[ix][iy][iz].pos.set(2.*(ix)*halfXVoxelDimensionX -halfSize.getX()+halfXVoxelDimensionX + centre.getX(),
164  2.*(iy)*halfXVoxelDimensionY -halfSize.getY()+halfXVoxelDimensionY + centre.getY(),
165  2.*(iz)*halfXVoxelDimensionZ -halfSize.getZ()+halfXVoxelDimensionZ + centre.getZ());
166  voxelsSingle[ix][iy][iz].nEvents=0;
167  }
168  }
169  }
170  nSingleTotalEvents=0;
171 }
void set(double x, double y, double z)
G4int nEvents
G4double depEnergyNorm
G4double depEnergy
G4double depEnergy2
G4int volumeId
double getY() const
G4double expDose
double getX() const
G4ThreeVector pos
G4double iz
Definition: TRTMaterials.hh:39
G4double depEnergyNormError
double getZ() const
G4ThreeVector halfSize
void CML2SDWithVoxels::save ( )

Definition at line 222 of file ML2SDWithVoxels.cc.

References G4endl.

Referenced by ProcessHits(), and CML2PhantomConstruction::saveData().

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)
227  {saveData(fullOutFileData, voxelsSum);}
228  if (nSingleTotalEvents>0)
229  {saveData(fullOutFileDataSingle, voxelsSingle);}
230 }
#define G4endl
Definition: G4ios.hh:61
void CML2SDWithVoxels::setActive ( G4bool  act)
inline

Definition at line 64 of file ML2SDWithVoxels.hh.

64 {bActive=act;}
void CML2SDWithVoxels::setFullOutFileDataSingle ( G4String  val)

Definition at line 278 of file ML2SDWithVoxels.cc.

Referenced by CML2PhantomConstruction::setNewName().

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 }
void CML2SDWithVoxels::setRecycling ( int  recycling)
inline

Definition at line 66 of file ML2SDWithVoxels.hh.

66 {nRecycling=recycling;}
void CML2SDWithVoxels::setVolumeNameIdLink ( std::vector< SvolumeNameId volNameIdLink)
inline

Definition at line 67 of file ML2SDWithVoxels.hh.

Referenced by CML2PhantomConstruction::Construct().

67 {volumeNameIdLink=volNameIdLink;}

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