69 if (instance)
delete instance;
70 instance =
new IORTMatrix(voxelX, voxelY, voxelZ, mass);
81 numberOfVoxelAlongX = voxelX;
82 numberOfVoxelAlongY = voxelY;
83 numberOfVoxelAlongZ = voxelZ;
86 matrix =
new G4double[numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ];
89 G4cout <<
"IORTMatrix: Memory space to store physical dose into " <<
90 numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ <<
91 " voxels has been allocated " <<
G4endl;
93 else G4Exception(
"IORTMatrix::IORTMatrix()",
"IORT0005",
FatalException,
"Error: can't allocate memory to store physical dose!");
97 hitTrack =
new G4int[numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ];
113 for (
size_t i=0; i<ionStore.size(); i++)
115 delete[] ionStore[i].dose;
116 delete[] ionStore[i].fluence;
128 for(
int i=0;i<numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ;i++)
138 for (
size_t i=0; i<ionStore.size(); i++)
147 for(
G4int i=0; i<numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ; i++) hitTrack[i] = 0;
152 return &(hitTrack[
Index(i,j,k)]);
167 if ( (energyDeposit <=0. && !fluence) || !
secondary)
return false;
169 G4int PDGencoding = particleDef -> GetPDGEncoding();
170 PDGencoding -= PDGencoding%10;
173 for (
size_t l=0; l < ionStore.size(); l++)
175 if (ionStore[l].PDGencoding == PDGencoding )
177 if ( ((trackID == 1) && (ionStore[l].isPrimary)) || ((trackID !=1) && (!ionStore[l].isPrimary)))
179 if (energyDeposit > 0.) ionStore[l].dose[
Index(i, j, k)] += energyDeposit/massOfVoxel;
182 if (fluence) ionStore[l].fluence[
Index(i, j, k)]++;
188 G4int Z = particleDef-> GetAtomicNumber();
189 G4int A = particleDef-> GetAtomicMass();
191 G4String fullName = particleDef -> GetParticleName();
192 G4String name = fullName.substr (0, fullName.find(
"[") );
196 (trackID == 1) ?
true:
false,
202 new G4double[numberOfVoxelAlongX * numberOfVoxelAlongY * numberOfVoxelAlongZ],
203 new unsigned int[numberOfVoxelAlongX * numberOfVoxelAlongY * numberOfVoxelAlongZ]
208 for(
G4int q=0; q<numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ; q++)
213 if (energyDeposit > 0.) newIon.
dose[
Index(i, j, k)] += energyDeposit/massOfVoxel;
216 ionStore.push_back(newIon);
245 ofs.open(file, std::ios::out);
248 for(
G4int i = 0; i < numberOfVoxelAlongX; i++)
249 for(
G4int j = 0; j < numberOfVoxelAlongY; j++)
250 for(
G4int k = 0; k < numberOfVoxelAlongZ; k++)
254 if (psize ==
sizeof(
unsigned int))
256 unsigned int* pdata = (
unsigned int*)data;
257 if (pdata[n]) ofs << i <<
'\t' << j <<
'\t' <<
258 k <<
'\t' << pdata[
n] <<
G4endl;
263 if (pdata[n]) ofs << i <<
'\t' << j <<
'\t' <<
264 k <<
'\t' << pdata[
n] <<
G4endl;
275 for (
size_t i=0; i < ionStore.size(); i++){
276 StoreMatrix(ionStore[i].
name +
"_Fluence.out", ionStore[i].fluence,
sizeof(
unsigned int));
283 for (
size_t i=0; i < ionStore.size(); i++){
294 filename = (file==
"") ? stdFile:file;
296 std::sort(ionStore.begin(), ionStore.end());
297 G4cout <<
"Dose is being written to " << filename <<
G4endl;
298 ofs.open(filename, std::ios::out);
302 ofs << std::setprecision(6) <<
std::left <<
305 ofs << std::setw(
width) <<
"Dose(MeV/g)";
308 for (
size_t l=0; l < ionStore.size(); l++)
310 G4String a = (ionStore[l].isPrimary) ?
"_1":
"";
311 ofs << std::setw(
width) << ionStore[l].name + a <<
312 std::setw(
width) << ionStore[l].name +
a;
334 for(
G4int i = 0; i < numberOfVoxelAlongX; i++)
335 for(
G4int j = 0; j < numberOfVoxelAlongY; j++)
336 for(
G4int k = 0; k < numberOfVoxelAlongZ; k++)
343 ofs << i <<
'\t' << j <<
'\t' << k <<
'\t';
345 ofs << std::setw(
width) << matrix[
n]/massOfVoxel/doseUnit;
348 for (
size_t l=0; l < ionStore.size(); l++)
351 ofs << std::setw(
width) << ionStore[l].dose[
n]/massOfVoxel/doseUnit <<
352 std::setw(
width) << ionStore[l].fluence[
n];
365 for(
G4int i = 0; i < numberOfVoxelAlongX; i++)
366 for(
G4int j = 0; j < numberOfVoxelAlongY; j++)
367 for(
G4int k = 0; k < numberOfVoxelAlongZ; k++)
370 for (
size_t l=0; l < ionStore.size(); l++)
374 analysis -> FillVoxelFragmentTuple( i, j, k,
377 ionStore[l].dose[n]/massOfVoxel/doseUnit,
378 ionStore[l].fluence[n] );
390 matrix[
Index(i,j,k)] += energyDeposit;
std::vector< ExP01TrackerHit * > a
void StoreMatrix(G4String file, void *data, size_t psize)
G4int * GetHitTrack(G4int i, G4int j, G4int k)
void TotalEnergyDeposit()
const XML_Char const XML_Char * data
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
static IORTAnalysisManager * GetInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4bool Fill(G4int, G4ParticleDefinition *particleDef, G4int i, G4int j, G4int k, G4double energyDeposit, G4bool fluence=false)
static constexpr double MeV
static IORTMatrix * GetInstance()
void StoreDoseFluenceRoot()
void StoreDoseFluenceAscii(G4String filename="")
G4int Index(G4int i, G4int j, G4int k)