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];
362 #ifdef G4ANALYSIS_USE_ROOT
363 void IORTMatrix::StoreDoseFluenceRoot()
366 if (analysis -> IsTheTFile())
368 for(
G4int i = 0; i < numberOfVoxelAlongX; i++)
369 for(
G4int j = 0; j < numberOfVoxelAlongY; j++)
370 for(
G4int k = 0; k < numberOfVoxelAlongZ; k++)
373 for (
size_t l=0; l < ionStore.size(); l++)
377 analysis -> FillVoxelFragmentTuple( i, j, k,
380 ionStore[l].
dose[n]/massOfVoxel/doseUnit,
381 ionStore[l].fluence[n] );
394 matrix[
Index(i,j,k)] += energyDeposit;