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