|
||||
Warning, file /geant4/examples/advanced/hadrontherapy/include/HadrontherapyMatrix.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // Hadrontherapy advanced example for Geant4 0027 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy 0028 0029 #ifndef HadrontherapyMatrix_H 0030 #define HadrontherapyMatrix_H 1 0031 #include <G4ParticleDefinition.hh> 0032 #include "globals.hh" 0033 #include <vector> 0034 #include <fstream> 0035 0036 0037 #ifndef HADRONTHERAPYANALYSISMANAGER_HH 0038 #define HADRONTHERAPYANALYSISMANAGER_HH 1 0039 0040 class HadrontherapyAnalysisFileMessenger; 0041 0042 /** 0043 * A class for connecting the simulation to an analysis package. 0044 */ 0045 class HadrontherapyAnalysis 0046 { 0047 private: 0048 /** 0049 * Analysis manager is a singleton object (there is only one instance). 0050 * The pointer to this object is available through the use of the method GetInstance(); 0051 * 0052 * @see GetInstance 0053 */ 0054 HadrontherapyAnalysis(); 0055 0056 0057 0058 public: 0059 ~HadrontherapyAnalysis(); 0060 0061 /** 0062 * Get the pointer to the analysis manager. 0063 */ 0064 static HadrontherapyAnalysis* GetInstance(); 0065 0066 0067 0068 static HadrontherapyAnalysis* instance; 0069 HadrontherapyAnalysisFileMessenger* fMess; 0070 0071 }; 0072 0073 #endif 0074 0075 // The information: energy deposit and position in the phantom 0076 // is stored in a matrix 0077 0078 // type struct useful to store nucludes data 0079 0080 0081 struct ion 0082 { 0083 G4bool isPrimary; // true if particle is primary 0084 G4int PDGencoding; // Particle data group id for the particle 0085 //G4String extName; // AZ[excitation energy]: like He3[1277.4], He4[0.0], Li7[231.4], ... 0086 G4String name; // simple name without excitation energy: He3, He4, Li7, ... 0087 std::string::size_type len; // name length 0088 G4int Z; // atomic number 0089 G4int A; // mass number 0090 G4double *dose; // pointer to dose matrix 0091 unsigned int *fluence; // pointer to fluence matrix 0092 //friend G4bool operator<(const ion& a, const ion& b) {return (a.Z == b.Z) ? b.A < a.A : b.Z < a.Z ;} 0093 G4bool operator<(const ion& a) const{return (this->Z == a.Z) ? this-> A < a.A : this->Z < a.Z ;} 0094 }; 0095 0096 class HadrontherapyMatrix 0097 { 0098 private: 0099 HadrontherapyMatrix(G4int numberOfVoxelAlongX, 0100 G4int numberOfVoxelAlongY, 0101 G4int numberOfVoxelAlongZ, 0102 G4double massOfVoxel); //< this is supposed to be a singleton 0103 0104 0105 public: 0106 0107 ~HadrontherapyMatrix(); 0108 // Get object instance only 0109 static HadrontherapyMatrix* GetInstance(); 0110 // Make & Get instance 0111 static HadrontherapyMatrix* GetInstance(G4int nX, G4int nY, G4int nZ, G4double mass); 0112 0113 static G4bool secondary; 0114 // Full list of generated nuclides 0115 0116 0117 void PrintNuclides(); 0118 // Hit array marker (useful to avoid multiple counts of fluence) 0119 void ClearHitTrack(); 0120 G4int* GetHitTrack(G4int i, G4int j, G4int k); 0121 0122 // All the elements of the matrix are initialised to zero 0123 void Initialize(); 0124 void Clear(); 0125 // Fill DOSE/fluence matrix for particle: 0126 // if fluence parameter is true then fluence at voxel (i, j, k) is increased 0127 // else energyDeposit fill the dose matrix for voxel (i,j,k) 0128 G4bool Fill(G4int, G4ParticleDefinition* particleDef, G4int i, G4int j, G4int k, G4double energyDeposit, G4bool fluence=false); 0129 0130 // Fill TOTAL DOSE matrix for primary particles only 0131 void Fill(G4int i, G4int j, G4int k, G4double energyDeposit); 0132 // The matrix is filled with the energy deposit 0133 // in the element corresponding to the voxel of the phantom where 0134 // the energy deposit was registered 0135 0136 // Store the information of the matrix in a ntuple and in 0137 // a 1D Histogram 0138 //void TotalEnergyDeposit(); 0139 0140 // Store single matrix data to filename 0141 void StoreMatrix(G4String file, void* data,size_t psize); 0142 // Store all fluence data to filenames 0143 void StoreFluenceData(); 0144 // Store all dose data to filenames 0145 void StoreDoseData(); 0146 0147 // Store all data (except the total dose) to ONE filename 0148 void StoreDoseFluenceAscii(G4String filename = ""); 0149 0150 0151 0152 inline G4int Index(G4int i, G4int j, G4int k) { return (i * numberOfVoxelAlongY + j) * numberOfVoxelAlongZ + k; } 0153 // Get a unique index from a three dimensional one 0154 0155 G4double * GetMatrix(){return matrix;} 0156 0157 G4int GetNvoxel(){return numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ;} 0158 // Total number of voxels read only access 0159 G4int GetNumberOfVoxelAlongX(){return numberOfVoxelAlongX;} 0160 G4int GetNumberOfVoxelAlongY(){return numberOfVoxelAlongY;} 0161 G4int GetNumberOfVoxelAlongZ(){return numberOfVoxelAlongZ;} 0162 private: 0163 0164 static HadrontherapyMatrix* instance; 0165 G4int numberOfVoxelAlongX; 0166 G4int numberOfVoxelAlongY; 0167 G4int numberOfVoxelAlongZ; 0168 G4double massOfVoxel; 0169 0170 G4double* matrix; 0171 G4int* hitTrack; 0172 G4String stdFile, filename; 0173 std::ofstream ofs; 0174 0175 // Dose&fluence data store 0176 std::vector <ion> ionStore; 0177 // want secondary particles? 0178 G4double doseUnit; 0179 }; 0180 #endif 0181
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |