File indexing completed on 2025-08-05 08:20:24
0001 #include "CemcMonDraw.h"
0002
0003 #include <onlmon/OnlMonClient.h>
0004
0005 #include <onlmon/triggerEnum.h>
0006
0007 #include <calobase/TowerInfoDefs.h>
0008
0009 #include <TAxis.h> // for TAxis
0010 #include <TCanvas.h>
0011 #include <TFile.h>
0012 #include <TFrame.h>
0013 #include <TGraph.h>
0014 #include <TGraphErrors.h>
0015 #include <TH1.h>
0016 #include <TH2.h>
0017 #include <TLegend.h>
0018 #include <TLine.h>
0019 #include <TPad.h>
0020 #include <TPaveText.h>
0021 #include <TProfile.h>
0022 #include <TProfile2D.h>
0023 #include <TQObject.h>
0024 #include <TROOT.h>
0025 #include <TStyle.h>
0026 #include <TSystem.h>
0027 #include <TText.h>
0028
0029 #include <cstring> // for memset
0030 #include <ctime>
0031 #include <fstream>
0032 #include <iostream> // for operator<<, basic_ostream, basic_os...
0033 #include <sstream>
0034 #include <vector> // for vector
0035
0036 CemcMonDraw::CemcMonDraw(const std::string &name)
0037 : OnlMonDraw(name)
0038 {
0039 return;
0040 }
0041
0042 int CemcMonDraw::Init()
0043 {
0044 std::cout << "initializing" << std::endl;
0045
0046 cemcStyle = new TStyle("cemcStyle", "cemcStyle");
0047 gStyle->SetOptStat(0);
0048 Int_t font = 42;
0049 cemcStyle->SetLabelFont(font, "x");
0050 cemcStyle->SetTitleFont(font, "x");
0051 cemcStyle->SetLabelFont(font, "y");
0052 cemcStyle->SetTitleFont(font, "y");
0053 cemcStyle->SetLabelFont(font, "z");
0054 cemcStyle->SetTitleFont(font, "z");
0055 cemcStyle->SetOptStat(0);
0056 cemcStyle->SetPadTickX(1);
0057 cemcStyle->SetPadTickY(1);
0058
0059 gROOT->SetStyle("cemcStyle");
0060 gROOT->ForceStyle();
0061
0062 const char *CEMCcalib = getenv("CEMCCALIB");
0063 TFile *inputTemplate = nullptr;
0064 TFile *inputTemplate_alltrig = nullptr;
0065 if (!CEMCcalib)
0066 {
0067 std::cout << "CEMCCALIB environment variable not set, empty refence will be used" << std::endl;
0068 h2_template_hit = new TH2D("templateHit", "", 96, 0, 96, 256, 0, 256);
0069 }
0070 else
0071 {
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 std::string Templatefilename = std::string(CEMCcalib) + "/" + "Template_69238_100ADC_hits.root";
0082
0083 inputTemplate = new TFile(Templatefilename.c_str(), "READ");
0084 if (!inputTemplate->IsOpen())
0085 {
0086 std::cout << Templatefilename << " could not be opened. Empty reference will be used" << std::endl;
0087 h2_template_hit = new TH2D("templateHit", "", 96, 0, 96, 256, 0, 256);
0088 }
0089 else
0090 {
0091 h2_template_hit = (TH2 *) inputTemplate->Get("h2_cemc_hits_template");
0092 if (!h2_template_hit)
0093 {
0094 std::cout << "h2_cemc_hits_template could not be retrieved from file. Empty reference will be used" << std::endl;
0095 h2_template_hit = new TH2D("templateHit", "", 96, 0, 96, 256, 0, 256);
0096 }
0097 }
0098
0099 std::string Templatefilename_alltrig = std::string(CEMCcalib) + "/" + "Template_69238_100ADC_alltrig.root";
0100 inputTemplate_alltrig = new TFile(Templatefilename_alltrig.c_str(), "READ");
0101 if (!inputTemplate_alltrig->IsOpen())
0102 {
0103 std::cout << Templatefilename_alltrig << " could not be opened. Empty reference will be used" << std::endl;
0104 h2_template_hit_alltrig = new TH2D("templateHit_alltrig", "", 96, 0, 96, 256, 0, 256);
0105 }
0106 else
0107 {
0108 h2_template_hit_alltrig = (TH2 *) inputTemplate_alltrig->Get("h2_cemc_rmhits_alltrig");
0109 if (!h2_template_hit_alltrig)
0110 {
0111 std::cout << "h2_cemc_hits_template could not be retrieved from file. Empty reference will be used" << std::endl;
0112 h2_template_hit_alltrig = new TH2D("templateHit_alltrig", "", 96, 0, 96, 256, 0, 256);
0113 }
0114 }
0115 }
0116
0117 h1_zs = new TH1F("h1_zs", "unsuppressed rate ", 100, 0, 1.1);
0118 h1_zs_low = new TH1F("h1_zs_low", "unsuppressed rate ", 100, 0, 1.1);
0119 h1_zs_high = new TH1F("h1_zs_high", "unsuppressed rate ", 100, 0, 1.1);
0120
0121
0122
0123 return 0;
0124 }
0125
0126 int CemcMonDraw::MakeCanvas(const std::string &name)
0127 {
0128 OnlMonClient *cl = OnlMonClient::instance();
0129 int xsize = cl->GetDisplaySizeX();
0130 int ysize = cl->GetDisplaySizeY();
0131 if (name == "CemcMon1")
0132 {
0133
0134 TC[0] = new TCanvas(name.c_str(), "CemcMon Tower Hits", -1, ysize, xsize / 3, ysize);
0135
0136
0137
0138
0139 gSystem->ProcessEvents();
0140 Pad[0] = new TPad("cemcpad0", "hit map", 0., 0.15, 1., 0.95);
0141 Pad[0]->Draw();
0142
0143 transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
0144 transparent[0]->SetFillStyle(4000);
0145 transparent[0]->Draw();
0146
0147
0148 warning[0] = new TPad("warning0", "hot tower warnings", 0, 0, 1, 0.15);
0149 warning[0]->SetFillStyle(4000);
0150 warning[0]->Draw();
0151 TC[0]->SetEditable(false);
0152 }
0153 else if (name == "CemcMon2")
0154 {
0155
0156 TC[1] = new TCanvas(name.c_str(), "Expert: CemcMon2 Packet Information", -1, ysize, xsize / 3, ysize);
0157 gSystem->ProcessEvents();
0158 Pad[1] = new TPad("cemcpad1", "packet event check", 0.0, 0.6, 1.0 / 2, 0.95, 0);
0159 Pad[2] = new TPad("cemcpad2", "packet size", 0.0, 0.3, 1.0 / 2, 0.6, 0);
0160 Pad[3] = new TPad("cemcpad3", "packet channels", 0.0, 0.0, 1.0 / 2, 0.3, 0);
0161 Pad[1]->Draw();
0162 Pad[2]->Draw();
0163 Pad[3]->Draw();
0164
0165 transparent[1] = new TPad("transparent1", "this does not show", 0, 0, 1., 1);
0166 transparent[1]->SetFillStyle(4000);
0167 transparent[1]->Draw();
0168
0169
0170 warning[1] = new TPad("warning1", "packet warnings", 0.5, 0, 1, 1);
0171 warning[1]->SetFillStyle(4000);
0172 warning[1]->Draw();
0173 TC[1]->SetEditable(false);
0174 }
0175 else if (name == "CemcMon3")
0176 {
0177 TC[2] = new TCanvas(name.c_str(), "CemcMon Waveform Processing", -1, ysize, xsize / 3, ysize);
0178 gSystem->ProcessEvents();
0179 Pad[4] = new TPad("cemcpad4", "who needs this?", 0.0, 0.6, 1.0, 0.95, 0);
0180 Pad[5] = new TPad("cemcpad5", "who needs this?", 0.0, 0.3, 1.0, 0.6, 0);
0181 Pad[6] = new TPad("cemcpad6", "who needs this?", 0.0, 0.0, 1.0, 0.3, 0);
0182 Pad[4]->Draw();
0183 Pad[5]->Draw();
0184 Pad[6]->Draw();
0185
0186 transparent[2] = new TPad("transparent3", "this does not show", 0, 0, 1, 1);
0187 transparent[2]->SetFillStyle(4000);
0188 transparent[2]->Draw();
0189 TC[2]->SetEditable(false);
0190 }
0191 else if (name == "CemcMon4")
0192 {
0193 TC[3] = new TCanvas(name.c_str(), "Expert: CemcMon Waveform Processing", -1, ysize, xsize / 3, ysize);
0194 gSystem->ProcessEvents();
0195 Pad[7] = new TPad("cemcpad7", "who needs this?", 0.0, 0.6, 1.0, 0.95, 0);
0196 Pad[8] = new TPad("cemcpad8", "who needs this?", 0.0, 0.3, 1.0, 0.6, 0);
0197 Pad[9] = new TPad("cemcpad9", "who needs this?", 0.0, 0.0, 1.0, 0.3, 0);
0198 Pad[7]->Draw();
0199 Pad[8]->Draw();
0200 Pad[9]->Draw();
0201
0202 transparent[3] = new TPad("transparent3", "this does not show", 0, 0, 1, 1);
0203 transparent[3]->SetFillStyle(4000);
0204 transparent[3]->Draw();
0205 TC[3]->SetEditable(false);
0206 }
0207 else if (name == "CemcMon5")
0208 {
0209 TC[4] = new TCanvas(name.c_str(), "Expert: Trigger Info", -1, ysize, xsize / 3, ysize);
0210 gSystem->ProcessEvents();
0211 Pad[10] = new TPad("cemcpad10", "who needs this?", 0.0, 0.6, 0.45, 0.95, 0);
0212 Pad[11] = new TPad("cemcpad11", "who needs this?", 0.45, 0.6, 0.9, 0.95, 0);
0213 Pad[12] = new TPad("cemcpad12", "who needs this?", 0.0, 0.3, 0.45, 0.6, 0);
0214 Pad[13] = new TPad("cemcpad13", "who needs this?", 0.45, 0.3, 0.9, 0.6, 0);
0215 Pad[14] = new TPad("cemcpad14", "who needs this?", 0.0, 0.0, 0.9, 0.3, 0);
0216 Pad[10]->Draw();
0217 Pad[11]->Draw();
0218 Pad[12]->Draw();
0219 Pad[13]->Draw();
0220 Pad[14]->Draw();
0221
0222 transparent[4] = new TPad("transparent4", "this does not show", 0, 0, 1, 1);
0223 transparent[4]->SetFillStyle(4000);
0224 transparent[4]->Draw();
0225 TC[4]->SetEditable(false);
0226 }
0227 else if (name == "CemcMonServerStats")
0228 {
0229 TC[5] = new TCanvas(name.c_str(), "CemcMon6 Server Stats", -1, 0, xsize, ysize);
0230 gSystem->ProcessEvents();
0231
0232 transparent[5] = new TPad("transparent5", "this does not show", 0, 0, 1, 1);
0233 transparent[5]->SetFillColor(kGray);
0234 transparent[5]->Draw();
0235 TC[5]->SetEditable(false);
0236 }
0237 else if (name == "CemcAllTrigHits")
0238 {
0239
0240 TC[6] = new TCanvas(name.c_str(), "CemcMon Tower Hits all trig", -1, ysize, xsize / 3, ysize);
0241
0242
0243
0244
0245 gSystem->ProcessEvents();
0246 Pad[15] = new TPad("cemcpad15", "hit map", 0., 0.15, 1., 0.95);
0247 Pad[15]->Draw();
0248
0249 transparent[6] = new TPad("transparent6", "this does not show", 0, 0, 1, 1);
0250 transparent[6]->SetFillStyle(4000);
0251 transparent[6]->Draw();
0252
0253
0254 warning[2] = new TPad("warning6", "hot tower warnings", 0, 0, 1, 0.15);
0255 warning[2]->SetFillStyle(4000);
0256 warning[2]->Draw();
0257 TC[6]->SetEditable(false);
0258 }
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294 else if (name == "CemcMon8")
0295 {
0296 TC[7] = new TCanvas(name.c_str(), "Channel unsuppressed event fraction", -1, ysize, xsize / 3, ysize);
0297 gSystem->ProcessEvents();
0298 Pad[19] = new TPad("cemcpad19", "who needs this?", 0.00, 0.3, 1.00, 0.95);
0299 Pad[19]->SetRightMargin(0.15);
0300 Pad[19]->Draw();
0301 Pad[20] = new TPad("hcalpad24", "1d zs rate", 0.0, 0.0, 1.00, 0.3);
0302 Pad[20]->SetRightMargin(0.15);
0303 Pad[20]->Draw();
0304 transparent[7] = new TPad("transparent7", "this does not show", 0, 0, 1, 1);
0305 transparent[7]->SetFillStyle(4000);
0306 transparent[7]->Draw();
0307 TC[7]->SetEditable(false);
0308 }
0309 else if (name == "CemcBadChi2")
0310 {
0311 TC[8] = new TCanvas(name.c_str(), "Bad Chi2", -1, ysize, xsize / 2, ysize);
0312 gSystem->ProcessEvents();
0313 Pad[21] = new TPad("cemcpad21", "who needs this?", 0.00, 0.00, 1.00, 0.95);
0314 Pad[21]->SetRightMargin(0.15);
0315 Pad[21]->Draw();
0316 transparent[8] = new TPad("transparent8", "this does not show", 0, 0, 1, 1);
0317 transparent[8]->SetFillStyle(4000);
0318 transparent[8]->Draw();
0319 TC[8]->SetEditable(false);
0320 }
0321 else if (name == "CemcNoiseRMS")
0322 {
0323
0324 TC[9] = new TCanvas(name.c_str(), "CemcMon Noise RMS per tower", -1, ysize, xsize / 3, ysize);
0325
0326
0327
0328
0329 gSystem->ProcessEvents();
0330 Pad[22] = new TPad("cemcpad22", "rms map", 0., 0.15, 1., 0.95);
0331 Pad[22]->Draw();
0332
0333 transparent[9] = new TPad("transparent6", "this does not show", 0, 0, 1, 1);
0334 transparent[9]->SetFillStyle(4000);
0335 transparent[9]->Draw();
0336
0337
0338 warning[3] = new TPad("warning6", "hot tower warnings", 0, 0, 1, 0.15);
0339 warning[3]->SetFillStyle(4000);
0340 warning[3]->Draw();
0341 TC[9]->SetEditable(false);
0342 }
0343
0344 return 0;
0345 }
0346
0347 int CemcMonDraw::Draw(const std::string &what)
0348 {
0349 int iret = 0;
0350 int idraw = 0;
0351 if (what == "ALL" || what == "FIRST")
0352 {
0353 iret += DrawFirst(what);
0354 idraw++;
0355 }
0356
0357 if (what == "ALL" || what == "SECOND")
0358 {
0359 iret += DrawSecond(what);
0360 idraw++;
0361 }
0362 if (what == "ALL" || what == "THIRD")
0363 {
0364 iret += DrawThird(what);
0365 idraw++;
0366 }
0367 if (what == "ALL" || what == "FOURTH")
0368 {
0369 iret += DrawFourth(what);
0370 idraw++;
0371 }
0372
0373 if (what == "ALL" || what == "FIFTH")
0374 {
0375 iret += DrawFifth(what);
0376 idraw++;
0377 }
0378
0379
0380
0381
0382
0383
0384
0385 if (what == "ALL" || what == "SERVERSTATS")
0386 {
0387 iret += DrawServerStats();
0388 idraw++;
0389 }
0390 if (what == "ALL" || what == "ALLTRIGHITS")
0391 {
0392 iret += DrawAllTrigHits(what);
0393 idraw++;
0394 }
0395 if (what == "ALL" || what == "BADCHI2")
0396 {
0397 iret += DrawBadChi2(what);
0398 idraw++;
0399 }
0400
0401 if (what == "ALL" || what == "NOISERMS")
0402 {
0403 iret += DrawNoiseRMS(what);
0404 idraw++;
0405 }
0406
0407
0408
0409 if (what == "ALL")
0410 {
0411
0412
0413 iret += DrawSeventh("ALLTRIGZS");
0414 idraw++;
0415 }
0416 if (what == "SEVENTH" || what == "ALLTRIGZS")
0417 {
0418 iret += DrawSeventh(what);
0419 idraw++;
0420 }
0421
0422 if (!idraw)
0423 {
0424 std::cout << __PRETTY_FUNCTION__ << " Unimplemented Drawing option: " << what << std::endl;
0425 iret = -1;
0426 }
0427 if (std::fabs(iret) != idraw)
0428 {
0429 return 0;
0430 }
0431 return iret;
0432 }
0433
0434 int CemcMonDraw::DrawFirst(const std::string & )
0435 {
0436 OnlMonClient *cl = OnlMonClient::instance();
0437
0438
0439 if (!h_cemc_datahits)
0440 {
0441 h_cemc_datahits = new TH2D("h_cemc_datahits", "", 96, 0, 96, 256, 0, 256);
0442 }
0443 else
0444 {
0445 h_cemc_datahits->Reset();
0446 }
0447 TH2 *htmp2d;
0448 int deadservercount = 0;
0449 int Nservers = 0;
0450 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
0451 {
0452 Nservers++;
0453 htmp2d = (TH2 *) cl->getHisto(*server, "h2_cemc_rmhits");
0454
0455 if (htmp2d)
0456 {
0457 h_cemc_datahits->Add(htmp2d);
0458 }
0459 else
0460 {
0461 deadservercount++;
0462 }
0463 }
0464 int avgevents = 0;
0465 int neventhist = 0;
0466 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
0467 {
0468 TH1 *h_eventSource = cl->getHisto(*server, "h1_event");
0469 if (h_eventSource)
0470 {
0471 avgevents += h_eventSource->GetEntries();
0472 neventhist++;
0473 }
0474 }
0475 if (neventhist)
0476 {
0477 avgevents /= neventhist;
0478 }
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550 if (!gROOT->FindObject("CemcMon1"))
0551 {
0552 MakeCanvas("CemcMon1");
0553 }
0554
0555 if (deadservercount == Nservers)
0556 {
0557 DrawDeadServer(transparent[0]);
0558 TC[0]->SetEditable(false);
0559 return -1;
0560 }
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632 TC[0]->SetEditable(true);
0633 TC[0]->Clear("D");
0634 Pad[0]->cd();
0635
0636
0637
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653 h_cemc_datahits->Divide(h2_template_hit);
0654 h_cemc_datahits->GetXaxis()->SetTitle("eta index");
0655 h_cemc_datahits->GetYaxis()->SetTitle("phi index");
0656 h_cemc_datahits->GetZaxis()->SetTitle("Tower Running Mean/Tower reference");
0657 h_cemc_datahits->GetXaxis()->CenterTitle();
0658 h_cemc_datahits->GetYaxis()->CenterTitle();
0659 h_cemc_datahits->GetZaxis()->CenterTitle();
0660 h_cemc_datahits->GetXaxis()->SetNdivisions(12, kFALSE);
0661 h_cemc_datahits->GetYaxis()->SetNdivisions(32, kFALSE);
0662
0663 float tsize = 0.03;
0664 h_cemc_datahits->GetXaxis()->SetLabelSize(tsize);
0665 h_cemc_datahits->GetYaxis()->SetLabelSize(tsize);
0666 h_cemc_datahits->GetYaxis()->SetTitleOffset(1.4);
0667 h_cemc_datahits->GetZaxis()->SetLabelSize(tsize);
0668 h_cemc_datahits->GetXaxis()->SetTitleSize(tsize);
0669 h_cemc_datahits->GetYaxis()->SetTitleSize(tsize);
0670 h_cemc_datahits->GetXaxis()->SetTickLength(0.02);
0671
0672 gPad->SetTopMargin(0.08);
0673 gPad->SetBottomMargin(0.07);
0674 gPad->SetLeftMargin(0.08);
0675 gPad->SetRightMargin(0.12);
0676
0677
0678
0679 Int_t palette[4] = {kBlack, kBlue, 8, 2};
0680 cemcStyle->SetPalette(4, palette);
0681 gROOT->SetStyle("cemcStyle");
0682 gROOT->ForceStyle();
0683 gStyle->SetPalette(4, palette);
0684 double_t levels[5] = {0, 0.01, 0.5, 2, 4};
0685 h_cemc_datahits->GetZaxis()->SetRangeUser(0, 4);
0686 h_cemc_datahits->SetContour(5, levels);
0687 gStyle->SetOptStat(0);
0688 h_cemc_datahits->DrawCopy("colz");
0689
0690 TLine line_sector[32];
0691 for (int i_line = 0; i_line < 32; i_line++)
0692 {
0693 line_sector[i_line] = TLine(0, (i_line + 1) * 8, 96, (i_line + 1) * 8);
0694 line_sector[i_line].SetLineColor(1);
0695 line_sector[i_line].SetLineWidth(1);
0696 line_sector[i_line].SetLineStyle(1);
0697 }
0698
0699 const int numVertDiv = 12;
0700 int dEI = 96 / numVertDiv;
0701 TLine l_board[numVertDiv - 1];
0702 for (int il = 1; il < numVertDiv; il++)
0703 {
0704 l_board[il - 1] = TLine(dEI * il, 0, dEI * il, 256);
0705 l_board[il - 1].SetLineColor(1);
0706 l_board[il - 1].SetLineWidth(1);
0707 l_board[il - 1].SetLineStyle(1);
0708 if (il == 6)
0709 {
0710 l_board[il - 1].SetLineWidth(2);
0711 }
0712 }
0713
0714 for (int i_line = 0; i_line < 32; i_line++)
0715 {
0716 line_sector[i_line].DrawLine(0, (i_line + 1) * 8, 96, (i_line + 1) * 8);
0717 }
0718
0719 for (int il = 1; il < numVertDiv; il++)
0720 {
0721 l_board[il - 1].DrawLine(dEI * il, 0, dEI * il, 256);
0722 }
0723
0724
0725 FindHotTower(warning[0], h_cemc_datahits, true);
0726 TText PrintRun;
0727 PrintRun.SetTextFont(62);
0728 PrintRun.SetTextSize(0.03);
0729 PrintRun.SetNDC();
0730 PrintRun.SetTextAlign(23);
0731 std::ostringstream runnostream;
0732 std::ostringstream runnostream2;
0733 std::ostringstream runnostream3;
0734 std::string runstring;
0735 std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
0736
0737 runnostream << ThisName << ": tower occupancy running mean/template";
0738 runnostream2 << " threshold: 100ADC, Run " << cl->RunNumber() << ", Event: " << avgevents;
0739 runnostream3 << "Time: " << ctime(&evttime.first);
0740
0741 transparent[0]->cd();
0742 runstring = runnostream.str();
0743 PrintRun.SetTextColor(evttime.second);
0744 PrintRun.DrawText(0.5, 0.99, runstring.c_str());
0745 runstring = runnostream2.str();
0746 PrintRun.DrawText(0.5, 0.96, runstring.c_str());
0747 runstring = runnostream3.str();
0748 PrintRun.DrawText(0.5, 0.93, runstring.c_str());
0749
0750 TC[0]->Update();
0751 TC[0]->Show();
0752 TC[0]->SetEditable(false);
0753 if (save)
0754 {
0755 TC[0]->SaveAs("plots/towerHits.pdf");
0756 }
0757 return 0;
0758 }
0759
0760 int CemcMonDraw::DrawAllTrigHits(const std::string & )
0761 {
0762 OnlMonClient *cl = OnlMonClient::instance();
0763
0764
0765 if (!h_cemc_datahits)
0766 {
0767 h_cemc_datahits = new TH2D("h_cemc_datahits", "", 96, 0, 96, 256, 0, 256);
0768 }
0769 else
0770 {
0771 h_cemc_datahits->Reset();
0772 }
0773 TH2 *htmp2d;
0774 int deadservercount = 0;
0775 int Nservers = 0;
0776 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
0777 {
0778 Nservers++;
0779 htmp2d = (TH2 *) cl->getHisto(*server, "h2_cemc_rmhits_alltrig");
0780
0781 if (htmp2d)
0782 {
0783 h_cemc_datahits->Add(htmp2d);
0784 }
0785 else
0786 {
0787 deadservercount++;
0788 }
0789 }
0790 int avgevents = 0;
0791 int neventhist = 0;
0792 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
0793 {
0794 TH1 *h_eventSource = cl->getHisto(*server, "h1_event");
0795 if (h_eventSource)
0796 {
0797 avgevents += h_eventSource->GetEntries();
0798 neventhist++;
0799 }
0800 }
0801 if (neventhist)
0802 {
0803 avgevents /= neventhist;
0804 }
0805
0806 if (!gROOT->FindObject("CemcAllTrigHits"))
0807 {
0808 MakeCanvas("CemcAllTrigHits");
0809 }
0810
0811 if (deadservercount == Nservers)
0812 {
0813 DrawDeadServer(transparent[6]);
0814 TC[6]->SetEditable(false);
0815 return -1;
0816 }
0817
0818 TC[6]->SetEditable(true);
0819 TC[6]->Clear("D");
0820 Pad[15]->cd();
0821
0822 h_cemc_datahits->Divide(h2_template_hit_alltrig);
0823
0824 h_cemc_datahits->GetXaxis()->SetTitle("eta index");
0825 h_cemc_datahits->GetYaxis()->SetTitle("phi index");
0826 h_cemc_datahits->GetZaxis()->SetTitle("Tower Running Mean with all trig");
0827 h_cemc_datahits->GetXaxis()->CenterTitle();
0828 h_cemc_datahits->GetYaxis()->CenterTitle();
0829 h_cemc_datahits->GetZaxis()->CenterTitle();
0830 h_cemc_datahits->GetXaxis()->SetNdivisions(12, kFALSE);
0831 h_cemc_datahits->GetYaxis()->SetNdivisions(32, kFALSE);
0832
0833 float tsize = 0.03;
0834 h_cemc_datahits->GetXaxis()->SetLabelSize(tsize);
0835 h_cemc_datahits->GetYaxis()->SetLabelSize(tsize);
0836 h_cemc_datahits->GetYaxis()->SetTitleOffset(1.4);
0837 h_cemc_datahits->GetZaxis()->SetLabelSize(tsize);
0838 h_cemc_datahits->GetXaxis()->SetTitleSize(tsize);
0839 h_cemc_datahits->GetYaxis()->SetTitleSize(tsize);
0840 h_cemc_datahits->GetXaxis()->SetTickLength(0.02);
0841 h_cemc_datahits->GetZaxis()->SetTitleOffset(1.6);
0842
0843 gPad->SetTopMargin(0.08);
0844 gPad->SetBottomMargin(0.07);
0845 gPad->SetLeftMargin(0.08);
0846 gPad->SetRightMargin(0.2);
0847
0848
0849
0850 Int_t palette[4] = {kBlack, kBlue, 8, 2};
0851 cemcStyle->SetPalette(4, palette);
0852 gROOT->SetStyle("cemcStyle");
0853 gROOT->ForceStyle();
0854 gStyle->SetPalette(4, palette);
0855 double_t levels[5] = {0, 0.01, 0.5, 2, 4};
0856 h_cemc_datahits->GetZaxis()->SetRangeUser(0, 4);
0857 h_cemc_datahits->SetContour(5, levels);
0858
0859 gStyle->SetOptStat(0);
0860 h_cemc_datahits->DrawCopy("colz");
0861
0862 TLine line_sector[32];
0863 for (int i_line = 0; i_line < 32; i_line++)
0864 {
0865 line_sector[i_line] = TLine(0, (i_line + 1) * 8, 96, (i_line + 1) * 8);
0866 line_sector[i_line].SetLineColor(1);
0867 line_sector[i_line].SetLineWidth(1);
0868 line_sector[i_line].SetLineStyle(1);
0869 }
0870
0871 const int numVertDiv = 12;
0872 int dEI = 96 / numVertDiv;
0873 TLine l_board[numVertDiv - 1];
0874 for (int il = 1; il < numVertDiv; il++)
0875 {
0876 l_board[il - 1] = TLine(dEI * il, 0, dEI * il, 256);
0877 l_board[il - 1].SetLineColor(1);
0878 l_board[il - 1].SetLineWidth(1);
0879 l_board[il - 1].SetLineStyle(1);
0880 if (il == 6)
0881 {
0882 l_board[il - 1].SetLineWidth(2);
0883 }
0884 }
0885
0886 for (int i_line = 0; i_line < 32; i_line++)
0887 {
0888 line_sector[i_line].DrawLine(0, (i_line + 1) * 8, 96, (i_line + 1) * 8);
0889 }
0890
0891 for (int il = 1; il < numVertDiv; il++)
0892 {
0893 l_board[il - 1].DrawLine(dEI * il, 0, dEI * il, 256);
0894 }
0895
0896 FindHotTower(warning[2], h_cemc_datahits, true);
0897 TText PrintRun;
0898 PrintRun.SetTextFont(62);
0899 PrintRun.SetTextSize(0.03);
0900 PrintRun.SetNDC();
0901 PrintRun.SetTextAlign(23);
0902 std::ostringstream runnostream;
0903 std::ostringstream runnostream2;
0904 std::ostringstream runnostream3;
0905 std::string runstring;
0906 std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
0907
0908 runnostream << ThisName << ": tower occupancy/template running mean with all trig";
0909 runnostream2 << " threshold: 100ADC, Run " << cl->RunNumber();
0910 runnostream3 << "Time: " << ctime(&evttime.first);
0911
0912 transparent[6]->cd();
0913 runstring = runnostream.str();
0914 PrintRun.SetTextColor(evttime.second);
0915 PrintRun.DrawText(0.5, 0.99, runstring.c_str());
0916 runstring = runnostream2.str();
0917 PrintRun.DrawText(0.5, 0.96, runstring.c_str());
0918 runstring = runnostream3.str();
0919 PrintRun.DrawText(0.5, 0.93, runstring.c_str());
0920
0921 TC[6]->Update();
0922 TC[6]->Show();
0923 TC[6]->SetEditable(false);
0924 if (save)
0925 {
0926 TC[6]->SaveAs("plots/towerHits.pdf");
0927 }
0928 return 0;
0929 }
0930
0931 int CemcMonDraw::DrawNoiseRMS(const std::string & )
0932 {
0933
0934 OnlMonClient *cl = OnlMonClient::instance();
0935
0936
0937 if (!h2_noiserms)
0938 {
0939 h2_noiserms = new TH2D("h2_noiserms", "", 96, 0, 96, 256, 0, 256);
0940 }
0941 else
0942 {
0943 h2_noiserms->Reset();
0944 }
0945 if (!p2_noiserms)
0946 {
0947 p2_noiserms = new TProfile2D("p2_noiserms", "", 96, 0, 96, 256, 0, 256, "S");
0948 }
0949 else
0950 {
0951 p2_noiserms->Reset();
0952 }
0953 TProfile2D *htmp2d;
0954 int deadservercount = 0;
0955 int Nservers = 0;
0956 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
0957 {
0958 Nservers++;
0959 htmp2d = (TProfile2D *) cl->getHisto(*server, "p2_pre_post");
0960
0961 if (htmp2d)
0962 {
0963 p2_noiserms->Add(htmp2d);
0964 }
0965 else
0966 {
0967 deadservercount++;
0968 }
0969 }
0970
0971 if (!gROOT->FindObject("CemcNoiseRMS"))
0972 {
0973 MakeCanvas("CemcNoiseRMS");
0974 }
0975
0976 if (deadservercount == Nservers)
0977 {
0978 DrawDeadServer(transparent[9]);
0979 TC[9]->SetEditable(false);
0980 return -1;
0981 }
0982
0983
0984 for (int i = 1; i <= p2_noiserms->GetNbinsX(); i++)
0985 {
0986 for (int j = 1; j <= p2_noiserms->GetNbinsY(); j++)
0987 {
0988 double error = p2_noiserms->GetBinError(i, j);
0989 h2_noiserms->SetBinContent(i, j, error);
0990 }
0991 }
0992
0993 TC[9]->SetEditable(true);
0994 TC[9]->Clear("D");
0995 Pad[22]->cd();
0996
0997 h2_noiserms->GetXaxis()->SetTitle("eta index");
0998 h2_noiserms->GetYaxis()->SetTitle("phi index");
0999 h2_noiserms->GetZaxis()->SetTitle("Tower Noise RMS with all trig");
1000 h2_noiserms->GetXaxis()->CenterTitle();
1001 h2_noiserms->GetYaxis()->CenterTitle();
1002 h2_noiserms->GetZaxis()->CenterTitle();
1003 h2_noiserms->GetXaxis()->SetNdivisions(12, kFALSE);
1004 h2_noiserms->GetYaxis()->SetNdivisions(32, kFALSE);
1005
1006 float tsize = 0.03;
1007 h2_noiserms->GetXaxis()->SetLabelSize(tsize);
1008 h2_noiserms->GetYaxis()->SetLabelSize(tsize);
1009 h2_noiserms->GetYaxis()->SetTitleOffset(1.4);
1010 h2_noiserms->GetZaxis()->SetLabelSize(tsize);
1011 h2_noiserms->GetXaxis()->SetTitleSize(tsize);
1012 h2_noiserms->GetYaxis()->SetTitleSize(tsize);
1013 h2_noiserms->GetXaxis()->SetTickLength(0.02);
1014 h2_noiserms->GetZaxis()->SetTitleOffset(1.6);
1015
1016 gPad->SetTopMargin(0.08);
1017 gPad->SetBottomMargin(0.07);
1018 gPad->SetLeftMargin(0.08);
1019 gPad->SetRightMargin(0.2);
1020
1021 gStyle->SetPalette(57);
1022 h2_noiserms->GetZaxis()->SetRangeUser(0, 100);
1023
1024 gStyle->SetOptStat(0);
1025 h2_noiserms->DrawCopy("colz");
1026 TLine line_sector[32];
1027 for (int i_line = 0; i_line < 32; i_line++)
1028 {
1029 line_sector[i_line] = TLine(0, (i_line + 1) * 8, 96, (i_line + 1) * 8);
1030 line_sector[i_line].SetLineColor(1);
1031 line_sector[i_line].SetLineWidth(1);
1032 line_sector[i_line].SetLineStyle(1);
1033 }
1034
1035 const int numVertDiv = 12;
1036 int dEI = 96 / numVertDiv;
1037 TLine l_board[numVertDiv - 1];
1038 for (int il = 1; il < numVertDiv; il++)
1039 {
1040 l_board[il - 1] = TLine(dEI * il, 0, dEI * il, 256);
1041 l_board[il - 1].SetLineColor(1);
1042 l_board[il - 1].SetLineWidth(1);
1043 l_board[il - 1].SetLineStyle(1);
1044 if (il == 6)
1045 {
1046 l_board[il - 1].SetLineWidth(2);
1047 }
1048 }
1049
1050 for (int i_line = 0; i_line < 32; i_line++)
1051 {
1052 line_sector[i_line].DrawLine(0, (i_line + 1) * 8, 96, (i_line + 1) * 8);
1053 }
1054
1055 for (int il = 1; il < numVertDiv; il++)
1056 {
1057 l_board[il - 1].DrawLine(dEI * il, 0, dEI * il, 256);
1058 }
1059 FindGainMode(warning[3], h2_noiserms);
1060
1061 TText PrintRun;
1062 PrintRun.SetTextFont(62);
1063 PrintRun.SetTextSize(0.03);
1064 PrintRun.SetNDC();
1065 PrintRun.SetTextAlign(23);
1066 std::ostringstream runnostream;
1067 std::ostringstream runnostream2;
1068 std::ostringstream runnostream3;
1069 std::string runstring;
1070 std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1071
1072 runnostream << ThisName << ": tower negative post - pre RMS all trig";
1073 runnostream2 << "Run " << cl->RunNumber();
1074 runnostream3 << "Time: " << ctime(&evttime.first);
1075
1076 transparent[9]->cd();
1077 runstring = runnostream.str();
1078 PrintRun.SetTextColor(evttime.second);
1079 PrintRun.DrawText(0.5, 0.99, runstring.c_str());
1080 runstring = runnostream2.str();
1081 PrintRun.DrawText(0.5, 0.96, runstring.c_str());
1082 runstring = runnostream3.str();
1083 PrintRun.DrawText(0.5, 0.93, runstring.c_str());
1084
1085 TC[9]->Update();
1086 TC[9]->Show();
1087 TC[9]->SetEditable(false);
1088 if (save)
1089 {
1090 TC[9]->SaveAs("plots/towerNoiseRMS.pdf");
1091 }
1092 return 0;
1093 }
1094
1095 int CemcMonDraw::DrawSecond(const std::string & )
1096 {
1097 OnlMonClient *cl = OnlMonClient::instance();
1098 gStyle->SetOptStat(0);
1099 TH1 *h_event[m_ServerSet.size()];
1100 TH1 *h_eventSource[m_ServerSet.size()];
1101 int start[4];
1102 start[0] = -1;
1103 float maxEvent = -1;
1104 int i = 0;
1105 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1106 {
1107 h_eventSource[i] = cl->getHisto(*server, "h1_event");
1108 if (h_eventSource[i] && start[0] == -1)
1109 {
1110 start[0] = i;
1111 }
1112 if (start[0] > -1 && h_eventSource[i])
1113 {
1114 h_event[i] = (TH1 *) h_eventSource[i]->Clone();
1115 h_event[i]->SetName(Form("h1_event_%d", i));
1116 if ( h_event[i]->GetEntries() > maxEvent)
1117 {
1118
1119 maxEvent = h_event[i]->GetEntries();
1120 }
1121 }
1122 i++;
1123 }
1124
1125 TH1 *h1_packet_number[m_ServerSet.size()];
1126 start[1] = -1;
1127 i = 0;
1128 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1129 {
1130 h1_packet_number[i] = cl->getHisto(*server, "h1_packet_number");
1131 if (h1_packet_number[i] && start[1] == -1)
1132 {
1133 start[1] = i;
1134 }
1135 if (start[1] > -1 && h1_packet_number[i])
1136 {
1137 h1_packet_number[i]->SetName(Form("h1_papcket_number_%d", i));
1138 if (i != start[1])
1139 {
1140 h1_packet_number[start[1]]->Add(h1_packet_number[i], 1);
1141 }
1142 }
1143 i++;
1144 }
1145
1146 TH1 *h1_packet_length[m_ServerSet.size()];
1147 start[2] = -1;
1148 i = 0;
1149 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1150 {
1151 h1_packet_length[i] = cl->getHisto(*server, "h1_packet_length");
1152 if (h1_packet_length[i] && start[2] == -1)
1153 {
1154 start[2] = i;
1155 }
1156 if (start[2] > -1 && h1_packet_length[i])
1157 {
1158 h1_packet_length[i]->SetName(Form("h1_papcket_length_%d", i));
1159 if (i != start[2])
1160 {
1161 h1_packet_length[start[2]]->Add(h1_packet_length[i], 1);
1162 }
1163 }
1164 i++;
1165 }
1166
1167 TH1 *h1_packet_chans[m_ServerSet.size()];
1168 start[3] = -1;
1169 i = 0;
1170 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1171 {
1172 h1_packet_chans[i] = cl->getHisto(*server, "h1_packet_chans");
1173 if (h1_packet_chans[i] && start[3] == -1)
1174 {
1175 start[3] = i;
1176 }
1177 if (start[3] > -1 && h1_packet_chans[i])
1178 {
1179 h1_packet_chans[i]->SetName(Form("h1_papcket_chans_%d", i));
1180 if (i != start[3])
1181 {
1182 h1_packet_chans[start[3]]->Add(h1_packet_chans[i], 1);
1183 }
1184 }
1185 i++;
1186 }
1187
1188 if (start[0] < 0 || start[1] < 0 || start[2] < 0)
1189 {
1190 DrawDeadServer(transparent[1]);
1191 TC[1]->SetEditable(false);
1192 return -1;
1193 }
1194
1195
1196
1197 if (maxEvent > 0)
1198 {
1199
1200
1201
1202 h1_packet_number[start[1]]->Scale(1. / maxEvent);
1203 h1_packet_length[start[2]]->Scale(1. / maxEvent);
1204 h1_packet_chans[start[3]]->Scale(1. / maxEvent);
1205 }
1206
1207 if (!gROOT->FindObject("CemcMon2"))
1208 {
1209 MakeCanvas("CemcMon2");
1210 }
1211
1212 TC[1]->SetEditable(true);
1213 TC[1]->Clear("D");
1214
1215 TLine *one = new TLine(6000.5, 1, 6128.5, 1);
1216 one->SetLineStyle(7);
1217
1218 TLine *goodSize = new TLine(6000.5, 1565, 6128.5, 1565);
1219 goodSize->SetLineStyle(7);
1220
1221 TLine *goodChans = new TLine(6000.5, 192, 6128.5, 192);
1222 goodChans->SetLineStyle(7);
1223
1224 float param = 0.95;
1225
1226
1227 TLegend *leg = new TLegend(0.3, 0.20, 0.95, 0.50);
1228 leg->SetFillStyle(0);
1229 leg->SetBorderSize(0);
1230
1231 TLine *warnLineOne = new TLine(6000.5, param * 1, 6128.5, param * 1);
1232 warnLineOne->SetLineStyle(7);
1233 warnLineOne->SetLineColor(2);
1234
1235 leg->AddEntry(warnLineOne, Form("%g%% Threshold", param * 100), "l");
1236
1237 TLine *warnLineOneS = new TLine(6000.5, param * 1, 6128.5, param * 1);
1238 warnLineOneS->SetLineStyle(10);
1239 warnLineOneS->SetLineColor(2);
1240
1241 leg->AddEntry(warnLineOneS, Form("%g%% Threshold, High Eta, South", 100 * param), "l");
1242
1243 TLine *warnLineSize = new TLine(6000.5, param * 5981., 6128.5, param * 5981.);
1244 warnLineSize->SetLineStyle(7);
1245 warnLineSize->SetLineColor(2);
1246
1247 TLine *warnLineSizeS = new TLine(6000.5, param * 3991., 6128.5, param * 3991.);
1248 warnLineSizeS->SetLineStyle(10);
1249 warnLineSizeS->SetLineColor(2);
1250
1251 TLine *warnLineChans = new TLine(6000.5, param * 192., 6128.5, param * 192.);
1252 warnLineChans->SetLineStyle(7);
1253 warnLineChans->SetLineColor(2);
1254
1255 TLine *warnLineChansS = new TLine(6000.5, param * 128., 6128.5, param * 128.);
1256 warnLineChansS->SetLineStyle(10);
1257 warnLineChansS->SetLineColor(2);
1258
1259 Pad[1]->cd();
1260 float tsize = 0.08;
1261 h1_packet_number[start[1]]->GetYaxis()->SetRangeUser(0.0, 1.3);
1262 std::vector<std::vector<int>> badPackets;
1263 badPackets.push_back(getBadPackets(h1_packet_number[start[1]], 0, param));
1264
1265 h1_packet_number[start[1]]->GetXaxis()->SetNdivisions(510, kTRUE);
1266 h1_packet_number[start[1]]->GetXaxis()->SetTitle("packet #");
1267 h1_packet_number[start[1]]->GetYaxis()->SetTitle("% Of Events Present");
1268 h1_packet_number[start[1]]->GetXaxis()->SetLabelSize(tsize - 0.01);
1269 h1_packet_number[start[1]]->GetYaxis()->SetLabelSize(tsize - 0.01);
1270 h1_packet_number[start[1]]->GetXaxis()->SetTitleSize(tsize - 0.01);
1271 h1_packet_number[start[1]]->GetYaxis()->SetTitleSize(tsize - 0.01);
1272 h1_packet_number[start[1]]->GetXaxis()->SetTitleOffset(1);
1273 gPad->SetBottomMargin(0.16);
1274 gPad->SetLeftMargin(0.16);
1275 gPad->SetRightMargin(0.05);
1276 gPad->SetLeftMargin(0.15);
1277 gPad->SetTicky();
1278 gPad->SetTickx();
1279 h1_packet_number[start[1]]->DrawCopy("hist");
1280 one->Draw("same");
1281 warnLineOne->Draw("same");
1282 leg->Draw("same");
1283
1284 Pad[2]->cd();
1285 badPackets.push_back(getBadPackets(h1_packet_length[start[2]], 1, 0));
1286
1287 h1_packet_length[start[2]]->GetXaxis()->SetNdivisions(510, kTRUE);
1288 h1_packet_length[start[2]]->GetXaxis()->SetTitle("packet #");
1289 h1_packet_length[start[2]]->GetYaxis()->SetTitle("Average Packet Size");
1290 h1_packet_length[start[2]]->GetXaxis()->SetLabelSize(tsize - .01);
1291 h1_packet_length[start[2]]->GetYaxis()->SetLabelSize(tsize);
1292 h1_packet_length[start[2]]->GetXaxis()->SetTitleSize(tsize - .01);
1293 h1_packet_length[start[2]]->GetYaxis()->SetTitleSize(tsize);
1294 h1_packet_length[start[2]]->GetXaxis()->SetTitleOffset(1);
1295 h1_packet_length[start[2]]->GetYaxis()->SetTitleOffset(0.9);
1296 h1_packet_length[start[2]]->GetYaxis()->SetRangeUser(0, 4000);
1297 gPad->SetBottomMargin(0.16);
1298 gPad->SetLeftMargin(0.16);
1299 gPad->SetRightMargin(0.05);
1300 gPad->SetLeftMargin(0.15);
1301 gPad->SetTicky();
1302 gPad->SetTickx();
1303 h1_packet_length[start[2]]->DrawCopy("hist");
1304 goodSize->Draw("same");
1305
1306
1307
1308 Pad[3]->cd();
1309 h1_packet_chans[start[3]]->GetYaxis()->SetRangeUser(0, 212);
1310 badPackets.push_back(getBadPackets(h1_packet_chans[start[3]], 2, param));
1311 h1_packet_chans[start[3]]->GetXaxis()->SetNdivisions(510, kTRUE);
1312 h1_packet_chans[start[3]]->GetXaxis()->SetTitle("packet #");
1313 h1_packet_chans[start[3]]->GetYaxis()->SetTitle("Average # of Channels");
1314 h1_packet_chans[start[3]]->GetXaxis()->SetLabelSize(tsize - .01);
1315 h1_packet_chans[start[3]]->GetYaxis()->SetLabelSize(tsize);
1316 h1_packet_chans[start[3]]->GetXaxis()->SetTitleSize(tsize - .01);
1317 h1_packet_chans[start[3]]->GetYaxis()->SetTitleSize(tsize);
1318 h1_packet_chans[start[3]]->GetXaxis()->SetTitleOffset(0.8);
1319 h1_packet_chans[start[3]]->GetYaxis()->SetTitleOffset(0.8);
1320 gPad->SetBottomMargin(0.16);
1321 gPad->SetLeftMargin(0.16);
1322 gPad->SetRightMargin(0.05);
1323 gPad->SetLeftMargin(0.15);
1324 gPad->SetTicky();
1325 gPad->SetTickx();
1326 h1_packet_chans[start[3]]->DrawCopy("hist");
1327 goodChans->Draw("same");
1328 warnLineChans->Draw("same");
1329 warnLineChansS->Draw("same");
1330
1331 warning[1]->cd();
1332 TLegend *badPacks = new TLegend(0, 1 / 4., 1, 0.9);
1333 TPaveText *title = new TPaveText(0, 0.9, 1, 0.95);
1334 title->AddText("Bad Packets");
1335 badPacks->SetNColumns(8);
1336 badPacks->SetTextSize(0.03);
1337 float badboys = 0;
1338 if (maxEvent > 0)
1339 {
1340 for (int k = 0; k < 3; k++)
1341 {
1342 for (int j = 0; j < (int) badPackets[k].size(); j++)
1343 {
1344
1345
1346 if (badPackets[k][j] == 0)
1347 {
1348 continue;
1349 }
1350
1351 if (k == 0)
1352 {
1353 badPacks->AddEntry("", Form("%d", badPackets[k][j]), "");
1354 badboys++;
1355 }
1356 else if (k == 1)
1357 {
1358 if (!(std::count(badPackets[k - 1].begin(), badPackets[k - 1].end(), badPackets[k][j])))
1359 {
1360 badPacks->AddEntry("", Form("%d", badPackets[k].at(j)), "");
1361 badboys++;
1362 }
1363 }
1364 else if (k == 2)
1365 {
1366 if (!(std::count(badPackets[k - 1].begin(), badPackets[k - 1].end(), badPackets[k][j])))
1367 {
1368 badPacks->AddEntry("", Form("%d", badPackets[k].at(j)), "");
1369 badboys++;
1370 }
1371 if (!(std::count(badPackets[k - 2].begin(), badPackets[k - 2].end(), badPackets[k][j])) && !(std::count(badPackets[k - 1].begin(), badPackets[k - 1].end(), badPackets[k][j])))
1372 {
1373 badPacks->AddEntry("", Form("%d", badPackets[k].at(j)), "");
1374 badboys++;
1375 }
1376 }
1377 }
1378 }
1379 }
1380 badPacks->Draw();
1381 title->Draw();
1382 TPaveText *desc = new TPaveText(0, 0, 1, 0.25);
1383 desc->AddText(Form("Currently %.2g%% of packets are reporting a problem", badboys / 128. * 100));
1384 desc->AddText("Packets will be reported bad as above for the following reasons:");
1385 desc->AddText(Form("A packet appears in less than %g %% of events", param * 100));
1386
1387 desc->AddText(Form("A packet sees fewer than %g %% of 192 channels", param * 100));
1388 desc->Draw();
1389 TText PrintRun;
1390 PrintRun.SetTextFont(62);
1391 PrintRun.SetTextSize(0.02);
1392 PrintRun.SetNDC();
1393 PrintRun.SetTextAlign(23);
1394 std::ostringstream runnostream;
1395 std::string runstring;
1396 std::ostringstream runnostream2;
1397 std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1398
1399
1400 runnostream << "Packet Information";
1401 runnostream2 << " Run " << cl->RunNumber() << ", Time: " << ctime(&evttime.first);
1402 transparent[1]->cd();
1403
1404 runstring = runnostream.str();
1405 PrintRun.SetTextColor(evttime.second);
1406 PrintRun.DrawText(0.5, .99, runstring.c_str());
1407
1408 runstring = runnostream2.str();
1409 PrintRun.DrawText(0.5, .966, runstring.c_str());
1410 TC[1]->Update();
1411 TC[1]->Show();
1412 TC[1]->SetEditable(false);
1413 if (save)
1414 {
1415 TC[1]->SaveAs("plots/packets.pdf");
1416 }
1417 return 0;
1418 }
1419
1420 int CemcMonDraw::DrawThird(const std::string & )
1421 {
1422 OnlMonClient *cl = OnlMonClient::instance();
1423
1424 TH2 *h2_waveform_twrAvg[m_ServerSet.size()];
1425 int start[3];
1426 start[0] = -1;
1427 int i = 0;
1428 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1429 {
1430 h2_waveform_twrAvg[i] = (TH2 *) cl->getHisto(*server, "h2_waveform_twrAvg");
1431 if (h2_waveform_twrAvg[i] && start[0] == -1)
1432 {
1433 start[0] = i;
1434 }
1435 if (start[0] > -1 && h2_waveform_twrAvg[i])
1436 {
1437 h2_waveform_twrAvg[i]->SetName(Form("h2_waveform_twrAvg_%d", i));
1438 h2_waveform_twrAvg[start[0]]->Add(h2_waveform_twrAvg[i], 1);
1439 }
1440 i++;
1441 }
1442
1443 TH1 *h1_waveform_time[m_ServerSet.size()];
1444 start[1] = -1;
1445 i = 0;
1446 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1447 {
1448 h1_waveform_time[i] = cl->getHisto(*server, "h1_waveform_time");
1449 if (h1_waveform_time[i] && start[1] == -1)
1450 {
1451 start[1] = i;
1452 }
1453 if (start[1] > -1 && h1_waveform_time[i])
1454 {
1455 h1_waveform_time[i]->SetName(Form("h1_waveform_time_%d", i));
1456 h1_waveform_time[start[1]]->Add(h1_waveform_time[i], 1);
1457 }
1458 i++;
1459 }
1460
1461 TH1 *h1_waveform_pedestal[m_ServerSet.size()];
1462 start[2] = -1;
1463 i = 0;
1464 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1465 {
1466 h1_waveform_pedestal[i] = cl->getHisto(*server, "h1_waveform_pedestal");
1467
1468 if (h1_waveform_pedestal[i] && start[2] == -1)
1469 {
1470 start[2] = i;
1471 }
1472 if (start[2] > -1 && h1_waveform_pedestal[i])
1473 {
1474 h1_waveform_pedestal[i]->SetName(Form("h1_waveform_pedestal_%d", i));
1475 h1_waveform_pedestal[start[2]]->Add(h1_waveform_pedestal[i], 1);
1476 }
1477 i++;
1478 }
1479
1480 if (!gROOT->FindObject("CemcMon3"))
1481 {
1482 MakeCanvas("CemcMon3");
1483 }
1484
1485 TC[2]->SetEditable(true);
1486 TC[2]->Clear("D");
1487 Pad[4]->cd();
1488 if (start[0] < 0 || start[1] < 0 || start[2] < 0)
1489 {
1490 DrawDeadServer(transparent[2]);
1491 TC[2]->SetEditable(false);
1492 return -1;
1493 }
1494 std::cout << "start drawing" << std::endl;
1495 gStyle->SetTitleFontSize(0.03);
1496 TProfile *profiled = h2_waveform_twrAvg[start[0]]->ProfileX();
1497 float ymaxp = profiled->GetMaximum();
1498 ymaxp = ymaxp * 20 > pow(2, 14) ? pow(2, 14) : 20 * ymaxp;
1499 h2_waveform_twrAvg[start[0]]->GetYaxis()->SetRangeUser(0, ymaxp);
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544 float tsize = 0.06;
1545 float tsize2 = 0.08;
1546
1547 h2_waveform_twrAvg[start[0]]->GetXaxis()->SetNdivisions(16);
1548 h2_waveform_twrAvg[start[0]]->GetXaxis()->SetTitle("sample #");
1549 h2_waveform_twrAvg[start[0]]->GetYaxis()->SetTitle("Waveform ADC [ADC]");
1550 h2_waveform_twrAvg[start[0]]->GetXaxis()->SetLabelSize(tsize2);
1551 h2_waveform_twrAvg[start[0]]->GetYaxis()->SetLabelSize(tsize2 - .01);
1552 h2_waveform_twrAvg[start[0]]->GetXaxis()->SetTitleSize(tsize2);
1553 h2_waveform_twrAvg[start[0]]->GetYaxis()->SetTitleSize(tsize);
1554 h2_waveform_twrAvg[start[0]]->GetXaxis()->SetTitleOffset(1.);
1555 h2_waveform_twrAvg[start[0]]->GetYaxis()->SetTitleOffset(1.25);
1556
1557 h2_waveform_twrAvg[start[0]]->GetYaxis()->SetRangeUser(0, ymaxp);
1558
1559 gStyle->SetOptStat(0);
1560 gPad->SetBottomMargin(0.16);
1561 gPad->SetLeftMargin(0.16);
1562 gPad->SetRightMargin(0.05);
1563 gPad->SetLeftMargin(0.15);
1564 gPad->SetTicky();
1565 gPad->SetTickx();
1566 gStyle->SetPalette(kBird);
1567 h2_waveform_twrAvg[start[0]]->DrawCopy("colz");
1568
1569
1570
1571
1572
1573
1574
1575
1576 TLine windowLow1(SampleLowBoundary, 0, SampleLowBoundary, ymaxp);
1577 windowLow1.SetLineWidth(3);
1578 windowLow1.DrawLine(SampleLowBoundary, 0, SampleLowBoundary, ymaxp);
1579
1580 TLine windowHigh1(SampleHighBoundary, 0, SampleHighBoundary, ymaxp);
1581 windowHigh1.SetLineWidth(3);
1582 windowHigh1.DrawLine(SampleHighBoundary, 0, SampleHighBoundary, ymaxp);
1583
1584 gStyle->SetPalette(57);
1585 gPad->SetLogz();
1586
1587 TText PrintRun;
1588 PrintRun.SetTextFont(62);
1589 PrintRun.SetTextSize(0.03);
1590 PrintRun.SetNDC();
1591 PrintRun.SetTextAlign(23);
1592 std::ostringstream runnostream;
1593 std::ostringstream runnostream2;
1594 std::string runstring;
1595 std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1596
1597 runnostream << ThisName << ": Pulse fitting";
1598 runnostream2 << "Run " << cl->RunNumber() << ", Time: " << ctime(&evttime.first);
1599
1600 transparent[2]->cd();
1601
1602 runstring = runnostream.str();
1603 PrintRun.SetTextColor(evttime.second);
1604 PrintRun.DrawText(0.5, 0.99, runstring.c_str());
1605
1606 runstring = runnostream2.str();
1607 PrintRun.DrawText(0.5, 0.966, runstring.c_str());
1608
1609 Pad[5]->cd();
1610 gPad->SetTopMargin(0.06);
1611 gPad->SetBottomMargin(0.18);
1612 gPad->SetRightMargin(0.05);
1613 gPad->SetLeftMargin(0.15);
1614 gPad->SetTicky();
1615 gPad->SetTickx();
1616
1617 gStyle->SetTitleFontSize(0.06);
1618
1619 h1_waveform_time[start[1]]->SetStats(kFALSE);
1620 h1_waveform_time[start[1]]->Draw("hist");
1621 h1_waveform_time[start[1]]->GetXaxis()->SetNdivisions(16);
1622 h1_waveform_time[start[1]]->GetXaxis()->SetTitle("Sample #");
1623 h1_waveform_time[start[1]]->GetYaxis()->SetTitle("Fraction of Towers");
1624 h1_waveform_time[start[1]]->GetXaxis()->SetLabelSize(tsize2);
1625 h1_waveform_time[start[1]]->GetYaxis()->SetLabelSize(tsize2);
1626 h1_waveform_time[start[1]]->GetXaxis()->SetTitleSize(tsize2);
1627 h1_waveform_time[start[1]]->GetYaxis()->SetTitleSize(tsize2);
1628 h1_waveform_time[start[1]]->GetXaxis()->SetTitleOffset(1.0);
1629 h1_waveform_time[start[1]]->GetYaxis()->SetTitleOffset(.85);
1630 h1_waveform_time[start[1]]->SetFillColorAlpha(kBlue, 0.1);
1631 gPad->Update();
1632 if (h1_waveform_time[start[1]]->GetEntries())
1633 {
1634 h1_waveform_time[start[1]]->Scale(1. / h1_waveform_time[start[1]]->GetEntries());
1635 }
1636 h1_waveform_time[start[1]]->GetYaxis()->SetRangeUser(0, 1.);
1637
1638 gPad->SetTopMargin(0.06);
1639 gPad->SetBottomMargin(0.18);
1640 gPad->SetRightMargin(0.05);
1641 gStyle->SetOptStat(0);
1642 gPad->SetLeftMargin(0.15);
1643 gPad->SetTicky();
1644 gPad->SetTickx();
1645 TLine windowLow2(SampleLowBoundary, 0, SampleLowBoundary, gPad->GetFrame()->GetY2());
1646 windowLow2.SetLineWidth(3);
1647 windowLow2.DrawLine(SampleLowBoundary, 0, SampleLowBoundary, gPad->GetFrame()->GetY2());
1648
1649 TLine windowHigh2(SampleHighBoundary, 0, SampleHighBoundary, gPad->GetFrame()->GetY2());
1650 windowHigh2.SetLineWidth(3);
1651 windowHigh2.DrawLine(SampleHighBoundary, 0, SampleHighBoundary, gPad->GetFrame()->GetY2());
1652
1653 TLine meantime(h1_waveform_time[start[1]]->GetMean(), 0, h1_waveform_time[start[1]]->GetMean(), gPad->GetFrame()->GetY2());
1654 meantime.SetLineWidth(3);
1655 meantime.SetLineColor(kRed);
1656 meantime.DrawLine(h1_waveform_time[start[1]]->GetMean(), 0, h1_waveform_time[start[1]]->GetMean(), gPad->GetFrame()->GetY2());
1657
1658 Pad[6]->cd();
1659 gPad->SetTopMargin(0.06);
1660 gPad->SetBottomMargin(0.18);
1661 gPad->SetRightMargin(0.05);
1662 gPad->SetLeftMargin(0.15);
1663 gPad->SetTicky();
1664 gPad->SetTickx();
1665
1666 gPad->SetLogy(kFALSE);
1667 gStyle->SetTitleFontSize(0.06);
1668 h1_waveform_pedestal[start[2]]->SetStats(false);
1669 h1_waveform_pedestal[start[2]]->Draw("hist");
1670 h1_waveform_pedestal[start[2]]->GetXaxis()->SetNdivisions(505, kTRUE);
1671 h1_waveform_pedestal[start[2]]->GetXaxis()->SetTitle("ADC Pedestal");
1672 h1_waveform_pedestal[start[2]]->GetYaxis()->SetTitle("Fraction of Towers");
1673 h1_waveform_pedestal[start[2]]->GetXaxis()->SetLabelSize(tsize2);
1674 h1_waveform_pedestal[start[2]]->GetYaxis()->SetLabelSize(tsize2);
1675 h1_waveform_pedestal[start[2]]->GetXaxis()->SetTitleSize(tsize2);
1676 h1_waveform_pedestal[start[2]]->GetYaxis()->SetTitleSize(tsize2);
1677 h1_waveform_pedestal[start[2]]->GetXaxis()->SetTitleOffset(1);
1678 h1_waveform_pedestal[start[2]]->GetYaxis()->SetTitleOffset(0.85);
1679 h1_waveform_pedestal[start[2]]->SetFillColorAlpha(kBlue, 0.1);
1680 gPad->Update();
1681
1682 TLine windowLow3(1000, 0, 1000, gPad->GetFrame()->GetY2());
1683 windowLow3.SetLineWidth(3);
1684 windowLow3.DrawLine(1000, 0, 1000, gPad->GetFrame()->GetY2());
1685
1686 TLine windowHigh3(2000, 0, 2000, gPad->GetFrame()->GetY2());
1687 windowHigh3.SetLineWidth(3);
1688 windowHigh3.DrawLine(2000, 0, 2000, gPad->GetFrame()->GetY2());
1689
1690 gPad->SetLogy();
1691 gPad->Update();
1692
1693 if (h1_waveform_pedestal[start[2]]->GetEntries())
1694 {
1695 h1_waveform_pedestal[start[2]]->Scale(1. / h1_waveform_pedestal[start[2]]->GetEntries());
1696 }
1697
1698 gStyle->SetOptStat(0);
1699
1700 TC[2]->Update();
1701
1702
1703 TC[2]->Show();
1704
1705
1706 TC[2]->SetEditable(false);
1707
1708
1709 if (save)
1710 {
1711 TC[2]->SaveAs("plots/waveform.pdf");
1712 }
1713
1714
1715 return 0;
1716 }
1717
1718 int CemcMonDraw::DrawFourth(const std::string & )
1719 {
1720 OnlMonClient *cl = OnlMonClient::instance();
1721
1722 TH1 *h_waveform_sigDiff[m_ServerSet.size()];
1723 int start[3];
1724 start[0] = -1;
1725 int i = 0;
1726 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1727 {
1728 h_waveform_sigDiff[i] = cl->getHisto(*server, "h1_fitting_sigDiff");
1729 if (h_waveform_sigDiff[i] && start[0] == -1)
1730 {
1731 start[0] = i;
1732 }
1733 if (start[0] > -1 && h_waveform_sigDiff[i])
1734 {
1735 h_waveform_sigDiff[i]->SetName(Form("h_fitting_sigDiff_%d", i));
1736 h_waveform_sigDiff[start[0]]->Add(h_waveform_sigDiff[i], 1);
1737 }
1738 i++;
1739 }
1740
1741 TH1 *h_waveform_pedDiff[m_ServerSet.size()];
1742 start[1] = -1;
1743 i = 0;
1744 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1745 {
1746 h_waveform_pedDiff[i] = cl->getHisto(*server, "h1_fitting_pedDiff");
1747 if (h_waveform_pedDiff[i] && start[1] == -1)
1748 {
1749 start[1] = i;
1750 }
1751 if (start[1] > -1 && h_waveform_pedDiff[i])
1752 {
1753 h_waveform_pedDiff[i]->SetName(Form("h_fitting_pedDiff_%d", i));
1754 h_waveform_pedDiff[start[1]]->Add(h_waveform_pedDiff[i], 1);
1755 }
1756 i++;
1757 }
1758
1759 TH1 *h_waveform_timeDiff[m_ServerSet.size()];
1760 start[2] = -1;
1761 i = 0;
1762 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1763 {
1764 h_waveform_timeDiff[i] = cl->getHisto(*server, "h1_fitting_timeDiff");
1765 if (h_waveform_timeDiff[i] && start[2] == -1)
1766 {
1767 start[2] = i;
1768 }
1769 if (start[2] > -1 && h_waveform_timeDiff[i])
1770 {
1771 h_waveform_timeDiff[i]->SetName(Form("h_fitting_timeDiff_%d", i));
1772 h_waveform_timeDiff[start[2]]->Add(h_waveform_timeDiff[i], 1);
1773 }
1774 i++;
1775 }
1776
1777 if (!gROOT->FindObject("CemcMon4"))
1778 {
1779 MakeCanvas("CemcMon4");
1780 }
1781
1782 TC[3]->SetEditable(true);
1783 TC[3]->Clear("D");
1784 if (start[0] < 0 || start[1] < 0 || start[2] < 0)
1785 {
1786 DrawDeadServer(transparent[3]);
1787 TC[3]->SetEditable(false);
1788 return -1;
1789 }
1790
1791 gStyle->SetTitleFontSize(0.03);
1792
1793 TText PrintRun;
1794 PrintRun.SetTextFont(62);
1795 PrintRun.SetTextSize(0.03);
1796 PrintRun.SetNDC();
1797 PrintRun.SetTextAlign(23);
1798 std::ostringstream runnostream;
1799 std::ostringstream runnostream2;
1800 std::string runstring;
1801 std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1802
1803 runnostream << "Waveform Template vs. Fast Fitting";
1804 runnostream2 << "Run " << cl->RunNumber() << ", Time: " << ctime(&evttime.first);
1805
1806 transparent[3]->cd();
1807
1808 runstring = runnostream.str();
1809 PrintRun.SetTextColor(evttime.second);
1810 PrintRun.DrawText(0.5, 0.99, runstring.c_str());
1811
1812 runstring = runnostream2.str();
1813 PrintRun.DrawText(0.5, 0.966, runstring.c_str());
1814
1815 Pad[7]->cd();
1816
1817 gStyle->SetTitleFontSize(0.06);
1818
1819 float tsize2 = 0.08;
1820 h_waveform_sigDiff[start[0]]->GetXaxis()->SetNdivisions(16);
1821 h_waveform_sigDiff[start[0]]->GetXaxis()->SetTitle("Fast ADC/Template ADC");
1822 h_waveform_sigDiff[start[0]]->GetYaxis()->SetTitle("Fraction of Towers");
1823 h_waveform_sigDiff[start[0]]->GetXaxis()->SetLabelSize(tsize2 - .01);
1824 h_waveform_sigDiff[start[0]]->GetYaxis()->SetLabelSize(tsize2 - .01);
1825 h_waveform_sigDiff[start[0]]->GetXaxis()->SetTitleSize(tsize2 - .01);
1826 h_waveform_sigDiff[start[0]]->GetYaxis()->SetTitleSize(tsize2 - .01);
1827 h_waveform_sigDiff[start[0]]->GetXaxis()->SetTitleOffset(.9);
1828 h_waveform_sigDiff[start[0]]->GetYaxis()->SetTitleOffset(1.1);
1829 if (h_waveform_sigDiff[start[0]]->GetEntries())
1830 {
1831 h_waveform_sigDiff[start[0]]->Scale(1. / h_waveform_sigDiff[start[0]]->GetEntries());
1832 }
1833 gPad->SetTopMargin(0.06);
1834 gPad->SetBottomMargin(0.18);
1835 gPad->SetRightMargin(0.05);
1836 gPad->SetLeftMargin(0.15);
1837 gStyle->SetOptStat(0);
1838 gPad->SetTicky();
1839 gPad->SetTickx();
1840 h_waveform_sigDiff[start[0]]->DrawCopy("hist");
1841
1842 Pad[8]->cd();
1843
1844 gStyle->SetTitleFontSize(0.06);
1845
1846 h_waveform_pedDiff[start[1]]->GetXaxis()->SetNdivisions(16);
1847 h_waveform_pedDiff[start[1]]->GetXaxis()->SetTitle("Fast Pedestal/Template Pedestal");
1848 h_waveform_pedDiff[start[1]]->GetYaxis()->SetTitle("Fraction of Towers");
1849 h_waveform_pedDiff[start[1]]->GetXaxis()->SetLabelSize(tsize2);
1850 h_waveform_pedDiff[start[1]]->GetYaxis()->SetLabelSize(tsize2);
1851 h_waveform_pedDiff[start[1]]->GetXaxis()->SetTitleSize(tsize2);
1852 h_waveform_pedDiff[start[1]]->GetYaxis()->SetTitleSize(tsize2);
1853 h_waveform_pedDiff[start[1]]->GetXaxis()->SetTitleOffset(0.9);
1854 h_waveform_pedDiff[start[1]]->GetYaxis()->SetTitleOffset(0.9);
1855 if (h_waveform_pedDiff[start[1]]->GetEntries())
1856 {
1857 h_waveform_pedDiff[start[1]]->Scale(1. / h_waveform_pedDiff[start[1]]->GetEntries());
1858 }
1859 gPad->SetTopMargin(0.06);
1860 gPad->SetBottomMargin(0.18);
1861 gPad->SetRightMargin(0.05);
1862 gPad->SetLeftMargin(0.15);
1863 gStyle->SetOptStat(0);
1864 gPad->SetTicky();
1865 gPad->SetTickx();
1866 h_waveform_pedDiff[start[1]]->DrawCopy("hist");
1867
1868 Pad[9]->cd();
1869
1870 h_waveform_timeDiff[start[2]]->GetXaxis()->SetNdivisions(16);
1871 h_waveform_timeDiff[start[2]]->GetXaxis()->SetTitle("Fast Peak Time - Template Peak Time");
1872 h_waveform_timeDiff[start[2]]->GetYaxis()->SetTitle("Fraction of Towers");
1873 h_waveform_timeDiff[start[2]]->GetXaxis()->SetLabelSize(tsize2);
1874 h_waveform_timeDiff[start[2]]->GetYaxis()->SetLabelSize(tsize2);
1875 h_waveform_timeDiff[start[2]]->GetXaxis()->SetTitleSize(tsize2);
1876 h_waveform_timeDiff[start[2]]->GetYaxis()->SetTitleSize(tsize2);
1877 h_waveform_timeDiff[start[2]]->GetXaxis()->SetTitleOffset(0.9);
1878 h_waveform_timeDiff[start[2]]->GetYaxis()->SetTitleOffset(0.9);
1879 if (h_waveform_timeDiff[start[2]]->GetEntries())
1880 {
1881 h_waveform_timeDiff[start[2]]->Scale(1. / h_waveform_timeDiff[start[2]]->GetEntries());
1882 }
1883 gPad->SetTopMargin(0.06);
1884 gPad->SetBottomMargin(0.18);
1885 gPad->SetRightMargin(0.05);
1886 gPad->SetLeftMargin(0.15);
1887 gPad->SetTicky();
1888 gPad->SetTickx();
1889 h_waveform_timeDiff[start[2]]->DrawCopy("hist");
1890
1891 TC[3]->Update();
1892 TC[3]->Show();
1893 TC[3]->SetEditable(false);
1894 gStyle->SetOptStat(0);
1895 if (save)
1896 {
1897 TC[3]->SaveAs("plots/waveformExpert.pdf");
1898 }
1899 return 0;
1900 }
1901
1902 int CemcMonDraw::DrawFifth(const std::string & )
1903 {
1904 OnlMonClient *cl = OnlMonClient::instance();
1905
1906 TH2 *h_cemc_hits_trig[64][m_ServerSet.size()];
1907 int start_trig[64] = {-1};
1908 for (int i = 1; i < 64; i++)
1909 {
1910 start_trig[i] = -1;
1911 }
1912 int i = 0;
1913
1914 for (int itrig = 0; itrig < 64; itrig++)
1915 {
1916 i = 0;
1917
1918 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1919 {
1920 h_cemc_hits_trig[itrig][i] = (TH2 *) cl->getHisto(*server, Form("h2_cemc_hits_trig_bit_%d", itrig));
1921 if (h_cemc_hits_trig[itrig][i] && start_trig[itrig] == -1)
1922 {
1923 start_trig[itrig] = i;
1924 }
1925 if (start_trig[itrig] > -1 && h_cemc_hits_trig[itrig][i])
1926 {
1927 h_cemc_hits_trig[itrig][i]->SetName(Form("h_cemc_hits_trig_bit_%d_%d", itrig, i));
1928 if (start_trig[itrig] != i)
1929 {
1930 h_cemc_hits_trig[itrig][start_trig[itrig]]->Add(h_cemc_hits_trig[itrig][i], 1);
1931 }
1932 }
1933 i++;
1934 }
1935 }
1936
1937 TH1 *h_cemc_trig[m_ServerSet.size()];
1938 int start = -1;
1939 i = 0;
1940 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1941 {
1942 h_cemc_trig[i] = cl->getHisto(*server, "h1_cemc_trig");
1943 if (h_cemc_trig[i] && start == -1)
1944 {
1945 start = i;
1946 }
1947 if (start > -1 && h_cemc_trig[i])
1948 {
1949 h_cemc_trig[i]->SetName(Form("h_cemc_trig_%d", i));
1950 if (start != i)
1951 {
1952 h_cemc_trig[start]->Add(h_cemc_trig[i], 1);
1953 }
1954 }
1955 i++;
1956 }
1957
1958 TProfile *h_evtRec;
1959 i = 0;
1960 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
1961 {
1962 h_evtRec = (TProfile *) cl->getHisto(*server, "h_evtRec");
1963 if (h_evtRec)
1964 {
1965 break;
1966 }
1967 }
1968
1969 if (!gROOT->FindObject("CemcMon5"))
1970 {
1971 MakeCanvas("CemcMon5");
1972 }
1973
1974 TC[4]->SetEditable(true);
1975 TC[4]->Clear("D");
1976 if (!h_cemc_trig[start])
1977 {
1978 DrawDeadServer(transparent[4]);
1979 TC[4]->SetEditable(false);
1980 return -1;
1981 }
1982
1983 for (int itrig = 0; itrig < 64; itrig++)
1984 {
1985 if (!h_cemc_hits_trig[itrig][start_trig[itrig]])
1986 {
1987 DrawDeadServer(transparent[4]);
1988 TC[4]->SetEditable(false);
1989 return -1;
1990 }
1991 }
1992
1993
1994 std::vector<std::pair<float, int>> n_entries;
1995
1996 for (int itrig = 0; itrig < 64; itrig++)
1997 {
1998 n_entries.push_back(std::make_pair(h_cemc_hits_trig[itrig][start_trig[itrig]]->GetEntries(), itrig));
1999 }
2000
2001
2002 std::sort(n_entries.begin(), n_entries.end());
2003
2004 std::reverse(n_entries.begin(), n_entries.end());
2005
2006
2007 std::vector<int> priority_triggers;
2008
2009 for (int itrig = 0; itrig < 64; itrig++)
2010 {
2011
2012
2013 if (n_entries[itrig].second == TriggerEnum::BitCodes::PHOTON6_MBD_NS2 ||
2014 n_entries[itrig].second == TriggerEnum::BitCodes::PHOTON8_MBD_NS2 ||
2015 n_entries[itrig].second == TriggerEnum::BitCodes::PHOTON10_MBD_NS2 ||
2016 n_entries[itrig].second == TriggerEnum::BitCodes::PHOTON12_MBD_NS2 || n_entries[itrig].second == TriggerEnum::BitCodes::HCAL_SINGLES || n_entries[itrig].second == TriggerEnum::BitCodes::HCAL_NARROW_VERT || n_entries[itrig].second == TriggerEnum::BitCodes::HCAL_WIDE_VERT || n_entries[itrig].second == TriggerEnum::BitCodes::HCAL_NARROW_HORZ || n_entries[itrig].second == TriggerEnum::BitCodes::HCAL_WIDE_HORZ)
2017 {
2018 if (n_entries[itrig].first > 0. && priority_triggers.size() < 4)
2019 {
2020 priority_triggers.push_back(n_entries[itrig].second);
2021 }
2022 }
2023 }
2024
2025
2026 if (priority_triggers.size() < 4)
2027 {
2028 for (int itrig = 0; itrig < 64; itrig++)
2029 {
2030 if (priority_triggers.size() < 4 && n_entries[itrig].second < TriggerEnum::BitCodes::PHOTON12_MBD_NS2)
2031 {
2032 priority_triggers.push_back(n_entries[itrig].second);
2033 }
2034 }
2035 }
2036
2037 TText PrintRun;
2038 PrintRun.SetTextFont(62);
2039 PrintRun.SetTextSize(0.03);
2040 PrintRun.SetNDC();
2041 PrintRun.SetTextAlign(23);
2042 std::ostringstream runnostream;
2043 std::string runstring;
2044 std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2045
2046 runnostream << ThisName << ": Trigger Info, Run" << cl->RunNumber()
2047 << ", Time: " << ctime(&evttime.first);
2048 runstring = runnostream.str();
2049 transparent[4]->cd();
2050 PrintRun.SetTextColor(evttime.second);
2051 PrintRun.DrawText(0.5, 0.99, runstring.c_str());
2052
2053 Pad[10]->cd();
2054 gStyle->SetTitleFontSize(0.06);
2055
2056 float tsize = 0.08;
2057 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->GetXaxis()->SetNdivisions(510, kTRUE);
2058 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->GetXaxis()->SetTitle(Form("(trigger bit %d) ieta", priority_triggers[0]));
2059 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->GetYaxis()->SetTitle("iphi");
2060 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->GetXaxis()->SetLabelSize(tsize);
2061 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->GetYaxis()->SetLabelSize(tsize);
2062 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->GetXaxis()->SetTitleSize(tsize);
2063 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->GetYaxis()->SetTitleSize(tsize);
2064 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->GetXaxis()->SetTitleOffset(1.2);
2065 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->GetYaxis()->SetTitleOffset(0.75);
2066 gPad->SetLogz();
2067 gPad->SetTopMargin(0.06);
2068 gPad->SetBottomMargin(0.18);
2069 gPad->SetRightMargin(0.05);
2070 gPad->SetLeftMargin(0.15);
2071 gStyle->SetOptStat(0);
2072 gStyle->SetPalette(57);
2073 gPad->SetTicky();
2074 gPad->SetTickx();
2075 h_cemc_hits_trig[priority_triggers[0]][start_trig[priority_triggers[0]]]->Draw("colz");
2076
2077 Pad[11]->cd();
2078 gStyle->SetTitleFontSize(0.06);
2079
2080 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->GetXaxis()->SetNdivisions(510, kTRUE);
2081 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->GetXaxis()->SetTitle(Form("(trigger bit %d) ieta", priority_triggers[1]));
2082 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->GetYaxis()->SetTitle("iphi");
2083 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->GetXaxis()->SetLabelSize(tsize);
2084 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->GetYaxis()->SetLabelSize(tsize);
2085 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->GetXaxis()->SetTitleSize(tsize);
2086 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->GetYaxis()->SetTitleSize(tsize);
2087 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->GetXaxis()->SetTitleOffset(1.2);
2088 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->GetYaxis()->SetTitleOffset(0.75);
2089 gPad->SetLogz();
2090 gPad->SetTopMargin(0.06);
2091 gPad->SetBottomMargin(0.18);
2092 gPad->SetRightMargin(0.05);
2093 gPad->SetLeftMargin(0.15);
2094 gStyle->SetOptStat(0);
2095 gStyle->SetPalette(57);
2096 gPad->SetTicky();
2097 gPad->SetTickx();
2098 h_cemc_hits_trig[priority_triggers[1]][start_trig[priority_triggers[1]]]->Draw("colz");
2099
2100 Pad[12]->cd();
2101 gStyle->SetTitleFontSize(0.06);
2102
2103 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->GetXaxis()->SetNdivisions(510, kTRUE);
2104 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->GetXaxis()->SetTitle(Form("(trigger bit %d) ieta", priority_triggers[2]));
2105 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->GetYaxis()->SetTitle("iphi");
2106 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->GetXaxis()->SetLabelSize(tsize);
2107 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->GetYaxis()->SetLabelSize(tsize);
2108 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->GetXaxis()->SetTitleSize(tsize);
2109 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->GetYaxis()->SetTitleSize(tsize);
2110 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->GetXaxis()->SetTitleOffset(1.2);
2111 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->GetYaxis()->SetTitleOffset(0.75);
2112 gPad->SetLogz();
2113 gPad->SetTopMargin(0.06);
2114 gPad->SetBottomMargin(0.18);
2115 gPad->SetRightMargin(0.05);
2116 gPad->SetLeftMargin(0.15);
2117 gStyle->SetOptStat(0);
2118 gStyle->SetPalette(57);
2119 gPad->SetTicky();
2120 gPad->SetTickx();
2121 h_cemc_hits_trig[priority_triggers[2]][start_trig[priority_triggers[2]]]->Draw("colz");
2122
2123 Pad[13]->cd();
2124 gStyle->SetTitleFontSize(0.06);
2125
2126 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->GetXaxis()->SetNdivisions(510, kTRUE);
2127 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->GetXaxis()->SetTitle(Form("(trigger bit %d) ieta", priority_triggers[3]));
2128 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->GetYaxis()->SetTitle("iphi");
2129 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->GetXaxis()->SetLabelSize(tsize);
2130 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->GetYaxis()->SetLabelSize(tsize);
2131 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->GetXaxis()->SetTitleSize(tsize);
2132 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->GetYaxis()->SetTitleSize(tsize);
2133 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->GetXaxis()->SetTitleOffset(1.2);
2134 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->GetYaxis()->SetTitleOffset(0.75);
2135 gPad->SetLogz();
2136 gPad->SetTopMargin(0.06);
2137 gPad->SetBottomMargin(0.18);
2138 gPad->SetRightMargin(0.05);
2139 gPad->SetLeftMargin(0.15);
2140 gStyle->SetOptStat(0);
2141 gStyle->SetPalette(57);
2142 gPad->SetTicky();
2143 gPad->SetTickx();
2144 h_cemc_hits_trig[priority_triggers[3]][start_trig[priority_triggers[3]]]->Draw("colz");
2145
2146 Pad[14]->cd();
2147 gStyle->SetTitleFontSize(0.06);
2148
2149 float nEvtRec = 0.;
2150
2151 if (h_evtRec)
2152 {
2153 nEvtRec = h_evtRec->GetBinContent(1);
2154 }
2155
2156 h_cemc_trig[start]->SetTitle(Form("Receiving %0.3f of events from event reciever", nEvtRec));
2157 h_cemc_trig[start]->GetXaxis()->SetNdivisions(510, kTRUE);
2158 h_cemc_trig[start]->GetXaxis()->SetTitle("trigger index");
2159 h_cemc_trig[start]->GetYaxis()->SetTitle("events");
2160 h_cemc_trig[start]->GetXaxis()->SetLabelSize(tsize);
2161 h_cemc_trig[start]->GetYaxis()->SetLabelSize(tsize);
2162 h_cemc_trig[start]->GetXaxis()->SetTitleSize(tsize);
2163 h_cemc_trig[start]->GetYaxis()->SetTitleSize(tsize);
2164 h_cemc_trig[start]->GetXaxis()->SetTitleOffset(0.9);
2165 h_cemc_trig[start]->GetYaxis()->SetTitleOffset(0.85);
2166 gPad->SetTopMargin(0.06);
2167 gPad->SetBottomMargin(0.18);
2168 gPad->SetRightMargin(0.05);
2169 gPad->SetLeftMargin(0.15);
2170 gStyle->SetOptStat(0);
2171 gPad->SetTicky();
2172 gPad->SetTickx();
2173 h_cemc_trig[start]->Draw("histo");
2174
2175 TC[4]->Update();
2176 TC[4]->Show();
2177 TC[4]->SetEditable(false);
2178
2179 return 0;
2180 }
2181 int CemcMonDraw::FindGainMode(TPad *warningpad, TH2 *hhit)
2182 {
2183 float avgrms = 0;
2184 float totaltowers = 0;
2185
2186 for (int ieta = 0; ieta < nTowersEta; ieta++)
2187 {
2188 for (int iphi = 0; iphi < nTowersPhi; iphi++)
2189 {
2190 if (hhit->GetBinContent(ieta + 1, iphi + 1) == 0)
2191 {
2192 continue;
2193 }
2194 double rms = hhit->GetBinContent(ieta + 1, iphi + 1);
2195 avgrms += rms;
2196 totaltowers += 1;
2197 }
2198 }
2199 avgrms /= totaltowers;
2200
2201 bool hg = false;
2202 if (avgrms > 100)
2203 {
2204 hg = true;
2205 }
2206
2207 warningpad->cd();
2208 std::string gainmode = "Gain mode: LOW";
2209 if (hg)
2210 {
2211 gainmode = "Gain mode: HIGH";
2212 }
2213
2214 TText warn;
2215 warn.SetTextFont(62);
2216 warn.SetTextSize(0.3);
2217 warn.SetTextColor(kRed);
2218 warn.SetNDC();
2219 warn.SetTextAlign(23);
2220 warn.DrawText(0.5, 0.5, gainmode.c_str());
2221
2222 warn.SetTextFont(62);
2223 warn.SetTextSize(0.06);
2224 warn.SetTextColor(1);
2225 warn.SetNDC();
2226 warn.SetTextAlign(23);
2227 warn.DrawText(0.5, 0.9, "Average RMS of pedestal:");
2228 warn.DrawText(0.5, 0.8, Form("%.2f", avgrms));
2229
2230 warningpad->Update();
2231 return 0;
2232 }
2233
2234 int CemcMonDraw::FindHotTower(TPad *warningpad, TH2 *hhit, bool usetemplate)
2235 {
2236 float nhott = 0;
2237 float ndeadt = 0;
2238 float ncoldt = 0;
2239 int displaylimit = 10;
2240 std::ostringstream hottowerlist;
2241 std::ostringstream deadtowerlist;
2242 std::ostringstream coldtowerlist;
2243 float hot_threshold = 2.0;
2244 float dead_threshold = 0.01;
2245 float cold_threshold = 0.5;
2246 if (!usetemplate)
2247 {
2248 float mean = 0;
2249 float rms = 0;
2250 int ntower = 0;
2251 for (int ieta = 0; ieta < nTowersEta; ieta++)
2252 {
2253 for (int iphi = 0; iphi < nTowersPhi; iphi++)
2254 {
2255 if ((ieta < 40 && ieta >= 32) && ((iphi >= 144) && (iphi < 152)))
2256 {
2257 continue;
2258 }
2259 else if ((ieta < 64 && ieta >= 56) && ((iphi >= 32) && (iphi < 40)))
2260 {
2261 continue;
2262 }
2263 if (hhit->GetBinContent(ieta + 1, iphi + 1) == 0)
2264 {
2265 continue;
2266 }
2267 double nhit = hhit->GetBinContent(ieta + 1, iphi + 1);
2268 mean += nhit;
2269 rms += nhit * nhit;
2270 ntower++;
2271 }
2272 }
2273 mean /= ntower;
2274 rms = sqrt(rms / ntower - mean * mean);
2275 hot_threshold = mean + 10 * rms;
2276 cold_threshold = mean - 3 * rms;
2277 dead_threshold = 0.01 * mean;
2278 }
2279
2280
2281 for (int ieta = 0; ieta < nTowersEta; ieta++)
2282 {
2283 for (int iphi = 0; iphi < nTowersPhi; iphi++)
2284 {
2285 if ((ieta < 40 && ieta >= 32) && ((iphi >= 144) && (iphi < 152)))
2286 {
2287 continue;
2288 }
2289 else if ((ieta < 64 && ieta >= 56) && ((iphi >= 32) && (iphi < 40)))
2290 {
2291 continue;
2292 }
2293 if (hhit->GetBinContent(ieta + 1, iphi + 1) == 0)
2294 {
2295 continue;
2296 }
2297 double nhit = hhit->GetBinContent(ieta + 1, iphi + 1);
2298
2299 if (nhit > hot_threshold)
2300 {
2301 if (nhott <= displaylimit)
2302 {
2303 hottowerlist << " (" << ieta << "," << iphi << ")";
2304 }
2305 nhott++;
2306 }
2307
2308 if (nhit < dead_threshold)
2309 {
2310 if (ndeadt <= displaylimit)
2311 {
2312 deadtowerlist << " (" << ieta << "," << iphi << ")";
2313 }
2314 ndeadt++;
2315 }
2316 else if (nhit < cold_threshold)
2317 {
2318 if (ncoldt <= displaylimit)
2319 {
2320 coldtowerlist << " (" << ieta << "," << iphi << ")";
2321 }
2322 ncoldt++;
2323 }
2324 }
2325 }
2326
2327 if (nhott > displaylimit)
2328 {
2329 hottowerlist << "... " << nhott << " total";
2330 }
2331 if (ndeadt > displaylimit)
2332 {
2333 deadtowerlist << "... " << ndeadt << " total";
2334 }
2335 if (ncoldt > displaylimit)
2336 {
2337 coldtowerlist << "... " << ncoldt << " total";
2338 }
2339 if (nhott == 0)
2340 {
2341 hottowerlist << " None";
2342 }
2343 if (ndeadt == 0)
2344 {
2345 deadtowerlist << " None";
2346 }
2347 if (ncoldt == 0)
2348 {
2349 coldtowerlist << " None";
2350 }
2351
2352 warningpad->cd();
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372 TText warn;
2373 warn.SetTextFont(62);
2374 warn.SetTextSize(0.09);
2375 warn.SetTextColor(2);
2376 warn.SetNDC();
2377 warn.SetTextAlign(23);
2378 warn.DrawText(0.5, 0.9, "Hot towers (ieta,iphi):");
2379 warn.DrawText(0.5, 0.8, hottowerlist.str().c_str());
2380
2381 warn.SetTextColor(1);
2382 warn.SetTextAlign(23);
2383 warn.DrawText(0.5, 0.3, "Dead towers (ieta,iphi):");
2384 warn.DrawText(0.5, 0.2, deadtowerlist.str().c_str());
2385
2386 warn.SetTextColor(4);
2387 warn.SetTextAlign(23);
2388 warn.DrawText(0.5, 0.6, "Cold towers (ieta,iphi):");
2389 warn.DrawText(0.5, 0.5, coldtowerlist.str().c_str());
2390
2391 warningpad->Update();
2392 return 0;
2393 }
2394
2395 int CemcMonDraw::SavePlot(const std::string &what, const std::string &type)
2396 {
2397 OnlMonClient *cl = OnlMonClient::instance();
2398 int iret = Draw(what);
2399 if (iret)
2400 {
2401 return iret;
2402 }
2403 int icnt = 0;
2404 for (TCanvas *canvas : TC)
2405 {
2406 if (canvas == nullptr)
2407 {
2408 continue;
2409 }
2410 icnt++;
2411 std::string filename = ThisName + "_" + std::to_string(icnt) + "_" +
2412 std::to_string(cl->RunNumber()) + "." + type;
2413 cl->CanvasToPng(canvas, filename);
2414 }
2415 return 0;
2416 }
2417
2418 int CemcMonDraw::MakeHtml(const std::string &what)
2419 {
2420 int iret = Draw(what);
2421 if (iret)
2422 {
2423 return iret;
2424 }
2425
2426 OnlMonClient *cl = OnlMonClient::instance();
2427
2428 int icnt = 0;
2429 for (TCanvas *canvas : TC)
2430 {
2431 if (canvas == nullptr)
2432 {
2433 continue;
2434 }
2435 icnt++;
2436
2437 std::string pngfile = cl->htmlRegisterPage(*this, canvas->GetTitle(), std::to_string(icnt), "png");
2438 cl->CanvasToPng(canvas, pngfile);
2439 }
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456 return 0;
2457 }
2458
2459 std::vector<int> CemcMonDraw::getBadPackets(TH1 *hist, int what, float cutoff)
2460 {
2461 float params[3] = {1., 5981., 192.};
2462 float params2[3] = {1., 3991., 128.};
2463
2464 std::vector<int> badpacks = {0};
2465 std::vector<int> uninPackets = {6022, 6026, 6030, 6034, 6038, 6042};
2466
2467 for (int i = 1; i < hist->GetNbinsX(); i++)
2468 {
2469 if (std::count(uninPackets.begin(), uninPackets.end(), i + 6000))
2470 {
2471 if ((hist->GetBinContent(i) < params2[what] * cutoff || hist->GetBinContent(i) > params2[what]))
2472 {
2473 badpacks.push_back(i + 6000);
2474 }
2475 }
2476 else
2477 {
2478 if ((hist->GetBinContent(i) < params[what] * cutoff || hist->GetBinContent(i) > params[what]))
2479 {
2480 badpacks.push_back(i + 6000);
2481 }
2482 }
2483 }
2484
2485
2486
2487
2488
2489 return badpacks;
2490 }
2491
2492 int CemcMonDraw::DrawServerStats()
2493 {
2494 OnlMonClient *cl = OnlMonClient::instance();
2495 if (!gROOT->FindObject("CemcMonServerStats"))
2496 {
2497 MakeCanvas("CemcMonServerStats");
2498 }
2499 TC[5]->Clear("D");
2500 TC[5]->SetEditable(true);
2501 transparent[5]->cd();
2502 TText PrintRun;
2503 PrintRun.SetTextFont(62);
2504 PrintRun.SetNDC();
2505 PrintRun.SetTextAlign(23);
2506 PrintRun.SetTextSize(0.04);
2507 PrintRun.SetTextColor(1);
2508 PrintRun.DrawText(0.5, 0.99, "Server Statistics");
2509
2510 PrintRun.SetTextSize(0.02);
2511 double vdist = 0.04;
2512 double vpos = 0.92;
2513 for (const auto &server : m_ServerSet)
2514 {
2515 std::ostringstream txt;
2516 auto servermapiter = cl->GetServerMap(server);
2517 if (servermapiter == cl->GetServerMapEnd())
2518 {
2519 txt << "Server " << server
2520 << " is dead ";
2521 PrintRun.SetTextColor(kRed);
2522 }
2523 else
2524 {
2525 int gl1counts = std::get<4>(servermapiter->second);
2526 txt << "Server " << server
2527 << ", run number " << std::get<1>(servermapiter->second)
2528 << ", event count: " << std::get<2>(servermapiter->second);
2529 if (gl1counts >= 0)
2530 {
2531 txt << ", gl1 count: " << std::get<4>(servermapiter->second);
2532 }
2533 txt << ", current time " << ctime(&(std::get<3>(servermapiter->second)));
2534 if (std::get<0>(servermapiter->second))
2535 {
2536 PrintRun.SetTextColor(kGray + 2);
2537 }
2538 else
2539 {
2540 PrintRun.SetTextColor(kRed);
2541 }
2542 }
2543 PrintRun.DrawText(0.5, vpos, txt.str().c_str());
2544 vpos -= vdist;
2545 }
2546 TC[5]->Update();
2547 TC[5]->Show();
2548 TC[5]->SetEditable(false);
2549
2550 return 0;
2551 }
2552
2553 int CemcMonDraw::DrawBadChi2(const std::string & )
2554 {
2555 OnlMonClient *cl = OnlMonClient::instance();
2556 if (!gROOT->FindObject("CemcBadChi2"))
2557 {
2558 MakeCanvas("CemcBadChi2");
2559 }
2560 TC[8]->Clear("D");
2561 TC[8]->SetEditable(true);
2562 transparent[8]->cd();
2563
2564 TText PrintRun;
2565 PrintRun.SetTextFont(62);
2566 PrintRun.SetTextSize(0.03);
2567 PrintRun.SetNDC();
2568 PrintRun.SetTextAlign(23);
2569 std::ostringstream runnostream;
2570 std::ostringstream runnostream2;
2571 std::string runstring;
2572 std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2573
2574 runnostream << "Tower with bad chi2";
2575 runnostream2 << "Run " << cl->RunNumber() << ", Time: " << ctime(&evttime.first);
2576
2577 runstring = runnostream.str();
2578 PrintRun.SetTextColor(evttime.second);
2579 PrintRun.DrawText(0.5, 0.99, runstring.c_str());
2580
2581 runstring = runnostream2.str();
2582 PrintRun.DrawText(0.5, 0.966, runstring.c_str());
2583
2584 TProfile2D *p2_bad_chi2 = nullptr;
2585 TProfile2D *proftmp;
2586 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
2587 {
2588 proftmp = (TProfile2D *) cl->getHisto(*server, "p2_bad_chi2");
2589 if (proftmp)
2590 {
2591 if (p2_bad_chi2)
2592 {
2593 p2_bad_chi2->Add(proftmp);
2594 }
2595 else
2596 {
2597 p2_bad_chi2 = proftmp;
2598 }
2599 }
2600 }
2601 Pad[21]->cd();
2602 std::vector<std::pair<int, int>> badchi2;
2603
2604 for (int i = 1; i <= p2_bad_chi2->GetNbinsX(); i++)
2605 {
2606 for (int j = 1; j <= p2_bad_chi2->GetNbinsY(); j++)
2607 {
2608 float bad_chi2_prob = p2_bad_chi2->GetBinContent(i, j);
2609 if (bad_chi2_prob > 0.5)
2610 {
2611
2612 badchi2.push_back(std::make_pair(i - 1, j - 1));
2613 }
2614 }
2615 }
2616
2617 double vdist = 0.04;
2618 double vpos = 0.92;
2619 int displayedTowers = 0;
2620 TText printChi2;
2621 printChi2.SetTextFont(62);
2622 printChi2.SetNDC();
2623 printChi2.SetTextAlign(23);
2624 printChi2.SetTextSize(0.04);
2625 printChi2.SetTextColor(1);
2626 for (const auto &[x, y] : badchi2)
2627 {
2628 bool ifknownbad = false;
2629 for (const auto &[i, j] : hotChannels)
2630 {
2631 if (i == x && j == y)
2632 {
2633 ifknownbad = true;
2634 break;
2635 }
2636 }
2637 float badChi2Rate = p2_bad_chi2->GetBinContent(x + 1, y + 1);
2638 std::ostringstream txt;
2639 txt << "Tower(" << x << "," << y << "): bad chi2 rate=" << badChi2Rate;
2640
2641 if (ifknownbad)
2642 {
2643 printChi2.SetTextColor(kRed);
2644 }
2645 else
2646 {
2647 printChi2.SetTextColor(kBlack);
2648 }
2649
2650 printChi2.DrawText(0.5, vpos, txt.str().c_str());
2651
2652 vpos -= vdist;
2653 displayedTowers++;
2654 if (vpos < 0.1) break;
2655 }
2656
2657 int remainingTowers = badchi2.size() - displayedTowers;
2658 if (remainingTowers > 0)
2659 {
2660
2661 std::ostringstream moreTxt;
2662 moreTxt << "And " << remainingTowers << " more...";
2663 printChi2.DrawText(0.5, 0.05, moreTxt.str().c_str());
2664 }
2665
2666 TC[8]->Update();
2667 TC[8]->Show();
2668 TC[8]->SetEditable(false);
2669
2670 return 0;
2671 }
2672
2673 int CemcMonDraw::DrawSeventh(const std::string &what)
2674 {
2675 OnlMonClient *cl = OnlMonClient::instance();
2676
2677
2678
2679 TProfile2D *p2_zsFrac_etaphiCombined = nullptr;
2680 TProfile2D *proftmp;
2681 for (auto server = ServerBegin(); server != ServerEnd(); ++server)
2682 {
2683 if (what == "SEVENTH")
2684 {
2685 proftmp = (TProfile2D *) cl->getHisto(*server, "p2_zsFrac_etaphi");
2686 }
2687 else
2688 {
2689 proftmp = (TProfile2D *) cl->getHisto(*server, "p2_zsFrac_etaphi_all");
2690 }
2691 if (proftmp)
2692 {
2693 if (p2_zsFrac_etaphiCombined)
2694 {
2695 p2_zsFrac_etaphiCombined->Add(proftmp);
2696 }
2697 else
2698 {
2699 p2_zsFrac_etaphiCombined = proftmp;
2700 }
2701 }
2702 }
2703
2704 if (!gROOT->FindObject("CemcMon8"))
2705 {
2706 MakeCanvas("CemcMon8");
2707 }
2708 TC[7]->SetEditable(true);
2709 TC[7]->Clear("D");
2710 if (what == "SEVENTH")
2711 {
2712 TC[7]->SetTitle("Channel unsuppressed event fraction");
2713 }
2714 else
2715 {
2716 TC[7]->SetTitle("Channel unsuppressed event fraction (all triggers)");
2717 }
2718 if (!p2_zsFrac_etaphiCombined)
2719 {
2720 DrawDeadServer(transparent[7]);
2721 TC[7]->SetEditable(false);
2722 return -1;
2723 }
2724
2725 Pad[19]->cd();
2726
2727 double sum = 0;
2728 int count = 0;
2729
2730
2731 h1_zs->Reset();
2732 h1_zs_low->Reset();
2733 h1_zs_high->Reset();
2734
2735 for (int i = 1; i <= p2_zsFrac_etaphiCombined->GetNbinsX(); i++)
2736 {
2737 for (int j = 1; j <= p2_zsFrac_etaphiCombined->GetNbinsY(); j++)
2738 {
2739 float rate = p2_zsFrac_etaphiCombined->GetBinContent(i + 1, j + 1);
2740 if (rate <= 0.05)
2741 {
2742 h1_zs_low->Fill(rate);
2743 }
2744 else if (rate > 0.8)
2745 {
2746 h1_zs_high->Fill(rate);
2747 }
2748
2749 h1_zs->Fill(rate);
2750
2751 sum += rate;
2752 count++;
2753 }
2754 }
2755
2756 double maxx = (sum / count) * 5 > 1.1 ? 1.1 : (sum / count) * 5;
2757 h1_zs->GetXaxis()->SetRangeUser(0, maxx);
2758
2759
2760
2761
2762 double averagezs = sum / count * 100;
2763
2764 gPad->SetTopMargin(0.02);
2765 gPad->SetBottomMargin(0.12);
2766 gPad->SetLeftMargin(0.12);
2767 gPad->SetRightMargin(0.12);
2768 gStyle->SetTitleFontSize(0.06);
2769 gStyle->SetPalette(57);
2770
2771 gStyle->SetNumberContours(255);
2772 p2_zsFrac_etaphiCombined->GetXaxis()->SetTitle("eta index");
2773 p2_zsFrac_etaphiCombined->GetYaxis()->SetTitle("phi index");
2774 p2_zsFrac_etaphiCombined->SetTitle(Form("Average unsuppressed rate: %.3f%%", averagezs));
2775 p2_zsFrac_etaphiCombined->GetXaxis()->SetLabelSize(0.05);
2776 p2_zsFrac_etaphiCombined->GetYaxis()->SetLabelSize(0.05);
2777 p2_zsFrac_etaphiCombined->GetXaxis()->SetTitleSize(0.05);
2778 p2_zsFrac_etaphiCombined->GetYaxis()->SetTitleSize(0.05);
2779 p2_zsFrac_etaphiCombined->GetXaxis()->SetTitleOffset(1.0);
2780 p2_zsFrac_etaphiCombined->GetYaxis()->SetTitleOffset(1.0);
2781 p2_zsFrac_etaphiCombined->SetMinimum(0);
2782 p2_zsFrac_etaphiCombined->SetMaximum(1);
2783 p2_zsFrac_etaphiCombined->SetStats(kFALSE);
2784 p2_zsFrac_etaphiCombined->DrawCopy("colz");
2785
2786 Pad[20]->cd();
2787 gStyle->SetTitleFontSize(0.06);
2788 float tsize = 0.08;
2789 h1_zs->Draw();
2790 h1_zs->GetXaxis()->SetTitle("unsuppressed fraction");
2791 h1_zs->GetYaxis()->SetTitle("towers");
2792 h1_zs->GetXaxis()->SetLabelSize(tsize);
2793 h1_zs->GetYaxis()->SetLabelSize(tsize);
2794 h1_zs->GetXaxis()->SetTitleSize(tsize);
2795 h1_zs->GetYaxis()->SetTitleSize(tsize);
2796 h1_zs->GetXaxis()->SetTitleOffset(0.9);
2797 h1_zs->GetYaxis()->SetTitleOffset(0.85);
2798 h1_zs->GetXaxis()->SetNdivisions(510, kTRUE);
2799 h1_zs->SetFillColorAlpha(kBlue, 0.1);
2800 h1_zs_low->SetFillColorAlpha(kRed, 0.1);
2801 h1_zs_high->SetFillColorAlpha(kYellow, 0.1);
2802 h1_zs_low->Draw("same");
2803 h1_zs_high->Draw("same");
2804 gPad->SetBottomMargin(0.16);
2805 gPad->SetLeftMargin(0.15);
2806 gPad->SetRightMargin(0.15);
2807 gPad->SetTopMargin(0.1);
2808 gStyle->SetOptStat(0);
2809 gPad->SetTicky();
2810 gPad->SetTickx();
2811
2812 TText PrintRun;
2813 PrintRun.SetTextFont(62);
2814 PrintRun.SetTextSize(0.03);
2815 PrintRun.SetNDC();
2816 PrintRun.SetTextAlign(23);
2817 std::ostringstream runnostream;
2818 std::string runstring;
2819 std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2820
2821 runnostream << ThisName << ": Unsuppressed event fraction, Run" << cl->RunNumber()
2822 << ", Time: " << ctime(&evttime.first);
2823 runstring = runnostream.str();
2824 transparent[7]->cd();
2825 PrintRun.SetTextColor(evttime.second);
2826 PrintRun.DrawText(0.5, 0.99, runstring.c_str());
2827
2828 TC[7]->Update();
2829 TC[7]->Show();
2830 TC[7]->SetEditable(false);
2831 if (save) TC[7]->SaveAs("plots/UnsuppressedEventFraction.pdf");
2832 return 0;
2833 }
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100