17void show_raw_stats(
int period = 8,
int start_run = 6587,
int end_run = -1,
bool show_only_wrong =
false)
25 const string red(
"\033[0;91m"), orange(
"\033[0;33m"), cyan(
"\033[0;96m"), reset(
"\033[0m");
30 xaxis_file_size->
SetTitle(
"Raw File Size, GB");
32 TH1D* hist_file_duration =
36 xaxis_file_duration->
SetTitle(
"Raw File Duration, sec");
41 xaxis_event_size->
SetTitle(
"Event Sizes, KB");
43 TH1D* hist_stream_ev =
44 new TH1D(
"hist_avg_stream_ev",
TString::Format(
"Event count per second for Period %d", period), 500,
47 xaxis_stream_ev->
SetTitle(
"Event stream, event/sec");
49 TH1D* hist_stream_mb =
new TH1D(
"hist_avg_stream_mb",
TString::Format(
"Megabytes per second for Period %d", period),
52 xaxis_stream_mb->
SetTitle(
"Binary stream, MB/sec");
54 int correct_file_count = 0;
55 int64_t sum_file_sec = 0, sum_event_count = 0;
56 double sum_file_size_mb = 0, sum_event_size_kb = 0;
57 map<TString, double> wrong_files;
58 map<TString, double> wrong_events;
59 map<TString, int> wrong_time;
61 for (
int i = 0;
i < run_count;
i++) {
64 if (pRun ==
nullptr) {
65 cout <<
"The function encountered with errors: no experimental run was found ("
74 if (raw_files ==
nullptr)
78 bool is_run_wrong =
false;
79 double sum_run_size_mb = 0;
80 for (
const auto& j : *raw_files) {
81 int is_file_wrong = 0;
87 UInt_t file_duration_sec = 0, end_seconds = file_end_time.
Convert(),
88 start_seconds = file_start_time.
Convert();
89 if (end_seconds < start_seconds) {
90 is_file_wrong = 1, is_run_wrong =
true;
91 file_duration_sec = start_seconds - end_seconds;
92 wrong_time.insert(pair<TString, int>(pRawFile->
GetFilePath(), -1 * file_duration_sec));
94 file_duration_sec = end_seconds - start_seconds;
97 double file_size_mb = file_size_byte / 1024.0 / 1024.0;
98 double file_size_gb = file_size_mb / 1024.0;
100 double event_size_kb = file_size_byte / 1024.0 / event_count;
102 is_file_wrong = 1, is_run_wrong =
true;
103 wrong_files.insert(pair<TString, double>(pRawFile->
GetFilePath(), file_size_mb));
106 double events_per_second = event_count / (double)file_duration_sec;
107 double mb_per_second = file_size_mb / (double)file_duration_sec;
111 is_file_wrong = 2, is_run_wrong =
true;
112 wrong_files.insert(pair<TString, double>(pRawFile->
GetFilePath(), file_size_mb));
117 is_file_wrong = 2, is_run_wrong =
true;
118 wrong_time.insert(pair<TString, double>(pRawFile->
GetFilePath(), file_duration_sec));
123 is_file_wrong = 2, is_run_wrong =
true;
124 wrong_events.insert(pair<TString, double>(pRawFile->
GetFilePath(), event_size_kb));
126 sum_run_size_mb += file_size_mb;
127 sum_file_size_mb += file_size_mb;
128 sum_file_sec += file_duration_sec;
129 sum_event_size_kb += event_size_kb;
130 sum_event_count += event_count;
131 correct_file_count++;
134 if (is_file_wrong == 1)
136 else if (is_file_wrong == 2)
138 if (!(show_only_wrong && (is_file_wrong == 0))) {
139 cout <<
"Current file '" << pRawFile->
GetFilePath() <<
"':" << endl;
140 cout <<
"File size: " << file_size_gb <<
" GB (event size = " << event_size_kb <<
" KB)" << endl;
141 cout <<
"Duration: " << file_duration_sec <<
" sec" << endl;
142 cout <<
"Events/second: " << events_per_second <<
" (" << mb_per_second <<
" MB/s)" << endl << endl;
144 if (is_file_wrong > 0)
147 hist_file_size->
Fill(file_size_gb);
148 hist_file_duration->
Fill(file_duration_sec);
149 hist_event_size->
Fill(event_size_kb);
150 hist_stream_ev->
Fill(events_per_second);
151 hist_stream_mb->
Fill(mb_per_second);
153 if (!(show_only_wrong && !is_run_wrong))
155 << sum_run_size_mb <<
" MB" << endl
159 double average_file_size = sum_file_size_mb / correct_file_count;
160 double average_file_duration = sum_file_sec / (double)correct_file_count;
161 double average_event_size = sum_event_size_kb / correct_file_count;
162 double average_event_stream = sum_event_count / (double)sum_file_sec;
163 double average_mb_stream = sum_file_size_mb / sum_file_sec;
164 cout << cyan <<
"-------------------------------------------------------" << endl;
165 cout <<
"Average file size for period " << period <<
": " <<
round(average_file_size) <<
" MB" << endl;
166 cout <<
"Average file duration for period " << period <<
": " <<
round(average_file_duration) <<
" sec" << endl;
167 cout <<
"Average event size for period " << period <<
": " <<
round(average_event_size) <<
" KB" << endl;
168 cout <<
"Average event stream for period " << period <<
": " <<
round(average_event_stream) <<
" event/sec" << endl;
169 cout <<
"Average binary stream for period " << period <<
": " <<
round(average_mb_stream) <<
" MB/sec" << endl;
170 cout <<
"-------------------------------------------------------" << endl << reset;
172 if (wrong_files.size() > 0) {
175 for (
auto it = wrong_files.begin(); it != wrong_files.end(); ++it)
176 cout <<
"File '" << (*it).first <<
"': " << (*it).second <<
" MB" << endl;
178 cout <<
"Total wrong file size: " << wrong_files.size() << endl;
182 if (wrong_events.size() > 0) {
185 for (
auto it = wrong_events.begin(); it != wrong_events.end(); ++it)
186 cout <<
"File '" << (*it).first <<
": " << (*it).second <<
" KB" << endl;
188 cout <<
"Total wrong event size: " << wrong_events.size() << endl;
192 if (wrong_time.size() > 0) {
195 <<
" minutes):" << endl;
196 for (
auto it = wrong_time.begin(); it != wrong_time.end(); ++it)
197 cout <<
"File '" << (*it).first <<
": " << (*it).second <<
" seconds" << endl;
199 cout <<
"Total wrong file duration: " << wrong_time.size() << endl;
206 TCanvas* canvas_size =
new TCanvas(
"canvas_size",
"canvas_size", 1200, 640);
207 canvas_size->
Divide(2, 1);
209 hist_file_size->
Draw();
211 hist_event_size->
Draw();
212 TCanvas* canvas_file_duration =
new TCanvas(
"canvas_file_duration",
"canvas_file_duration");
213 canvas_file_duration->
cd();
214 hist_file_duration->
Draw();
215 TCanvas* canvas_stream =
new TCanvas(
"canvas_stream",
"canvas_stream", 1200, 640);
216 canvas_stream->
Divide(2, 1);
217 canvas_stream->
cd(1);
218 hist_stream_ev->
Draw();
219 canvas_stream->
cd(2);
220 hist_stream_mb->
Draw();
222 cout <<
"Macro finished successfully" << endl;