Geant4  10.02.p03
HadrontherapyLet Class Reference

#include <HadrontherapyLet.hh>

Collaboration diagram for HadrontherapyLet:

Public Member Functions

 ~HadrontherapyLet ()
 
void Initialize ()
 
void Clear ()
 
void Fill (G4int i, G4int j, G4int k, G4double DE, G4double DX)
 
void FillEnergySpectrum (G4int trackID, G4ParticleDefinition *particleDef, G4double DE, G4double DX, G4int i, G4int j, G4int k)
 
void LetOutput ()
 
void StoreLetAscii ()
 
void StoreLetRoot ()
 

Static Public Member Functions

static HadrontherapyLetGetInstance (HadrontherapyDetectorConstruction *)
 
static HadrontherapyLetGetInstance ()
 

Static Public Attributes

static G4bool doCalculation = false
 

Private Member Functions

 HadrontherapyLet (HadrontherapyDetectorConstruction *)
 

Private Attributes

HadrontherapyPrimaryGeneratorActionpPGA
 
G4MaterialdetectorMat
 
G4double density
 
G4String filename
 
std::ofstream ofs
 
std::ofstream stopFile
 
HadrontherapyMatrixmatrix
 
G4int nVoxels
 
G4int numberOfVoxelAlongX
 
G4int numberOfVoxelAlongY
 
G4int numberOfVoxelAlongZ
 
G4double primaryEnergy
 
G4double energyLimit
 
G4double binWidth
 
G4int nBins
 
G4double nT
 
G4double dT
 
G4double nD
 
G4double dD
 
G4double nSecondaryT
 
G4double nSecondaryD
 
G4double dSecondaryT
 
G4double dSecondaryD
 
G4double nPrimaryT
 
G4double nPrimaryD
 
G4double dPrimaryT
 
G4double dPrimaryD
 
G4doublesecondaryLetT
 
G4doublesecondaryLetD
 
G4doubletotalLetT
 
G4doubleDtotalLetD
 
G4doubletotalLetD
 
G4String nome_file
 
std::vector< ionLetionLetStore
 

Static Private Attributes

static HadrontherapyLetinstance = NULL
 

Detailed Description

Definition at line 61 of file HadrontherapyLet.hh.

Constructor & Destructor Documentation

◆ HadrontherapyLet()

HadrontherapyLet::HadrontherapyLet ( HadrontherapyDetectorConstruction pDet)
private

Definition at line 54 of file HadrontherapyLet.cc.

55  :filename("Let.out"),matrix(0) // Default output filename
56 {
57 
59 
60  if (!matrix)
61  G4Exception("HadrontherapyLet::HadrontherapyLet",
62  "Hadrontherapy0005", FatalException,
63  "HadrontherapyMatrix not found. Firstly create an instance of it.");
64 
65  nVoxels = matrix -> GetNvoxel();
66 
67  numberOfVoxelAlongX = matrix -> GetNumberOfVoxelAlongX();
68  numberOfVoxelAlongY = matrix -> GetNumberOfVoxelAlongY();
69  numberOfVoxelAlongZ = matrix -> GetNumberOfVoxelAlongZ();
70 
72  pPGA = (HadrontherapyPrimaryGeneratorAction*)runManager -> GetUserPrimaryGeneratorAction();
73  // Pointer to the detector material
74  detectorMat = pDet -> GetDetectorLogicalVolume() -> GetMaterial();
75  density = detectorMat -> GetDensity();
76  // Instances for Total LET
77  totalLetD = new G4double[nVoxels];
79 
80 }
HadrontherapyMatrix * matrix
HadrontherapyPrimaryGeneratorAction * pPGA
static HadrontherapyMatrix * GetInstance()
G4Material * detectorMat
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~HadrontherapyLet()

HadrontherapyLet::~HadrontherapyLet ( )

Definition at line 82 of file HadrontherapyLet.cc.

83 {
84  Clear();
85  delete [] totalLetD;
86  delete [] DtotalLetD;
87 }
Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void HadrontherapyLet::Clear ( )

Clear all stored data

Definition at line 98 of file HadrontherapyLet.cc.

99 {
100  for (size_t i=0; i < ionLetStore.size(); i++)
101  {
102  delete [] ionLetStore[i].letDN;
103  delete [] ionLetStore[i].letDD;
104  }
105  ionLetStore.clear();
106 }
std::vector< ionLet > ionLetStore
Here is the caller graph for this function:

◆ Fill()

void HadrontherapyLet::Fill ( G4int  i,
G4int  j,
G4int  k,
G4double  DE,
G4double  DX 
)

◆ FillEnergySpectrum()

void HadrontherapyLet::FillEnergySpectrum ( G4int  trackID,
G4ParticleDefinition particleDef,
G4double  DE,
G4double  DX,
G4int  i,
G4int  j,
G4int  k 
)

Definition at line 107 of file HadrontherapyLet.cc.

113 {
114  if (DE <= 0. || DX <=0.) return;
115  if (!doCalculation) return;
116  G4int Z = particleDef -> GetAtomicNumber();
117 
118 
119  G4int PDGencoding = particleDef -> GetPDGEncoding();
120  PDGencoding -= PDGencoding%10;
121 
122  G4int voxel = matrix -> Index(i,j,k);
123  // Total LET calculation...
124  totalLetD[voxel] += DE*(DE/DX);
125  DtotalLetD[voxel] += DE;
126  // Single ion LET
127  if (Z>=1)
128  {
129  // Search for already allocated data...
130  size_t l;
131  for (l=0; l < ionLetStore.size(); l++)
132  {
133  if (ionLetStore[l].PDGencoding == PDGencoding)
134  if ( ((trackID ==1) && (ionLetStore[l].isPrimary)) || ((trackID !=1) && (!ionLetStore[l].isPrimary)))
135  break;
136  }
137 
138  if (l == ionLetStore.size()) // Just another type of ion/particle for our store...
139  {
140 
141  G4int A = particleDef -> GetAtomicMass();
142 
143  G4String fullName = particleDef -> GetParticleName();
144  G4String name = fullName.substr (0, fullName.find("[") ); // cut excitation energy [x.y]
145 
146  ionLet ion =
147  {
148  (trackID == 1) ? true:false, // is it the primary particle?
149  PDGencoding,
150  fullName,
151  name,
152  Z,
153  A,
154  new G4double[nVoxels], // Let Dose Numerator
155  new G4double[nVoxels] // Let Dose Denominator
156  };
157 
158  // Initialize let
159  for(G4int v=0; v < nVoxels; v++) ion.letDN[v] = ion.letDD[v] = 0.;
160  ionLetStore.push_back(ion);
161  //G4cout << "Allocated LET data for " << ion.name << G4endl;
162 
163  }
164  ionLetStore[l].letDN[voxel] += DE*(DE/DX);
165  ionLetStore[l].letDD[voxel] += DE;
166  }
167 }
static G4bool doCalculation
G4double * letDD
HadrontherapyMatrix * matrix
G4String name
Definition: TRTMaterials.hh:40
int G4int
Definition: G4Types.hh:78
double A(double temperature)
Float_t Z
std::vector< ionLet > ionLetStore
G4double * letDN
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ GetInstance() [1/2]

HadrontherapyLet * HadrontherapyLet::GetInstance ( HadrontherapyDetectorConstruction pDet)
static

Definition at line 42 of file HadrontherapyLet.cc.

43 {
44  if (instance) delete instance;
45  instance = new HadrontherapyLet(pDet);
46  return instance;
47 }
HadrontherapyLet(HadrontherapyDetectorConstruction *)
static HadrontherapyLet * instance
Here is the call graph for this function:

◆ GetInstance() [2/2]

HadrontherapyLet * HadrontherapyLet::GetInstance ( )
static

Definition at line 49 of file HadrontherapyLet.cc.

50 {
51  return instance;
52 }
static HadrontherapyLet * instance
Here is the caller graph for this function:

◆ Initialize()

void HadrontherapyLet::Initialize ( )

Definition at line 90 of file HadrontherapyLet.cc.

91 {
92  for(G4int v=0; v < nVoxels; v++) totalLetD[v] = DtotalLetD[v] = 0.;
93  Clear();
94 }
int G4int
Definition: G4Types.hh:78
Here is the call graph for this function:

◆ LetOutput()

void HadrontherapyLet::LetOutput ( )

Definition at line 172 of file HadrontherapyLet.cc.

173 {
174  for(G4int v=0; v < nVoxels; v++) if (DtotalLetD[v]>0.) totalLetD[v] = totalLetD[v]/DtotalLetD[v];
175  // Sort ions by A and then by Z ...
176  std::sort(ionLetStore.begin(), ionLetStore.end());
177  // Compute Let Track and Let Dose for any single ion
178 
179  for(G4int v=0; v < nVoxels; v++)
180  {
181  for (size_t ion=0; ion < ionLetStore.size(); ion++)
182  {
183  if (ionLetStore[ion].letDD[v] >0.) ionLetStore[ion].letDN[v] = ionLetStore[ion].letDN[v] / ionLetStore[ion].letDD[v];
184 
185  }// end loop over ions
186  }
187 
188 }// end loop over voxels
int G4int
Definition: G4Types.hh:78
std::vector< ionLet > ionLetStore

◆ StoreLetAscii()

void HadrontherapyLet::StoreLetAscii ( )

Definition at line 190 of file HadrontherapyLet.cc.

191 {
192 #define width 15L
193  if(ionLetStore.size())
194  {
195  ofs.open(filename, std::ios::out);
196  if (ofs.is_open())
197  {
198 
199  // Write the voxels index and the list of particles/ions
200  ofs << std::setprecision(6) << std::left <<
201  "i\tj\tk\t";
202  ofs << std::setw(width) << "LDT";
203  for (size_t l=0; l < ionLetStore.size(); l++)
204  {
205  G4String a = (ionLetStore[l].isPrimary) ? "_1":"";
206  ofs << std::setw(width) << ionLetStore[l].name + a ;
207  }
208  ofs << G4endl;
209 
210  // Write data
211  for(G4int i = 0; i < numberOfVoxelAlongX; i++)
212  for(G4int j = 0; j < numberOfVoxelAlongY; j++)
213  for(G4int k = 0; k < numberOfVoxelAlongZ; k++)
214  {
215  G4int v = matrix -> Index(i, j, k);
216  // row write
217  for (size_t l=0; l < ionLetStore.size(); l++)
218  {
219  // Write only not identically null data lines
220  if(ionLetStore[l].letDN)
221  {
222  ofs << G4endl;
223  ofs << i << '\t' << j << '\t' << k << '\t';
224 
225  ofs << std::setw(width) << totalLetD[v]/(keV/um);
226  for (size_t ll=0; ll < ionLetStore.size(); ll++)
227  {
228  ofs << std::setw(width) << ionLetStore[ll].letDN[v]/(keV/um) ;
229  }
230  break;
231  }
232  }
233  }
234  ofs.close();
235  G4cout << "Let is being written to " << filename << G4endl;
236  }
237 
238  }
239 }
HadrontherapyMatrix * matrix
#define width
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
std::vector< ionLet > ionLetStore
std::ofstream ofs
static const double um
Definition: G4SIunits.hh:112
#define G4endl
Definition: G4ios.hh:61
static const double keV
Definition: G4SIunits.hh:213

◆ StoreLetRoot()

void HadrontherapyLet::StoreLetRoot ( )

Definition at line 241 of file HadrontherapyLet.cc.

242 {
243 #ifdef G4ANALYSIS_USE_ROOT
244 
246 
247  for(G4int i = 0; i < numberOfVoxelAlongX; i++)
248  for(G4int j = 0; j < numberOfVoxelAlongY; j++)
249  for(G4int k = 0; k < numberOfVoxelAlongZ; k++)
250  {
251  G4int v = matrix -> Index(i, j, k);
252  for (size_t ion=0; ion < ionLetStore.size(); ion++)
253  {
254 
255  analysis -> FillLetFragmentTuple( i, j, k, ionLetStore[ion].A, ionLetStore[ion].Z, ionLetStore[ion].letDN[v]);
256 
257 
258  }
259  }
260 
261 #endif
262 }
static HadrontherapyAnalysisManager * GetInstance()
HadrontherapyMatrix * matrix
int G4int
Definition: G4Types.hh:78
double A(double temperature)
Float_t Z
std::vector< ionLet > ionLetStore
Here is the call graph for this function:

Member Data Documentation

◆ binWidth

G4double HadrontherapyLet::binWidth
private

Definition at line 98 of file HadrontherapyLet.hh.

◆ dD

G4double HadrontherapyLet::dD
private

Definition at line 100 of file HadrontherapyLet.hh.

◆ density

G4double HadrontherapyLet::density
private

Definition at line 91 of file HadrontherapyLet.hh.

◆ detectorMat

G4Material* HadrontherapyLet::detectorMat
private

Definition at line 90 of file HadrontherapyLet.hh.

◆ doCalculation

G4bool HadrontherapyLet::doCalculation = false
static

Definition at line 70 of file HadrontherapyLet.hh.

◆ dPrimaryD

G4double HadrontherapyLet::dPrimaryD
private

Definition at line 102 of file HadrontherapyLet.hh.

◆ dPrimaryT

G4double HadrontherapyLet::dPrimaryT
private

Definition at line 102 of file HadrontherapyLet.hh.

◆ dSecondaryD

G4double HadrontherapyLet::dSecondaryD
private

Definition at line 101 of file HadrontherapyLet.hh.

◆ dSecondaryT

G4double HadrontherapyLet::dSecondaryT
private

Definition at line 101 of file HadrontherapyLet.hh.

◆ dT

G4double HadrontherapyLet::dT
private

Definition at line 100 of file HadrontherapyLet.hh.

◆ DtotalLetD

G4double * HadrontherapyLet::DtotalLetD
private

Definition at line 104 of file HadrontherapyLet.hh.

◆ energyLimit

G4double HadrontherapyLet::energyLimit
private

Definition at line 98 of file HadrontherapyLet.hh.

◆ filename

G4String HadrontherapyLet::filename
private

Definition at line 92 of file HadrontherapyLet.hh.

◆ instance

HadrontherapyLet * HadrontherapyLet::instance = NULL
staticprivate

Definition at line 87 of file HadrontherapyLet.hh.

◆ ionLetStore

std::vector<ionLet> HadrontherapyLet::ionLetStore
private

Definition at line 107 of file HadrontherapyLet.hh.

◆ matrix

HadrontherapyMatrix* HadrontherapyLet::matrix
private

Definition at line 96 of file HadrontherapyLet.hh.

◆ nBins

G4int HadrontherapyLet::nBins
private

Definition at line 99 of file HadrontherapyLet.hh.

◆ nD

G4double HadrontherapyLet::nD
private

Definition at line 100 of file HadrontherapyLet.hh.

◆ nome_file

G4String HadrontherapyLet::nome_file
private

Definition at line 105 of file HadrontherapyLet.hh.

◆ nPrimaryD

G4double HadrontherapyLet::nPrimaryD
private

Definition at line 102 of file HadrontherapyLet.hh.

◆ nPrimaryT

G4double HadrontherapyLet::nPrimaryT
private

Definition at line 102 of file HadrontherapyLet.hh.

◆ nSecondaryD

G4double HadrontherapyLet::nSecondaryD
private

Definition at line 101 of file HadrontherapyLet.hh.

◆ nSecondaryT

G4double HadrontherapyLet::nSecondaryT
private

Definition at line 101 of file HadrontherapyLet.hh.

◆ nT

G4double HadrontherapyLet::nT
private

Definition at line 100 of file HadrontherapyLet.hh.

◆ numberOfVoxelAlongX

G4int HadrontherapyLet::numberOfVoxelAlongX
private

Definition at line 97 of file HadrontherapyLet.hh.

◆ numberOfVoxelAlongY

G4int HadrontherapyLet::numberOfVoxelAlongY
private

Definition at line 97 of file HadrontherapyLet.hh.

◆ numberOfVoxelAlongZ

G4int HadrontherapyLet::numberOfVoxelAlongZ
private

Definition at line 97 of file HadrontherapyLet.hh.

◆ nVoxels

G4int HadrontherapyLet::nVoxels
private

Definition at line 97 of file HadrontherapyLet.hh.

◆ ofs

std::ofstream HadrontherapyLet::ofs
private

Definition at line 94 of file HadrontherapyLet.hh.

◆ pPGA

HadrontherapyPrimaryGeneratorAction* HadrontherapyLet::pPGA
private

Definition at line 88 of file HadrontherapyLet.hh.

◆ primaryEnergy

G4double HadrontherapyLet::primaryEnergy
private

Definition at line 98 of file HadrontherapyLet.hh.

◆ secondaryLetD

G4double * HadrontherapyLet::secondaryLetD
private

Definition at line 104 of file HadrontherapyLet.hh.

◆ secondaryLetT

G4double* HadrontherapyLet::secondaryLetT
private

Definition at line 104 of file HadrontherapyLet.hh.

◆ stopFile

std::ofstream HadrontherapyLet::stopFile
private

Definition at line 95 of file HadrontherapyLet.hh.

◆ totalLetD

G4double * HadrontherapyLet::totalLetD
private

Definition at line 104 of file HadrontherapyLet.hh.

◆ totalLetT

G4double * HadrontherapyLet::totalLetT
private

Definition at line 104 of file HadrontherapyLet.hh.


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