BmnRoot
Loading...
Searching...
No Matches
BmnHistStat.cxx
Go to the documentation of this file.
1#include "BmnHistStat.h"
2
3// #include <stdio.h>
4// #include <curl/curl.h>
5// BmnRoot
6#include "BmnRawDataDecoder.h"
7
8using namespace std::chrono;
9#ifdef HAVE_PROMCPP
10using namespace prometheus;
11#endif
12
13BmnHistStat::BmnHistStat(TString title, TString path)
14 : BmnHist()
15 , varsInitDone{false}
16 , fdPosition{-1}
17 , bdPosition{-1}
18 , bc1Position{-1}
19 , bit_filter{0}
20 , sum_fsd{0}
21 , sum_tof400{0}
22 , sum_tof700{0}
23 , sum_csc{0}
24 , sum_fhcal{0}
25 , sum_gem{0}
26 , sum_nbc1{0}
27 , nbc1{0}
28 , fsd2gem{0}
29 , tof4002gem{0}
30 , tof7002gem{0}
31 , csc2gem{0}
32 , fhcal2gem{0}
33 , gem2nbc1{0}
34 , nevents{0}
35 , last_ev_time{SysPoint::min()}
36 , ev_type{kBMNPEDESTAL}
37 , ev_type_prev{kBMNPEDESTAL}
38#ifdef HAVE_PROMCPP
39 , gauge_family{nullptr}
40 , counter_family{nullptr}
41 , registry_init_done{false}
42 , metrics_available{false}
43#endif
44// , pushgateway{"http://localhost:9091"}
45{
46 fTitle = title;
47 fName = title + "_cl";
48 refPath = path;
49
50 initHistDet();
51 initHistFD();
52 initHistBD();
53 initHistCorr();
54
55 bit_filter = BIT(11); // @TODO: replace with something unified (valid only for period 9)
56}
57
59{
60 delete canStatDet;
61 delete canStatFD;
62 delete canStatBD;
63 delete canStatCorr;
64
65 if (fDir)
66 return;
67
68 delete histGemStat;
69 delete histSiliconStat;
70 delete histTof400Stat;
71 delete histTof700Stat;
72 delete histCscStat;
73 delete histFHCalStat;
74
75 delete histFDGemStat;
76 delete histFDSiliconStat;
77 delete histFDTof400Stat;
78 delete histFDTof700Stat;
79 delete histFDCscStat;
80 delete histFDFHCalStat;
81
82 delete histBDGemStat;
83 delete histBDSiliconStat;
84 delete histBDTof400Stat;
85 delete histBDTof700Stat;
86 delete histBDCscStat;
87 delete histBDFHCalStat;
88
89 delete histGemSilicon;
90 delete histGemTof400;
91 delete histGemTof700;
92 delete histGemCsc;
93 delete histGemFHCal;
94 delete histCscFHCal;
95
96 for (auto padDet : canStatDetPads)
97 delete padDet;
98
99 for (auto padFD : canStatFDPads)
100 delete padFD;
101
102 for (auto padBD : canStatBDPads)
103 delete padBD;
104
105 for (auto padCorr : canStatCorrPads)
106 delete padCorr;
107}
108
109#ifdef HAVE_PROMCPP
110void BmnHistStat::ResetRegistry()
111{
112 // LOGF(info, "Families %zu", registry->Collect().size());
113 if (!exposer) {
114 exposer = make_unique<Exposer>("127.0.0.1:9092");
115 registry = make_shared<Registry>();
116 }
117 registry->Remove(*gauge_family);
118 DBG("ResetRegistry")
119 // LOGF(info, "Families %zu after", registry->Collect().size());
120 registry_init_done = true;
121 metrics_available = false;
122 return;
123}
124
125void BmnHistStat::CreateMetrics()
126{
127 auto& gf = BuildGauge().Name("Spill_events").Help("Number of digits in each detectors").Register(*registry);
128 gauge_family = &gf;
129 {
130 Gauge& worker_gauge = gauge_family->Add({{"Stage", "Digi"}, {"Level", "Spill"}, {"Var", "sum_nbc1"}});
131 gauges_by_name["sum_nbc1"] = &worker_gauge;
132 }
133 {
134 Gauge& worker_gauge = gauge_family->Add({{"Stage", "Digi"}, {"Level", "Spill"}, {"Var", "gem2nbc1"}});
135 gauges_by_name["gem2nbc1"] = &worker_gauge;
136 }
137 {
138 Gauge& worker_gauge = gauge_family->Add({{"Stage", "Digi"}, {"Level", "Spill"}, {"Var", "fsd2gem"}});
139 gauges_by_name["fsd2gem"] = &worker_gauge;
140 }
141 {
142 Gauge& worker_gauge = gauge_family->Add({{"Stage", "Digi"}, {"Level", "Spill"}, {"Var", "tof4002gem"}});
143 gauges_by_name["tof4002gem"] = &worker_gauge;
144 }
145 {
146 Gauge& worker_gauge = gauge_family->Add({{"Stage", "Digi"}, {"Level", "Spill"}, {"Var", "tof7002gem"}});
147 gauges_by_name["tof7002gem"] = &worker_gauge;
148 }
149 {
150 Gauge& worker_gauge = gauge_family->Add({{"Stage", "Digi"}, {"Level", "Spill"}, {"Var", "csc2gem"}});
151 gauges_by_name["csc2gem"] = &worker_gauge;
152 }
153 {
154 Gauge& worker_gauge = gauge_family->Add({{"Stage", "Digi"}, {"Level", "Spill"}, {"Var", "fhcal2gem"}});
155 gauges_by_name["fhcal2gem"] = &worker_gauge;
156 }
157 {
158 Gauge& worker_gauge = gauge_family->Add({{"Stage", "Digi"}, {"Level", "Spill"}, {"Var", "time_point"}});
159 gauges_by_name["time_point"] = &worker_gauge;
160 }
161 exposer->RegisterCollectable(registry);
162 metrics_available = true;
163 return;
164}
165
166void BmnHistStat::DestroyMetrics()
167{
168 return;
169}
170
171BmnStatus BmnHistStat::UpdateMetrics()
172{
173 gauges_by_name["sum_nbc1"]->Set(sum_nbc1);
174 gauges_by_name["gem2nbc1"]->Set(gem2nbc1);
175 gauges_by_name["fsd2gem"]->Set(fsd2gem);
176 gauges_by_name["tof4002gem"]->Set(tof4002gem);
177 gauges_by_name["tof7002gem"]->Set(tof7002gem);
178 gauges_by_name["csc2gem"]->Set(csc2gem);
179 gauges_by_name["fhcal2gem"]->Set(fhcal2gem);
180 gauges_by_name["time_point"]->Set(duration_cast<milliseconds>(last_ev_time_show.time_since_epoch()).count());
181 return kBMNSUCCESS;
182}
183#endif
184
185void BmnHistStat::Register(THttpServer* serv)
186{
187 fServer = serv;
188 fServer->Register("/", this);
189 TString path = "/" + fTitle + "/";
190 fServer->Register(path, canStatDet);
191 fServer->Register(path, canStatFD);
192 fServer->Register(path, canStatBD);
193 fServer->Register(path, canStatCorr);
194 // fServer->Register(path + "/spill_stat", MetricsHandler);
195 fServer->SetItemField(path, "_monitoring", "2000");
196 fServer->SetItemField(path, "_layout", "grid3x3");
197 TString cmd = "/" + fName + "/->Reset()";
198 TString cmdTitle = path + "Reset";
199 fServer->RegisterCommand(cmdTitle.Data(), cmd.Data(), "button;");
200 fServer->Restrict(cmdTitle.Data(), "visible=shift");
201 fServer->Restrict(cmdTitle.Data(), "allow=shift");
202 fServer->Restrict(cmdTitle.Data(), "deny=guest");
203 cmd = "/" + fName + "/->SetRefRun(%arg1%)";
204 cmdTitle = path + "SetRefRun";
205 fServer->RegisterCommand(cmdTitle.Data(), cmd.Data(), "button;");
206 // fServer->Restrict(cmdTitle.Data(), "deny=guest");
207}
208
209void BmnHistStat::SetDir(TFile* outFile, TTree* recoTree)
210{
211 frecoTree = recoTree;
212 fDir = NULL;
213 if (outFile != NULL)
214 fDir = outFile->mkdir(fTitle + "_hists");
215 histGemStat->SetDirectory(fDir);
216 histSiliconStat->SetDirectory(fDir);
217 histTof400Stat->SetDirectory(fDir);
218 histTof700Stat->SetDirectory(fDir);
219 histCscStat->SetDirectory(fDir);
220 histFHCalStat->SetDirectory(fDir);
221
222 histFDGemStat->SetDirectory(fDir);
223 histFDSiliconStat->SetDirectory(fDir);
224 histFDTof400Stat->SetDirectory(fDir);
225 histFDTof700Stat->SetDirectory(fDir);
226 histFDCscStat->SetDirectory(fDir);
227 histFDFHCalStat->SetDirectory(fDir);
228
229 histBDGemStat->SetDirectory(fDir);
230 histBDSiliconStat->SetDirectory(fDir);
231 histBDTof400Stat->SetDirectory(fDir);
232 histBDTof700Stat->SetDirectory(fDir);
233 histBDCscStat->SetDirectory(fDir);
234 histBDFHCalStat->SetDirectory(fDir);
235
236 histGemSilicon->SetDirectory(fDir);
237 histGemTof400->SetDirectory(fDir);
238 histGemTof700->SetDirectory(fDir);
239 histGemCsc->SetDirectory(fDir);
240 histGemFHCal->SetDirectory(fDir);
241 histCscFHCal->SetDirectory(fDir);
242#ifdef HAVE_PROMCPP
243 if (fDir) {
244 if (metrics_available)
245 ResetRegistry();
246 }
247#endif
248}
249
251{
252 BmnHist::DrawRef(canStatDet, &canStatDetPads);
253 BmnHist::DrawRef(canStatFD, &canStatFDPads);
254 BmnHist::DrawRef(canStatBD, &canStatBDPads);
255 BmnHist::DrawRef(canStatCorr, &canStatCorrPads);
256 return;
257}
258
260{
261 const uint32_t timewin_begin = 312;
262 const uint32_t timewin_end = 362;
263 BmnEventHeader* header = fDigiArrays->header;
264 ev_type = header->GetEventType();
265#ifdef HAVE_PROMCPP
266 if (fDir) {
267 if (header->GetSpillStart()) {
268 printf("Spill start n ev %lu\n", nevents);
269 if ((sum_gem > 0) && (nbc1 > Min_NBC1)) {
270 if (!registry_init_done)
271 ResetRegistry();
272 if (!metrics_available)
273 CreateMetrics();
274 sum_nbc1 = nbc1;
275 fsd2gem = sum_fsd / sum_gem;
276 tof4002gem = sum_tof400 / sum_gem;
277 tof7002gem = sum_tof700 / sum_gem;
278 csc2gem = sum_csc / sum_gem;
279 fhcal2gem = sum_fhcal / sum_gem;
280 gem2nbc1 = sum_gem / sum_nbc1;
281 last_ev_time_show = last_ev_time;
282 printf("sum_nbc1 %4.3f gem2nbc1 %4.3f fsd2gem %4.3f \n", sum_nbc1, gem2nbc1, fsd2gem);
283 UpdateMetrics();
284 // SendMetrics();
285 } else if (metrics_available)
286 ResetRegistry();
287 ResetTimelineCounters();
288 }
289 nevents++;
290 }
291#endif
292 if (ev_type == kBMNPAYLOAD) {
293 TClonesArray* gemDigits = fDigiArrays->gem;
294 TClonesArray* siliconDigits = fDigiArrays->silicon;
295 TClonesArray* tof400Digits = fDigiArrays->tof400;
296 TClonesArray* tof700Digits = fDigiArrays->tof701;
297 if (tof700Digits == nullptr)
298 tof700Digits = fDigiArrays->tof700;
299 TClonesArray* cscDigits = fDigiArrays->csc;
300 TClonesArray* fhcalDigits = fDigiArrays->fhcal;
301
302 vector<TClonesArray*>* trigDigits = fDigiArrays->trigAr;
303
304 if (!varsInitDone) {
305 fdPosition = getPositionInArray(trigDigits, "TQDC_FD");
306 bdPosition = getPositionInArray(trigDigits, "BD");
307 bc1Position = getPositionInArray(trigDigits, "TQDC_BC1");
308 varsInitDone = true;
309 }
310
311 if (gemDigits)
312 histGemStat->Fill(gemDigits->GetEntriesFast());
313 if (siliconDigits)
314 histSiliconStat->Fill(siliconDigits->GetEntriesFast());
315 if (tof400Digits)
316 histTof400Stat->Fill(tof400Digits->GetEntriesFast());
317 if (tof700Digits)
318 histTof700Stat->Fill(tof700Digits->GetEntriesFast());
319 if (cscDigits)
320 histCscStat->Fill(cscDigits->GetEntriesFast());
321 if (fhcalDigits)
322 histFHCalStat->Fill(fhcalDigits->GetEntriesFast());
323 if (trigDigits) {
324 TClonesArray* TQDC_FD = trigDigits->at(fdPosition);
325 TClonesArray* TQDC_BD = trigDigits->at(bdPosition);
326 if (TQDC_FD->GetEntriesFast() != 0) {
327 BmnTrigWaveDigit* fdDigit = dynamic_cast<BmnTrigWaveDigit*>(TQDC_FD->At(0));
328 Double_t peakFD = fdDigit->GetPeak(timewin_begin, timewin_end);
329 if (gemDigits) {
330 histFDGemStat->Fill(peakFD, gemDigits->GetEntriesFast());
331 }
332 if (siliconDigits) {
333 histFDSiliconStat->Fill(peakFD, siliconDigits->GetEntriesFast());
334 }
335 if (tof400Digits) {
336 histFDTof400Stat->Fill(peakFD, tof400Digits->GetEntriesFast());
337 }
338 if (tof700Digits) {
339 histFDTof700Stat->Fill(peakFD, tof700Digits->GetEntriesFast());
340 }
341 if (cscDigits) {
342 histFDCscStat->Fill(peakFD, cscDigits->GetEntriesFast());
343 }
344 if (fhcalDigits) {
345 histFDFHCalStat->Fill(peakFD, fhcalDigits->GetEntriesFast());
346 }
347 }
348 if (TQDC_BD) {
349 Double_t numberMod = TQDC_BD->GetEntriesFast();
350 if (gemDigits) {
351 histBDGemStat->Fill(numberMod, gemDigits->GetEntriesFast());
352 }
353 if (siliconDigits) {
354 histBDSiliconStat->Fill(numberMod, siliconDigits->GetEntriesFast());
355 }
356 if (tof400Digits) {
357 histBDTof400Stat->Fill(numberMod, tof400Digits->GetEntriesFast());
358 }
359 if (tof700Digits) {
360 histBDTof700Stat->Fill(numberMod, tof700Digits->GetEntriesFast());
361 }
362 if (cscDigits) {
363 histBDCscStat->Fill(numberMod, cscDigits->GetEntriesFast());
364 }
365 if (fhcalDigits) {
366 histBDFHCalStat->Fill(numberMod, fhcalDigits->GetEntriesFast());
367 }
368 }
369 }
370
371 if (gemDigits && siliconDigits)
372 histGemSilicon->Fill(gemDigits->GetEntriesFast(), siliconDigits->GetEntriesFast());
373 if (gemDigits && tof400Digits)
374 histGemTof400->Fill(gemDigits->GetEntriesFast(), tof400Digits->GetEntriesFast());
375 if (gemDigits && tof700Digits)
376 histGemTof700->Fill(gemDigits->GetEntriesFast(), tof700Digits->GetEntriesFast());
377 if (gemDigits && cscDigits)
378 histGemCsc->Fill(gemDigits->GetEntriesFast(), cscDigits->GetEntriesFast());
379 if (gemDigits && fhcalDigits)
380 histGemFHCal->Fill(gemDigits->GetEntriesFast(), fhcalDigits->GetEntriesFast());
381 if (cscDigits && fhcalDigits)
382 histCscFHCal->Fill(cscDigits->GetEntriesFast(), fhcalDigits->GetEntriesFast());
383
384#ifdef HAVE_PROMCPP
385 // fDir means set of hists not for show (may be resetted)
386 // bc1Position if not found
387 if ((fDir) && (bc1Position >= 0)) {
388 if (header->GetInputSignalsAR() | bit_filter) {
389 if (siliconDigits)
390 sum_fsd += siliconDigits->GetEntriesFast();
391 if (tof400Digits)
392 sum_tof400 += tof400Digits->GetEntriesFast();
393 if (tof700Digits)
394 sum_tof700 += tof700Digits->GetEntriesFast();
395 if (cscDigits)
396 sum_csc += cscDigits->GetEntriesFast();
397 if (fhcalDigits)
398 sum_fhcal += fhcalDigits->GetEntriesFast();
399 if (gemDigits)
400 sum_gem += gemDigits->GetEntriesFast();
401 TClonesArray* TQDC_BC1 = trigDigits->at(bc1Position);
402 for (Int_t digIndex = 0; digIndex < TQDC_BC1->GetEntriesFast(); digIndex++) {
403 BmnTrigWaveDigit* td = static_cast<BmnTrigWaveDigit*>(TQDC_BC1->At(digIndex));
404 nbc1 += td->GetIntegral(timewin_begin, timewin_end);
405 }
406 last_ev_time = header->GetEventTimeTP();
407 // printf("sum_fsd %4.2f sum_gem %4.2f nbc1 %4.2f\n", sum_fsd, sum_gem, nbc1);
408 }
409 }
410#endif
411 } // else {
412 // if (ev_type_prev == kBMNPAYLOAD) { // spill ended on prev event
413 // }
414 // }
415 ev_type_prev = ev_type;
416}
417
418void BmnHistStat::ResetTimelineCounters()
419{
420 sum_fsd = 0;
421 sum_tof400 = 0;
422 sum_tof700 = 0;
423 sum_csc = 0;
424 sum_fhcal = 0;
425 sum_gem = 0;
426 nbc1 = 0;
427 fsd2gem = 0;
428 tof4002gem = 0;
429 tof7002gem = 0;
430 csc2gem = 0;
431 fhcal2gem = 0;
432 gem2nbc1 = 0;
433 nevents = 0;
434}
435
436// BmnStatus BmnHistStat::SendMetrics()
437// {
438// string job = "job1";
439// // string instance = "";
440// string url = pushgateway + "/metrics/job/" + curl_easy_escape(nullptr, job.c_str(), 0);
441// // + "/instance/" + curl_easy_escape(nullptr, instance.c_str(), 0);
442// string payload =
443// string("# HELP gem2nbc1 GEM/n(BC1) digits in a spill\n")
444// + "# TYPE gem2nbc1 gauge\n"
445// + Form("gem2nbc1 %3.3f\n", gem2nbc1)
446// + "# HELP fsd2gem FSD/GEM digits in a spill\n"
447// + "# TYPE fsd2gem gauge\n"
448// + Form("fsd2gem %3.3f\n", fsd2gem)
449// + "# HELP time_point Last event timestamp\n"
450// + "# TYPE time_point gauge\n"
451// + Form("time_point %zu\n", duration_cast<milliseconds>(last_ev_time_show.time_since_epoch()).count());
452
453// CURL* curl = curl_easy_init();
454// if (!curl) {
455// std::cerr << "curl init failed\n";
456// return kBMNERROR;
457// }
458// struct curl_slist* headers = nullptr;
459// headers = curl_slist_append(headers, "Content-Type: text/plain; version=0.0.4");
460// curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
461// curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT"); // PUT replaces metrics for that job/instance
462// curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
463// curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload.c_str());
464// curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)payload.size());
465// curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L);
466// // SendText sets body and Content-Type
467// // arg->SetText(out.str().c_str(), "text/plain; version=0.0.4; charset=utf-8");
468// CURLcode res = curl_easy_perform(curl);
469// if (res != CURLE_OK) {
470// std::cerr << "curl failed: " << curl_easy_strerror(res) << "\n";
471// curl_slist_free_all(headers);
472// curl_easy_cleanup(curl);
473// return kBMNERROR;
474// }
475// long http_code = 0;
476// curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
477// std::cout << "Pushgateway HTTP status: " << http_code << "\n";
478
479// curl_slist_free_all(headers);
480// curl_easy_cleanup(curl);
481// return kBMNSUCCESS;
482// }
483
485{
486 if (refID != id) {
487 TString FileName = Form("bmn_run%04d_hist.root", id);
488 printf("SetRefRun: %s\n", FileName.Data());
489 refRunName = FileName;
490 refID = id;
491 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canStatDetPads, NamesStatDet);
492 // BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canStatFDPads, NamesStatFD);
493 // BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canStatBDPads, NamesStatBD);
494 // BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canStatCorrPads, NamesStatCorr);
495 DrawBoth();
496 }
497
498 return kBMNSUCCESS;
499}
500
502{
503 for (auto pad : canStatDetPads) {
504 if (pad->ref)
505 delete pad->ref;
506 pad->ref = NULL;
507 }
508 refID = 0;
509}
510
512{
513 printf("ResetStat\n");
514 histGemStat->Reset();
515 histSiliconStat->Reset();
516 histTof400Stat->Reset();
517 histTof700Stat->Reset();
518 histCscStat->Reset();
519 histFHCalStat->Reset();
520
521 histFDGemStat->Reset();
522 histFDSiliconStat->Reset();
523 histFDTof400Stat->Reset();
524 histFDTof700Stat->Reset();
525 histFDCscStat->Reset();
526 histFDFHCalStat->Reset();
527
528 histBDGemStat->Reset();
529 histBDSiliconStat->Reset();
530 histBDTof400Stat->Reset();
531 histBDTof700Stat->Reset();
532 histBDCscStat->Reset();
533 histBDFHCalStat->Reset();
534
535 histGemSilicon->Reset();
536 histGemTof400->Reset();
537 histGemTof700->Reset();
538 histGemCsc->Reset();
539 histGemFHCal->Reset();
540 histCscFHCal->Reset();
541}
542
543void BmnHistStat::initHistDet()
544{
545 TString name;
546 name = fTitle + "_GEM";
547 histGemStat = new TH1I(name, name, 250, 1, Max_GEM_Cnt);
548 histGemStat->GetXaxis()->SetTitle("Count in event");
549 histGemStat->GetYaxis()->SetTitle("Activations count");
550 name = fTitle + "_SILICON";
551 histSiliconStat = new TH1I(name, name, 250, 1, Max_FSD_Cnt);
552 histSiliconStat->GetXaxis()->SetTitle("Count in event");
553 histSiliconStat->GetYaxis()->SetTitle("Activations count");
554 name = fTitle + "_ToF400";
555 histTof400Stat = new TH1I(name, name, 100, 1, Max_ToF_Cnt);
556 histTof400Stat->GetXaxis()->SetTitle("Count in event");
557 histTof400Stat->GetYaxis()->SetTitle("Activations count");
558 name = fTitle + "_ToF700";
559 histTof700Stat = new TH1I(name, name, 100, 1, Max_ToF_Cnt);
560 histTof700Stat->GetXaxis()->SetTitle("Count in event");
561 histTof700Stat->GetYaxis()->SetTitle("Activations count");
562 name = fTitle + "_CSC";
563 histCscStat = new TH1I(name, name, 200, 1, Max_CSC_Cnt);
564 histCscStat->GetXaxis()->SetTitle("Count in event");
565 histCscStat->GetYaxis()->SetTitle("Activations count");
566 name = fTitle + "_FHCAL";
567 histFHCalStat = new TH1I(name, name, 250, 1, Max_FHC_Cnt);
568 histFHCalStat->GetXaxis()->SetTitle("Count in event");
569 histFHCalStat->GetYaxis()->SetTitle("Activations count");
570
571 name = fTitle + "Canvas";
572 canStatDet = new TCanvas(name, name, PAD_WIDTH * 2, PAD_HEIGHT * 3);
573 canStatDet->Divide(3, 2);
574 canStatDetPads.resize(3 * 2);
575 NamesStatDet.resize(3 * 2);
576 for (Int_t iPad = 0; iPad < 6; iPad++) {
577 PadInfo* p = new PadInfo();
578 canStatDetPads[iPad] = p;
579 canStatDet->GetPad(iPad + 1)->SetGrid();
580 }
581 canStatDetPads[0]->current = histGemStat;
582 canStatDetPads[1]->current = histSiliconStat;
583 canStatDetPads[2]->current = histTof400Stat;
584 canStatDetPads[3]->current = histTof700Stat;
585 canStatDetPads[4]->current = histCscStat;
586 canStatDetPads[5]->current = histFHCalStat;
587 for (size_t iPad = 0; iPad < canStatDetPads.size(); iPad++)
588 if (canStatDetPads[iPad]->current) {
589 NamesStatDet.push_back(canStatDetPads[iPad]->current->GetName());
590 BmnHist::SetHistStyleTH1(canStatDetPads[iPad]->current);
591 }
592}
593
594void BmnHistStat::initHistFD()
595{
596 TString name;
597 name = fTitle + "_FD_GEM";
598 histFDGemStat = new TH2F(name, name, 300, 0, Max_FD_Sig, 250, 1, Max_GEM_Cnt);
599 histFDGemStat->GetXaxis()->SetTitle("FD.GetPeak()");
600 histFDGemStat->GetYaxis()->SetTitle("Number of digits in event");
601
602 name = fTitle + "_FD_Silicon";
603 histFDSiliconStat = new TH2F(name, name, 300, 0, Max_FD_Sig, 250, 1, Max_FSD_Cnt);
604 histFDSiliconStat->GetXaxis()->SetTitle("FD.GetPeak()");
605 histFDSiliconStat->GetYaxis()->SetTitle("Number of digits in event");
606
607 name = fTitle + "_FD_Tof400";
608 histFDTof400Stat = new TH2F(name, name, 300, 0, Max_FD_Sig, 100, 1, Max_ToF_Cnt);
609 histFDTof400Stat->GetXaxis()->SetTitle("FD.GetPeak()");
610 histFDTof400Stat->GetYaxis()->SetTitle("Number of digits in event");
611
612 name = fTitle + "_FD_Tof700";
613 histFDTof700Stat = new TH2F(name, name, 300, 0, Max_FD_Sig, 100, 1, Max_ToF_Cnt);
614 histFDTof700Stat->GetXaxis()->SetTitle("FD.GetPeak()");
615 histFDTof700Stat->GetYaxis()->SetTitle("Number of digits in event");
616
617 name = fTitle + "_FD_CSC";
618 histFDCscStat = new TH2F(name, name, 300, 0, Max_FD_Sig, 150, 1, Max_CSC_Cnt);
619 histFDCscStat->GetXaxis()->SetTitle("FD.GetPeak()");
620 histFDCscStat->GetYaxis()->SetTitle("Number of digits in event");
621
622 name = fTitle + "_FD_FHCAL";
623 histFDFHCalStat = new TH2F(name, name, 300, 0, Max_FD_Sig, 250, 1, Max_FHC_Cnt);
624 histFDFHCalStat->GetXaxis()->SetTitle("FD.GetPeak()");
625 histFDFHCalStat->GetYaxis()->SetTitle("Number of digits in event");
626
627 name = fTitle + "FD_DetCanvas";
628 canStatFD = new TCanvas(name, name, PAD_WIDTH * 2, PAD_HEIGHT * 3);
629 canStatFD->Divide(3, 2);
630 canStatFDPads.resize(3 * 2);
631 NamesStatFD.resize(3 * 2);
632 for (Int_t iPad = 0; iPad < 6; iPad++) {
633 PadInfo* p = new PadInfo();
634 p->opt = "colz";
635 canStatFDPads[iPad] = p;
636 canStatFD->GetPad(iPad + 1)->SetGrid();
637 }
638 canStatFDPads[0]->current = histFDGemStat;
639 canStatFDPads[1]->current = histFDSiliconStat;
640 canStatFDPads[2]->current = histFDTof400Stat;
641 canStatFDPads[3]->current = histFDTof700Stat;
642 canStatFDPads[4]->current = histFDCscStat;
643 canStatFDPads[5]->current = histFDFHCalStat;
644 for (size_t iPad = 0; iPad < canStatFDPads.size(); iPad++)
645 if (canStatFDPads[iPad]->current) {
646 NamesStatFD.push_back(canStatFDPads[iPad]->current->GetName());
647 // BmnHist::SetHistStyleTH2(canStatFDPads[iPad]->current);
648 }
649}
650
651void BmnHistStat::initHistBD()
652{
653 TString name;
654 name = fTitle + "_BD_GEM";
655 histBDGemStat = new TH2F(name, name, Max_BD_Cnt - 1, 1, Max_BD_Cnt, 250, 1, Max_GEM_Cnt);
656 histBDGemStat->GetXaxis()->SetTitle("Number of digits in BD");
657 histBDGemStat->GetYaxis()->SetTitle("Number of digits in event GEM");
658
659 name = fTitle + "_BD_Silicon";
660 histBDSiliconStat = new TH2F(name, name, Max_BD_Cnt - 1, 1, Max_BD_Cnt, 250, 1, Max_FSD_Cnt);
661 histBDSiliconStat->GetXaxis()->SetTitle("Number of digits in BD");
662 histBDSiliconStat->GetYaxis()->SetTitle("Number of digits in event Silicon");
663
664 name = fTitle + "_BD_Tof400";
665 histBDTof400Stat = new TH2F(name, name, Max_BD_Cnt - 1, 1, Max_BD_Cnt, 100, 1, Max_ToF_Cnt);
666 histBDTof400Stat->GetXaxis()->SetTitle("Number of digits in BD");
667 histBDTof400Stat->GetYaxis()->SetTitle("Number of digits in event Tof400");
668
669 name = fTitle + "_BD_Tof700";
670 histBDTof700Stat = new TH2F(name, name, Max_BD_Cnt - 1, 1, Max_BD_Cnt, 100, 1, Max_ToF_Cnt);
671 histBDTof700Stat->GetXaxis()->SetTitle("Number of digits in BD");
672 histBDTof700Stat->GetYaxis()->SetTitle("Number of digits in event Tof700");
673
674 name = fTitle + "_BD_CSC";
675 histBDCscStat = new TH2F(name, name, Max_BD_Cnt - 1, 1, Max_BD_Cnt, 150, 1, Max_CSC_Cnt);
676 histBDCscStat->GetXaxis()->SetTitle("Number of digits in BD");
677 histBDCscStat->GetYaxis()->SetTitle("Number of digits in event CSC");
678
679 name = fTitle + "_BD_FHCAL";
680 histBDFHCalStat = new TH2F(name, name, Max_BD_Cnt - 1, 1, Max_BD_Cnt, 250, 1, Max_FHC_Cnt);
681 histBDFHCalStat->GetXaxis()->SetTitle("Number of digits in BD");
682 histBDFHCalStat->GetYaxis()->SetTitle("Number of digits in event FHCAL");
683
684 name = fTitle + "BD_DetCanvas";
685 canStatBD = new TCanvas(name, name, PAD_WIDTH * 2, PAD_HEIGHT * 3);
686 canStatBD->Divide(3, 2);
687 canStatBDPads.resize(3 * 2);
688 NamesStatBD.resize(3 * 2);
689 for (Int_t iPad = 0; iPad < 6; iPad++) {
690 PadInfo* p = new PadInfo();
691 p->opt = "colz";
692 canStatBDPads[iPad] = p;
693 canStatBD->GetPad(iPad + 1)->SetGrid();
694 }
695 canStatBDPads[0]->current = histBDGemStat;
696 canStatBDPads[1]->current = histBDSiliconStat;
697 canStatBDPads[2]->current = histBDTof400Stat;
698 canStatBDPads[3]->current = histBDTof700Stat;
699 canStatBDPads[4]->current = histBDCscStat;
700 canStatBDPads[5]->current = histBDFHCalStat;
701 for (size_t iPad = 0; iPad < canStatBDPads.size(); iPad++)
702 if (canStatBDPads[iPad]->current) {
703 NamesStatBD.push_back(canStatBDPads[iPad]->current->GetName());
704 }
705}
706
707void BmnHistStat::initHistCorr()
708{
709 TString name;
710 name = fTitle + "_GEM_Silicon";
711 histGemSilicon = new TH2F(name, name, 250, 1, Max_GEM_Cnt, 250, 1, Max_FSD_Cnt);
712 histGemSilicon->GetXaxis()->SetTitle("Number of digits in event GEM");
713 histGemSilicon->GetYaxis()->SetTitle("Number of digits in event Silicon");
714
715 name = fTitle + "_GEM_Tof400";
716 histGemTof400 = new TH2F(name, name, 250, 1, Max_GEM_Cnt, 100, 1, Max_ToF_Cnt);
717 histGemTof400->GetXaxis()->SetTitle("Number of digits in event GEM");
718 histGemTof400->GetYaxis()->SetTitle("Number of digits in event Tof400");
719
720 name = fTitle + "_GEM_Tof700";
721 histGemTof700 = new TH2F(name, name, 250, 1, Max_GEM_Cnt, 100, 1, Max_ToF_Cnt);
722 histGemTof700->GetXaxis()->SetTitle("Number of digits in event GEM");
723 histGemTof700->GetYaxis()->SetTitle("Number of digits in event Tof700");
724
725 name = fTitle + "_GEM_CSC";
726 histGemCsc = new TH2F(name, name, 250, 1, Max_GEM_Cnt, 150, 1, Max_CSC_Cnt);
727 histGemCsc->GetXaxis()->SetTitle("Number of digits in event GEM");
728 histGemCsc->GetYaxis()->SetTitle("Number of digits in event CSC");
729
730 name = fTitle + "_GEM_FHCAL";
731 histGemFHCal = new TH2F(name, name, 250, 1, Max_GEM_Cnt, 250, 1, Max_FHC_Cnt);
732 histGemFHCal->GetXaxis()->SetTitle("Number of digits in event GEM");
733 histGemFHCal->GetYaxis()->SetTitle("Number of digits in event FHCAL");
734
735 name = fTitle + "_CSC_FHCAL";
736 histCscFHCal = new TH2F(name, name, 150, 1, Max_CSC_Cnt, 250, 1, Max_FHC_Cnt);
737 histCscFHCal->GetXaxis()->SetTitle("Number of digits in event CSC");
738 histCscFHCal->GetYaxis()->SetTitle("Number of digits in event FHCAL");
739
740 name = fTitle + "CorrCanvas";
741 canStatCorr = new TCanvas(name, name, PAD_WIDTH * 2, PAD_HEIGHT * 3);
742 canStatCorr->Divide(3, 2);
743 canStatCorrPads.resize(3 * 2);
744 NamesStatCorr.resize(3 * 2);
745 for (Int_t iPad = 0; iPad < 6; iPad++) {
746 PadInfo* p = new PadInfo();
747 p->opt = "colz";
748 canStatCorrPads[iPad] = p;
749 canStatCorr->GetPad(iPad + 1)->SetGrid();
750 }
751 canStatCorrPads[0]->current = histGemSilicon;
752 canStatCorrPads[1]->current = histGemTof400;
753 canStatCorrPads[2]->current = histGemTof700;
754 canStatCorrPads[3]->current = histGemCsc;
755 canStatCorrPads[4]->current = histGemFHCal;
756 canStatCorrPads[5]->current = histCscFHCal;
757 for (size_t iPad = 0; iPad < canStatCorrPads.size(); iPad++)
758 if (canStatCorrPads[iPad]->current) {
759 NamesStatCorr.push_back(canStatCorrPads[iPad]->current->GetName());
760 }
761}
762
763Int_t BmnHistStat::getPositionInArray(vector<TClonesArray*>* trigDigits, TString name)
764{
765 for (size_t iTrig = 0; iTrig < trigDigits->size(); ++iTrig) {
766 TClonesArray* array = trigDigits->at(iTrig);
767 TString nameArray = array->GetName();
768 if (nameArray.EqualTo(name))
769 return iTrig;
770 }
771
772 return -1;
773}
#define PAD_WIDTH
Definition BmnAdcQA.cxx:3
#define PAD_HEIGHT
Definition BmnAdcQA.cxx:4
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:30
BmnStatus
Definition BmnEnums.h:24
@ kBMNSUCCESS
Definition BmnEnums.h:25
@ kBMNPAYLOAD
Definition BmnEnums.h:71
@ kBMNPEDESTAL
Definition BmnEnums.h:70
std::chrono::time_point< SysClock > SysPoint
#define DBG(a)
Definition BmnMath.h:24
BmnStatus SetRefRun(Int_t id)
void FillFromDigi(DigiArrays *fDigiArrays)
void SetDir(TFile *outFile=NULL, TTree *recoTree=NULL)
void ClearRefRun()
virtual ~BmnHistStat()
BmnHistStat(TString title, TString path="")
void Register(THttpServer *serv)
TTree * frecoTree
Definition BmnHist.h:88
Int_t refID
Definition BmnHist.h:92
TString refPath
Definition BmnHist.h:90
TDirectory * fDir
Definition BmnHist.h:89
static void DrawRef(unique_ptr< TCanvas > &canGemStrip, vector< PadInfo * > *canGemStripPads)
Definition BmnHist.cxx:15
static void SetHistStyleTH1(TH1 *h)
Definition BmnHist.cxx:195
TString refRunName
Definition BmnHist.h:91
static BmnStatus LoadRefRun(Int_t refID, TString FullName, TString fTitle, vector< PadInfo * > canPads, vector< TString > Names)
Definition BmnHist.cxx:100
THttpServer * fServer
Definition BmnHist.h:87
int GetPeak(UInt_t start=0, UInt_t stop=1e9) const
int GetIntegral(UInt_t start=0, UInt_t stop=1e9) const
TClonesArray * fhcal
Definition DigiArrays.h:134
std::vector< TClonesArray * > * trigAr
Definition DigiArrays.h:144
TClonesArray * gem
Definition DigiArrays.h:126
BmnEventHeader * header
Definition DigiArrays.h:146
TClonesArray * silicon
Definition DigiArrays.h:125
TClonesArray * tof400
Definition DigiArrays.h:129
TClonesArray * tof700
Definition DigiArrays.h:130
TClonesArray * tof701
Definition DigiArrays.h:131
TClonesArray * csc
Definition DigiArrays.h:127
Storage for pad content and it's options.
Definition PadInfo.h:20
string opt
Definition PadInfo.h:88
@ array
array (ordered collection of values)
name
Definition setup.py:7