28 TString digi_path =
"/ncx/scratch1/ilnur/mini_release/",
29 TString txtfile_path =
"$VMCWORKDIR/database/uni_db/macros/parse_schemes/spill_run7/SRC_Data.txt",
30 TString scheme_path =
"$VMCWORKDIR/database/uni_db/macros/parse_schemes/spill_run7/spill_run7_src_full.xslt")
36 Int_t nPedestals = 100;
41 Int_t log_shift_src = -3;
42 map<TDatime, vector<Int_t>> spill_map;
43 map<Int_t, vector<Int_t>> run_map;
46 vector<structParseValue*> parse_values;
47 vector<structParseSchema> vecElements;
48 int res_code = parser.
ParseTxt2Struct(txtfile_path, scheme_path, parse_values, vecElements);
50 cout << endl <<
"Macro finished with errors: parser error (" << res_code <<
")" << endl;
54 if (parse_values.size() < 1) {
55 cout << endl <<
"Macro finished with errors: there are no lines to parse" << endl;
68 arrayConditions.
Add((
TObject*)searchCondition);
73 arrayConditions.
Add((
TObject*)searchCondition);
78 arrayConditions.
Add((
TObject*)searchCondition);
83 cout << endl <<
"Macro finished with errors: no runs exists for the given target: " << target << endl;
90 Int_t first_run_id = (
reinterpret_cast<UniRun*
>(pRunArray->
First()))->GetRunNumber();
91 Int_t last_run_id = (
reinterpret_cast<UniRun*
>(pRunArray->
Last()))->GetRunNumber();
92 printf(
"range %d - %d\n", first_run_id, last_run_id);
93 Int_t nbins = (last_run_id + 1 - first_run_id);
95 TH1* hBT =
new TH1I(
"hBT",
"BT", nbins, first_run_id, last_run_id + 1);
96 TH1* hBTnB =
new TH1I(
"hBTnB",
"BT & notBusy", nbins, first_run_id, last_run_id + 1);
97 TH1* hBTAc =
new TH1D(
"hBTAc",
"BT Accepted", nbins, first_run_id, last_run_id + 1);
104 hists.push_back(hBT);
105 hists.push_back(hBTnB);
106 hists.push_back(hBTAc);
108 TH1I* hBT_log =
new TH1I(
"hBT_log",
"BT", nbins, first_run_id, last_run_id + 1);
109 TH1* hBTnB_log =
new TH1I(
"hBTnB_log",
"BT & notBusy", nbins, first_run_id, last_run_id + 1);
110 TH1D* hBTAc_log =
new TH1D(
"hBTAc_log",
"BT Accepted", nbins, first_run_id, last_run_id + 1);
112 TH1* hBC1H_log =
new TH1I(
"hBC1H_log",
"BC1 High", nbins, first_run_id, last_run_id + 1);
113 TH1* hBC1BP_log =
new TH1I(
"hBC1BP_log",
"BC1 Before Protection", nbins, first_run_id, last_run_id + 1);
114 TH1* hBC1xBC2_log =
new TH1I(
"hBC1xBC2_log",
"BC1 * BC2", nbins, first_run_id, last_run_id + 1);
115 TH1* hBC1nBusy_log =
new TH1I(
"hBC1nBusy_log",
"BC1 * !Busy", nbins, first_run_id, last_run_id + 1);
116 TH1* hIT_log =
new TH1I(
"hIT_log",
"Interaction Trigger", nbins, first_run_id, last_run_id + 1);
117 TH1* hSRC_log =
new TH1I(
"hSRC_log",
"SRC Trigger", nbins, first_run_id, last_run_id + 1);
118 TH1* hTrignBusy_log =
new TH1I(
"hTrignBusy_log",
"Trigger * !Busy", nbins, first_run_id, last_run_id + 1);
119 vector<TH1*> hists_log;
123 hists_log.push_back(hBC1H_log);
127 hists_log.push_back(hIT_log);
128 hists_log.push_back(hSRC_log);
129 hists_log.push_back(hTrignBusy_log);
131 int sum_size = parse_values[0]->arrValues.size();
133 for (
int ind = 0; ind < parse_values.size(); ind++) {
136 for (
Int_t iValue = 0; iValue < sum_size; iValue++)
137 vals.push_back(boost::any_cast<Int_t>(st->
arrValues[iValue]));
142 vector<Long64_t> total_columns;
143 for (
int i_total = 0; i_total < sum_size; i_total++)
144 total_columns.push_back(0);
147 for (
int i = 0;
i < run_count;
i++) {
148 if (run_numbers != NULL)
150 if (pRunArray != NULL)
151 run = ((
UniRun*)pRunArray->
At(
i))->GetRunNumber();
157 <<
"Macro finished with errors: no experimental run was found " << period <<
" : " << run <<
" / "
158 << ((
UniRun*)pRunArray->
At(
i))->GetRunNumber() << endl;
159 if (run_numbers != NULL)
160 delete[] run_numbers;
161 if (pRunArray != NULL)
168 if (dateEnd == NULL) {
169 cout <<
"Macro finished with errors: no end datetime in the database for this run" << endl;
171 if (run_numbers != NULL)
172 delete[] run_numbers;
173 if (pRunArray != NULL)
180 vector<Long64_t> sum_columns;
181 for (
int i_sum = 0; i_sum < sum_size; i_sum++)
182 sum_columns.push_back(0);
184 if (!((run >= first_run_id) && (run <= last_run_id)))
189 fprintf(stderr,
"ELOG Error!\n");
192 fprintf(stderr,
"Run %d not found in ELOG!\n", run);
199 vector<Int_t> preVals;
201 preVals.resize(20, 0);
202 for (
auto it = spill_map.lower_bound(dtStart); it != spill_map.upper_bound(dtEnd); it++) {
204 printf(
" spill %s\n", it->first.AsSQLString());
205 vector<Int_t>
v = it->second;
208 if ((preVals[
i] !=
v[
i]))
211 printf(
"\n\tALARM!\n\n");
219 bt_acc += bt_notBusy * (acc - nPedestals) / ((
Double_t)(acc - nPedestals + bp + ap));
223 int count_column = 0;
224 for (vector<structParseSchema>::iterator it = vecElements.begin(); it != vecElements.end(); ++it) {
225 if (count_column >= sum_size)
232 if (schema.
vecRows[0].strStatementType ==
"int") {
233 if (count_column > 0)
235 cout <<
"\tsum(" << schema.
vecRows[0].strColumnName <<
"): " <<
v[count_column];
238 if (schema.
vecRows[0].strStatementType ==
"double") {
239 cout <<
"ERROR: type of the column is not supported: " << schema.
vecRows[0].strStatementType
245 cout << endl << endl;
246 for (
int i_sum = 0; i_sum < sum_size; i_sum++)
247 sum_columns[i_sum] +=
v[i_sum];
251 Long64_t bt_notBusy_sum = sum_columns[16];
253 printf(
"\tSum bt= %05lld bt_notBusy= %05lld acc = %05lld bt_acc = %05.3f\n\n", bt_sum, bt_notBusy_sum, acc_sum,
311 TString plotName =
"spill.pdf";
312 for (
Int_t i = 0;
i < hists_log.size();
i++) {
313 Draw2Can(
can, hists_log[
i], (
i < hists.size()) ? hists[
i] :
nullptr);
314 can->SaveAs(
Form(
"%s.png", hists_log[
i]->GetName()));
330 if (run_numbers != NULL)
331 delete[] run_numbers;
332 if (pRunArray != NULL)
334 for (
auto& h : hists)
336 for (
auto& h : hists_log)
347 cout <<
"Macro finished successfully" << endl;