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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/TestEm13/src/Run.cc (Version 11.3.0) and /examples/extended/electromagnetic/TestEm13/src/Run.cc (Version 10.7.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 electromagnetic/TestEm13/src/Run.cc      26 /// \file electromagnetic/TestEm13/src/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 { }
                                                   >>  51 
                                                   >>  52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >>  53 
                                                   >>  54 Run::~Run()
                                                   >>  55 { }
 48                                                    56 
 49 //....oooOO0OOooo........oooOO0OOooo........oo     57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 50                                                    58 
 51 void Run::SetPrimary(G4ParticleDefinition* par     59 void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy)
 52 {                                              <<  60 { 
 53   fParticle = particle;                            61   fParticle = particle;
 54   fEkin = energy;                                  62   fEkin = energy;
 55 }                                                  63 }
 56 //....oooOO0OOooo........oooOO0OOooo........oo     64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 57                                                    65 
 58 void Run::CountProcesses(G4String procName)    <<  66 void Run::CountProcesses(G4String procName) 
 59 {                                                  67 {
 60   std::map<G4String, G4int>::iterator it = fPr <<  68   std::map<G4String,G4int>::iterator it = fProcCounter.find(procName);
 61   if (it == fProcCounter.end()) {              <<  69   if ( it == fProcCounter.end()) {
 62     fProcCounter[procName] = 1;                    70     fProcCounter[procName] = 1;
 63   }                                                71   }
 64   else {                                           72   else {
 65     fProcCounter[procName]++;                  <<  73     fProcCounter[procName]++; 
 66   }                                                74   }
 67 }                                                  75 }
 68                                                <<  76  
 69 //....oooOO0OOooo........oooOO0OOooo........oo     77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70                                                    78 
 71 void Run::Merge(const G4Run* run)                  79 void Run::Merge(const G4Run* run)
 72 {                                                  80 {
 73   const Run* localRun = static_cast<const Run*     81   const Run* localRun = static_cast<const Run*>(run);
 74                                                    82 
 75   // pass information about primary particle       83   // pass information about primary particle
 76   fParticle = localRun->fParticle;                 84   fParticle = localRun->fParticle;
 77   fEkin = localRun->fEkin;                     <<  85   fEkin     = localRun->fEkin;
 78                                                <<  86       
 79   // map: processes count                      <<  87   //map: processes count
 80   std::map<G4String, G4int>::const_iterator it <<  88   std::map<G4String,G4int>::const_iterator it;
 81   for (it = localRun->fProcCounter.begin(); it <<  89   for (it = localRun->fProcCounter.begin(); 
                                                   >>  90        it !=localRun->fProcCounter.end(); ++it) {
                                                   >>  91        
 82     G4String procName = it->first;                 92     G4String procName = it->first;
 83     G4int localCount = it->second;             <<  93     G4int localCount  = it->second;
 84     if (fProcCounter.find(procName) == fProcCo <<  94     if ( fProcCounter.find(procName) == fProcCounter.end()) {
 85       fProcCounter[procName] = localCount;         95       fProcCounter[procName] = localCount;
 86     }                                              96     }
 87     else {                                         97     else {
 88       fProcCounter[procName] += localCount;        98       fProcCounter[procName] += localCount;
 89     }                                          <<  99     }         
 90   }                                               100   }
 91                                                << 101   
 92   G4Run::Merge(run);                           << 102   G4Run::Merge(run); 
 93 }                                              << 103 } 
 94                                                   104 
 95 //....oooOO0OOooo........oooOO0OOooo........oo    105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 96                                                   106 
 97 void Run::EndOfRun()                              107 void Run::EndOfRun()
 98 {                                                 108 {
 99   G4int prec = 5;                              << 109   G4int prec = 5;  
100   G4int dfprec = G4cout.precision(prec);          110   G4int dfprec = G4cout.precision(prec);
101                                                << 111   
102   // run condition                             << 112   //run condition
103   //                                           << 113   //        
104   G4String partName = fParticle->GetParticleNa << 114   G4String partName    = fParticle->GetParticleName();    
105   G4Material* material = fDetector->GetMateria    115   G4Material* material = fDetector->GetMaterial();
106   G4double density = material->GetDensity();   << 116   G4double density     = material->GetDensity();
107   G4double tickness = fDetector->GetSize();       117   G4double tickness = fDetector->GetSize();
108                                                << 118      
109   G4cout << "\n ======================== run s    119   G4cout << "\n ======================== run summary ======================\n";
110   G4cout << "\n The run is: " << numberOfEvent    120   G4cout << "\n The run is: " << numberOfEvent << " " << partName << " of "
111          << G4BestUnit(fEkin, "Energy") << " t << 121          << G4BestUnit(fEkin,"Energy") << " through " 
112          << material->GetName() << " (density: << 122          << G4BestUnit(tickness,"Length") << " of "
113          << G4endl;                            << 123          << material->GetName() << " (density: " 
                                                   >> 124          << G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
114                                                   125 
115   // frequency of processes                    << 126   //frequency of processes
116   G4int totalCount = 0;                           127   G4int totalCount = 0;
117   G4int survive = 0;                           << 128   G4int survive = 0;  
118   G4cout << "\n Process calls frequency --->";    129   G4cout << "\n Process calls frequency --->";
119   std::map<G4String, G4int>::iterator it;      << 130   std::map<G4String,G4int>::iterator it;  
120   for (it = fProcCounter.begin(); it != fProcC    131   for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
121     G4String procName = it->first;             << 132      G4String procName = it->first;
122     G4int count = it->second;                  << 133      G4int    count    = it->second;
123     totalCount += count;                       << 134      totalCount += count; 
124     G4cout << "\t" << procName << " = " << cou << 135      G4cout << "\t" << procName << " = " << count;
125     if (procName == "Transportation") survive  << 136      if (procName == "Transportation") survive = count;
126   }                                               137   }
127   G4cout << G4endl;                               138   G4cout << G4endl;
128                                                   139 
129   if (totalCount == 0) {                       << 140   if (totalCount == 0) { G4cout.precision(dfprec);   return;};  
130     G4cout.precision(dfprec);                  << 141   G4double ratio = double(survive)/totalCount;
131     return;                                    << 
132   };                                           << 
133   G4double ratio = double(survive) / totalCoun << 
134                                                << 
135   G4cout << "\n Nb of incident particles unalt << 
136          << " of " << material->GetName() << " << 
137          << " incident particles."             << 
138          << "  Ratio = " << 100 * ratio << " % << 
139                                                   142 
                                                   >> 143   G4cout << "\n Nb of incident particles unaltered after "
                                                   >> 144          << G4BestUnit(tickness,"Length") << " of "
                                                   >> 145          << material->GetName() << " : " << survive 
                                                   >> 146          << " over " << totalCount << " incident particles."
                                                   >> 147          << "  Ratio = " << 100*ratio << " %" << G4endl;
                                                   >> 148   
140   if (ratio == 0.) return;                        149   if (ratio == 0.) return;
141                                                << 150   
142   // compute cross section and related quantit << 151   //compute cross section and related quantities
143   //                                              152   //
144   G4double CrossSection = -std::log(ratio) / t << 153   G4double CrossSection = - std::log(ratio)/tickness;     
145   G4double massicCS = CrossSection / density;  << 154   G4double massicCS  = CrossSection/density;
146                                                << 155    
147   G4cout << " ---> CrossSection per volume:\t" << 156   G4cout << " ---> CrossSection per volume:\t" << CrossSection*cm << " cm^-1 "
148          << "\tCrossSection per mass: " << G4B << 157          << "\tCrossSection per mass: " << G4BestUnit(massicCS, "Surface/Mass")
                                                   >> 158          << G4endl;
149                                                   159 
150   // check cross section from G4EmCalculator   << 160   //check cross section from G4EmCalculator
151   //                                              161   //
152   G4cout << "\n Verification from G4EmCalculat << 162   G4cout << "\n Verification from G4EmCalculator: \n"; 
153   G4EmCalculator emCalculator;                    163   G4EmCalculator emCalculator;
154   G4double sumc = 0.0;                         << 164   G4double sumc = 0.0;  
155   for (it = fProcCounter.begin(); it != fProcC    165   for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
156     G4String procName = it->first;             << 166     G4String procName = it->first;  
157     G4double massSigma =                       << 167     G4double massSigma = 
158       emCalculator.GetCrossSectionPerVolume(fE << 168     emCalculator.GetCrossSectionPerVolume(fEkin,fParticle,
                                                   >> 169                                               procName,material)/density;
159     if (fParticle == G4Gamma::Gamma())            170     if (fParticle == G4Gamma::Gamma())
160       massSigma =                              << 171        massSigma = 
161         emCalculator.ComputeCrossSectionPerVol << 172        emCalculator.ComputeCrossSectionPerVolume(fEkin,fParticle,
                                                   >> 173                                               procName,material)/density;
162     sumc += massSigma;                            174     sumc += massSigma;
163     if (procName != "Transportation")             175     if (procName != "Transportation")
164       G4cout << "\t" << procName << "= " << G4 << 176       G4cout << "\t" << procName << "= " 
165   }                                            << 177              << G4BestUnit(massSigma, "Surface/Mass");
166   G4cout << "\ttotal= " << G4BestUnit(sumc, "S << 178   }             
167                                                << 179   G4cout << "\ttotal= " 
168   // expected ratio of transmitted particles   << 180          << G4BestUnit(sumc, "Surface/Mass") << G4endl;
169   G4double Ratio = std::exp(-sumc * density *  << 181          
170   G4cout << "\tExpected ratio of transmitted p << 182   //expected ratio of transmitted particles
171                                                << 183   G4double Ratio = std::exp(-sumc*density*tickness);
172   // remove all contents in fProcCounter       << 184   G4cout << "\tExpected ratio of transmitted particles= " 
                                                   >> 185          << 100*Ratio << " %" << G4endl;         
                                                   >> 186                         
                                                   >> 187   // remove all contents in fProcCounter 
173   fProcCounter.clear();                           188   fProcCounter.clear();
174                                                << 189   
175   // restore default format                    << 190   //restore default format
176   G4cout.precision(dfprec);                    << 191   G4cout.precision(dfprec);  
177 }                                                 192 }
178                                                   193 
179 //....oooOO0OOooo........oooOO0OOooo........oo    194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180                                                   195