78 G4cout <<
"HadrontherapyMatrix: Memory space to store physical dose into " <<
80 " voxels has been allocated " <<
G4endl;
82 else G4Exception(
"HadrontherapyMatrix::HadrontherapyMatrix()",
"Hadrontherapy0005",
FatalException,
"Can't allocate memory to store physical dose!");
102 for (
size_t i=0; i<
ionStore.size(); i++)
127 for (
size_t i=0; i<
ionStore.size(); i++)
156 if ( (energyDeposit <=0. && !fluence) || !
secondary)
return false;
158 G4int PDGencoding = particleDef -> GetPDGEncoding();
159 PDGencoding -= PDGencoding%10;
162 for (
size_t l=0; l <
ionStore.size(); l++)
164 if (
ionStore[l].PDGencoding == PDGencoding )
166 if ( (trackID ==1 &&
ionStore[l].isPrimary) || (trackID !=1 && !
ionStore[l].isPrimary))
168 if (energyDeposit > 0.)
ionStore[l].dose[
Index(i, j, k)] += energyDeposit;
177 G4int Z = particleDef-> GetAtomicNumber();
178 G4int A = particleDef-> GetAtomicMass();
180 G4String fullName = particleDef -> GetParticleName();
181 G4String name = fullName.substr (0, fullName.find(
"[") );
185 (trackID == 1) ?
true:
false,
202 if (energyDeposit > 0.) newIon.
dose[
Index(i, j, k)] += energyDeposit;
234 ofs.open(file, std::ios::out);
243 if (psize ==
sizeof(
unsigned int))
245 unsigned int* pdata = (
unsigned int*)data;
246 if (pdata[n])
ofs << i <<
'\t' << j <<
'\t' <<
247 k <<
'\t' << pdata[
n] <<
G4endl;
252 if (pdata[n])
ofs << i <<
'\t' << j <<
'\t' <<
253 k <<
'\t' << pdata[
n] <<
G4endl;
264 for (
size_t i=0; i <
ionStore.size(); i++){
272 for (
size_t i=0; i <
ionStore.size(); i++){
294 ofs << std::setw(
width) <<
"Dose(Gy)";
297 for (
size_t l=0; l <
ionStore.size(); l++)
332 ofs << i <<
'\t' << j <<
'\t' << k <<
'\t';
337 for (
size_t l=0; l <
ionStore.size(); l++)
351 #ifdef G4ANALYSIS_USE_ROOT
352 void HadrontherapyMatrix::StoreDoseFluenceRoot()
355 if (analysis -> IsTheTFile())
362 for (
size_t l=0; l <
ionStore.size(); l++)
366 analysis -> FillVoxelFragmentTuple( i, j, k,
393 #ifdef G4ANALYSIS_USE_ROOT
403 #ifdef G4ANALYSIS_USE_ROOT
405 if (analysis -> IsTheTFile() )
static HadrontherapyAnalysisManager * GetInstance()
Get the pointer to the analysis manager.
G4int Index(G4int i, G4int j, G4int k)
void StoreDoseFluenceAscii(G4String filename="")
G4int numberOfVoxelAlongY
G4int numberOfVoxelAlongZ
static HadrontherapyMatrix * GetInstance()
void StoreMatrix(G4String file, void *data, size_t psize)
G4GLOB_DLL std::ostream G4cout
G4int * GetHitTrack(G4int i, G4int j, G4int k)
G4bool Fill(G4int, G4ParticleDefinition *particleDef, G4int i, G4int j, G4int k, G4double energyDeposit, G4bool fluence=false)
static const G4double A[nN]
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
HadrontherapyMatrix(G4int numberOfVoxelAlongX, G4int numberOfVoxelAlongY, G4int numberOfVoxelAlongZ, G4double massOfVoxel)
void TotalEnergyDeposit()
A class for connecting the simulation to an analysis package.
static HadrontherapyMatrix * instance
std::vector< ion > ionStore
G4int numberOfVoxelAlongX