ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Run.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Run.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include <numeric>
34 
35 #include "Run.hh"
36 #include "DetectorConstruction.hh"
37 
38 #include "G4OpBoundaryProcess.hh"
39 #include "G4SystemOfUnits.hh"
40 #include "G4UnitsTable.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 Run::Run()
44 : G4Run()
45 {
46  fParticle = nullptr;
47  fEkin = -1.;
48 
49  fCerenkovEnergy = 0.0;
50  fScintEnergy = 0.0;
51 
52  fCerenkovCount = 0;
53  fScintCount = 0;
54  fRayleighCount = 0;
55 
56  fOpAbsorption = 0;
58 
59  fTotalSurface = 0;
60 
61  fBoundaryProcs.clear();
62  fBoundaryProcs.resize(40);
63  for (G4int i = 0; i < 40; ++i) {
64  fBoundaryProcs[i] = 0;
65  }
66 }
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 Run::~Run()
70 {}
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 {
76  fEkin = energy;
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 void Run::Merge(const G4Run* run)
81 {
82  const Run* localRun = static_cast<const Run*>(run);
83 
84  // pass information about primary particle
85  fParticle = localRun->fParticle;
86  fEkin = localRun->fEkin;
87 
88  fCerenkovEnergy += localRun->fCerenkovEnergy;
89  fScintEnergy += localRun->fScintEnergy;
90 
91  fCerenkovCount += localRun->fCerenkovCount;
92  fScintCount += localRun->fScintCount;
93  fRayleighCount += localRun->fRayleighCount;
94 
95  fTotalSurface += localRun->fTotalSurface;
96 
97  fOpAbsorption += localRun->fOpAbsorption;
99 
100  for (size_t i = 0; i < fBoundaryProcs.size(); ++i) {
101  fBoundaryProcs[i] += localRun->fBoundaryProcs[i];
102  }
103 
104  G4Run::Merge(run);
105 }
106 
107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 void Run::EndOfRun()
109 {
110  G4int TotNbofEvents = numberOfEvent;
111  if (TotNbofEvents == 0) return;
112 
113  const DetectorConstruction* det = (const DetectorConstruction*)
115 
116  std::ios::fmtflags mode = G4cout.flags();
117  G4int prec = G4cout.precision(2);
118 
119  G4cout << "\n Run Summary\n";
120  G4cout << "---------------------------------\n";
121  G4cout << "Primary particle was: " << fParticle->GetParticleName()
122  << " with energy " << G4BestUnit(fEkin, "Energy") << "." << G4endl;
123 
124  G4cout << "Material of world: " << det->GetWorldMaterial()->GetName()
125  << G4endl;
126  G4cout << "Material of tank: " << det->GetTankMaterial()->GetName()
127  << G4endl << G4endl;
128 
129  if (fParticle->GetParticleName() != "opticalphoton") {
130  G4cout << "Average energy of Cerenkov photons created per event: "
131  << (fCerenkovEnergy/eV)/TotNbofEvents << " eV." << G4endl;
132  G4cout << "Average number of Cerenkov photons created per event: "
133  << fCerenkovCount/TotNbofEvents << G4endl;
134  if (fCerenkovCount > 0) {
135  G4cout << " Average energy: " << (fCerenkovEnergy/eV)/fCerenkovCount
136  << " eV." << G4endl;
137  }
138  G4cout << "Average energy of scintillation photons created per event: "
139  << (fScintEnergy/eV)/TotNbofEvents << " eV." << G4endl;
140  G4cout << "Average number of scintillation photons created per event: "
141  << fScintCount/TotNbofEvents << G4endl;
142  if (fScintCount > 0) {
143  G4cout << " Average energy: " << (fScintEnergy/eV)/fScintCount << " eV."
144  << G4endl;
145  }
146  }
147  G4cout << "Average number of OpRayleigh per event: "
148  << fRayleighCount/TotNbofEvents << G4endl;
149  G4cout << "Average number of OpAbsorption per event: "
150  << fOpAbsorption/TotNbofEvents << G4endl;
151  G4cout <<
152  "\nSurface events (on +X surface, maximum one per photon) this run:"
153  << G4endl;
154  G4cout << "# of primary particles: " << std::setw(8) << TotNbofEvents
155  << G4endl;
156  G4cout << "OpAbsorption before surface: " << std::setw(8)
158  G4cout << "Total # of surface events: " << std::setw(8) << fTotalSurface
159  << G4endl;
160  if (fParticle->GetParticleName() == "opticalphoton") {
161  G4cout << "Unaccounted for: " << std::setw(8)
162  << fTotalSurface + fOpAbsorptionPrior - TotNbofEvents << G4endl;
163  }
164  G4cout << "\nSurface events by process:" << G4endl;
165  if (fBoundaryProcs[Transmission] > 0) {
166  G4cout << " Transmission: " << std::setw(8)
168  }
170  G4cout << " Fresnel refraction: " << std::setw(8)
172  }
174  G4cout << " Fresnel reflection: " << std::setw(8)
176  }
178  G4cout << " Total internal reflection: " << std::setw(8)
180  }
182  G4cout << " Lambertian reflection: " << std::setw(8)
184  }
185  if (fBoundaryProcs[LobeReflection] > 0) {
186  G4cout << " Lobe reflection: " << std::setw(8)
188  }
189  if (fBoundaryProcs[SpikeReflection] > 0) {
190  G4cout << " Spike reflection: " << std::setw(8)
192  }
193  if (fBoundaryProcs[BackScattering] > 0) {
194  G4cout << " Backscattering: " << std::setw(8)
196  }
197  if (fBoundaryProcs[Absorption] > 0) {
198  G4cout << " Absorption: " << std::setw(8)
200  }
201  if (fBoundaryProcs[Detection] > 0) {
202  G4cout << " Detection: " << std::setw(8)
204  }
205  if (fBoundaryProcs[NotAtBoundary] > 0) {
206  G4cout << " Not at boundary: " << std::setw(8)
208  }
209  if (fBoundaryProcs[SameMaterial] > 0) {
210  G4cout << " Same material: " << std::setw(8)
212  }
213  if (fBoundaryProcs[StepTooSmall] > 0) {
214  G4cout << " Step too small: " << std::setw(8)
216  }
217  if (fBoundaryProcs[NoRINDEX] > 0) {
218  G4cout << " No RINDEX: " << std::setw(8)
220  }
221  // LBNL polished
223  G4cout << " Polished Lumirror Air reflection: " << std::setw(8)
225  }
227  G4cout << " Polished Lumirror Glue reflection: " << std::setw(8)
229  }
231  G4cout << " Polished Air reflection: " << std::setw(8)
233  }
235  G4cout << " Polished Teflon Air reflection: " << std::setw(8)
237  }
239  G4cout << " Polished TiO Air reflection: " << std::setw(8)
241  }
243  G4cout << " Polished Tyvek Air reflection: " << std::setw(8)
245  }
247  G4cout << " Polished VM2000 Air reflection: " << std::setw(8)
249  }
251  G4cout << " Polished VM2000 Glue reflection: " << std::setw(8)
253  }
254  // LBNL etched
256  G4cout << " Etched Lumirror Air reflection: " << std::setw(8)
258  }
260  G4cout << " Etched Lumirror Glue reflection: " << std::setw(8)
262  }
264  G4cout << " Etched Air reflection: " << std::setw(8)
266  }
268  G4cout << " Etched Teflon Air reflection: " << std::setw(8)
270  }
272  G4cout << " Etched TiO Air reflection: " << std::setw(8)
274  }
276  G4cout << " Etched Tyvek Air reflection: " << std::setw(8)
278  }
280  G4cout << " Etched VM2000 Air reflection: " << std::setw(8)
282  }
284  G4cout << " Etched VM2000 Glue reflection: " << std::setw(8)
286  }
287  // LBNL ground
289  G4cout << " Ground Lumirror Air reflection: " << std::setw(8)
291  }
293  G4cout << " Ground Lumirror Glue reflection: " << std::setw(8)
295  }
297  G4cout << " Ground Air reflection: " << std::setw(8)
299  }
301  G4cout << " Ground Teflon Air reflection: " << std::setw(8)
303  }
305  G4cout << " Ground TiO Air reflection: " << std::setw(8)
307  }
309  G4cout << " Ground Tyvek Air reflection: " << std::setw(8)
311  }
313  G4cout << " Ground VM2000 Air reflection: " << std::setw(8)
315  }
317  G4cout << " Ground VM2000 Glue reflection: " << std::setw(8)
319  }
320 
321  G4int sum = std::accumulate(fBoundaryProcs.begin(), fBoundaryProcs.end(), 0);
322  G4cout << " Sum: " << std::setw(8) << sum << G4endl;
323  G4cout << " Unaccounted for: " << std::setw(8)
324  << fTotalSurface - sum << G4endl;
325 
326  G4cout << "---------------------------------\n";
327 
328  G4cout.setf(mode, std::ios::floatfield);
329  G4cout.precision(prec);
330 }