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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/dna/svalue/src/Run.cc (Version 11.3.0) and /examples/extended/medical/dna/svalue/src/Run.cc (Version 8.0.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 // This example is provided by the Geant4-DNA     
 27 // Any report or published results obtained us    
 28 // shall cite the following Geant4-DNA collabo    
 29 // Med. Phys. 45 (2018) e722-e739                 
 30 // Phys. Med. 31 (2015) 861-874                   
 31 // Med. Phys. 37 (2010) 4692-4708                 
 32 // Int. J. Model. Simul. Sci. Comput. 1 (2010)    
 33 //                                                
 34 // The Geant4-DNA web site is available at htt    
 35 //                                                
 36 /// \file medical/dna/svalue/src/Run.cc           
 37 /// \brief Implementation of the Run class        
 38                                                   
 39 #include "Run.hh"                                 
 40                                                   
 41 #include "HistoManager.hh"                        
 42 #include "MyFile.hh"                              
 43                                                   
 44 #ifdef MYFILE                                     
 45 #  include "MyPrimaryGeneratorActionFromFile.h    
 46 #else                                             
 47 #  include "PrimaryGeneratorAction.hh"            
 48 #endif                                            
 49                                                   
 50 #include "G4SystemOfUnits.hh"                     
 51 #include "G4UnitsTable.hh"                        
 52                                                   
 53 //....oooOO0OOooo........oooOO0OOooo........oo    
 54                                                   
 55 Run::Run(const DetectorConstruction* detector)    
 56   : G4Run(),                                      
 57     fDetector(detector),                          
 58     fParticle(0),                                 
 59     fEkin(0.),                                    
 60     fCytoEdeposit(0.),                            
 61     fCytoEdeposit2(0.),                           
 62     fNuclEdeposit(0.),                            
 63     fNuclEdeposit2(0.),                           
 64     fTrackLen(0.),                                
 65     fTrackLen2(0.),                               
 66     fProjRange(0.),                               
 67     fProjRange2(0.),                              
 68     fNbOfSteps(0),                                
 69     fNbOfSteps2(0),                               
 70     fStepSize(0.),                                
 71     fStepSize2(0.)                                
 72 {}                                                
 73                                                   
 74 //....oooOO0OOooo........oooOO0OOooo........oo    
 75                                                   
 76 Run::~Run() {}                                    
 77                                                   
 78 //....oooOO0OOooo........oooOO0OOooo........oo    
 79                                                   
 80 void Run::SetPrimary(G4ParticleDefinition* par    
 81 {                                                 
 82   fParticle = particle;                           
 83   fEkin = energy;                                 
 84 }                                                 
 85                                                   
 86 //....oooOO0OOooo........oooOO0OOooo........oo    
 87                                                   
 88 void Run::AddCytoEdep(G4double e)                 
 89 {                                                 
 90   fCytoEdeposit += e;                             
 91   fCytoEdeposit2 += e * e;                        
 92 }                                                 
 93                                                   
 94 //....oooOO0OOooo........oooOO0OOooo........oo    
 95                                                   
 96 void Run::AddNuclEdep(G4double e)                 
 97 {                                                 
 98   fNuclEdeposit += e;                             
 99   fNuclEdeposit2 += e * e;                        
100 }                                                 
101                                                   
102 //....oooOO0OOooo........oooOO0OOooo........oo    
103                                                   
104 void Run::AddTrackLength(G4double t)              
105 {                                                 
106   fTrackLen += t;                                 
107   fTrackLen2 += t * t;                            
108 }                                                 
109                                                   
110 //....oooOO0OOooo........oooOO0OOooo........oo    
111                                                   
112 void Run::AddProjRange(G4double x)                
113 {                                                 
114   fProjRange += x;                                
115   fProjRange2 += x * x;                           
116 }                                                 
117                                                   
118 //....oooOO0OOooo........oooOO0OOooo........oo    
119                                                   
120 void Run::AddStepSize(G4int nb, G4double st)      
121 {                                                 
122   fNbOfSteps += nb;                               
123   fNbOfSteps2 += nb * nb;                         
124   fStepSize += st;                                
125   fStepSize2 += st * st;                          
126 }                                                 
127                                                   
128 //....oooOO0OOooo........oooOO0OOooo........oo    
129                                                   
130 void Run::Merge(const G4Run* run)                 
131 {                                                 
132   const Run* localRun = static_cast<const Run*    
133                                                   
134   // Pass information about primary particle      
135                                                   
136   fParticle = localRun->fParticle;                
137   fEkin = localRun->fEkin;                        
138                                                   
139   // Accumulate sums                              
140                                                   
141   fCytoEdeposit += localRun->fCytoEdeposit;       
142   fCytoEdeposit2 += localRun->fCytoEdeposit2;     
143   fNuclEdeposit += localRun->fNuclEdeposit;       
144   fNuclEdeposit2 += localRun->fNuclEdeposit2;     
145                                                   
146   fTrackLen += localRun->fTrackLen;               
147   fTrackLen2 += localRun->fTrackLen2;             
148   fProjRange += localRun->fProjRange;             
149   fProjRange2 += localRun->fProjRange2;           
150   fNbOfSteps += localRun->fNbOfSteps;             
151   fNbOfSteps2 += localRun->fNbOfSteps2;           
152   fStepSize += localRun->fStepSize;               
153   fStepSize2 += localRun->fStepSize2;             
154                                                   
155   G4Run::Merge(run);                              
156 }                                                 
157                                                   
158 //....oooOO0OOooo........oooOO0OOooo........oo    
159                                                   
160 void Run::EndOfRun()                              
161 {                                                 
162   std::ios::fmtflags mode = G4cout.flags();       
163   G4cout.setf(std::ios::fixed, std::ios::float    
164   G4int prec = G4cout.precision(2);               
165                                                   
166   // Run conditions                               
167                                                   
168   G4String partName = fParticle->GetParticleNa    
169                                                   
170   G4cout << "\n ======================== run s    
171   G4cout << "\n The run is " << numberOfEvent     
172          << G4BestUnit(fEkin, "Energy") << G4e    
173                                                   
174   if (numberOfEvent == 0) {                       
175     G4cout.setf(mode, std::ios::floatfield);      
176     G4cout.precision(prec);                       
177     return;                                       
178   }                                               
179                                                   
180   // Compute S-value for cytoplasm (C<-C)         
181                                                   
182   fCytoEdeposit /= numberOfEvent;                 
183   fCytoEdeposit2 /= numberOfEvent;                
184   G4double rmsCyto = fCytoEdeposit2 - fCytoEde    
185   if (rmsCyto > 0.)                               
186     rmsCyto = std::sqrt(rmsCyto);                 
187   else                                            
188     rmsCyto = 0.;                                 
189                                                   
190   G4cout.precision(3);                            
191   G4cout << "\n Total Energy deposited in cyto    
192          << " +- " << G4BestUnit(rmsCyto, "Ene    
193                                                   
194   G4double sValueCyto = fCytoEdeposit / fDetec    
195   G4double rmsSValueCyto = rmsCyto / fDetector    
196                                                   
197   G4cout.precision(3);                            
198   G4cout << "\n S value for cytoplasm (C<-C) =    
199          << " +- " << rmsSValueCyto / gray <<     
200                                                   
201   // Compute S-value for nucleus (N<-C)           
202                                                   
203   fNuclEdeposit /= numberOfEvent;                 
204   fNuclEdeposit2 /= numberOfEvent;                
205   G4double rmsNucl = fNuclEdeposit2 - fNuclEde    
206   if (rmsNucl > 0.)                               
207     rmsNucl = std::sqrt(rmsNucl);                 
208   else                                            
209     rmsNucl = 0.;                                 
210                                                   
211   G4cout.precision(3);                            
212   G4cout << "\n Total Energy deposited in nucl    
213          << " +- " << G4BestUnit(rmsNucl, "Ene    
214                                                   
215   G4double sValueNucl = fNuclEdeposit / fDetec    
216   G4double rmsSValueNucl = rmsNucl / fDetector    
217                                                   
218   G4cout.precision(3);                            
219   G4cout << "\n S value for nucleus (N<-C) = "    
220          << " +- " << rmsSValueNucl / gray <<     
221                                                   
222   // Compute track length of primary track        
223                                                   
224   fTrackLen /= numberOfEvent;                     
225   fTrackLen2 /= numberOfEvent;                    
226   G4double rms = fTrackLen2 - fTrackLen * fTra    
227   if (rms > 0.)                                   
228     rms = std::sqrt(rms);                         
229   else                                            
230     rms = 0.;                                     
231                                                   
232   G4cout.precision(3);                            
233   G4cout << "\n Track length of primary track     
234          << G4BestUnit(rms, "Length");            
235                                                   
236   // Compute projected range of primary track     
237                                                   
238   fProjRange /= numberOfEvent;                    
239   fProjRange2 /= numberOfEvent;                   
240   rms = fProjRange2 - fProjRange * fProjRange;    
241   if (rms > 0.)                                   
242     rms = std::sqrt(rms);                         
243   else                                            
244     rms = 0.;                                     
245                                                   
246   G4cout << "\n Projected range                   
247          << G4BestUnit(rms, "Length") << G4end    
248                                                   
249   // Nb of steps and step size of primary trac    
250                                                   
251   G4double dNofEvents = double(numberOfEvent);    
252   G4double fNbSteps = fNbOfSteps / dNofEvents,    
253   rms = fNbSteps2 - fNbSteps * fNbSteps;          
254   if (rms > 0.)                                   
255     rms = std::sqrt(rms);                         
256   else                                            
257     rms = 0.;                                     
258                                                   
259   G4cout.precision(2);                            
260   G4cout << "\n Nb of steps of primary track      
261                                                   
262   fStepSize /= numberOfEvent;                     
263   fStepSize2 /= numberOfEvent;                    
264   rms = fStepSize2 - fStepSize * fStepSize;       
265   if (rms > 0.)                                   
266     rms = std::sqrt(rms);                         
267   else                                            
268     rms = 0.;                                     
269                                                   
270   G4cout.precision(3);                            
271   G4cout << "\n Step size                         
272          << G4BestUnit(rms, "Length") << G4end    
273                                                   
274   // Normalize histograms of longitudinal ener    
275                                                   
276   G4AnalysisManager* analysisManager = G4Analy    
277   G4int ih = 1;                                   
278   G4double binWidth = analysisManager->GetH1Wi    
279   G4double fac = (1. / (numberOfEvent * binWid    
280   analysisManager->ScaleH1(ih, fac);              
281                                                   
282   // Reset default formats                        
283                                                   
284   G4cout.setf(mode, std::ios::floatfield);        
285   G4cout.precision(prec);                         
286                                                   
287   // Output file                                  
288                                                   
289   FILE* myFile;                                   
290   myFile = fopen("s.txt", "a");                   
291   fprintf(myFile, "%e %e %e %e %e %e %e \n", f    
292           fDetector->GetCytoThickness() / nm,     
293           sValueNucl / gray, rmsSValueNucl / g    
294   fclose(myFile);                                 
295 }                                                 
296