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
EicEventGenerator.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file EicEventGenerator.h
1
//
2
// AYK (ayk@bnl.gov), 2013/06/12
3
//
4
// Interface to eic-smear import classes;
5
//
6
7
#include <assert.h>
8
9
#include <set>
10
11
#ifndef _EIC_EVENT_GENERATOR_
12
#define _EIC_EVENT_GENERATOR_
13
14
#include <TChain.h>
15
#include <TH1D.h>
16
17
#include "
FairGenerator.h
"
18
#include "
FairTask.h
"
19
20
#include "
eicsmear/erhic/EventFactory.h
"
21
#include "
eicsmear/erhic/Forester.h
"
22
23
// Of course want to use eic-smear code conventions on the tree/branch names;
24
#define _EIC_GENERATOR_TREE_ "EICTree"
25
#define _EIC_GENERATOR_EVENT_BRANCH_ "event"
26
27
// Basically describes which entries in the original ParticleMC array made
28
// it into the GEANT input table for tracking;
29
#define _EIC_MAPPING_BRANCH_ "ParticleMap"
30
31
class
FairPrimaryGenerator
;
32
class
TBranch;
33
34
class
ProMCBook;
35
36
namespace
EicMC {
37
class
Reader;
38
}
39
40
// erhic::EventMC has a pure virtual member -> have to create
41
// inherited class in order to instantiate it;
42
class
EventProMC
:
public
erhic::EventMC
43
{
44
public
:
45
EventProMC
() {};
46
~EventProMC
() {};
47
48
// FIXME: for now can not get these from the ProMC Pythia 8 pp-files;
49
const
erhic::ParticleMC
*
BeamLepton
()
const
{
return
0; };
50
const
erhic::ParticleMC
*
BeamHadron
()
const
{
return
0; };
51
const
erhic::ParticleMC
*
ExchangeBoson
()
const
{
return
0; };
52
const
erhic::ParticleMC
*
ScatteredLepton
()
const
{
return
0; };
53
54
// There is no parser either (but have to create implementation of this
55
// pure virtual member);
56
bool
Parse
(
const
std::string&) { assert(0);
return
false
; };
57
58
ClassDef
(
EventProMC
, 1);
59
};
60
61
// Same story; THINK: do I really need these complications for EicMC input?;
62
class
EventEicMC
:
public
erhic::EventMC
63
{
64
public
:
65
EventEicMC
() {};
66
~EventEicMC
() {};
67
68
// FIXME: add proper calls here, please;
69
const
erhic::ParticleMC
*
BeamLepton
()
const
{
return
0; };
70
const
erhic::ParticleMC
*
BeamHadron
()
const
{
return
0; };
71
const
erhic::ParticleMC
*
ExchangeBoson
()
const
{
return
0; };
72
const
erhic::ParticleMC
*
ScatteredLepton
()
const
{
return
0; };
73
74
// There is no parser either (but have to create implementation of this
75
// pure virtual member);
76
bool
Parse
(
const
std::string&) { assert(0);
return
false
; };
77
78
ClassDef
(
EventEicMC
, 1);
79
};
80
81
//
82
// Want to access protected variables in Forester class, but
83
// can not just use it as a base class in EicEventGenerator because
84
// of ambiguos inheritance of TObject; so create an intermediate
85
// class and be happy; actually the functionality matches the name;
86
//
87
class
Poacher
:
public
erhic::Forester
88
{
89
public
:
90
Poacher
() {
ResetProMC
();
ResetEicMC
(); };
91
Poacher
(
const
TString &fileName);
92
93
~Poacher
() {};
94
95
erhic::VirtualEvent
*
GetNextEvent
();
96
97
std::string
EventName
()
const
;
98
99
private
:
100
// Part related to ProMC input;
101
ProMCBook *
mProMCBook
;
102
double
mMomentumUnits
,
mLengthUnits
;
103
erhic::ParticleMC
*
mParticle
;
104
EventProMC
*
mEventProMC
;
105
106
// Part related to EicMC input;
107
EventEicMC
*
mEventEicMC
;
108
EicMC::Reader *
mReaderEicMC
;
109
110
void
ResetProMC
() {
111
mProMCBook
= 0;
112
mEventProMC
= 0;
113
mMomentumUnits
=
mLengthUnits
= 0.0;
114
};
115
void
ResetEicMC
() {
116
mReaderEicMC
= 0;
117
mEventEicMC
= 0;
118
};
119
120
ClassDef
(
Poacher
,3);
121
};
122
123
class
ParticleMappingTable
:
public
TObject
{
124
// Avoid the access complications;
125
friend
class
EicEventGenerator
;
126
127
public
:
128
ParticleMappingTable
() {};
129
~ParticleMappingTable
() {};
130
131
const
std::vector<unsigned> &
GetData
()
const
{
return
mData
; };
132
133
private
:
134
std::vector <unsigned>
mData
;
135
136
ClassDef
(
ParticleMappingTable
,4);
137
};
138
139
// FIXME: create a separate EicProtoGenerator.h file;
140
#include <
EicBoxGenerator.h
>
141
142
class
EicEventGenerator
:
public
EicProtoGenerator
143
{
144
friend
class
EicEventGeneratorTask
;
145
146
public
:
148
//EicEventGenerator(): FairGenerator() { ResetVars(); };
149
153
EicEventGenerator
(TString fileName =
""
);
154
156
virtual
~EicEventGenerator
() {};
157
158
// Singelton instance get method;
159
static
EicEventGenerator
*
Instance
() {
return
mInstance
; };
160
161
// Well, may want to use the same input file to be processed in chunks
162
// in a batch mode; FairRunSim class does not seem to provide functionality
163
// to skip events, so implement this feature here;
164
int
SkipFewEvents
(
unsigned
eventsToSkip);
165
void
RestrictEventChunkSize
(
unsigned
nEvents
) {
mEventChunkSize
=
nEvents
; };
166
167
// May want to select only few particle types; can call more than once
168
// (say enable only electrons and pi-minus tracks);
169
void
SelectPdgCode
(
int
pdg
) {
mSelectedPdgCodes
.insert(pdg); };
170
void
SelectLeadingParticle
(
double
pmin = 0.0) {
171
mSelectLeadingParticle
=
true
;
172
mSelectedLeadingParticlePmin
= pmin;
173
};
174
175
void
BuildEnergyFlowPlot
(
int
etaBinNum,
double
etaMin,
double
etaMax) {
176
mEnergyFlowHist
=
new
TH1D(
"EnergyFlowPlot"
,
"Energy Flow Plot"
, etaBinNum, etaMin, etaMax);
177
mEnergyFlowHist
->GetXaxis()->SetTitle(
"Pseudorapidity"
);
178
mEnergyFlowHist
->GetYaxis()->SetTitle(
"Energy flow per rapidity unit per event, [GeV]"
);
179
180
mParticleCountHist
=
new
TH1D(
"ParticleCountPlot"
,
"Particle Count Plot"
, etaBinNum, etaMin, etaMax);
181
mParticleCountHist
->GetXaxis()->SetTitle(
"Pseudorapidity"
);
182
mParticleCountHist
->GetYaxis()->SetTitle(
"Particle count per rapidity unit per event"
);
183
184
// FIXME: some sanity check needed here;
185
mEtaBinWidth
= (etaMax - etaMin)/etaBinNum;
186
};
187
void
AddEnergyFlowPdgCode
(
int
pdg
) {
mEnergyFlowPdgCodes
.insert(pdg); };
188
193
virtual
Bool_t
ReadEvent
(
FairPrimaryGenerator
* primGen);
194
195
const
TChain *
GetInputTree
()
const
{
return
mInputTree
; };
196
197
private
:
198
static
EicEventGenerator
*
mInstance
;
199
200
Poacher
*
mPoacher
;
201
TChain *
mInputTree
;
202
unsigned
mInputTreeNextEventId
;
203
erhic::VirtualEvent
*
mGeneratorEvent
;
204
205
// Do not want to rely on "vp->GetStatus() == 1" check when passing data
206
// over to the GEANT engine; just record the exact list of particles which
207
// will enter PndMCTrack array and import it back during the reconstruction;
208
ParticleMappingTable
*
mMappingTable
;
209
210
Bool_t
mSelectLeadingParticle
;
// may want to select leading particles only ...
211
Double_t
mSelectedLeadingParticlePmin
;
// ... and with a momentum cut-off
212
std::set<Int_t>
mSelectedPdgCodes
;
// if empty, all particles; otherwise selected only
213
214
// May want to carve a huge input file into several chunks to be processed by different
215
// batch jobs; SkipFewEvents() helps to arrange a jump, fine; however, since ReadEvent() may
216
// want to skip several events (because there are no particles left after SelectPdgCode()
217
// call(s)), one needs to restrict max event chunk to consider in order not to grab events
218
// from the "next chunk";
219
UInt_t
mEventChunkSize
;
// consider at most that number of event candidates
220
UInt_t
mEventCounter
;
// internal counter which helps to obey mEventChunkSize limit
221
222
double
mEtaBinWidth
;
223
TH1D *
mEnergyFlowHist
;
224
TH1D *
mParticleCountHist
;
225
std::set<Int_t>
mEnergyFlowPdgCodes
;
226
227
void
ResetVars
() {
228
mPoacher
= 0;
229
mGeneratorEvent
= 0;
230
mInputTree
= 0;
mInputTreeNextEventId
= 0;
mMappingTable
= 0;
231
232
mSelectLeadingParticle
=
false
;
mSelectedLeadingParticlePmin
= 0.0;
233
mEventChunkSize
=
mEventCounter
= 0;
234
235
mEtaBinWidth
= 0.0;
236
mEnergyFlowHist
=
mParticleCountHist
= 0;
237
};
238
239
ClassDef
(
EicEventGenerator
,22);
240
};
241
242
class
EicEventGeneratorTask
:
public
FairTask
{
243
public
:
244
EicEventGeneratorTask
(TTree* tree = 0):
mOutputTree
(tree) {};
245
~EicEventGeneratorTask
() {};
246
247
// The only method I need here;
248
void
FinishTask
();
249
250
private
:
251
TTree*
mOutputTree
;
252
253
ClassDef
(
EicEventGeneratorTask
,4);
254
};
255
256
#endif
EicRoot
blob
master
eic
event
EicEventGenerator.h
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:35
using
1.8.2 with
EIC GitHub integration