Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-04 08:16:15

0001 #include "TpcMonDraw.h"
0002 
0003 #include <onlmon/OnlMonClient.h>
0004 
0005 #include <TAxis.h>  // for TAxis
0006 #include <TCanvas.h>
0007 #include <TDatime.h>
0008 #include <TEllipse.h>
0009 #include <TF1.h>
0010 #include <TGraphErrors.h>
0011 #include <TH1.h>
0012 #include <TH2.h>
0013 #include <TLatex.h>
0014 #include <TLegend.h>
0015 #include <TLine.h>
0016 #include <TMath.h>
0017 #include <TPad.h>
0018 #include <TPaveLabel.h>
0019 #include <TPaveText.h>
0020 #include <TROOT.h>
0021 #include <TString.h>
0022 #include <TStyle.h>
0023 #include <TSystem.h>
0024 #include <TText.h>
0025 
0026 #include <cstring>  // for memset
0027 #include <ctime>
0028 #include <fstream>
0029 #include <iostream>  // for operator<<, basic_ostream, basic_os...
0030 #include <limits>
0031 #include <sstream>
0032 #include <vector>  // for vector
0033 
0034 #include <cmath>
0035 #include <cstdio>  // for printf
0036 #include <string>  // for allocator, string, char_traits
0037 
0038 TpcMonDraw::TpcMonDraw(const std::string &name)
0039   : OnlMonDraw(name)
0040 {
0041   return;
0042 }
0043 
0044 int TpcMonDraw::Init()
0045 {
0046   return 0;
0047 }
0048 
0049 int TpcMonDraw::MakeCanvas(const std::string &name)
0050 {
0051   OnlMonClient *cl = OnlMonClient::instance();
0052   int xsize = cl->GetDisplaySizeX();
0053   int ysize = cl->GetDisplaySizeY();
0054   if (name == "TPCModules")
0055   {
0056     TC[0] = new TCanvas(name.c_str(), "ADC Count by GEM Example", -1, 0, 1350, 700);
0057     gSystem->ProcessEvents();
0058     TC[0]->Divide(2, 1);
0059     // gStyle->SetPalette(57); //kBird CVD friendly
0060     //  this one is used to plot the run number on the canvas
0061     transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
0062     transparent[0]->SetFillStyle(4000);
0063     transparent[0]->Draw();
0064     TC[0]->SetEditable(false);
0065   }
0066   else if (name == "TPCSampleSize")
0067   {
0068     TC[1] = new TCanvas(name.c_str(), "TPC Sample Size Distribution in Events", -1, 0, xsize, ysize);
0069     gSystem->ProcessEvents();
0070     TC[1]->Divide(4, 7);
0071     transparent[1] = new TPad("transparent1", "this does not show", 0, 0, 1, 1);
0072     transparent[1]->SetFillStyle(4000);
0073     transparent[1]->Draw();
0074     TC[1]->SetEditable(false);
0075   }
0076   else if (name == "TPCCheckSumError")
0077   {
0078     TC[2] = new TCanvas(name.c_str(), "TPC CheckSumError Probability in Events", -1, 0, xsize, ysize);
0079     gSystem->ProcessEvents();
0080     TC[2]->Divide(4, 7);
0081     transparent[2] = new TPad("transparent2", "this does not show", 0, 0, 1, 1);
0082     transparent[2]->SetFillStyle(4000);
0083     transparent[2]->Draw();
0084     TC[2]->SetEditable(false);
0085   }
0086   else if (name == "TPCADCSample")
0087   {
0088     TC[3] = new TCanvas(name.c_str(), "TPC ADC vs Sample in Whole Sector", -1, 0, xsize, ysize);
0089     gSystem->ProcessEvents();
0090     // gStyle->SetPalette(57); //kBird CVD friendly
0091     TC[3]->Divide(4, 7);
0092     transparent[3] = new TPad("transparent3", "this does not show", 0, 0, 1, 1);
0093     transparent[3]->SetFillStyle(4000);
0094     transparent[3]->Draw();
0095     TC[3]->SetEditable(false);
0096   }
0097   else if (name == "TPCMaxADCModule")
0098   {
0099     TC[4] = new TCanvas(name.c_str(), "(MAX ADC - pedestal) in SLIDING WINDOW for each Module in Sector", -1, 0, xsize, ysize);
0100     gSystem->ProcessEvents();
0101     // gStyle->SetPalette(57); //kBird CVD friendly
0102     TC[4]->Divide(4, 7);
0103     transparent[4] = new TPad("transparent4", "this does not show", 0, 0, 1, 1);
0104     transparent[4]->SetFillStyle(4000);
0105     transparent[4]->Draw();
0106     TC[4]->SetEditable(false);
0107   }
0108   else if (name == "TPCRawADC1D")
0109   {
0110     TC[5] = new TCanvas(name.c_str(), "TPC RAW ADC 1D distribution", -1, 0, xsize, ysize);
0111     gSystem->ProcessEvents();
0112     // gStyle->SetPalette(57); //kBird CVD friendly
0113     TC[5]->Divide(4, 7);
0114     transparent[5] = new TPad("transparent5", "this does not show", 0, 0, 1, 1);
0115     transparent[5]->SetFillStyle(4000);
0116     transparent[5]->Draw();
0117     TC[5]->SetEditable(false);
0118   }
0119   else if (name == "TPCMaxADC1D")
0120   {
0121     TC[6] = new TCanvas(name.c_str(), "(MAX ADC - pedestal) in SLIDING WINDOW 1D distribution", -1, 0, xsize, ysize);
0122     gSystem->ProcessEvents();
0123     // gStyle->SetPalette(57); //kBird CVD friendly
0124     TC[6]->Divide(4, 7);
0125     transparent[6] = new TPad("transparent6", "this does not show", 0, 0, 1, 1);
0126     transparent[6]->SetFillStyle(4000);
0127     transparent[6]->Draw();
0128     TC[6]->SetEditable(false);
0129   }
0130   else if (name == "TPCClusterXY")
0131   {
0132     TC[7] = new TCanvas(name.c_str(), "(MAX ADC - pedestal)>  (20 ADC || 5sigma) for NS and SS, WEIGHTED", -1, 0, 1350, 700);
0133     gSystem->ProcessEvents();
0134     // gStyle->SetPalette(57); //kBird CVD friendly
0135     TC[7]->Divide(2, 1);
0136     // this one is used to plot the run number on the canvas
0137     transparent[7] = new TPad("transparent7", "this does not show", 0, 0, 1, 1);
0138     transparent[7]->SetFillStyle(4000);
0139     transparent[7]->Draw();
0140     TC[7]->SetEditable(false);
0141   }
0142   else if (name == "TPCClusterXY_unw")
0143   {
0144     TC[8] = new TCanvas(name.c_str(), "(MAX ADC - pedestal)>  (20 ADC || 5sigma) for NS and SS, UNWEIGHTED", -1, 0, 1350, 700);
0145     gSystem->ProcessEvents();
0146     // gStyle->SetPalette(57); //kBird CVD friendly
0147     TC[8]->Divide(2, 1);
0148     // this one is used to plot the run number on the canvas
0149     transparent[8] = new TPad("transparent8", "this does not show", 0, 0, 1, 1);
0150     transparent[8]->SetFillStyle(4000);
0151     transparent[8]->Draw();
0152     TC[8]->SetEditable(false);
0153   }
0154   else if (name == "TPCADCSamplelarge")
0155   {
0156     TC[9] = new TCanvas(name.c_str(), "TPC ADC vs Large Sample in Whole Sector", -1, 0, xsize, ysize);
0157     gSystem->ProcessEvents();
0158     // gStyle->SetPalette(57); //kBird CVD friendly
0159     TC[9]->Divide(4, 7);
0160     transparent[9] = new TPad("transparent9", "this does not show", 0, 0, 1, 1);
0161     transparent[9]->SetFillStyle(4000);
0162     transparent[9]->Draw();
0163     TC[9]->SetEditable(false);
0164   }
0165 
0166   else if (name == "TPCClusterZY")
0167   {
0168     TC[10] = new TCanvas(name.c_str(), "(MAX ADC - pedestal)> (20 ADC || 5sigma) for NS and SS, WEIGHTED", -1, 0, 1350, 700);
0169     gSystem->ProcessEvents();
0170     // gStyle->SetPalette(57); //kBird CVD friendly
0171     TC[10]->Divide(1, 1);
0172     // this one is used to plot the run number on the canvas
0173     transparent[10] = new TPad("transparent10", "this does not show", 0, 0, 1, 1);
0174     transparent[10]->SetFillStyle(4000);
0175     transparent[10]->Draw();
0176     TC[10]->SetEditable(false);
0177   }
0178 
0179   else if (name == "TPCClusterZY_unw")
0180   {
0181     TC[11] = new TCanvas(name.c_str(), "(MAX ADC - pedestal)> (20 ADC || 5sigma) for NS and SS, UNWEIGHTED", -1, 0, 1350, 700);
0182     gSystem->ProcessEvents();
0183     // gStyle->SetPalette(57); //kBird CVD friendly
0184     TC[11]->Divide(1, 1);
0185     // this one is used to plot the run number on the canvas
0186     transparent[11] = new TPad("transparent11", "this does not show", 0, 0, 1, 1);
0187     transparent[11]->SetFillStyle(4000);
0188     transparent[11]->Draw();
0189     TC[11]->SetEditable(false);
0190   }
0191 
0192   else if (name == "TPCLayerPhi")
0193   {
0194     TC[12] = new TCanvas(name.c_str(), "Layer vs Channel Phi for NS and SS, WEIGHTED by Sum(ADC-pedestal)", -1, 0, 1350, 700);
0195     gSystem->ProcessEvents();
0196     // gStyle->SetPalette(57); //kBird CVD friendly
0197     TC[12]->Divide(1, 1);
0198     // this one is used to plot the run number on the canvas
0199     transparent[12] = new TPad("transparent12", "this does not show", 0, 0, 1, 1);
0200     transparent[12]->SetFillStyle(4000);
0201     transparent[12]->Draw();
0202     TC[12]->SetEditable(false);
0203   }
0204   else if (name == "TPCPedestSubADC1D")
0205   {
0206     TC[13] = new TCanvas(name.c_str(), "TPC PEDEST SUB ADC 1D distribution", -1, 0, xsize, ysize);
0207     gSystem->ProcessEvents();
0208     // gStyle->SetPalette(57); //kBird CVD friendly
0209     TC[13]->Divide(4, 7);
0210     transparent[13] = new TPad("transparent13", "this does not show", 0, 0, 1, 1);
0211     transparent[13]->SetFillStyle(4000);
0212     transparent[13]->Draw();
0213     TC[13]->SetEditable(false);
0214   }
0215   else if (name == "TPCNEventsEBDC")
0216   {
0217     TC[14] = new TCanvas(name.c_str(), "TPC NUMBER EVENTS vs EBDC", 1350, 700);
0218     gSystem->ProcessEvents();
0219     // gStyle->SetPalette(57); //kBird CVD friendly
0220     TC[14]->Divide(1, 1);
0221     // this one is used to plot the run number on the canvas
0222     transparent[14] = new TPad("transparent14", "this does not show", 0, 0, 1, 1);
0223     transparent[14]->SetFillStyle(4000);
0224     transparent[14]->Draw();
0225     TC[14]->SetEditable(false);
0226   }
0227   else if (name == "TPCPedestSubADCSample")
0228   {
0229     TC[15] = new TCanvas(name.c_str(), "TPC PEDEST SUB ADC vs Sample in Whole Sector", -1, 0, xsize, ysize);
0230     gSystem->ProcessEvents();
0231     // gStyle->SetPalette(57); //kBird CVD friendly
0232     TC[15]->Divide(4, 7);
0233     transparent[15] = new TPad("transparent15", "this does not show", 0, 0, 1, 1);
0234     transparent[15]->SetFillStyle(4000);
0235     transparent[15]->Draw();
0236     TC[15]->SetEditable(false);
0237   }
0238   else if (name == "TPCPedestSubADCSample_R1")
0239   {
0240     TC[16] = new TCanvas(name.c_str(), "TPC PEDEST SUB ADC vs Sample in R1 ONLY", -1, 0, xsize, ysize);
0241     gSystem->ProcessEvents();
0242     // gStyle->SetPalette(57); //kBird CVD friendly
0243     TC[16]->Divide(4, 7);
0244     transparent[16] = new TPad("transparent16", "this does not show", 0, 0, 1, 1);
0245     transparent[16]->SetFillStyle(4000);
0246     transparent[16]->Draw();
0247     TC[16]->SetEditable(false);
0248   }
0249   else if (name == "TPCPedestSubADCSample_R2")
0250   {
0251     TC[17] = new TCanvas(name.c_str(), "TPC PEDEST SUB ADC vs Sample in R2 ONLY", -1, 0, xsize, ysize);
0252     gSystem->ProcessEvents();
0253     // gStyle->SetPalette(57); //kBird CVD friendly
0254     TC[17]->Divide(4, 7);
0255     transparent[17] = new TPad("transparent17", "this does not show", 0, 0, 1, 1);
0256     transparent[17]->SetFillStyle(4000);
0257     transparent[17]->Draw();
0258     TC[17]->SetEditable(false);
0259   }
0260   else if (name == "TPCPedestSubADCSample_R3")
0261   {
0262     TC[18] = new TCanvas(name.c_str(), "TPC PEDEST SUB ADC vs Sample in R3 ONLY", -1, 0, xsize, ysize);
0263     gSystem->ProcessEvents();
0264     // gStyle->SetPalette(57); //kBird CVD friendly
0265     TC[18]->Divide(4, 7);
0266     transparent[18] = new TPad("transparent18", "this does not show", 0, 0, 1, 1);
0267     transparent[18]->SetFillStyle(4000);
0268     transparent[18]->Draw();
0269     TC[18]->SetEditable(false);
0270   }
0271   else if (name == "TPCClusterXY_laser")
0272   {
0273     TC[19] = new TCanvas(name.c_str(), "(MAX ADC - pedestal)> (20 ADC || 5sigma) for NS and SS, LASER FLASH ONLY, WEIGHTED", -1, 0, 1350, 700);
0274     gSystem->ProcessEvents();
0275     // gStyle->SetPalette(57); //kBird CVD friendly
0276     TC[19]->Divide(2, 1);
0277     // this one is used to plot the run number on the canvas
0278     transparent[19] = new TPad("transparent19", "this does not show", 0, 0, 1, 1);
0279     transparent[19]->SetFillStyle(4000);
0280     transparent[19]->Draw();
0281     TC[19]->SetEditable(false);
0282   }
0283   else if (name == "TpcMonServerStats")
0284   {
0285     TC[20] = new TCanvas(name.c_str(), "TpcMon Server Stats", -1, 0, xsize, ysize);
0286     gSystem->ProcessEvents();
0287     transparent[20] = new TPad("transparent20", "this does not show", 0, 0, 1, 1);
0288     transparent[20]->Draw();
0289     transparent[20]->SetFillColor(kGray);
0290     TC[20]->SetEditable(false);
0291     TC[20]->SetTopMargin(0.05);
0292     TC[20]->SetBottomMargin(0.05);
0293   }
0294   else if (name == "TPCStuckChannels")
0295   {
0296     TC[21] = new TCanvas(name.c_str(), "TPC Stuck Channels in Events", -1, 0, xsize, ysize);
0297     gSystem->ProcessEvents();
0298     TC[21]->Divide(4, 7);
0299     transparent[21] = new TPad("transparent21", "this does not show", 0, 0, 1, 1);
0300     transparent[21]->SetFillStyle(4000);
0301     transparent[21]->Draw();
0302     TC[21]->SetEditable(false);
0303   }
0304   else if (name == "TPCClusterXY_u5")
0305   {
0306     TC[22] = new TCanvas(name.c_str(), "(MAX ADC - pedestal)>  (20 ADC || 5sigma) for NS and SS, <= 5 EVENTS WEIGHTED", -1, 0, 1350, 700);
0307     gSystem->ProcessEvents();
0308     // gStyle->SetPalette(57); //kBird CVD friendly
0309     TC[22]->Divide(2, 1);
0310     // this one is used to plot the run number on the canvas
0311     transparent[22] = new TPad("transparent22", "this does not show", 0, 0, 1, 1);
0312     transparent[22]->SetFillStyle(4000);
0313     transparent[22]->Draw();
0314     TC[22]->SetEditable(false);
0315   }
0316   else if (name == "TPCChan_in_Packets_NS")
0317   {
0318     TC[23] = new TCanvas(name.c_str(), "TPC Channel Fraction Present in Packet in RCDAQ Event, NS ONLY", -1, 0, xsize, ysize);
0319     gSystem->ProcessEvents();
0320     TC[23]->Divide(2, 7);
0321     transparent[23] = new TPad("transparent23", "this does not show", 0, 0, 1, 1);
0322     transparent[23]->SetFillStyle(4000);
0323     transparent[23]->Draw();
0324     TC[23]->SetEditable(false);
0325   }
0326   else if (name == "TPCChan_in_Packets_SS")
0327   {
0328     TC[24] = new TCanvas(name.c_str(), "TPC Channel Fraction Present in Packet in RCDAQ Event, sS ONLY", -1, 0, xsize, ysize);
0329     gSystem->ProcessEvents();
0330     TC[24]->Divide(2, 7);
0331     transparent[24] = new TPad("transparent24", "this does not show", 0, 0, 1, 1);
0332     transparent[24]->SetFillStyle(4000);
0333     transparent[24]->Draw();
0334     TC[24]->SetEditable(false);
0335   }
0336   else if (name == "TPCNonZSChannels")
0337   {
0338     TC[25] = new TCanvas(name.c_str(), "TPC non ZS Channels in SAMPAs acrosss whole Sector", -1, 0, xsize, ysize);
0339     gSystem->ProcessEvents();
0340     // gStyle->SetPalette(57); //kBird CVD friendly
0341     TC[25]->Divide(4, 7);
0342     transparent[25] = new TPad("transparent25", "this does not show", 0, 0, 1, 1);
0343     transparent[25]->SetFillStyle(4000);
0344     transparent[25]->Draw();
0345     TC[25]->SetEditable(false);
0346   }
0347   else if (name == "TPCNonZSTriggerADCvsSample")
0348   {
0349     TC[26] = new TCanvas(name.c_str(), "", -1, 0, xsize, ysize);
0350     gSystem->ProcessEvents();
0351     // gStyle->SetPalette(57); //kBird CVD friendly
0352     TC[26]->Divide(4, 7);
0353     transparent[26] = new TPad("transparent26", "this does not show", 0, 0, 1, 1);
0354     transparent[26]->SetFillStyle(4000);
0355     transparent[26]->Draw();
0356     TC[26]->SetEditable(false);
0357   }
0358   else if (name == "TPCFirstADCvsFirstSample")
0359   {
0360     TC[27] = new TCanvas(name.c_str(), "", -1, 0, xsize, ysize);
0361     gSystem->ProcessEvents();
0362     // gStyle->SetPalette(57); //kBird CVD friendly
0363     TC[27]->Divide(4, 7);
0364     transparent[27] = new TPad("transparent27", "this does not show", 0, 0, 1, 1);
0365     transparent[27]->SetFillStyle(4000);
0366     transparent[27]->Draw();
0367     TC[27]->SetEditable(false);
0368   }
0369   else if (name == "TPCDriftWindow")
0370   {
0371     TC[28] = new TCanvas(name.c_str(), "", -1, 0, xsize, ysize);
0372     gSystem->ProcessEvents();
0373     // gStyle->SetPalette(57); //kBird CVD friendly
0374     TC[28]->Divide(4, 7);
0375     transparent[28] = new TPad("transparent28", "this does not show", 0, 0, 1, 1);
0376     transparent[28]->SetFillStyle(4000);
0377     transparent[28]->Draw();
0378     TC[28]->SetEditable(false);
0379   }
0380   else if (name == "TPCNStreakersvsEventNo")
0381   {
0382     TC[29] = new TCanvas(name.c_str(), "TPC Number of Horizontal Tracks vs Event No.", -1, 0, xsize, ysize);
0383     gSystem->ProcessEvents();
0384     TC[29]->Divide(1, 2);
0385     transparent[29] = new TPad("transparent29", "this does not show", 0, 0, 1, 1);
0386     transparent[29]->SetFillStyle(4000);
0387     transparent[29]->Draw();
0388     TC[29]->SetEditable(false);
0389   }
0390   else if (name == "TPCPacketType")
0391   {
0392     TC[30] = new TCanvas(name.c_str(), "", -1, 0, xsize, ysize);
0393     gSystem->ProcessEvents();
0394     // gStyle->SetPalette(57); //kBird CVD friendly
0395     TC[30]->Divide(4, 7);
0396     transparent[30] = new TPad("transparent30", "this does not show", 0, 0, 1, 1);
0397     transparent[30]->SetFillStyle(4000);
0398     transparent[30]->Draw();
0399     TC[30]->SetEditable(false);
0400   }
0401   else if (name == "TPCChan_per_LVL1_NS")
0402   {
0403     TC[31] = new TCanvas(name.c_str(), "TPC Channels per LVL_1 in RCDAQ Event, NS ONLY", -1, 0, xsize, ysize);
0404     gSystem->ProcessEvents();
0405     TC[31]->Divide(2, 7);
0406     transparent[31] = new TPad("transparent31", "this does not show", 0, 0, 1, 1);
0407     transparent[31]->SetFillStyle(4000);
0408     transparent[31]->Draw();
0409     TC[31]->SetEditable(false);
0410   }
0411   else if (name == "TPCChan_per_LVL1_SS")
0412   {
0413     TC[32] = new TCanvas(name.c_str(), "TPC Channels per LVL_1 in RCDAQ Event, SS ONLY", -1, 0, xsize, ysize);
0414     gSystem->ProcessEvents();
0415     TC[32]->Divide(2, 7);
0416     transparent[32] = new TPad("transparent32", "this does not show", 0, 0, 1, 1);
0417     transparent[32]->SetFillStyle(4000);
0418     transparent[32]->Draw();
0419     TC[32]->SetEditable(false);
0420   }
0421   else if (name == "TPCParityError")
0422   {
0423     TC[33] = new TCanvas(name.c_str(), "TPC CheckSumError Probability in Events", -1, 0, xsize, ysize);
0424     gSystem->ProcessEvents();
0425     TC[33]->Divide(4, 7);
0426     transparent[33] = new TPad("transparent33", "this does not show", 0, 0, 1, 1);
0427     transparent[33]->SetFillStyle(4000);
0428     transparent[33]->Draw();
0429     TC[33]->SetEditable(false);
0430   }
0431   else if (name == "ShifterTPCDriftWindow")
0432   {
0433     TC[34] = new TCanvas(name.c_str(), "TPC Drift Window for Shifter Checks", -1, 0, xsize, ysize);
0434     gSystem->ProcessEvents();
0435     TC[34]->Divide(4, 7);
0436     transparent[34] = new TPad("transparent34", "this does not show", 0, 0, 1, 1);
0437     transparent[34]->SetFillStyle(4000);
0438     transparent[34]->Draw();
0439     TC[34]->SetEditable(false);
0440   }
0441   else if (name == "TPCNoiseChannelsPlots")
0442   {
0443     TC[35] = new TCanvas(name.c_str(), "Noise Channel Check for nonZS events w/ no load in TPC", -1, 0, xsize, ysize);
0444     gSystem->ProcessEvents();
0445     TC[35]->Divide(4, 7);
0446     transparent[35] = new TPad("transparent35", "this does not show", 0, 0, 1, 1);
0447     transparent[35]->SetFillStyle(4000);
0448     transparent[35]->Draw();
0449     TC[35]->SetEditable(false);
0450   }
0451   else if (name == "ShifterTPCTransmissionDist")
0452   {
0453     TC[36] = new TCanvas(name.c_str(), "Background Corrected Tranmission Distribution", -1, 0, xsize, ysize);
0454     gSystem->ProcessEvents();
0455     TC[36]->Divide(1, 1);
0456     transparent[36] = new TPad("transparent36", "this does not show", 0, 0, 1, 1);
0457     transparent[36]->SetFillStyle(4000);
0458     transparent[36]->Draw();
0459     TC[36]->SetEditable(false);
0460   }
0461   else if (name == "DC_vs_SAMPA_CANVAS")
0462   {
0463     std::cout << "creating TC[37]" << std::endl;
0464     TC[37] = new TCanvas(name.c_str(), "Digital Current vs SAMPA", -1, 0, xsize, ysize);
0465     gSystem->ProcessEvents();
0466     TC[37]->Divide(4, 7);
0467     transparent[37] = new TPad("transparent37", "this does not show", 0, 0, 1, 1);
0468     transparent[37]->SetFillStyle(4000);
0469     transparent[37]->Draw();
0470     TC[37]->SetEditable(false);
0471   }
0472   else if (name == "DC_SAMPA_vs_TIME_CANVAS")
0473   {
0474     TC[38] = new TCanvas(name.c_str(), "SAMPA vs TIME wtd. by Digital Current", -1, 0, xsize, ysize);
0475     gSystem->ProcessEvents();
0476     TC[38]->Divide(4, 7);
0477     transparent[38] = new TPad("transparent38", "this does not show", 0, 0, 1, 1);
0478     transparent[38]->SetFillStyle(4000);
0479     transparent[38]->Draw();
0480     TC[38]->SetEditable(false);
0481   }
0482   else if (name == "TPCPACKETTYPE_vs_SAMPLE_ADC")
0483   {
0484     TC[39] = new TCanvas(name.c_str(), "", -1, 0, xsize, ysize);
0485     gSystem->ProcessEvents();
0486     // gStyle->SetPalette(57); //kBird CVD friendly
0487     TC[39]->Divide(4, 7);
0488     transparent[39] = new TPad("transparent39", "this does not show", 0, 0, 1, 1);
0489     transparent[39]->SetFillStyle(4000);
0490     transparent[39]->Draw();
0491     TC[39]->SetEditable(false);
0492   }
0493   return 0;
0494 }
0495 
0496 int TpcMonDraw::Draw(const std::string &what)
0497 {
0498   int iret = 0;
0499   int idraw = 0;
0500   if (what == "ALL" || what == "TPCMODULE")
0501   {
0502     iret += DrawTPCModules(what);
0503     idraw++;
0504   }
0505   if (what == "ALL" || what == "TPCSAMPLESIZE")
0506   {
0507     iret += DrawTPCSampleSize(what);
0508     idraw++;
0509   }
0510   if (what == "ALL" || what == "TPCSTUCKCHANNELS")
0511   {
0512     iret += DrawTPCStuckChannels(what);
0513     idraw++;
0514   }
0515   if (what == "ALL" || what == "TPCCHECKSUMERROR")
0516   {
0517     iret += DrawTPCCheckSum(what);
0518     idraw++;
0519   }
0520   if (what == "ALL" || what == "TPCPARITYERROR")
0521   {
0522     iret += DrawTPCParity(what);
0523     idraw++;
0524   }
0525   if (what == "ALL" || what == "TPCADCVSSAMPLE")
0526   {
0527     iret += DrawTPCADCSample(what);
0528     idraw++;
0529   }
0530   if (what == "ALL" || what == "TPCMAXADCMODULE")
0531   {
0532     iret += DrawTPCMaxADCModule(what);
0533     idraw++;
0534   }
0535   if (what == "ALL" || what == "TPCRAWADC1D")
0536   {
0537     iret += DrawTPCRawADC1D(what);
0538     idraw++;
0539   }
0540   if (what == "ALL" || what == "TPCMAXADC1D")
0541   {
0542     iret += DrawTPCMaxADC1D(what);
0543     idraw++;
0544   }
0545   if (what == "ALL" || what == "TPCCLUSTERSXYWEIGTHED")
0546   {
0547     iret += DrawTPCXYclusters(what);
0548     idraw++;
0549   }
0550   if (what == "ALL" || what == "TPCCLUSTERSXYUNWEIGTHED")
0551   {
0552     iret += DrawTPCXYclusters_unweighted(what);
0553     idraw++;
0554   }
0555   if (what == "ALL" || what == "TPCADCVSSAMPLELARGE")
0556   {
0557     iret += DrawTPCADCSampleLarge(what);
0558     idraw++;
0559   }
0560   if (what == "ALL" || what == "TPCCLUSTERSZYWEIGTHED")
0561   {
0562     iret += DrawTPCZYclusters(what);
0563     idraw++;
0564   }
0565   if (what == "ALL" || what == "TPCCLUSTERSZYUNWEIGTHED")
0566   {
0567     iret += DrawTPCZYclusters_unweighted(what);
0568     idraw++;
0569   }
0570   if (what == "ALL" || what == "TPCCHANNELPHI_LAYER_WEIGHTED")
0571   {
0572     iret += DrawTPCchannelphi_layer_weighted(what);
0573     idraw++;
0574   }
0575   if (what == "ALL" || what == "TPCPEDESTSUBADC1D")
0576   {
0577     iret += DrawTPCPedestSubADC1D(what);
0578     idraw++;
0579   }
0580   if (what == "ALL" || what == "TPCNEVENTSEBDC")
0581   {
0582     iret += DrawTPCNEventsvsEBDC(what);
0583     idraw++;
0584   }
0585   if (what == "ALL" || what == "TPCPEDESTSUBADCVSSAMPLE")
0586   {
0587     iret += DrawTPCPedestSubADCSample(what);
0588     idraw++;
0589   }
0590   if (what == "ALL" || what == "TPCPEDESTSUBADCVSSAMPLE_R1")
0591   {
0592     iret += DrawTPCPedestSubADCSample_R1(what);
0593     idraw++;
0594   }
0595   if (what == "ALL" || what == "TPCPEDESTSUBADCVSSAMPLE_R2")
0596   {
0597     iret += DrawTPCPedestSubADCSample_R2(what);
0598     idraw++;
0599   }
0600   if (what == "ALL" || what == "TPCPEDESTSUBADCVSSAMPLE_R3")
0601   {
0602     iret += DrawTPCPedestSubADCSample_R3(what);
0603     idraw++;
0604   }
0605   if (what == "ALL" || what == "TPCLASERCLUSTERSXYWEIGTHED")
0606   {
0607     iret += DrawTPCXYlaserclusters(what);
0608     idraw++;
0609   }
0610   if (what == "ALL" || what == "TPCCLUSTERS5EXYUNWEIGTHED")
0611   {
0612     iret += DrawTPCXYclusters5event(what);
0613     idraw++;
0614   }
0615   if (what == "ALL" || what == "TPCCHANSINPACKETNS")
0616   {
0617     iret += DrawTPCChansinPacketNS(what);
0618     idraw++;
0619   }
0620   if (what == "ALL" || what == "TPCCHANSINPACKETSS")
0621   {
0622     iret += DrawTPCChansinPacketSS(what);
0623     idraw++;
0624   }
0625   if (what == "ALL" || what == "TPCCHANSPERLVL1NS")
0626   {
0627     iret += DrawTPCChansperLVL1_NS(what);
0628     idraw++;
0629   }
0630   if (what == "ALL" || what == "TPCCHANSPERLVL1SS")
0631   {
0632     iret += DrawTPCChansperLVL1_SS(what);
0633     idraw++;
0634   }
0635   if (what == "ALL" || what == "TPCNONZSCHANNELS")
0636   {
0637     iret += DrawTPCNonZSChannels(what);
0638     idraw++;
0639   }
0640   if (what == "ALL" || what == "TPCZSTRIGGERADCVSSAMPLE")
0641   {
0642     iret += DrawTPCZSTriggerADCSample(what);
0643     idraw++;
0644   }
0645   if (what == "ALL" || what == "TPCFIRSTNONZSADCVSFIRSTNONZSSAMPLE")
0646   {
0647     iret += DrawTPCFirstnonZSADCFirstnonZSSample(what);
0648     idraw++;
0649   }
0650   if (what == "ALL" || what == "TPCDRIFTWINDOW")
0651   {
0652     iret += DrawTPCDriftWindow(what);
0653     idraw++;
0654   }
0655   if (what == "ALL" || what == "SERVERSTATS")
0656   {
0657     iret += DrawServerStats();
0658     idraw++;
0659   }
0660   if (what == "ALL" || what == "TPCNSTREAKERSVSEVENTNO")
0661   {
0662     iret += DrawTPCNStreaksvsEventNo(what);
0663     idraw++;
0664   }
0665   if (what == "ALL" || what == "TPCPACKETYPEFRACTION")
0666   {
0667     iret += DrawTPCPacketTypes(what);
0668     idraw++;
0669   }
0670   if (what == "ALL" || what == "TPCPACKETTYPEVSSAMPLEADC")
0671   {
0672     iret += DrawTPCPACKETTYPEvsSAMPLEADC(what);
0673     idraw++;
0674   }
0675   if (what == "ALL" || what == "SHIFTER_DRIFT_PLOT")
0676   {
0677     iret += DrawShifterTPCDriftWindow(what);
0678     idraw++;
0679   }
0680   if (what == "ALL" || what == "TPCNOISECHANNELPLOTS")
0681   {
0682     iret += DrawTPCNoiseChannelPlots(what);
0683     idraw++;
0684   }
0685   if (what == "ALL" || what == "SHIFTER_TRANSMISSION_PLOT")
0686   {
0687     iret += DrawShifterTransmissionDist(what);
0688     idraw++;
0689   }
0690   if (what == "ALL" || what == "TPCDCVSSAMPA")
0691   {
0692     iret += DrawDCvsSAMPA(what);
0693     idraw++;
0694   }
0695   if (what == "ALL" || what == "TPCDCSAMPAVSTIME")
0696   {
0697     iret += DrawDCSAMPAvsTIME(what);
0698     idraw++;
0699   }
0700   if (!idraw)
0701   {
0702     std::cout << __PRETTY_FUNCTION__ << " Unimplemented Drawing option: " << what << std::endl;
0703     iret = -1;
0704   }
0705   return iret;
0706 }
0707 
0708 int TpcMonDraw::DrawTPCModules(const std::string & /* what */)
0709 {
0710   OnlMonClient *cl = OnlMonClient::instance();
0711   TH2 *tpcmon_NSIDEADC_u[48] = {nullptr};
0712   TH2 *tpcmon_SSIDEADC_u[48] = {nullptr};
0713 
0714   TH2 *tpcmon_NSIDEADC[24] = {nullptr};
0715   TH2 *tpcmon_SSIDEADC[24] = {nullptr};
0716 
0717   char TPCMON_STR[100];
0718   // TPC ADC pie chart
0719   for (int i = 0; i < 48; i++)
0720   {
0721     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
0722     sprintf(TPCMON_STR, "TPCMON_%i", i);
0723     tpcmon_NSIDEADC_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC");
0724     tpcmon_SSIDEADC_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC");
0725   }
0726 
0727   add_TH2(tpcmon_NSIDEADC_u, tpcmon_NSIDEADC);
0728   add_TH2(tpcmon_SSIDEADC_u, tpcmon_SSIDEADC);
0729 
0730   // TH2 *tpcmon_NSIDEADC1 = (TH2*) cl->getHisto("TPCMON_0","NorthSideADC");
0731   // TH2 *tpcmon_SSIDEADC1 = (TH2*) cl->getHisto("TPCMON_0","SouthSideADC");
0732 
0733   if (!gROOT->FindObject("TPCModules"))
0734   {
0735     MakeCanvas("TPCModules");
0736   }
0737 
0738   TCanvas *MyTC = TC[0];
0739   TPad *TransparentTPad = transparent[0];
0740 
0741   dummy_his1 = new TH2F("dummy_his1", "ADC Counts North Side", 100, -1.5, 1.5, 100, -1.5, 1.5);  // dummy histos for titles
0742   dummy_his2 = new TH2F("dummy_his2", "ADC Counts South Side", 100, -1.5, 1.5, 100, -1.5, 1.5);
0743 
0744   // labels
0745   NS18 = new TPaveLabel(1.046586, -0.1938999, 1.407997, 0.2144871, "18");
0746   NS17 = new TPaveLabel(0.962076, 0.4382608, 1.323487, 0.8466479, "17");
0747   NS16 = new TPaveLabel(0.4801947, 0.8802139, 0.8416056, 1.288601, "16");
0748   NS15 = new TPaveLabel(-0.1823921, 1.011681, 0.1790189, 1.425662, "15");
0749   NS14 = new TPaveLabel(-0.8449788, 0.8690253, -0.4835679, 1.288601, "14");
0750   NS13 = new TPaveLabel(-1.30879, 0.441058, -0.9473786, 0.8550394, "13");
0751   NS12 = new TPaveLabel(-1.411009, -0.2050886, -1.049598, 0.2144871, "12");
0752   NS23 = new TPaveLabel(-1.302585, -0.7757116, -0.9471979, -0.3561359, "23");
0753   NS22 = new TPaveLabel(-0.8449788, -1.309971, -0.4835679, -0.8848013, "22");
0754   NS21 = new TPaveLabel(-0.1823921, -1.426557, 0.1790189, -1.006982, "21");
0755   NS20 = new TPaveLabel(0.4801947, -1.309076, 0.8416056, -0.8839062, "20");
0756   NS19 = new TPaveLabel(0.9622567, -0.7785088, 1.323668, -0.3533387, "19");
0757 
0758   SS00 = new TPaveLabel(1.046586, -0.1938999, 1.407997, 0.2144871, "00");
0759   SS01 = new TPaveLabel(0.962076, 0.4382608, 1.323487, 0.8466479, "01");
0760   SS02 = new TPaveLabel(0.4801947, 0.8802139, 0.8416056, 1.288601, "02");
0761   SS03 = new TPaveLabel(-0.1823921, 1.011681, 0.1790189, 1.425662, "03");
0762   SS04 = new TPaveLabel(-0.8449788, 0.8690253, -0.4835679, 1.288601, "04");
0763   SS05 = new TPaveLabel(-1.30879, 0.441058, -0.9473786, 0.8550394, "05");
0764   SS06 = new TPaveLabel(-1.411009, -0.2050886, -1.049598, 0.2144871, "06");
0765   SS07 = new TPaveLabel(-1.302585, -0.7757116, -0.9471979, -0.3561359, "07");
0766   SS08 = new TPaveLabel(-0.8449788, -1.309971, -0.4835679, -0.8848013, "08");
0767   SS09 = new TPaveLabel(-0.1823921, -1.426557, 0.1790189, -1.006982, "09");
0768   SS10 = new TPaveLabel(0.4801947, -1.309076, 0.8416056, -0.8839062, "10");
0769   SS11 = new TPaveLabel(0.9622567, -0.7785088, 1.323668, -0.3533387, "11");
0770 
0771   NS18->SetFillColor(0);
0772   NS17->SetFillColor(0);
0773   NS16->SetFillColor(0);
0774   NS15->SetFillColor(0);
0775   NS14->SetFillColor(0);
0776   NS13->SetFillColor(0);
0777   NS12->SetFillColor(0);
0778   NS23->SetFillColor(0);
0779   NS22->SetFillColor(0);
0780   NS21->SetFillColor(0);
0781   NS20->SetFillColor(0);
0782   NS19->SetFillColor(0);
0783 
0784   SS00->SetFillColor(0);
0785   SS01->SetFillColor(0);
0786   SS02->SetFillColor(0);
0787   SS03->SetFillColor(0);
0788   SS04->SetFillColor(0);
0789   SS05->SetFillColor(0);
0790   SS06->SetFillColor(0);
0791   SS07->SetFillColor(0);
0792   SS08->SetFillColor(0);
0793   SS09->SetFillColor(0);
0794   SS10->SetFillColor(0);
0795   SS11->SetFillColor(0);
0796 
0797   MyTC->SetEditable(true);
0798   MyTC->Clear("D");
0799   MyTC->cd(1);
0800   gPad->SetTopMargin(0.15);
0801   gStyle->SetOptStat(0);
0802   dummy_his1->Draw("colpolzsame");
0803 
0804   float NS_max = 0;
0805   for (int i = 0; i < 12; i++)
0806   {
0807     if (tpcmon_NSIDEADC[i])
0808     {
0809       MyTC->cd(1);
0810       tpcmon_NSIDEADC[i]->DrawCopy("colpolzsame");
0811       if (tpcmon_NSIDEADC[i]->GetBinContent(tpcmon_NSIDEADC[i]->GetMaximumBin()) > NS_max)
0812       {
0813         NS_max = tpcmon_NSIDEADC[i]->GetBinContent(tpcmon_NSIDEADC[i]->GetMaximumBin());
0814         dummy_his1->SetMaximum(NS_max);
0815       }
0816       gStyle->SetPalette(57);  // kBird CVD friendly
0817     }
0818   }
0819   MyTC->Update();
0820   MyTC->cd(1);
0821   SS00->Draw("same");
0822   SS01->Draw("same");
0823   SS02->Draw("same");
0824   SS03->Draw("same");
0825   SS04->Draw("same");
0826   SS05->Draw("same");
0827   SS06->Draw("same");
0828   SS07->Draw("same");
0829   SS08->Draw("same");
0830   SS09->Draw("same");
0831   SS10->Draw("same");
0832   SS11->Draw("same");
0833 
0834   MyTC->cd(2);
0835   gPad->SetTopMargin(0.15);
0836   gStyle->SetOptStat(0);
0837   dummy_his2->Draw("colpolzsame");
0838 
0839   float SS_max = 0;
0840   for (int i = 0; i < 12; i++)
0841   {
0842     if (tpcmon_SSIDEADC[i + 12])
0843     {
0844       // std::cout<<"tpcmon_SSIDEADC i: "<< i+12 <<std::endl;
0845       MyTC->cd(2);
0846       tpcmon_SSIDEADC[i + 12]->DrawCopy("colpolzsame");
0847 
0848       if (tpcmon_SSIDEADC[i + 12]->GetBinContent(tpcmon_SSIDEADC[i + 12]->GetMaximumBin()) > SS_max)
0849       {
0850         SS_max = tpcmon_SSIDEADC[i + 12]->GetBinContent(tpcmon_SSIDEADC[i + 12]->GetMaximumBin());
0851         dummy_his2->SetMaximum(SS_max);
0852       }
0853 
0854       gStyle->SetPalette(57);  // kBird CVD friendly
0855     }
0856   }
0857   MyTC->Update();
0858 
0859   MyTC->cd(2);
0860   NS18->Draw("same");
0861   NS17->Draw("same");
0862   NS16->Draw("same");
0863   NS15->Draw("same");
0864   NS14->Draw("same");
0865   NS13->Draw("same");
0866   NS12->Draw("same");
0867   NS23->Draw("same");
0868   NS22->Draw("same");
0869   NS21->Draw("same");
0870   NS20->Draw("same");
0871   NS19->Draw("same");
0872 
0873   TText PrintRun;
0874   PrintRun.SetTextFont(62);
0875   PrintRun.SetTextSize(0.04);
0876   PrintRun.SetNDC();          // set to normalized coordinates
0877   PrintRun.SetTextAlign(23);  // center/top alignment
0878   std::ostringstream runnostream;
0879   std::string runstring;
0880   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
0881   // fill run number and event time into string
0882   runnostream << ThisName << "_SUMADC Run " << cl->RunNumber()
0883               << ", Time: " << ctime(&evttime.first);
0884   runstring = runnostream.str();
0885   TransparentTPad->cd();
0886   PrintRun.SetTextColor(evttime.second);
0887   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
0888 
0889   // turn off stats box
0890   // dummy_his1->SetStats(0);
0891   // dummy_his2->SetStats(0);
0892 
0893   MyTC->Update();
0894 
0895   MyTC->Show();
0896   MyTC->SetEditable(false);
0897 
0898   return 0;
0899 }
0900 
0901 int TpcMonDraw::DrawTPCSampleSize(const std::string & /* what */)
0902 {
0903   OnlMonClient *cl = OnlMonClient::instance();
0904 
0905   TH1 *tpcmon_samplesizedist_u[48] = {nullptr};
0906   TH1 *tpcmon_samplesizedist[24] = {nullptr};
0907 
0908   char TPCMON_STR[100];
0909   for (int i = 0; i < 48; i++)
0910   {
0911     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
0912     sprintf(TPCMON_STR, "TPCMON_%i", i);
0913     tpcmon_samplesizedist_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "sample_size_hist");
0914   }
0915 
0916   add_TH1(tpcmon_samplesizedist_u, tpcmon_samplesizedist);
0917 
0918   if (!gROOT->FindObject("TPCSampleSize"))
0919   {
0920     MakeCanvas("TPCSampleSize");
0921   }
0922   TCanvas *MyTC = TC[1];
0923   TPad *TransparentTPad = transparent[1];
0924   MyTC->SetEditable(true);
0925   MyTC->Clear("D");
0926   for (int i = 0; i < 24; i++)
0927   {
0928     if (tpcmon_samplesizedist[i])
0929     {
0930       MyTC->cd(i + 5);
0931       tpcmon_samplesizedist[i]->DrawCopy("");
0932       gPad->SetLogx(kTRUE);
0933       gPad->SetLogy(kTRUE);
0934     }
0935   }
0936 
0937   TText PrintRun;
0938   PrintRun.SetTextFont(62);
0939   PrintRun.SetTextSize(0.04);
0940   PrintRun.SetNDC();          // set to normalized coordinates
0941   PrintRun.SetTextAlign(23);  // center/top alignment
0942   std::ostringstream runnostream;
0943   std::string runstring;
0944   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
0945   // fill run number and event time into string
0946   runnostream << ThisName << "_SampleSize Run " << cl->RunNumber()
0947               << ", Time: " << ctime(&evttime.first);
0948   runstring = runnostream.str();
0949   TransparentTPad->cd();
0950   PrintRun.SetTextColor(evttime.second);
0951   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
0952 
0953   MyTC->Update();
0954   MyTC->SetLogx();
0955   MyTC->Show();
0956   MyTC->SetEditable(false);
0957 
0958   return 0;
0959 }
0960 
0961 int TpcMonDraw::DrawTPCCheckSum(const std::string & /* what */)
0962 {
0963   OnlMonClient *cl = OnlMonClient::instance();
0964 
0965   TH1 *tpcmon_checksumerror[24] = {nullptr};
0966   TH1 *tpcmon_checksums[24] = {nullptr};
0967 
0968   TH1 *tpcmon_checksumerror_u[48] = {nullptr};
0969   TH1 *tpcmon_checksums_u[48] = {nullptr};
0970 
0971   char TPCMON_STR[100];
0972   for (int i = 0; i < 48; i++)
0973   {
0974     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
0975     sprintf(TPCMON_STR, "TPCMON_%i", i);
0976     tpcmon_checksumerror_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Check_Sum_Error");
0977     tpcmon_checksums_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Check_Sums");
0978   }
0979 
0980   add_TH1(tpcmon_checksumerror_u, tpcmon_checksumerror);
0981   add_TH1(tpcmon_checksums_u, tpcmon_checksums);
0982 
0983   if (!gROOT->FindObject("TPCCheckSumError"))
0984   {
0985     MakeCanvas("TPCCheckSumError");
0986   }
0987   TCanvas *MyTC = TC[2];
0988   TPad *TransparentTPad = transparent[2];
0989 
0990   MyTC->SetEditable(true);
0991   MyTC->Clear("D");
0992   MyTC->cd(1);
0993 
0994   TLine *t1 = new TLine();
0995   t1->SetLineWidth(2);
0996   TLine *t2 = new TLine();
0997   t2->SetLineStyle(2);
0998   TText *tt1 = new TText();
0999   tt1->SetTextSize(0.05);
1000 
1001   int FEEid[26] = {
1002       2, 4, 3, 13, 17, 16,                       // R1
1003       11, 12, 19, 18, 0, 1, 15, 14,              // R2
1004       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
1005   };
1006 
1007   char title[50];
1008 
1009   for (int i = 0; i < 24; i++)
1010   {
1011     if (tpcmon_checksumerror[i] && tpcmon_checksums[i])
1012     {
1013       MyTC->cd(i + 5);
1014 
1015       tpcmon_checksumerror[i]->Divide(tpcmon_checksums[i]);
1016       tpcmon_checksumerror[i]->GetYaxis()->SetRangeUser(0.0001, 1.5);
1017       tpcmon_checksumerror[i]->DrawCopy("HIST");
1018 
1019       MyTC->Update();
1020 
1021       for (int j = 0; j < 25; j++)
1022       {
1023         t2->DrawLine((j + 1) * 8, -0.01, (j + 1) * 8, 1.5);
1024       }
1025       for (int k = 0; k < 26; k++)
1026       {
1027         sprintf(title, "%d", FEEid[k]);
1028         tt1->DrawText(k * 8 + 4, 1.2, title);
1029       }
1030       tt1->SetTextSize(0.06);
1031       tt1->DrawText(25, 1.4, "R1");
1032       tt1->DrawText(77, 1.4, "R2");
1033       tt1->DrawText(163, 1.4, "R3");
1034       tt1->SetTextSize(0.05);
1035 
1036       t1->DrawLine(48.5, -0.01, 48.5, 1.5);
1037       t1->DrawLine(112.5, -0.01, 112.5, 1.5);
1038     }
1039   }
1040 
1041   TText PrintRun;
1042   PrintRun.SetTextFont(62);
1043   PrintRun.SetTextSize(0.04);
1044   PrintRun.SetNDC();          // set to normalized coordinates
1045   PrintRun.SetTextAlign(23);  // center/top alignment
1046   std::ostringstream runnostream;
1047   std::string runstring;
1048   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1049   // fill run number and event time into string
1050   runnostream << ThisName << "_CheckSumError Run " << cl->RunNumber()
1051               << ", Time: " << ctime(&evttime.first);
1052   runstring = runnostream.str();
1053   TransparentTPad->cd();
1054   PrintRun.SetTextColor(evttime.second);
1055   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1056 
1057   MyTC->Update();
1058   // MyTC->SetLogy();
1059   MyTC->Show();
1060   MyTC->SetEditable(false);
1061 
1062   return 0;
1063 }
1064 
1065 int TpcMonDraw::DrawTPCADCSample(const std::string & /* what */)
1066 {
1067   OnlMonClient *cl = OnlMonClient::instance();
1068 
1069   TH2 *tpcmon_ADCSAMPLE[24] = {nullptr};
1070   TH2 *tpcmon_ADCSAMPLE_u[48] = {nullptr};
1071 
1072   char TPCMON_STR[100];
1073   for (int i = 0; i < 48; i++)
1074   {
1075     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1076     sprintf(TPCMON_STR, "TPCMON_%i", i);
1077     tpcmon_ADCSAMPLE_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "ADC_vs_SAMPLE");
1078   }
1079 
1080   add_TH2(tpcmon_ADCSAMPLE_u, tpcmon_ADCSAMPLE);
1081 
1082   if (!gROOT->FindObject("TPCADCSample"))
1083   {
1084     MakeCanvas("TPCADCSample");
1085   }
1086 
1087   TCanvas *MyTC = TC[3];
1088   TPad *TransparentTPad = transparent[3];
1089 
1090   MyTC->SetEditable(true);
1091   MyTC->Clear("D");
1092 
1093   for (int i = 0; i < 24; i++)
1094   {
1095     if (tpcmon_ADCSAMPLE[i])
1096     {
1097       MyTC->cd(i + 5);
1098       gStyle->SetPalette(57);  // kBird CVD friendly
1099       gPad->SetLogz(kTRUE);
1100       tpcmon_ADCSAMPLE[i]->DrawCopy("colz");
1101     }
1102   }
1103 
1104   TText PrintRun;
1105   PrintRun.SetTextFont(62);
1106   PrintRun.SetTextSize(0.04);
1107   PrintRun.SetNDC();          // set to normalized coordinates
1108   PrintRun.SetTextAlign(23);  // center/top alignment
1109   std::ostringstream runnostream;
1110   std::string runstring;
1111   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1112   // fill run number and event time into string
1113   runnostream << ThisName << "_ADC_vs_SAMPLE Run " << cl->RunNumber()
1114               << ", Time: " << ctime(&evttime.first);
1115   runstring = runnostream.str();
1116   TransparentTPad->cd();
1117   PrintRun.SetTextColor(evttime.second);
1118   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1119 
1120   MyTC->Update();
1121   MyTC->Show();
1122   MyTC->SetEditable(false);
1123 
1124   return 0;
1125 }
1126 
1127 int TpcMonDraw::DrawTPCMaxADCModule(const std::string & /* what */)
1128 {
1129   OnlMonClient *cl = OnlMonClient::instance();
1130 
1131   TH2 *tpcmon_MAXADC_MODULE[24] = {nullptr};
1132   TH2 *tpcmon_MAXADC_MODULE_u[48] = {nullptr};
1133 
1134   char TPCMON_STR[100];
1135   for (int i = 0; i < 48; i++)
1136   {
1137     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1138     sprintf(TPCMON_STR, "TPCMON_%i", i);
1139     tpcmon_MAXADC_MODULE_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "MAXADC");
1140   }
1141 
1142   add_TH2(tpcmon_MAXADC_MODULE_u, tpcmon_MAXADC_MODULE);
1143 
1144   if (!gROOT->FindObject("TPCMaxADCModule"))
1145   {
1146     MakeCanvas("TPCMaxADCModule");
1147   }
1148 
1149   TCanvas *MyTC = TC[4];
1150   TPad *TransparentTPad = transparent[4];
1151 
1152   MyTC->SetEditable(true);
1153   MyTC->Clear("D");
1154 
1155   for (int i = 0; i < 24; i++)
1156   {
1157     if (tpcmon_MAXADC_MODULE[i])
1158     {
1159       MyTC->cd(i + 5);
1160       gStyle->SetPalette(57);  // kBird CVD friendly
1161       gPad->SetLogz(kTRUE);
1162       tpcmon_MAXADC_MODULE[i]->DrawCopy("colz");
1163     }
1164   }
1165 
1166   TText PrintRun;
1167   PrintRun.SetTextFont(62);
1168   PrintRun.SetTextSize(0.04);
1169   PrintRun.SetNDC();          // set to normalized coordinates
1170   PrintRun.SetTextAlign(23);  // center/top alignment
1171   std::ostringstream runnostream;
1172   std::string runstring;
1173   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1174   // fill run number and event time into string
1175   runnostream << ThisName << "_MAXADC2D Run " << cl->RunNumber()
1176               << ", Time: " << ctime(&evttime.first);
1177   runstring = runnostream.str();
1178   TransparentTPad->cd();
1179   PrintRun.SetTextColor(evttime.second);
1180   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1181 
1182   MyTC->Update();
1183   MyTC->Show();
1184   MyTC->SetEditable(false);
1185 
1186   return 0;
1187 }
1188 
1189 int TpcMonDraw::DrawTPCRawADC1D(const std::string & /* what */)
1190 {
1191   // std::cout<<"Made it inside DrawTPCRawADC1D"<<std::endl;
1192   OnlMonClient *cl = OnlMonClient::instance();
1193 
1194   TH1 *tpcmon_RAWADC1D[24][3] = {nullptr};
1195   TH1 *tpcmon_RAWADC1D_u[48][3] = {nullptr};
1196 
1197   char TPCMON_STR[100];
1198   for (int i = 0; i < 48; i++)
1199   {
1200     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1201     sprintf(TPCMON_STR, "TPCMON_%i", i);
1202     tpcmon_RAWADC1D_u[i][0] = (TH1 *) cl->getHisto(TPCMON_STR, "RAWADC_1D_R1");
1203     tpcmon_RAWADC1D_u[i][1] = (TH1 *) cl->getHisto(TPCMON_STR, "RAWADC_1D_R2");
1204     tpcmon_RAWADC1D_u[i][2] = (TH1 *) cl->getHisto(TPCMON_STR, "RAWADC_1D_R3");
1205   }
1206 
1207   add_TH1_modules(tpcmon_RAWADC1D_u, tpcmon_RAWADC1D);
1208 
1209   if (!gROOT->FindObject("TPCRawADC1D"))
1210   {
1211     MakeCanvas("TPCRawADC1D");
1212   }
1213 
1214   TCanvas *MyTC = TC[5];
1215   TPad *TransparentTPad = transparent[5];
1216 
1217   MyTC->SetEditable(true);
1218   MyTC->Clear("D");
1219 
1220   auto legend = new TLegend(0.7, 0.65, 0.98, 0.95);
1221   bool draw_leg = 0;
1222 
1223   for (int i = 0; i < 24; i++)
1224   {
1225     MyTC->cd(i + 5);
1226     for (int j = 2; j > -1; j--)
1227     {
1228       if (tpcmon_RAWADC1D[i][j])
1229       {
1230         if (j == 2)
1231         {
1232           tpcmon_RAWADC1D[i][j]->DrawCopy("HIST");
1233         }
1234         else
1235         {
1236           tpcmon_RAWADC1D[i][j]->DrawCopy("HISTsame");
1237         }  // assumes that R3 will always exist and is most entries
1238       }
1239     }
1240     gPad->Update();
1241     gPad->SetLogy(kTRUE);
1242 
1243     if (draw_leg == 0 && tpcmon_RAWADC1D[i][0] && tpcmon_RAWADC1D[i][1] && tpcmon_RAWADC1D[i][2])  // if you have not drawn the legend yet, draw it BUT ONLY ONCE
1244     {
1245       legend->AddEntry(tpcmon_RAWADC1D[i][0], "R1");
1246       legend->AddEntry(tpcmon_RAWADC1D[i][1], "R2");
1247       legend->AddEntry(tpcmon_RAWADC1D[i][2], "R3");
1248       MyTC->cd(i + 5);
1249       legend->Draw();
1250       draw_leg = 1;  // don't draw it again
1251     }
1252   }
1253 
1254   TText PrintRun;
1255   PrintRun.SetTextFont(62);
1256   PrintRun.SetTextSize(0.04);
1257   PrintRun.SetNDC();          // set to normalized coordinates
1258   PrintRun.SetTextAlign(23);  // center/top alignment
1259   std::ostringstream runnostream;
1260   std::string runstring;
1261   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1262   // fill run number and event time into string
1263   runnostream << ThisName << "_RAWADC Run " << cl->RunNumber()
1264               << ", Time: " << ctime(&evttime.first);
1265   runstring = runnostream.str();
1266   TransparentTPad->cd();
1267   PrintRun.SetTextColor(evttime.second);
1268   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1269 
1270   MyTC->Update();
1271   MyTC->Show();
1272   MyTC->SetEditable(false);
1273 
1274   return 0;
1275 }
1276 
1277 int TpcMonDraw::DrawTPCMaxADC1D(const std::string & /* what */)
1278 {
1279   // std::cout<<"Made it inside DrawTPCMaxADC1D"<<std::endl;
1280   OnlMonClient *cl = OnlMonClient::instance();
1281 
1282   TH1 *tpcmon_MAXADC1D[24][3] = {nullptr};
1283   TH1 *tpcmon_MAXADC1D_u[48][3] = {nullptr};
1284 
1285   char TPCMON_STR[100];
1286   for (int i = 0; i < 48; i++)
1287   {
1288     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1289     sprintf(TPCMON_STR, "TPCMON_%i", i);
1290     tpcmon_MAXADC1D_u[i][0] = (TH1 *) cl->getHisto(TPCMON_STR, "MAXADC_1D_R1");
1291     tpcmon_MAXADC1D_u[i][1] = (TH1 *) cl->getHisto(TPCMON_STR, "MAXADC_1D_R2");
1292     tpcmon_MAXADC1D_u[i][2] = (TH1 *) cl->getHisto(TPCMON_STR, "MAXADC_1D_R3");
1293   }
1294 
1295   add_TH1_modules(tpcmon_MAXADC1D_u, tpcmon_MAXADC1D);
1296 
1297   if (!gROOT->FindObject("TPCMaxADC1D"))
1298   {
1299     MakeCanvas("TPCMaxADC1D");
1300   }
1301 
1302   TCanvas *MyTC = TC[6];
1303   TPad *TransparentTPad = transparent[6];
1304 
1305   MyTC->SetEditable(true);
1306   MyTC->Clear("D");
1307 
1308   auto legend = new TLegend(0.7, 0.65, 0.98, 0.95);
1309   bool draw_leg = 0;
1310 
1311   for (int i = 0; i < 24; i++)
1312   {
1313     MyTC->cd(i + 5);
1314     for (int j = 2; j > -1; j--)
1315     {
1316       if (tpcmon_MAXADC1D[i][j])
1317       {
1318         if (j == 2)
1319         {
1320           tpcmon_MAXADC1D[i][j]->DrawCopy("HIST");
1321         }
1322         else
1323         {
1324           tpcmon_MAXADC1D[i][j]->DrawCopy("HISTsame");
1325         }  // assumes that R3 will always exist and is max
1326       }
1327     }
1328     gPad->Update();
1329     gPad->SetLogy(kTRUE);
1330 
1331     if (draw_leg == 0 && tpcmon_MAXADC1D[i][0] && tpcmon_MAXADC1D[i][1] && tpcmon_MAXADC1D[i][2])  // if you have not drawn the legend yet, draw it BUT ONLY ONCE
1332     {
1333       MyTC->cd(i + 5);
1334       legend->AddEntry(tpcmon_MAXADC1D[i][0], "R1");
1335       legend->AddEntry(tpcmon_MAXADC1D[i][1], "R2");
1336       legend->AddEntry(tpcmon_MAXADC1D[i][2], "R3");
1337       legend->Draw();
1338       draw_leg = 1;  // don't draw it again
1339     }
1340   }
1341 
1342   TText PrintRun;
1343   PrintRun.SetTextFont(62);
1344   PrintRun.SetTextSize(0.04);
1345   PrintRun.SetNDC();          // set to normalized coordinates
1346   PrintRun.SetTextAlign(23);  // center/top alignment
1347   std::ostringstream runnostream;
1348   std::string runstring;
1349   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1350   // fill run number and event time into string
1351   runnostream << ThisName << "_LOCALMAXADC-PEDESTAL Run " << cl->RunNumber()
1352               << ", Time: " << ctime(&evttime.first);
1353   runstring = runnostream.str();
1354   TransparentTPad->cd();
1355   PrintRun.SetTextColor(evttime.second);
1356   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1357 
1358   MyTC->Update();
1359   MyTC->Show();
1360   MyTC->SetEditable(false);
1361 
1362   return 0;
1363 }
1364 int TpcMonDraw::DrawTPCXYclusters(const std::string & /* what */)
1365 {
1366   OnlMonClient *cl = OnlMonClient::instance();
1367 
1368   TH2 *tpcmon_NSTPC_clusXY[24][3] = {nullptr};
1369   TH2 *tpcmon_SSTPC_clusXY[24][3] = {nullptr};
1370 
1371   TH2 *tpcmon_NSTPC_clusXY_u[48][3] = {nullptr};
1372   TH2 *tpcmon_SSTPC_clusXY_u[48][3] = {nullptr};
1373 
1374   dummy_his1_XY = new TH2F("dummy_his1_XY", "(ADC-Pedestal) > (5#sigma||20ADC) North Side, WEIGHTED", 400, -800, 800, 400, -800, 800);  // dummy histos for titles
1375   dummy_his2_XY = new TH2F("dummy_his2_XY", "(ADC-Pedestal) > (5#sigma||20ADC) South Side, WEIGHTED", 400, -800, 800, 400, -800, 800);
1376 
1377   dummy_his1_XY->SetXTitle("X [mm]");
1378   dummy_his1_XY->SetYTitle("Y [mm]");
1379   dummy_his1_XY->GetYaxis()->SetTitleSize(0.02);
1380 
1381   dummy_his2_XY->SetXTitle("-X [mm]");  // SS x is flipped from global coordinates
1382   dummy_his2_XY->SetYTitle("Y [mm]");
1383   dummy_his2_XY->GetYaxis()->SetTitleSize(0.02);
1384 
1385   // the lines are for the sector boundaries
1386   Double_t sec_gap_inner = (2 * M_PI - 0.5024 * 12.0) / 12.0;
1387 
1388   Double_t sec_gap_outer = (2 * M_PI - 0.5097 * 12.0) / 12.0;
1389 
1390   Double_t sec_gap = (sec_gap_inner + sec_gap_outer) / 2.0;
1391 
1392   Double_t sec_phi = (0.5024 + 0.5097) / 2.0;
1393 
1394   TLine *lines[12];
1395 
1396   for (int ln = 0; ln < 12; ln++)
1397   {
1398     lines[ln] = new TLine(311.05 * cos((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 311.05 * sin((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 759.11 * cos((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 759.11 * sin((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)));
1399   }
1400 
1401   TEllipse *e1 = new TEllipse(0.0, 0.0, 311.05, 311.05);
1402   TEllipse *e2 = new TEllipse(0.0, 0.0, (402.49 + 411.53) / 2.0, (402.49 + 411.53) / 2.0);
1403   TEllipse *e3 = new TEllipse(0.0, 0.0, (583.67 + 574.75) / 2.0, (583.67 + 574.75) / 2.0);
1404   TEllipse *e4 = new TEllipse(0.0, 0.0, 759.11, 759.11);
1405   //__________________
1406 
1407   char TPCMON_STR[100];
1408   for (int i = 0; i < 48; i++)
1409   {
1410     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1411     sprintf(TPCMON_STR, "TPCMON_%i", i);
1412     tpcmon_NSTPC_clusXY_u[i][0] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R1");
1413     tpcmon_NSTPC_clusXY_u[i][1] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R2");
1414     tpcmon_NSTPC_clusXY_u[i][2] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R3");
1415 
1416     tpcmon_SSTPC_clusXY_u[i][0] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R1");
1417     tpcmon_SSTPC_clusXY_u[i][1] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R2");
1418     tpcmon_SSTPC_clusXY_u[i][2] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R3");
1419   }
1420 
1421   add_TH2_modules(tpcmon_NSTPC_clusXY_u, tpcmon_NSTPC_clusXY);
1422   add_TH2_modules(tpcmon_SSTPC_clusXY_u, tpcmon_SSTPC_clusXY);
1423 
1424   if (!gROOT->FindObject("TPCClusterXY"))
1425   {
1426     MakeCanvas("TPCClusterXY");
1427   }
1428 
1429   TCanvas *MyTC = TC[7];
1430   TPad *TransparentTPad = transparent[7];
1431 
1432   MyTC->SetEditable(true);
1433   MyTC->Clear("D");
1434 
1435   TText PrintRun;
1436   PrintRun.SetTextFont(62);
1437   PrintRun.SetTextSize(0.04);
1438   PrintRun.SetNDC();          // set to normalized coordinates
1439   PrintRun.SetTextAlign(23);  // center/top alignment
1440   std::ostringstream runnostream;
1441   std::string runstring;
1442   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1443   // fill run number and event time into string
1444   runnostream << ThisName << "_ADC-Pedestal>(5sigma||20ADC) WEIGHTED, Run" << cl->RunNumber()
1445               << ", Time: " << ctime(&evttime.first);
1446   runstring = runnostream.str();
1447   TransparentTPad->cd();
1448   PrintRun.SetTextColor(evttime.second);
1449   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1450 
1451   MyTC->cd(1);
1452   gStyle->SetOptStat(kFALSE);
1453   gPad->SetTopMargin(0.15);
1454   gPad->SetLogz(kTRUE);
1455   dummy_his1_XY->Draw("colzsame");
1456 
1457   float NS_max = 0;
1458   for (int i = 0; i < 12; i++)
1459   {
1460     for (int j = 0; j < 3; j++)
1461     {
1462       if (tpcmon_NSTPC_clusXY[i][j])
1463       {
1464         MyTC->cd(1);
1465         tpcmon_NSTPC_clusXY[i][j]->Draw("colzsame");
1466         // gStyle->SetLogz(kTRUE);
1467         if (tpcmon_NSTPC_clusXY[i][j]->GetBinContent(tpcmon_NSTPC_clusXY[i][j]->GetMaximumBin()) > NS_max)
1468         {
1469           NS_max = tpcmon_NSTPC_clusXY[i][j]->GetBinContent(tpcmon_NSTPC_clusXY[i][j]->GetMaximumBin());
1470           dummy_his1_XY->SetMaximum(NS_max);
1471         }
1472         gStyle->SetPalette(57);  // kBird CVD friendly
1473       }
1474     }
1475   }
1476   MyTC->cd(1);
1477   e1->SetFillStyle(0);
1478   e2->SetFillStyle(0);
1479   e3->SetFillStyle(0);
1480   e4->SetFillStyle(0);
1481 
1482   e1->Draw("same");
1483   e2->Draw("same");
1484   e3->Draw("same");
1485   e4->Draw("same");
1486   for (int ln2 = 0; ln2 < 12; ln2++)
1487   {
1488     lines[ln2]->Draw("same");
1489   }
1490   MyTC->Update();
1491 
1492   MyTC->cd(2);
1493   gStyle->SetOptStat(kFALSE);
1494   gPad->SetTopMargin(0.15);
1495   gPad->SetLogz(kTRUE);
1496   dummy_his2_XY->Draw("colzsame");
1497 
1498   float SS_max = 0;
1499   for (int i = 0; i < 12; i++)
1500   {
1501     for (int j = 0; j < 3; j++)
1502     {
1503       if (tpcmon_SSTPC_clusXY[i + 12][j])
1504       {
1505         // std::cout<<"South Side Custer XY i: "<< i+12 <<", j: "<<j<<std::endl;
1506         MyTC->cd(2);
1507         tpcmon_SSTPC_clusXY[i + 12][j]->Draw("colzsame");
1508         // gStyle->SetLogz(kTRUE);
1509         if (tpcmon_SSTPC_clusXY[i + 12][j]->GetBinContent(tpcmon_SSTPC_clusXY[i + 12][j]->GetMaximumBin()) > SS_max)
1510         {
1511           SS_max = tpcmon_SSTPC_clusXY[i + 12][j]->GetBinContent(tpcmon_SSTPC_clusXY[i + 12][j]->GetMaximumBin());
1512           dummy_his2_XY->SetMaximum(SS_max);
1513         }
1514         gStyle->SetPalette(57);  // kBird CVD friendly
1515       }
1516     }
1517   }
1518   MyTC->cd(2);
1519   e1->SetFillStyle(0);
1520   e2->SetFillStyle(0);
1521   e3->SetFillStyle(0);
1522   e4->SetFillStyle(0);
1523 
1524   e1->Draw("same");
1525   e2->Draw("same");
1526   e3->Draw("same");
1527   e4->Draw("same");
1528   for (int ln2 = 0; ln2 < 12; ln2++)
1529   {
1530     lines[ln2]->Draw("same");
1531   }
1532 
1533   MyTC->Update();
1534   MyTC->Show();
1535   MyTC->SetEditable(false);
1536 
1537   return 0;
1538 }
1539 
1540 int TpcMonDraw::DrawTPCXYclusters_unweighted(const std::string & /* what */)
1541 {
1542   OnlMonClient *cl = OnlMonClient::instance();
1543 
1544   TH2 *tpcmon_NSTPC_clusXY[24][3] = {nullptr};
1545   TH2 *tpcmon_SSTPC_clusXY[24][3] = {nullptr};
1546 
1547   TH2 *tpcmon_NSTPC_clusXY_u[48][3] = {nullptr};
1548   TH2 *tpcmon_SSTPC_clusXY_u[48][3] = {nullptr};
1549 
1550   dummy_his1_XY_unw = new TH2F("dummy_his1_XY_unw", "(ADC-Pedestal) > (5#sigma||20ADC) North Side, UNWEIGHTED", 400, -800, 800, 400, -800, 800);  // dummy histos for titles
1551   dummy_his2_XY_unw = new TH2F("dummy_his2_XY_unw", "(ADC-Pedestal) > (5#sigma||20ADC) South Side, UNWEIGHTED", 400, -800, 800, 400, -800, 800);
1552 
1553   dummy_his1_XY_unw->SetXTitle("X [mm]");
1554   dummy_his1_XY_unw->SetYTitle("Y [mm]");
1555   dummy_his1_XY_unw->GetYaxis()->SetTitleSize(0.02);
1556 
1557   dummy_his2_XY_unw->SetXTitle("-X [mm]");  // SS x is flipped from global coordinates
1558   dummy_his2_XY_unw->SetYTitle("Y [mm]");
1559   dummy_his2_XY_unw->GetYaxis()->SetTitleSize(0.02);
1560 
1561   // the lines are for the sector boundaries
1562   Double_t sec_gap_inner = (2 * M_PI - 0.5024 * 12.0) / 12.0;
1563 
1564   Double_t sec_gap_outer = (2 * M_PI - 0.5097 * 12.0) / 12.0;
1565 
1566   Double_t sec_gap = (sec_gap_inner + sec_gap_outer) / 2.0;
1567 
1568   Double_t sec_phi = (0.5024 + 0.5097) / 2.0;
1569 
1570   TLine *lines[12];
1571 
1572   for (int ln = 0; ln < 12; ln++)
1573   {
1574     lines[ln] = new TLine(311.05 * cos((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 311.05 * sin((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 759.11 * cos((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 759.11 * sin((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)));
1575   }
1576 
1577   TEllipse *e1 = new TEllipse(0.0, 0.0, 311.05, 311.05);
1578   TEllipse *e2 = new TEllipse(0.0, 0.0, (402.49 + 411.53) / 2.0, (402.49 + 411.53) / 2.0);
1579   TEllipse *e3 = new TEllipse(0.0, 0.0, (583.67 + 574.75) / 2.0, (583.67 + 574.75) / 2.0);
1580   TEllipse *e4 = new TEllipse(0.0, 0.0, 759.11, 759.11);
1581   //__________________
1582 
1583   char TPCMON_STR[100];
1584 
1585   for (int i = 0; i < 48; i++)
1586   {
1587     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1588     sprintf(TPCMON_STR, "TPCMON_%i", i);
1589     tpcmon_NSTPC_clusXY_u[i][0] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R1_unw");
1590     tpcmon_NSTPC_clusXY_u[i][1] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R2_unw");
1591     tpcmon_NSTPC_clusXY_u[i][2] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R3_unw");
1592 
1593     tpcmon_SSTPC_clusXY_u[i][0] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R1_unw");
1594     tpcmon_SSTPC_clusXY_u[i][1] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R2_unw");
1595     tpcmon_SSTPC_clusXY_u[i][2] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R3_unw");
1596   }
1597 
1598   add_TH2_modules(tpcmon_NSTPC_clusXY_u, tpcmon_NSTPC_clusXY);
1599   add_TH2_modules(tpcmon_SSTPC_clusXY_u, tpcmon_SSTPC_clusXY);
1600 
1601   if (!gROOT->FindObject("TPCClusterXY_unw"))
1602   {
1603     MakeCanvas("TPCClusterXY_unw");
1604   }
1605 
1606   TCanvas *MyTC = TC[8];
1607   TPad *TransparentTPad = transparent[8];
1608 
1609   MyTC->SetEditable(true);
1610   MyTC->Clear("D");
1611 
1612   TText PrintRun;
1613   PrintRun.SetTextFont(62);
1614   PrintRun.SetTextSize(0.04);
1615   PrintRun.SetNDC();          // set to normalized coordinates
1616   PrintRun.SetTextAlign(23);  // center/top alignment
1617   std::ostringstream runnostream;
1618   std::string runstring;
1619   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1620   // fill run number and event time into string
1621   runnostream << ThisName << "_ADC-Pedestal>(5sigma||20ADC), UNWEIGHTED, Run " << cl->RunNumber()
1622               << ", Time: " << ctime(&evttime.first);
1623   runstring = runnostream.str();
1624   TransparentTPad->cd();
1625   PrintRun.SetTextColor(evttime.second);
1626   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1627 
1628   MyTC->cd(1);
1629   gStyle->SetOptStat(kFALSE);
1630   gPad->SetTopMargin(0.15);
1631   // gPad->SetLogz(kTRUE);
1632   dummy_his1_XY_unw->Draw("colzsame");
1633 
1634   float NS_max = 0;
1635   for (int i = 0; i < 12; i++)
1636   {
1637     for (int j = 0; j < 3; j++)
1638     {
1639       if (tpcmon_NSTPC_clusXY[i][j])
1640       {
1641         MyTC->cd(1);
1642         tpcmon_NSTPC_clusXY[i][j]->Draw("colzsame");
1643         // gStyle->SetLogz(kTRUE);
1644         if (tpcmon_NSTPC_clusXY[i][j]->GetBinContent(tpcmon_NSTPC_clusXY[i][j]->GetMaximumBin()) > NS_max)
1645         {
1646           NS_max = tpcmon_NSTPC_clusXY[i][j]->GetBinContent(tpcmon_NSTPC_clusXY[i][j]->GetMaximumBin());
1647           dummy_his1_XY_unw->SetMaximum(NS_max);
1648         }
1649         gStyle->SetPalette(57);  // kBird CVD friendly
1650       }
1651     }
1652   }
1653   MyTC->cd(1);
1654   e1->SetFillStyle(0);
1655   e2->SetFillStyle(0);
1656   e3->SetFillStyle(0);
1657   e4->SetFillStyle(0);
1658 
1659   e1->Draw("same");
1660   e2->Draw("same");
1661   e3->Draw("same");
1662   e4->Draw("same");
1663   for (int ln2 = 0; ln2 < 12; ln2++)
1664   {
1665     lines[ln2]->Draw("same");
1666   }
1667   MyTC->Update();
1668 
1669   MyTC->cd(2);
1670   gStyle->SetOptStat(kFALSE);
1671   gPad->SetTopMargin(0.15);
1672   dummy_his2_XY_unw->Draw("colzsame");
1673   // gPad->SetLogz(kTRUE);
1674 
1675   float SS_max = 0;
1676   for (int i = 0; i < 12; i++)
1677   {
1678     for (int j = 0; j < 3; j++)
1679     {
1680       if (tpcmon_SSTPC_clusXY[i + 12][j])
1681       {
1682         // std::cout<<"South Side Custer XY i: "<< i+12 <<", j: "<<j<<std::endl;
1683         MyTC->cd(2);
1684         tpcmon_SSTPC_clusXY[i + 12][j]->Draw("colzsame");
1685         // gStyle->SetLogz(kTRUE);
1686         if (tpcmon_SSTPC_clusXY[i + 12][j]->GetBinContent(tpcmon_SSTPC_clusXY[i + 12][j]->GetMaximumBin()) > SS_max)
1687         {
1688           SS_max = tpcmon_SSTPC_clusXY[i + 12][j]->GetBinContent(tpcmon_SSTPC_clusXY[i + 12][j]->GetMaximumBin());
1689           dummy_his2_XY_unw->SetMaximum(SS_max);
1690         }
1691         gStyle->SetPalette(57);  // kBird CVD friendly
1692       }
1693     }
1694   }
1695   MyTC->cd(2);
1696   e1->SetFillStyle(0);
1697   e2->SetFillStyle(0);
1698   e3->SetFillStyle(0);
1699   e4->SetFillStyle(0);
1700 
1701   e1->Draw("same");
1702   e2->Draw("same");
1703   e3->Draw("same");
1704   e4->Draw("same");
1705   for (int ln2 = 0; ln2 < 12; ln2++)
1706   {
1707     lines[ln2]->Draw("same");
1708   }
1709   MyTC->Update();
1710 
1711   MyTC->Show();
1712   MyTC->SetEditable(false);
1713 
1714   return 0;
1715 }
1716 
1717 int TpcMonDraw::DrawTPCADCSampleLarge(const std::string & /* what */)
1718 {
1719   OnlMonClient *cl = OnlMonClient::instance();
1720 
1721   TH2 *tpcmon_ADCSAMPLE_large[24] = {nullptr};
1722   TH2 *tpcmon_ADCSAMPLE_large_u[48] = {nullptr};
1723 
1724   char TPCMON_STR[100];
1725   for (int i = 0; i < 48; i++)
1726   {
1727     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1728     sprintf(TPCMON_STR, "TPCMON_%i", i);
1729     tpcmon_ADCSAMPLE_large_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "ADC_vs_SAMPLE_large");
1730   }
1731 
1732   add_TH2(tpcmon_ADCSAMPLE_large_u, tpcmon_ADCSAMPLE_large);
1733 
1734   if (!gROOT->FindObject("TPCADCSamplelarge"))
1735   {
1736     MakeCanvas("TPCADCSamplelarge");
1737   }
1738 
1739   TCanvas *MyTC = TC[9];
1740   TPad *TransparentTPad = transparent[9];
1741 
1742   MyTC->SetEditable(true);
1743   MyTC->Clear("D");
1744 
1745   for (int i = 0; i < 24; i++)
1746   {
1747     if (tpcmon_ADCSAMPLE_large[i])
1748     {
1749       MyTC->cd(i + 5);
1750       gStyle->SetPalette(57);  // kBird CVD friendly
1751       gPad->SetLogz(kTRUE);
1752       tpcmon_ADCSAMPLE_large[i]->DrawCopy("colz");
1753     }
1754   }
1755 
1756   TText PrintRun;
1757   PrintRun.SetTextFont(62);
1758   PrintRun.SetTextSize(0.04);
1759   PrintRun.SetNDC();          // set to normalized coordinates
1760   PrintRun.SetTextAlign(23);  // center/top alignment
1761   std::ostringstream runnostream;
1762   std::string runstring;
1763   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1764   // fill run number and event time into string
1765   runnostream << ThisName << "_ADC_vs_SAMPLE_large Run " << cl->RunNumber()
1766               << ", Time: " << ctime(&evttime.first);
1767   runstring = runnostream.str();
1768   TransparentTPad->cd();
1769   PrintRun.SetTextColor(evttime.second);
1770   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1771 
1772   MyTC->Update();
1773   MyTC->Show();
1774   MyTC->SetEditable(false);
1775 
1776   return 0;
1777 }
1778 
1779 int TpcMonDraw::DrawTPCZYclusters(const std::string & /* what */)
1780 {
1781   OnlMonClient *cl = OnlMonClient::instance();
1782 
1783   TH2 *tpcmon_NSTPC_clusZY[24] = {nullptr};
1784   TH2 *tpcmon_SSTPC_clusZY[24] = {nullptr};
1785 
1786   TH2 *tpcmon_NSTPC_clusZY_u[48] = {nullptr};
1787   TH2 *tpcmon_SSTPC_clusZY_u[48] = {nullptr};
1788 
1789   dummy_his1_ZY = new TH2F("dummy_his1_ZY", "(ADC-Pedestal) > ((5#sigma||20ADC), WEIGHTED", 515, -1030, 1030, 400, -800, 800);  // dummy histos for titles
1790   dummy_his1_ZY->SetXTitle("Z [mm]");
1791   dummy_his1_ZY->SetYTitle("Y [mm]");
1792 
1793   char TPCMON_STR[100];
1794   for (int i = 0; i < 48; i++)
1795   {
1796     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1797     sprintf(TPCMON_STR, "TPCMON_%i", i);
1798     tpcmon_NSTPC_clusZY_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterZY");
1799 
1800     tpcmon_SSTPC_clusZY_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterZY");
1801   }
1802 
1803   add_TH2(tpcmon_NSTPC_clusZY_u, tpcmon_NSTPC_clusZY);
1804   add_TH2(tpcmon_SSTPC_clusZY_u, tpcmon_SSTPC_clusZY);
1805 
1806   if (!gROOT->FindObject("TPCClusterZY"))
1807   {
1808     MakeCanvas("TPCClusterZY");
1809   }
1810 
1811   TCanvas *MyTC = TC[10];
1812   TPad *TransparentTPad = transparent[10];
1813 
1814   MyTC->SetEditable(true);
1815   MyTC->Clear("D");
1816 
1817   TText PrintRun;
1818   PrintRun.SetTextFont(62);
1819   PrintRun.SetTextSize(0.04);
1820   PrintRun.SetNDC();          // set to normalized coordinates
1821   PrintRun.SetTextAlign(23);  // center/top alignment
1822   std::ostringstream runnostream;
1823   std::string runstring;
1824   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1825   // fill run number and event time into string
1826   runnostream << ThisName << "_ADC-Pedestal>(5sigma||20ADC), WEIGHTED, Run " << cl->RunNumber()
1827               << ", Time: " << ctime(&evttime.first);
1828   runstring = runnostream.str();
1829   TransparentTPad->cd();
1830   PrintRun.SetTextColor(evttime.second);
1831   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1832 
1833   MyTC->cd(1);
1834   gStyle->SetOptStat(kFALSE);
1835   gPad->SetTopMargin(0.15);
1836   gPad->SetLogz(kTRUE);
1837   dummy_his1_ZY->Draw("colzsame");
1838 
1839   float max = 0;
1840   for (int i = 0; i < 12; i++)
1841   {
1842     if (tpcmon_NSTPC_clusZY[i])
1843     {
1844       MyTC->cd(1);
1845       tpcmon_NSTPC_clusZY[i]->Draw("colzsame");
1846       if (tpcmon_NSTPC_clusZY[i]->GetBinContent(tpcmon_NSTPC_clusZY[i]->GetMaximumBin()) > max)
1847       {
1848         max = tpcmon_NSTPC_clusZY[i]->GetBinContent(tpcmon_NSTPC_clusZY[i]->GetMaximumBin());
1849         dummy_his1_ZY->SetMaximum(max);
1850       }
1851       gStyle->SetPalette(57);  // kBird CVD friendly
1852     }
1853   }
1854   MyTC->Update();
1855 
1856   for (int i = 0; i < 12; i++)
1857   {
1858     if (tpcmon_SSTPC_clusZY[i + 12])
1859     {
1860       MyTC->cd(1);
1861       tpcmon_SSTPC_clusZY[i + 12]->Draw("colzsame");
1862       if (tpcmon_SSTPC_clusZY[i + 12]->GetBinContent(tpcmon_SSTPC_clusZY[i + 12]->GetMaximumBin()) > max)
1863       {
1864         max = tpcmon_SSTPC_clusZY[i + 12]->GetBinContent(tpcmon_SSTPC_clusZY[i + 12]->GetMaximumBin());
1865         dummy_his1_ZY->SetMaximum(max);
1866       }
1867       // gStyle->SetLogz(kTRUE);
1868       gStyle->SetPalette(57);  // kBird CVD friendly
1869     }
1870   }
1871 
1872   MyTC->Update();
1873   MyTC->Show();
1874   MyTC->SetEditable(false);
1875 
1876   return 0;
1877 }
1878 
1879 int TpcMonDraw::DrawTPCZYclusters_unweighted(const std::string & /* what */)
1880 {
1881   OnlMonClient *cl = OnlMonClient::instance();
1882 
1883   TH2 *tpcmon_NSTPC_clusZY_unw[24] = {nullptr};
1884   TH2 *tpcmon_SSTPC_clusZY_unw[24] = {nullptr};
1885 
1886   TH2 *tpcmon_NSTPC_clusZY_unw_u[48] = {nullptr};
1887   TH2 *tpcmon_SSTPC_clusZY_unw_u[48] = {nullptr};
1888 
1889   dummy_his1_ZY_unw = new TH2F("dummy_his1_ZY_unw", "(ADC-Pedestal) > (5#sigma||20ADC), UNWEIGHTED", 515, -1030, 1030, 400, -800, 800);  // dummy histos for titles
1890   dummy_his1_ZY_unw->SetXTitle("Z [mm]");
1891   dummy_his1_ZY_unw->SetYTitle("Y [mm]");
1892 
1893   char TPCMON_STR[100];
1894   for (int i = 0; i < 48; i++)
1895   {
1896     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1897     sprintf(TPCMON_STR, "TPCMON_%i", i);
1898     tpcmon_NSTPC_clusZY_unw_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterZY_unw");
1899 
1900     tpcmon_SSTPC_clusZY_unw_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterZY_unw");
1901   }
1902 
1903   add_TH2(tpcmon_NSTPC_clusZY_unw_u, tpcmon_NSTPC_clusZY_unw);
1904   add_TH2(tpcmon_SSTPC_clusZY_unw_u, tpcmon_SSTPC_clusZY_unw);
1905 
1906   if (!gROOT->FindObject("TPCClusterZY_unw"))
1907   {
1908     MakeCanvas("TPCClusterZY_unw");
1909   }
1910 
1911   TCanvas *MyTC = TC[11];
1912   TPad *TransparentTPad = transparent[11];
1913 
1914   MyTC->SetEditable(true);
1915   MyTC->Clear("D");
1916 
1917   TText PrintRun;
1918   PrintRun.SetTextFont(62);
1919   PrintRun.SetTextSize(0.04);
1920   PrintRun.SetNDC();          // set to normalized coordinates
1921   PrintRun.SetTextAlign(23);  // center/top alignment
1922   std::ostringstream runnostream;
1923   std::string runstring;
1924   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
1925   // fill run number and event time into string
1926   runnostream << ThisName << "_ADC-Pedestal>(5sigma||20ADC), UNWEIGHTED, Run " << cl->RunNumber()
1927               << ", Time: " << ctime(&evttime.first);
1928   runstring = runnostream.str();
1929   TransparentTPad->cd();
1930   PrintRun.SetTextColor(evttime.second);
1931   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
1932 
1933   MyTC->cd(1);
1934   gStyle->SetOptStat(kFALSE);
1935   gPad->SetTopMargin(0.15);
1936   gPad->SetLogz(kTRUE);
1937   dummy_his1_ZY_unw->Draw("colzsame");
1938 
1939   float max = 0;
1940   for (int i = 0; i < 12; i++)
1941   {
1942     if (tpcmon_NSTPC_clusZY_unw[i])
1943     {
1944       MyTC->cd(1);
1945       tpcmon_NSTPC_clusZY_unw[i]->Draw("colzsame");
1946       if (tpcmon_NSTPC_clusZY_unw[i]->GetBinContent(tpcmon_NSTPC_clusZY_unw[i]->GetMaximumBin()) > max)
1947       {
1948         max = tpcmon_NSTPC_clusZY_unw[i]->GetBinContent(tpcmon_NSTPC_clusZY_unw[i]->GetMaximumBin());
1949         dummy_his1_ZY->SetMaximum(max);
1950       }
1951       // gStyle->SetLogz(kTRUE);
1952       gStyle->SetPalette(57);  // kBird CVD friendly
1953     }
1954   }
1955   MyTC->Update();
1956 
1957   for (int i = 0; i < 12; i++)
1958   {
1959     if (tpcmon_SSTPC_clusZY_unw[i + 12])
1960     {
1961       MyTC->cd(1);
1962       tpcmon_SSTPC_clusZY_unw[i + 12]->Draw("colzsame");
1963       if (tpcmon_SSTPC_clusZY_unw[i + 12]->GetBinContent(tpcmon_SSTPC_clusZY_unw[i + 12]->GetMaximumBin()) > max)
1964       {
1965         max = tpcmon_SSTPC_clusZY_unw[i + 12]->GetBinContent(tpcmon_SSTPC_clusZY_unw[i + 12]->GetMaximumBin());
1966         dummy_his1_ZY->SetMaximum(max);
1967       }
1968       // gStyle->SetLogz(kTRUE);
1969       gStyle->SetPalette(57);  // kBird CVD friendly
1970     }
1971   }
1972   MyTC->Update();
1973 
1974   MyTC->Show();
1975   MyTC->SetEditable(false);
1976 
1977   return 0;
1978 }
1979 int TpcMonDraw::DrawTPCchannelphi_layer_weighted(const std::string & /* what */)
1980 {
1981   OnlMonClient *cl = OnlMonClient::instance();
1982 
1983   TH2 *tpcmonth2channelphi_layer[24] = {nullptr};
1984   TH2 *tpcmonth2channelphi_layer_u[48] = {nullptr};
1985 
1986   char TPCMON_STR[100];
1987 
1988   dummy_his1_channelphi_layer_w = new TH2F("dummy_his1_channelphi_layer_", "(ADC-Pedestal) > 20 ADC, UNWEIGHTED", 515, -1030, 1030, 400, -800, 800);  // dummy histos for titles
1989   dummy_his1_channelphi_layer_w->SetXTitle("#phi chan. #");
1990   dummy_his1_channelphi_layer_w->SetYTitle("layer ");
1991   dummy_his1_channelphi_layer_w->SetZTitle("#Sigma(ADC-ped.)");
1992 
1993   for (int i = 0; i < 48; i++)
1994   {
1995     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
1996     sprintf(TPCMON_STR, "TPCMON_%i", i);
1997     tpcmonth2channelphi_layer_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "Layer_ChannelPhi_ADC_weighted");
1998   }
1999 
2000   add_TH2(tpcmonth2channelphi_layer_u, tpcmonth2channelphi_layer);
2001 
2002   if (!gROOT->FindObject("TPCLayerPhi"))
2003   {
2004     MakeCanvas("TPCLayerPhi");
2005   }
2006 
2007   TCanvas *MyTC = TC[12];
2008   TPad *TransparentTPad = transparent[12];
2009 
2010   MyTC->SetEditable(true);
2011   MyTC->Clear("D");
2012 
2013   TText PrintRun;
2014   PrintRun.SetTextFont(62);
2015   PrintRun.SetTextSize(0.04);
2016   PrintRun.SetNDC();          // set to normalized coordinates
2017   PrintRun.SetTextAlign(23);  // center/top alignment
2018   std::ostringstream runnostream;
2019   std::string runstring;
2020   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2021   // fill run number and event time into string
2022   runnostream << ThisName << "_ChannelPhi_vs_Layer_ADC_weighted " << cl->RunNumber()
2023               << ", Time: " << ctime(&evttime.first);
2024   runstring = runnostream.str();
2025   TransparentTPad->cd();
2026   PrintRun.SetTextColor(evttime.second);
2027   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2028 
2029   MyTC->cd(1);
2030   gStyle->SetOptStat(kFALSE);
2031   gPad->SetTopMargin(0.15);
2032   gPad->SetLogz(kTRUE);
2033   dummy_his1_channelphi_layer_w->Draw("lego2zsame");
2034 
2035   float max = 0;
2036   for (int i = 0; i < 24; i++)
2037   {
2038     if (tpcmonth2channelphi_layer[i])
2039     {
2040       MyTC->cd(1);
2041       tpcmonth2channelphi_layer[i]->Draw("lego2zsame");
2042       if (tpcmonth2channelphi_layer[i]->GetBinContent(tpcmonth2channelphi_layer[i]->GetMaximumBin()) > max)
2043       {
2044         max = tpcmonth2channelphi_layer[i]->GetBinContent(tpcmonth2channelphi_layer[i]->GetMaximumBin());
2045         dummy_his1_channelphi_layer_w->SetMaximum(max);
2046       }
2047       // gStyle->SetLogz(kTRUE);
2048       gStyle->SetPalette(57);  // kBird CVD friendly
2049     }
2050   }
2051   MyTC->Update();
2052 
2053   MyTC->Show();
2054   MyTC->SetEditable(false);
2055 
2056   return 0;
2057 }
2058 
2059 int TpcMonDraw::DrawTPCPedestSubADC1D(const std::string & /* what */)
2060 {
2061   // std::cout<<"Made it inside DrawTPCRawADC1D"<<std::endl;
2062   OnlMonClient *cl = OnlMonClient::instance();
2063 
2064   TH1 *tpcmon_PEDESTSUBADC1D[24][3] = {nullptr};
2065   TH1 *tpcmon_PEDESTSUBADC1D_u[48][3] = {nullptr};
2066 
2067   char TPCMON_STR[100];
2068   for (int i = 0; i < 48; i++)
2069   {
2070     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2071     sprintf(TPCMON_STR, "TPCMON_%i", i);
2072     tpcmon_PEDESTSUBADC1D_u[i][0] = (TH1 *) cl->getHisto(TPCMON_STR, "PEDEST_SUB_1D_R1");
2073     tpcmon_PEDESTSUBADC1D_u[i][1] = (TH1 *) cl->getHisto(TPCMON_STR, "PEDEST_SUB_1D_R2");
2074     tpcmon_PEDESTSUBADC1D_u[i][2] = (TH1 *) cl->getHisto(TPCMON_STR, "PEDEST_SUB_1D_R3");
2075   }
2076 
2077   add_TH1_modules(tpcmon_PEDESTSUBADC1D_u, tpcmon_PEDESTSUBADC1D);
2078 
2079   if (!gROOT->FindObject("TPCPedestSubADC1D"))
2080   {
2081     MakeCanvas("TPCPedestSubADC1D");
2082   }
2083 
2084   TCanvas *MyTC = TC[13];
2085   TPad *TransparentTPad = transparent[13];
2086 
2087   MyTC->SetEditable(true);
2088   MyTC->Clear("D");
2089 
2090   auto legend = new TLegend(0.7, 0.65, 0.98, 0.95);
2091   bool draw_leg = 0;
2092 
2093   for (int i = 0; i < 24; i++)
2094   {
2095     MyTC->cd(i + 5);
2096     for (int j = 2; j > -1; j--)
2097     {
2098       if (tpcmon_PEDESTSUBADC1D[i][j])
2099       {
2100         if (j == 2)
2101         {
2102           tpcmon_PEDESTSUBADC1D[i][j]->DrawCopy("HIST");
2103         }
2104         else
2105         {
2106           tpcmon_PEDESTSUBADC1D[i][j]->DrawCopy("HISTsame");
2107         }  // assumes that R3 will always exist and is most entries
2108       }
2109     }
2110     gPad->Update();
2111     gPad->SetLogy(kTRUE);
2112 
2113     if (draw_leg == 0 && tpcmon_PEDESTSUBADC1D[i][0] && tpcmon_PEDESTSUBADC1D[i][1] && tpcmon_PEDESTSUBADC1D[i][2])  // if you have not drawn the legend yet, draw it BUT ONLY ONCE
2114     {
2115       legend->AddEntry(tpcmon_PEDESTSUBADC1D[i][0], "R1");
2116       legend->AddEntry(tpcmon_PEDESTSUBADC1D[i][1], "R2");
2117       legend->AddEntry(tpcmon_PEDESTSUBADC1D[i][2], "R3");
2118       MyTC->cd(i + 5);
2119       legend->Draw();
2120       draw_leg = 1;  // don't draw it again
2121     }
2122   }
2123 
2124   TText PrintRun;
2125   PrintRun.SetTextFont(62);
2126   PrintRun.SetTextSize(0.04);
2127   PrintRun.SetNDC();          // set to normalized coordinates
2128   PrintRun.SetTextAlign(23);  // center/top alignment
2129   std::ostringstream runnostream;
2130   std::string runstring;
2131   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2132   // fill run number and event time into string
2133   runnostream << ThisName << "_PEDESTSUBADC Run " << cl->RunNumber()
2134               << ", Time: " << ctime(&evttime.first);
2135   runstring = runnostream.str();
2136   TransparentTPad->cd();
2137   PrintRun.SetTextColor(evttime.second);
2138   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2139 
2140   MyTC->Update();
2141   MyTC->Show();
2142   MyTC->SetEditable(false);
2143 
2144   return 0;
2145 }
2146 
2147 int TpcMonDraw::DrawTPCNEventsvsEBDC(const std::string & /* what */)
2148 {
2149   OnlMonClient *cl = OnlMonClient::instance();
2150 
2151   TH1 *tpcmoneventsebdc[24] = {nullptr};
2152   TH1 *tpcmoneventsebdc_u[48] = {nullptr};
2153 
2154   char TPCMON_STR[100];
2155 
2156   dummy_his1_NEvents_EBDC = new TH1F("dummy_his1_Nevents_EBDC", "N_{Events} vs EBDC", 24, -0.5, 23.5);  // dummy histos for titles
2157   dummy_his1_NEvents_EBDC->SetXTitle("EBDC #");
2158   dummy_his1_NEvents_EBDC->SetYTitle("N_{Events}");
2159 
2160   for (int i = 0; i < 48; i++)
2161   {
2162     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2163     sprintf(TPCMON_STR, "TPCMON_%i", i);
2164     tpcmoneventsebdc_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "NEvents_vs_EBDC");
2165   }
2166 
2167   add_TH1(tpcmoneventsebdc_u, tpcmoneventsebdc);
2168 
2169   if (!gROOT->FindObject("TPCNEventsEBDC"))
2170   {
2171     MakeCanvas("TPCNEventsEBDC");
2172   }
2173 
2174   TCanvas *MyTC = TC[14];
2175   TPad *TransparentTPad = transparent[14];
2176 
2177   MyTC->SetEditable(true);
2178   MyTC->Clear("D");
2179 
2180   TText PrintRun;
2181   PrintRun.SetTextFont(62);
2182   PrintRun.SetTextSize(0.04);
2183   PrintRun.SetNDC();          // set to normalized coordinates
2184   PrintRun.SetTextAlign(23);  // center/top alignment
2185   std::ostringstream runnostream;
2186   std::string runstring;
2187   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2188   // fill run number and event time into string
2189   runnostream << ThisName << "_N_Events_vs_EBDC " << cl->RunNumber()
2190               << ", Time: " << ctime(&evttime.first);
2191   runstring = runnostream.str();
2192   TransparentTPad->cd();
2193   PrintRun.SetTextColor(evttime.second);
2194   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2195 
2196   MyTC->cd(1);
2197   gStyle->SetOptStat(kFALSE);
2198   gPad->SetTopMargin(0.15);
2199   dummy_his1_NEvents_EBDC->Draw("HISTsame");
2200 
2201   float max = 0;
2202   for (int i = 0; i < 24; i++)
2203   {
2204     if (tpcmoneventsebdc[i])
2205     {
2206       MyTC->cd(1);
2207       tpcmoneventsebdc[i]->Draw("HISTsame");
2208       if (tpcmoneventsebdc[i]->GetBinContent(tpcmoneventsebdc[i]->GetMaximumBin()) > max)
2209       {
2210         max = tpcmoneventsebdc[i]->GetBinContent(tpcmoneventsebdc[i]->GetMaximumBin());
2211         dummy_his1_NEvents_EBDC->SetMaximum(max * (1.3));
2212       }
2213     }
2214   }
2215   MyTC->Update();
2216 
2217   MyTC->Show();
2218   MyTC->SetEditable(false);
2219 
2220   return 0;
2221 }
2222 
2223 int TpcMonDraw::DrawTPCPedestSubADCSample(const std::string & /* what */)
2224 {
2225   OnlMonClient *cl = OnlMonClient::instance();
2226 
2227   TH2 *tpcmon_PEDESTSUBADCSAMPLE[24] = {nullptr};
2228   TH2 *tpcmon_PEDESTSUBADCSAMPLE_u[48] = {nullptr};
2229 
2230   char TPCMON_STR[100];
2231   for (int i = 0; i < 48; i++)
2232   {
2233     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2234     sprintf(TPCMON_STR, "TPCMON_%i", i);
2235     tpcmon_PEDESTSUBADCSAMPLE_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "PEDEST_SUB_ADC_vs_SAMPLE");
2236   }
2237 
2238   add_TH2(tpcmon_PEDESTSUBADCSAMPLE_u, tpcmon_PEDESTSUBADCSAMPLE);
2239 
2240   if (!gROOT->FindObject("TPCPedestSubADCSample"))
2241   {
2242     MakeCanvas("TPCPedestSubADCSample");
2243   }
2244 
2245   TCanvas *MyTC = TC[15];
2246   TPad *TransparentTPad = transparent[15];
2247 
2248   MyTC->SetEditable(true);
2249   MyTC->Clear("D");
2250 
2251   for (int i = 0; i < 24; i++)
2252   {
2253     if (tpcmon_PEDESTSUBADCSAMPLE[i])
2254     {
2255       MyTC->cd(i + 5);
2256       gStyle->SetPalette(57);  // kBird CVD friendly
2257       gPad->SetLogz(kTRUE);
2258       tpcmon_PEDESTSUBADCSAMPLE[i]->DrawCopy("colz");
2259     }
2260   }
2261 
2262   TText PrintRun;
2263   PrintRun.SetTextFont(62);
2264   PrintRun.SetTextSize(0.04);
2265   PrintRun.SetNDC();          // set to normalized coordinates
2266   PrintRun.SetTextAlign(23);  // center/top alignment
2267   std::ostringstream runnostream;
2268   std::string runstring;
2269   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2270   // fill run number and event time into string
2271   runnostream << ThisName << "_PEDEST_SUB_ADC_vs_SAMPLE Run " << cl->RunNumber()
2272               << ", Time: " << ctime(&evttime.first);
2273   runstring = runnostream.str();
2274   TransparentTPad->cd();
2275   PrintRun.SetTextColor(evttime.second);
2276   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2277 
2278   MyTC->Update();
2279   MyTC->Show();
2280   MyTC->SetEditable(false);
2281 
2282   return 0;
2283 }
2284 
2285 int TpcMonDraw::DrawTPCPedestSubADCSample_R1(const std::string & /* what */)
2286 {
2287   OnlMonClient *cl = OnlMonClient::instance();
2288 
2289   TH2 *tpcmon_PEDESTSUBADCSAMPLE_R1[24] = {nullptr};
2290   TH2 *tpcmon_PEDESTSUBADCSAMPLE_R1_u[48] = {nullptr};
2291 
2292   char TPCMON_STR[100];
2293   for (int i = 0; i < 48; i++)
2294   {
2295     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2296     sprintf(TPCMON_STR, "TPCMON_%i", i);
2297     tpcmon_PEDESTSUBADCSAMPLE_R1_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "PEDEST_SUB_ADC_vs_SAMPLE_R1");
2298   }
2299 
2300   add_TH2(tpcmon_PEDESTSUBADCSAMPLE_R1_u, tpcmon_PEDESTSUBADCSAMPLE_R1);
2301 
2302   if (!gROOT->FindObject("TPCPedestSubADCSample_R1"))
2303   {
2304     MakeCanvas("TPCPedestSubADCSample_R1");
2305   }
2306 
2307   TCanvas *MyTC = TC[16];
2308   TPad *TransparentTPad = transparent[16];
2309 
2310   MyTC->SetEditable(true);
2311   MyTC->Clear("D");
2312 
2313   for (int i = 0; i < 24; i++)
2314   {
2315     if (tpcmon_PEDESTSUBADCSAMPLE_R1[i])
2316     {
2317       MyTC->cd(i + 5);
2318       gStyle->SetPalette(57);  // kBird CVD friendly
2319       gPad->SetLogz(kTRUE);
2320       tpcmon_PEDESTSUBADCSAMPLE_R1[i]->DrawCopy("colz");
2321     }
2322   }
2323 
2324   TText PrintRun;
2325   PrintRun.SetTextFont(62);
2326   PrintRun.SetTextSize(0.04);
2327   PrintRun.SetNDC();          // set to normalized coordinates
2328   PrintRun.SetTextAlign(23);  // center/top alignment
2329   std::ostringstream runnostream;
2330   std::string runstring;
2331   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2332   // fill run number and event time into string
2333   runnostream << ThisName << "_PEDEST_SUB_ADC_vs_SAMPLE R1 ONLY Run " << cl->RunNumber()
2334               << ", Time: " << ctime(&evttime.first);
2335   runstring = runnostream.str();
2336   TransparentTPad->cd();
2337   PrintRun.SetTextColor(evttime.second);
2338   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2339 
2340   MyTC->Update();
2341   MyTC->Show();
2342   MyTC->SetEditable(false);
2343 
2344   return 0;
2345 }
2346 
2347 int TpcMonDraw::DrawTPCPedestSubADCSample_R2(const std::string & /* what */)
2348 {
2349   OnlMonClient *cl = OnlMonClient::instance();
2350 
2351   TH2 *tpcmon_PEDESTSUBADCSAMPLE_R2[24] = {nullptr};
2352   TH2 *tpcmon_PEDESTSUBADCSAMPLE_R2_u[48] = {nullptr};
2353 
2354   char TPCMON_STR[100];
2355   for (int i = 0; i < 48; i++)
2356   {
2357     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2358     sprintf(TPCMON_STR, "TPCMON_%i", i);
2359     tpcmon_PEDESTSUBADCSAMPLE_R2_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "PEDEST_SUB_ADC_vs_SAMPLE_R2");
2360   }
2361 
2362   add_TH2(tpcmon_PEDESTSUBADCSAMPLE_R2_u, tpcmon_PEDESTSUBADCSAMPLE_R2);
2363 
2364   if (!gROOT->FindObject("TPCPedestSubADCSample_R2"))
2365   {
2366     MakeCanvas("TPCPedestSubADCSample_R2");
2367   }
2368 
2369   TCanvas *MyTC = TC[17];
2370   TPad *TransparentTPad = transparent[17];
2371 
2372   MyTC->SetEditable(true);
2373   MyTC->Clear("D");
2374 
2375   for (int i = 0; i < 24; i++)
2376   {
2377     if (tpcmon_PEDESTSUBADCSAMPLE_R2[i])
2378     {
2379       MyTC->cd(i + 5);
2380       gStyle->SetPalette(57);  // kBird CVD friendly
2381       gPad->SetLogz(kTRUE);
2382       tpcmon_PEDESTSUBADCSAMPLE_R2[i]->DrawCopy("colz");
2383     }
2384   }
2385 
2386   TText PrintRun;
2387   PrintRun.SetTextFont(62);
2388   PrintRun.SetTextSize(0.04);
2389   PrintRun.SetNDC();          // set to normalized coordinates
2390   PrintRun.SetTextAlign(23);  // center/top alignment
2391   std::ostringstream runnostream;
2392   std::string runstring;
2393   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2394   // fill run number and event time into string
2395   runnostream << ThisName << "_PEDEST_SUB_ADC_vs_SAMPLE R2 ONLY Run " << cl->RunNumber()
2396               << ", Time: " << ctime(&evttime.first);
2397   runstring = runnostream.str();
2398   TransparentTPad->cd();
2399   PrintRun.SetTextColor(evttime.second);
2400   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2401 
2402   MyTC->Update();
2403   MyTC->Show();
2404   MyTC->SetEditable(false);
2405 
2406   return 0;
2407 }
2408 
2409 int TpcMonDraw::DrawTPCPedestSubADCSample_R3(const std::string & /* what */)
2410 {
2411   OnlMonClient *cl = OnlMonClient::instance();
2412 
2413   TH2 *tpcmon_PEDESTSUBADCSAMPLE_R3[24] = {nullptr};
2414   TH2 *tpcmon_PEDESTSUBADCSAMPLE_R3_u[48] = {nullptr};
2415 
2416   char TPCMON_STR[100];
2417   for (int i = 0; i < 48; i++)
2418   {
2419     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2420     sprintf(TPCMON_STR, "TPCMON_%i", i);
2421     tpcmon_PEDESTSUBADCSAMPLE_R3_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "PEDEST_SUB_ADC_vs_SAMPLE_R3");
2422   }
2423 
2424   add_TH2(tpcmon_PEDESTSUBADCSAMPLE_R3_u, tpcmon_PEDESTSUBADCSAMPLE_R3);
2425 
2426   if (!gROOT->FindObject("TPCPedestSubADCSample_R3"))
2427   {
2428     MakeCanvas("TPCPedestSubADCSample_R3");
2429   }
2430 
2431   TCanvas *MyTC = TC[18];
2432   TPad *TransparentTPad = transparent[18];
2433 
2434   MyTC->SetEditable(true);
2435   MyTC->Clear("D");
2436 
2437   for (int i = 0; i < 24; i++)
2438   {
2439     if (tpcmon_PEDESTSUBADCSAMPLE_R3[i])
2440     {
2441       MyTC->cd(i + 5);
2442       gStyle->SetPalette(57);  // kBird CVD friendly
2443       gPad->SetLogz(kTRUE);
2444       tpcmon_PEDESTSUBADCSAMPLE_R3[i]->DrawCopy("colz");
2445     }
2446   }
2447 
2448   TText PrintRun;
2449   PrintRun.SetTextFont(62);
2450   PrintRun.SetTextSize(0.04);
2451   PrintRun.SetNDC();          // set to normalized coordinates
2452   PrintRun.SetTextAlign(23);  // center/top alignment
2453   std::ostringstream runnostream;
2454   std::string runstring;
2455   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2456   // fill run number and event time into string
2457   runnostream << ThisName << "_PEDEST_SUB_ADC_vs_SAMPLE R3 ONLY Run " << cl->RunNumber()
2458               << ", Time: " << ctime(&evttime.first);
2459   runstring = runnostream.str();
2460   TransparentTPad->cd();
2461   PrintRun.SetTextColor(evttime.second);
2462   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2463 
2464   MyTC->Update();
2465   MyTC->Show();
2466   MyTC->SetEditable(false);
2467 
2468   return 0;
2469 }
2470 
2471 int TpcMonDraw::DrawTPCXYlaserclusters(const std::string & /* what */)
2472 {
2473   OnlMonClient *cl = OnlMonClient::instance();
2474 
2475   TH2 *tpcmon_NSTPC_laser_clusXY[24][3] = {nullptr};
2476   TH2 *tpcmon_SSTPC_laser_clusXY[24][3] = {nullptr};
2477 
2478   TH2 *tpcmon_NSTPC_laser_clusXY_u[48][3] = {nullptr};
2479   TH2 *tpcmon_SSTPC_laser_clusXY_u[48][3] = {nullptr};
2480 
2481   dummy_his1_laser_XY = new TH2F("dummy_his1_laser_XY", "(ADC-Pedestal) > (5#sigma||20ADC) North Side, WEIGHTED", 400, -800, 800, 400, -800, 800);  // dummy histos for titles
2482   dummy_his2_laser_XY = new TH2F("dummy_his2_laser_XY", "(ADC-Pedestal) > (5#sigma||20ADC) South Side, WEIGHTED", 400, -800, 800, 400, -800, 800);
2483 
2484   dummy_his1_laser_XY->SetXTitle("X [mm]");
2485   dummy_his1_laser_XY->SetYTitle("Y [mm]");
2486   dummy_his1_laser_XY->GetYaxis()->SetTitleSize(0.02);
2487 
2488   dummy_his2_laser_XY->SetXTitle("-X [mm]");  // SS x is flipped from global coordinates
2489   dummy_his2_laser_XY->SetYTitle("Y [mm]");
2490   dummy_his2_laser_XY->GetYaxis()->SetTitleSize(0.02);
2491 
2492   // the lines are for the sector boundaries
2493   Double_t sec_gap_inner = (2 * M_PI - 0.5024 * 12.0) / 12.0;
2494 
2495   Double_t sec_gap_outer = (2 * M_PI - 0.5097 * 12.0) / 12.0;
2496 
2497   Double_t sec_gap = (sec_gap_inner + sec_gap_outer) / 2.0;
2498 
2499   Double_t sec_phi = (0.5024 + 0.5097) / 2.0;
2500 
2501   TLine *lines[12];
2502 
2503   for (int ln = 0; ln < 12; ln++)
2504   {
2505     lines[ln] = new TLine(311.05 * cos((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 311.05 * sin((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 759.11 * cos((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 759.11 * sin((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)));
2506   }
2507 
2508   TEllipse *e1 = new TEllipse(0.0, 0.0, 311.05, 311.05);
2509   TEllipse *e2 = new TEllipse(0.0, 0.0, (402.49 + 411.53) / 2.0, (402.49 + 411.53) / 2.0);
2510   TEllipse *e3 = new TEllipse(0.0, 0.0, (583.67 + 574.75) / 2.0, (583.67 + 574.75) / 2.0);
2511   TEllipse *e4 = new TEllipse(0.0, 0.0, 759.11, 759.11);
2512   //__________________
2513 
2514   char TPCMON_STR[100];
2515   for (int i = 0; i < 48; i++)
2516   {
2517     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2518     sprintf(TPCMON_STR, "TPCMON_%i", i);
2519     tpcmon_NSTPC_laser_clusXY_u[i][0] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R1_LASER");
2520     tpcmon_NSTPC_laser_clusXY_u[i][1] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R2_LASER");
2521     tpcmon_NSTPC_laser_clusXY_u[i][2] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R3_LASER");
2522 
2523     tpcmon_SSTPC_laser_clusXY_u[i][0] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R1_LASER");
2524     tpcmon_SSTPC_laser_clusXY_u[i][1] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R2_LASER");
2525     tpcmon_SSTPC_laser_clusXY_u[i][2] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R3_LASER");
2526   }
2527 
2528   add_TH2_modules(tpcmon_NSTPC_laser_clusXY_u, tpcmon_NSTPC_laser_clusXY);
2529   add_TH2_modules(tpcmon_SSTPC_laser_clusXY_u, tpcmon_SSTPC_laser_clusXY);
2530 
2531   if (!gROOT->FindObject("TPCClusterXY_laser"))
2532   {
2533     MakeCanvas("TPCClusterXY_laser");
2534   }
2535 
2536   TCanvas *MyTC = TC[19];
2537   TPad *TransparentTPad = transparent[19];
2538 
2539   MyTC->SetEditable(true);  // after Chris' change need to skip 22
2540   MyTC->Clear("D");
2541 
2542   TText PrintRun;
2543   PrintRun.SetTextFont(62);
2544   PrintRun.SetTextSize(0.04);
2545   PrintRun.SetNDC();          // set to normalized coordinates
2546   PrintRun.SetTextAlign(23);  // center/top alignment
2547   std::ostringstream runnostream;
2548   std::string runstring;
2549   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2550   // fill run number and event time into string
2551   runnostream << ThisName << "_LASER_ADC-Pedestal>(5sigma||20ADC) WEIGHTED, Run" << cl->RunNumber()
2552               << ", Time: " << ctime(&evttime.first);
2553   runstring = runnostream.str();
2554   TransparentTPad->cd();
2555   PrintRun.SetTextColor(evttime.second);
2556   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2557 
2558   MyTC->cd(1);
2559   gStyle->SetOptStat(kFALSE);
2560   gPad->SetTopMargin(0.15);
2561   gPad->SetLogz(kTRUE);
2562   dummy_his1_laser_XY->Draw("colzsame");
2563 
2564   float NS_max = 0;
2565   for (int i = 0; i < 12; i++)
2566   {
2567     for (int j = 0; j < 3; j++)
2568     {
2569       if (tpcmon_NSTPC_laser_clusXY[i][j])
2570       {
2571         MyTC->cd(1);
2572         tpcmon_NSTPC_laser_clusXY[i][j]->Draw("colzsame");
2573         // gStyle->SetLogz(kTRUE);
2574         if (tpcmon_NSTPC_laser_clusXY[i][j]->GetBinContent(tpcmon_NSTPC_laser_clusXY[i][j]->GetMaximumBin()) > NS_max)
2575         {
2576           NS_max = tpcmon_NSTPC_laser_clusXY[i][j]->GetBinContent(tpcmon_NSTPC_laser_clusXY[i][j]->GetMaximumBin());
2577           dummy_his1_laser_XY->SetMaximum(NS_max);
2578         }
2579         gStyle->SetPalette(57);  // kBird CVD friendly
2580       }
2581     }
2582   }
2583   MyTC->cd(1);
2584   e1->SetFillStyle(0);
2585   e2->SetFillStyle(0);
2586   e3->SetFillStyle(0);
2587   e4->SetFillStyle(0);
2588 
2589   e1->Draw("same");
2590   e2->Draw("same");
2591   e3->Draw("same");
2592   e4->Draw("same");
2593   for (int ln2 = 0; ln2 < 12; ln2++)
2594   {
2595     lines[ln2]->Draw("same");
2596   }
2597   MyTC->Update();
2598 
2599   MyTC->cd(2);
2600   gStyle->SetOptStat(kFALSE);
2601   gPad->SetTopMargin(0.15);
2602   gPad->SetLogz(kTRUE);
2603   dummy_his2_laser_XY->Draw("colzsame");
2604 
2605   float SS_max = 0;
2606   for (int i = 0; i < 12; i++)
2607   {
2608     for (int j = 0; j < 3; j++)
2609     {
2610       if (tpcmon_SSTPC_laser_clusXY[i + 12][j])
2611       {
2612         // std::cout<<"South Side Custer XY i: "<< i+12 <<", j: "<<j<<std::endl;
2613         MyTC->cd(2);
2614         tpcmon_SSTPC_laser_clusXY[i + 12][j]->Draw("colzsame");
2615         // gStyle->SetLogz(kTRUE);
2616         if (tpcmon_SSTPC_laser_clusXY[i + 12][j]->GetBinContent(tpcmon_SSTPC_laser_clusXY[i + 12][j]->GetMaximumBin()) > SS_max)
2617         {
2618           SS_max = tpcmon_SSTPC_laser_clusXY[i + 12][j]->GetBinContent(tpcmon_SSTPC_laser_clusXY[i + 12][j]->GetMaximumBin());
2619           dummy_his2_laser_XY->SetMaximum(SS_max);
2620         }
2621         gStyle->SetPalette(57);  // kBird CVD friendly
2622       }
2623     }
2624   }
2625   MyTC->cd(2);
2626   e1->SetFillStyle(0);
2627   e2->SetFillStyle(0);
2628   e3->SetFillStyle(0);
2629   e4->SetFillStyle(0);
2630 
2631   e1->Draw("same");
2632   e2->Draw("same");
2633   e3->Draw("same");
2634   e4->Draw("same");
2635   for (int ln2 = 0; ln2 < 12; ln2++)
2636   {
2637     lines[ln2]->Draw("same");
2638   }
2639 
2640   MyTC->Update();
2641   MyTC->Show();
2642   MyTC->SetEditable(false);
2643 
2644   return 0;
2645 }
2646 
2647 int TpcMonDraw::DrawTPCStuckChannels(const std::string & /* what */)
2648 {
2649   OnlMonClient *cl = OnlMonClient::instance();
2650 
2651   TH1 *tpcmon_stuckchannels[24] = {nullptr};
2652   TH1 *tpcmon_stuckchannels_u[48] = {nullptr};
2653 
2654   char TPCMON_STR[100];
2655   for (int i = 0; i < 48; i++)
2656   {
2657     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2658     sprintf(TPCMON_STR, "TPCMON_%i", i);
2659     tpcmon_stuckchannels_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Stuck_Channels");
2660     // if( !tpcmon_stuckchannels[i] ){std::cout<<"Not able to get stuck channel histo # "<<i<<std::endl;}
2661   }
2662 
2663   add_TH1(tpcmon_stuckchannels_u, tpcmon_stuckchannels);
2664 
2665   if (!gROOT->FindObject("TPCStuckChannels"))
2666   {
2667     MakeCanvas("TPCStuckChannels");
2668   }
2669 
2670   TCanvas *MyTC = TC[21];
2671   TPad *TransparentTPad = transparent[21];
2672 
2673   MyTC->SetEditable(true);
2674   MyTC->Clear("D");
2675   MyTC->cd(1);
2676 
2677   TLine *t1 = new TLine();
2678   t1->SetLineWidth(2);
2679   TLine *t11 = new TLine();
2680   t11->SetLineWidth(2);
2681   TLine *t2 = new TLine();
2682   t2->SetLineStyle(2);
2683   TText *tt1 = new TText();
2684   tt1->SetTextSize(0.05);
2685 
2686   int FEEid[26] = {
2687       2, 4, 3, 13, 17, 16,                       // R1
2688       11, 12, 19, 18, 0, 1, 15, 14,              // R2
2689       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
2690   };
2691 
2692   char title[50];
2693 
2694   for (int i = 0; i < 24; i++)
2695   {
2696     if (tpcmon_stuckchannels[i])
2697     {
2698       MyTC->cd(i + 5);
2699 
2700       tpcmon_stuckchannels[i]->GetYaxis()->SetRangeUser(0.01, 10000);
2701       tpcmon_stuckchannels[i]->DrawCopy("HIST");
2702 
2703       gPad->SetLogy(kTRUE);
2704 
2705       MyTC->Update();
2706 
2707       for (int j = 0; j < 25; j++)
2708       {
2709         t2->DrawLine((j + 0.5), 0.01, (j + 0.5), 1500);
2710       }
2711       for (int k = 0; k < 26; k++)
2712       {
2713         sprintf(title, "%d", FEEid[k]);
2714         tt1->DrawText(k, 400, title);
2715       }
2716       tt1->SetTextSize(0.06);
2717       tt1->DrawText(3.1, 2000, "R1");
2718       tt1->DrawText(9.6, 2000, "R2");
2719       tt1->DrawText(20.4, 2000, "R3");
2720       tt1->SetTextSize(0.05);
2721 
2722       t1->DrawLine(5.5, 0.01, 5.5, 5000);
2723       t1->DrawLine(13.5, 0.01, 13.5, 5000);
2724 
2725       t11->DrawLine(-0.5, 256, 25.5, 256);
2726     }
2727   }
2728 
2729   TText PrintRun;
2730   PrintRun.SetTextFont(62);
2731   PrintRun.SetTextSize(0.04);
2732   PrintRun.SetNDC();          // set to normalized coordinates
2733   PrintRun.SetTextAlign(23);  // center/top alignment
2734   std::ostringstream runnostream;
2735   std::string runstring;
2736   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2737   // fill run number and event time into string
2738   runnostream << ThisName << "_StuckChannel Run " << cl->RunNumber()
2739               << ", Time: " << ctime(&evttime.first);
2740   runstring = runnostream.str();
2741   TransparentTPad->cd();
2742   PrintRun.SetTextColor(evttime.second);
2743   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2744 
2745   MyTC->Update();
2746   // MyTC->SetLogy();
2747   MyTC->Show();
2748   MyTC->SetEditable(false);
2749 
2750   return 0;
2751 }
2752 int TpcMonDraw::DrawTPCXYclusters5event(const std::string & /* what */)
2753 {
2754   OnlMonClient *cl = OnlMonClient::instance();
2755 
2756   TH2 *tpcmon_NSTPC_5e_clusXY[24][3] = {nullptr};
2757   TH2 *tpcmon_SSTPC_5e_clusXY[24][3] = {nullptr};
2758 
2759   TH2 *tpcmon_NSTPC_5e_clusXY_u[48][3] = {nullptr};
2760   TH2 *tpcmon_SSTPC_5e_clusXY_u[48][3] = {nullptr};
2761 
2762   dummy_his1_u5_XY = new TH2F("dummy_his1_u5_XY", "(ADC-Pedestal) > (5#sigma||20ADC) North Side, <= 5 E , UNWEIGHTED", 400, -800, 800, 400, -800, 800);  // dummy histos for titles
2763   dummy_his2_u5_XY = new TH2F("dummy_his2_u5_XY", "(ADC-Pedestal) > (5#sigma||20ADC) South Side, <= 5 E , UNWEIGHTED", 400, -800, 800, 400, -800, 800);
2764 
2765   dummy_his1_u5_XY->SetXTitle("X [mm]");
2766   dummy_his1_u5_XY->SetYTitle("Y [mm]");
2767   dummy_his1_u5_XY->GetYaxis()->SetTitleSize(0.02);
2768 
2769   dummy_his2_u5_XY->SetXTitle("-X [mm]");  // SS x is flipped from global coordinates
2770   dummy_his2_u5_XY->SetYTitle("Y [mm]");
2771   dummy_his2_u5_XY->GetYaxis()->SetTitleSize(0.02);
2772 
2773   // the lines are for the sector boundaries
2774   Double_t sec_gap_inner = (2 * M_PI - 0.5024 * 12.0) / 12.0;
2775 
2776   Double_t sec_gap_outer = (2 * M_PI - 0.5097 * 12.0) / 12.0;
2777 
2778   Double_t sec_gap = (sec_gap_inner + sec_gap_outer) / 2.0;
2779 
2780   Double_t sec_phi = (0.5024 + 0.5097) / 2.0;
2781 
2782   TLine *lines[12];
2783 
2784   for (int ln = 0; ln < 12; ln++)
2785   {
2786     lines[ln] = new TLine(311.05 * cos((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 311.05 * sin((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 759.11 * cos((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)), 759.11 * sin((sec_phi + sec_gap) / 2.0 + ln * (sec_phi + sec_gap)));
2787   }
2788 
2789   TEllipse *e1 = new TEllipse(0.0, 0.0, 311.05, 311.05);
2790   TEllipse *e2 = new TEllipse(0.0, 0.0, (402.49 + 411.53) / 2.0, (402.49 + 411.53) / 2.0);
2791   TEllipse *e3 = new TEllipse(0.0, 0.0, (583.67 + 574.75) / 2.0, (583.67 + 574.75) / 2.0);
2792   TEllipse *e4 = new TEllipse(0.0, 0.0, 759.11, 759.11);
2793   //__________________
2794 
2795   char TPCMON_STR[100];
2796   for (int i = 0; i < 48; i++)
2797   {
2798     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2799     sprintf(TPCMON_STR, "TPCMON_%i", i);
2800     tpcmon_NSTPC_5e_clusXY_u[i][0] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R1_u5");
2801     tpcmon_NSTPC_5e_clusXY_u[i][1] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R2_u5");
2802     tpcmon_NSTPC_5e_clusXY_u[i][2] = (TH2 *) cl->getHisto(TPCMON_STR, "NorthSideADC_clusterXY_R3_u5");
2803 
2804     tpcmon_SSTPC_5e_clusXY_u[i][0] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R1_u5");
2805     tpcmon_SSTPC_5e_clusXY_u[i][1] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R2_u5");
2806     tpcmon_SSTPC_5e_clusXY_u[i][2] = (TH2 *) cl->getHisto(TPCMON_STR, "SouthSideADC_clusterXY_R3_u5");
2807   }
2808 
2809   add_TH2_modules(tpcmon_NSTPC_5e_clusXY_u, tpcmon_NSTPC_5e_clusXY);
2810   add_TH2_modules(tpcmon_SSTPC_5e_clusXY_u, tpcmon_SSTPC_5e_clusXY);
2811 
2812   if (!gROOT->FindObject("TPCClusterXY_u5"))
2813   {
2814     MakeCanvas("TPCClusterXY_u5");
2815   }
2816 
2817   TCanvas *MyTC = TC[22];
2818   TPad *TransparentTPad = transparent[22];
2819 
2820   MyTC->SetEditable(true);
2821   MyTC->Clear("D");
2822 
2823   TText PrintRun;
2824   PrintRun.SetTextFont(62);
2825   PrintRun.SetTextSize(0.04);
2826   PrintRun.SetNDC();          // set to normalized coordinates
2827   PrintRun.SetTextAlign(23);  // center/top alignment
2828   std::ostringstream runnostream;
2829   std::string runstring;
2830   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
2831   // fill run number and event time into string
2832   runnostream << ThisName << "_ADC-Pedestal>(5sigma||20ADC) UNWEIGHTED, <= 5E, Run" << cl->RunNumber()
2833               << ", Time: " << ctime(&evttime.first);
2834   runstring = runnostream.str();
2835   TransparentTPad->cd();
2836   PrintRun.SetTextColor(evttime.second);
2837   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
2838 
2839   MyTC->cd(1);
2840   gStyle->SetOptStat(kFALSE);
2841   gPad->SetTopMargin(0.15);
2842   // gPad->SetLogz(kTRUE);
2843   dummy_his1_u5_XY->Draw("colzsame");
2844 
2845   float NS_max = 0;
2846   for (int i = 0; i < 12; i++)
2847   {
2848     for (int j = 0; j < 3; j++)
2849     {
2850       if (tpcmon_NSTPC_5e_clusXY[i][j])
2851       {
2852         MyTC->cd(1);
2853         tpcmon_NSTPC_5e_clusXY[i][j]->Draw("colzsame");
2854         // gStyle->SetLogz(kTRUE);
2855         if (tpcmon_NSTPC_5e_clusXY[i][j]->GetBinContent(tpcmon_NSTPC_5e_clusXY[i][j]->GetMaximumBin()) > NS_max)
2856         {
2857           NS_max = tpcmon_NSTPC_5e_clusXY[i][j]->GetBinContent(tpcmon_NSTPC_5e_clusXY[i][j]->GetMaximumBin());
2858           dummy_his1_u5_XY->SetMaximum(NS_max);
2859         }
2860         gStyle->SetPalette(57);  // kBird CVD friendly
2861       }
2862     }
2863   }
2864   MyTC->cd(1);
2865   e1->SetFillStyle(0);
2866   e2->SetFillStyle(0);
2867   e3->SetFillStyle(0);
2868   e4->SetFillStyle(0);
2869 
2870   e1->Draw("same");
2871   e2->Draw("same");
2872   e3->Draw("same");
2873   e4->Draw("same");
2874   for (int ln2 = 0; ln2 < 12; ln2++)
2875   {
2876     lines[ln2]->Draw("same");
2877   }
2878   MyTC->Update();
2879 
2880   MyTC->cd(2);
2881   gStyle->SetOptStat(kFALSE);
2882   gPad->SetTopMargin(0.15);
2883   // gPad->SetLogz(kTRUE);
2884   dummy_his2_u5_XY->Draw("colzsame");
2885 
2886   float SS_max = 0;
2887   for (int i = 0; i < 12; i++)
2888   {
2889     for (int j = 0; j < 3; j++)
2890     {
2891       if (tpcmon_SSTPC_5e_clusXY[i + 12][j])
2892       {
2893         // std::cout<<"South Side Custer XY i: "<< i+12 <<", j: "<<j<<std::endl;
2894         MyTC->cd(2);
2895         tpcmon_SSTPC_5e_clusXY[i + 12][j]->Draw("colzsame");
2896         // gStyle->SetLogz(kTRUE);
2897         if (tpcmon_SSTPC_5e_clusXY[i + 12][j]->GetBinContent(tpcmon_SSTPC_5e_clusXY[i + 12][j]->GetMaximumBin()) > SS_max)
2898         {
2899           SS_max = tpcmon_SSTPC_5e_clusXY[i + 12][j]->GetBinContent(tpcmon_SSTPC_5e_clusXY[i + 12][j]->GetMaximumBin());
2900           dummy_his2_u5_XY->SetMaximum(SS_max);
2901         }
2902         gStyle->SetPalette(57);  // kBird CVD friendly
2903       }
2904     }
2905   }
2906   MyTC->cd(2);
2907   e1->SetFillStyle(0);
2908   e2->SetFillStyle(0);
2909   e3->SetFillStyle(0);
2910   e4->SetFillStyle(0);
2911 
2912   e1->Draw("same");
2913   e2->Draw("same");
2914   e3->Draw("same");
2915   e4->Draw("same");
2916   for (int ln2 = 0; ln2 < 12; ln2++)
2917   {
2918     lines[ln2]->Draw("same");
2919   }
2920 
2921   MyTC->Update();
2922   MyTC->Show();
2923   MyTC->SetEditable(false);
2924 
2925   return 0;
2926 }
2927 
2928 int TpcMonDraw::DrawTPCChansinPacketNS(const std::string & /* what */)
2929 {
2930   OnlMonClient *cl = OnlMonClient::instance();
2931 
2932   TH1 *tpcmon_chanpacketNS[24] = {nullptr};
2933   TH1 *tpcmon_chanpacketalwaysNS[24] = {nullptr};
2934 
2935   TH1 *tpcmon_chanpacketNS_u[48] = {nullptr};
2936   TH1 *tpcmon_chanpacketalwaysNS_u[48] = {nullptr};
2937 
2938   char TPCMON_STR[100];
2939   for (int i = 0; i < 12; i++)
2940   {
2941     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2942     sprintf(TPCMON_STR, "TPCMON_%i", i);
2943     tpcmon_chanpacketNS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_in_Packet");
2944     tpcmon_chanpacketalwaysNS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_Always");
2945   }
2946 
2947   for (int i = 24; i < 36; i++)
2948   {
2949     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
2950     sprintf(TPCMON_STR, "TPCMON_%i", i);
2951     tpcmon_chanpacketNS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_in_Packet");
2952     tpcmon_chanpacketalwaysNS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_Always");
2953   }
2954 
2955   add_TH1(tpcmon_chanpacketNS_u, tpcmon_chanpacketNS);
2956   add_TH1(tpcmon_chanpacketalwaysNS_u, tpcmon_chanpacketalwaysNS);
2957 
2958   if (!gROOT->FindObject("TPCChan_in_Packets_NS"))
2959   {
2960     MakeCanvas("TPCChan_in_Packets_NS");
2961   }
2962 
2963   TCanvas *MyTC = TC[23];
2964   TPad *TransparentTPad = transparent[23];
2965 
2966   TLine *t1 = new TLine();
2967   t1->SetLineWidth(2);
2968   TLine *t2 = new TLine();
2969   t2->SetLineStyle(2);
2970   TText *tt1 = new TText();
2971   tt1->SetTextSize(0.05);
2972 
2973   int FEEid[26] = {
2974       2, 4, 3, 13, 17, 16,                       // R1
2975       11, 12, 19, 18, 0, 1, 15, 14,              // R2
2976       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
2977   };
2978 
2979   char title[50];
2980 
2981   MyTC->SetEditable(true);
2982   MyTC->Clear("D");
2983   for (int i = 0; i < 12; i++)
2984   {
2985     if (tpcmon_chanpacketNS[i] && tpcmon_chanpacketalwaysNS[i])
2986     {
2987       MyTC->cd(i + 3);
2988       gStyle->SetPadLeftMargin(0.05);
2989       gStyle->SetPadRightMargin(0.02);
2990       tpcmon_chanpacketNS[i]->Divide(tpcmon_chanpacketalwaysNS[i]);
2991 
2992       double Yrange_upper = 1.32 * tpcmon_chanpacketNS[i]->GetMaximum();
2993 
2994       tpcmon_chanpacketNS[i]->GetYaxis()->SetRangeUser(0, Yrange_upper);
2995 
2996       tpcmon_chanpacketNS[i]->SetMarkerColor(4);
2997       tpcmon_chanpacketNS[i]->SetLineColor(4);
2998       tpcmon_chanpacketNS[i]->DrawCopy("HIST");
2999 
3000       MyTC->Update();
3001 
3002       for (int j = 0; j < 25; j++)
3003       {
3004         t2->DrawLine((j + 1) * 256, -0.01, (j + 1) * 256, Yrange_upper);
3005       }
3006       for (int k = 0; k < 26; k++)
3007       {
3008         sprintf(title, "%d", FEEid[k]);
3009         tt1->DrawText(k * 256 + 128, 0.84 * Yrange_upper, title);
3010       }
3011       tt1->SetTextSize(0.06);
3012       tt1->DrawText(800, 0.92 * Yrange_upper, "R1");
3013       tt1->DrawText(2450, 0.92 * Yrange_upper, "R2");
3014       tt1->DrawText(5200, 0.92 * Yrange_upper, "R3");
3015       tt1->SetTextSize(0.05);
3016 
3017       t1->DrawLine(1536, 0, 1536, Yrange_upper);
3018       t1->DrawLine(3584, 0, 3584, Yrange_upper);
3019     }
3020   }
3021 
3022   TText PrintRun;
3023   PrintRun.SetTextFont(62);
3024   PrintRun.SetTextSize(0.04);
3025   PrintRun.SetNDC();          // set to normalized coordinates
3026   PrintRun.SetTextAlign(23);  // center/top alignment
3027   std::ostringstream runnostream;
3028   std::string runstring;
3029   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
3030   // fill run number and event time into string
3031   runnostream << ThisName << "_NS_Channels per Packet per RCDAQ Event Run " << cl->RunNumber()
3032               << ", Time: " << ctime(&evttime.first);
3033   runstring = runnostream.str();
3034   TransparentTPad->cd();
3035   PrintRun.SetTextColor(evttime.second);
3036   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
3037 
3038   MyTC->Update();
3039   MyTC->Show();
3040   MyTC->SetEditable(false);
3041 
3042   return 0;
3043 }
3044 
3045 int TpcMonDraw::DrawTPCChansinPacketSS(const std::string & /* what */)
3046 {
3047   OnlMonClient *cl = OnlMonClient::instance();
3048 
3049   TH1 *tpcmon_chanpacketSS[24] = {nullptr};
3050   TH1 *tpcmon_chanpacketalwaysSS[24] = {nullptr};
3051 
3052   TH1 *tpcmon_chanpacketSS_u[48] = {nullptr};
3053   TH1 *tpcmon_chanpacketalwaysSS_u[48] = {nullptr};
3054 
3055   char TPCMON_STR[100];
3056   for (int i = 12; i < 24; i++)
3057   {
3058     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3059     sprintf(TPCMON_STR, "TPCMON_%i", i);
3060     tpcmon_chanpacketSS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_in_Packet");
3061     tpcmon_chanpacketalwaysSS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_Always");
3062   }
3063 
3064   for (int i = 36; i < 48; i++)
3065   {
3066     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3067     sprintf(TPCMON_STR, "TPCMON_%i", i);
3068     tpcmon_chanpacketSS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_in_Packet");
3069     tpcmon_chanpacketalwaysSS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_Always");
3070   }
3071 
3072   add_TH1(tpcmon_chanpacketSS_u, tpcmon_chanpacketSS);
3073   add_TH1(tpcmon_chanpacketalwaysSS_u, tpcmon_chanpacketalwaysSS);
3074 
3075   if (!gROOT->FindObject("TPCChan_in_Packets_SS"))
3076   {
3077     MakeCanvas("TPCChan_in_Packets_SS");
3078   }
3079 
3080   TCanvas *MyTC = TC[24];
3081   TPad *TransparentTPad = transparent[24];
3082 
3083   TLine *t1 = new TLine();
3084   t1->SetLineWidth(2);
3085   TLine *t2 = new TLine();
3086   t2->SetLineStyle(2);
3087   TText *tt1 = new TText();
3088   tt1->SetTextSize(0.05);
3089 
3090   int FEEid[26] = {
3091       2, 4, 3, 13, 17, 16,                       // R1
3092       11, 12, 19, 18, 0, 1, 15, 14,              // R2
3093       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
3094   };
3095 
3096   char title[50];
3097 
3098   MyTC->SetEditable(true);
3099   MyTC->Clear("D");
3100   for (int i = 12; i < 24; i++)
3101   {
3102     if (tpcmon_chanpacketSS[i] && tpcmon_chanpacketalwaysSS[i])
3103     {
3104       MyTC->cd(i - 12 + 3);
3105       gStyle->SetPadLeftMargin(0.05);
3106       gStyle->SetPadRightMargin(0.02);
3107       tpcmon_chanpacketSS[i]->Divide(tpcmon_chanpacketalwaysSS[i]);
3108       double Yrange_upper = 1.32 * tpcmon_chanpacketSS[i]->GetMaximum();
3109       tpcmon_chanpacketSS[i]->GetYaxis()->SetRangeUser(0, Yrange_upper);
3110 
3111       tpcmon_chanpacketSS[i]->SetMarkerColor(4);
3112       tpcmon_chanpacketSS[i]->SetLineColor(4);
3113       tpcmon_chanpacketSS[i]->DrawCopy("HIST");
3114 
3115       MyTC->Update();
3116 
3117       for (int j = 0; j < 25; j++)
3118       {
3119         t2->DrawLine((j + 1) * 256, -0.01, (j + 1) * 256, Yrange_upper);
3120       }
3121       for (int k = 0; k < 26; k++)
3122       {
3123         sprintf(title, "%d", FEEid[k]);
3124         tt1->DrawText(k * 256 + 128, 0.84 * Yrange_upper, title);
3125       }
3126       tt1->SetTextSize(0.06);
3127       tt1->DrawText(800, 0.92 * Yrange_upper, "R1");
3128       tt1->DrawText(2450, 0.92 * Yrange_upper, "R2");
3129       tt1->DrawText(5200, 0.92 * Yrange_upper, "R3");
3130       tt1->SetTextSize(0.05);
3131 
3132       t1->DrawLine(1536, 0, 1536, Yrange_upper);
3133       t1->DrawLine(3584, 0, 3584, Yrange_upper);
3134     }
3135   }
3136 
3137   TText PrintRun;
3138   PrintRun.SetTextFont(62);
3139   PrintRun.SetTextSize(0.04);
3140   PrintRun.SetNDC();          // set to normalized coordinates
3141   PrintRun.SetTextAlign(23);  // center/top alignment
3142   std::ostringstream runnostream;
3143   std::string runstring;
3144   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
3145   // fill run number and event time into string
3146   runnostream << ThisName << "_SS_Channels per Packet per RCDAQ Event Run " << cl->RunNumber()
3147               << ", Time: " << ctime(&evttime.first);
3148   runstring = runnostream.str();
3149   TransparentTPad->cd();
3150   PrintRun.SetTextColor(evttime.second);
3151   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
3152 
3153   MyTC->Update();
3154   MyTC->Show();
3155   MyTC->SetEditable(false);
3156 
3157   return 0;
3158 }
3159 
3160 int TpcMonDraw::DrawTPCNonZSChannels(const std::string & /* what */)
3161 {
3162   OnlMonClient *cl = OnlMonClient::instance();
3163 
3164   TH2 *tpcmon_nonZSchannels_u[48] = {nullptr};
3165   TH2 *tpcmon_nonZSchannels[24] = {nullptr};
3166 
3167   char TPCMON_STR[100];
3168   for (int i = 0; i < 48; i++)
3169   {
3170     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3171     sprintf(TPCMON_STR, "TPCMON_%i", i);
3172     tpcmon_nonZSchannels_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "Num_non_ZS_channels_vs_SAMPA");
3173   }
3174 
3175   add_TH2(tpcmon_nonZSchannels_u, tpcmon_nonZSchannels);
3176 
3177   if (!gROOT->FindObject("TPCNonZSChannels"))
3178   {
3179     MakeCanvas("TPCNonZSChannels");
3180   }
3181   TCanvas *MyTC = TC[25];
3182   TPad *TransparentTPad = transparent[25];
3183   MyTC->SetEditable(true);
3184   MyTC->Clear("D");
3185 
3186   TLine *t1 = new TLine();
3187   t1->SetLineWidth(2);
3188   TLine *t2 = new TLine();
3189   t2->SetLineStyle(2);
3190   TText *tt1 = new TText();
3191   tt1->SetTextSize(0.05);
3192 
3193   int FEEid[26] = {
3194       2, 4, 3, 13, 17, 16,                       // R1
3195       11, 12, 19, 18, 0, 1, 15, 14,              // R2
3196       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
3197   };
3198 
3199   char title[50];
3200 
3201   gStyle->SetOptStat(0);
3202   gStyle->SetPalette(57);  // kBird CVD friendly
3203 
3204   for (int i = 0; i < 24; i++)
3205   {
3206     if (tpcmon_nonZSchannels[i])
3207     {
3208       MyTC->cd(i + 5);
3209       tpcmon_nonZSchannels[i]->DrawCopy("colz");
3210       gPad->SetLogz(kTRUE);
3211 
3212       MyTC->Update();
3213 
3214       for (int j = 0; j < 25; j++)
3215       {
3216         t2->DrawLine((j + 1) * 8, -300.01, (j + 1) * 8, 1024);
3217       }
3218       for (int k = 0; k < 26; k++)
3219       {
3220         sprintf(title, "%d", FEEid[k]);
3221         tt1->DrawText(k * 8 + 4, -100, title);
3222       }
3223       tt1->SetTextSize(0.06);
3224       tt1->DrawText(25, -200, "R1");
3225       tt1->DrawText(77, -200, "R2");
3226       tt1->DrawText(163, -200, "R3");
3227       tt1->SetTextSize(0.05);
3228 
3229       t1->DrawLine(48, -300.01, 48, 1024);
3230       t1->DrawLine(112, -300.01, 112, 1024);
3231     }
3232   }
3233 
3234   TText PrintRun;
3235   PrintRun.SetTextFont(62);
3236   PrintRun.SetTextSize(0.04);
3237   PrintRun.SetNDC();          // set to normalized coordinates
3238   PrintRun.SetTextAlign(23);  // center/top alignment
3239   std::ostringstream runnostream;
3240   std::string runstring;
3241   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
3242   // fill run number and event time into string
3243   runnostream << ThisName << "_Non-ZS Channels per SAMPA Run " << cl->RunNumber()
3244               << ", Time: " << ctime(&evttime.first);
3245   runstring = runnostream.str();
3246   TransparentTPad->cd();
3247   PrintRun.SetTextColor(evttime.second);
3248   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
3249 
3250   MyTC->Update();
3251   MyTC->Show();
3252   MyTC->SetEditable(false);
3253 
3254   return 0;
3255 }
3256 
3257 int TpcMonDraw::DrawTPCZSTriggerADCSample(const std::string & /* what */)
3258 {
3259   OnlMonClient *cl = OnlMonClient::instance();
3260 
3261   TH2 *tpcmon_ZSTriggerADCSampledist[24] = {nullptr};
3262   TH2 *tpcmon_ZSTriggerADCSampledist_u[48] = {nullptr};
3263 
3264   char TPCMON_STR[100];
3265   for (int i = 0; i < 48; i++)
3266   {
3267     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3268     sprintf(TPCMON_STR, "TPCMON_%i", i);
3269     tpcmon_ZSTriggerADCSampledist_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "ZS_Trigger_ADC_vs_Sample");
3270   }
3271 
3272   add_TH2(tpcmon_ZSTriggerADCSampledist_u, tpcmon_ZSTriggerADCSampledist);
3273 
3274   if (!gROOT->FindObject("TPCNonZSTriggerADCvsSample"))
3275   {
3276     MakeCanvas("TPCNonZSTriggerADCvsSample");
3277   }
3278 
3279   TCanvas *MyTC = TC[26];
3280   TPad *TransparentTPad = transparent[26];
3281   MyTC->SetEditable(true);
3282   MyTC->Clear("D");
3283 
3284   gStyle->SetOptStat(0);
3285   gStyle->SetPalette(57);  // kBird CVD friendly
3286 
3287   for (int i = 0; i < 24; i++)
3288   {
3289     if (tpcmon_ZSTriggerADCSampledist[i])
3290     {
3291       MyTC->cd(i + 5);
3292       tpcmon_ZSTriggerADCSampledist[i]->GetXaxis()->SetRangeUser(0, 20);
3293       tpcmon_ZSTriggerADCSampledist[i]->DrawCopy("colz");
3294       gPad->SetLogz(kTRUE);
3295       gPad->SetLogy(kTRUE);
3296       gPad->SetGridy(kTRUE);
3297     }
3298   }
3299 
3300   TText PrintRun;
3301   PrintRun.SetTextFont(62);
3302   PrintRun.SetTextSize(0.04);
3303   PrintRun.SetNDC();          // set to normalized coordinates
3304   PrintRun.SetTextAlign(23);  // center/top alignment
3305   std::ostringstream runnostream;
3306   std::string runstring;
3307   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
3308   // fill run number and event time into string
3309   runnostream << ThisName << "_Trigger ADC vs Sample Run " << cl->RunNumber()
3310               << ", Time: " << ctime(&evttime.first);
3311   runstring = runnostream.str();
3312   TransparentTPad->cd();
3313   PrintRun.SetTextColor(evttime.second);
3314   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
3315 
3316   MyTC->Update();
3317   MyTC->Show();
3318   MyTC->SetEditable(false);
3319 
3320   return 0;
3321 }
3322 
3323 int TpcMonDraw::DrawTPCFirstnonZSADCFirstnonZSSample(const std::string & /* what */)
3324 {
3325   OnlMonClient *cl = OnlMonClient::instance();
3326 
3327   TH2 *tpcmon_FirstNZSADCvsFirstNZSSample[24] = {nullptr};
3328   TH2 *tpcmon_FirstNZSADCvsFirstNZSSample_u[48] = {nullptr};
3329 
3330   char TPCMON_STR[100];
3331   for (int i = 0; i < 48; i++)
3332   {
3333     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3334     sprintf(TPCMON_STR, "TPCMON_%i", i);
3335     tpcmon_FirstNZSADCvsFirstNZSSample_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "First_ADC_vs_First_Time_Bin");
3336   }
3337 
3338   add_TH2(tpcmon_FirstNZSADCvsFirstNZSSample_u, tpcmon_FirstNZSADCvsFirstNZSSample);
3339 
3340   if (!gROOT->FindObject("TPCFirstADCvsFirstSample"))
3341   {
3342     MakeCanvas("TPCFirstADCvsFirstSample");
3343   }
3344 
3345   TCanvas *MyTC = TC[27];
3346   TPad *TransparentTPad = transparent[27];
3347   MyTC->SetEditable(true);
3348   MyTC->Clear("D");
3349 
3350   gStyle->SetOptStat(0);
3351   gStyle->SetPalette(57);  // kBird CVD friendly
3352 
3353   for (int i = 0; i < 24; i++)
3354   {
3355     if (tpcmon_FirstNZSADCvsFirstNZSSample[i])
3356     {
3357       MyTC->cd(i + 5);
3358       tpcmon_FirstNZSADCvsFirstNZSSample[i]->RebinX(5);
3359       tpcmon_FirstNZSADCvsFirstNZSSample[i]->DrawCopy("colz");
3360       gPad->SetLogz(kTRUE);
3361       gPad->SetLogy(kTRUE);
3362     }
3363   }
3364 
3365   TText PrintRun;
3366   PrintRun.SetTextFont(62);
3367   PrintRun.SetTextSize(0.04);
3368   PrintRun.SetNDC();          // set to normalized coordinates
3369   PrintRun.SetTextAlign(23);  // center/top alignment
3370   std::ostringstream runnostream;
3371   std::string runstring;
3372   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
3373   // fill run number and event time into string
3374   runnostream << ThisName << "_1st non-ZS ADC vs 1st non-ZS Sample Run " << cl->RunNumber()
3375               << ", Time: " << ctime(&evttime.first);
3376   runstring = runnostream.str();
3377   TransparentTPad->cd();
3378   PrintRun.SetTextColor(evttime.second);
3379   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
3380 
3381   MyTC->Update();
3382   MyTC->Show();
3383   MyTC->SetEditable(false);
3384 
3385   return 0;
3386 }
3387 
3388 int TpcMonDraw::DrawTPCDriftWindow(const std::string & /* what */)
3389 {
3390   OnlMonClient *cl = OnlMonClient::instance();
3391 
3392   TH1 *tpcmon_DriftWindow[24][3] = {nullptr};
3393   TH1 *tpcmon_DriftWindow_u[48][3] = {nullptr};
3394 
3395   char TPCMON_STR[100];
3396   for (int i = 0; i < 48; i++)
3397   {
3398     for (int j = 0; j < 3; j++)
3399     {
3400       // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3401       sprintf(TPCMON_STR, "TPCMON_%i", i);
3402       tpcmon_DriftWindow_u[i][0] = (TH1 *) cl->getHisto(TPCMON_STR, "COUNTS_vs_SAMPLE_1D_R1");  // tpcmon_DriftWindow[i][0]->GetXaxis()->SetRangeUser(0,500);
3403       tpcmon_DriftWindow_u[i][1] = (TH1 *) cl->getHisto(TPCMON_STR, "COUNTS_vs_SAMPLE_1D_R2");  // tpcmon_DriftWindow[i][1]->GetXaxis()->SetRangeUser(0,500);
3404       tpcmon_DriftWindow_u[i][2] = (TH1 *) cl->getHisto(TPCMON_STR, "COUNTS_vs_SAMPLE_1D_R3");  // tpcmon_DriftWindow[i][2]->GetXaxis()->SetRangeUser(0,500);
3405     }
3406   }
3407 
3408   add_TH1_modules(tpcmon_DriftWindow_u, tpcmon_DriftWindow);
3409 
3410   if (!gROOT->FindObject("TPCDriftWindow"))
3411   {
3412     MakeCanvas("TPCDriftWindow");
3413   }
3414 
3415   TCanvas *MyTC = TC[28];
3416   TPad *TransparentTPad = transparent[28];
3417   MyTC->SetEditable(true);
3418   MyTC->Clear("D");
3419 
3420   gStyle->SetOptStat(0);
3421   gStyle->SetPalette(57);  // kBird CVD friendly
3422 
3423   auto legend = new TLegend(0.7, 0.65, 0.98, 0.95);
3424   bool draw_leg = 0;
3425 
3426   for (int i = 0; i < 24; i++)
3427   {
3428     MyTC->cd(i + 5);
3429 
3430     int min = std::numeric_limits<int>::max();           // start wih the largest possible value
3431     int max = std::numeric_limits<int>::min();           // start with smalles possible value
3432     int no_laser_max = std::numeric_limits<int>::min();  // start with smalles possible value
3433 
3434     bool no_laser_window = 0;
3435 
3436     for (int j = 2; j > -1; j--)
3437     {
3438       if (tpcmon_DriftWindow[i][j])
3439       {
3440         for (int k = 1; k < tpcmon_DriftWindow[i][j]->GetNbinsX(); k++)  // old laser peak 416, new laser peak 403, new laser peak w/ 57.14 ns clock 368
3441         {
3442           if ((k >= 0 && k <= 350) || (k > 380))
3443           {
3444             no_laser_window = 1;
3445           }
3446           if (k > 350 && k <= 380)
3447           {
3448             no_laser_window = 0;
3449           }
3450           if ((tpcmon_DriftWindow[i][j]->GetBinContent(k) > no_laser_max && tpcmon_DriftWindow[i][j]->GetBinContent(k) > 0) && (no_laser_window == 1))
3451           {
3452             no_laser_max = tpcmon_DriftWindow[i][j]->GetBinContent(k);
3453           }
3454           if (tpcmon_DriftWindow[i][j]->GetBinContent(k) > max && tpcmon_DriftWindow[i][j]->GetBinContent(k) > 0)
3455           {
3456             max = tpcmon_DriftWindow[i][j]->GetBinContent(k);
3457           }
3458           if (tpcmon_DriftWindow[i][j]->GetBinContent(k) < min && tpcmon_DriftWindow[i][j]->GetBinContent(k) > 0)
3459           {
3460             min = tpcmon_DriftWindow[i][j]->GetBinContent(k);
3461           }
3462         }
3463       }
3464     }
3465 
3466     for (int l = 2; l > -1; l--)
3467     {
3468       if (tpcmon_DriftWindow[i][l])
3469       {
3470         tpcmon_DriftWindow[i][l]->GetXaxis()->SetRangeUser(0, 500);
3471         if (l == 2)
3472         {
3473           tpcmon_DriftWindow[i][l]->GetYaxis()->SetRangeUser(0.9 * min, 1.1 * max);
3474           tpcmon_DriftWindow[i][l]->DrawCopy("HIST");
3475         }  // used to be
3476         else
3477         {
3478           tpcmon_DriftWindow[i][l]->GetYaxis()->SetRangeUser(0.9 * min, 1.1 * max);
3479           tpcmon_DriftWindow[i][l]->DrawCopy("HISTsame");
3480         }  // assumes that R3 will always exist and is most entries
3481       }
3482     }
3483 
3484     gPad->Update();
3485 
3486     if (draw_leg == 0 && tpcmon_DriftWindow[i][0] && tpcmon_DriftWindow[i][1] && tpcmon_DriftWindow[i][2])  // if you have not drawn the legend yet, draw it BUT ONLY ONCE
3487     {
3488       legend->AddEntry(tpcmon_DriftWindow[i][0], "R1");
3489       legend->AddEntry(tpcmon_DriftWindow[i][1], "R2");
3490       legend->AddEntry(tpcmon_DriftWindow[i][2], "R3");
3491       MyTC->cd(i + 5);
3492       legend->Draw();
3493       draw_leg = 1;  // don't draw it again
3494     }
3495   }
3496 
3497   TText PrintRun;
3498   PrintRun.SetTextFont(62);
3499   PrintRun.SetTextSize(0.04);
3500   PrintRun.SetNDC();          // set to normalized coordinates
3501   PrintRun.SetTextAlign(23);  // center/top alignment
3502   std::ostringstream runnostream;
3503   std::string runstring;
3504   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
3505   // fill run number and event time into string
3506   runnostream << ThisName << "_Drift Window, ADC-Pedestal>(5sigma||20ADC) Run " << cl->RunNumber()
3507               << ", Time: " << ctime(&evttime.first);
3508   runstring = runnostream.str();
3509   TransparentTPad->cd();
3510   PrintRun.SetTextColor(evttime.second);
3511   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
3512 
3513   MyTC->Update();
3514   MyTC->Show();
3515   MyTC->SetEditable(false);
3516 
3517   return 0;
3518 }
3519 
3520 int TpcMonDraw::DrawTPCNStreaksvsEventNo(const std::string & /* what */)
3521 {
3522   OnlMonClient *cl = OnlMonClient::instance();
3523 
3524   TH1 *tpcmon_NStreak_vsEventNo[24] = {nullptr};
3525   TH1 *tpcmoneventsebdc[24] = {nullptr};
3526 
3527   TH1 *tpcmon_NStreak_vsEventNo_u[48] = {nullptr};
3528   TH1 *tpcmoneventsebdc_u[48] = {nullptr};
3529 
3530   char TPCMON_STR[100];
3531 
3532   for (int i = 0; i < 48; i++)  // get the streakers vs event nos from each event histo
3533   {
3534     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3535     sprintf(TPCMON_STR, "TPCMON_%i", i);
3536     tpcmon_NStreak_vsEventNo_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "NStreaks_vs_EventNo");
3537   }
3538 
3539   for (int i = 0; i < 48; i++)  // get the num of events from each event histo
3540   {
3541     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3542     sprintf(TPCMON_STR, "TPCMON_%i", i);
3543     tpcmoneventsebdc_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "NEvents_vs_EBDC");
3544   }
3545 
3546   add_TH1(tpcmon_NStreak_vsEventNo_u, tpcmon_NStreak_vsEventNo);
3547   add_TH1(tpcmoneventsebdc_u, tpcmoneventsebdc);
3548 
3549   if (!gROOT->FindObject("TPCNStreakersvsEventNo"))
3550   {
3551     MakeCanvas("TPCNStreakersvsEventNo");
3552   }
3553 
3554   int event_max = 0;
3555   int horiz_max = 0;
3556 
3557   for (int i = 0; i < 24; i++)
3558   {
3559     if (tpcmoneventsebdc[i])
3560     {
3561       if (tpcmoneventsebdc[i]->GetBinContent(i + 1) > event_max)
3562       {
3563         event_max = tpcmoneventsebdc[i]->GetBinContent(i + 1);
3564       }
3565       if (tpcmoneventsebdc[i]->GetBinContent(tpcmoneventsebdc[i]->GetMaximumBin()) > horiz_max)
3566       {
3567         horiz_max = tpcmoneventsebdc[i]->GetBinContent(tpcmoneventsebdc[i]->GetMaximumBin());
3568       }
3569     }
3570   }
3571 
3572   int line_colors[24] = {3, 8, 2, 6, 46, 14, 1, 39, 38, 4, 7, 30, 3, 8, 6, 2, 46, 4, 1, 39, 38, 4, 7, 30};  // assumed filling down and across
3573   // int line_colors_leg[24] = {2, 3, 38, 14, 6, 8, 4, 1, 46, 30, 7, 39, 6, 3, 38, 4, 2, 8, 4, 1, 46, 30, 7, 39 }; // assumed filling across and down
3574 
3575   TCanvas *MyTC = TC[29];
3576   TPad *TransparentTPad = transparent[29];
3577 
3578   auto leg1 = new TLegend(0.6, 0.65, 0.98, 0.95);
3579   leg1->SetNColumns(4);
3580 
3581   leg1->AddEntry((TObject *) 0, "North Top", "");
3582   leg1->AddEntry((TObject *) 0, "North West", "");
3583   leg1->AddEntry((TObject *) 0, "North Bottom", "");
3584   leg1->AddEntry((TObject *) 0, "North East", "");
3585 
3586   auto leg2 = new TLegend(0.6, 0.65, 0.98, 0.95);
3587   leg2->SetNColumns(4);
3588   leg2->AddEntry((TObject *) 0, "South Top", "");
3589   leg2->AddEntry((TObject *) 0, "South West", "");
3590   leg2->AddEntry((TObject *) 0, "South Bottom", "");
3591   leg2->AddEntry((TObject *) 0, "South East", "");
3592 
3593   // int order[24] = {2, 3, 4, 0, 1, 11, 8, 9, 10, 5, 6, 7, 14, 15, 16, 12, 13, 23, 20, 21, 22, 17, 18, 19}; // assumed filling down and across
3594   int order_leg[24] = {2, 0, 8, 5, 3, 1, 9, 6, 4, 11, 10, 7, 14, 12, 20, 17, 15, 13, 21, 18, 16, 23, 22, 19};  // assumed filling across and down
3595 
3596   char legend_str[100];
3597 
3598   for (int i = 0; i < 24; i++)  // legend loop
3599   {
3600     if (tpcmon_NStreak_vsEventNo[order_leg[i]] && i <= 11)
3601     {
3602       sprintf(legend_str, "Sector %i", order_leg[i]);
3603       leg1->AddEntry(tpcmon_NStreak_vsEventNo[order_leg[i]], legend_str);
3604     }
3605 
3606     if (!tpcmon_NStreak_vsEventNo[order_leg[i]] && i <= 11)
3607     {
3608       leg1->AddEntry((TObject *) 0, "", "");
3609     }
3610 
3611     if (tpcmon_NStreak_vsEventNo[order_leg[i]] && i > 11)
3612     {
3613       sprintf(legend_str, "Sector %i", order_leg[i]);
3614       leg2->AddEntry(tpcmon_NStreak_vsEventNo[order_leg[i]], legend_str);
3615     }
3616 
3617     if (!tpcmon_NStreak_vsEventNo[order_leg[i]] && i > 11)
3618     {
3619       leg2->AddEntry((TObject *) 0, "", "");
3620     }
3621   }
3622 
3623   MyTC->SetEditable(true);
3624   MyTC->Clear("D");
3625   for (int i = 0; i < 24; i++)
3626   {
3627     if (tpcmon_NStreak_vsEventNo[i])
3628     {
3629       if (i <= 11)
3630       {
3631         MyTC->cd(1);
3632       }
3633       else
3634       {
3635         MyTC->cd(2);
3636       }
3637       gStyle->SetPadLeftMargin(0.05);
3638       gStyle->SetPadRightMargin(0.02);
3639 
3640       tpcmon_NStreak_vsEventNo[i]->GetXaxis()->SetRangeUser(0, event_max);
3641       tpcmon_NStreak_vsEventNo[i]->GetYaxis()->SetRangeUser(0.01, 1.1 * horiz_max);
3642       tpcmon_NStreak_vsEventNo[i]->SetStats(kFALSE);
3643       tpcmon_NStreak_vsEventNo[i]->SetTitle("");
3644 
3645       tpcmon_NStreak_vsEventNo[i]->SetMarkerColor(line_colors[i]);
3646       tpcmon_NStreak_vsEventNo[i]->SetLineColor(line_colors[i]);
3647       tpcmon_NStreak_vsEventNo[i]->SetLineWidth(3);
3648       tpcmon_NStreak_vsEventNo[i]->Draw("LF2 same");
3649 
3650       gPad->SetLogy(kTRUE);
3651 
3652       MyTC->Update();
3653     }
3654   }
3655 
3656   MyTC->cd(1);
3657   leg1->Draw("same");
3658   MyTC->cd(2);
3659   leg2->Draw("same");
3660 
3661   TText PrintRun;
3662   PrintRun.SetTextFont(62);
3663   PrintRun.SetTextSize(0.04);
3664   PrintRun.SetNDC();          // set to normalized coordinates
3665   PrintRun.SetTextAlign(23);  // center/top alignment
3666   std::ostringstream runnostream;
3667   std::string runstring;
3668   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
3669   // fill run number and event time into string
3670   runnostream << ThisName << "_NStreakers_vs_Event # Packet per Sector" << cl->RunNumber()
3671               << ", Time: " << ctime(&evttime.first);
3672   runstring = runnostream.str();
3673   TransparentTPad->cd();
3674   PrintRun.SetTextColor(evttime.second);
3675   PrintRun.DrawText(0.5, 0.99, runstring.c_str());
3676 
3677   MyTC->Update();
3678   MyTC->Show();
3679   MyTC->SetEditable(false);
3680 
3681   return 0;
3682 }
3683 
3684 int TpcMonDraw::DrawTPCPacketTypes(const std::string & /* what */)
3685 {
3686   OnlMonClient *cl = OnlMonClient::instance();
3687 
3688   TH1 *tpcmon_PacketType[24][3] = {nullptr};
3689   TH1 *tpcmon_PacketType_u[48][3] = {nullptr};
3690 
3691   char TPCMON_STR[100];
3692   for (int i = 0; i < 48; i++)
3693   {
3694     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3695     sprintf(TPCMON_STR, "TPCMON_%i", i);
3696     tpcmon_PacketType_u[i][0] = (TH1 *) cl->getHisto(TPCMON_STR, "Packet_Type_Fraction_HB");
3697     tpcmon_PacketType_u[i][1] = (TH1 *) cl->getHisto(TPCMON_STR, "Packet_Type_Fraction_NORM");
3698     tpcmon_PacketType_u[i][2] = (TH1 *) cl->getHisto(TPCMON_STR, "Packet_Type_Fraction_ELSE");
3699   }
3700 
3701   add_TH1_modules(tpcmon_PacketType_u, tpcmon_PacketType);
3702 
3703   if (!gROOT->FindObject("TPCPacketType"))
3704   {
3705     MakeCanvas("TPCPacketType");
3706   }
3707 
3708   TCanvas *MyTC = TC[30];
3709   TPad *TransparentTPad = transparent[30];
3710   MyTC->SetEditable(true);
3711   MyTC->Clear("D");
3712 
3713   gStyle->SetOptStat(0);
3714   gStyle->SetPalette(57);  // kBird CVD friendly
3715 
3716   double normfactor = 0;
3717 
3718   int index_arr[3] = {1, 0, 2};
3719 
3720   double norm_highest = 0.;
3721   int index_highest = 1;
3722 
3723   for (int i = 0; i < 24; i++)
3724   {
3725     for (int k = 0; k < 3; k++)
3726     {
3727       if (tpcmon_PacketType[i][k])
3728       {
3729         normfactor += (tpcmon_PacketType[i][k]->GetEntries());
3730         if (tpcmon_PacketType[i][k]->GetEntries() > norm_highest)
3731         {
3732           norm_highest = (tpcmon_PacketType[i][k]->GetEntries());
3733           index_highest = k;
3734         }
3735       }
3736     }
3737 
3738     if (index_highest == 0)
3739     {
3740       index_arr[0] = 0;
3741       index_arr[1] = 1;
3742       index_arr[2] = 2;
3743     }
3744     if (index_highest == 2)
3745     {
3746       index_arr[0] = 2;
3747       index_arr[1] = 1;
3748       index_arr[2] = 0;
3749     }
3750 
3751     for (int j = 0; j < 3; j++)
3752     {
3753       if (tpcmon_PacketType[i][index_arr[j]])
3754       {
3755         MyTC->cd(i + 5);
3756         if (normfactor > 0)
3757         {
3758           tpcmon_PacketType[i][index_arr[j]]->Scale(1 / (normfactor), "width");
3759         }
3760         gPad->SetLogy(kTRUE);
3761         if (j == 0)
3762         {
3763           tpcmon_PacketType[i][index_arr[j]]->DrawCopy("HIST");
3764         }
3765         else
3766         {
3767           tpcmon_PacketType[i][index_arr[j]]->DrawCopy("HISTsame");
3768         }
3769       }
3770     }
3771 
3772     gPad->Update();
3773 
3774     normfactor = 0;  // reset this after scaling each histogram at end of iteration of outer for loop (i loop)
3775   }
3776 
3777   TText PrintRun;
3778   PrintRun.SetTextFont(62);
3779   PrintRun.SetTextSize(0.04);
3780   PrintRun.SetNDC();          // set to normalized coordinates
3781   PrintRun.SetTextAlign(23);  // center/top alignment
3782   std::ostringstream runnostream;
3783   std::string runstring;
3784   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
3785   // fill run number and event time into string
3786   runnostream << ThisName << "_WF PACKET FRACTION Run " << cl->RunNumber()
3787               << ", Time: " << ctime(&evttime.first);
3788   runstring = runnostream.str();
3789   TransparentTPad->cd();
3790   PrintRun.SetTextColor(evttime.second);
3791   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
3792 
3793   MyTC->Update();
3794   MyTC->Show();
3795   MyTC->SetEditable(false);
3796 
3797   return 0;
3798 }
3799 
3800 int TpcMonDraw::DrawTPCChansperLVL1_NS(const std::string & /* what */)
3801 {
3802   OnlMonClient *cl = OnlMonClient::instance();
3803 
3804   TH1 *tpcmon_chanlvl1NS[24] = {nullptr};
3805   TH1 *lvl1_per_EBDC[24] = {nullptr};
3806 
3807   TH1 *tpcmon_chanlvl1NS_u[48] = {nullptr};
3808   TH1 *lvl1_per_EBDC_u[48] = {nullptr};
3809 
3810   char TPCMON_STR[100];
3811   for (int i = 0; i < 12; i++)
3812   {
3813     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3814     sprintf(TPCMON_STR, "TPCMON_%i", i);
3815     tpcmon_chanlvl1NS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_in_Packet");
3816     lvl1_per_EBDC_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "LVL_1_TAGGER_per_EBDC");
3817   }
3818 
3819   for (int i = 24; i < 36; i++)
3820   {
3821     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3822     sprintf(TPCMON_STR, "TPCMON_%i", i);
3823     tpcmon_chanlvl1NS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_in_Packet");
3824     lvl1_per_EBDC_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "LVL_1_TAGGER_per_EBDC");
3825   }
3826 
3827   add_TH1(tpcmon_chanlvl1NS_u, tpcmon_chanlvl1NS);
3828   add_TH1(lvl1_per_EBDC_u, lvl1_per_EBDC);
3829 
3830   if (!gROOT->FindObject("TPCChan_per_LVL1_NS"))
3831   {
3832     MakeCanvas("TPCChan_per_LVL1_NS");
3833   }
3834 
3835   TCanvas *MyTC = TC[31];
3836   TPad *TransparentTPad = transparent[31];
3837 
3838   TLine *t1 = new TLine();
3839   t1->SetLineWidth(2);
3840   TLine *t2 = new TLine();
3841   t2->SetLineStyle(2);
3842   TText *tt1 = new TText();
3843   tt1->SetTextSize(0.05);
3844 
3845   int FEEid[26] = {
3846       2, 4, 3, 13, 17, 16,                       // R1
3847       11, 12, 19, 18, 0, 1, 15, 14,              // R2
3848       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
3849   };
3850 
3851   char title[50];
3852 
3853   MyTC->SetEditable(true);
3854   MyTC->Clear("D");
3855   for (int i = 0; i < 12; i++)
3856   {
3857     if (tpcmon_chanlvl1NS[i] && lvl1_per_EBDC[i])
3858     {
3859       MyTC->cd(i + 3);
3860       gStyle->SetPadLeftMargin(0.05);
3861       gStyle->SetPadRightMargin(0.02);
3862       tpcmon_chanlvl1NS[i]->Scale(1 / (lvl1_per_EBDC[i]->GetBinContent(i + 1)), "width");
3863       double Yrange_upper = 1.32 * tpcmon_chanlvl1NS[i]->GetMaximum();
3864       tpcmon_chanlvl1NS[i]->GetYaxis()->SetRangeUser(0, Yrange_upper);
3865 
3866       tpcmon_chanlvl1NS[i]->SetMarkerColor(4);
3867       tpcmon_chanlvl1NS[i]->SetLineColor(4);
3868       tpcmon_chanlvl1NS[i]->SetFillColor(5);
3869       tpcmon_chanlvl1NS[i]->DrawCopy("HIST");
3870 
3871       MyTC->Update();
3872 
3873       for (int j = 0; j < 25; j++)
3874       {
3875         t2->DrawLine((j + 1) * 256, -0.01, (j + 1) * 256, Yrange_upper);
3876       }
3877       for (int k = 0; k < 26; k++)
3878       {
3879         sprintf(title, "%d", FEEid[k]);
3880         tt1->DrawText(k * 256 + 128, 0.84 * Yrange_upper, title);
3881       }
3882       tt1->SetTextSize(0.06);
3883       tt1->DrawText(800, 0.92 * Yrange_upper, "R1");
3884       tt1->DrawText(2450, 0.92 * Yrange_upper, "R2");
3885       tt1->DrawText(5200, 0.92 * Yrange_upper, "R3");
3886       tt1->SetTextSize(0.05);
3887 
3888       t1->DrawLine(1536, 0, 1536, Yrange_upper);
3889       t1->DrawLine(3584, 0, 3584, Yrange_upper);
3890     }
3891   }
3892 
3893   TText PrintRun;
3894   PrintRun.SetTextFont(62);
3895   PrintRun.SetTextSize(0.04);
3896   PrintRun.SetNDC();          // set to normalized coordinates
3897   PrintRun.SetTextAlign(23);  // center/top alignment
3898   std::ostringstream runnostream;
3899   std::string runstring;
3900   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
3901   // fill run number and event time into string
3902   runnostream << ThisName << "_NS_Channels per LEVEL_1 TAGGER Run " << cl->RunNumber()
3903               << ", Time: " << ctime(&evttime.first);
3904   runstring = runnostream.str();
3905   TransparentTPad->cd();
3906   PrintRun.SetTextColor(evttime.second);
3907   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
3908 
3909   MyTC->Update();
3910   MyTC->Show();
3911   MyTC->SetEditable(false);
3912 
3913   return 0;
3914 }
3915 
3916 int TpcMonDraw::DrawTPCChansperLVL1_SS(const std::string & /* what */)
3917 {
3918   OnlMonClient *cl = OnlMonClient::instance();
3919 
3920   TH1 *tpcmon_chanlvl1SS[24] = {nullptr};
3921   TH1 *lvl1_per_EBDC[24] = {nullptr};
3922 
3923   TH1 *tpcmon_chanlvl1SS_u[48] = {nullptr};
3924   TH1 *lvl1_per_EBDC_u[48] = {nullptr};
3925 
3926   char TPCMON_STR[100];
3927   for (int i = 12; i < 24; i++)
3928   {
3929     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3930     sprintf(TPCMON_STR, "TPCMON_%i", i);
3931     tpcmon_chanlvl1SS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_in_Packet");
3932     lvl1_per_EBDC_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "LVL_1_TAGGER_per_EBDC");
3933   }
3934 
3935   for (int i = 36; i < 48; i++)
3936   {
3937     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
3938     sprintf(TPCMON_STR, "TPCMON_%i", i);
3939     tpcmon_chanlvl1SS_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Channels_in_Packet");
3940     lvl1_per_EBDC_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "LVL_1_TAGGER_per_EBDC");
3941   }
3942 
3943   add_TH1(tpcmon_chanlvl1SS_u, tpcmon_chanlvl1SS);
3944   add_TH1(lvl1_per_EBDC_u, lvl1_per_EBDC);
3945 
3946   if (!gROOT->FindObject("TPCChan_per_LVL1_SS"))
3947   {
3948     MakeCanvas("TPCChan_per_LVL1_SS");
3949   }
3950 
3951   TCanvas *MyTC = TC[32];
3952   TPad *TransparentTPad = transparent[32];
3953 
3954   TLine *t1 = new TLine();
3955   t1->SetLineWidth(2);
3956   TLine *t2 = new TLine();
3957   t2->SetLineStyle(2);
3958   TText *tt1 = new TText();
3959   tt1->SetTextSize(0.05);
3960 
3961   int FEEid[26] = {
3962       2, 4, 3, 13, 17, 16,                       // R1
3963       11, 12, 19, 18, 0, 1, 15, 14,              // R2
3964       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
3965   };
3966 
3967   char title[50];
3968 
3969   MyTC->SetEditable(true);
3970   MyTC->Clear("D");
3971   for (int i = 12; i < 24; i++)
3972   {
3973     if (tpcmon_chanlvl1SS[i] && lvl1_per_EBDC[i])
3974     {
3975       MyTC->cd(i - 12 + 3);
3976       gStyle->SetPadLeftMargin(0.05);
3977       gStyle->SetPadRightMargin(0.02);
3978       tpcmon_chanlvl1SS[i]->Scale(1 / (lvl1_per_EBDC[i]->GetBinContent(i - 12 + 13)), "width");
3979       double Yrange_upper = 1.32 * tpcmon_chanlvl1SS[i]->GetMaximum();
3980       tpcmon_chanlvl1SS[i]->GetYaxis()->SetRangeUser(0, Yrange_upper);
3981 
3982       tpcmon_chanlvl1SS[i]->SetMarkerColor(4);
3983       tpcmon_chanlvl1SS[i]->SetLineColor(4);
3984       tpcmon_chanlvl1SS[i]->SetFillColor(5);
3985       tpcmon_chanlvl1SS[i]->DrawCopy("HIST");
3986 
3987       MyTC->Update();
3988 
3989       for (int j = 0; j < 25; j++)
3990       {
3991         t2->DrawLine((j + 1) * 256, -0.01, (j + 1) * 256, Yrange_upper);
3992       }
3993       for (int k = 0; k < 26; k++)
3994       {
3995         sprintf(title, "%d", FEEid[k]);
3996         tt1->DrawText(k * 256 + 128, 0.84 * Yrange_upper, title);
3997       }
3998       tt1->SetTextSize(0.06);
3999       tt1->DrawText(800, 0.92 * Yrange_upper, "R1");
4000       tt1->DrawText(2450, 0.92 * Yrange_upper, "R2");
4001       tt1->DrawText(5200, 0.92 * Yrange_upper, "R3");
4002       tt1->SetTextSize(0.05);
4003 
4004       t1->DrawLine(1536, 0, 1536, Yrange_upper);
4005       t1->DrawLine(3584, 0, 3584, Yrange_upper);
4006     }
4007   }
4008 
4009   TText PrintRun;
4010   PrintRun.SetTextFont(62);
4011   PrintRun.SetTextSize(0.04);
4012   PrintRun.SetNDC();          // set to normalized coordinates
4013   PrintRun.SetTextAlign(23);  // center/top alignment
4014   std::ostringstream runnostream;
4015   std::string runstring;
4016   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
4017   // fill run number and event time into string
4018   runnostream << ThisName << "_SS_Channels per LEVEL_1 TAGGER Run " << cl->RunNumber()
4019               << ", Time: " << ctime(&evttime.first);
4020   runstring = runnostream.str();
4021   TransparentTPad->cd();
4022   PrintRun.SetTextColor(evttime.second);
4023   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
4024 
4025   MyTC->Update();
4026   MyTC->Show();
4027   MyTC->SetEditable(false);
4028 
4029   return 0;
4030 }
4031 
4032 int TpcMonDraw::DrawTPCParity(const std::string & /* what */)
4033 {
4034   OnlMonClient *cl = OnlMonClient::instance();
4035 
4036   TH1 *tpcmon_parityerror[24] = {nullptr};
4037   TH1 *tpcmon_parities[24] = {nullptr};
4038 
4039   TH1 *tpcmon_parityerror_u[48] = {nullptr};
4040   TH1 *tpcmon_parities_u[48] = {nullptr};
4041 
4042   char TPCMON_STR[100];
4043   for (int i = 0; i < 48; i++)
4044   {
4045     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
4046     sprintf(TPCMON_STR, "TPCMON_%i", i);
4047     tpcmon_parityerror_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Parity_Error");
4048     tpcmon_parities_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Check_Sums");
4049   }
4050 
4051   add_TH1(tpcmon_parityerror_u, tpcmon_parityerror);
4052   add_TH1(tpcmon_parities_u, tpcmon_parities);
4053 
4054   if (!gROOT->FindObject("TPCParityError"))
4055   {
4056     MakeCanvas("TPCParityError");
4057   }
4058   TCanvas *MyTC = TC[33];
4059   TPad *TransparentTPad = transparent[33];
4060 
4061   MyTC->SetEditable(true);
4062   MyTC->Clear("D");
4063   MyTC->cd(1);
4064 
4065   TLine *t1 = new TLine();
4066   t1->SetLineWidth(2);
4067   TLine *t2 = new TLine();
4068   t2->SetLineStyle(2);
4069   TText *tt1 = new TText();
4070   tt1->SetTextSize(0.05);
4071 
4072   int FEEid[26] = {
4073       2, 4, 3, 13, 17, 16,                       // R1
4074       11, 12, 19, 18, 0, 1, 15, 14,              // R2
4075       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
4076   };
4077 
4078   char title[50];
4079 
4080   for (int i = 0; i < 24; i++)
4081   {
4082     if (tpcmon_parityerror[i] && tpcmon_parities[i])
4083     {
4084       MyTC->cd(i + 5);
4085 
4086       tpcmon_parityerror[i]->Divide(tpcmon_parities[i]);
4087       tpcmon_parityerror[i]->GetYaxis()->SetRangeUser(0.0001, 1.5);
4088       tpcmon_parityerror[i]->DrawCopy("HIST");
4089 
4090       MyTC->Update();
4091 
4092       for (int j = 0; j < 25; j++)
4093       {
4094         t2->DrawLine((j + 1) * 8, -0.01, (j + 1) * 8, 1.5);
4095       }
4096       for (int k = 0; k < 26; k++)
4097       {
4098         sprintf(title, "%d", FEEid[k]);
4099         tt1->DrawText(k * 8 + 4, 1.2, title);
4100       }
4101       tt1->SetTextSize(0.06);
4102       tt1->DrawText(25, 1.4, "R1");
4103       tt1->DrawText(77, 1.4, "R2");
4104       tt1->DrawText(163, 1.4, "R3");
4105       tt1->SetTextSize(0.05);
4106 
4107       t1->DrawLine(48.5, -0.01, 48.5, 1.5);
4108       t1->DrawLine(112.5, -0.01, 112.5, 1.5);
4109     }
4110   }
4111 
4112   TText PrintRun;
4113   PrintRun.SetTextFont(62);
4114   PrintRun.SetTextSize(0.04);
4115   PrintRun.SetNDC();          // set to normalized coordinates
4116   PrintRun.SetTextAlign(23);  // center/top alignment
4117   std::ostringstream runnostream;
4118   std::string runstring;
4119   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
4120   // fill run number and event time into string
4121   runnostream << ThisName << "_ParityError Run " << cl->RunNumber()
4122               << ", Time: " << ctime(&evttime.first);
4123   runstring = runnostream.str();
4124   TransparentTPad->cd();
4125   PrintRun.SetTextColor(evttime.second);
4126   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
4127 
4128   MyTC->Update();
4129   // MyTC->SetLogy();
4130   MyTC->Show();
4131   MyTC->SetEditable(false);
4132 
4133   return 0;
4134 }
4135 
4136 int TpcMonDraw::DrawShifterTPCDriftWindow(const std::string & /* what */)
4137 {
4138   OnlMonClient *cl = OnlMonClient::instance();
4139 
4140   TH1 *tpcmon_DriftWindow_shifter[24][3] = {nullptr};
4141   TH1 *tpcmon_DriftWindow_shifter_u[48][3] = {nullptr};
4142 
4143   char TPCMON_STR[100];
4144   for (int i = 0; i < 48; i++)
4145   {
4146     for (int j = 0; j < 3; j++)
4147     {
4148       // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
4149       sprintf(TPCMON_STR, "TPCMON_%i", i);
4150       tpcmon_DriftWindow_shifter_u[i][0] = (TH1 *) cl->getHisto(TPCMON_STR, "COUNTS_vs_SAMPLE_1D_R1");
4151       tpcmon_DriftWindow_shifter_u[i][1] = (TH1 *) cl->getHisto(TPCMON_STR, "COUNTS_vs_SAMPLE_1D_R2");
4152       tpcmon_DriftWindow_shifter_u[i][2] = (TH1 *) cl->getHisto(TPCMON_STR, "COUNTS_vs_SAMPLE_1D_R3");
4153     }
4154   }
4155 
4156   add_TH1_modules(tpcmon_DriftWindow_shifter_u, tpcmon_DriftWindow_shifter);
4157 
4158   // also get # of events that made it into each OnlMon Server
4159   TH1 *tpcmoneventsebdc[24] = {nullptr};
4160 
4161   char TPCMON_STR2[100];
4162   for (int i = 0; i < 24; i++)
4163   {
4164     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
4165     sprintf(TPCMON_STR2, "TPCMON_%i", i);
4166     tpcmoneventsebdc[i] = (TH1 *) cl->getHisto(TPCMON_STR2, "NEvents_vs_EBDC");
4167   }
4168 
4169   if (!gROOT->FindObject("ShifterTPCDriftWindow"))
4170   {
4171     MakeCanvas("ShifterTPCDriftWindow");
4172   }
4173 
4174   TCanvas *MyTC = TC[34];
4175   TPad *TransparentTPad = transparent[34];
4176   MyTC->SetEditable(true);
4177   MyTC->Clear("D");
4178 
4179   gStyle->SetOptStat(0);
4180   gStyle->SetPalette(57);  // kBird CVD friendly
4181 
4182   auto legend = new TLegend(0.7, 0.65, 0.98, 0.95);
4183   bool draw_leg = 0;
4184 
4185   char bad_message[128];
4186 
4187   TLine *t2 = new TLine();
4188   t2->SetLineStyle(2);
4189   TPaveText *messages[24];
4190 
4191   for (int i = 0; i < 24; i++)
4192   {
4193     MyTC->cd(i + 5);
4194 
4195     int min = std::numeric_limits<int>::max();  // start wih the largest possible value
4196     int max = std::numeric_limits<int>::min();  // start with smalles possible value
4197 
4198     int R1_max = std::numeric_limits<int>::min();  // start with smalles possible value
4199     int R2_max = std::numeric_limits<int>::min();  // start with smalles possible value
4200     int R3_max = std::numeric_limits<int>::min();  // start with smalles possible value
4201 
4202     bool R1_bad = 0;
4203     bool R2_bad = 0;
4204     bool R3_bad = 0;
4205 
4206     for (int j = 2; j > -1; j--)
4207     {
4208       if (tpcmon_DriftWindow_shifter[i][j])
4209       {
4210         for (int k = 1; k < tpcmon_DriftWindow_shifter[i][j]->GetNbinsX(); k++)
4211         {
4212           // if(j == 2 &&  (tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) > R3_max && tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) > 0) ){ R3_max = k; }
4213           // if(j == 1 &&  (tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) > R2_max && tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) > 0) ){ R2_max = k; }
4214           // if(j == 0 &&  (tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) > R1_max && tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) > 0) ){ R1_max = k; }
4215           // std::cout<<"In Progress: "<<"R1_max = "<<R1_max<<" R2_max = "<<R2_max<<" R3_max = "<<R3_max<<std::endl;
4216           if (tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) > max && tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) > 0)
4217           {
4218             max = tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k);
4219           }
4220           if (tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) < min && tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k) > 0)
4221           {
4222             min = tpcmon_DriftWindow_shifter[i][j]->GetBinContent(k);
4223           }
4224         }
4225       }
4226     }
4227 
4228     if (tpcmon_DriftWindow_shifter[i][0])
4229     {
4230       R1_max = tpcmon_DriftWindow_shifter[i][0]->GetBinCenter(tpcmon_DriftWindow_shifter[i][0]->GetMaximumBin());
4231     }
4232     if (tpcmon_DriftWindow_shifter[i][1])
4233     {
4234       R2_max = tpcmon_DriftWindow_shifter[i][1]->GetBinCenter(tpcmon_DriftWindow_shifter[i][1]->GetMaximumBin());
4235     }
4236     if (tpcmon_DriftWindow_shifter[i][2])
4237     {
4238       R3_max = tpcmon_DriftWindow_shifter[i][2]->GetBinCenter(tpcmon_DriftWindow_shifter[i][2]->GetMaximumBin());
4239     }
4240 
4241     if ((R1_max > std::numeric_limits<int>::min() && (R1_max < 365)) || R1_max > 374)
4242     {
4243       R1_bad = 1;
4244     }  // old peak - 416, new peak 403 50 ns clock, new peak 368 57.14 ns clock
4245     if ((R2_max > std::numeric_limits<int>::min() && (R2_max < 365)) || R2_max > 374)
4246     {
4247       R2_bad = 1;
4248     }
4249     if ((R3_max > std::numeric_limits<int>::min() && (R3_max < 365)) || R3_max > 374)
4250     {
4251       R3_bad = 1;
4252     }
4253 
4254     for (int l = 2; l > -1; l--)
4255     {
4256       if (tpcmon_DriftWindow_shifter[i][l])
4257       {
4258         tpcmon_DriftWindow_shifter[i][l]->GetXaxis()->SetRangeUser(346, 396);  // old peak - 416, new peak 403, new peak 368 57.14 ns clock
4259         if (l == 2)
4260         {
4261           tpcmon_DriftWindow_shifter[i][l]->GetYaxis()->SetRangeUser(0.9 * min, 1.3 * max);
4262           tpcmon_DriftWindow_shifter[i][l]->DrawCopy("HIST");
4263         }  // used to be
4264         else
4265         {
4266           tpcmon_DriftWindow_shifter[i][l]->GetYaxis()->SetRangeUser(0.9 * min, 1.3 * max);
4267           tpcmon_DriftWindow_shifter[i][l]->DrawCopy("HISTsame");
4268         }  // assumes that R3 will always exist and is most entries
4269       }
4270     }
4271 
4272     t2->DrawLine(365, 0.9 * min, 365, 1.3 * max);
4273     t2->DrawLine(375, 0.9 * min, 375, 1.3 * max);
4274 
4275     gPad->Update();
4276 
4277     if (draw_leg == 0 && tpcmon_DriftWindow_shifter[i][0] && tpcmon_DriftWindow_shifter[i][1] && tpcmon_DriftWindow_shifter[i][2])  // if you have not drawn the legend yet, draw it BUT ONLY ONCE
4278     {
4279       legend->AddEntry(tpcmon_DriftWindow_shifter[i][0], "R1");
4280       legend->AddEntry(tpcmon_DriftWindow_shifter[i][1], "R2");
4281       legend->AddEntry(tpcmon_DriftWindow_shifter[i][2], "R3");
4282       MyTC->cd(i + 5);
4283       legend->Draw();
4284       draw_leg = 1;  // draw legend only once
4285     }
4286 
4287     // std::cout<<"R1_max = "<<R1_max<<" R2_max = "<<R2_max<<" R3_max = "<<R3_max<<std::endl;
4288     // messages->Clear();
4289     messages[i] = new TPaveText(0.1, 0.5, 0.4, 0.9, "brNDC");
4290 
4291     /*
4292     if( (i == 21 || i == 22) || (i == 23) )
4293     {
4294       messages[i]->AddText("SECTOR NOT MONITORED"); ((TText*)messages[i]->GetListOfLines()->Last())->SetTextColor(kBlack);
4295       MyTC->cd(i+5);
4296       messages[i]->Draw("same");
4297     }
4298     */
4299     if (tpcmoneventsebdc[i])
4300     {
4301       if (tpcmoneventsebdc[i]->GetEntries() < 8000)
4302       {
4303         messages[i]->AddText("NOT ENOUGH STATS");
4304         ((TText *) messages[i]->GetListOfLines()->Last())->SetTextColor(kBlue);
4305         messages[i]->AddText("CHECK AGAIN");
4306         ((TText *) messages[i]->GetListOfLines()->Last())->SetTextColor(kBlue);
4307         MyTC->cd(i + 5);
4308         messages[i]->Draw("same");
4309       }
4310     }
4311     else if ((R1_bad == 1 || R2_bad == 1) || R3_bad == 1)
4312     {
4313       // std::cout<<"made it into the if statement for bad timing"<<std::endl;
4314       sprintf(bad_message, "Sector %i BAD", i);
4315       messages[i]->SetFillColor(kRed);
4316       messages[i]->AddText(bad_message);
4317       ((TText *) messages[i]->GetListOfLines()->Last())->SetTextColor(kBlack);
4318       messages[i]->AddText("REFRESH. IF PERSISTS, CALL EXPERT");
4319       ((TText *) messages[i]->GetListOfLines()->Last())->SetTextColor(kBlack);
4320       MyTC->cd(i + 5);
4321       messages[i]->Draw("same");
4322     }
4323     else if (tpcmon_DriftWindow_shifter[i][0] && (tpcmon_DriftWindow_shifter[i][1] && tpcmon_DriftWindow_shifter[i][2]))
4324     {
4325       messages[i]->SetFillColor(kGreen);
4326       messages[i]->AddText("ALL GOOD");
4327       ((TText *) messages[i]->GetListOfLines()->Last())->SetTextColor(kBlack);
4328       MyTC->cd(i + 5);
4329       messages[i]->Draw("same");
4330     }
4331     else
4332     {
4333       messages[i]->AddText("MISSING DATA");
4334       ((TText *) messages[i]->GetListOfLines()->Last())->SetTextColor(kBlack);
4335       MyTC->cd(i + 5);
4336       messages[i]->Draw("same");
4337     }
4338 
4339   }  // finish looping over 24 sectors
4340 
4341   TText PrintRun;
4342   PrintRun.SetTextFont(62);
4343   PrintRun.SetTextSize(0.04);
4344   PrintRun.SetNDC();          // set to normalized coordinates
4345   PrintRun.SetTextAlign(23);  // center/top alignment
4346   std::ostringstream runnostream;
4347   std::string runstring;
4348   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
4349   // fill run number and event time into string
4350   runnostream << ThisName << "_Shifter_Drift Window, ADC-Pedestal>(5sigma||20ADC) Run " << cl->RunNumber()
4351               << ", Time: " << ctime(&evttime.first);
4352   runstring = runnostream.str();
4353   TransparentTPad->cd();
4354   PrintRun.SetTextColor(evttime.second);
4355   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
4356 
4357   MyTC->Update();
4358   MyTC->Show();
4359   MyTC->SetEditable(false);
4360 
4361   return 0;
4362 }
4363 
4364 int TpcMonDraw::DrawTPCNoiseChannelPlots(const std::string & /* what */)
4365 {
4366   OnlMonClient *cl = OnlMonClient::instance();
4367 
4368   TH1 *tpcmon_noise_channel_plots[24] = {nullptr};
4369   TH1 *tpcmon_lvl1_per_EBDC[24] = {nullptr};
4370 
4371   TH1 *tpcmon_noise_channel_plots_u[48] = {nullptr};
4372   TH1 *tpcmon_lvl1_per_EBDC_u[48] = {nullptr};
4373 
4374   char TPCMON_STR[100];
4375   for (int i = 0; i < 48; i++)
4376   {
4377     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
4378     sprintf(TPCMON_STR, "TPCMON_%i", i);
4379     tpcmon_noise_channel_plots_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "Noise_Channel_Plots");
4380     tpcmon_lvl1_per_EBDC_u[i] = (TH1 *) cl->getHisto(TPCMON_STR, "LVL_1_TAGGER_per_EBDC");
4381   }
4382 
4383   add_TH1(tpcmon_noise_channel_plots_u, tpcmon_noise_channel_plots);
4384   add_TH1(tpcmon_lvl1_per_EBDC_u, tpcmon_lvl1_per_EBDC);
4385 
4386   if (!gROOT->FindObject("TPCNoiseChannelsPlots"))
4387   {
4388     MakeCanvas("TPCNoiseChannelsPlots");
4389   }
4390 
4391   TCanvas *MyTC = TC[35];
4392   TPad *TransparentTPad = transparent[35];
4393 
4394   TLine *t1 = new TLine();
4395   t1->SetLineWidth(2);
4396   TLine *t2 = new TLine();
4397   t2->SetLineStyle(2);
4398   TText *tt1 = new TText();
4399   tt1->SetTextSize(0.05);
4400 
4401   int FEEid[26] = {
4402       2, 4, 3, 13, 17, 16,                       // R1
4403       11, 12, 19, 18, 0, 1, 15, 14,              // R2
4404       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
4405   };
4406 
4407   char title[50];
4408 
4409   MyTC->SetEditable(true);
4410   MyTC->Clear("D");
4411   for (int i = 0; i < 24; i++)
4412   {
4413     if (tpcmon_noise_channel_plots[i] && tpcmon_lvl1_per_EBDC[i])
4414     {
4415       MyTC->cd(i + 5);
4416       gStyle->SetPadLeftMargin(0.05);
4417       gStyle->SetPadRightMargin(0.02);
4418       tpcmon_noise_channel_plots[i]->Scale(1. / tpcmon_lvl1_per_EBDC[i]->GetEntries());
4419 
4420       double Yrange_upper = 2.0 * tpcmon_noise_channel_plots[i]->GetMaximum();
4421       tpcmon_noise_channel_plots[i]->GetYaxis()->SetRangeUser(0, Yrange_upper);
4422       tpcmon_noise_channel_plots[i]->DrawCopy("HIST");
4423 
4424       MyTC->Update();
4425 
4426       for (int j = 0; j < 25; j++)
4427       {
4428         t2->DrawLine((j + 1) * 256, -0.01, (j + 1) * 256, Yrange_upper);
4429       }
4430       for (int k = 0; k < 26; k++)
4431       {
4432         sprintf(title, "%d", FEEid[k]);
4433         tt1->DrawText(k * 256 + 128, 0.84 * Yrange_upper, title);
4434       }
4435       tt1->SetTextSize(0.06);
4436       tt1->DrawText(800, 0.92 * Yrange_upper, "R1");
4437       tt1->DrawText(2450, 0.92 * Yrange_upper, "R2");
4438       tt1->DrawText(5200, 0.92 * Yrange_upper, "R3");
4439       tt1->SetTextSize(0.05);
4440 
4441       t1->DrawLine(1536, 0, 1536, Yrange_upper);
4442       t1->DrawLine(3584, 0, 3584, Yrange_upper);
4443     }
4444   }
4445 
4446   TText PrintRun;
4447   PrintRun.SetTextFont(62);
4448   PrintRun.SetTextSize(0.04);
4449   PrintRun.SetNDC();          // set to normalized coordinates
4450   PrintRun.SetTextAlign(23);  // center/top alignment
4451   std::ostringstream runnostream;
4452   std::string runstring;
4453   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
4454   // fill run number and event time into string
4455   runnostream << ThisName << "_Counts of ADC-Ped. > 300, t < 360 Run " << cl->RunNumber()
4456               << ", Time: " << ctime(&evttime.first);
4457   runstring = runnostream.str();
4458   TransparentTPad->cd();
4459   PrintRun.SetTextColor(evttime.second);
4460   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
4461 
4462   MyTC->Update();
4463   MyTC->Show();
4464   MyTC->SetEditable(false);
4465 
4466   return 0;
4467 }
4468 
4469 int TpcMonDraw::DrawShifterTransmissionDist(const std::string & /* what */)
4470 {
4471   OnlMonClient *cl = OnlMonClient::instance();
4472 
4473   // TH1F *tpcmon_back[24][3] = {nullptr};
4474   //  TH1F *tpcmon_drift[24][3] = {nullptr};
4475 
4476   TH1 *tpcmon_Drift[24][3] = {nullptr};
4477   TH1 *tpcmon_Drift_u[48][3] = {nullptr};
4478   // TH1 *tpcmoneventsebdc[24] = {nullptr};
4479 
4480   TH1F *PERCENT = new TH1F("PERCENT", "TPC PERCENT TRANSMISSION; % Transmission; Counts", 124, -1.5, 251.5);
4481 
4482   TF1 *exxy = new TF1("exxy", "[0]*exp(x*[1])", 0, 500);
4483 
4484   char TPCMON_STR[100];
4485 
4486   for (int i = 0; i < 48; i++)
4487   {
4488     sprintf(TPCMON_STR, "TPCMON_%i", i);
4489     // tpcmoneventsebdc[i] = (TH1*) cl->getHisto(TPCMON_STR,"NEvents_vs_EBDC");
4490     for (int j = 0; j < 3; j++)
4491     {
4492       tpcmon_Drift_u[i][0] = (TH1F *) cl->getHisto(TPCMON_STR, "COUNTS_vs_SAMPLE_1D_R1");
4493       tpcmon_Drift_u[i][1] = (TH1F *) cl->getHisto(TPCMON_STR, "COUNTS_vs_SAMPLE_1D_R2");
4494       tpcmon_Drift_u[i][2] = (TH1F *) cl->getHisto(TPCMON_STR, "COUNTS_vs_SAMPLE_1D_R3");
4495 
4496       /*
4497       sprintf(DRIFT_CLONE_STR,"drift_sec_%i_R%i",i,j+1);
4498 
4499       tpcmon_DriftBackground[i][j] = (TH1F*)tpcmon_back[i][j]->Clone(BACK_CLONE_STR);
4500       tpcmon_DriftNorm[i][j] = (TH1F*)tpcmon_back[i][j]->Clone(DRIFT_CLONE_STR);
4501       */
4502     }
4503   }
4504 
4505   add_TH1_modules(tpcmon_Drift_u, tpcmon_Drift);
4506 
4507   if (!gROOT->FindObject("ShifterTPCTransmissionDist"))
4508   {
4509     MakeCanvas("ShifterTPCTransmissionDist");
4510   }
4511 
4512   TCanvas *MyTC = TC[36];
4513   TPad *TransparentTPad = transparent[36];
4514   MyTC->SetEditable(true);
4515   MyTC->Clear("D");
4516 
4517   // left = 34, right = 350 for new firmware with laser around 380 samples
4518   int left = 35;
4519   int right = 350;
4520 
4521   // gStyle->SetOptStat(0);
4522   // gStyle->SetPalette(57); //kBird CVD friendly
4523 
4524   char norm_str[100];
4525   char back_str[100];
4526 
4527   for (int sector = 0; sector < 24; sector++)
4528   {
4529     for (int rad = 0; rad < 3; rad++)
4530     {
4531       if ((!tpcmon_Drift[sector][rad] || tpcmon_Drift[sector][rad]->GetEntries() < 20000))
4532       {
4533         continue;
4534       }  // if doesn't exist move on
4535       // first zero the drift signal out of the background spectra
4536       sprintf(norm_str, "norm_sec_%i_r%i", sector, rad + 1);
4537       sprintf(back_str, "back_sec_%i_r%i", sector, rad + 1);
4538 
4539       TH1F *current_norm = (TH1F *) tpcmon_Drift[sector][rad]->Clone(norm_str);
4540       current_norm->GetXaxis()->SetRangeUser(0, 500);
4541       TH1F *back_norm = (TH1F *) tpcmon_Drift[sector][rad]->Clone(back_str);
4542       back_norm->GetXaxis()->SetRangeUser(0, 500);
4543 
4544       for (int bin = left; bin <= right; bin++)
4545       {
4546         back_norm->SetBinContent(bin, 0.0);
4547       }
4548       //  second zero the laser signal out of the background spectra.
4549       for (int bin = 367; bin <= 376; bin++)
4550       {
4551         back_norm->SetBinContent(bin, 0.0);
4552       }
4553 
4554       // Now Fit a function to each background and divide...
4555       exxy->SetParameter(0, back_norm->GetBinContent(2));
4556       exxy->SetParameter(1, 0);
4557       back_norm->Fit(exxy, "QW");
4558       current_norm->Divide(back_norm->GetFunction("exxy"));
4559       //  Subtract the "1" offset and set the minimum to -0.2...
4560       for (int bin = 1; bin <= current_norm->GetNbinsX(); bin++)
4561       {
4562         current_norm->SetBinContent(bin, std::max(-0.2, current_norm->GetBinContent(bin) - 1.0));
4563       }
4564 
4565       if (current_norm->GetBinContent(75) > 0)
4566       {
4567         exxy->SetParameter(0, current_norm->GetBinContent(75));
4568         exxy->SetParameter(1, 0);
4569         current_norm->Fit(exxy, "QW", "", 75, 275);
4570         double one = current_norm->GetFunction("exxy")->GetParameter(1);
4571         double percent = 100.0 * exp(one * (275 - 75));
4572         PERCENT->Fill(percent);
4573       }
4574     }
4575   }
4576 
4577   MyTC->Clear("D");
4578 
4579   TText PrintRun;
4580   PrintRun.SetTextFont(62);
4581   PrintRun.SetTextSize(0.04);
4582   PrintRun.SetNDC();          // set to normalized coordinates
4583   PrintRun.SetTextAlign(23);  // center/top alignment
4584   std::ostringstream runnostream;
4585   std::string runstring;
4586   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
4587   // fill run number and event time into string
4588   runnostream << ThisName << " Run " << cl->RunNumber()
4589               << ", Time: " << ctime(&evttime.first);
4590   runstring = runnostream.str();
4591   TransparentTPad->cd();
4592   PrintRun.SetTextColor(evttime.second);
4593   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
4594 
4595   TLine *t1 = new TLine();
4596   t1->SetLineWidth(4);
4597   t1->SetLineColor(kBlack);
4598   TLine *t2 = new TLine();
4599   t2->SetLineWidth(2);
4600   t2->SetLineStyle(10);
4601   t2->SetLineColor(kRed);
4602 
4603   MyTC->cd(1);
4604   gPad->SetTopMargin(0.15);
4605   PERCENT->DrawCopy("hist");
4606   if (PERCENT->GetEntries() > 36)
4607   {
4608     PERCENT->Fit("gaus");
4609     if (PERCENT->GetFunction("gaus") != nullptr)
4610     {
4611     t2->DrawLine(PERCENT->GetFunction("gaus")->GetParameter(1), 0, PERCENT->GetFunction("gaus")->GetParameter(1), 1.05 * PERCENT->GetMaximum());
4612     }
4613   }
4614   t1->DrawLine(70, 0, 70, 1.05 * PERCENT->GetMaximum());
4615 
4616   MyTC->Update();
4617   MyTC->Show();
4618   MyTC->SetEditable(false);
4619 
4620   return 0;
4621 }
4622 
4623 int TpcMonDraw::DrawDCvsSAMPA(const std::string & /* what */)
4624 {
4625   OnlMonClient *cl = OnlMonClient::instance();
4626 
4627   TH2 *tpcmon_dc_vs_sampa_plots[24] = {nullptr};
4628 
4629   TH2 *tpcmon_dc_vs_sampa_plots_u[48] = {nullptr};
4630 
4631   char TPCMON_STR[100];
4632   for (int i = 0; i < 48; i++)
4633   {
4634     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
4635     sprintf(TPCMON_STR, "TPCMON_%i", i);
4636     tpcmon_dc_vs_sampa_plots_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "DC_vs_SAMPA");
4637   }
4638 
4639   add_TH2(tpcmon_dc_vs_sampa_plots_u, tpcmon_dc_vs_sampa_plots);
4640 
4641   if (!gROOT->FindObject("DC_vs_SAMPA_CANVAS"))
4642   {
4643     MakeCanvas("DC_vs_SAMPA_CANVAS");
4644   }
4645 
4646   TCanvas *MyTC = TC[37];
4647   TPad *TransparentTPad = transparent[37];
4648 
4649   // Add lines and text annotations
4650   TLine *t1 = new TLine();
4651   t1->SetLineWidth(2);
4652   TLine *t2 = new TLine();
4653   t2->SetLineStyle(2);
4654   TText *tt1 = new TText();
4655   tt1->SetTextSize(0.05);
4656 
4657   int FEEid[26] = {
4658       2, 4, 3, 13, 17, 16,                       // R1
4659       11, 12, 19, 18, 0, 1, 15, 14,              // R2
4660       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
4661   };
4662   char title[32];
4663 
4664   MyTC->SetEditable(true);
4665   MyTC->Clear("D");
4666   for (int i = 0; i < 24; i++)
4667   {
4668     if (tpcmon_dc_vs_sampa_plots[i])
4669     {
4670       MyTC->cd(i + 5);
4671       gPad->SetLogz();
4672       gStyle->SetPadLeftMargin(0.05);
4673       gStyle->SetPadRightMargin(0.02);
4674 
4675       tpcmon_dc_vs_sampa_plots[i]->SetStats(kFALSE);
4676       tpcmon_dc_vs_sampa_plots[i]->DrawCopy("COLZ");
4677 
4678       MyTC->Update();
4679 
4680       for (int j = 0; j < 25; j++)
4681       {
4682         t2->DrawLine((j + 1) * 8, -9000.01, (j + 1) * 8, 50240);
4683       }
4684       for (int k = 0; k < 26; k++)
4685       {
4686         sprintf(title, "%d", FEEid[k]);
4687         if (FEEid[k] > 9)
4688           tt1->DrawText(k * 8, -4000, title);
4689         else
4690           tt1->DrawText(k * 8 + 2, -4000, title);
4691       }
4692       tt1->SetTextSize(0.06);
4693       tt1->DrawText(25, -8000, "R1");
4694       tt1->DrawText(77, -8000, "R2");
4695       tt1->DrawText(163, -8000, "R3");
4696       tt1->SetTextSize(0.05);
4697 
4698       t1->DrawLine(48, -9000.01, 48, 50240);
4699       t1->DrawLine(112, -9000.01, 112, 50240);
4700     }
4701   }
4702 
4703   TText PrintRun;
4704   PrintRun.SetTextFont(62);
4705   PrintRun.SetTextSize(0.04);
4706   PrintRun.SetNDC();          // set to normalized coordinates
4707   PrintRun.SetTextAlign(23);  // center/top alignment
4708   std::ostringstream runnostream;
4709   std::string runstring;
4710   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
4711   // fill run number and event time into string
4712   runnostream << ThisName << "_DC_vs_SAMPA Run " << cl->RunNumber()
4713               << ", Time: " << ctime(&evttime.first);
4714   runstring = runnostream.str();
4715   TransparentTPad->cd();
4716   PrintRun.SetTextColor(evttime.second);
4717   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
4718 
4719   MyTC->Update();
4720   MyTC->Show();
4721   MyTC->SetEditable(false);
4722 
4723   return 0;
4724 }
4725 
4726 int TpcMonDraw::DrawDCSAMPAvsTIME(const std::string & /* what */)
4727 {
4728   OnlMonClient *cl = OnlMonClient::instance();
4729 
4730   TH2 *tpcmon_dc_sampa_vs_time_plots[24] = {nullptr};
4731 
4732   TH2 *tpcmon_dc_sampa_vs_time_plots_u[48] = {nullptr};
4733 
4734   char TPCMON_STR[100];
4735   for (int i = 0; i < 48; i++)
4736   {
4737     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
4738     sprintf(TPCMON_STR, "TPCMON_%i", i);
4739     tpcmon_dc_sampa_vs_time_plots_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "DC_SAMPA_vs_TIME");
4740   }
4741 
4742   add_TH2(tpcmon_dc_sampa_vs_time_plots_u, tpcmon_dc_sampa_vs_time_plots);
4743 
4744   if (!gROOT->FindObject("DC_SAMPA_vs_TIME_CANVAS"))
4745   {
4746     MakeCanvas("DC_SAMPA_vs_TIME_CANVAS");
4747   }
4748 
4749   TCanvas *MyTC = TC[38];
4750   TPad *TransparentTPad = transparent[38];
4751 
4752   // Draw vertical lines and labels
4753   TLine *t1 = new TLine();
4754   t1->SetLineWidth(2);
4755   TLine *t2 = new TLine();
4756   t2->SetLineStyle(2);
4757   TText *tt1 = new TText();
4758   tt1->SetTextSize(0.05);
4759   TText *tt2 = new TText();
4760   tt2->SetTextSize(0.025);  // fee labels
4761 
4762   int FEEid[26] = {
4763       2, 4, 3, 13, 17, 16,                       // R1
4764       11, 12, 19, 18, 0, 1, 15, 14,              // R2
4765       20, 22, 21, 23, 25, 24, 10, 9, 8, 6, 7, 5  // R3
4766   };
4767   char title[32];
4768 
4769   MyTC->SetEditable(true);
4770   MyTC->Clear("D");
4771   for (int i = 0; i < 24; i++)
4772   {
4773     if (tpcmon_dc_sampa_vs_time_plots[i])
4774     {
4775       MyTC->cd(i + 5);
4776       gPad->SetLogz();
4777       gStyle->SetPadLeftMargin(0.05);
4778       gStyle->SetPadRightMargin(0.02);
4779 
4780       tpcmon_dc_sampa_vs_time_plots[i]->SetStats(kFALSE);
4781       tpcmon_dc_sampa_vs_time_plots[i]->DrawCopy("COLZ");
4782 
4783       MyTC->Update();
4784 
4785       for (int j = 0; j < 25; j++)
4786       {
4787         t2->DrawLine(-659999, (j + 1) * 8, 1200000.5, (j + 1) * 8);  // rollover
4788         // t2->DrawLine( -49499999, (j+1)*8, 150000000.5, (j+1)*8); //no rollover
4789       }
4790       // FEE ID labels
4791       for (int k = 0; k < 26; k++)
4792       {
4793         sprintf(title, "%d", FEEid[k]);
4794         if (FEEid[k] > 9)
4795         {
4796           tt2->DrawText(-250000, k * 8 + 2, title);
4797         }  // rollover
4798         else
4799         {
4800           tt2->DrawText(-250000, k * 8 + 2, title);
4801         }  // rollover
4802         // if(FEEid[k] >9){tt2->DrawText(-17040000,k*8+2, title);} //no rollover
4803         // else {tt2->DrawText(-17040000,k*8 + 2,title);} //no rollover
4804       }
4805       // Region labels
4806       tt1->SetTextSize(0.06);
4807       tt1->DrawText(-550000, 25, "R1");   // rollover
4808       tt1->DrawText(-550000, 77, "R2");   // rollover
4809       tt1->DrawText(-550000, 163, "R3");  // rollover
4810       // tt1->DrawText(-41250000,25, "R1"); //no rollover
4811       // tt1->DrawText(-41250000,77, "R2"); //no rollover
4812       // tt1->DrawText(-41250000,163, "R3"); // no rollover
4813       tt1->SetTextSize(0.05);
4814 
4815       // Solid region boundary lines
4816       t1->DrawLine(-659999, 48, 1200000.5, 48);    // rollover
4817       t1->DrawLine(-659999, 112, 1200000.5, 112);  // rollover
4818       // t1->DrawLine( -49499999,48,150000000.5,48); // no rollover
4819       // t1->DrawLine( -49499999,112,150000000.5,112); // no rollover
4820     }
4821   }
4822 
4823   TText PrintRun;
4824   PrintRun.SetTextFont(62);
4825   PrintRun.SetTextSize(0.04);
4826   PrintRun.SetNDC();          // set to normalized coordinates
4827   PrintRun.SetTextAlign(23);  // center/top alignment
4828   std::ostringstream runnostream;
4829   std::string runstring;
4830   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
4831   // fill run number and event time into string
4832   runnostream << ThisName << "_DC_SAMPA_vs_TIME Run " << cl->RunNumber()
4833               << ", Time: " << ctime(&evttime.first);
4834   runstring = runnostream.str();
4835   TransparentTPad->cd();
4836   PrintRun.SetTextColor(evttime.second);
4837   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
4838 
4839   MyTC->Update();
4840   MyTC->Show();
4841   MyTC->SetEditable(false);
4842 
4843   return 0;
4844 }
4845 
4846 int TpcMonDraw::DrawTPCPACKETTYPEvsSAMPLEADC(const std::string & /* what */)
4847 {
4848   OnlMonClient *cl = OnlMonClient::instance();
4849 
4850   TH2 *tpcmon_PacketType_vs_Sample_ADC[24] = {nullptr};
4851   TH2 *tpcmon_PacketType_vs_Sample_ADC_u[48] = {nullptr};
4852 
4853   char TPCMON_STR[100];
4854   for (int i = 0; i < 48; i++)
4855   {
4856     // const TString TPCMON_STR( Form( "TPCMON_%i", i ) );
4857     sprintf(TPCMON_STR, "TPCMON_%i", i);
4858     tpcmon_PacketType_vs_Sample_ADC_u[i] = (TH2 *) cl->getHisto(TPCMON_STR, "Packet_Type_vs_sample_ADC");
4859   }
4860 
4861   add_TH2(tpcmon_PacketType_vs_Sample_ADC_u, tpcmon_PacketType_vs_Sample_ADC);
4862 
4863   if (!gROOT->FindObject("TPCPACKETTYPE_vs_SAMPLE_ADC"))
4864   {
4865     MakeCanvas("TPCPACKETTYPE_vs_SAMPLE_ADC");
4866   }
4867 
4868   TCanvas *MyTC = TC[39];
4869   TPad *TransparentTPad = transparent[39];
4870   MyTC->SetEditable(true);
4871   MyTC->Clear("D");
4872 
4873   gStyle->SetOptStat(0);
4874   gStyle->SetPalette(57);  // kBird CVD friendly
4875 
4876   for (int i = 0; i < 24; i++)
4877   {
4878     if (tpcmon_PacketType_vs_Sample_ADC[i])
4879     {
4880       MyTC->cd(i + 5);
4881       tpcmon_PacketType_vs_Sample_ADC[i]->SetStats(0);
4882       tpcmon_PacketType_vs_Sample_ADC[i]->DrawCopy("COLZ");
4883     }
4884     gPad->Update();
4885   }
4886 
4887   TText PrintRun;
4888   PrintRun.SetTextFont(62);
4889   PrintRun.SetTextSize(0.04);
4890   PrintRun.SetNDC();          // set to normalized coordinates
4891   PrintRun.SetTextAlign(23);  // center/top alignment
4892   std::ostringstream runnostream;
4893   std::string runstring;
4894   std::pair<time_t, int> evttime = cl->EventTime("CURRENT");
4895   // fill run number and event time into string
4896   runnostream << ThisName << "_PACKET TYPE vs SAMPLE wtd. by ADC Run " << cl->RunNumber()
4897               << ", Time: " << ctime(&evttime.first);
4898   runstring = runnostream.str();
4899   TransparentTPad->cd();
4900   PrintRun.SetTextColor(evttime.second);
4901   PrintRun.DrawText(0.5, 0.91, runstring.c_str());
4902 
4903   MyTC->Update();
4904   MyTC->Show();
4905   MyTC->SetEditable(false);
4906 
4907   return 0;
4908 }
4909 
4910 int TpcMonDraw::SavePlot(const std::string &what, const std::string &type)
4911 {
4912   OnlMonClient *cl = OnlMonClient::instance();
4913   int iret = Draw(what);
4914   if (iret)  // on error no png files please
4915   {
4916     return iret;
4917   }
4918   int icnt = 0;
4919   for (TCanvas *canvas : TC)
4920   {
4921     if (canvas == nullptr)
4922     {
4923       continue;
4924     }
4925     icnt++;
4926     std::string filename = ThisName + "_" + std::to_string(icnt) + "_" +
4927                            std::to_string(cl->RunNumber()) + "." + type;
4928     cl->CanvasToPng(canvas, filename);
4929   }
4930   return 0;
4931 }
4932 
4933 int TpcMonDraw::MakeHtml(const std::string &what)
4934 {
4935   int iret = Draw(what);
4936   if (iret)  // on error no html output please
4937   {
4938     return iret;
4939   }
4940 
4941   OnlMonClient *cl = OnlMonClient::instance();
4942 
4943   int icnt = 0;
4944   for (TCanvas *canvas : TC)
4945   {
4946     if (canvas == nullptr)
4947     {
4948       continue;
4949     }
4950     icnt++;
4951     // Register the canvas png file to the menu and produces the png file.
4952     std::string pngfile = cl->htmlRegisterPage(*this, canvas->GetTitle(), std::to_string(icnt), "png");
4953     cl->CanvasToPng(canvas, pngfile);
4954   }
4955   // Now register also EXPERTS html pages, under the EXPERTS subfolder.
4956 
4957   // std::string logfile = cl->htmlRegisterPage(*this, "EXPERTS/Log", "log", "html");
4958   // std::ofstream out(logfile.c_str());
4959   // out << "<HTML><HEAD><TITLE>Log file for run " << cl->RunNumber()
4960   //     << "</TITLE></HEAD>" << std::endl;
4961   // out << "<P>Some log file output would go here." << std::endl;
4962   // out.close();
4963 
4964   // std::string status = cl->htmlRegisterPage(*this, "EXPERTS/Status", "status", "html");
4965   // std::ofstream out2(status.c_str());
4966   // out2 << "<HTML><HEAD><TITLE>Status file for run " << cl->RunNumber()
4967   //      << "</TITLE></HEAD>" << std::endl;
4968   // out2 << "<P>Some status output would go here." << std::endl;
4969   // out2.close();
4970   // cl->SaveLogFile(*this);
4971   return 0;
4972 }
4973 
4974 time_t TpcMonDraw::getTime()
4975 {
4976   OnlMonClient *cl = OnlMonClient::instance();
4977   time_t currtime = 0;
4978   int i = 0;
4979   while (currtime == 0 && i <= 23)
4980   {
4981     std::string servername = "TPCMON_" + std::to_string(i);
4982     currtime = cl->EventTime(servername, "CURRENT");
4983     i++;
4984   }
4985   return currtime;
4986 }
4987 
4988 int TpcMonDraw::DrawServerStats()
4989 {
4990   OnlMonClient *cl = OnlMonClient::instance();
4991   if (!gROOT->FindObject("TpcMonServerStats"))
4992   {
4993     MakeCanvas("TpcMonServerStats");
4994   }
4995   TCanvas *MyTC = TC[20];
4996   TPad *TransparentTPad = transparent[20];
4997 
4998   MyTC->Clear("D");
4999   MyTC->SetEditable(true);
5000   TransparentTPad->cd();
5001   TText PrintRun;
5002   PrintRun.SetTextFont(62);
5003   PrintRun.SetNDC();          // set to normalized coordinates
5004   PrintRun.SetTextAlign(23);  // center/top alignment
5005   PrintRun.SetTextSize(0.04);
5006   PrintRun.SetTextColor(1);
5007   PrintRun.DrawText(0.5, 0.99, "Server Statistics");
5008 
5009   PrintRun.SetTextAlign(13);  // left/top alignment
5010   PrintRun.SetTextSize(0.02);
5011   double vdist = 0.03;
5012   double vstart = 0.9;
5013   double vpos = vstart;
5014   double hpos = 0.01;
5015   int i = 0;
5016   int numservers = m_ServerSet.size();
5017   std::vector<std::string> ServerVector;
5018   for (const auto &server : m_ServerSet)
5019   {
5020     if (server.size() <= 8)
5021     {
5022       ServerVector.push_back(server);
5023     }
5024   }
5025   for (const auto &server : m_ServerSet)
5026   {
5027     if (server.size() > 8)
5028     {
5029       ServerVector.push_back(server);
5030     }
5031   }
5032   for (const auto &server : ServerVector)
5033   {
5034     std::ostringstream txt;
5035     auto servermapiter = cl->GetServerMap(server);
5036     if (servermapiter == cl->GetServerMapEnd())
5037     {
5038       txt << "Server " << server
5039           << " is dead ";
5040       PrintRun.SetTextColor(kRed);
5041     }
5042     else
5043     {
5044       txt << "Server " << server
5045           << ", run:" << std::get<1>(servermapiter->second)
5046           << ", events: " << std::get<2>(servermapiter->second)
5047           << ", time: " << ctime(&(std::get<3>(servermapiter->second)));
5048       if (std::get<0>(servermapiter->second))
5049       {
5050         PrintRun.SetTextColor(kGray + 2);
5051       }
5052       else
5053       {
5054         PrintRun.SetTextColor(kRed);
5055       }
5056     }
5057     if (i >= numservers / 2)
5058     {
5059       hpos = 0.5;
5060       vpos = vstart;
5061       i = 0;
5062     }
5063     PrintRun.DrawText(hpos, vpos, txt.str().c_str());
5064     vpos -= vdist;
5065     i++;
5066   }
5067   MyTC->Update();
5068   MyTC->Show();
5069   MyTC->SetEditable(false);
5070 
5071   return 0;
5072 }
5073 
5074 void TpcMonDraw::add_TH1(TH1 *hist[48], TH1 *histadd[24])
5075 {
5076   for (int i = 0; i < 24; ++i)
5077   {
5078     // Clone hist[i] to preserve binning, axis labels, etc.
5079     // char name_str[256];
5080     // sprintf(name_str,"%s",hist[i]->GetName());
5081     if (!hist[i] && !hist[i + 24])
5082     {
5083       continue;
5084     }
5085     if (hist[i] && !hist[i + 24])
5086     {
5087       histadd[i] = (TH1 *) hist[i]->Clone(Form("histadd_%d", i));
5088     }
5089     if (!hist[i] && hist[i + 24])
5090     {
5091       histadd[i] = (TH1 *) hist[i + 24]->Clone(Form("histadd_%d", i));
5092     }
5093     if (hist[i] && hist[i + 24])
5094     {
5095       histadd[i] = (TH1 *) hist[i]->Clone(Form("histadd_%d", i));
5096       histadd[i]->Add(hist[i + 24]);
5097     }
5098   }
5099 }
5100 
5101 void TpcMonDraw::add_TH2(TH2 *hist[48], TH2 *histadd[24])
5102 {
5103   for (int i = 0; i < 24; ++i)
5104   {
5105     // Clone hist[i] to preserve binning, axis labels, etc.
5106     // char name_str[256];
5107     // sprintf(name_str,"%s",hist[i]->GetName());
5108     if (!hist[i] && !hist[i + 24])
5109     {
5110       continue;
5111     }
5112     if (hist[i] && !hist[i + 24])
5113     {
5114       histadd[i] = (TH2 *) hist[i]->Clone(Form("histadd_%d", i));
5115     }
5116     if (!hist[i] && hist[i + 24])
5117     {
5118       histadd[i] = (TH2 *) hist[i + 24]->Clone(Form("histadd_%d", i));
5119     }
5120     if (hist[i] && hist[i + 24])
5121     {
5122       histadd[i] = (TH2 *) hist[i]->Clone(Form("histadd_%d", i));
5123       histadd[i]->Add(hist[i + 24]);
5124     }
5125   }
5126 }
5127 
5128 void TpcMonDraw::add_TH1_modules(TH1 *hist[48][3], TH1 *histadd[24][3])
5129 {
5130   for (int i = 0; i < 24; ++i)
5131   {
5132     for (int j = 0; j < 3; ++j)
5133     {
5134       // Clone hist[i] to preserve binning, axis labels, etc.
5135       // char name_str[256];
5136       // sprintf(name_str,"%s",hist[i]->GetName());
5137       if (!hist[i][j] && !hist[i + 24][j])
5138       {
5139         continue;
5140       }
5141       if (hist[i][j] && !hist[i + 24][j])
5142       {
5143         histadd[i][j] = (TH1 *) hist[i][j]->Clone(Form("histadd_%d_%d", i, j));
5144       }
5145       if (!hist[i][j] && hist[i + 24][j])
5146       {
5147         histadd[i][j] = (TH1 *) hist[i + 24][j]->Clone(Form("histadd_%d_%d", i, j));
5148       }
5149       if (hist[i][j] && hist[i + 24][j])
5150       {
5151         histadd[i][j] = (TH1 *) hist[i][j]->Clone(Form("histadd_%d_%d", i, j));
5152         histadd[i][j]->Add(hist[i + 24][j]);
5153       }
5154     }
5155   }
5156 }
5157 
5158 void TpcMonDraw::add_TH2_modules(TH2 *hist[48][3], TH2 *histadd[24][3])
5159 {
5160   for (int i = 0; i < 24; ++i)
5161   {
5162     for (int j = 0; j < 3; ++j)
5163     {
5164       // Clone hist[i] to preserve binning, axis labels, etc.
5165       // char name_str[256];
5166       // sprintf(name_str,"%s",hist[i]->GetName());
5167       if (!hist[i][j] && !hist[i + 24][j])
5168       {
5169         continue;
5170       }
5171       if (hist[i][j] && !hist[i + 24][j])
5172       {
5173         histadd[i][j] = (TH2 *) hist[i][j]->Clone(Form("histadd_%d_%d", i, j));
5174       }
5175       if (!hist[i][j] && hist[i + 24][j])
5176       {
5177         histadd[i][j] = (TH2 *) hist[i + 24][j]->Clone(Form("histadd_%d_%d", i, j));
5178       }
5179       if (hist[i][j] && hist[i + 24][j])
5180       {
5181         histadd[i][j] = (TH2 *) hist[i][j]->Clone(Form("histadd_%d_%d", i, j));
5182         histadd[i][j]->Add(hist[i + 24][j]);
5183       }
5184     }
5185   }
5186 }