Ignore:
Timestamp:
Jun 14, 2010, 3:54:58 PM (14 years ago)
Author:
garnier
Message:

geant4.9.4 beta rc0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/advanced/hadrontherapy/include/HadrontherapyMatrix.hh

    r1230 r1313  
    2929#ifndef HadrontherapyMatrix_H
    3030#define HadrontherapyMatrix_H 1
    31 
     31#include <G4ParticleDefinition.hh>
    3232#include "globals.hh"
    3333#include <vector>
     34#include <fstream>
    3435
    3536// The information: energy deposit and position in the phantom
    3637// is stored in a matrix
    3738
     39// type struct useful to store nucludes data
     40struct ion
     41 {
     42     G4bool isPrimary;   // true if particle is primary
     43     G4int PDGencoding;  // Particle data group id for the particle
     44     //G4String extName; //  AZ[excitation energy]: like He3[1277.4], He4[0.0], Li7[231.4], ...
     45     G4String name;      // simple name without excitation energy: He3, He4, Li7, ...
     46     G4int len;          // name length
     47     G4int Z;            // atomic number
     48     G4int A;            // mass number
     49     G4double *dose;     // pointer to dose matrix
     50     unsigned int    *fluence;  // pointer to fluence matrix
     51     //friend bool operator<(const ion& a, const ion& b) {return (a.Z == b.Z) ? b.A < a.A : b.Z < a.Z ;}
     52     G4bool operator<(const ion& a) const{return (this->Z == a.Z) ? this-> A < a.A : this->Z < a.Z ;}
     53 };
     54
    3855class HadrontherapyMatrix
    3956{
    4057private:
    41   HadrontherapyMatrix(G4int voxelX, G4int voxelY, G4int voxelZ); //<--- this is supposed to be a singleton
     58  HadrontherapyMatrix(G4int numberOfVoxelAlongX,
     59                      G4int numberOfVoxelAlongY,
     60                      G4int numberOfVoxelAlongZ,
     61                      G4double massOfVoxel); //< this is supposed to be a singleton
     62
    4263
    4364public:
    4465
    4566  ~HadrontherapyMatrix();
    46 // Get object instance only
    47   static HadrontherapyMatrix* getInstance();
    48 // Make & Get instance
    49   static HadrontherapyMatrix* getInstance(G4int nX, G4int nY, G4int nZ);
    50  
    51   void flush();
    52  
     67  // Get object instance only
     68  static HadrontherapyMatrix* GetInstance();
     69  // Make & Get instance
     70  static HadrontherapyMatrix* GetInstance(G4int nX, G4int nY, G4int nZ, G4double mass);
     71
     72  static G4bool secondaries;
     73  // Full list of generated nuclides
     74  void PrintNuclides();
     75  // Hit array marker (useful to avoid multiple counts of fluence)
     76  void ClearHitTrack();
     77  G4int* GetHitTrack(G4int i, G4int j, G4int k);
     78
     79  // All the elements of the matrix are initialised to zero
    5380  void Initialize();
    54   // All the elements of the matrix are initialised to zero
    55    
     81  void Clear();
     82  // Fill DOSE/fluence matrix for particle:
     83  // if fluence parameter is true then fluence at voxel (i, j, k) is increased
     84  // else energyDeposit fill the dose matrix for voxel (i,j,k)
     85  G4bool Fill(G4int, G4ParticleDefinition* particleDef, G4int i, G4int j, G4int k, G4double energyDeposit, G4bool fluence=false);
     86
     87  // Fill TOTAL DOSE matrix for primary particles only
    5688  void Fill(G4int i, G4int j, G4int k, G4double energyDeposit);
    5789  // The matrix is filled with the energy deposit
    5890  // in the element corresponding to the voxel of the phantom where
    5991  // the energy deposit was registered
    60  
    61   void TotalEnergyDeposit();
     92 
    6293  // Store the information of the matrix in a ntuple and in
    6394  // a 1D Histogram
    64  
    65   inline G4int Index(G4int i, G4int j, G4int k){ return (i * numberVoxelY + j) * numberVoxelZ + k; }
    66   // Get a unique index from a three dimensional voxel information
     95  void TotalEnergyDeposit();
     96   
     97  // Store single matrix data to filename
     98  void StoreMatrix(G4String file, void* data,size_t psize);
     99  // Store all fluence data to filenames
     100  void StoreFluenceData();
     101  // Store all dose data to filenames
     102  void StoreDoseData();
    67103
     104  // Store all data (except the total dose) to ONE filename
     105  void StoreDoseFluenceAscii();
     106
     107#ifdef G4ANALYSIS_USE_ROOT
     108  void StoreDoseFluenceRoot();
     109#endif
     110
     111  inline G4int Index(G4int i, G4int j, G4int k) { return (i * numberOfVoxelAlongY + j) * numberOfVoxelAlongZ + k; }
     112  // Get a unique index from  a three dimensional one
     113
     114  G4double * GetMatrix(){return matrix;}
     115
     116  G4int GetNvoxel(){return numberOfVoxelAlongX*numberOfVoxelAlongY*numberOfVoxelAlongZ;}
     117  // Total number of voxels read only access 
     118  G4int GetNumberOfVoxelAlongX(){return numberOfVoxelAlongX;}
     119  G4int GetNumberOfVoxelAlongY(){return numberOfVoxelAlongY;}
     120  G4int GetNumberOfVoxelAlongZ(){return numberOfVoxelAlongZ;}
    68121private:
    69122
    70123  static HadrontherapyMatrix* instance;
    71   G4int numberVoxelX;
    72   G4int numberVoxelY;
    73   G4int numberVoxelZ;
     124  G4int numberOfVoxelAlongX;
     125  G4int numberOfVoxelAlongY;
     126  G4int numberOfVoxelAlongZ;
     127  G4double massOfVoxel;
     128
    74129  G4double* matrix;
     130  G4int* hitTrack;
     131  G4String filename;
     132  std::ofstream ofs;
     133
     134  // Dose&fluence data store
     135  std::vector <ion> ionStore;
     136  // want secondaries?
     137  G4double doseUnit;
    75138};
    76139#endif
     140
Note: See TracChangeset for help on using the changeset viewer.