Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CML2ExpVoxels Class Reference

#include <ML2ExpVoxels.hh>

Public Member Functions

 CML2ExpVoxels (G4bool bHasExperimentalData, G4int saving_in_Selected_Voxels_every_events, G4int seed, G4String FileExperimentalData, G4String FileExperimentalDataOut)
 
 ~CML2ExpVoxels (void)
 
void add (G4ThreeVector pos, G4double depEnergy, G4double density)
 
void add (const G4Step *aStep)
 
std::vector< SvoxelgetVoxels ()
 
G4int getMinNumberOfEvents ()
 
G4int getMaxNumberOfEvents ()
 
G4bool loadData ()
 
void setRecycling (int recycling)
 
void saveResults (void)
 
void resetNEventsInVoxels ()
 

Detailed Description

Definition at line 51 of file ML2ExpVoxels.hh.

Constructor & Destructor Documentation

CML2ExpVoxels::CML2ExpVoxels ( G4bool  bHasExperimentalData,
G4int  saving_in_Selected_Voxels_every_events,
G4int  seed,
G4String  FileExperimentalData,
G4String  FileExperimentalDataOut 
)

Definition at line 48 of file ML2ExpVoxels.cc.

49  :startCurve(0),
50  stopCurve(0),chi2Factor(0)
51 {
52  char a[10];
53  sprintf(a,"%d", seed);
54  seedName=(G4String)a;
55  saving_in_Selected_Voxels_every_events=saveEvents;
56  nRecycling=1;
57 
58 
59  fullFileOut=FileExperimentalDataOut+seedName+".m";
60  fullFileIn=FileExperimentalData;
61  nParticle=nTotalEvents=0;
62 
63 // define the extremes of global-volume containing all experimental voxels
64  G4double extr=100000000000.;
65  minZone.set(extr, extr, extr);
66  maxZone.set(-extr, -extr, -extr);
67  bHasExperimentalData=bData;
68 }
void set(double x, double y, double z)
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
long seed
Definition: chem4.cc:68
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

CML2ExpVoxels::~CML2ExpVoxels ( void  )

Definition at line 70 of file ML2ExpVoxels.cc.

71 {
72  delete [] startCurve;
73  delete [] stopCurve;
74  delete [] chi2Factor;
75  delete [] nVoxelsgeometry;
76 }

Member Function Documentation

void CML2ExpVoxels::add ( G4ThreeVector  pos,
G4double  depEnergy,
G4double  density 
)

Here is the caller graph for this function:

void CML2ExpVoxels::add ( const G4Step aStep)

Definition at line 165 of file ML2ExpVoxels.cc.

166 {
168  G4double depEnergy, density, voxelVolume;
169 
170  pos=aStep->GetPreStepPoint()->GetPosition();
171  depEnergy=aStep->GetTotalEnergyDeposit();
173 
174  G4ThreeVector minPos, maxPos;
175  G4bool newEvent=false;
176  G4double voxelMass, dose;
177 
178 // check if the event is inside the global-volume
179  if (minZone.getX()<= pos.getX() && pos.getX()<maxZone.getX() &&
180  minZone.getY()<= pos.getY() && pos.getY()<maxZone.getY() &&
181  minZone.getZ()<= pos.getZ() && pos.getZ()<maxZone.getZ())
182  {
183 // look for the voxel containing the event
184  for (int i=0; i<(int)voxels.size(); i++)
185  {
186  minPos=voxels[i].pos-voxels[i].halfSize;
187  maxPos=voxels[i].pos+voxels[i].halfSize;
188  if (minPos.getX()<= pos.getX() && pos.getX()<maxPos.getX() &&
189  minPos.getY()<= pos.getY() && pos.getY()<maxPos.getY() &&
190  minPos.getZ()<= pos.getZ() && pos.getZ()<maxPos.getZ())
191  {
192  voxelVolume=voxels[i].halfSize.getX()*voxels[i].halfSize.getY()*voxels[i].halfSize.getZ()*8.;
193  voxelMass=density*voxelVolume;
194 // calculate the dose
195  dose=depEnergy/(voxelMass*nRecycling);
196  voxels[i].nEvents++;
197  nVoxelsgeometry[i]++;
198  voxels[i].depEnergy+=dose;
199  voxels[i].depEnergy2+=dose*dose;
200  newEvent=true;
201 
202  Sparticle *particle=new Sparticle;
203  particle->dir=aStep->GetPreStepPoint()->GetMomentumDirection();
204  particle->pos=aStep->GetPreStepPoint()->GetPosition();
205  particle->kinEnergy=dose; // I use the same kinEnergy name to store the dose
206  particle->nPrimaryPart=-1;
207  particle->partPDGE=aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
208  particle->primaryParticlePDGE=-1;
209  particle->volumeId=i; // voxel index where the dose is accumulating
210  particle->volumeName="-1";
211  }
212  }
213  if (newEvent)
214  {
215 // save data
216  nTotalEvents++;
217  if (nTotalEvents%saving_in_Selected_Voxels_every_events==0 && nTotalEvents>0)
218  {
219  saveResults();
220  }
221  }
222  }
223 }
G4ParticleDefinition * GetDefinition() const
G4Material * GetMaterial() const
G4int partPDGE
G4double GetDensity() const
Definition: G4Material.hh:180
double getY() const
G4ThreeVector dir
G4int nPrimaryPart
G4StepPoint * GetPreStepPoint() const
double getX() const
const G4ThreeVector & GetMomentumDirection() const
G4VPhysicalVolume * GetPhysicalVolume() const
G4int primaryParticlePDGE
const G4ThreeVector & GetPosition() const
bool G4bool
Definition: G4Types.hh:79
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4double GetTotalEnergyDeposit() const
G4LogicalVolume * GetLogicalVolume() const
G4ThreeVector pos
G4double kinEnergy
double getZ() const
G4String volumeName
G4int volumeId
void saveResults(void)
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const
static const G4double pos

Here is the call graph for this function:

G4int CML2ExpVoxels::getMaxNumberOfEvents ( )

Definition at line 234 of file ML2ExpVoxels.cc.

235 {
236  int n=nVoxelsgeometry[0];
237  for (int i=0;i<(int)voxels.size();i++)
238  {
239  if (n<nVoxelsgeometry[i]){n = nVoxelsgeometry[i];}
240  }
241  return n;
242 }
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const G4int n

Here is the call graph for this function:

G4int CML2ExpVoxels::getMinNumberOfEvents ( )

Definition at line 225 of file ML2ExpVoxels.cc.

226 {
227  int n=voxels[0].nEvents;
228  for (int i=0;i<(int)voxels.size();i++)
229  {
230  if (n>voxels[i].nEvents){n = voxels[i].nEvents;}
231  }
232  return n;
233 }
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const G4int n

Here is the call graph for this function:

std::vector<Svoxel> CML2ExpVoxels::getVoxels ( )
inline

Definition at line 59 of file ML2ExpVoxels.hh.

59 {return voxels;}
G4bool CML2ExpVoxels::loadData ( void  )

Definition at line 77 of file ML2ExpVoxels.cc.

78 {
79  bHasExperimentalData=true;
80  std::ifstream in;
81 
82  Svoxel voxel; voxel.volumeId=0;
83  G4ThreeVector pos, halfSize;
84  G4double expDose;
85 
86  in.open(fullFileIn, std::ios::in);
87  if (in)
88  {
89  G4String appo;
90  char a[1000];
91  in.getline(a,1000,'\n'); headerText1=(G4String)a;
92  in.getline(a,1000,'\n');
93  in >> nCurves;
94  startCurve=new G4int[nCurves];
95  stopCurve=new G4int[nCurves];
96  chi2Factor=new G4double[nCurves];
97  for (int i=0; i< nCurves; i++)
98  {
99  chi2Factor[i]=0.;
100  in >> startCurve[i];
101  in >> stopCurve[i];
102  in >> chi2Factor[i];
103  }
104  in.getline(a,1000,'\n');
105  in.getline(a,1000,'\n'); headerText2=(G4String)a;
106 
107  while (!in.eof())
108  {
109  in >> pos;
110  in >> halfSize;
111  if (bHasExperimentalData)
112  {
113  in >> expDose;
114  voxel.expDose=expDose/100.*(joule/kg); // input data in cGy
115  }
116  else
117  {
118  voxel.expDose=0.;
119  }
120  voxel.pos=pos;
121  voxel.halfSize=halfSize;
122  voxel.depEnergy=0.;
123  voxel.depEnergy2=0.;
124  voxel.nEvents=0;
125  voxel.depEnergyNorm=0.;
126  voxel.depEnergyNormError=0.;
127  voxels.push_back(voxel);
128 
129 // calculate the actual extremes of the global-volume containing all the experimental data
130  if (minZone.getX()>pos.getX()-halfSize.getX())
131  {minZone.setX(pos.getX()-halfSize.getX());}
132  if (maxZone.getX()<pos.getX()+halfSize.getX())
133  {maxZone.setX(pos.getX()+halfSize.getX());}
134 
135  if (minZone.getY()>pos.getY()-halfSize.getY())
136  {minZone.setY(pos.getY()-halfSize.getY());}
137  if (maxZone.getY()<pos.getY()+halfSize.getY())
138  {maxZone.setY(pos.getY()+halfSize.getY());}
139 
140  if (minZone.getZ()>pos.getZ()-halfSize.getZ())
141  {minZone.setZ(pos.getZ()-halfSize.getZ());}
142  if (maxZone.getZ()<pos.getZ()+halfSize.getZ())
143  {maxZone.setZ(pos.getZ()+halfSize.getZ());}
144 
145  }
146  }
147  else
148  {
149  std::cout << "ERROR I can't find the experimental data file" << G4endl;
150  return false;
151  }
152  in.close();
153 
154  nVoxelsgeometry=new G4int[(G4int) voxels.size()];
156 
157  return true;
158 }
G4int nEvents
G4double depEnergyNorm
G4double depEnergy
G4double depEnergy2
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
G4int volumeId
double getY() const
int G4int
Definition: G4Types.hh:78
void setY(double)
void setZ(double)
void setX(double)
G4double expDose
double getX() const
void resetNEventsInVoxels()
G4ThreeVector pos
G4double depEnergyNormError
static constexpr double kg
Definition: G4SIunits.hh:182
static constexpr double joule
Definition: G4SIunits.hh:204
double getZ() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4ThreeVector halfSize
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:

void CML2ExpVoxels::resetNEventsInVoxels ( )

Definition at line 159 of file ML2ExpVoxels.cc.

160 {
161  for (int i=0; i<(int) voxels.size(); i++ )
162  {nVoxelsgeometry[i]=0;}
163 }
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)

Here is the call graph for this function:

Here is the caller graph for this function:

void CML2ExpVoxels::saveResults ( void  )

Definition at line 262 of file ML2ExpVoxels.cc.

263 {
264  if (nTotalEvents>0)
265  {
266  calculateNormalizedEd(voxels);
267  saveHeader();
268  std::ofstream out;
269  out.open(fullFileOut, std::ios::app);
270  out <<"d"<< seedName<<"=["<< G4endl;
271  for (int i=0; i<(int)voxels.size(); i++)
272  {
273  out <<voxels[i].pos.getX()/mm<<'\t'<<voxels[i].pos.getY()/mm<<'\t'<<voxels[i].pos.getZ()/mm<<'\t';
274  out <<voxels[i].halfSize.getX()/mm<<'\t'<<voxels[i].halfSize.getY()/mm<<'\t'<<voxels[i].halfSize.getZ()/mm<<'\t';
275  out <<voxels[i].expDose/(joule/kg)<<'\t'<<voxels[i].depEnergy/(joule/kg)<<'\t'<<voxels[i].depEnergy2/((joule/kg)*(joule/kg))<<'\t'<<voxels[i].nEvents<< '\t';
276  out <<voxels[i].depEnergyNorm/(joule/kg)<<'\t'<<voxels[i].depEnergyNormError/(joule/kg);
277  out << G4endl;
278  }
279  out << "];"<<G4endl;
280  out.close();
281  }
282 }
static constexpr double mm
Definition: G4SIunits.hh:115
tuple app
Definition: demo.py:189
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
static constexpr double kg
Definition: G4SIunits.hh:182
static constexpr double joule
Definition: G4SIunits.hh:204
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

void CML2ExpVoxels::setRecycling ( int  recycling)
inline

Definition at line 66 of file ML2ExpVoxels.hh.

66 {nRecycling=recycling;}

Here is the caller graph for this function:


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