EIC Software
Reference for
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
EicRunSim.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file EicRunSim.h
1
//
2
// AYK (ayk@bnl.gov), 2014/08/22
3
//
4
// A trivial (for now) extension of FairRunSim class;
5
//
6
7
#include <TVector3.h>
8
9
#include <
FairRunSim.h
>
10
#include <
FairModule.h
>
11
#include <
FairGenerator.h
>
12
#include <
FairField.h
>
13
14
#include <
PndMultiField.h
>
15
16
#include <
EicDetector.h
>
17
18
#ifndef _EIC_RUN_SIM_
19
#define _EIC_RUN_SIM_
20
21
#define _SEED_DEFAULT_ 0x12345678
22
23
#define _GPHYSI_DAT_ "gphysi.dat"
24
25
class
FluxMonitorParticleType
:
public
TObject
26
{
27
friend
class
FluxMonitorGrid
;
28
29
public
:
30
FluxMonitorParticleType
() {
ResetVars
(); };
31
FluxMonitorParticleType
(
int
pdg
,
double
eMin = 0.0,
double
eMax = 0.0):
32
mPDG
(pdg),
mEmin
(eMin),
mEmax
(eMax) {};
33
~FluxMonitorParticleType
() {};
34
35
private
:
36
Int_t
mPDG
;
// particle type
37
Double_t
mEmin
;
// min kin.energy
38
Double_t
mEmax
;
// max kin.energy
39
40
// Transient track length, density*length and dE/dx arrays;
41
Double_t *
mLength
;
42
Double_t *
mDensityLength
;
43
Double_t *
mEdep
;
44
45
void
ResetVars
() {
46
mPDG
= 0;
47
mEmin
=
mEmax
= 0.0;
48
49
mLength
=
mDensityLength
=
mEdep
= 0;
50
};
51
52
ClassDef(
FluxMonitorParticleType
, 1)
53
};
54
55
class
FluxMonitorGrid
:
public
TObject
56
{
57
public
:
58
FluxMonitorGrid
() {
ResetVars
(); };
59
FluxMonitorGrid
(
double
rMax,
unsigned
rDim,
double
zMin,
double
zMax,
unsigned
zDim);
60
~FluxMonitorGrid
() {};
61
62
int
AddFluxMonitorParticleType
(
int
pdg
,
double
eMin = 0.0,
double
eMax = 0.0);
63
void
AddEntry
(
int
pdg
,
double
eKin,
double
dE, TVector3
in
, TVector3 out);
64
65
void
FillOutHistograms
(
unsigned
evStat);
66
67
void
SetRadiationMapType
(
bool
what =
true
) {
mRadiationMapType
= what; };
68
// NB: use this call only if you really understand what you are doing; otherwise
69
// consider to use input .root file with MC events, which was properly put together
70
// via eic-smear BuildTree() call (so ASCII event generator file and a matching log
71
// file were used); in the latter case normalization is properly extracted from
72
// this .root file; limitations apply, see comments in FluxMonitorGrid::FillOutHistograms()
73
// source code;
74
void
SetNormalization
(
double
xsec,
unsigned
trials
/*, unsigned all_events*/
) {
75
mNormalizedCrossSection
= xsec;
76
mTrials
=
mTotalOriginalStat
= trials;
77
//mTotalOriginalStat = all_events;
78
}
79
80
private
:
81
void
ResetVars
() {
82
mRdim
=
mZdim
=
mTrials
=
mTotalOriginalStat
= 0;
83
mRmax
=
mZmin
=
mZmax
=
mZbwidth
=
mRbwidth
=
mNormalizedCrossSection
= 0.0;
84
85
mRadiationMapType
=
false
;
86
//mDensity = 0;
87
};
88
89
// Assume {RZ}-grid symmetric wrt the beam axis is fine;
90
Double_t
mRmax
;
// grid max radius
91
Double_t
mZmin
;
// grid min Z along the beam line
92
Double_t
mZmax
;
// grid max Z along the beam line
93
UInt_t
mRdim
;
// grid granularity in radius
94
UInt_t
mZdim
;
// grid granularity in Z
95
96
Double_t
mRbwidth
;
// bin width in R direction
97
Double_t
mZbwidth
;
// bin width in Z direction
98
99
// For neutrons want Fisyak-like variable; for radiation map just dE/dx losses map;
100
Bool_t
mRadiationMapType
;
// crossing flux (if false) or dE/dx rad.map
101
102
// Normalized cross-section in [microbarn], total number of trials in the MC file
103
// and total number of events in the original generator file;
104
Double_t
mNormalizedCrossSection
;
105
UInt_t
mTrials
;
106
UInt_t
mTotalOriginalStat
;
107
108
// Transient RxZ grid cell material density array; FIXME: implementation is
109
// clearly suboptimal
110
//Double_t *mDensity; //!
111
112
// NB: energy ranges can overlap; this why in particular do not see a good
113
// reason to use more tricky type than std::vector here;
114
std::vector<FluxMonitorParticleType>
mParticles
;
// particle types and energy range
115
116
ClassDef(
FluxMonitorGrid
, 3)
117
};
118
119
class
EicRunSim
:
public
FairRunSim
120
{
121
public
:
122
EicRunSim
(
const
char
*
engine
= 0);
123
~EicRunSim
() {};
124
125
enum
InitializationState
{
stUndefined
,
stFailed
,
stSucceeded
};
126
127
// Singelton instance get method;
128
static
EicRunSim
*
Instance
() {
return
mInstance
; };
129
130
// Prefer to match AddModule() name (even that this works for EicDetector only);
131
EicDetector
*
GetModule
(
const
char
*detName)
const
{
132
return
dynamic_cast<
EicDetector
*
>
(
ListOfModules
->FindObject(detName));
133
};
134
135
//
136
// There is a number of places in FairRoot where it deals with secondaries:
137
//
138
// - PndStack::StoreSecondaries() in either g3Config.C or g4Config.C;
139
// - /mcTracking/saveSecondaries in g4config.in;
140
// - FairTrajFilter::SetStoreSecondaries() in simulation.C;
141
//
142
// Unless I'm blind, all this have to do with *output* only (namely what should
143
// be saved in simulation.root file); somehow the functionality to suppress
144
// secondaries completely (a la GEANT3 GSKING() call) is missing;
145
//
146
// NB: the functionality implemented in EicRunSim here is not clean; secondaries
147
// will not be killed at their production vertex, but only once they enter any
148
// of the detector sensitive volumes; which is fine, since they will not produce
149
// any hits then (which was the primary purpose of this excercise); will still affect
150
// the performance due to the interaction with dead material volumes;
151
//
152
void
SuppressSecondaries
() {
mSuppressSecondariesFlag
=
true
; };
153
bool
SuppressSecondariesFlag
()
const
{
return
mSuppressSecondariesFlag
; };
154
155
void
IgnoreBlackHoleVolumes
() {
mIgnoreBlackHoleVolumes
=
true
; };
156
bool
IgnoreBlackHoleVolumesFlag
()
const
{
return
mIgnoreBlackHoleVolumes
; };
157
158
int
DefineFluxMonitorGrid
(
double
rMax,
unsigned
rDim,
double
zMin,
double
zMax,
unsigned
zDim);
159
int
AddFluxMonitorParticleType
(
int
pdg
,
double
eMin = 0.0,
double
eMax = 0.0);
160
FluxMonitorGrid
*
GetFluxMonitorGrid
() {
return
mFluxMonitorGrid
; };
161
162
// Do not mind to use the same FairRunSim method names and make then virtual
163
// in the base class;
164
void
SetMaterials
(
const
char
*mediaFileName);
165
void
SetOutputFile
(
const
char
*outputFileName);
166
void
AddModule
(
FairModule
*module);
167
168
// For completeness; actually sometimes need to define a bigger cave;
169
void
SetCaveFileName
(
const
char
*caveFileName);
170
171
void
Init
();
172
void
Run
(Int_t NEvents = 0, Int_t NotUsed = 0);
173
void
RunCoreStart
(Int_t NEvents = 0, Int_t NotUsed = 0);
174
bool
JanaLoopPossible
(
void
)
const
{
return
false
; }
175
176
void
SetSeed
(
unsigned
seed) {
mSeed
= seed; };
177
void
SuppressTimerInfo
() {
mTimerFlag
=
false
; };
178
179
void
SuppressHitProduction
() {
mSuppressHitProductionFlag
=
true
; };
180
bool
SuppressHitProductionFlag
()
const
{
return
mSuppressHitProductionFlag
; };
181
182
void
SuppressFairRootSteppingCall
() {
mSuppressFairRootSteppingCallFlag
=
true
; };
183
bool
SuppressFairRootSteppingCallFlag
()
const
{
return
mSuppressFairRootSteppingCallFlag
; };
184
185
// Just to avoid FairPrimaryGenerator-related black magic in simulation.C script;
186
void
AddGenerator
(
FairGenerator
*
generator
);
187
188
// Also avoid field-definition-related black magic in simulation.C script;
189
// typically need just PndMultiField which can happily be a default option
190
// hidden inside this AddField() call; of course old scheme with calling
191
// "new PndMultiField();" by hand is available as well; low Q^2 tagger and Co
192
// (which need more sofisticated field composition) can still invoke EicMagneticField;
193
void
AddField
(FairField *field);
194
195
private
:
196
// THINK: can probably live with dynamic cast to respective FairRunSim method?;
197
static
EicRunSim
*
mInstance
;
198
199
// FairRun::Init() conveniently does not return any value; arrange a work-around;
200
InitializationState
mInitState
;
// EicRunSim::Init() call state
201
202
// NB: having default here is not necessarily a good idea; so for now do not
203
// have this mechanism in EicRunAna class; THINK later;
204
TString
mOutputFileName
;
// output file name; default: simulation.root
205
206
TString
mMediaFileName
;
// media file name; default: media.geo
207
TString
mCaveFileName
;
// file name with cave description; default: cave.geo
208
209
UInt_t
mSeed
;
// random seed; default: 0x12345678
210
211
// AddModule() checks for this flag and defines cave if not yet done
212
Bool_t
mCaveDefinedFlag
;
213
Bool_t
mSuppressSecondariesFlag
;
// try best to suppress secondaries; off by default
214
Bool_t
mTimerFlag
;
// either printout or not timer info; default: true
215
216
// It looks like I do not need more than one grid?; otherwise change
217
// later to a vector or something like this;
218
FluxMonitorGrid
*
mFluxMonitorGrid
;
// flux monitor grid parameters
219
220
Bool_t
mIgnoreBlackHoleVolumes
;
// may want to ignore those (say for neutron flux calculations)
221
222
Bool_t
mSuppressHitProductionFlag
;
// may want to skip all the EicDetector::ProcessHits() calls ...
223
Bool_t
mSuppressFairRootSteppingCallFlag
;
// ... or FairMCApplication::Stepping() alltogether
224
225
// Help simplify field definition calls -> need this transient variable;
226
PndMultiField
*
mField
;
227
228
ClassDef(
EicRunSim
, 5)
229
};
230
231
class
EicFluxMonitorTask
:
public
FairTask
{
232
public
:
233
EicFluxMonitorTask
():
mStat
(0) {};
234
~EicFluxMonitorTask
() {};
235
236
// The only two methods I need here;
237
void
FinishEvent
() {
mStat
++;
FairTask::FinishEvent
(); };
238
void
FinishTask
();
239
240
private
:
241
// Well, do not mind to maintain local event counter;
242
UInt_t
mStat
;
243
244
ClassDef
(
EicFluxMonitorTask
,2);
245
};
246
247
#endif
EicRoot
blob
master
eic
base
EicRunSim.h
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:34
using
1.8.2 with
EIC GitHub integration