Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/optical/OpNovice2/src/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 // $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include <numeric>
35 
36 #include "Run.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 {
75  fParticle = particle;
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  std::ios::fmtflags mode = G4cout.flags();
114  G4int prec = G4cout.precision(2);
115 
116  G4cout << "\n Run Summary\n";
117  G4cout << "---------------------------------\n";
118  G4cout << "Primary particle was: " << fParticle->GetParticleName()
119  << " with energy " << G4BestUnit(fEkin, "Energy") << "." << G4endl;
120 
121  if (fParticle->GetParticleName() != "opticalphoton") {
122  G4cout << "Average energy of Cerenkov photons created per event: "
123  << (fCerenkovEnergy/eV)/TotNbofEvents << " eV." << G4endl;
124  G4cout << "Average number of Cerenkov photons created per event: "
125  << fCerenkovCount/TotNbofEvents << G4endl;
126  if (fCerenkovCount > 0) {
127  G4cout << " Average energy: " << (fCerenkovEnergy/eV)/fCerenkovCount
128  << " eV." << G4endl;
129  }
130  G4cout << "Average energy of scintillation photons created per event: "
131  << (fScintEnergy/eV)/TotNbofEvents << " eV." << G4endl;
132  G4cout << "Average number of scintillation photons created per event: "
133  << fScintCount/TotNbofEvents << G4endl;
134  if (fScintCount > 0) {
135  G4cout << " Average energy: " << (fScintEnergy/eV)/fScintCount << " eV."
136  << G4endl;
137  }
138  G4cout << "Average number of OpRayleigh scatters per event: "
139  << fRayleighCount/TotNbofEvents << G4endl;
140  G4cout << "\n";
141  }
142  G4cout << "OpAbsorption per event: " << fOpAbsorption/TotNbofEvents
143  << G4endl;
144  G4cout << "\nSurface events (on +X surface) this run:" << G4endl;
145  G4cout << "# of primary particles: " << std::setw(8) << TotNbofEvents
146  << G4endl;
147  G4cout << "OpAbsorption before surface: " << std::setw(8)
149  G4cout << "Total # of surface events: " << std::setw(8) << fTotalSurface
150  << G4endl;
151  if (fParticle->GetParticleName() == "opticalphoton") {
152  G4cout << "Unaccounted for: " << std::setw(8)
153  << fTotalSurface + fOpAbsorptionPrior - TotNbofEvents << G4endl;
154  }
155  G4cout << "\nSurface events by process:" << G4endl;
156  if (fBoundaryProcs[Transmission] > 0) {
157  G4cout << " Transmission: " << std::setw(8)
159  }
161  G4cout << " Fresnel refraction: " << std::setw(8)
163  }
165  G4cout << " Fresnel reflection: " << std::setw(8)
167  }
169  G4cout << " Total internal reflection: " << std::setw(8)
171  }
173  G4cout << " Lambertian reflection: " << std::setw(8)
175  }
176  if (fBoundaryProcs[LobeReflection] > 0) {
177  G4cout << " Lobe reflection: " << std::setw(8)
179  }
180  if (fBoundaryProcs[SpikeReflection] > 0) {
181  G4cout << " Spike reflection: " << std::setw(8)
183  }
184  if (fBoundaryProcs[BackScattering] > 0) {
185  G4cout << " Backscattering: " << std::setw(8)
187  }
188  if (fBoundaryProcs[Absorption] > 0) {
189  G4cout << " Absorption: " << std::setw(8)
191  }
192  if (fBoundaryProcs[Detection] > 0) {
193  G4cout << " Detection: " << std::setw(8)
195  }
196  if (fBoundaryProcs[NotAtBoundary] > 0) {
197  G4cout << " Not at boundary: " << std::setw(8)
199  }
200  if (fBoundaryProcs[SameMaterial] > 0) {
201  G4cout << " Same material: " << std::setw(8)
203  }
204  if (fBoundaryProcs[StepTooSmall] > 0) {
205  G4cout << " Step too small: " << std::setw(8)
207  }
208  if (fBoundaryProcs[NoRINDEX] > 0) {
209  G4cout << " No RINDEX: " << std::setw(8)
211  }
212  // LBNL polished
214  G4cout << " Polished Lumirror Air reflection: " << std::setw(8)
216  }
218  G4cout << " Polished Lumirror Glue reflection: " << std::setw(8)
220  }
222  G4cout << " Polished Air reflection: " << std::setw(8)
224  }
226  G4cout << " Polished Teflon Air reflection: " << std::setw(8)
228  }
230  G4cout << " Polished TiO Air reflection: " << std::setw(8)
232  }
234  G4cout << " Polished Tyvek Air reflection: " << std::setw(8)
236  }
238  G4cout << " Polished VM2000 Air reflection: " << std::setw(8)
240  }
242  G4cout << " Polished VM2000 Glue reflection: " << std::setw(8)
244  }
245  // LBNL etched
247  G4cout << " Etched Lumirror Air reflection: " << std::setw(8)
249  }
251  G4cout << " Etched Lumirror Glue reflection: " << std::setw(8)
253  }
255  G4cout << " Etched Air reflection: " << std::setw(8)
257  }
259  G4cout << " Etched Teflon Air reflection: " << std::setw(8)
261  }
263  G4cout << " Etched TiO Air reflection: " << std::setw(8)
265  }
267  G4cout << " Etched Tyvek Air reflection: " << std::setw(8)
269  }
271  G4cout << " Etched VM2000 Air reflection: " << std::setw(8)
273  }
275  G4cout << " Etched VM2000 Glue reflection: " << std::setw(8)
277  }
278  // LBNL ground
280  G4cout << " Ground Lumirror Air reflection: " << std::setw(8)
282  }
284  G4cout << " Ground Lumirror Glue reflection: " << std::setw(8)
286  }
288  G4cout << " Ground Air reflection: " << std::setw(8)
290  }
292  G4cout << " Ground Teflon Air reflection: " << std::setw(8)
294  }
296  G4cout << " Ground TiO Air reflection: " << std::setw(8)
298  }
300  G4cout << " Ground Tyvek Air reflection: " << std::setw(8)
302  }
304  G4cout << " Ground VM2000 Air reflection: " << std::setw(8)
306  }
308  G4cout << " Ground VM2000 Glue reflection: " << std::setw(8)
310  }
311 
312  G4int sum = std::accumulate(fBoundaryProcs.begin(), fBoundaryProcs.end(), 0);
313  G4cout << " Sum: " << std::setw(8) << sum << G4endl;
314  G4cout << " Unaccounted for: " << std::setw(8)
315  << fTotalSurface - sum << G4endl;
316 
317  G4cout << "---------------------------------\n";
318 
319  G4cout.setf(mode, std::ios::floatfield);
320  G4cout.precision(prec);
321 }
static const double prec
Definition: RanecuEngine.cc:58
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
G4int numberOfEvent
Definition: G4Run.hh:59
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
double G4double
Definition: G4Types.hh:76
double energy
Definition: plottest35.C:25
virtual void Merge(const G4Run *)
static constexpr double eV
Definition: G4SIunits.hh:215
Definition: G4Run.hh:46
G4ParticleDefinition * fParticle
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
std::vector< G4int > fBoundaryProcs
G4GLOB_DLL std::ostream G4cout
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54