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


  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 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 "G4Gamma.hh"                             
 40 #include "G4SystemOfUnits.hh"                     
 41 #include "G4UnitsTable.hh"                        
 42                                                   
 43 #include <iomanip>                                
 44                                                   
 45 //....oooOO0OOooo........oooOO0OOooo........oo    
 46                                                   
 47 Run::Run(DetectorConstruction* det) : fDetecto    
 48                                                   
 49 //....oooOO0OOooo........oooOO0OOooo........oo    
 50                                                   
 51 void Run::SetPrimary(G4ParticleDefinition* par    
 52 {                                                 
 53   fParticle = particle;                           
 54   fEkin = energy;                                 
 55 }                                                 
 56 //....oooOO0OOooo........oooOO0OOooo........oo    
 57                                                   
 58 void Run::CountProcesses(G4String procName)       
 59 {                                                 
 60   std::map<G4String, G4int>::iterator it = fPr    
 61   if (it == fProcCounter.end()) {                 
 62     fProcCounter[procName] = 1;                   
 63   }                                               
 64   else {                                          
 65     fProcCounter[procName]++;                     
 66   }                                               
 67 }                                                 
 68                                                   
 69 //....oooOO0OOooo........oooOO0OOooo........oo    
 70                                                   
 71 void Run::SumTrack(G4double track)                
 72 {                                                 
 73   fTotalCount++;                                  
 74   fSumTrack += track;                             
 75   fSumTrack2 += track * track;                    
 76 }                                                 
 77                                                   
 78 //....oooOO0OOooo........oooOO0OOooo........oo    
 79                                                   
 80 void Run::SumeTransf(G4double energy)             
 81 {                                                 
 82   fEnTransfer += energy;                          
 83 }                                                 
 84                                                   
 85 //....oooOO0OOooo........oooOO0OOooo........oo    
 86                                                   
 87 void Run::Merge(const G4Run* run)                 
 88 {                                                 
 89   const Run* localRun = static_cast<const Run*    
 90                                                   
 91   // pass information about primary particle      
 92   fParticle = localRun->fParticle;                
 93   fEkin = localRun->fEkin;                        
 94                                                   
 95   // map: processes count                         
 96   std::map<G4String, G4int>::const_iterator it    
 97   for (it = localRun->fProcCounter.begin(); it    
 98     G4String procName = it->first;                
 99     G4int localCount = it->second;                
100     if (fProcCounter.find(procName) == fProcCo    
101       fProcCounter[procName] = localCount;        
102     }                                             
103     else {                                        
104       fProcCounter[procName] += localCount;       
105     }                                             
106   }                                               
107                                                   
108   fTotalCount += localRun->fTotalCount;           
109   fSumTrack += localRun->fSumTrack;               
110   fSumTrack2 += localRun->fSumTrack2;             
111   fEnTransfer += localRun->fEnTransfer;           
112                                                   
113   G4Run::Merge(run);                              
114 }                                                 
115                                                   
116 //....oooOO0OOooo........oooOO0OOooo........oo    
117                                                   
118 void Run::EndOfRun()                              
119 {                                                 
120   G4int prec = 5;                                 
121   G4int dfprec = G4cout.precision(prec);          
122                                                   
123   // run condition                                
124   //                                              
125   G4String partName = fParticle->GetParticleNa    
126   G4Material* material = fDetector->GetMateria    
127   G4double density = material->GetDensity();      
128   G4double tickness = fDetector->GetSize();       
129                                                   
130   G4cout << "\n ======================== run s    
131   G4cout << "\n The run is: " << numberOfEvent    
132          << G4BestUnit(fEkin, "Energy") << " t    
133          << material->GetName() << " (density:    
134          << G4endl;                               
135                                                   
136   // frequency of processes                       
137   G4int survive = 0;                              
138   G4cout << "\n Process calls frequency --->";    
139   std::map<G4String, G4int>::iterator it;         
140   for (it = fProcCounter.begin(); it != fProcC    
141     G4String procName = it->first;                
142     G4int count = it->second;                     
143     G4cout << "\t" << procName << " = " << cou    
144     if (procName == "Transportation") survive     
145   }                                               
146                                                   
147   if (survive > 0) {                              
148     G4cout << "\n\n Nb of incident particles s    
149            << G4BestUnit(fDetector->GetSize(),    
150            << survive << G4endl;                  
151   }                                               
152                                                   
153   if (fTotalCount == 0) fTotalCount = 1;  // f    
154                                                   
155   // compute mean free path and related quanti    
156   //                                              
157   G4double MeanFreePath = fSumTrack / fTotalCo    
158   G4double MeanTrack2 = fSumTrack2 / fTotalCou    
159   G4double rms = std::sqrt(std::fabs(MeanTrack    
160   G4double CrossSection = 1. / MeanFreePath;      
161   G4double massicMFP = MeanFreePath * density;    
162   G4double massicCS = 1. / massicMFP;             
163                                                   
164   G4cout << "\n\n MeanFreePath:\t" << G4BestUn    
165          << G4BestUnit(rms, "Length") << "\tma    
166          << "\n CrossSection:\t" << CrossSecti    
167          << "\t\t\tmassic: " << G4BestUnit(mas    
168                                                   
169   // compute energy transfer coefficient          
170   //                                              
171   G4double MeanTransfer = fEnTransfer / fTotal    
172   G4double massTransfCoef = massicCS * MeanTra    
173                                                   
174   G4cout << "\n mean energy of charged seconda    
175          << "\n     ---> mass_energy_transfer     
176          << G4endl;                               
177                                                   
178   // check cross section from G4EmCalculator      
179   //                                              
180   G4cout << "\n Verification : "                  
181          << "crossSections from G4EmCalculator    
182                                                   
183   G4EmCalculator emCalculator;                    
184   G4double sumc = 0.0;                            
185   for (it = fProcCounter.begin(); it != fProcC    
186     G4String procName = it->first;                
187     G4double massSigma =                          
188       emCalculator.GetCrossSectionPerVolume(fE    
189     if (fParticle == G4Gamma::Gamma())            
190       massSigma =                                 
191         emCalculator.ComputeCrossSectionPerVol    
192     sumc += massSigma;                            
193     G4cout << "   " << procName << "= " << G4B    
194   }                                               
195   G4cout << "   total= " << G4BestUnit(sumc, "    
196                                                   
197   // remove all contents in fProcCounter          
198   fProcCounter.clear();                           
199                                                   
200   // restore default format                       
201   G4cout.precision(dfprec);                       
202 }                                                 
203                                                   
204 //....oooOO0OOooo........oooOO0OOooo........oo    
205