Geant4 Cross Reference |
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/TestEm13/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 "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::Merge(const G4Run* run) 72 { 73 const Run* localRun = static_cast<const Run* 74 75 // pass information about primary particle 76 fParticle = localRun->fParticle; 77 fEkin = localRun->fEkin; 78 79 // map: processes count 80 std::map<G4String, G4int>::const_iterator it 81 for (it = localRun->fProcCounter.begin(); it 82 G4String procName = it->first; 83 G4int localCount = it->second; 84 if (fProcCounter.find(procName) == fProcCo 85 fProcCounter[procName] = localCount; 86 } 87 else { 88 fProcCounter[procName] += localCount; 89 } 90 } 91 92 G4Run::Merge(run); 93 } 94 95 //....oooOO0OOooo........oooOO0OOooo........oo 96 97 void Run::EndOfRun() 98 { 99 G4int prec = 5; 100 G4int dfprec = G4cout.precision(prec); 101 102 // run condition 103 // 104 G4String partName = fParticle->GetParticleNa 105 G4Material* material = fDetector->GetMateria 106 G4double density = material->GetDensity(); 107 G4double tickness = fDetector->GetSize(); 108 109 G4cout << "\n ======================== run s 110 G4cout << "\n The run is: " << numberOfEvent 111 << G4BestUnit(fEkin, "Energy") << " t 112 << material->GetName() << " (density: 113 << G4endl; 114 115 // frequency of processes 116 G4int totalCount = 0; 117 G4int survive = 0; 118 G4cout << "\n Process calls frequency --->"; 119 std::map<G4String, G4int>::iterator it; 120 for (it = fProcCounter.begin(); it != fProcC 121 G4String procName = it->first; 122 G4int count = it->second; 123 totalCount += count; 124 G4cout << "\t" << procName << " = " << cou 125 if (procName == "Transportation") survive 126 } 127 G4cout << G4endl; 128 129 if (totalCount == 0) { 130 G4cout.precision(dfprec); 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 140 if (ratio == 0.) return; 141 142 // compute cross section and related quantit 143 // 144 G4double CrossSection = -std::log(ratio) / t 145 G4double massicCS = CrossSection / density; 146 147 G4cout << " ---> CrossSection per volume:\t" 148 << "\tCrossSection per mass: " << G4B 149 150 // check cross section from G4EmCalculator 151 // 152 G4cout << "\n Verification from G4EmCalculat 153 G4EmCalculator emCalculator; 154 G4double sumc = 0.0; 155 for (it = fProcCounter.begin(); it != fProcC 156 G4String procName = it->first; 157 G4double massSigma = 158 emCalculator.GetCrossSectionPerVolume(fE 159 if (fParticle == G4Gamma::Gamma()) 160 massSigma = 161 emCalculator.ComputeCrossSectionPerVol 162 sumc += massSigma; 163 if (procName != "Transportation") 164 G4cout << "\t" << procName << "= " << G4 165 } 166 G4cout << "\ttotal= " << G4BestUnit(sumc, "S 167 168 // expected ratio of transmitted particles 169 G4double Ratio = std::exp(-sumc * density * 170 G4cout << "\tExpected ratio of transmitted p 171 172 // remove all contents in fProcCounter 173 fProcCounter.clear(); 174 175 // restore default format 176 G4cout.precision(dfprec); 177 } 178 179 //....oooOO0OOooo........oooOO0OOooo........oo 180