Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
HadrontherapyMatrix.hh
이 파일의 문서화 페이지로 가기
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 // Hadrontherapy advanced example for Geant4
27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
28 
29 #ifndef HadrontherapyMatrix_H
30 #define HadrontherapyMatrix_H 1
31 #include <G4ParticleDefinition.hh>
32 #include "globals.hh"
33 #include <vector>
34 #include <fstream>
35 #include "g4csv.hh"
36 
37 
38 #ifndef HADRONTHERAPYANALYSISMANAGER_HH
39 #define HADRONTHERAPYANALYSISMANAGER_HH 1
40 
42 
47 {
48 private:
56 
57 
58 
59 public:
61 
66 
67 
68 
71 
72 };
73 
74 #endif
75 
76 // The information: energy deposit and position in the phantom
77 // is stored in a matrix
78 
79 // type struct useful to store nucludes data
80 
81 
82 struct ion
83 {
84  G4bool isPrimary; // true if particle is primary
85  G4int PDGencoding; // Particle data group id for the particle
86  //G4String extName; // AZ[excitation energy]: like He3[1277.4], He4[0.0], Li7[231.4], ...
87  G4String name; // simple name without excitation energy: He3, He4, Li7, ...
88  std::string::size_type len; // name length
89  G4int Z; // atomic number
90  G4int A; // mass number
91  G4double *dose; // pointer to dose matrix
92  unsigned int *fluence; // pointer to fluence matrix
93  //friend bool operator<(const ion& a, const ion& b) {return (a.Z == b.Z) ? b.A < a.A : b.Z < a.Z ;}
94  G4bool operator<(const ion& a) const{return (this->Z == a.Z) ? this-> A < a.A : this->Z < a.Z ;}
95 };
96 
98 {
99 private:
103  G4double massOfVoxel); //< this is supposed to be a singleton
104 
105 
106 public:
107 
109  // Get object instance only
111  // Make & Get instance
112  static HadrontherapyMatrix* GetInstance(G4int nX, G4int nY, G4int nZ, G4double mass);
113 
115  // Full list of generated nuclides
116 
117 
118 
119  void PrintNuclides();
120  // Hit array marker (useful to avoid multiple counts of fluence)
121  void ClearHitTrack();
122  G4int* GetHitTrack(G4int i, G4int j, G4int k);
123 
124  // All the elements of the matrix are initialised to zero
125  void Initialize();
126  void Clear();
127  // Fill DOSE/fluence matrix for particle:
128  // if fluence parameter is true then fluence at voxel (i, j, k) is increased
129  // else energyDeposit fill the dose matrix for voxel (i,j,k)
130  G4bool Fill(G4int, G4ParticleDefinition* particleDef, G4int i, G4int j, G4int k, G4double energyDeposit, G4bool fluence=false);
131 
132  // Fill TOTAL DOSE matrix for primary particles only
133  void Fill(G4int i, G4int j, G4int k, G4double energyDeposit);
134  // The matrix is filled with the energy deposit
135  // in the element corresponding to the voxel of the phantom where
136  // the energy deposit was registered
137 
138  // Store the information of the matrix in a ntuple and in
139  // a 1D Histogram
140  //void TotalEnergyDeposit();
141 
142  // Store single matrix data to filename
143  void StoreMatrix(G4String file, void* data,size_t psize);
144  // Store all fluence data to filenames
145  void StoreFluenceData();
146  // Store all dose data to filenames
147  void StoreDoseData();
148 
149  // Store all data (except the total dose) to ONE filename
151 
152 
153 
154  inline G4int Index(G4int i, G4int j, G4int k) { return (i * numberOfVoxelAlongY + j) * numberOfVoxelAlongZ + k; }
155  // Get a unique index from a three dimensional one
156 
157  G4double * GetMatrix(){return matrix;}
158 
159  G4int GetNvoxel(){return numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ;}
160  // Total number of voxels read only access
164 private:
165 
171 
175  std::ofstream ofs;
176 
177  // Dose&fluence data store
178  std::vector <ion> ionStore;
179  // want secondary particles?
181 };
182 #endif
183 
std::string::size_type len
G4String name
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
static HadrontherapyAnalysisManager * instance
G4bool operator<(const ion &a) const
G4double * dose
static HadrontherapyMatrix * GetInstance()
G4int Index(G4int i, G4int j, G4int k)
std::vector< ion > ionStore
const XML_Char const XML_Char * data
Definition: expat.h:268
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4bool Fill(G4int, G4ParticleDefinition *particleDef, G4int i, G4int j, G4int k, G4double energyDeposit, G4bool fluence=false)
unsigned int * fluence
void StoreDoseFluenceAscii(G4String filename="")
G4int PDGencoding
HadrontherapyAnalysisFileMessenger * fMess
int G4int
Definition: G4Types.hh:78
TFile * file
static HadrontherapyMatrix * instance
G4int * GetHitTrack(G4int i, G4int j, G4int k)
G4bool isPrimary
static HadrontherapyAnalysisManager * GetInstance()
void StoreMatrix(G4String file, void *data, size_t psize)
HadrontherapyMatrix(G4int numberOfVoxelAlongX, G4int numberOfVoxelAlongY, G4int numberOfVoxelAlongZ, G4double massOfVoxel)