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
RunAction.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file RunAction.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 "RunAction.hh"
34
#include "RunActionMessenger.hh"
35
#include "DetectorConstruction.hh"
36
#include "PrimaryGeneratorAction.hh"
37
#include "Run.hh"
38
39
#include "
G4UnitsTable.hh
"
40
#include "
G4SystemOfUnits.hh
"
41
#include "
G4ios.hh
"
42
#include "
Randomize.hh
"
43
#include "
G4ProductionCutsTable.hh
"
44
45
#include "
G4EmCalculator.hh
"
46
47
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48
49
RunAction::RunAction
(
DetectorConstruction
* det,
PrimaryGeneratorAction
* kin)
50
:fDetector(det),fKinematic(kin)
51
{
52
fMessenger
=
new
RunActionMessenger
(
this
);
53
fBinLength
= 5 *
CLHEP::mm
;
54
G4AnalysisManager
* analysisManager =
G4AnalysisManager::Instance
();
55
analysisManager->
SetFileName
(
"monopole"
);
56
analysisManager->
SetVerboseLevel
(1);
57
analysisManager->
SetActivation
(
true
);
58
}
59
60
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61
62
RunAction::~RunAction
()
63
{
64
if
(
isMaster
&&
G4Threading::IsMultithreadedApplication
())
delete
fKinematic
;
65
66
delete
fMessenger
;
67
}
68
69
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70
71
G4Run
*
RunAction::GenerateRun
()
72
{
73
fRun
=
new
Run
(
fDetector
,
fKinematic
);
74
return
fRun
;
75
}
76
77
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78
79
void
RunAction::BeginOfRunAction
(
const
G4Run
* aRun)
80
{
81
// Dump production cuts
82
G4ProductionCutsTable::GetProductionCutsTable
()->
DumpCouples
();
83
84
G4cout
<<
"### Run "
<< aRun->
GetRunID
() <<
" start."
<<
G4endl
;
85
//histograms
86
//
87
Book
();
88
}
89
90
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91
92
void
RunAction::EndOfRunAction
(
const
G4Run
*)
93
{
94
// print Run summary
95
//
96
if
(
isMaster
)
fRun
->
EndOfRun
(
fBinLength
);
97
98
// save histograms
99
G4AnalysisManager
* analysisManager =
G4AnalysisManager::Instance
();
100
if
( analysisManager->
IsActive
() ) {
101
analysisManager->
Write
();
102
analysisManager->
CloseFile
();
103
}
104
}
105
106
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
107
108
void
RunAction::SetBinSize
(
G4double
size)
109
{
110
fBinLength
= size;
111
if
(
fBinLength
>
fDetector
->
GetMaxStepSize
()) {
112
fBinLength
=
fDetector
->
GetMaxStepSize
();
113
}
114
}
115
116
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117
118
void
RunAction::Book
()
119
{
120
G4AnalysisManager
* analysisManager =
G4AnalysisManager::Instance
();
121
analysisManager->
SetFirstHistoId
(1);
122
123
G4double
length
=
fDetector
->
GetAbsorSizeX
();
124
G4int
nbBins =
G4lrint
(length /
fBinLength
);
125
126
// Create histograms
127
analysisManager->
CreateH1
(
"h1"
,
"Edep (MeV/mm) along absorber (mm)"
,
128
nbBins, 0, length);
129
analysisManager->
CreateH1
(
"h2"
,
"Total DEDX (MeV/mm) of proton"
,100,-3.,7.);
130
analysisManager->
CreateH1
(
"h3"
,
"Total DEDX (MeV/mm) of monopole"
,100,-3., 7.);
131
analysisManager->
CreateH1
(
"h4"
,
"Range(mm) of proton"
, 100, -3., 7.,
"mm"
);
132
analysisManager->
CreateH1
(
"h5"
,
"Range(mm) of monopole"
, 100, -3., 7.,
"mm"
);
133
analysisManager->
CreateH1
(
"h6"
,
"Restricted DEDX (MeV/mm) of proton"
,
134
100,-3.,7.);
135
analysisManager->
CreateH1
(
"h7"
,
"Restricted DEDX (MeV/mm) of monopole"
,
136
100,-3., 7.);
137
analysisManager->
CreateH1
(
"h8"
,
"Delta-electron x-section (1/mm) of proton"
,
138
100, -3., 7.,
"mm"
);
139
analysisManager->
CreateH1
(
"h9"
,
"Delta-electron x-section (1/mm) of monopole"
,
140
100, -3., 7.,
"mm"
);
141
analysisManager->
OpenFile
();
142
}
143
144
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
exoticphysics
monopole
src
RunAction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:52
using
1.8.2 with
ECCE GitHub integration