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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/dna/cellularPhantom/src/RunAction.cc (Version 11.3.0) and /examples/advanced/dna/cellularPhantom/src/RunAction.cc (Version 8.2.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // -------------------------------------------    
 27 //       MONTE CARLO SIMULATION OF REALISTIC G    
 28 //                                                
 29 // Authors and contributors:                      
 30 // P. Barberet, S. Incerti, N. H. Tran, L. Mor    
 31 //                                                
 32 // University of Bordeaux, CNRS, LP2i, UMR5797    
 33 //                                                
 34 // If you use this code, please cite the follo    
 35 // P. Barberet et al.,                            
 36 // "Monte-Carlo dosimetry on a realistic cell     
 37 // geometry exposed to alpha particles."          
 38 // Ph. Barberet et al 2012 Phys. Med. Biol. 57    
 39 // doi: 110.1088/0031-9155/57/8/2189              
 40 // -------------------------------------------    
 41                                                   
 42 #include "RunAction.hh"                           
 43                                                   
 44 #include "G4UnitsTable.hh"                        
 45                                                   
 46 //....oooOO0OOooo........oooOO0OOooo........oo    
 47                                                   
 48 RunAction::RunAction()                            
 49 :G4UserRunAction()                                
 50 {                                                 
 51   auto man = G4AnalysisManager::Instance();       
 52   man->SetDefaultFileType("root");                
 53   man->SetNtupleMerging(true);                    
 54   man->SetFirstNtupleId(1);                       
 55                                                   
 56   // Create 1st ntuple (id = 1)                   
 57   man->CreateNtuple("ntuple1", "RED");            
 58   man->CreateNtupleDColumn("x");                  
 59   man->CreateNtupleDColumn("y");                  
 60   man->CreateNtupleDColumn("z");                  
 61   man->CreateNtupleDColumn("energy");             
 62   man->CreateNtupleDColumn("dose");               
 63   man->CreateNtupleIColumn("voxelID");            
 64   man->FinishNtuple();                            
 65                                                   
 66   // Create 2nd ntuple (id = 2)                   
 67   man->CreateNtuple("ntuple2", "GREEN");          
 68   man->CreateNtupleDColumn("x");                  
 69   man->CreateNtupleDColumn("y");                  
 70   man->CreateNtupleDColumn("z");                  
 71   man->CreateNtupleDColumn("energy");             
 72   man->CreateNtupleDColumn("dose");               
 73   man->CreateNtupleIColumn("voxelID");            
 74   man->FinishNtuple();                            
 75                                                   
 76   // Create 3rd ntuple (id = 3)                   
 77   man->CreateNtuple("ntuple3", "BLUE");           
 78   man->CreateNtupleDColumn("x");                  
 79   man->CreateNtupleDColumn("y");                  
 80   man->CreateNtupleDColumn("z");                  
 81   man->CreateNtupleDColumn("energy");             
 82   man->CreateNtupleDColumn("dose");               
 83   man->CreateNtupleIColumn("voxelID");            
 84   man->FinishNtuple();                            
 85 }                                                 
 86                                                   
 87 //....oooOO0OOooo........oooOO0OOooo........oo    
 88                                                   
 89 RunAction::~RunAction()                           
 90 {                                                 
 91   delete[] fVoxelEnergy;                          
 92 }                                                 
 93                                                   
 94 //....oooOO0OOooo........oooOO0OOooo........oo    
 95                                                   
 96 void RunAction::BeginOfRunAction(const G4Run *    
 97 {                                                 
 98   // Analysis manager                             
 99   auto man = G4AnalysisManager::Instance();       
100   man->OpenFile("phantom");                       
101                                                   
102   // Access phantom singleton                     
103   fMyPhantomParam = CellParameterisation::Inst    
104                                                   
105   fNbVoxels = fMyPhantomParam->GetPhantomTotal    
106                                                   
107   // Allocates the array receiving the energy     
108   fVoxelEnergy = new G4double[fNbVoxels];         
109                                                   
110   // Initialisation of the energy array           
111   for (G4int i = 0; i < fNbVoxels; i++) fVoxel    
112 }                                                 
113                                                   
114 //....oooOO0OOooo........oooOO0OOooo........oo    
115                                                   
116 void RunAction::EndOfRunAction(const G4Run * /    
117 {                                                 
118   auto man = G4AnalysisManager::Instance();       
119                                                   
120   G4double X, Y, Z;                               
121                                                   
122   // Total mass of voxel                          
123   G4double redMassTot=0.;                         
124   G4double greenMassTot=0.;                       
125   G4double blueMassTot=0.;                        
126                                                   
127   redMassTot = fMyPhantomParam->GetRedMass();     
128   greenMassTot = fMyPhantomParam->GetGreenMass    
129   blueMassTot = fMyPhantomParam->GetBlueMass()    
130                                                   
131   // (Optional) Numbers of voxel                  
132   //G4double redVox=0;                            
133   //G4double greenVox=0;                          
134   //G4double blueVox=0;                           
135   //redVox = fMyPhantomParam->GetRedTotalPixel    
136   //greenVox = fMyPhantomParam->GetGreenTotalP    
137   //blueVox = fMyPhantomParam->GetBlueTotalPix    
138                                                   
139   // (Optional) Single voxel mass                 
140   //G4double redMass=0.;                          
141   //G4double greenMass=0.;                        
142   //G4double blueMass=0.;                         
143   //redMass = redMassTot/redVox;                  
144   //greenMass = greenMassTot/greenVox;            
145   //blueMass = blueMassTot/blueVox;               
146                                                   
147   // Save x, y, z and energy for every voxel h    
148   // Energy is in keV                             
149   // Dose is in Gy                                
150                                                   
151   for (G4int i = 0; i < fMyPhantomParam->GetPh    
152   {                                               
153     if (fVoxelEnergy[i] > 0.)                     
154     {                                             
155       X = (fMyPhantomParam->GetVoxelThreeVecto    
156       Y = (fMyPhantomParam->GetVoxelThreeVecto    
157       Z = (fMyPhantomParam->GetVoxelThreeVecto    
158                                                   
159       if (fMyPhantomParam->GetMaterial(i) == 1    
160       {                                           
161         man->FillNtupleDColumn(1,0,X);            
162         man->FillNtupleDColumn(1,1,Y);            
163         man->FillNtupleDColumn(1,2,Z);            
164         man->FillNtupleDColumn(1,3,fVoxelEnerg    
165         man->FillNtupleDColumn(1,4,((fVoxelEne    
166         man->FillNtupleIColumn(1,5,i);            
167         man->AddNtupleRow(1);                     
168       }                                           
169                                                   
170       else if (fMyPhantomParam->GetMaterial(i)    
171       {                                           
172         man->FillNtupleDColumn(2,0,X);            
173         man->FillNtupleDColumn(2,1,Y);            
174         man->FillNtupleDColumn(2,2,Z);            
175         man->FillNtupleDColumn(2,3,fVoxelEnerg    
176         man->FillNtupleDColumn(2,4,((fVoxelEne    
177         man->FillNtupleIColumn(2,5,i);            
178         man->AddNtupleRow(2);                     
179       }                                           
180                                                   
181       else if (fMyPhantomParam->GetMaterial(i)    
182       {                                           
183         man->FillNtupleDColumn(3,0,X);            
184         man->FillNtupleDColumn(3,1,Y);            
185         man->FillNtupleDColumn(3,2,Z);            
186         man->FillNtupleDColumn(3,3,fVoxelEnerg    
187         man->FillNtupleDColumn(3,4,((fVoxelEne    
188         man->FillNtupleIColumn(3,5,i);            
189         man->AddNtupleRow(3);                     
190       }                                           
191     }                                             
192   }                                               
193                                                   
194   // Save histograms                              
195   man->Write();                                   
196   man->CloseFile();                               
197                                                   
198   // Complete clean-up                            
199   man->Clear();                                   
200 }                                                 
201