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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 10.4.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /// \file Run.cc                               <<  26 /// \file electromagnetic/TestEm14/src/Run.cc
 27 /// \brief Implementation of the Run class         27 /// \brief Implementation of the Run class
 28 //                                                 28 //
 29 //                                             <<  29 // $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $
                                                   >>  30 // 
 30 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 31 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32                                                    33 
 33 #include "Run.hh"                                  34 #include "Run.hh"
 34                                                << 
 35 #include "DetectorConstruction.hh"                 35 #include "DetectorConstruction.hh"
 36 #include "PrimaryGeneratorAction.hh"               36 #include "PrimaryGeneratorAction.hh"
 37                                                    37 
                                                   >>  38 #include "G4UnitsTable.hh"
                                                   >>  39 #include "G4SystemOfUnits.hh"
 38 #include "G4EmCalculator.hh"                       40 #include "G4EmCalculator.hh"
 39 #include "G4Gamma.hh"                              41 #include "G4Gamma.hh"
 40 #include "G4SystemOfUnits.hh"                  << 
 41 #include "G4UnitsTable.hh"                     << 
 42                                                    42 
 43 #include <iomanip>                                 43 #include <iomanip>
 44                                                    44 
 45 //....oooOO0OOooo........oooOO0OOooo........oo     45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 46                                                    46 
 47 Run::Run(DetectorConstruction* det) : fDetecto <<  47 Run::Run(DetectorConstruction* det)
                                                   >>  48 : G4Run(),
                                                   >>  49   fDetector(det), 
                                                   >>  50   fParticle(0), fEkin(0.),
                                                   >>  51   fTotalCount(0), fSumTrack(0.), fSumTrack2(0.), fEnTransfer(0.)
                                                   >>  52 { }
                                                   >>  53 
                                                   >>  54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >>  55 
                                                   >>  56 Run::~Run()
                                                   >>  57 { }
 48                                                    58 
 49 //....oooOO0OOooo........oooOO0OOooo........oo     59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 50                                                    60 
 51 void Run::SetPrimary(G4ParticleDefinition* par     61 void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy)
 52 {                                              <<  62 { 
 53   fParticle = particle;                            63   fParticle = particle;
 54   fEkin = energy;                                  64   fEkin = energy;
 55 }                                                  65 }
 56 //....oooOO0OOooo........oooOO0OOooo........oo     66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 57                                                    67 
 58 void Run::CountProcesses(G4String procName)    <<  68 void Run::CountProcesses(G4String procName) 
 59 {                                                  69 {
 60   std::map<G4String, G4int>::iterator it = fPr <<  70   std::map<G4String,G4int>::iterator it = fProcCounter.find(procName);
 61   if (it == fProcCounter.end()) {              <<  71   if ( it == fProcCounter.end()) {
 62     fProcCounter[procName] = 1;                    72     fProcCounter[procName] = 1;
 63   }                                                73   }
 64   else {                                           74   else {
 65     fProcCounter[procName]++;                  <<  75     fProcCounter[procName]++; 
 66   }                                                76   }
 67 }                                                  77 }
 68                                                    78 
 69 //....oooOO0OOooo........oooOO0OOooo........oo     79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70                                                    80 
 71 void Run::SumTrack(G4double track)             <<  81 void Run::SumTrack (G4double track)
 72 {                                                  82 {
 73   fTotalCount++;                                   83   fTotalCount++;
 74   fSumTrack += track;                              84   fSumTrack += track;
 75   fSumTrack2 += track * track;                 <<  85   fSumTrack2 += track*track;
 76 }                                                  86 }
 77                                                    87 
 78 //....oooOO0OOooo........oooOO0OOooo........oo     88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 79                                                    89 
 80 void Run::SumeTransf(G4double energy)          <<  90 void Run::SumeTransf (G4double energy)
 81 {                                                  91 {
 82   fEnTransfer += energy;                           92   fEnTransfer += energy;
 83 }                                                  93 }
 84                                                    94 
 85 //....oooOO0OOooo........oooOO0OOooo........oo     95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 86                                                    96 
 87 void Run::Merge(const G4Run* run)                  97 void Run::Merge(const G4Run* run)
 88 {                                                  98 {
 89   const Run* localRun = static_cast<const Run*     99   const Run* localRun = static_cast<const Run*>(run);
 90                                                   100 
 91   // pass information about primary particle      101   // pass information about primary particle
 92   fParticle = localRun->fParticle;                102   fParticle = localRun->fParticle;
 93   fEkin = localRun->fEkin;                     << 103   fEkin     = localRun->fEkin;
 94                                                << 104       
 95   // map: processes count                      << 105   //map: processes count
 96   std::map<G4String, G4int>::const_iterator it << 106   std::map<G4String,G4int>::const_iterator it;
 97   for (it = localRun->fProcCounter.begin(); it << 107   for (it = localRun->fProcCounter.begin(); 
                                                   >> 108        it !=localRun->fProcCounter.end(); ++it) {
                                                   >> 109        
 98     G4String procName = it->first;                110     G4String procName = it->first;
 99     G4int localCount = it->second;             << 111     G4int localCount  = it->second;
100     if (fProcCounter.find(procName) == fProcCo << 112     if ( fProcCounter.find(procName) == fProcCounter.end()) {
101       fProcCounter[procName] = localCount;        113       fProcCounter[procName] = localCount;
102     }                                             114     }
103     else {                                        115     else {
104       fProcCounter[procName] += localCount;       116       fProcCounter[procName] += localCount;
105     }                                             117     }
106   }                                               118   }
107                                                << 119   
108   fTotalCount += localRun->fTotalCount;           120   fTotalCount += localRun->fTotalCount;
109   fSumTrack += localRun->fSumTrack;            << 121   fSumTrack   += localRun->fSumTrack;
110   fSumTrack2 += localRun->fSumTrack2;          << 122   fSumTrack2  += localRun->fSumTrack2;
111   fEnTransfer += localRun->fEnTransfer;           123   fEnTransfer += localRun->fEnTransfer;
112                                                << 124   
113   G4Run::Merge(run);                           << 125   G4Run::Merge(run); 
114 }                                              << 126 } 
115                                                   127 
116 //....oooOO0OOooo........oooOO0OOooo........oo    128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117                                                   129 
118 void Run::EndOfRun()                              130 void Run::EndOfRun()
119 {                                                 131 {
120   G4int prec = 5;                              << 132   G4int prec = 5;  
121   G4int dfprec = G4cout.precision(prec);          133   G4int dfprec = G4cout.precision(prec);
122                                                << 134   
123   // run condition                             << 135   //run condition
124   //                                           << 136   //        
125   G4String partName = fParticle->GetParticleNa << 137   G4String partName    = fParticle->GetParticleName();    
126   G4Material* material = fDetector->GetMateria    138   G4Material* material = fDetector->GetMaterial();
127   G4double density = material->GetDensity();   << 139   G4double density     = material->GetDensity();
128   G4double tickness = fDetector->GetSize();    << 140   G4double tickness    = fDetector->GetSize();
129                                                << 141      
130   G4cout << "\n ======================== run s    142   G4cout << "\n ======================== run summary ======================\n";
131   G4cout << "\n The run is: " << numberOfEvent    143   G4cout << "\n The run is: " << numberOfEvent << " " << partName << " of "
132          << G4BestUnit(fEkin, "Energy") << " t << 144          << G4BestUnit(fEkin,"Energy") << " through " 
133          << material->GetName() << " (density: << 145          << G4BestUnit(tickness,"Length") << " of "
134          << G4endl;                            << 146          << material->GetName() << " (density: " 
                                                   >> 147          << G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
135                                                   148 
136   // frequency of processes                    << 149   //frequency of processes
137   G4int survive = 0;                           << 150   G4int survive = 0;  
138   G4cout << "\n Process calls frequency --->";    151   G4cout << "\n Process calls frequency --->";
139   std::map<G4String, G4int>::iterator it;      << 152   std::map<G4String,G4int>::iterator it;  
140   for (it = fProcCounter.begin(); it != fProcC    153   for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
141     G4String procName = it->first;             << 154      G4String procName = it->first;
142     G4int count = it->second;                  << 155      G4int    count    = it->second;
143     G4cout << "\t" << procName << " = " << cou << 156      G4cout << "\t" << procName << " = " << count;
144     if (procName == "Transportation") survive  << 157      if (procName == "Transportation") survive = count;
145   }                                               158   }
146                                                   159 
147   if (survive > 0) {                              160   if (survive > 0) {
148     G4cout << "\n\n Nb of incident particles s    161     G4cout << "\n\n Nb of incident particles surviving after "
149            << G4BestUnit(fDetector->GetSize(), << 162            << G4BestUnit(fDetector->GetSize(),"Length") << " of "
150            << survive << G4endl;               << 163            << material->GetName() << " : " << survive << G4endl;
151   }                                               164   }
152                                                   165 
153   if (fTotalCount == 0) fTotalCount = 1;  // f << 166   if (fTotalCount == 0) fTotalCount = 1;   //force printing anyway
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                                                   167 
169   // compute energy transfer coefficient       << 168   //compute mean free path and related quantities
170   //                                              169   //
171   G4double MeanTransfer = fEnTransfer / fTotal << 170   G4double MeanFreePath = fSumTrack /fTotalCount;     
172   G4double massTransfCoef = massicCS * MeanTra << 171   G4double MeanTrack2   = fSumTrack2/fTotalCount;     
173                                                << 172   G4double rms = std::sqrt(std::fabs(MeanTrack2 - MeanFreePath*MeanFreePath));
174   G4cout << "\n mean energy of charged seconda << 173   G4double CrossSection = 1./MeanFreePath;     
175          << "\n     ---> mass_energy_transfer  << 174   G4double massicMFP = MeanFreePath*density;
                                                   >> 175   G4double massicCS  = 1./massicMFP;
                                                   >> 176 
                                                   >> 177   G4cout << "\n\n MeanFreePath:\t"   << G4BestUnit(MeanFreePath,"Length")
                                                   >> 178          << " +- "                   << G4BestUnit( rms,"Length")
                                                   >> 179          << "\tmassic: "             << G4BestUnit(massicMFP, "Mass/Surface")
                                                   >> 180          << "\n CrossSection:\t"     << CrossSection*cm << " cm^-1 "
                                                   >> 181          << "\t\t\tmassic: "         << G4BestUnit(massicCS, "Surface/Mass")
176          << G4endl;                               182          << G4endl;
                                                   >> 183          
                                                   >> 184   //compute energy transfer coefficient
                                                   >> 185   //
                                                   >> 186   G4double MeanTransfer   = fEnTransfer/fTotalCount;
                                                   >> 187   G4double massTransfCoef = massicCS*MeanTransfer/fEkin;
                                                   >> 188    
                                                   >> 189   G4cout << "\n mean energy of charged secondaries: " 
                                                   >> 190          << G4BestUnit(MeanTransfer, "Energy")
                                                   >> 191          << "\n     ---> mass_energy_transfer coef: "
                                                   >> 192          << G4BestUnit(massTransfCoef, "Surface/Mass")
                                                   >> 193          << G4endl;       
177                                                   194 
178   // check cross section from G4EmCalculator   << 195   //check cross section from G4EmCalculator
179   //                                              196   //
180   G4cout << "\n Verification : "                  197   G4cout << "\n Verification : "
181          << "crossSections from G4EmCalculator    198          << "crossSections from G4EmCalculator \n";
182                                                   199 
183   G4EmCalculator emCalculator;                    200   G4EmCalculator emCalculator;
184   G4double sumc = 0.0;                         << 201   G4double sumc = 0.0;  
185   for (it = fProcCounter.begin(); it != fProcC    202   for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
186     G4String procName = it->first;             << 203     G4String procName = it->first;      
187     G4double massSigma =                       << 204     G4double massSigma = 
188       emCalculator.GetCrossSectionPerVolume(fE << 205     emCalculator.GetCrossSectionPerVolume(fEkin,fParticle,
                                                   >> 206                                               procName,material)/density;
189     if (fParticle == G4Gamma::Gamma())            207     if (fParticle == G4Gamma::Gamma())
190       massSigma =                              << 208        massSigma = 
191         emCalculator.ComputeCrossSectionPerVol << 209        emCalculator.ComputeCrossSectionPerVolume(fEkin,fParticle,
                                                   >> 210                                               procName,material)/density;
192     sumc += massSigma;                            211     sumc += massSigma;
193     G4cout << "   " << procName << "= " << G4B << 212     G4cout << "   " << procName << "= " 
                                                   >> 213            << G4BestUnit(massSigma, "Surface/Mass");
194   }                                               214   }
195   G4cout << "   total= " << G4BestUnit(sumc, " << 215   G4cout << "   total= " 
                                                   >> 216          << G4BestUnit(sumc, "Surface/Mass") << G4endl;
196                                                   217 
197   // remove all contents in fProcCounter       << 218   // remove all contents in fProcCounter 
198   fProcCounter.clear();                           219   fProcCounter.clear();
199                                                   220 
200   // restore default format                    << 221   //restore default format
201   G4cout.precision(dfprec);                    << 222   G4cout.precision(dfprec);  
202 }                                                 223 }
203                                                   224 
204 //....oooOO0OOooo........oooOO0OOooo........oo    225 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
205                                                   226