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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.6)


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