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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/extended/electromagnetic/TestEm1/src/Run.cc (Version 11.3.0) and /examples/extended/electromagnetic/TestEm1/src/Run.cc (Version 9.6)


  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 electromagnetic/TestEm1/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 "G4EmCalculator.hh"                      
 39 #include "G4SystemOfUnits.hh"                     
 40 #include "G4UnitsTable.hh"                        
 41                                                   
 42 #include <iomanip>                                
 43                                                   
 44 //....oooOO0OOooo........oooOO0OOooo........oo    
 45                                                   
 46 Run::Run(const DetectorConstruction* det) : fD    
 47                                                   
 48 //....oooOO0OOooo........oooOO0OOooo........oo    
 49                                                   
 50 void Run::SetPrimary(const G4ParticleDefinitio    
 51 {                                                 
 52   fParticle = particle;                           
 53   fEkin = energy;                                 
 54 }                                                 
 55 //....oooOO0OOooo........oooOO0OOooo........oo    
 56                                                   
 57 void Run::CountProcesses(const G4String& procN    
 58 {                                                 
 59   std::map<G4String, G4int>::iterator it = fPr    
 60   if (it == fProcCounter.end()) {                 
 61     fProcCounter[procName] = 1;                   
 62   }                                               
 63   else {                                          
 64     fProcCounter[procName]++;                     
 65   }                                               
 66 }                                                 
 67                                                   
 68 //....oooOO0OOooo........oooOO0OOooo........oo    
 69                                                   
 70 void Run::Merge(const G4Run* run)                 
 71 {                                                 
 72   const Run* localRun = static_cast<const Run*    
 73                                                   
 74   // pass information about primary particle      
 75   fParticle = localRun->fParticle;                
 76   fEkin = localRun->fEkin;                        
 77                                                   
 78   // accumulate sums                              
 79   //                                              
 80   fNbOfTraks0 += localRun->fNbOfTraks0;           
 81   fNbOfTraks1 += localRun->fNbOfTraks1;           
 82   fNbOfSteps0 += localRun->fNbOfSteps0;           
 83   fNbOfSteps1 += localRun->fNbOfSteps1;           
 84   fEdep += localRun->fEdep;                       
 85   fEleak += localRun->fEleak;                     
 86   fNIEL += localRun->fNIEL;                       
 87   fTrueRange += localRun->fTrueRange;             
 88   fTrueRange2 += localRun->fTrueRange2;           
 89   fProjRange += localRun->fProjRange;             
 90   fProjRange2 += localRun->fProjRange2;           
 91   fTransvDev += localRun->fTransvDev;             
 92   fTransvDev2 += localRun->fTransvDev2;           
 93                                                   
 94   // map: processes count                         
 95   std::map<G4String, G4int>::const_iterator it    
 96   for (it = localRun->fProcCounter.begin(); it    
 97     G4String procName = it->first;                
 98     G4int localCount = it->second;                
 99     if (fProcCounter.find(procName) == fProcCo    
100       fProcCounter[procName] = localCount;        
101     }                                             
102     else {                                        
103       fProcCounter[procName] += localCount;       
104     }                                             
105   }                                               
106                                                   
107   G4Run::Merge(run);                              
108 }                                                 
109                                                   
110 //....oooOO0OOooo........oooOO0OOooo........oo    
111                                                   
112 void Run::EndOfRun()                              
113 {                                                 
114   G4int prec = 5, wid = prec + 2;                 
115   G4int dfprec = G4cout.precision(prec);          
116                                                   
117   // run condition                                
118   //                                              
119   G4String partName = fParticle->GetParticleNa    
120   const G4Material* material = fDetector->GetM    
121   G4double density = material->GetDensity();      
122                                                   
123   G4cout << "\n ======================== run s    
124   G4cout << "\n The run is: " << numberOfEvent    
125          << G4BestUnit(fEkin, "Energy") << " t    
126          << " of " << material->GetName() << "    
127          << ")" << G4endl;                        
128                                                   
129   if (numberOfEvent == 0) {                       
130     G4cout.precision(dfprec);                     
131     return;                                       
132   }                                               
133                                                   
134   G4double dNbOfEvents = (G4double)numberOfEve    
135   G4cout << "\n Energy deposit:   "               
136          << G4BestUnit(fEdep/dNbOfEvents,  "En    
137   G4cout << " Energy leakage:   "                 
138          << G4BestUnit(fEleak/dNbOfEvents, "En    
139   G4cout << " Edep + Eleak:     "                 
140          << G4BestUnit((fEdep+fEleak)/dNbOfEve    
141   G4cout << " \n NIEL energy calculated: "        
142          << G4BestUnit(fNIEL/dNbOfEvents,  "En    
143                                                   
144   // nb of tracks and steps per event             
145   //                                              
146   G4cout << "\n Nb tracks/event"                  
147          << "   neutral: " << std::setw(wid) <    
148          << "   charged: " << std::setw(wid) <    
149          << "   neutral: " << std::setw(wid) <    
150          << "   charged: " << std::setw(wid) <    
151                                                   
152   // frequency of processes                       
153   //                                              
154   G4cout << "\n Process calls frequency :" <<     
155   G4int index = 0;                                
156   std::map<G4String, G4int>::iterator it;         
157   for (it = fProcCounter.begin(); it != fProcC    
158     G4String procName = it->first;                
159     G4int count = it->second;                     
160     G4String space = " ";                         
161     if (++index % 3 == 0) space = "\n";           
162     G4cout << " " << std::setw(20) << procName    
163   }                                               
164   G4cout << G4endl;                               
165                                                   
166   // compute true and projected ranges, and tr    
167   //                                              
168   fTrueRange /= numberOfEvent;                    
169   fTrueRange2 /= numberOfEvent;                   
170   G4double trueRms = fTrueRange2 - fTrueRange     
171   if (trueRms > 0.)                               
172     trueRms = std::sqrt(trueRms);                 
173   else                                            
174     trueRms = 0.;                                 
175                                                   
176   fProjRange /= numberOfEvent;                    
177   fProjRange2 /= numberOfEvent;                   
178   G4double projRms = fProjRange2 - fProjRange     
179   if (projRms > 0.)                               
180     projRms = std::sqrt(projRms);                 
181   else                                            
182     projRms = 0.;                                 
183                                                   
184   fTransvDev /= 2 * numberOfEvent;                
185   fTransvDev2 /= 2 * numberOfEvent;               
186   G4double trvsRms = fTransvDev2 - fTransvDev     
187   if (trvsRms > 0.)                               
188     trvsRms = std::sqrt(trvsRms);                 
189   else                                            
190     trvsRms = 0.;                                 
191                                                   
192   // compare true range with csda range from P    
193   //                                              
194   G4EmCalculator emCalculator;                    
195   G4double rangeTable = 0.;                       
196   if (fParticle->GetPDGCharge() != 0.)            
197     rangeTable = emCalculator.GetCSDARange(fEk    
198                                                   
199   G4cout << "\n-------------------------------    
200   G4cout << " Primary particle : ";               
201   G4cout << "\n true Range = " << G4BestUnit(f    
202          << "   rms = " << G4BestUnit(trueRms,    
203                                                   
204   G4cout << "\n proj Range = " << G4BestUnit(f    
205          << "   rms = " << G4BestUnit(projRms,    
206                                                   
207   G4cout << "\n proj/true  = " << fProjRange /    
208                                                   
209   G4cout << "\n transverse dispersion at end =    
210                                                   
211   G4cout << "\n      mass true Range from simu    
212          << G4BestUnit(fTrueRange * density, "    
213          << "\n       from PhysicsTable (csda     
214          << G4BestUnit(rangeTable * density, "    
215   G4cout << "\n-------------------------------    
216   G4cout << G4endl;                               
217                                                   
218   // remove all contents in fProcCounter          
219   fProcCounter.clear();                           
220                                                   
221   // restore default format                       
222   G4cout.precision(dfprec);                       
223 }                                                 
224                                                   
225 //....oooOO0OOooo........oooOO0OOooo........oo    
226