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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/extended/runAndEvent/RE07/src/Run.cc (Version 11.3.0) and /examples/extended/runAndEvent/RE07/src/Run.cc (Version 10.1.p2)


  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 /// \file src/Run.cc                              
 27 /// \brief Implementation of the Run class        
 28 //                                                
 29 //                                                
 30 //....oooOO0OOooo........oooOO0OOooo........oo    
 31 //....oooOO0OOooo........oooOO0OOooo........oo    
 32                                                   
 33 #include "Run.hh"                                 
 34                                                   
 35 #include "DetectorConstruction.hh"                
 36 #include "PrimaryGeneratorAction.hh"              
 37                                                   
 38 #include "G4Electron.hh"                          
 39 #include "G4Gamma.hh"                             
 40 #include "G4ParticleDefinition.hh"                
 41 #include "G4ParticleTable.hh"                     
 42 #include "G4Positron.hh"                          
 43 #include "G4SystemOfUnits.hh"                     
 44 #include "G4Track.hh"                             
 45 #include "G4UnitsTable.hh"                        
 46                                                   
 47 #include <iomanip>                                
 48                                                   
 49 //....oooOO0OOooo........oooOO0OOooo........oo    
 50                                                   
 51 Run::Run(DetectorConstruction* det)               
 52   : G4Run(),                                      
 53     fDetector(det),                               
 54     fParticle(nullptr),                           
 55     fEkin(0.),                                    
 56     fChargedStep(0),                              
 57     fNeutralStep(0),                              
 58     fN_gamma(0),                                  
 59     fN_elec(0),                                   
 60     fN_pos(0)                                     
 61 {                                                 
 62   // initialize cumulative quantities             
 63   //                                              
 64   for (G4int k = 0; k < kMaxAbsor; k++) {         
 65     fSumEAbs[k] = fSum2EAbs[k] = fSumLAbs[k] =    
 66     fEnergyDeposit[k].clear();                    
 67   }                                               
 68 }                                                 
 69                                                   
 70 //....oooOO0OOooo........oooOO0OOooo........oo    
 71                                                   
 72 Run::~Run() {}                                    
 73                                                   
 74 //....oooOO0OOooo........oooOO0OOooo........oo    
 75                                                   
 76 void Run::SetPrimary(G4ParticleDefinition* par    
 77 {                                                 
 78   fParticle = particle;                           
 79   fEkin = energy;                                 
 80 }                                                 
 81                                                   
 82 //....oooOO0OOooo........oooOO0OOooo........oo    
 83                                                   
 84 void Run::FillPerEvent(G4int kAbs, G4double EA    
 85 {                                                 
 86   // accumulate statistic with restriction        
 87   //                                              
 88   fEnergyDeposit[kAbs].push_back(EAbs);           
 89   fSumEAbs[kAbs] += EAbs;                         
 90   fSum2EAbs[kAbs] += EAbs * EAbs;                 
 91   fSumLAbs[kAbs] += LAbs;                         
 92   fSum2LAbs[kAbs] += LAbs * LAbs;                 
 93 }                                                 
 94                                                   
 95 //....oooOO0OOooo........oooOO0OOooo........oo    
 96                                                   
 97 void Run::AddChargedStep()                        
 98 {                                                 
 99   fChargedStep += 1.0;                            
100 }                                                 
101                                                   
102 //....oooOO0OOooo........oooOO0OOooo........oo    
103                                                   
104 void Run::AddNeutralStep()                        
105 {                                                 
106   fNeutralStep += 1.0;                            
107 }                                                 
108                                                   
109 //....oooOO0OOooo........oooOO0OOooo........oo    
110                                                   
111 void Run::AddSecondaryTrack(const G4Track* tra    
112 {                                                 
113   const G4ParticleDefinition* d = track->GetDe    
114   if (d == G4Gamma::Gamma()) {                    
115     ++fN_gamma;                                   
116   }                                               
117   else if (d == G4Electron::Electron()) {         
118     ++fN_elec;                                    
119   }                                               
120   else if (d == G4Positron::Positron()) {         
121     ++fN_pos;                                     
122   }                                               
123 }                                                 
124                                                   
125 //....oooOO0OOooo........oooOO0OOooo........oo    
126                                                   
127 void Run::Merge(const G4Run* run)                 
128 {                                                 
129   const Run* localRun = static_cast<const Run*    
130                                                   
131   // pass information about primary particle      
132   fParticle = localRun->fParticle;                
133   fEkin = localRun->fEkin;                        
134                                                   
135   // accumulate sums                              
136   //                                              
137   for (G4int k = 0; k < kMaxAbsor; k++) {         
138     fSumEAbs[k] += localRun->fSumEAbs[k];         
139     fSum2EAbs[k] += localRun->fSum2EAbs[k];       
140     fSumLAbs[k] += localRun->fSumLAbs[k];         
141     fSum2LAbs[k] += localRun->fSum2LAbs[k];       
142   }                                               
143                                                   
144   fChargedStep += localRun->fChargedStep;         
145   fNeutralStep += localRun->fNeutralStep;         
146                                                   
147   fN_gamma += localRun->fN_gamma;                 
148   fN_elec += localRun->fN_elec;                   
149   fN_pos += localRun->fN_pos;                     
150                                                   
151   G4Run::Merge(run);                              
152 }                                                 
153                                                   
154 //....oooOO0OOooo........oooOO0OOooo........oo    
155                                                   
156 void Run::EndOfRun()                              
157 {                                                 
158   G4int nEvt = numberOfEvent;                     
159   G4double norm = G4double(nEvt);                 
160   if (norm > 0) norm = 1. / norm;                 
161   G4double qnorm = std::sqrt(norm);               
162                                                   
163   fChargedStep *= norm;                           
164   fNeutralStep *= norm;                           
165                                                   
166   // compute and print statistic                  
167   //                                              
168   G4double beamEnergy = fEkin;                    
169   G4double sqbeam = std::sqrt(beamEnergy / GeV    
170                                                   
171   G4double MeanEAbs, MeanEAbs2, rmsEAbs, resol    
172   G4double MeanLAbs, MeanLAbs2, rmsLAbs;          
173                                                   
174   std::ios::fmtflags mode = G4cout.flags();       
175   G4int prec = G4cout.precision(2);               
176   G4cout << "\n-------------------------------    
177   G4cout << std::setw(14) << "material" << std    
178          << "sqrt(E0(GeV))*rmsE/Emean" << std:    
179                                                   
180   for (G4int k = 1; k <= fDetector->GetNbOfAbs    
181     MeanEAbs = fSumEAbs[k] * norm;                
182     MeanEAbs2 = fSum2EAbs[k] * norm;              
183     rmsEAbs = std::sqrt(std::abs(MeanEAbs2 - M    
184                                                   
185     resolution = 100. * sqbeam * rmsEAbs / Mea    
186     rmsres = resolution * qnorm;                  
187                                                   
188     // Save mean and RMS                          
189     fSumEAbs[k] = MeanEAbs;                       
190     fSum2EAbs[k] = rmsEAbs;                       
191                                                   
192     MeanLAbs = fSumLAbs[k] * norm;                
193     MeanLAbs2 = fSum2LAbs[k] * norm;              
194     rmsLAbs = std::sqrt(std::abs(MeanLAbs2 - M    
195                                                   
196     // print                                      
197     //                                            
198     G4cout << std::setw(14) << fDetector->GetA    
199            << std::setprecision(5) << std::set    
200            << std::setprecision(4) << std::set    
201            << resolution << " +- " << std::set    
202            << std::setw(10) << G4BestUnit(Mean    
203            << G4BestUnit(rmsLAbs, "Length") <<    
204   }                                               
205   G4cout << "\n-------------------------------    
206                                                   
207   G4cout << " Beam particle " << fParticle->Ge    
208          << "  E = " << G4BestUnit(beamEnergy,    
209   G4cout << " Mean number of gamma       " <<     
210   G4cout << " Mean number of e-          " <<     
211   G4cout << " Mean number of e+          " <<     
212   G4cout << std::setprecision(6) << " Mean num    
213   G4cout << " Mean number of neutral steps  "     
214   G4cout << "---------------------------------    
215                                                   
216   G4cout.setf(mode, std::ios::floatfield);        
217   G4cout.precision(prec);                         
218 }                                                 
219                                                   
220 //....oooOO0OOooo........oooOO0OOooo........oo    
221