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
EicRunAna.cxx
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file EicRunAna.cxx
1
//
2
// AYK (ayk@bnl.gov), 2015/07/15
3
//
4
// A trivial (for now) extension of FairRunAna class;
5
//
6
7
#include <TRandom.h>
8
9
#include <
FairRuntimeDb.h
>
10
#include <
FairParRootFileIo.h
>
11
12
#include <
FairEventHeader.h
>
13
#include <
FairMCEventHeader.h
>
14
#include <
FairTrajFilter.h
>
15
16
#include <
EicRunAna.h
>
17
18
EicRunAna
*
EicRunAna::mInstance
= 0;
19
20
// ---------------------------------------------------------------------------------------
21
22
EicRunAna::EicRunAna
(): mSeed(
_SEED_DEFAULT_
), mInitCallHappened(
false
), mEvStart(0), mEvEnd(0)
23
//, mEvCurrent(-1)
24
{
25
if
(
mInstance
) {
26
Fatal(
"EicRunAna::EicRunAna()"
,
"Singleton instance already exists."
);
27
return
;
28
}
//if
29
30
mInstance
=
this
;
31
}
// EicRunAna::EicRunAna()
32
33
// ---------------------------------------------------------------------------------------
34
35
void
EicRunAna::SetInputFile
(TString fname)
36
{
37
mInputFileName
= fname;
38
39
FairRunAna::SetInputFile
(fname);
40
}
// EicRunAna::SetInputFile()
41
42
// ---------------------------------------------------------------------------------------
43
44
void
EicRunAna::Init
()
45
{
46
FairRuntimeDb
* rtdb =
GetRuntimeDb
();
47
FairParRootFileIo
* parInput1 =
new
FairParRootFileIo
();
48
parInput1->
open
(
mInputFileName
);
49
50
rtdb->
setFirstInput
(parInput1);
51
52
FairRunAna::Init
();
53
54
mInitCallHappened
=
true
;
55
}
// EicRunAna::Init()
56
57
// ---------------------------------------------------------------------------------------
58
59
void
EicRunAna::Run
(Int_t NStart, Int_t NStop)
60
{
61
// This is indeed a clear hack;
62
if
(
mJanaPluginMode
)
return
;
63
64
//gRandom->SetSeed(mSeed);
65
66
// Well, may want to use either {Init(), then Run()} or just {Run()}; avoid
67
// calling Init() twice;
68
//if (!mInitCallHappened) Init();
69
70
//FairRunAna::Run(NStart, NStop);
71
RunCoreStart
(NStart, NStop);
72
while
(
RunCoreImportNextEvent
())
RunCoreProcessNextEvent
();
73
RunCoreFinish
();
74
75
// Yes, and get rid of this file as well;
76
//if (!access(_GPHYSI_DAT_, W_OK)) unlink(_GPHYSI_DAT_);
77
78
// Yes, just exit; change the default behaviour if this ever becomes a problem;
79
// NB: can reach this point in a "standalone" mode only (not as a plugin);
80
// so terminate and exit ROOT session, for user convenience;
81
exit
(0);
82
}
// EicRunAna::Run()
83
84
// ---------------------------------------------------------------------------------------
85
86
void
EicRunAna::RunCoreStart
(Int_t Ev_start, Int_t Ev_end)
87
{
88
gRandom->SetSeed(
mSeed
);
89
90
// Well, may want to use either {Init(), then Run()} or just {Run()}; avoid
91
// calling Init() twice;
92
if
(!
mInitCallHappened
)
Init
();
93
94
assert(!
fProofAnalysis
&& !
fTimeStamps
&& !
fMixedInput
&&
fInFileIsOpen
);
95
96
//if ( fProofAnalysis ) {
97
//RunOnProof(Ev_start,Ev_end);
98
//return;
99
//}
100
101
//if (fTimeStamps) {
102
//RunTSBuffers();
103
//} else if (fMixedInput) {
104
//RunMixed(Ev_start,Ev_end);
105
//} else {
106
{
107
//UInt_t tmpId =0;
108
// if (fInputFile==0) {
109
//if (!fInFileIsOpen) {
110
//DummyRun(Ev_start,Ev_end);
111
//return;
112
//}
113
if
(Ev_end==0) {
114
if
(Ev_start==0) {
115
Ev_end=Int_t((
fRootManager
->
GetInChain
())->GetEntries());
116
}
else
{
117
Ev_end = Ev_start;
118
if
( Ev_end > ((
fRootManager
->
GetInChain
())->GetEntries()) ) {
119
Ev_end = (Int_t) (
fRootManager
->
GetInChain
())->GetEntries();
120
}
121
Ev_start=0;
122
}
123
}
else
{
124
Int_t fileEnd=(
fRootManager
->
GetInChain
())->GetEntries();
125
if
(Ev_end > fileEnd) {
126
//cout << "-------------------Warning---------------------------" << endl;
127
//cout << " -W FairRunAna : File has less events than requested!!" << endl;
128
//cout << " File contains : " << fileEnd << " Events" << endl;
129
//cout << " Requested number of events = " << Ev_end << " Events"<< endl;
130
//cout << " The number of events is set to " << fileEnd << " Events"<< endl;
131
//cout << "-----------------------------------------------------" << endl;
132
Ev_end = fileEnd;
133
}
134
}
135
136
// Assign class instance variables;
137
mEvStart
= Ev_start;
mEvEnd
= Ev_end;
mEvCurrent
=
mEvStart
-1;
138
139
fRunInfo
.
Reset
();
140
}
141
}
// EicRunAna::RunCoreStart()
142
143
bool
EicRunAna::RunCoreImportNextEvent
(
void
)
144
{
145
if
(++
mEvCurrent
==
mEvEnd
)
return
false
;
146
147
//for (int i=mEvStart; i< mEvEnd; i++) {
148
fRootManager
->
ReadEvent
(
mEvCurrent
);
149
return
true
;
150
}
// EicRunAna::RunCoreImportNextEvent()
151
152
void
EicRunAna::RunCoreProcessNextEvent
(
void
)
153
{
154
{
155
UInt_t tmpId =0;
156
161
if
(
fRootManager
->
IsEvtHeaderNew
()) {
162
tmpId =
fMCHeader
->
GetRunID
();
163
}
else
{
164
tmpId =
fEvtHeader
->
GetRunId
();
165
}
166
if
( tmpId !=
fRunId
) {
167
fRunId
= tmpId;
168
if
( !
fStatic
) {
169
Reinit
(
fRunId
);
170
fTask
->
ReInitTask
();
171
}
172
}
173
//FairMCEventHeader* header = (FairMCEventHeader*)fRootManager->GetObject("MCEventHeader.");
174
//std::cout << "WriteoutBufferData with time: " << fRootManager->GetEventTime();
175
fRootManager
->
StoreWriteoutBufferData
(
fRootManager
->
GetEventTime
());
176
fTask
->ExecuteTask(
""
);
177
fRootManager
->
Fill
();
178
fRootManager
->
DeleteOldWriteoutBufferData
();
179
fTask
->
FinishEvent
();
180
181
fRunInfo
.
StoreInfo
();
182
if
(NULL !=
FairTrajFilter::Instance
()) {
183
FairTrajFilter::Instance
()->
Reset
();
184
}
185
//}
186
}
187
188
//mEvCurrent++;
189
//return true;
190
}
// EicRunAna::RunCoreProcessNextEvent()
191
192
void
EicRunAna::RunCoreFinish
(
void
)
193
{
194
{
195
fRootManager
->
StoreAllWriteoutBufferData
();
196
fTask
->
FinishTask
();
197
if
(
fWriteRunInfo
) {
198
fRunInfo
.
WriteInfo
();
199
}
200
fRootManager
->
LastFill
();
201
fRootManager
->
Write
();
202
}
203
204
// Yes, and get rid of this file as well;
205
if
(!access(
_GPHYSI_DAT_
, W_OK)) unlink(
_GPHYSI_DAT_
);
206
}
207
208
// ---------------------------------------------------------------------------------------
209
210
ClassImp
(
EicRunAna
)
EicRoot
blob
master
eic
base
EicRunAna.cxx
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:33
using
1.8.2 with
EIC GitHub integration