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 ] [ 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/extended/medical/radiobiology/src/Dose.cc (Version 11.3.0) and /examples/extended/medical/radiobiology/src/Dose.cc (Version 7.1.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 /// \file radiobiology/src/Dose.cc                
 28 /// \brief Implementation of the RadioBio::Dos    
 29                                                   
 30 #include "Dose.hh"                                
 31                                                   
 32 #include "G4SystemOfUnits.hh"                     
 33                                                   
 34 #include "DetectorConstruction.hh"                
 35 #include "DoseAccumulable.hh"                     
 36 #include "DoseMessenger.hh"                       
 37 #include "VoxelizedSensitiveDetector.hh"          
 38                                                   
 39 #include <fstream>                                
 40                                                   
 41 namespace RadioBio                                
 42 {                                                 
 43                                                   
 44 #define width 15L                                 
 45                                                   
 46 //....oooOO0OOooo........oooOO0OOooo........oo    
 47                                                   
 48 Dose::Dose()                                      
 49 {                                                 
 50   // Default output filename                      
 51   fPath = "RadioBio_Dose.out";                    
 52                                                   
 53   // Create the messenger                         
 54   fMessenger = new DoseMessenger(this);           
 55                                                   
 56   // Initialize the class                         
 57   Initialize();                                   
 58 }                                                 
 59                                                   
 60 //....oooOO0OOooo........oooOO0OOooo........oo    
 61                                                   
 62 Dose::~Dose()                                     
 63 {                                                 
 64   delete fMessenger;                              
 65 }                                                 
 66                                                   
 67 //....oooOO0OOooo........oooOO0OOooo........oo    
 68                                                   
 69 void Dose::Initialize()                           
 70 {                                                 
 71   if (fVerboseLevel > 0) G4cout << "Dose::Init    
 72                                                   
 73   G4int VoxelNumber = VoxelizedSensitiveDetect    
 74                                                   
 75   fEnDep.resize(VoxelNumber);                     
 76   fDose.resize(VoxelNumber);                      
 77   fInitialized = true;                            
 78 }                                                 
 79                                                   
 80 //....oooOO0OOooo........oooOO0OOooo........oo    
 81                                                   
 82 void Dose::Compute()                              
 83 {                                                 
 84   // Skip Dose computation if calculation not     
 85   if (!fCalculationEnabled) {                     
 86     if (fVerboseLevel > 0) {                      
 87       G4cout << "Dose::Compute() called but sk    
 88     }                                             
 89     return;                                       
 90   }                                               
 91                                                   
 92   if (fCalculated) return;                        
 93                                                   
 94   if (fVerboseLevel > 0) G4cout << "Dose::Comp    
 95                                                   
 96   auto voxSensDet = VoxelizedSensitiveDetector    
 97                                                   
 98   if (voxSensDet == nullptr)                      
 99     G4Exception("Dose::Compute", "VoxNotInit",    
100                 "Calculating dose without voxe    
101                                                   
102   G4double voxelMass = voxSensDet->GetVoxelMas    
103                                                   
104   for (G4int v = 0; v < voxSensDet->GetTotalVo    
105     if (fVerboseLevel > 1) G4cout << "Calculat    
106                                                   
107     // compute total Dose                         
108     fDose[v] = fEnDep[v] / voxelMass;             
109   }                                               
110                                                   
111   fCalculated = true;                             
112 }                                                 
113                                                   
114 //....oooOO0OOooo........oooOO0OOooo........oo    
115                                                   
116 void Dose::Store()                                
117 {                                                 
118   // Skip Dose store if calculation not enable    
119   if (!fCalculationEnabled) {                     
120     if (fVerboseLevel > 0) {                      
121       G4cout << "Dose::Store() called but skip    
122     }                                             
123     return;                                       
124   }                                               
125                                                   
126   if (fSaved == true)                             
127     G4Exception("Dose::Store", "DoseOverwrite"    
128                 "Overwriting Dose file. For mu    
129                                                   
130   Compute();                                      
131                                                   
132   std::ofstream ofs(fPath);                       
133                                                   
134   if (ofs.is_open()) {                            
135     ofs << "x_index" << std::setw(width) << "y    
136         << std::setw(width) << "Dose (Gy)" <<     
137                                                   
138     auto voxSensDet = VoxelizedSensitiveDetect    
139                                                   
140     for (G4int i = 0; i < voxSensDet->GetVoxel    
141       for (G4int j = 0; j < voxSensDet->GetVox    
142         for (G4int k = 0; k < voxSensDet->GetV    
143           G4int v = voxSensDet->GetThisVoxelNu    
144           ofs << i << std::setw(width) << j <<    
145               << fDose[v] / gray << G4endl;       
146         }                                         
147   }                                               
148   if (fVerboseLevel > 0) {                        
149     G4cout << "Dose: Dose written to " << fPat    
150   }                                               
151   fSaved = true;                                  
152 }                                                 
153                                                   
154 //....oooOO0OOooo........oooOO0OOooo........oo    
155                                                   
156 void Dose::AddFromAccumulable(G4VAccumulable*     
157 {                                                 
158   DoseAccumulable* acc = (DoseAccumulable*)Gen    
159   AddEnergyDeposit(acc->GetEnDeposit());          
160   fCalculated = false;                            
161 }                                                 
162                                                   
163 //....oooOO0OOooo........oooOO0OOooo........oo    
164                                                   
165 void Dose::Reset()                                
166 {                                                 
167   if (fVerboseLevel > 1) {                        
168     G4cout << "Dose::Reset(): ";                  
169   }                                               
170   fEnDep = 0.0;                                   
171   fDose = 0.0;                                    
172   fCalculated = false;                            
173 }                                                 
174                                                   
175 //....oooOO0OOooo........oooOO0OOooo........oo    
176                                                   
177 void Dose::PrintParameters()                      
178 {                                                 
179   G4cout << "*********************************    
180          << "****** Parameters of the class Do    
181          << "*********************************    
182   PrintVirtualParameters();                       
183 }                                                 
184                                                   
185 //....oooOO0OOooo........oooOO0OOooo........oo    
186                                                   
187 }  // namespace RadioBio