3 #include <onlmon/OnlMonClient.h>
7 #include <TGraphErrors.h>
40 if (name ==
"SepdMon1")
43 TC[0] =
new TCanvas(name.c_str(),
"SepdMon Example Monitor", 1200, 600);
48 gSystem->ProcessEvents();
49 Pad[0] =
new TPad(
"sepdpad0",
"Left", 0., 0., 0.5, 1);
50 Pad[1] =
new TPad(
"sepdpad1",
"Right", 0.5, 0., 1, 1);
54 transparent[0] =
new TPad(
"transparent0",
"this does not show", 0, 0, 1, 1);
57 TC[0]->SetEditable(
false);
59 else if (name ==
"SepdMon2")
62 TC[1] =
new TCanvas(name.c_str(),
"SepdMon2 Example Monitor", 1200, 600);
63 gSystem->ProcessEvents();
64 Pad[2] =
new TPad(
"sepdpad2",
"Left", 0., 0., 0.5, 1);
65 Pad[3] =
new TPad(
"sepdpad3",
"Right", 0.5, 0., 1, 1);
69 transparent[1] =
new TPad(
"transparent1",
"this does not show", 0, 0, 1, 1);
72 TC[1]->SetEditable(
false);
79 else if (name ==
"SepdMon4")
81 TC[3] =
new TCanvas(name.c_str(),
"SepdMon3 Waveform Info", xsize / 3, 0, xsize / 3, ysize * 0.9);
82 gSystem->ProcessEvents();
83 Pad[6] =
new TPad(
"hcalpad6",
"who needs this?", 0.0, 0.6, 1.0, 0.95, 0);
84 Pad[7] =
new TPad(
"hcalpad7",
"who needs this?", 0.0, 0.3, 1.0, 0.6, 0);
85 Pad[8] =
new TPad(
"hcalpad8",
"who needs this?", 0.0, 0.0, 1.0, 0.3, 0);
90 transparent[3] =
new TPad(
"transparent3",
"this does not show", 0, 0, 1, 1);
93 TC[3]->SetEditable(0);
95 else if (name ==
"SepdMon5")
98 TC[4] =
new TCanvas(name.c_str(),
"HCAL Packet Information", 2 * xsize / 3, 0, 2 * xsize / 3, ysize * 0.9);
99 gSystem->ProcessEvents();
100 Pad[10] =
new TPad(
"pad10",
"packet event check", 0.0, 0.6, 1.0 / 2, 0.95, 0);
101 Pad[11] =
new TPad(
"pad11",
"packet size", 0.0, 0.3, 1.0 / 2, 0.6, 0);
102 Pad[12] =
new TPad(
"pad12",
"packet channels", 0.0, 0.0, 1.0 / 2, 0.3, 0);
103 Pad[13] =
new TPad(
"pad13",
"event number offset", 0.5, 0.6, 1.0, 0.95, 0);
115 transparent[4] =
new TPad(
"transparent1",
"this does not show", 0, 0, 1., 1);
120 warning[1] =
new TPad(
"warning1",
"packet warnings", 0.5, 0, 1, 0.2);
121 warning[1]->SetFillStyle(4000);
123 TC[4]->SetEditable(0);
132 if (what ==
"ALL" || what ==
"FIRST")
137 if (what ==
"ALL" || what ==
"SECOND")
149 if (what ==
"ALL" || what ==
"FOURTH")
154 if (what ==
"ALL" || what ==
"FIFTH")
169 std::cout << __PRETTY_FUNCTION__ <<
" Unimplemented Drawing option: " << what << std::endl;
178 TH2 *h_ADC0_s = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_ADC0_s");
179 TH2 *h_ADC0_n = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_ADC0_n");
180 TH2 *h_ADC_s = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_ADC_s");
181 TH2 *h_ADC_n = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_ADC_n");
182 TH2 *h_hits0_s = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_hits0_s");
183 TH2 *h_hits0_n = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_hits0_n");
184 TH2 *h_hits_s = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_hits_s");
185 TH2 *h_hits_n = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_hits_n");
186 time_t evttime = cl->
EventTime(
"CURRENT");
188 if (!gROOT->FindObject(
"SepdMon1"))
192 TC[0]->SetEditable(
true);
198 TC[0]->SetEditable(
false);
202 int nbinsx0 = h_ADC0_s->GetNbinsX();
203 int nbinsy0 = h_ADC0_s->GetNbinsY();
204 int nbinsx = h_ADC_s->GetNbinsX();
205 int nbinsy = h_ADC_s->GetNbinsY();
207 for (
int ibx = 0; ibx < nbinsx0; ibx++)
209 for (
int iby = 0; iby < nbinsy0; iby++)
211 double con = h_ADC0_s->GetBinContent(ibx + 1, iby + 1);
212 double div = h_hits0_s->GetBinContent(ibx + 1, iby + 1);
213 h_ADC0_s->SetBinContent(ibx + 1, iby + 1, con / div);
214 con = h_ADC0_n->GetBinContent(ibx + 1, iby + 1);
215 div = h_hits0_n->GetBinContent(ibx + 1, iby + 1);
216 h_ADC0_n->SetBinContent(ibx + 1, iby + 1, con / div);
220 for (
int ibx = 0; ibx <
nbinsx; ibx++)
222 for (
int iby = 0; iby <
nbinsy; iby++)
224 double con = h_ADC_s->GetBinContent(ibx + 1, iby + 1);
225 double div = h_hits_s->GetBinContent(ibx + 1, iby + 1);
226 h_ADC_s->SetBinContent(ibx + 1, iby + 1, con / div);
227 con = h_ADC_n->GetBinContent(ibx + 1, iby + 1);
228 div = h_hits_n->GetBinContent(ibx + 1, iby + 1);
229 h_ADC_n->SetBinContent(ibx + 1, iby + 1, con / div);
232 gStyle->SetOptStat(0);
234 h_ADC0_s->Draw(
"COLZPOL");
235 h_ADC_s->Draw(
"COLZPOL same");
237 h_ADC0_n->Draw(
"COLZPOL");
238 h_ADC_n->Draw(
"COLZPOL same");
241 PrintRun.SetTextFont(62);
242 PrintRun.SetTextSize(0.04);
244 PrintRun.SetTextAlign(23);
245 std::ostringstream runnostream;
249 <<
", Time: " << ctime(&evttime);
250 runstring = runnostream.str();
252 PrintRun.DrawText(0.5, 1., runstring.c_str());
255 TC[0]->SetEditable(
false);
262 TH2 *h_hits0_s = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_hits0_s");
263 TH2 *h_hits0_n = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_hits0_n");
264 TH2 *h_hits_s = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_hits_s");
265 TH2 *h_hits_n = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_hits_n");
267 TH1 *h_event = cl->
getHisto(
"SEPDMON_0",
"h_event");
268 time_t evttime = cl->
EventTime(
"CURRENT");
270 if (!gROOT->FindObject(
"SepdMon2"))
277 TC[0]->SetEditable(
false);
280 int nevt = h_event->GetEntries();
281 h_hits0_s->Scale(1. / nevt);
282 h_hits_s->Scale(1. / nevt);
283 h_hits0_n->Scale(1. / nevt);
284 h_hits_n->Scale(1. / nevt);
285 gStyle->SetOptStat(0);
286 TC[1]->SetEditable(
true);
289 h_hits0_s->Draw(
"COLZPOL");
290 h_hits_s->Draw(
"COLZPOL same");
292 h_hits0_n->Draw(
"COLZPOL");
293 h_hits_n->Draw(
"COLZPOL same");
295 PrintRun.SetTextFont(62);
296 PrintRun.SetTextSize(0.04);
298 PrintRun.SetTextAlign(23);
299 std::ostringstream runnostream;
303 <<
", Time: " << ctime(&evttime);
304 runstring = runnostream.str();
306 PrintRun.DrawText(0.5, 1., runstring.c_str());
309 TC[1]->SetEditable(
false);
316 TH2 *h_ADC_corr = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_ADC_corr");
317 TH2 *h_hits_corr = (TH2 *) cl->
getHisto(
"SEPDMON_0",
"h_hits_corr");
318 time_t evttime = cl->
EventTime(
"CURRENT");
319 if (!gROOT->FindObject(
"SepdMon3"))
326 TC[0]->SetEditable(
false);
329 TC[2]->SetEditable(
true);
332 h_ADC_corr->Draw(
"COLZ");
334 h_hits_corr->Draw(
"COLZ");
336 PrintRun.SetTextFont(62);
337 PrintRun.SetTextSize(0.04);
339 PrintRun.SetTextAlign(23);
340 std::ostringstream runnostream;
344 <<
", Time: " << ctime(&evttime);
345 runstring = runnostream.str();
347 PrintRun.DrawText(0.5, 1., runstring.c_str());
350 TC[2]->SetEditable(
false);
358 TH1F *h_waveform_time = (TH1F *) cl->
getHisto(
"SEPDMON_0",
"h1_waveform_time");
359 TH1F *h_waveform_pedestal = (TH1F *) cl->
getHisto(
"SEPDMON_0",
"h1_waveform_pedestal");
360 TH2F *h2_sepd_waveform = (TH2F *) cl->
getHisto(
"SEPDMON_0",
"h2_sepd_waveform");
362 if (!gROOT->FindObject(
"SepdMon4"))
367 TC[3]->SetEditable(1);
370 if (!h2_sepd_waveform || !h_waveform_time || !h_waveform_pedestal)
373 if (!h2_sepd_waveform) std::cout <<
"h2_sepd_waveform not found" << std::endl;
374 if (!h_waveform_time) std::cout <<
"h_waveform_time not found" << std::endl;
375 if (!h_waveform_pedestal) std::cout <<
"h_waveform_pedestal not found" << std::endl;
377 TC[3]->SetEditable(0);
382 gStyle->SetTitleFontSize(0.03);
383 float ymaxp = h2_sepd_waveform->ProfileX()->GetMaximum();
384 h2_sepd_waveform->GetYaxis()->SetRangeUser(0, ymaxp * 20);
386 h2_sepd_waveform->Draw(
"colz");
389 h2_sepd_waveform->GetXaxis()->SetNdivisions(510, kTRUE);
390 h2_sepd_waveform->GetXaxis()->SetTitle(
"Sample #");
391 h2_sepd_waveform->GetYaxis()->SetTitle(
"Waveform [ADC]");
392 h2_sepd_waveform->GetXaxis()->SetLabelSize(tsize);
393 h2_sepd_waveform->GetYaxis()->SetLabelSize(tsize);
394 h2_sepd_waveform->GetXaxis()->SetTitleSize(tsize);
395 h2_sepd_waveform->GetYaxis()->SetTitleSize(tsize);
396 h2_sepd_waveform->GetXaxis()->SetTitleOffset(1.2);
397 h2_sepd_waveform->GetYaxis()->SetTitleOffset(0.75);
399 gPad->SetBottomMargin(0.16);
400 gPad->SetLeftMargin(0.2);
401 gPad->SetRightMargin(0.05);
402 gPad->SetLeftMargin(0.15);
403 gStyle->SetOptStat(0);
404 gStyle->SetPalette(57);
409 PrintRun.SetTextFont(62);
410 PrintRun.SetTextSize(0.03);
412 PrintRun.SetTextAlign(23);
413 std::ostringstream runnostream;
418 <<
", Time: " << ctime(&evttime);
419 runstring = runnostream.str();
421 PrintRun.DrawText(0.5, 0.99, runstring.c_str());
425 gStyle->SetTitleFontSize(0.06);
428 h_waveform_time->Draw(
"hist");
429 h_waveform_time->GetXaxis()->SetNdivisions(510, kTRUE);
430 h_waveform_time->GetXaxis()->SetTitle(
"Sample #");
431 h_waveform_time->GetYaxis()->SetTitle(
"Towers");
432 h_waveform_time->GetXaxis()->SetLabelSize(tsize2);
433 h_waveform_time->GetYaxis()->SetLabelSize(tsize2);
434 h_waveform_time->GetXaxis()->SetTitleSize(tsize2);
435 h_waveform_time->GetYaxis()->SetTitleSize(tsize2);
436 h_waveform_time->GetXaxis()->SetTitleOffset(1.0);
437 h_waveform_time->GetYaxis()->SetTitleOffset(0.85);
438 gPad->SetTopMargin(0.06);
439 gPad->SetBottomMargin(0.18);
440 gPad->SetRightMargin(0.05);
441 gPad->SetLeftMargin(0.2);
442 gStyle->SetOptStat(0);
448 gStyle->SetTitleFontSize(0.06);
450 h_waveform_pedestal->Draw(
"hist");
451 h_waveform_pedestal->GetXaxis()->SetNdivisions(510, kTRUE);
452 h_waveform_pedestal->GetXaxis()->SetTitle(
"ADC Pedistal");
453 h_waveform_pedestal->GetYaxis()->SetTitle(
"Towers");
454 h_waveform_pedestal->GetXaxis()->SetLabelSize(tsize2);
455 h_waveform_pedestal->GetYaxis()->SetLabelSize(tsize2);
456 h_waveform_pedestal->GetXaxis()->SetTitleSize(tsize2);
457 h_waveform_pedestal->GetYaxis()->SetTitleSize(tsize2);
458 h_waveform_pedestal->GetXaxis()->SetTitleOffset(0.9);
459 h_waveform_pedestal->GetYaxis()->SetTitleOffset(0.85);
460 gPad->SetTopMargin(0.06);
461 gPad->SetBottomMargin(0.18);
462 gPad->SetRightMargin(0.05);
463 gPad->SetLeftMargin(0.2);
464 gStyle->SetOptStat(0);
470 TC[3]->SetEditable(0);
478 TH1F *h1_packet_number = (TH1F *) cl->
getHisto(
"SEPDMON_0",
"h1_packet_number");
479 TH1F *h1_packet_length = (TH1F *) cl->
getHisto(
"SEPDMON_0",
"h1_packet_length");
480 TH1F *h1_packet_chans = (TH1F *) cl->
getHisto(
"SEPDMON_0",
"h1_packet_chans");
481 TH1F *h1_packet_event = (TH1F *) cl->
getHisto(
"SEPDMON_0",
"h1_packet_event");
483 if (!gROOT->FindObject(
"SepdMon5"))
487 TC[4]->SetEditable(1);
490 if (!h1_packet_number || !h1_packet_length || !h1_packet_chans || !h1_packet_event)
493 if (!h1_packet_number) std::cout <<
"h1_packet_number not found" << std::endl;
494 if (!h1_packet_length) std::cout <<
"h1_packet_length not found" << std::endl;
495 if (!h1_packet_chans) std::cout <<
"h1_packet_chans not found" << std::endl;
496 if (!h1_packet_event) std::cout <<
"h1_packet_event not found" << std::endl;
499 TC[5]->SetEditable(0);
504 int maxy = h1_packet_event->GetMaximum();
506 for (
int i = 1;
i <= h1_packet_event->GetNbinsX();
i++)
508 if (h1_packet_event->GetBinContent(
i) != 0)
510 h1_packet_event->SetBinContent(
i, h1_packet_event->GetBinContent(
i) - maxy);
515 double xmin = h1_packet_number->GetXaxis()->GetXmin();
516 double xmax = h1_packet_number->GetXaxis()->GetXmax();
518 TLine *one =
new TLine(xmin, 1, xmax, 1);
519 one->SetLineStyle(7);
521 TLine *goodSize =
new TLine(xmin, 3991, xmax, 3991);
522 goodSize->SetLineStyle(7);
524 TLine *goodChans =
new TLine(xmin, 128, xmax, 128);
525 goodChans->SetLineStyle(7);
529 TLegend *
leg =
new TLegend(0.3, 0.16, 0.95, 0.4);
530 leg->SetFillStyle(0);
531 leg->SetBorderSize(0);
533 TLine *warnLineOne =
new TLine(xmin, param * 1, xmax, param * 1);
534 warnLineOne->SetLineStyle(7);
535 warnLineOne->SetLineColor(2);
537 leg->AddEntry(warnLineOne,
"95% Threshold",
"l");
539 TLine *warnLineSize =
new TLine(xmin, param * 3991., xmax, param * 3991.);
540 warnLineSize->SetLineStyle(7);
541 warnLineSize->SetLineColor(2);
543 TLine *warnLineChans =
new TLine(xmin, param * 128., xmax, param * 128.);
544 warnLineChans->SetLineStyle(7);
545 warnLineChans->SetLineColor(2);
549 h1_packet_number->GetYaxis()->SetRangeUser(0.0, 1.3);
550 h1_packet_number->Draw(
"hist");
552 warnLineOne->Draw(
"same");
553 h1_packet_number->GetXaxis()->SetNdivisions(510, kTRUE);
554 h1_packet_number->GetXaxis()->SetTitle(
"Packet #");
555 h1_packet_number->GetYaxis()->SetTitle(
"% Of Events Present");
556 h1_packet_number->GetXaxis()->SetLabelSize(tsize - 0.01);
557 h1_packet_number->GetYaxis()->SetLabelSize(tsize - 0.01);
558 h1_packet_number->GetXaxis()->SetTitleSize(tsize - 0.01);
559 h1_packet_number->GetYaxis()->SetTitleSize(tsize - 0.01);
560 h1_packet_number->GetXaxis()->SetTitleOffset(1);
561 gPad->SetBottomMargin(0.16);
562 gPad->SetLeftMargin(0.16);
563 gPad->SetRightMargin(0.05);
564 gPad->SetLeftMargin(0.15);
565 gStyle->SetOptStat(0);
570 h1_packet_length->Draw(
"hist");
571 h1_packet_length->GetYaxis()->SetRangeUser(0, 6500);
572 goodSize->Draw(
"same");
573 warnLineSize->Draw(
"same");
575 h1_packet_length->GetXaxis()->SetNdivisions(510, kTRUE);
576 h1_packet_length->GetXaxis()->SetTitle(
"Packet #");
577 h1_packet_length->GetYaxis()->SetTitle(
"Average Packet Size");
578 h1_packet_length->GetXaxis()->SetLabelSize(tsize - .01);
579 h1_packet_length->GetYaxis()->SetLabelSize(tsize);
580 h1_packet_length->GetXaxis()->SetTitleSize(tsize - .01);
581 h1_packet_length->GetYaxis()->SetTitleSize(tsize);
582 h1_packet_length->GetXaxis()->SetTitleOffset(1);
583 h1_packet_length->GetYaxis()->SetTitleOffset(0.8);
584 gPad->SetBottomMargin(0.16);
585 gPad->SetLeftMargin(0.16);
586 gPad->SetRightMargin(0.05);
587 gPad->SetLeftMargin(0.15);
588 gStyle->SetOptStat(0);
593 h1_packet_chans->Draw(
"hist");
594 h1_packet_chans->GetYaxis()->SetRangeUser(0, 212);
595 goodChans->Draw(
"same");
596 warnLineChans->Draw(
"same");
597 h1_packet_chans->GetXaxis()->SetNdivisions(510, kTRUE);
598 h1_packet_chans->GetXaxis()->SetTitle(
"Packet #");
599 h1_packet_chans->GetYaxis()->SetTitle(
"Average # of Channels");
600 h1_packet_chans->GetXaxis()->SetLabelSize(tsize - .01);
601 h1_packet_chans->GetYaxis()->SetLabelSize(tsize);
602 h1_packet_chans->GetXaxis()->SetTitleSize(tsize - .01);
603 h1_packet_chans->GetYaxis()->SetTitleSize(tsize);
604 h1_packet_chans->GetXaxis()->SetTitleOffset(0.8);
605 h1_packet_chans->GetYaxis()->SetTitleOffset(0.8);
606 gPad->SetBottomMargin(0.16);
607 gPad->SetLeftMargin(0.16);
608 gPad->SetRightMargin(0.05);
609 gPad->SetLeftMargin(0.15);
610 gStyle->SetOptStat(0);
615 h1_packet_event->Draw(
"hist");
616 double ymax = h1_packet_event->GetMaximum();
617 double ymin = h1_packet_event->GetMinimum();
619 h1_packet_event->GetYaxis()->SetRangeUser(ymin - 0.3 * (ymax - ymin + 30), ymax + 0.3 * (ymax - ymin + 30));
620 h1_packet_event->GetXaxis()->SetTitle(
"Packet #");
621 h1_packet_event->GetYaxis()->SetTitle(
"clock offset");
622 h1_packet_event->GetXaxis()->SetLabelSize(tsize - .01);
623 h1_packet_event->GetYaxis()->SetLabelSize(tsize);
624 h1_packet_event->GetXaxis()->SetTitleSize(tsize - .01);
625 h1_packet_event->GetYaxis()->SetTitleSize(tsize);
626 h1_packet_event->GetXaxis()->SetTitleOffset(0.8);
627 h1_packet_event->GetYaxis()->SetTitleOffset(1.2);
628 gPad->SetBottomMargin(0.16);
629 gPad->SetLeftMargin(0.2);
630 gPad->SetRightMargin(0.05);
631 gPad->SetLeftMargin(0.2);
632 gStyle->SetOptStat(0);
641 std::vector<int> badPackets;
642 std::vector<std::string> whatswrong;
643 for (
int i = 1;
i <= 6;
i++)
645 bool missing =
false;
646 bool badnumber =
false;
647 bool badlength =
false;
648 bool badchans =
false;
649 if (h1_packet_number->GetBinContent(
i) == 0)
653 if (h1_packet_number->GetBinContent(
i) < param)
657 if (h1_packet_length->GetBinContent(
i) < param * 3991.)
661 if (h1_packet_chans->GetBinContent(
i) < param * 128.)
665 if (badnumber || badlength || badchans || missing)
667 badPackets.push_back((
int) h1_packet_number->GetBinCenter(
i));
671 reason +=
"packet lost! ";
677 reason +=
"some events are missing, ";
681 reason +=
"too short, ";
685 reason +=
"too few channels, ";
688 reason = reason.substr(0, reason.size() - 2);
691 whatswrong.push_back(reason);
694 bool mismatch =
false;
695 for (
int i = 1;
i <= h1_packet_event->GetNbinsX();
i++)
697 if (h1_packet_event->GetBinContent(
i) != 0)
704 mismatchWarn.SetTextFont(62);
705 mismatchWarn.SetTextSize(0.06);
706 mismatchWarn.SetTextColor(2);
707 mismatchWarn.SetNDC();
708 mismatchWarn.SetTextAlign(23);
711 mismatchWarn.DrawText(0.5, 0.95,
"Packet misaligned!");
714 mismatchWarn.SetTextColor(1);
715 mismatchWarn.SetTextSize(0.05);
719 PacketWarn.SetTextFont(62);
720 PacketWarn.SetTextSize(0.04);
721 PacketWarn.SetTextColor(1);
723 PacketWarn.SetTextAlign(23);
724 PacketWarn.DrawText(0.5, 0.75,
"Bad Packets:");
725 for (
int i = 0;
i < (int) badPackets.size();
i++)
727 PacketWarn.DrawText(0.5, 0.7 - 0.05 *
i, Form(
"%i: %s", badPackets[
i], whatswrong[i].c_str()));
731 PrintRun.SetTextFont(62);
732 PrintRun.SetTextSize(0.02);
734 PrintRun.SetTextAlign(23);
735 std::ostringstream runnostream;
737 std::ostringstream runnostream2;
741 runnostream <<
"Packet Information";
742 runnostream2 <<
" Run " << cl->
RunNumber() <<
", Time: " << ctime(&evttime);
745 runstring = runnostream.str();
746 PrintRun.DrawText(0.5, .99, runstring.c_str());
748 runstring = runnostream2.str();
749 PrintRun.DrawText(0.5, .966, runstring.c_str());
752 TC[4]->SetEditable(0);
760 int iret =
Draw(what);
766 for (TCanvas *canvas :
TC)
768 if (canvas ==
nullptr)
782 int iret =
Draw(what);
790 for (TCanvas *canvas :
TC)
792 if (canvas ==
nullptr)