14void show_run_stats(
int period = 8,
int start_run = 6587,
int end_run = -1,
bool show_only_wrong =
false)
22 const string red(
"\033[0;91m"), orange(
"\033[0;33m"), cyan(
"\033[0;96m"), reset(
"\033[0m");
27 xaxis_run_duration->
SetTitle(
"Run Duration, min");
29 TH1D* hist_stream_ev =
new TH1D(
"hist_stream_ev",
TString::Format(
"Event count per second for Period %d", period),
32 xaxis_stream_ev->
SetTitle(
"Event stream, event/sec");
34 int correct_run_count = 0;
35 int64_t sum_run_sec = 0, sum_event_count = 0;
36 map<int, int> wrong_time;
37 for (
int i = 0;
i < run_count;
i++) {
40 if (pRun ==
nullptr) {
41 cout <<
"The function encountered with errors: no experimental run was found ("
47 bool is_run_wrong =
false;
51 if (run_end_time ==
nullptr) {
52 cout <<
"The function encountered with errors: end time of the run was not defined for "
57 UInt_t run_duration_sec = 0, end_seconds = (*run_end_time).Convert(), start_seconds = run_start_time.
Convert();
58 if (end_seconds < start_seconds) {
60 run_duration_sec = start_seconds - end_seconds;
61 wrong_time.insert(pair<int, int>(run_numbers[
i].
run_number, -1 * run_duration_sec));
63 run_duration_sec = end_seconds - start_seconds;
67 if (p_event_count ==
nullptr) {
68 cout <<
"The function encountered with errors: event count was not defined for "
72 int event_count = *p_event_count;
74 double events_per_second = event_count / (double)run_duration_sec;
79 wrong_time.insert(pair<int, int>(run_numbers[
i].
run_number, run_duration_sec));
81 sum_run_sec += run_duration_sec;
82 sum_event_count += event_count;
88 if (!(show_only_wrong && !is_run_wrong)) {
90 cout <<
"Duration: " << run_duration_sec <<
" sec" << endl;
91 cout <<
"Events/second: " << events_per_second << endl << endl;
96 hist_run_duration->
Fill(run_duration_sec / 60.0);
97 hist_stream_ev->
Fill(events_per_second);
100 double average_run_duration = sum_run_sec / (double)correct_run_count;
101 double average_event_stream = sum_event_count / (double)sum_run_sec;
102 cout << cyan <<
"-------------------------------------------------------" << endl;
103 cout <<
"Average run duration for period " << period <<
": " <<
round(average_run_duration) <<
" sec ("
104 <<
TString::Format(
"%.2f", average_run_duration / 60) <<
" min)" << endl;
105 cout <<
"Average event stream for period " << period <<
": " <<
round(average_event_stream) <<
" event/sec" << endl;
106 cout <<
"-------------------------------------------------------" << endl << reset;
108 if (wrong_time.size() > 0) {
109 cout << endl <<
"Wrong run duration:" << endl;
110 for (
auto it = wrong_time.begin(); it != wrong_time.end(); ++it)
111 cout <<
"Run " << period <<
"-" << (*it).first <<
": " << (*it).second <<
" seconds" << endl;
113 cout <<
"Total wrong run duration: " << wrong_time.size() << endl;
120 TCanvas* canvas_run =
new TCanvas(
"canvas_run",
"canvas_run", 1200, 640);
123 hist_run_duration->
Draw();
125 hist_stream_ev->
Draw();
127 TCanvas* canvas_run_diff =
new TCanvas(
"canvas_run_diff",
"canvas_run_diff");
128 TH1D* hist_run_diff =
129 new TH1D(
"hist_run_diff",
TString::Format(
"Run time gap for Period %d", period), 1000, 0, 3 * 3600);
131 xaxis_run_diff->
SetTitle(
"Run Time Gaps, sec");
133 canvas_run_diff->
cd();
134 hist_run_diff->
Draw();
136 cout <<
"Macro finished successfully" << endl;
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
static int GetRunNumbers(UniqueRunNumber *&run_numbers, int start_period, int start_run=0, int end_period=-1, int end_run=-1)
get numbers of runs stored in the Database for a selected range
void show_run_stats(int period=8, int start_run=6587, int end_run=-1, bool show_only_wrong=false)
Function for creating statistics histograms on run duration and average stream (event/sec) for runs s...