44 if (instance)
delete instance;
55 :filename(
"Let.out"),matrix(0)
63 "HadrontherapyMatrix not found. Firstly create an instance of it.");
65 nVoxels = matrix -> GetNvoxel();
67 numberOfVoxelAlongX = matrix -> GetNumberOfVoxelAlongX();
68 numberOfVoxelAlongY = matrix -> GetNumberOfVoxelAlongY();
69 numberOfVoxelAlongZ = matrix -> GetNumberOfVoxelAlongZ();
74 detectorMat = pDet -> GetDetectorLogicalVolume() -> GetMaterial();
75 density = detectorMat -> GetDensity();
92 for(
G4int v=0;
v < nVoxels;
v++) totalLetD[
v] = DtotalLetD[
v] = 0.;
100 for (
size_t i=0; i < ionLetStore.size(); i++)
102 delete [] ionLetStore[i].letDN;
103 delete [] ionLetStore[i].letDD;
114 if (DE <= 0. || DX <=0.)
return;
116 G4int Z = particleDef -> GetAtomicNumber();
119 G4int PDGencoding = particleDef -> GetPDGEncoding();
120 PDGencoding -= PDGencoding%10;
122 G4int voxel = matrix -> Index(i,j,k);
124 totalLetD[voxel] += DE*(DE/DX);
125 DtotalLetD[voxel] += DE;
131 for (l=0; l < ionLetStore.size(); l++)
133 if (ionLetStore[l].PDGencoding == PDGencoding)
134 if ( ((trackID ==1) && (ionLetStore[l].isPrimary)) || ((trackID !=1) && (!ionLetStore[l].isPrimary)))
138 if (l == ionLetStore.size())
141 G4int A = particleDef -> GetAtomicMass();
143 G4String fullName = particleDef -> GetParticleName();
144 G4String name = fullName.substr (0, fullName.find(
"[") );
148 (trackID == 1) ?
true:
false,
160 ionLetStore.push_back(ion);
164 ionLetStore[l].letDN[voxel] += DE*(DE/DX);
165 ionLetStore[l].letDD[voxel] += DE;
174 for(
G4int v=0; v < nVoxels; v++) if (DtotalLetD[v]>0.) totalLetD[
v] = totalLetD[
v]/DtotalLetD[
v];
176 std::sort(ionLetStore.begin(), ionLetStore.end());
181 for (
size_t ion=0;
ion < ionLetStore.size();
ion++)
183 if (ionLetStore[
ion].letDD[
v] >0.) ionLetStore[
ion].letDN[
v] = ionLetStore[
ion].letDN[
v] / ionLetStore[
ion].letDD[
v];
193 if(ionLetStore.size())
195 ofs.open(filename, std::ios::out);
200 ofs << std::setprecision(6) <<
std::left <<
202 ofs << std::setw(
width) <<
"LDT";
203 for (
size_t l=0; l < ionLetStore.size(); l++)
205 G4String a = (ionLetStore[l].isPrimary) ?
"_1":
"";
206 ofs << std::setw(
width) << ionLetStore[l].name +
a ;
211 for(
G4int i = 0; i < numberOfVoxelAlongX; i++)
212 for(
G4int j = 0; j < numberOfVoxelAlongY; j++)
213 for(
G4int k = 0; k < numberOfVoxelAlongZ; k++)
215 G4int v = matrix -> Index(i, j, k);
217 for (
size_t l=0; l < ionLetStore.size(); l++)
220 if(ionLetStore[l].letDN)
223 ofs << i <<
'\t' << j <<
'\t' << k <<
'\t';
226 for (
size_t ll=0; ll < ionLetStore.size(); ll++)
228 ofs << std::setw(
width) << ionLetStore[ll].letDN[
v]/(
keV/
um) ;
235 G4cout <<
"Let is being written to " << filename <<
G4endl;
243 #ifdef G4ANALYSIS_USE_ROOT
247 for(
G4int i = 0; i < numberOfVoxelAlongX; i++)
248 for(
G4int j = 0; j < numberOfVoxelAlongY; j++)
249 for(
G4int k = 0; k < numberOfVoxelAlongZ; k++)
251 G4int v = matrix -> Index(i, j, k);
252 for (
size_t ion=0;
ion < ionLetStore.size();
ion++)
255 analysis -> FillLetFragmentTuple( i, j, k, ionLetStore[
ion].
A, ionLetStore[
ion].Z, ionLetStore[
ion].letDN[v]);
static G4bool doCalculation
void FillEnergySpectrum(G4int trackID, G4ParticleDefinition *particleDef, G4double DE, G4double DX, G4int i, G4int j, G4int k)
static HadrontherapyAnalysisManager * GetInstance()
std::vector< ExP01TrackerHit * > a
static HadrontherapyLet * GetInstance()
static HadrontherapyMatrix * GetInstance()
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
static constexpr double um
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4RunManager * GetRunManager()
static constexpr double keV