BmnRoot
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
27
28InitStatus BmnCounter::Init()
29{
30 FairRootManager* ioman = FairRootManager::Instance();
31 if (!ioman)
32 {
33 Fatal("Init", "FairRootManager is not instantiated");
34 return kERROR;
35 }
36 fEvHead = (BmnEventHeader*) ioman->GetObject("EventHeader");
37 if (!fEvHead)
38 cout << "WARNING! No EventHeader array!!!" << endl;
39
40 if (ioman->CheckMaxEventNo(fNEvents) < fNEvents)
41 fNEvents = ioman->CheckMaxEventNo(fNEvents);
42
43 return kSUCCESS;
44}
45
46void BmnCounter::Exec(Option_t* opt) {
47
48 fRunId = (fEvHead) ? fEvHead->GetRunId() : 0;
49
50 printf(ANSI_COLOR_BLUE "RUN-" ANSI_COLOR_RESET);
51 printf(ANSI_COLOR_RED "%d" ANSI_COLOR_RESET, fRunId);
52 printf(ANSI_COLOR_BLUE ": [");
53
54 Float_t progress = fIEvent * 1.0 / fNEvents;
55 Int_t barWidth = 70;
56
57 Int_t pos = barWidth * progress;
58 for (Int_t i = 0; i < barWidth; ++i) {
59 if (i < pos) printf("=");
60 else if (i == pos) printf(">");
61 else printf(" ");
62 }
63
64 printf("] " ANSI_COLOR_RESET);
65 printf(ANSI_COLOR_RED "%d%%\r" ANSI_COLOR_RESET, Int_t(progress * 100.0 + 0.5));
66 cout.flush();
67 fIEvent++;
68}
69
71 printf("\n");
72}
int i
Definition P4_F32vec4.h:22
#define ANSI_COLOR_RED
Definition BmnMath.h:16
#define ANSI_COLOR_RESET
Definition BmnMath.h:18
#define ANSI_COLOR_BLUE
Definition BmnMath.h:17
virtual void Finish()
virtual ~BmnCounter()
virtual InitStatus Init()
virtual void Exec(Option_t *opt)