BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnCounterTask.cxx
Go to the documentation of this file.
1
#include "
BmnCounterTask.h
"
2
3
#include "FairRootManager.h"
4
5
#include <iostream>
6
7
#define ANSI_COLOR_RED "\x1b[91m"
8
#define ANSI_COLOR_BLUE "\x1b[94m"
9
#define ANSI_COLOR_RESET "\x1b[0m"
10
11
BmnCounter::BmnCounter
()
12
:
fEvHead
(NULL)
13
,
fNEvents
(0)
14
,
fIEvent
(0)
15
,
fRunId
(0)
16
{}
17
18
BmnCounter::BmnCounter
(
Long64_t
n
)
19
:
fEvHead
(NULL)
20
,
fNEvents
(
n
)
21
,
fIEvent
(0)
22
,
fRunId
(0)
23
{}
24
25
BmnCounter::~BmnCounter
() {}
26
27
InitStatus
BmnCounter::Init
()
28
{
29
FairRootManager* ioman = FairRootManager::Instance();
30
if
(!ioman) {
31
Fatal
(
"Init"
,
"FairRootManager is not instantiated"
);
32
return
kERROR;
33
}
34
fEvHead
= (
BmnEventHeader
*)ioman->GetObject(
"EventHeader"
);
35
if
(!
fEvHead
)
36
cout <<
"WARNING! No EventHeader array!!!"
<< endl;
37
38
if
(ioman->CheckMaxEventNo(
fNEvents
) <
fNEvents
)
39
fNEvents
= ioman->CheckMaxEventNo(
fNEvents
);
40
41
return
kSUCCESS;
42
}
43
44
void
BmnCounter::Exec
(
Option_t
* opt)
45
{
46
47
fRunId
= (
fEvHead
) ?
fEvHead
->GetRunId() : 0;
48
49
printf(
ANSI_COLOR_BLUE
"RUN-"
ANSI_COLOR_RESET
);
50
printf(
ANSI_COLOR_RED
"%d"
ANSI_COLOR_RESET
,
fRunId
);
51
printf(
ANSI_COLOR_BLUE
": ["
);
52
53
Float_t
progress =
fIEvent
* 1.0 /
fNEvents
;
54
Int_t
barWidth = 70;
55
56
Int_t
pos = barWidth * progress;
57
for
(
Int_t
i
= 0;
i
< barWidth; ++
i
) {
58
if
(
i
< pos)
59
printf(
"="
);
60
else
if
(
i
== pos)
61
printf(
">"
);
62
else
63
printf(
" "
);
64
}
65
66
printf(
"] "
ANSI_COLOR_RESET
);
67
printf(
ANSI_COLOR_RED
"%d%%\r"
ANSI_COLOR_RESET
,
Int_t
(progress * 100.0 + 0.5));
68
cout.flush();
69
fIEvent
++;
70
}
71
72
void
BmnCounter::Finish
()
73
{
74
printf(
"\n"
);
75
}
i
int i
Definition
P4_F32vec4.h:22
Int_t
int Int_t
Float_t
float Float_t
Long64_t
long long Long64_t
Option_t
const char Option_t
Fatal
void Fatal(const char *location, const char *msgfmt,...)
ANSI_COLOR_RED
#define ANSI_COLOR_RED
Definition
BmnMath.h:16
ANSI_COLOR_RESET
#define ANSI_COLOR_RESET
Definition
BmnMath.h:18
ANSI_COLOR_BLUE
#define ANSI_COLOR_BLUE
Definition
BmnMath.h:17
BmnCounter::BmnCounter
BmnCounter()
Definition
BmnCounterTask.cxx:11
BmnCounter::fEvHead
BmnEventHeader * fEvHead
Definition
BmnCounterTask.h:22
BmnCounter::Finish
virtual void Finish()
Definition
BmnCounterTask.cxx:72
BmnCounter::~BmnCounter
virtual ~BmnCounter()
Definition
BmnCounterTask.cxx:25
BmnCounter::fIEvent
Long64_t fIEvent
Definition
BmnCounterTask.h:24
BmnCounter::fRunId
Int_t fRunId
Definition
BmnCounterTask.h:25
BmnCounter::Init
virtual InitStatus Init()
Definition
BmnCounterTask.cxx:27
BmnCounter::Exec
virtual void Exec(Option_t *opt)
Definition
BmnCounterTask.cxx:44
BmnCounter::fNEvents
Long64_t fNEvents
Definition
BmnCounterTask.h:23
BmnEventHeader
Definition
BmnEventHeader.h:24
n
*brief user defined string literal for JSON values *sa std::size_t n
Definition
json.hpp:20362
BmnCounterTask.h
miscellaneous
BmnCounterTask.cxx
Generated on
for BmnRoot by
1.17.0