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

#include <HadrontherapyLet.hh>

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
 

Detailed Description

Definition at line 59 of file HadrontherapyLet.hh.

Constructor & Destructor Documentation

HadrontherapyLet::~HadrontherapyLet ( )

Definition at line 76 of file HadrontherapyLet.cc.

References Clear().

77 {
78  Clear();
79  delete [] totalLetD;
80  delete [] DtotalLetD;
81 }

Member Function Documentation

void HadrontherapyLet::Clear ( )

Clear all stored data

Definition at line 92 of file HadrontherapyLet.cc.

Referenced by Initialize(), and ~HadrontherapyLet().

93 {
94  for (size_t i=0; i < ionLetStore.size(); i++)
95  {
96  delete [] ionLetStore[i].letDN;
97  delete [] ionLetStore[i].letDD;
98  }
99  ionLetStore.clear();
100 }
void HadrontherapyLet::Fill ( G4int  i,
G4int  j,
G4int  k,
G4double  DE,
G4double  DX 
)
void HadrontherapyLet::FillEnergySpectrum ( G4int  trackID,
G4ParticleDefinition particleDef,
G4double  DE,
G4double  DX,
G4int  i,
G4int  j,
G4int  k 
)

Definition at line 101 of file HadrontherapyLet.cc.

References doCalculation, ionLet::letDD, ionLet::letDN, and test::v.

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

Definition at line 40 of file HadrontherapyLet.cc.

41 {
42  if (instance) delete instance;
43  instance = new HadrontherapyLet(pDet);
44  return instance;
45 }
HadrontherapyLet * HadrontherapyLet::GetInstance ( )
static
void HadrontherapyLet::Initialize ( )

Definition at line 84 of file HadrontherapyLet.cc.

References Clear(), and test::v.

85 {
86  for(G4int v=0; v < nVoxels; v++) totalLetD[v] = DtotalLetD[v] = 0.;
87  Clear();
88 }
int G4int
Definition: G4Types.hh:78
void HadrontherapyLet::LetOutput ( )

Definition at line 166 of file HadrontherapyLet.cc.

References sort(), and test::v.

167 {
168  for(G4int v=0; v < nVoxels; v++) if (DtotalLetD[v]>0.) totalLetD[v] = totalLetD[v]/DtotalLetD[v];
169  // Sort ions by A and then by Z ...
170  std::sort(ionLetStore.begin(), ionLetStore.end());
171  // Compute Let Track and Let Dose for any single ion
172 
173  for(G4int v=0; v < nVoxels; v++)
174  {
175  for (size_t ion=0; ion < ionLetStore.size(); ion++)
176  {
177  if (ionLetStore[ion].letDD[v] >0.) ionLetStore[ion].letDN[v] = ionLetStore[ion].letDN[v] / ionLetStore[ion].letDD[v];
178 
179  }// end loop over ions
180  }
181 
182 }// end loop over voxels
subroutine sort(A, N)
Definition: dpm25nuc7.f:4670
int G4int
Definition: G4Types.hh:78
void HadrontherapyLet::StoreLetAscii ( )

Definition at line 184 of file HadrontherapyLet.cc.

References test::a, G4cout, G4endl, python.hepunit::keV, left, test::v, and width.

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

Definition at line 235 of file HadrontherapyLet.cc.

References HadrontherapyAnalysisManager::GetInstance(), and test::v.

236 {
237 #ifdef G4ANALYSIS_USE_ROOT
238 
240 
241  for(G4int i = 0; i < numberOfVoxelAlongX; i++)
242  for(G4int j = 0; j < numberOfVoxelAlongY; j++)
243  for(G4int k = 0; k < numberOfVoxelAlongZ; k++)
244  {
245  G4int v = matrix -> Index(i, j, k);
246  for (size_t ion=0; ion < ionLetStore.size(); ion++)
247  {
248 
249  analysis -> FillLetFragmentTuple( i, j, k, ionLetStore[ion].A, ionLetStore[ion].Z, ionLetStore[ion].letDN[v]);
250 
251 
252  }
253  }
254 
255 #endif
256 }
static HadrontherapyAnalysisManager * GetInstance()
int G4int
Definition: G4Types.hh:78

Field Documentation

G4bool HadrontherapyLet::doCalculation = false
static

Definition at line 68 of file HadrontherapyLet.hh.

Referenced by FillEnergySpectrum().


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