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