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
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
33
#include "Run.hh"
34
#include "
G4Step.hh
"
35
#include "
G4Run.hh
"
36
#include "
G4LossTableManager.hh
"
37
#include "
G4ElectronIonPair.hh
"
38
#include "
G4SystemOfUnits.hh
"
39
#include "
G4PhysicalConstants.hh
"
40
#include "TestParameters.hh"
41
#include "
Randomize.hh
"
42
43
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45
Run::Run
()
46
:
G4Run
(), fElIonPair(0), fParam(
TestParameters
::GetPointer())
47
{
48
fElIonPair
=
G4LossTableManager::Instance
()->
ElectronIonPair
();
49
fTotStepGas
=
fTotCluster
=
fMeanCluster
=
fOverflow
=
fTotEdep
50
=
fStepGas
=
fCluster
=
fMaxEnergy
= 0.0;
51
fEvt
=
fNbins
= 0;
52
fFactorALICE
=
fParam
->
GetFactorALICE
();
53
fWidthALICE
=
fParam
->
GetEnergySmear
();
54
}
55
56
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58
Run::~Run
()
59
{}
60
61
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62
63
void
Run::BeginOfRun
()
64
{
65
// initilise scoring
66
fTotStepGas
=
fTotCluster
=
fMeanCluster
=
fOverflow
=
fTotEdep
67
=
fStepGas
=
fCluster
= 0.0;
68
fEvt
= 0;
69
70
fFactorALICE
=
fParam
->
GetFactorALICE
();
71
fWidthALICE
=
fParam
->
GetEnergySmear
();
72
73
SetVerbose
(1);
74
75
fNbins
=
fParam
->
GetNumberBins
();
76
fMaxEnergy
=
fParam
->
GetMaxEnergy
();
77
78
fEgas
.resize(
fNbins
,0.0);
79
fEdep
.reset();
80
81
if
(
fVerbose
> 0) {
82
G4int
binsCluster =
fParam
->
GetNumberBinsCluster
();
83
G4cout
<<
" BinsCluster= "
<< binsCluster <<
" BinsE= "
<<
fNbins
84
<<
" Emax(keV)= "
<<
fMaxEnergy
/
keV
<<
G4endl
;
85
G4cout
<<
" WidthALICE(keV)= "
<<
fWidthALICE
/
keV
86
<<
" FactorALICE= "
<<
fFactorALICE
<<
G4endl
;
87
88
}
89
}
90
91
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92
93
void
Run::EndOfRun
()
94
{
95
G4int
nEvt =
GetNumberOfEvent
();
96
G4double
norm
= (nEvt > 0) ? 1.0/(
G4double
)nEvt : 0.0;
97
98
fTotStepGas
*=
norm
;
99
fTotCluster
*=
norm
;
100
fMeanCluster
*=
norm
;
101
fOverflow
*=
norm
;
102
103
G4double
y1
=
fEdep
.mean();
104
G4double
y2
=
fEdep
.rms();
105
106
G4double
de =
fMaxEnergy
/
G4double
(
fNbins
);
107
G4double
x1
= -de*0.5;
108
109
fFactorALICE
=
fParam
->
GetFactorALICE
();
110
111
G4cout
<<
" ===================================================="
<<
G4endl
;
112
G4cout
<<
" Beam Particle: "
113
<<
fParam
->
GetBeamParticle
()->
GetParticleName
() << G4endl
114
<<
" Ekin(MeV) = "
<<
fParam
->
GetBeamEnergy
()/
MeV
115
<< G4endl
116
<<
" Z(mm) = "
<<
fParam
->
GetPositionZ
()/
mm
117
<<
G4endl
;
118
G4cout
<<
" ================== run summary ====================="
<<
G4endl
;
119
G4int
prec
=
G4cout
.precision(5);
120
G4cout
<<
" End of Run TotNbofEvents = "
121
<< nEvt <<
G4endl
;
122
G4cout
<<
" Energy(keV) per ADC channel = "
123
<< 1.0/(
keV
*
fFactorALICE
) << G4endl;
124
125
G4cout
<<
G4endl
;
126
G4cout
<<
" Mean energy deposit in absorber = "
<<
127
y1/
keV
<<
" +- "
<< y2*std::sqrt(norm)/
keV
<<
" keV; "
;
128
if
(y1 > 0.0) {
G4cout
<<
" RMS/Emean = "
<< y2/
y1
; }
129
G4cout
<<
G4endl
;
130
G4cout
<<
" Mean number of steps in absorber= "
131
<<
fTotStepGas
<<
"; mean number of ion-clusters = "
132
<<
fTotCluster
<<
" MeanCluster= "
<<
fMeanCluster
133
<<
G4endl
;
134
G4cout
<<
G4endl
;
135
136
G4cout
<<
" ====== Energy deposit distribution Noverflows= "
<<
fOverflow
137
<<
" ====== "
<<
G4endl
;
138
G4cout
<<
" bin nb Elow entries normalized "
<<
G4endl
;
139
140
std::ofstream fileOut(
"distribution.out"
, std::ios::out );
141
fileOut.setf( std::ios::scientific, std::ios::floatfield );
142
143
x1 = 0.0;
144
145
fileOut <<
fNbins
<<
G4endl
;
146
147
for
(
G4int
j=0; j<
fNbins
; ++j)
148
{
149
G4cout
<< std::setw(5) << j << std::setw(10) << x1/
keV
150
<< std::setw(12) <<
fEgas
[j] << std::setw(12) <<
fEgas
[j]*norm
151
<<
G4endl
;
152
fileOut << x1/
keV
<<
"\t"
<<
fEgas
[j] <<
G4endl
;
153
x1 += de;
154
}
155
G4cout
.precision(prec);
156
157
G4AnalysisManager
* analysisManager =
G4AnalysisManager::Instance
();
158
// normalize histograms
159
G4double
normf =
fParam
->
GetNormFactor
();
160
analysisManager->
ScaleH1
(1,norm);
161
analysisManager->
ScaleH1
(2,norm);
162
analysisManager->
ScaleH1
(3,norm*normf);
163
164
G4cout
<<
" ================== run end =========================="
<<
G4endl
;
165
}
166
167
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168
169
void
Run::BeginOfEvent
()
170
{
171
fTotEdep
= 0.0;
172
fStepGas
= 0;
173
fCluster
= 0;
174
++
fEvt
;
175
}
176
177
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
178
179
void
Run::EndOfEvent
()
180
{
181
fTotStepGas
+=
fStepGas
;
182
fTotCluster
+=
fCluster
;
183
184
if
(
fWidthALICE
> 0.0) {
185
G4double
x
=
G4RandGauss::shoot
(0.,
fWidthALICE
);
186
fTotEdep
+=
x
;
187
fTotEdep
=
std::max
(
fTotEdep
, 0.0);
188
}
189
190
G4int
idx
=
G4int
(
fTotEdep
*fNbins/
fMaxEnergy
);
191
192
if
(idx < 0) {
fEgas
[0] += 1.0; }
193
if
(idx >= fNbins) {
fOverflow
+= 1.0; }
194
else
{
fEgas
[
idx
] += 1.0; }
195
196
G4AnalysisManager
* analysisManager =
G4AnalysisManager::Instance
();
197
// fill histo
198
analysisManager->
FillH1
(1,
fTotEdep
/
keV
,1.0);
199
analysisManager->
FillH1
(2,
fCluster
,1.0);
200
analysisManager->
FillH1
(3,
fTotEdep
*
fFactorALICE
,1.0);
201
fEdep
.fill(
fTotEdep
, 1.0);
202
}
203
204
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
205
206
void
Run::Merge
(
const
G4Run
* run)
207
{
208
const
Run
* localRun =
static_cast<
const
Run
*
>
(run);
209
210
fTotStepGas
+= localRun->
fTotStepGas
;
211
fTotCluster
+= localRun->
fTotCluster
;
212
fMeanCluster
+= localRun->
fMeanCluster
;
213
fOverflow
+= localRun->
fOverflow
;
214
215
G4StatDouble
* stat =
const_cast<
G4StatDouble
*
>
(localRun->
GetStat
());
216
217
fEdep
.add(stat);
218
219
for
(
G4int
j=0; j<
fNbins
; ++j)
220
{
221
fEgas
[j] += localRun->
fEgas
[j];
222
}
223
224
G4Run::Merge
(run);
225
}
226
227
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
228
229
void
Run::AddEnergy
(
G4double
edep
,
const
G4Step
*
step
)
230
{
231
if
(1 <
fVerbose
) {
232
G4cout
<<
"Run::AddEnergy: e(keV)= "
<< edep/
keV
233
<<
G4endl
;
234
}
235
fTotEdep
+=
edep
;
236
if
(step) {
237
if
(1 == step->
GetTrack
()->
GetTrackID
()) {
fStepGas
+= 1.0; }
238
239
fMeanCluster
+=
fElIonPair
->
MeanNumberOfIonsAlongStep
(step);
240
fCluster
+=
fElIonPair
->
SampleNumberOfIonsAlongStep
(step);
241
}
242
}
243
244
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
electromagnetic
TestEm8
src
Run.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:54
using
1.8.2 with
ECCE GitHub integration