Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:20:26

0001 #include "LL1MonDraw.h"
0002 
0003 #include <onlmon/OnlMonClient.h>
0004 
0005 #include <TAxis.h>  // for TAxis
0006 #include <TCanvas.h>
0007 #include <TGraphErrors.h>
0008 #include <TH1.h>
0009 #include <TH2.h>
0010 #include <TPad.h>
0011 #include <TROOT.h>
0012 #include <TSystem.h>
0013 #include <TText.h>
0014 #include <TStyle.h>
0015 
0016 #include <cstring>  // for memset
0017 #include <ctime>
0018 #include <fstream>
0019 #include <iostream>  // for operator<<, basic_ostream, basic_os...
0020 #include <sstream>
0021 #include <vector>  // for vector
0022 
0023 LL1MonDraw::LL1MonDraw(const std::string &name)
0024   : OnlMonDraw(name)
0025 {
0026   return;
0027 }
0028 
0029 int LL1MonDraw::Init()
0030 {
0031   return 0;
0032 }
0033 
0034 int LL1MonDraw::MakeCanvas(const std::string &name)
0035 {
0036   OnlMonClient *cl = OnlMonClient::instance();
0037   int xsize = cl->GetDisplaySizeX();
0038   int ysize = cl->GetDisplaySizeY();
0039 
0040   gStyle->SetOptStat(0);
0041   if (name == "LL1Mon0")
0042   {
0043     int canvasindex = 0;
0044     std::string tctitle = name + " Monitor - MBD";
0045     // xpos (-1) negative: do not draw menu bar
0046     TC[canvasindex] = new TCanvas(name.c_str(), tctitle.c_str(), -1, 0, xsize/2, ysize/2);
0047     TC[canvasindex]->SetTicks(1,1);
0048     // root is pathetic, whenever a new TCanvas is created root piles up
0049     // 6kb worth of X11 events which need to be cleared with
0050     // gSystem->ProcessEvents(), otherwise your process will grow and
0051     // grow and grow but will not show a definitely lost memory leak
0052     gSystem->ProcessEvents();
0053     for(int ipad=0; ipad<nPad1; ipad++){
0054       Pad[ipad] = new TPad(Form("ll1pad%d",ipad),Form("ll1pad%d",ipad),padx1[ipad],pady1[ipad],padx2[ipad],pady2[ipad],0);
0055       Pad[ipad]->Draw();
0056       Pad[ipad]->SetTicks(1,1);
0057     }
0058     transparent[canvasindex] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
0059     transparent[canvasindex]->SetFillStyle(4000);
0060     transparent[canvasindex]->Draw();
0061     TC[canvasindex]->SetEditable(false);
0062   }
0063   else if (name == "LL1Mon1")
0064   {
0065     int canvasindex = 1;
0066     std::string tctitle = name + " Monitor - MBD";
0067     // xpos negative: do not draw menu bar
0068     gStyle->SetOptStat(0);
0069     TC[canvasindex] = new TCanvas(name.c_str(), tctitle.c_str(), -1, 0, xsize / 2, ysize/2);
0070     TC[canvasindex]->SetTicks(1,1);
0071     gSystem->ProcessEvents();
0072     // this one is used to plot the run number on the canvas
0073     transparent[canvasindex] = new TPad("transparent1", "this does not show", 0, 0, 1, 1);
0074     transparent[canvasindex]->SetFillStyle(4000);
0075     transparent[canvasindex]->Draw();
0076     TC[canvasindex]->SetEditable(false);
0077   }
0078   else if (name == "LL1Mon2")
0079   {
0080     int canvasindex = 2;
0081     std::string tctitle = name + " Monitor - MBD";
0082     TC[canvasindex] = new TCanvas(name.c_str(), tctitle.c_str(), -1, 0, xsize / 2, ysize/2);
0083     TC[canvasindex]->SetTicks(1,1);
0084     gSystem->ProcessEvents();
0085     // this one is used to plot the run number on the canvas
0086     transparent[canvasindex] = new TPad("transparent2", "this does not show", 0, 0, 1, 1);
0087     transparent[canvasindex]->SetFillStyle(4000);
0088     transparent[canvasindex]->Draw();
0089     TC[canvasindex]->SetEditable(0);
0090   }
0091   else if (name == "LL1Mon3")
0092   {
0093     int canvasindex = 3;
0094     std::string tctitle = name + " Monitor - Photon";
0095     TC[canvasindex] = new TCanvas(name.c_str(), tctitle.c_str(), -1, 0, xsize / 2, ysize/2);
0096     TC[canvasindex]->SetTicks(1,1);
0097     gSystem->ProcessEvents();
0098 
0099     transparent[canvasindex] = new TPad("transparent3", "this does not show", 0, 0, 1, 1);
0100     transparent[canvasindex]->SetFillStyle(4000);
0101     transparent[canvasindex]->Draw();
0102     TC[canvasindex]->SetEditable(0);
0103 
0104   }
0105   else if (name == "LL1Mon4")
0106   {
0107     int canvasindex = 4;
0108     std::string tctitle = name + " Monitor - HCAL";
0109     TC[canvasindex] = new TCanvas(name.c_str(), tctitle.c_str(), -1, 0, xsize / 2, ysize/2);
0110     TC[canvasindex]->SetTicks(1,1);
0111     gSystem->ProcessEvents();
0112     // this one is used to plot the run number on the canvas
0113 
0114 
0115     transparent[canvasindex] = new TPad("transparent4", "this does not show", 0, 0, 1, 1);
0116     transparent[canvasindex]->SetFillStyle(4000);
0117     transparent[canvasindex]->Draw();
0118     TC[canvasindex]->SetEditable(0);
0119   }
0120   else if (name == "LL1Mon5")
0121   {
0122     int canvasindex = 5;
0123     std::string tctitle = name + " Monitor - Jet";
0124     TC[canvasindex] = new TCanvas(name.c_str(), tctitle.c_str(), -1, 0, xsize / 2, ysize/2);
0125     TC[canvasindex]->SetTicks(1,1);
0126     gSystem->ProcessEvents();
0127     // 
0128     transparent[canvasindex] = new TPad("transparent5", "this does not show", 0, 0, 1, 1);
0129     transparent[canvasindex]->SetFillStyle(4000);
0130     transparent[canvasindex]->Draw();
0131     TC[canvasindex]->SetEditable(0);
0132   }
0133   else if (name == "LL1Mon6")
0134   {
0135     int canvasindex = 6;
0136     std::string tctitle = name + " Monitor - EMCAL 2x2";
0137     TC[canvasindex] = new TCanvas(name.c_str(), tctitle.c_str(), -1, 0, xsize / 2, ysize/2);
0138     TC[canvasindex]->SetTicks(1,1);
0139     gSystem->ProcessEvents();
0140     // 
0141     float topbrim = 0.96;
0142     float dx = 0.25;
0143     float dy = topbrim / 4.;
0144     // this one is used to plot the run number on the canvas
0145     for (int i = 0; i < 16; i++)
0146       {
0147     std::string padname = "pad_emcal_"+std::to_string(i);
0148     int y = 3 - (i/4);
0149     int x = i%4;
0150     emcalpad[i] = new TPad(padname.c_str(),"", x*dx, y*dy,(x+1)*dx, (y+1)*dy); 
0151     emcalpad[i]->Draw();
0152       }
0153     transparent[canvasindex] = new TPad("transparent6", "this does not show", 0, 0, 1, 1);
0154     transparent[canvasindex]->SetFillStyle(4000);
0155     transparent[canvasindex]->Draw();
0156     TC[canvasindex]->SetEditable(0);
0157   }
0158 
0159   return 0;
0160 }
0161 
0162 int LL1MonDraw::Draw(const std::string &what)
0163 {
0164   int iret = 0;
0165   int idraw = 0;
0166   if (what == "ALL" || what == "FIRST")
0167   {
0168     iret += DrawFirst(what);
0169     idraw++;
0170   }
0171   if (what == "ALL" || what == "SECOND")
0172   {
0173     iret += DrawSecond(what);
0174     idraw++;
0175   }
0176   if (what == "ALL" || what == "THIRD")
0177   {
0178     iret += DrawThird(what);
0179     idraw++;
0180   }
0181   if (what == "ALL" || what == "FOURTH")
0182   {
0183     iret += DrawFourth(what);
0184     idraw++;
0185   }
0186   if (what == "ALL" || what == "FIFTH")
0187   {
0188     iret += DrawFifth(what);
0189     idraw++;
0190   }
0191   if (what == "ALL" || what == "SIXTH")
0192   {
0193     iret += DrawSixth(what);
0194     idraw++;
0195   }
0196 
0197   if (what == "ALL" || what == "SEVENTH")
0198   {
0199     iret += DrawSeventh(what);
0200     idraw++;
0201   }
0202 
0203   if (!idraw)
0204   {
0205     std::cout << __PRETTY_FUNCTION__ << " Unimplemented Drawing option: " << what << std::endl;
0206     iret = -1;
0207   }
0208   return iret;
0209 }
0210 
0211 int LL1MonDraw::DrawFirst(const std::string & /* what */)
0212 {
0213   // index of TC and transparent TPad array 
0214   // so we don't make cut and paste errors
0215   int canvasindex = 0;
0216   if (!gROOT->FindObject("LL1Mon0"))
0217   {
0218     MakeCanvas("LL1Mon0");
0219   }
0220 // set canvas to editable before the dead server drawing otherwise
0221 // canvas will not be updated
0222   TC[canvasindex]->SetEditable(true);
0223   TC[canvasindex]->Clear("D");
0224 
0225   OnlMonClient *cl = OnlMonClient::instance();
0226   TH1 *h_nhit_n1 = cl->getHisto("LL1MON_0","h_nhit_n1");
0227   TH1 *h_nhit_n2 = cl->getHisto("LL1MON_0","h_nhit_n2");
0228   TH1 *h_nhit_s1 = cl->getHisto("LL1MON_0","h_nhit_s1");
0229   TH1 *h_nhit_s2 = cl->getHisto("LL1MON_0","h_nhit_s2");
0230   std::pair<time_t,int> evttime = cl->EventTime("CURRENT");
0231   Pad[0]->cd();
0232   if (h_nhit_n1)
0233   {
0234     h_nhit_n1->DrawCopy();
0235   }
0236   else
0237   {
0238     DrawDeadServer(transparent[canvasindex]);
0239     TC[canvasindex]->SetEditable(false);
0240     return -1;
0241   }
0242   Pad[1]->cd();
0243   h_nhit_n2->DrawCopy();
0244   Pad[2]->cd();
0245   h_nhit_s1->DrawCopy();
0246   Pad[3]->cd();
0247   h_nhit_s2->DrawCopy();
0248 
0249   TText PrintRun;
0250   PrintRun.SetTextFont(62);
0251   PrintRun.SetTextSize(0.04);
0252   PrintRun.SetNDC();          // set to normalized coordinates
0253   PrintRun.SetTextAlign(23);  // center/top alignment
0254   std::ostringstream runnostream;
0255   std::string runstring;
0256   // fill run number and event time into string
0257   runnostream << ThisName << "_1 Run " << cl->RunNumber()
0258               << ", Time: " << ctime(&evttime.first);
0259   runstring = runnostream.str();
0260   transparent[canvasindex]->cd();
0261   PrintRun.SetTextColor(evttime.second);
0262   PrintRun.DrawText(0.5, 1., runstring.c_str());
0263   gStyle->SetOptStat(0);
0264   TC[canvasindex]->Update();
0265   TC[canvasindex]->SetTicks(1,1);
0266   TC[canvasindex]->Show();
0267   TC[canvasindex]->SetEditable(false);
0268   return 0;
0269 }
0270 
0271 int LL1MonDraw::DrawSecond(const std::string & /* what */)
0272 {
0273   // index of TC and transparent TPad array 
0274   // so we don't make cut and paste errors
0275   int canvasindex = 1;
0276   if (!gROOT->FindObject("LL1Mon1"))
0277   {
0278     MakeCanvas("LL1Mon1");
0279   }
0280 
0281 // set canvas to editable before the dead server drawing otherwise
0282 // canvas will not be updated
0283   TC[canvasindex]->SetEditable(true);
0284   TC[canvasindex]->Clear("D");
0285 
0286   OnlMonClient *cl = OnlMonClient::instance();
0287   TH2 *h_nhit_corr= (TH2D*) cl->getHisto("LL1MON_0","h_nhit_corr");
0288   std::pair<time_t,int> evttime = cl->EventTime("CURRENT");
0289   if (h_nhit_corr)
0290   {
0291     h_nhit_corr->Draw("colz");
0292   }
0293   else
0294   {
0295     DrawDeadServer(transparent[canvasindex]);
0296     TC[canvasindex]->SetEditable(false);
0297     return -1;
0298   }
0299   TText PrintRun;
0300   PrintRun.SetTextFont(62);
0301   PrintRun.SetTextSize(0.04);
0302   PrintRun.SetNDC();          // set to normalized coordinates
0303   PrintRun.SetTextAlign(23);  // center/top alignment
0304   std::ostringstream runnostream;
0305   std::string runstring;
0306   // fill run number and event time into string
0307   runnostream << ThisName << "_2 Run " << cl->RunNumber()
0308               << ", Time: " << ctime(&evttime.first);
0309   runstring = runnostream.str();
0310   transparent[canvasindex]->cd();
0311   PrintRun.SetTextColor(evttime.second);
0312   PrintRun.DrawText(0.5, 1., runstring.c_str());
0313   TC[canvasindex]->SetTicks(1,1);
0314   TC[canvasindex]->Update();
0315   TC[canvasindex]->Show();
0316   TC[canvasindex]->SetEditable(false);
0317   return 0;
0318 }
0319 
0320 int LL1MonDraw::DrawThird(const std::string & /* what */)
0321 {
0322   // index of TC and transparent TPad array 
0323   // so we don't make cut and paste errors
0324   int canvasindex = 2;
0325   if (!gROOT->FindObject("LL1Mon2"))
0326   {
0327     MakeCanvas("LL1Mon2");
0328   }
0329 
0330 // set canvas to editable before the dead server drawing otherwise
0331 // canvas will not be updated
0332   TC[canvasindex]->SetEditable(true);
0333   TC[canvasindex]->Clear("D");
0334   gStyle->SetOptStat(0);
0335 
0336   OnlMonClient *cl = OnlMonClient::instance();
0337   TH2 *h_line_up= (TH2*) cl->getHisto("LL1MON_0","h_line_up");
0338   std::pair<time_t,int> evttime = cl->EventTime("CURRENT");
0339   if (h_line_up)
0340   {
0341     h_line_up->Draw("colz");
0342   }
0343   else
0344   {
0345     DrawDeadServer(transparent[canvasindex]);
0346     TC[canvasindex]->SetEditable(false);
0347     return -1;
0348   }
0349   TText PrintRun;
0350   PrintRun.SetTextFont(62);
0351   PrintRun.SetTextSize(0.04);
0352   PrintRun.SetNDC();          // set to normalized coordinates
0353   PrintRun.SetTextAlign(23);  // center/top alignment
0354   std::ostringstream runnostream;
0355   std::string runstring;
0356   // fill run number and event time into string
0357   runnostream << ThisName << "_3 Run " << cl->RunNumber()
0358               << ", Time: " << ctime(&evttime.first);
0359   runstring = runnostream.str();
0360   transparent[canvasindex]->cd();
0361   PrintRun.SetTextColor(evttime.second);
0362   PrintRun.DrawText(0.5, 1., runstring.c_str());
0363   TC[canvasindex]->Update();
0364   TC[canvasindex]->SetTicks(1,1);
0365   TC[canvasindex]->Show();
0366   TC[canvasindex]->SetEditable(false);
0367   return 0;
0368 }
0369 
0370 int LL1MonDraw::DrawFourth(const std::string & /* what */)
0371 {
0372   // index of TC and transparent TPad array 
0373   // so we don't make cut and paste errors
0374   int canvasindex = 3;
0375 
0376   if (!gROOT->FindObject("LL1Mon3"))
0377   {
0378     MakeCanvas("LL1Mon3");
0379   }
0380 
0381 // set canvas to editable before the dead server drawing otherwise
0382 // canvas will not be updated
0383   TC[canvasindex]->SetEditable(true); 
0384   TC[canvasindex]->Clear("D");
0385   gStyle->SetOptStat(0);
0386 
0387   OnlMonClient *cl = OnlMonClient::instance();
0388   TH2 *h_8x8_sum_emcal= (TH2*) cl->getHisto("LL1MON_0","h_8x8_sum_emcal");
0389   if (!h_8x8_sum_emcal)
0390    {
0391      DrawDeadServer(transparent[canvasindex]);
0392      TC[canvasindex]->SetEditable(false);
0393      return -1;
0394    }
0395   TH2 *h_8x8_sum_emcal_above_threshold= (TH2*) cl->getHisto("LL1MON_0","h_8x8_sum_emcal_above_threshold_0");
0396   if (!h_8x8_sum_emcal_above_threshold)
0397   {
0398       DrawDeadServer(transparent[canvasindex]);
0399       TC[canvasindex]->SetEditable(false);
0400       return -1;
0401   }
0402   TH2 *h_sample_diff_emcal= (TH2*) cl->getHisto("LL1MON_0","h_sample_diff_emcal");
0403   if (!h_sample_diff_emcal)
0404    {
0405      DrawDeadServer(transparent[canvasindex]);
0406      TC[canvasindex]->SetEditable(false);
0407      return -1;
0408    }
0409   std::pair<time_t,int> evttime = cl->EventTime("CURRENT");
0410 
0411   TC[canvasindex]->cd();
0412   TPad *left_top_pad = new TPad("left_top_pad", "", 0.0, 0.45, 0.5, 0.9);
0413   left_top_pad->SetTicks(1,1);
0414   left_top_pad->Draw();
0415   left_top_pad->cd();
0416  
0417   h_8x8_sum_emcal->SetTitle("EMCAL 8x8 Total Sums ; #eta <8x8> sum; #phi <8x8> sum"); 
0418   h_8x8_sum_emcal->Draw("colz");
0419  
0420   TC[canvasindex]->cd();
0421   TPad *top_right_pad = new TPad("top_right_pad", "", 0.5, 0.45, 1.0, 0.9);
0422   top_right_pad->SetTicks(1,1);
0423   top_right_pad->Draw();
0424   top_right_pad->SetLogz();
0425   top_right_pad->cd();
0426 
0427   h_8x8_sum_emcal_above_threshold->SetTitle("EMCAL 8x8 Sums Above Threshold;#eta <8x8> sum; #phi <8x8> sum");
0428   h_8x8_sum_emcal_above_threshold->Draw("colz");
0429   
0430   TC[canvasindex]->cd();
0431   TPad *bottom_left_pad = new TPad("bottom_left_pad", "", 0.0, 0.0, 0.5, 0.450);
0432   bottom_left_pad->SetTicks(1,1);
0433   bottom_left_pad->SetTopMargin(0.2);
0434   bottom_left_pad->Draw();
0435 
0436   bottom_left_pad->SetLogz();
0437   bottom_left_pad->cd();
0438 
0439   h_sample_diff_emcal->SetTitle("EMCAL Output Timing; Relative BC of L1 Trigger; EMCAL Board");
0440   h_sample_diff_emcal->Draw("colz");
0441   
0442   TC[canvasindex]->cd();
0443 
0444   //Calculate 8x8 EMCal sum excessing 10% of the total integral 
0445   int nbinsx = h_8x8_sum_emcal_above_threshold->GetNbinsX();
0446   int nbinsy = h_8x8_sum_emcal_above_threshold->GetNbinsY();
0447   float integral = h_8x8_sum_emcal_above_threshold->Integral();
0448   std::vector<std::tuple<int,int,float>> emcalhotbin;
0449 
0450   for(int ibinx = 1; ibinx<=nbinsx; ibinx++){
0451       for(int ibiny=1; ibiny<=nbinsy; ibiny++){
0452           float con = h_8x8_sum_emcal_above_threshold->GetBinContent(ibinx,ibiny);
0453           if(con > integral*0.1) emcalhotbin.push_back(std::make_tuple(ibinx,ibiny,con/integral));
0454       }
0455   }
0456           
0457   TPad *bottom_right_pad = new TPad("bottom_right_pad", "", 0.5, 0.0, 1.0, 0.450);
0458   bottom_right_pad->SetTicks(1,1);
0459   bottom_right_pad->SetTopMargin(0.2);
0460   bottom_right_pad->Draw();
0461   bottom_right_pad->cd();
0462 
0463   double textsize = 0.04;
0464   TLatex PrintHot;
0465   //PrintHot.SetTextFont(40);
0466   PrintHot.SetTextSize(textsize);
0467   PrintHot.SetNDC();          // set to normalized coordinates
0468   PrintHot.SetTextAlign(23);  // center/top alignment
0469   std::ostringstream hotchannelstream;
0470   std::string hotstring;
0471   
0472   float y_position = 0.9;
0473   float x_position = 0.4;
0474   
0475   hotchannelstream << "8x8 Photon Trigger - Hot Trigger Areas : Total " << emcalhotbin.size() << std::endl;
0476   hotstring = hotchannelstream.str();
0477   PrintHot.DrawText(x_position, y_position, hotstring.c_str());
0478   y_position -=0.06;
0479 
0480   for (auto& entry : emcalhotbin) {
0481       int etabin = std::get<0>(entry);
0482       int phibin = std::get<1>(entry);
0483       float frac = std::get<2>(entry)*100.;
0484 
0485       std::string text = "#eta bin : " + std::to_string(etabin) + ", #phi bin : " + std::to_string(phibin) + Form(", fraction : %.1f",frac) + " (%)";
0486       PrintHot.DrawLatex(x_position, y_position, text.c_str());
0487       y_position -= (textsize * 1.2);
0488       if (y_position < 0) break; 
0489   }
0490 
0491   TC[canvasindex]->cd();
0492   TPad *tr = new TPad("tr", "this does not show", 0, 0, 1, 1);
0493   tr->SetFillStyle(4000);
0494   tr->Draw();
0495   tr->cd();
0496   TText PrintRun;
0497   PrintRun.SetTextFont(62);
0498   PrintRun.SetTextSize(0.04);
0499   PrintRun.SetNDC();          // set to normalized coordinates
0500   PrintRun.SetTextAlign(23);  // center/top alignment
0501   std::ostringstream runnostream;
0502   std::string runstring;
0503   // fill run number and event time into string
0504   runnostream << "EMCAL 8x8 Photon Run " << cl->RunNumber()
0505               << ", Time: " << ctime(&evttime.first);
0506   runstring = runnostream.str();
0507   PrintRun.SetTextColor(evttime.second);
0508   PrintRun.DrawText(0.5, 1., runstring.c_str());
0509   TC[canvasindex]->Update();
0510   TC[canvasindex]->SetTicks(1,1);
0511   TC[canvasindex]->Show();
0512   TC[canvasindex]->SetEditable(false);
0513   return 0;
0514 }
0515 int LL1MonDraw::DrawFifth(const std::string & /* what */)
0516 {
0517   // index of TC and transparent TPad array 
0518   // so we don't make cut and paste errors
0519   int canvasindex = 4;
0520   if (!gROOT->FindObject("LL1Mon4"))
0521   {
0522     MakeCanvas("LL1Mon4");
0523   }
0524 
0525 // set canvas to editable before the dead server drawing otherwise
0526 // canvas will not be updated
0527   TC[canvasindex]->SetEditable(true);
0528   TC[canvasindex]->Clear("D");
0529   gStyle->SetOptStat(0);
0530 
0531   OnlMonClient *cl = OnlMonClient::instance();
0532   TH2 *h_jet_input= (TH2*) cl->getHisto("LL1MON_0","h_jet_input");
0533   if (!h_jet_input)
0534     {
0535       DrawDeadServer(transparent[canvasindex]);
0536       TC[canvasindex]->SetEditable(false);
0537       return -1;
0538     }
0539   
0540 
0541   TH2 *h_sample_diff_jet_input = (TH2*) cl->getHisto("LL1MON_0","h_sample_diff_jet_input");
0542   if (!h_sample_diff_jet_input)
0543     {
0544       DrawDeadServer(transparent[canvasindex]);
0545       TC[canvasindex]->SetEditable(false);
0546       return -1;
0547     }
0548 
0549   TH1 *h_hit_format = (TH1*) cl->getHisto("LL1MON_0", "h_hit_format");
0550   if (!h_hit_format)
0551     {
0552       DrawDeadServer(transparent[canvasindex]);
0553       TC[canvasindex]->SetEditable(false);
0554       return -1;
0555     }
0556 
0557   std::pair<time_t,int> evttime = cl->EventTime("CURRENT");
0558 
0559   TC[canvasindex]->cd();
0560   TPad *left_pad = new TPad("left_pad", "", 0.0, 0.0,0.5, 0.9);
0561   left_pad->SetTicks(1,1);
0562   left_pad->Draw();
0563   left_pad->cd();
0564   left_pad->SetLogz();
0565 
0566 
0567   std::string hf_name = "HCAL";
0568   int hitformat = static_cast<int>(h_hit_format->GetBinCenter(h_hit_format->GetMaximumBin()));
0569   if (hitformat%2 == 0)
0570     {
0571       hf_name = "EMCAL";
0572     }
0573   std::string title = "Jet Input (" + hf_name + ") 2x2 Tower Sums; #eta ; #phi";
0574   h_jet_input->SetTitle("Jet Input (HCAL) 2x2 Tower Sums; #eta ; #phi");
0575   h_jet_input->Draw("colz");
0576   
0577   TC[canvasindex]->cd();
0578   TPad *right_pad = new TPad("right_pad", "", 0.5, 0.0,1.0, 0.9);
0579   right_pad->SetTicks(1,1);
0580   right_pad->Draw();
0581   right_pad->cd();
0582   right_pad->SetLogz();
0583  
0584   h_jet_input->SetTitle("Jet Input (HCAL); #eta 2x2 Sum ; #phi 2x2 Sum");
0585   h_sample_diff_jet_input->Draw("colz");
0586  
0587 
0588   TText PrintRun;
0589   PrintRun.SetTextFont(62);
0590   PrintRun.SetTextSize(0.04);
0591   PrintRun.SetNDC();          // set to normalized coordinates
0592   PrintRun.SetTextAlign(23);  // center/top alignment
0593   std::ostringstream runnostream;
0594   std::string runstring;
0595   // fill run number and event time into string
0596   runnostream << ThisName << "_3 Run " << cl->RunNumber()
0597               << ", Time: " << ctime(&evttime.first);
0598   runstring = runnostream.str();
0599   TC[canvasindex]->cd();
0600   TPad *tr = new TPad("tr", "this does not show", 0, 0, 1, 1);
0601   tr->SetFillStyle(4000);
0602   tr->Draw();
0603   tr->cd();
0604   PrintRun.SetTextColor(evttime.second);
0605   PrintRun.DrawText(0.5, 1., runstring.c_str());
0606   TC[canvasindex]->Update();
0607   TC[canvasindex]->SetTicks(1,1);
0608   TC[canvasindex]->Show();
0609   TC[canvasindex]->SetEditable(false);
0610   return 0;
0611 }
0612 
0613 int LL1MonDraw::DrawSixth(const std::string & /* what */)
0614 {
0615   // index of TC and transparent TPad array 
0616   // so we don't make cut and paste errors
0617   int canvasindex = 5;
0618   if (!gROOT->FindObject("LL1Mon5"))
0619   {
0620     MakeCanvas("LL1Mon5");
0621   }
0622 
0623 // set canvas to editable before the dead server drawing otherwise
0624 // canvas will not be updated
0625   TC[canvasindex]->SetEditable(true);
0626   TC[canvasindex]->Clear("D");
0627   gStyle->SetOptStat(0);
0628 
0629   OnlMonClient *cl = OnlMonClient::instance();
0630   TH2 *h_jet_output= (TH2*) cl->getHisto("LL1MON_0","h_jet_output");
0631   if (!h_jet_output)
0632     {
0633       DrawDeadServer(transparent[canvasindex]);
0634       TC[canvasindex]->SetEditable(false);
0635       return -1;
0636     }
0637   h_jet_output->SetTitle("Jet <8x8> Overlapping Total Sums; #eta <8x8> Sum; #phi <8x8> Sum");
0638   TH2 *h_jet_output_above_threshold= (TH2*) cl->getHisto("LL1MON_0","h_jet_output_above_threshold_0");
0639   if (!h_jet_output_above_threshold)
0640     {
0641       DrawDeadServer(transparent[canvasindex]);
0642       TC[canvasindex]->SetEditable(false);
0643       return -1;
0644     }
0645   h_jet_output_above_threshold->SetTitle("Jet <8x8> Overlapping Hits above Threshold; #eta <8x8> Sum; #phi <8x8> Sum");
0646   std::pair<time_t,int> evttime = cl->EventTime("CURRENT");
0647 
0648   transparent[canvasindex]->cd();
0649   TPad *left_pad = new TPad("left_pad", "", 0.0, 0.0, 0.5, 0.9);
0650   left_pad->SetTicks(1,1);
0651   left_pad->Draw();
0652   left_pad->cd();
0653 
0654   h_jet_output->Draw("colz");
0655   
0656   TC[canvasindex]->cd();
0657   TPad *right_pad = new TPad("right_pad", "", 0.5, 0.0, 1.0, 0.9);
0658   right_pad->SetTicks(1,1);
0659   right_pad->Draw();
0660   right_pad->SetLogz();
0661   right_pad->cd();
0662 
0663   h_jet_output_above_threshold->Draw("colz");
0664   
0665   TText PrintRun;
0666   PrintRun.SetTextFont(62);
0667   PrintRun.SetTextSize(0.04);
0668   PrintRun.SetNDC();          // set to normalized coordinates
0669   PrintRun.SetTextAlign(23);  // center/top alignment
0670   std::ostringstream runnostream;
0671   std::string runstring;
0672   // fill run number and event time into string
0673   runnostream << ThisName << "_3 Run " << cl->RunNumber()
0674               << ", Time: " << ctime(&evttime.first);
0675   runstring = runnostream.str();
0676   TC[canvasindex]->cd();
0677   TPad *tr = new TPad("tr", "this does not show", 0, 0, 1, 1);
0678   tr->SetFillStyle(4000);
0679   tr->Draw();
0680   tr->cd();
0681   PrintRun.SetTextColor(evttime.second);
0682   PrintRun.DrawText(0.5, 1., runstring.c_str());
0683   TC[canvasindex]->Update();
0684   TC[canvasindex]->SetTicks(1,1);
0685   TC[canvasindex]->Show();
0686   TC[canvasindex]->SetEditable(false);
0687   return 0;
0688 }
0689 
0690 int LL1MonDraw::DrawSeventh(const std::string & /* what */)
0691 {
0692   // index of TC and transparent TPad array 
0693   // so we don't make cut and paste errors
0694   int canvasindex = 6;
0695   if (!gROOT->FindObject("LL1Mon6"))
0696   {
0697     MakeCanvas("LL1Mon6");
0698   }
0699 
0700 // set canvas to editable before the dead server drawing otherwise
0701 // canvas will not be updated
0702   TC[canvasindex]->SetEditable(true);
0703   TC[canvasindex]->Clear("D");
0704   gStyle->SetOptStat(0);
0705 
0706   OnlMonClient *cl = OnlMonClient::instance();
0707   std::pair<time_t,int> evttime = cl->EventTime("CURRENT");
0708 
0709   for (int i = 0 ; i < 16; i++)
0710     {
0711       std::string histname = "h_2x2_sum_emcal_" + std::to_string(i);
0712       TH1 *h_emcal= (TH1*) cl->getHisto("LL1MON_0",histname.c_str());
0713 
0714       if (!h_emcal)
0715     {
0716       DrawDeadServer(transparent[canvasindex]);
0717       TC[canvasindex]->SetEditable(false);
0718       return -1;
0719     }
0720       emcalpad[i]->cd();
0721       h_emcal->SetLineColor(kBlack);
0722       h_emcal->SetLineWidth(2);
0723       h_emcal->SetFillColor(kSpring + 2);
0724       h_emcal->Draw();
0725     }
0726   
0727   TText PrintRun;
0728   PrintRun.SetTextFont(62);
0729   PrintRun.SetTextSize(0.04);
0730   PrintRun.SetNDC();          // set to normalized coordinates
0731   PrintRun.SetTextAlign(23);  // center/top alignment
0732   std::ostringstream runnostream;
0733   std::string runstring;
0734   // fill run number and event time into string
0735   runnostream << ThisName << "_3 Run " << cl->RunNumber()
0736               << ", Time: " << ctime(&evttime.first);
0737   runstring = runnostream.str();
0738   TC[canvasindex]->cd();
0739   TPad *tr = new TPad("tr", "this does not show", 0, 0, 1, 1);
0740   tr->SetFillStyle(4000);
0741   tr->Draw();
0742   tr->cd();
0743   PrintRun.SetTextColor(evttime.second);
0744   PrintRun.DrawText(0.5, 1., runstring.c_str());
0745   TC[canvasindex]->Update();
0746   TC[canvasindex]->SetTicks(1,1);
0747   TC[canvasindex]->Show();
0748   TC[canvasindex]->SetEditable(false);
0749   return 0;
0750 }
0751 
0752 int LL1MonDraw::SavePlot(const std::string &what, const std::string &type)
0753 {
0754 
0755   OnlMonClient *cl = OnlMonClient::instance();
0756   int iret = Draw(what);
0757   if (iret)  // on error no png files please
0758   {
0759       return iret;
0760   }
0761   int icnt = 0;
0762   for (TCanvas *canvas : TC)
0763   {
0764     if (canvas == nullptr)
0765     {
0766       continue;
0767     }
0768     icnt++;
0769     std::string filename = ThisName + "_" + std::to_string(icnt) + "_" +
0770       std::to_string(cl->RunNumber()) + "." + type;
0771     cl->CanvasToPng(canvas, filename);
0772   }
0773   return 0;
0774 }
0775 
0776 int LL1MonDraw::MakeHtml(const std::string &what)
0777 {
0778   int iret = Draw(what);
0779   if (iret)  // on error no html output please
0780   {
0781     return iret;
0782   }
0783 
0784   OnlMonClient *cl = OnlMonClient::instance();
0785 
0786   int icnt = 0;
0787   for (TCanvas *canvas : TC)
0788   {
0789     if (canvas == nullptr)
0790     {
0791       continue;
0792     }
0793     icnt++;
0794     // Register the canvas png file to the menu and produces the png file.
0795     std::string pngfile = cl->htmlRegisterPage(*this, canvas->GetTitle(), std::to_string(icnt), "png");
0796     cl->CanvasToPng(canvas, pngfile);
0797   }
0798   // Now register also EXPERTS html pages, under the EXPERTS subfolder.
0799 
0800   // std::string logfile = cl->htmlRegisterPage(*this, "EXPERTS/Log", "log", "html");
0801   // std::ofstream out(logfile.c_str());
0802   // out << "<HTML><HEAD><TITLE>Log file for run " << cl->RunNumber()
0803   //     << "</TITLE></HEAD>" << std::endl;
0804   // out << "<P>Some log file output would go here." << std::endl;
0805   // out.close();
0806 
0807   // std::string status = cl->htmlRegisterPage(*this, "EXPERTS/Status", "status", "html");
0808   // std::ofstream out2(status.c_str());
0809   // out2 << "<HTML><HEAD><TITLE>Status file for run " << cl->RunNumber()
0810   //      << "</TITLE></HEAD>" << std::endl;
0811   // out2 << "<P>Some status output would go here." << std::endl;
0812   // out2.close();
0813   // cl->SaveLogFile(*this);
0814   return 0;
0815 }