Geant4  10.01.p02
IORTMatrix.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // This is the *BASIC* version of IORT, a Geant4-based application
27 //
28 // Main Authors: G.Russo(a,b), C.Casarino*(c), G.C. Candiano(c), G.A.P. Cirrone(d), F.Romano(d)
29 // Contributor Authors: S.Guatelli(e)
30 // Past Authors: G.Arnetta(c), S.E.Mazzaglia(d)
31 //
32 // (a) Fondazione Istituto San Raffaele G.Giglio, Cefalù, Italy
33 // (b) IBFM-CNR , Segrate (Milano), Italy
34 // (c) LATO (Laboratorio di Tecnologie Oncologiche), Cefalù, Italy
35 // (d) Laboratori Nazionali del Sud of the INFN, Catania, Italy
36 // (e) University of Wallongong, Australia
37 //
38 // *Corresponding author, email to carlo.casarino@polooncologicocefalu.it
40 #ifndef IORTMatrix_H
41 #define IORTMatrix_H 1
42 #include <G4ParticleDefinition.hh>
43 #include "globals.hh"
44 #include <vector>
45 #include <fstream>
46 
47 // The information: energy deposit and position in the phantom
48 // is stored in a matrix
49 
50 // type struct useful to store nucludes data
51 struct ion
52 {
53  G4bool isPrimary; // true if particle is primary
54  G4int PDGencoding; // Particle data group id for the particle
55  //G4String extName; // AZ[excitation energy]: like He3[1277.4], He4[0.0], Li7[231.4], ...
56  G4String name; // simple name without excitation energy: He3, He4, Li7, ...
57  std::string::size_type len; // name length
58  G4int Z; // atomic number
59  G4int A; // mass number
60  G4double *dose; // pointer to dose matrix
61  unsigned int *fluence; // pointer to fluence matrix
62  //friend bool operator<(const ion& a, const ion& b) {return (a.Z == b.Z) ? b.A < a.A : b.Z < a.Z ;}
63  G4bool operator<(const ion& a) const{return (this->Z == a.Z) ? this-> A < a.A : this->Z < a.Z ;}
64 };
65 
66 class IORTMatrix
67 {
68 private:
72  G4double massOfVoxel); //< this is supposed to be a singleton
73 
74 
75 public:
76 
77  ~IORTMatrix();
78  // Get object instance only
79  static IORTMatrix* GetInstance();
80  // Make & Get instance
81  static IORTMatrix* GetInstance(G4int nX, G4int nY, G4int nZ, G4double mass);
82 
83  static G4bool secondary;
84  // Full list of generated nuclides
85  void PrintNuclides();
86  // Hit array marker (useful to avoid multiple counts of fluence)
87  void ClearHitTrack();
88  G4int* GetHitTrack(G4int i, G4int j, G4int k);
89 
90  // All the elements of the matrix are initialised to zero
91  void Initialize();
92  void Clear();
93  // Fill DOSE/fluence matrix for particle:
94  // if fluence parameter is true then fluence at voxel (i, j, k) is increased
95  // else energyDeposit fill the dose matrix for voxel (i,j,k)
96  G4bool Fill(G4int, G4ParticleDefinition* particleDef, G4int i, G4int j, G4int k, G4double energyDeposit, G4bool fluence=false);
97 
98  // Fill TOTAL DOSE matrix for primary particles only
99  void Fill(G4int i, G4int j, G4int k, G4double energyDeposit);
100  // The matrix is filled with the energy deposit
101  // in the element corresponding to the voxel of the phantom where
102  // the energy deposit was registered
103 
104  // Store the information of the matrix in a ntuple and in
105  // a 1D Histogram
106  void TotalEnergyDeposit();
107 
108  // Store single matrix data to filename
109  void StoreMatrix(G4String file, void* data,size_t psize);
110  // Store all fluence data to filenames
111  void StoreFluenceData();
112  // Store all dose data to filenames
113  void StoreDoseData();
114 
115  // Store all data (except the total dose) to ONE filename
117 
118 #ifdef G4ANALYSIS_USE_ROOT
119  void StoreDoseFluenceRoot();
120 #endif
121 
122  inline G4int Index(G4int i, G4int j, G4int k) { return (i * numberOfVoxelAlongY + j) * numberOfVoxelAlongZ + k; }
123  // Get a unique index from a three dimensional one
124 
125  G4double * GetMatrix(){return matrix;}
126 
127  G4int GetNvoxel(){return numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ;}
128  // Total number of voxels read only access
132 private:
133 
139 
143  std::ofstream ofs;
144 
145  // Dose&fluence data store
146  std::vector <ion> ionStore;
147  // want secondary particles?
149 };
150 #endif
151 
std::string::size_type len
G4String name
void Clear()
Definition: IORTMatrix.cc:111
G4int numberOfVoxelAlongY
Definition: IORTMatrix.hh:136
G4bool operator<(const ion &a) const
Definition: IORTMatrix.hh:63
G4double * dose
void StoreMatrix(G4String file, void *data, size_t psize)
Definition: IORTMatrix.cc:241
static G4bool secondary
Definition: IORTMatrix.hh:83
G4double a
Definition: TRTMaterials.hh:39
G4int * GetHitTrack(G4int i, G4int j, G4int k)
Definition: IORTMatrix.cc:150
G4double massOfVoxel
Definition: IORTMatrix.hh:138
int G4int
Definition: G4Types.hh:78
G4double doseUnit
Definition: IORTMatrix.hh:148
void TotalEnergyDeposit()
Definition: IORTMatrix.cc:399
G4int GetNumberOfVoxelAlongZ()
Definition: IORTMatrix.hh:131
G4String stdFile
Definition: IORTMatrix.hh:142
G4double * matrix
Definition: IORTMatrix.hh:140
unsigned int * fluence
bool G4bool
Definition: G4Types.hh:79
G4int GetNumberOfVoxelAlongY()
Definition: IORTMatrix.hh:130
void StoreDoseData()
Definition: IORTMatrix.cc:280
void StoreFluenceData()
Definition: IORTMatrix.cc:273
G4int numberOfVoxelAlongX
Definition: IORTMatrix.hh:135
void ClearHitTrack()
Definition: IORTMatrix.cc:145
G4int PDGencoding
G4int GetNumberOfVoxelAlongX()
Definition: IORTMatrix.hh:129
G4bool Fill(G4int, G4ParticleDefinition *particleDef, G4int i, G4int j, G4int k, G4double energyDeposit, G4bool fluence=false)
Definition: IORTMatrix.cc:161
static IORTMatrix * instance
Definition: IORTMatrix.hh:134
G4int GetNvoxel()
Definition: IORTMatrix.hh:127
IORTMatrix(G4int numberOfVoxelAlongX, G4int numberOfVoxelAlongY, G4int numberOfVoxelAlongZ, G4double massOfVoxel)
Definition: IORTMatrix.cc:74
void PrintNuclides()
Definition: IORTMatrix.cc:136
G4double * GetMatrix()
Definition: IORTMatrix.hh:125
G4int * hitTrack
Definition: IORTMatrix.hh:141
void Initialize()
Definition: IORTMatrix.cc:123
static IORTMatrix * GetInstance()
Definition: IORTMatrix.cc:61
std::vector< ion > ionStore
Definition: IORTMatrix.hh:146
double G4double
Definition: G4Types.hh:76
G4String filename
Definition: IORTMatrix.hh:142
G4int numberOfVoxelAlongZ
Definition: IORTMatrix.hh:137
std::ofstream ofs
Definition: IORTMatrix.hh:143
G4bool isPrimary
void StoreDoseFluenceAscii(G4String filename="")
Definition: IORTMatrix.cc:291
G4int Index(G4int i, G4int j, G4int k)
Definition: IORTMatrix.hh:122