ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
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
#include "Run.hh"
31
#include "
G4Step.hh
"
32
#include "
G4Run.hh
"
33
#include "
G4LossTableManager.hh
"
34
#include "
G4ElectronIonPair.hh
"
35
#include "
G4SystemOfUnits.hh
"
36
#include "
G4PhysicalConstants.hh
"
37
#include "TestParameters.hh"
38
#include "
Randomize.hh
"
39
40
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41
42
Run::Run
()
43
:
G4Run
(), fParam(
TestParameters
::GetPointer())
44
{
45
fTotStepGas
=
fOverflow
=
fTotEdep
=
fStepGas
=
fMaxEnergy
= 0.0;
46
fEvt
=
fNbins
= 0;
47
}
48
49
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50
51
Run::~Run
()
52
{}
53
54
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55
56
void
Run::BeginOfRun
()
57
{
58
// initilise scoring
59
fTotStepGas
=
fOverflow
=
fTotEdep
=
fStepGas
=
fMaxEnergy
= 0.0;
60
fEvt
= 0;
61
62
SetVerbose
(1);
63
64
fNbins
=
fParam
->
GetNumberBins
();
65
fMaxEnergy
=
fParam
->
GetMaxEnergy
();
66
67
fEgas
.resize(
fNbins
,0.0);
68
fEdep
.reset();
69
70
if
(
fVerbose
> 0)
71
{
72
G4cout
<<
" BinsE= "
<<
fNbins
73
<<
" Emax(keV)= "
<<
fMaxEnergy
/
keV
<<
G4endl
;
74
}
75
}
76
77
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78
79
void
Run::EndOfRun
()
80
{
81
G4int
nEvt =
GetNumberOfEvent
();
82
83
G4double
norm
= (nEvt > 0) ? 1.0/(
G4double
)nEvt : 0.0;
84
85
fTotStepGas
*=
norm
;
86
fOverflow
*=
norm
;
87
88
G4double
y1
=
fEdep
.mean();
89
G4double
y2
=
fEdep
.rms();
90
91
//G4double de = fMaxEnergy/G4double(fNbins);
92
//G4double x1 = -de*0.5;
93
94
G4cout
<<
" ===================================================="
<<
G4endl
;
95
G4cout
<<
" Beam Particle: "
96
<<
fParam
->
GetBeamParticle
()->
GetParticleName
() << G4endl
97
<<
" Ekin(GeV) = "
<<
fParam
->
GetBeamEnergy
()/
GeV
98
<< G4endl
99
<<
" Z(mm) = "
<<
fParam
->
GetPositionZ
()/
mm
100
<<
G4endl
;
101
G4cout
<<
" ================== run summary ====================="
<<
G4endl
;
102
G4int
prec
=
G4cout
.precision(5);
103
G4cout
<<
" End of Run TotNbofEvents = "
104
<< nEvt <<
G4endl
;
105
106
G4cout
<<
G4endl
;
107
G4cout
<<
" Mean energy deposit in absorber = "
<<
108
y1/
GeV
<<
" +- "
<< y2*std::sqrt(norm)/
GeV
<<
" GeV; "
;
109
if
(y1 > 0.0) {
G4cout
<<
" RMS/Emean = "
<< y2/
y1
; }
110
G4cout
<<
G4endl
;
111
G4cout
<<
" Mean number of steps in absorber= "
112
<<
fTotStepGas
113
<<
G4endl
;
114
G4cout
<<
G4endl
;
115
/*
116
G4cout << " ====== Energy deposit distribution Noverflows= " << fOverflow
117
<< " ====== " << G4endl ;
118
G4cout << " bin nb Elow entries normalized " << G4endl;
119
120
x1 = 0.0;
121
122
for(G4int j=0; j<fNbins; ++j)
123
{
124
G4cout << std::setw(5) << j << std::setw(10) << x1/keV
125
<< std::setw(12) << fEgas[j] << std::setw(12) << fEgas[j]*norm
126
<< G4endl ;
127
x1 += de;
128
}
129
*/
130
G4cout
.precision(prec);
131
132
G4AnalysisManager
* analysisManager =
G4AnalysisManager::Instance
();
133
134
// normalize histograms
135
136
analysisManager->
ScaleH1
(1,norm);
137
138
G4cout
<<
" ================== run end =========================="
<<
G4endl
;
139
}
140
141
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
142
143
void
Run::BeginOfEvent
()
144
{
145
fTotEdep
= 0.0;
146
fStepGas
= 0;
147
++
fEvt
;
148
}
149
150
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151
152
void
Run::EndOfEvent
()
153
{
154
/*
155
G4cout << "fStepGas = " << fStepGas << " fTotStepGas= " << fTotStepGas
156
<< " fTotEdep= " << fTotEdep << " fNbins= " << fNbins
157
<< " fMaxEnergy= " << fMaxEnergy << G4endl;
158
*/
159
fTotStepGas
+=
fStepGas
;
160
161
G4int
idx
=
G4lrint
(
fTotEdep
*
fNbins
/
fMaxEnergy
);
162
163
if
(idx < 0) {
fEgas
[0] += 1.0; }
164
if
(idx >=
fNbins
) {
fOverflow
+= 1.0; }
165
else
{
fEgas
[
idx
] += 1.0; }
166
167
G4AnalysisManager
* analysisManager =
G4AnalysisManager::Instance
();
168
169
// fill histo
170
171
analysisManager->
FillH1
(1,
fTotEdep
/
GeV
,1.0);
172
fEdep
.fill(
fTotEdep
, 1.0);
173
}
174
175
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176
//
177
// Allows one to accumulate data from different threads
178
179
void
Run::Merge
(
const
G4Run
* run )
180
{
181
const
Run
* localRun =
static_cast<
const
Run
*
>
(run);
182
183
fTotStepGas
+= localRun->
fTotStepGas
;
184
fOverflow
+= localRun->
fOverflow
;
185
186
G4StatDouble
* stat =
const_cast<
G4StatDouble
*
>
(localRun->
GetStat
());
187
188
fEdep
.add(stat);
189
190
for
(
G4int
j = 0; j <
fNbins
; ++j )
191
{
192
fEgas
[j] += localRun->
fEgas
[j];
193
}
194
195
G4Run::Merge
(run);
196
}
197
198
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
199
//
200
// Is called from TargetSD
201
202
void
Run::AddEnergy
(
G4double
edep
,
const
G4Step
*
step
)
203
{
204
if
( 1 <
fVerbose
)
205
{
206
G4cout
<<
"Run::AddEnergy: e(keV)= "
<< edep/
keV
207
<<
G4endl
;
208
}
209
fTotEdep
+=
edep
;
210
211
if
( step )
212
{
213
if
( 1 == step->
GetTrack
()->
GetTrackID
())
214
{
215
fStepGas
+= 1.0;
216
}
217
}
218
}
219
220
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
221
geant4
tree
geant4-10.6-release
examples
extended
exoticphysics
dmparticle
src
Run.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:54
using
1.8.2 with
ECCE GitHub integration