BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
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
12 : fEvHead(NULL)
13 , fNEvents(0)
14 , fIEvent(0)
15 , fRunId(0)
16{}
17
19 : fEvHead(NULL)
20 , fNEvents(n)
21 , fIEvent(0)
22 , fRunId(0)
23{}
24
26
27InitStatus 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
45{
46
47 fRunId = (fEvHead) ? fEvHead->GetRunId() : 0;
48
49 printf(ANSI_COLOR_BLUE "RUN-" ANSI_COLOR_RESET);
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
73{
74 printf("\n");
75}
int i
Definition P4_F32vec4.h:22
int Int_t
float Float_t
long long Long64_t
const char Option_t
void Fatal(const char *location, const char *msgfmt,...)
#define ANSI_COLOR_RED
Definition BmnMath.h:16
#define ANSI_COLOR_RESET
Definition BmnMath.h:18
#define ANSI_COLOR_BLUE
Definition BmnMath.h:17
BmnEventHeader * fEvHead
virtual void Finish()
virtual ~BmnCounter()
Long64_t fIEvent
virtual InitStatus Init()
virtual void Exec(Option_t *opt)
Long64_t fNEvents
*brief user defined string literal for JSON values *sa std::size_t n
Definition json.hpp:20362