Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:46

0001 // How to run:
0002 //root -b -q -l RemoteMonitoringGLOBAL.C+
0003 //root -b -q -l 'RemoteMonitoringGLOBAL.C+("/afs/cern.ch/cms/CAF/CMSALCA/ALCA_HCALCALIB/HCALMONITORING/CMTweb/histos/Global_190707.root")'
0004 
0005 #include "LogEleMapdb.h"
0006 
0007 #include <iostream>
0008 #include <fstream>
0009 
0010 #include "TH1.h"
0011 #include "TH2.h"
0012 #include "TCanvas.h"
0013 #include "TROOT.h"
0014 #include <TMath.h>
0015 #include "TStyle.h"
0016 #include "TSystem.h"
0017 #include "TLegend.h"
0018 #include "TText.h"
0019 #include "TAxis.h"
0020 #include "TFile.h"
0021 #include "TLine.h"
0022 #include "TGraph.h"
0023 #include <THStack.h>
0024 #include <TPaveText.h>
0025 
0026 using namespace std;
0027 //inline void HERE(const char *msg) { std::cout << msg << std::endl; }    kfitq
0028 int copyContents(TH1F **hDest, TString hname, TString htitle, const TH1F *hSrc, int lastBin);
0029 
0030 // -----------------------------------------------------
0031 
0032 int main(int argc, char *argv[]) {
0033   gROOT->Reset();
0034   gROOT->SetStyle("Plain");
0035   gStyle->SetOptStat(0);
0036   gStyle->SetOptTitle(1);
0037 
0038   if (argc < 1)
0039     return 1;
0040   char fname[300];
0041   sprintf(fname, "%s", argv[1]);
0042   std::cout << fname << std::endl;
0043 
0044   //======================================================================
0045   // Connect the input files, parameters and get the 2-d histogram in memory
0046   //    TFile *hfile= new TFile("GlobalHist.root", "READ");
0047   string promt = (string)fname;
0048   string runnumber = "";
0049   for (unsigned int i = promt.size() - 11; i < promt.size() - 5; i++)
0050     runnumber += fname[i];
0051 
0052   TFile *hfile = new TFile(fname, "READ");
0053   // Cut [test][sub][depth]
0054   //                              Empty                         HB                           HE                                                     HO                          HF
0055   double Cut0[7][5][8] = {
0056       {{0., 0., 0., 0., 0., 0., 0., 0.},
0057        {0., 1.0, 1.0, 0., 0., 0., 0., 0.},
0058        {0., 1., 1., 1., 0., 0., 0., 0.},
0059        {0., 0., 0., 0., 1., 0., 0., 0.},
0060        {0., 1., 1., 0., 0., 0., 0., 0.}},  //CapID  0,HB,HE,HO,HF
0061       //      {{0.,0.,0.,0.,0.,0.,0.,0.}, {0.,35.,35.,0.,0.,0.,0.,0.}, {0.,100.,140.,150.,0.,0.,0.,0.},                         {0.,0.,0.,0.,100.,0.,0.,0.}, {0.,170.,110.,170.,110.,0.,0.,0.} },  //Amplitude  0,HB,HE,HO,HF
0062       {{0., 0., 0., 0., 0., 0., 0., 0.},
0063        {0., 35., 35., 0., 0., 0., 0., 0.},
0064        {0., 12000., 4500., 3500., 3500., 4000., 4500., 5500.},
0065        {0., 0., 0., 0., 200., 0., 0., 0.},
0066        {0., 4500., 4500., 4500., 4500., 0., 0., 0.}},  //Amplitude  0,HB,HE,HO,HF
0067       {{0., 0., 0., 0., 0., 0., 0., 0.},
0068        {0., 3., 3., 0., 0., 0., 0., 0.},
0069        {0., 3., 3., 3., 0., 0., 0., 0.},
0070        {0., 0., 0., 0., 3., 0., 0., 0.},
0071        {0., 2., 2., 0., 0., 0., 0., 0.}},  //Width  0,HB,HE,HO,HF
0072       {{0., 0., 0., 0., 0., 0., 0., 0.},
0073        {0., 0.4, 0.4, 0., 0., 0., 0., 0.},
0074        {0., 0.4, 0.4, 0.4, 0., 0., 0., 0.},
0075        {0., 0., 0., 0., 0.4, 0., 0., 0.},
0076        {0., 0.8, 0.8, 0., 0., 0., 0., 0.}},  //Ratio  0,HB,HE,HO,HF
0077       {{0., 0., 0., 0., 0., 0., 0., 0.},
0078        {0., 4.7, 4.7, 0., 0., 0., 0., 0.},
0079        {0., 4.8, 4.8, 5.0, 0., 0., 0., 0.},
0080        {0., 0., 0., 0., 4.8, 0., 0., 0.},
0081        {0., 4.0, 4.0, 0., 0., 0., 0., 0.}},  //TSn  0,HB,HE,HO,HF
0082       {{0., 0., 0., 0., 0., 0., 0., 0.},
0083        {0., 3.5, 3.5, 0., 0., 0., 0., 0.},
0084        {0., 4.0, 4.0, 4.0, 0., 0., 0., 0.},
0085        {0., 0., 0., 0., 3., 0., 0., 0.},
0086        {0., 3.5, 3.5, 0., 0., 0., 0., 0.}},  //TSx  0,HB,HE,HO,HF
0087       {{0., 0., 0., 0., 0., 0., 0., 0.},
0088        {0., 0., 0., 0., 0., 0., 0., 0.},
0089        {0., 0., 0., 0., 0., 0., 0., 0.},
0090        {0., 0., 0., 0., 0., 0., 0., 0.},
0091        {0., 0., 0., 0., 0., 0., 0., 0.}}};  //Empty
0092 
0093   double CutAb[5][8] = {{0., 0., 0., 0., 0., 0., 0., 0.},
0094                         {0., 20., 7., 0., 0., 0., 0., 0.},
0095                         {0., 16., 13., 4., 0., 0., 0., 0.},
0096                         {0., 0., 0., 0., 45., 0., 0., 0.},
0097                         {0., 10., 5., 0., 0., 0., 0., 0.}};  // cut 1 for CapIdErrors 0,HB,HE,HO,HF
0098 
0099   double CutPo[5][8] = {{0., 0., 0., 0., 0., 0., 0., 0.},
0100                         {0., 9., 3., 0., 0., 0., 0., 0.},
0101                         {0., 8., 6., 2., 0., 0., 0., 0.},
0102                         {0., 0., 0., 0., 20., 0., 0., 0.},
0103                         {0., 5., 3., 0., 0., 0., 0., 0.}};  //cut 3 for CapIdErrors (portions) 0,HB,HE,HO,HF
0104 
0105   //======================================================================
0106 
0107   // CUTs FOR IPHI RBX:
0108   int cutA_HB = 100;
0109   int cutA_HE = 6000;
0110   int cutA_HO = 150;
0111   int cutA_HF = 500;
0112   // CUTs FOR IETA RBX:
0113   int cutB_HB = 100;
0114   int cutB_HE = 10000;
0115   int cutB_HO = 150;
0116   int cutB_HF = 500;
0117 
0118   //======================================================================
0119   // Prepare histograms and plot them to .png files
0120   TCanvas *c1 = new TCanvas("c1", "Hcal4test", 200, 10, 700, 900);
0121 
0122   TCanvas *cHB = new TCanvas("cHB", "cHB", 1000, 500);
0123   TCanvas *cHE = new TCanvas("cHE", "cHE", 1500, 500);
0124   TCanvas *cONE = new TCanvas("cONE", "cONE", 500, 500);
0125   TCanvas *cFour = new TCanvas("cFour", "cFour", 1500, 1000);
0126   TCanvas *cFour1 = new TCanvas("cFour1", "cFour1", 1200, 800);
0127   TCanvas *cNine = new TCanvas("cNine", "cNine", 1500, 1500);
0128 
0129   // RBX:
0130   //  TCanvas *c4x6 = new TCanvas("c4x6","c4x6",1500,3000);
0131   TCanvas *c4x6 = new TCanvas("c4x6", "c4x6", 1200, 2400);
0132   //TCanvas *c5x6 = new TCanvas("c5x6","c5x6",2000,3000);
0133   TCanvas *c5x6 = new TCanvas("c5x6", "c5x6", 1500, 2400);
0134   //  TCanvas *cRBX1 = new TCanvas("cRBX1","cRBX1",200,10,1300,1110);
0135   TCanvas *cRBX1 = new TCanvas("cRBX1", "cRBX1", 1200, 1000);
0136   //
0137   //         TCanvas *cRBX31 = new TCanvas("cRBX31","cRBX31",1800,600);
0138   TCanvas *cRBX31 = new TCanvas("cRBX31", "cRBX31", 1860, 600);
0139   //         TCanvas *cRBX31 = new TCanvas("cRBX31","cRBX31",200,10,,1800,600);
0140 
0141   //  char *str = (char*)alloca(10000);
0142 
0143   int k_min[5] = {0, 1, 1, 4, 1};  // minimum depth for each subdet HB HE HO HF
0144 
0145   int k_max[5] = {0, 2, 3, 4, 2};  // maximum depth for each subdet HB HE HO HF
0146   //  int k_maxHFupgrade[5]={0,2,3,4,4}; // maximum depth for each subdet HB HE HO HF
0147   int k_maxHFupgrade[5] = {0, 2, 7, 4, 4};  // maximum depth for each subdet HB HE HO HF
0148 
0149   //+++++++++++++++++++++++++++++
0150   // Lumi iLumi and number of events
0151   //+++++++++++++++++++++++++++++
0152   cHB->Divide(2, 1);
0153   cHB->cd(1);
0154   TH1F *LumLum = (TH1F *)hfile->Get("h_lsnumber_per_eachLS");
0155   int MaxLumDanila = LumLum->GetBinContent(LumLum->GetMaximumBin());  // old variant of Danila
0156   cout << " MaxLumDanila=     " << MaxLumDanila << endl;
0157   gPad->SetGridy();
0158   gPad->SetGridx();
0159   LumLum->SetMarkerStyle(10);
0160   LumLum->SetMarkerSize(0.8);
0161   LumLum->GetYaxis()->SetLabelSize(0.04);
0162   LumLum->SetTitle("Cont. number per LS  \b");
0163   LumLum->SetXTitle("Cont.number \b");
0164   LumLum->SetYTitle("Ls \b");
0165   LumLum->SetMarkerColor(4);
0166   LumLum->SetLineColor(0);
0167   LumLum->SetMinimum(0.8);
0168   LumLum->GetXaxis()->SetRangeUser(0, MaxLumDanila);
0169   LumLum->Draw("Error");
0170 
0171   cHB->cd(2);
0172   TH1F *LumiEv = (TH1F *)hfile->Get("h_nevents_per_eachRealLS");
0173   int MaxLum0 = LumiEv->GetBinContent(LumiEv->GetMaximumBin());
0174   int MaxLum = 0;
0175   for (int i = 1; i <= LumiEv->GetXaxis()->GetNbins(); i++) {
0176     if (LumiEv->GetBinContent(i)) {
0177       MaxLum = i;
0178     }
0179   }
0180   cout << " MaxLum0=     " << MaxLum0 << " MaxLum=     " << MaxLum << endl;
0181 
0182   gPad->SetGridy();
0183   gPad->SetGridx();
0184   gPad->SetLogy();
0185   //            gPad->SetLogx();
0186   LumiEv->GetYaxis()->SetLabelSize(0.04);
0187   LumiEv->SetTitle("Number of events per LS");
0188   LumiEv->SetXTitle("LS");
0189   LumiEv->SetYTitle("Number of events ");
0190   LumiEv->SetMarkerStyle(10);
0191   LumiEv->SetMarkerSize(0.8);
0192   LumiEv->SetMarkerColor(4);
0193   LumiEv->SetLineColor(0);
0194   //      LumiEv->SetMinimum(0.8);
0195   LumiEv->GetXaxis()->SetRangeUser(0, MaxLum);
0196   LumiEv->Draw("Error");
0197 
0198   cHB->Print("LumiEvent.png");
0199   cHB->Clear();
0200 
0201   //=======================================================================================================
0202   // Shape criteria: 1d histogram first definition
0203   //=======================================================================================================
0204   TH1F *H_NumBadChanDepth[7][5][5];  // 1d histogramm for test,subdet, depth
0205 
0206   //+++++++++++++++++++++++++++++
0207   // ADC Amplitude
0208   //+++++++++++++++++++++++++++++
0209 
0210   H_NumBadChanDepth[1][1][1] = (TH1F *)hfile->Get("h_sumADCAmplLS1");
0211   H_NumBadChanDepth[1][1][2] = (TH1F *)hfile->Get("h_sumADCAmplLS2");
0212 
0213   H_NumBadChanDepth[1][2][1] = (TH1F *)hfile->Get("h_sumADCAmplLS3");
0214   H_NumBadChanDepth[1][2][2] = (TH1F *)hfile->Get("h_sumADCAmplLS4");
0215   H_NumBadChanDepth[1][2][3] = (TH1F *)hfile->Get("h_sumADCAmplLS5");
0216 
0217   H_NumBadChanDepth[1][3][4] = (TH1F *)hfile->Get("h_sumADCAmplLS8");
0218 
0219   H_NumBadChanDepth[1][4][1] = (TH1F *)hfile->Get("h_sumADCAmplLS6");
0220   H_NumBadChanDepth[1][4][2] = (TH1F *)hfile->Get("h_sumADCAmplLS7");
0221 
0222   //+++++++++++++++++++++++++++++
0223   // Width
0224   //+++++++++++++++++++++++++++++
0225 
0226   H_NumBadChanDepth[2][1][1] = (TH1F *)hfile->Get("h_sumAmplitudeLS1");
0227   H_NumBadChanDepth[2][1][2] = (TH1F *)hfile->Get("h_sumAmplitudeLS2");
0228 
0229   H_NumBadChanDepth[2][2][1] = (TH1F *)hfile->Get("h_sumAmplitudeLS3");
0230   H_NumBadChanDepth[2][2][2] = (TH1F *)hfile->Get("h_sumAmplitudeLS4");
0231   H_NumBadChanDepth[2][2][3] = (TH1F *)hfile->Get("h_sumAmplitudeLS5");
0232 
0233   H_NumBadChanDepth[2][3][4] = (TH1F *)hfile->Get("h_sumAmplitudeLS8");
0234 
0235   H_NumBadChanDepth[2][4][1] = (TH1F *)hfile->Get("h_sumAmplitudeLS6");
0236   H_NumBadChanDepth[2][4][2] = (TH1F *)hfile->Get("h_sumAmplitudeLS7");
0237 
0238   //+++++++++++++++++++++++++++++
0239   // Ratio
0240   //+++++++++++++++++++++++++++++
0241 
0242   H_NumBadChanDepth[3][1][1] = (TH1F *)hfile->Get("h_sumAmplLS1");
0243   H_NumBadChanDepth[3][1][2] = (TH1F *)hfile->Get("h_sumAmplLS2");
0244 
0245   H_NumBadChanDepth[3][2][1] = (TH1F *)hfile->Get("h_sumAmplLS3");
0246   H_NumBadChanDepth[3][2][2] = (TH1F *)hfile->Get("h_sumAmplLS4");
0247   H_NumBadChanDepth[3][2][3] = (TH1F *)hfile->Get("h_sumAmplLS5");
0248 
0249   H_NumBadChanDepth[3][3][4] = (TH1F *)hfile->Get("h_sumAmplLS8");
0250 
0251   H_NumBadChanDepth[3][4][1] = (TH1F *)hfile->Get("h_sumAmplLS6");
0252   H_NumBadChanDepth[3][4][2] = (TH1F *)hfile->Get("h_sumAmplLS7");
0253 
0254   //+++++++++++++++++++++++++++++
0255   // Tmean
0256   //+++++++++++++++++++++++++++++
0257 
0258   H_NumBadChanDepth[4][1][1] = (TH1F *)hfile->Get("h_sumTSmeanALS1");
0259   H_NumBadChanDepth[4][1][2] = (TH1F *)hfile->Get("h_sumTSmeanALS2");
0260 
0261   H_NumBadChanDepth[4][2][1] = (TH1F *)hfile->Get("h_sumTSmeanALS3");
0262   H_NumBadChanDepth[4][2][2] = (TH1F *)hfile->Get("h_sumTSmeanALS4");
0263   H_NumBadChanDepth[4][2][3] = (TH1F *)hfile->Get("h_sumTSmeanALS5");
0264 
0265   H_NumBadChanDepth[4][3][4] = (TH1F *)hfile->Get("h_sumTSmeanALS8");
0266 
0267   H_NumBadChanDepth[4][4][1] = (TH1F *)hfile->Get("h_sumTSmeanALS6");
0268   H_NumBadChanDepth[4][4][2] = (TH1F *)hfile->Get("h_sumTSmeanALS7");
0269 
0270   //+++++++++++++++++++++++++++++
0271   // Tmax
0272   //+++++++++++++++++++++++++++++
0273 
0274   H_NumBadChanDepth[5][1][1] = (TH1F *)hfile->Get("h_sumTSmaxALS1");
0275   H_NumBadChanDepth[5][1][2] = (TH1F *)hfile->Get("h_sumTSmaxALS2");
0276 
0277   H_NumBadChanDepth[5][2][1] = (TH1F *)hfile->Get("h_sumTSmaxALS3");
0278   H_NumBadChanDepth[5][2][2] = (TH1F *)hfile->Get("h_sumTSmaxALS4");
0279   H_NumBadChanDepth[5][2][3] = (TH1F *)hfile->Get("h_sumTSmaxALS5");
0280 
0281   H_NumBadChanDepth[5][3][4] = (TH1F *)hfile->Get("h_sumTSmaxALS8");
0282 
0283   H_NumBadChanDepth[5][4][1] = (TH1F *)hfile->Get("h_sumTSmaxALS6");
0284   H_NumBadChanDepth[5][4][2] = (TH1F *)hfile->Get("h_sumTSmaxALS7");
0285 
0286   gStyle->SetOptStat(110000);
0287 
0288   for (int test = 1; test <= 5; test++) {  //Test: 0,
0289     for (int sub = 1; sub <= 4; sub++) {   //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
0290       if (sub == 1)
0291         cHB->Divide(2, 1);
0292       if (sub == 2)
0293         cHE->Divide(3, 1);
0294       if (sub == 3)
0295         cONE->Divide(1, 1);
0296       if (sub == 4)
0297         cHB->Divide(2, 1);
0298       for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
0299         if (sub == 1)
0300           cHB->cd(k);
0301         if (sub == 2)
0302           cHE->cd(k);
0303         if (sub == 3)
0304           cONE->cd(k - 3);
0305         if (sub == 4)
0306           cHB->cd(k);
0307         gPad->SetGridy();
0308         gPad->SetGridx();
0309         gPad->SetLogy();
0310         H_NumBadChanDepth[test][sub][k]->SetMarkerStyle(20);
0311         H_NumBadChanDepth[test][sub][k]->SetMarkerSize(0.8);
0312         if (k == 1)
0313           H_NumBadChanDepth[test][sub][k]->SetTitle("Depth 1\b");
0314         if (k == 2)
0315           H_NumBadChanDepth[test][sub][k]->SetTitle("Depth 2\b");
0316         if (k == 3)
0317           H_NumBadChanDepth[test][sub][k]->SetTitle("Depth 3\b");
0318         if (k == 4)
0319           H_NumBadChanDepth[test][sub][k]->SetTitle("Depth 4\b");
0320         if (test == 1)
0321           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <Amplitude> \b");
0322         if (test == 2)
0323           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <Width> \b");
0324         if (test == 3)
0325           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <Ratio> \b");
0326         if (test == 4)
0327           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <TS mean> \b");
0328         if (test == 5)
0329           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <TS max> \b");
0330         H_NumBadChanDepth[test][sub][k]->SetYTitle("Number of channel-LSs\b");
0331         H_NumBadChanDepth[test][sub][k]->SetMarkerColor(4);
0332         H_NumBadChanDepth[test][sub][k]->SetLineColor(0);
0333         //                H_NumBadChanDepth[test][sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
0334         H_NumBadChanDepth[test][sub][k]->SetMinimum(0.8);
0335         H_NumBadChanDepth[test][sub][k]->Draw("Error");
0336       }
0337       if (test == 0) {
0338         if (sub == 1) {
0339           cHB->Print("H_NBCMNHB.png");
0340           cHB->Clear();
0341         }
0342         if (sub == 2) {
0343           cHE->Print("H_NBCMNHE.png");
0344           cHE->Clear();
0345         }
0346         if (sub == 3) {
0347           cONE->Print("H_NBCMNHO.png");
0348           cONE->Clear();
0349         }
0350         if (sub == 4) {
0351           cHB->Print("H_NBCMNHF.png");
0352           cHB->Clear();
0353         }
0354       }
0355 
0356       if (test == 1) {
0357         if (sub == 1) {
0358           cHB->Print("H_ADCamplHB.png");
0359           cHB->Clear();
0360         }
0361         if (sub == 2) {
0362           cHE->Print("H_ADCamplHE.png");
0363           cHE->Clear();
0364         }
0365         if (sub == 3) {
0366           cONE->Print("H_ADCamplHO.png");
0367           cONE->Clear();
0368         }
0369         if (sub == 4) {
0370           cHB->Print("H_ADCamplHF.png");
0371           cHB->Clear();
0372         }
0373       }
0374       if (test == 2) {
0375         if (sub == 1) {
0376           cHB->Print("H_WidthHB.png");
0377           cHB->Clear();
0378         }
0379         if (sub == 2) {
0380           cHE->Print("H_WidthHE.png");
0381           cHE->Clear();
0382         }
0383         if (sub == 3) {
0384           cONE->Print("H_WidthHO.png");
0385           cONE->Clear();
0386         }
0387         if (sub == 4) {
0388           cHB->Print("H_WidthHF.png");
0389           cHB->Clear();
0390         }
0391       }
0392       if (test == 3) {
0393         if (sub == 1) {
0394           cHB->Print("H_RatioHB.png");
0395           cHB->Clear();
0396         }
0397         if (sub == 2) {
0398           cHE->Print("H_RatioHE.png");
0399           cHE->Clear();
0400         }
0401         if (sub == 3) {
0402           cONE->Print("H_RatioHO.png");
0403           cONE->Clear();
0404         }
0405         if (sub == 4) {
0406           cHB->Print("H_RatioHF.png");
0407           cHB->Clear();
0408         }
0409       }
0410       if (test == 4) {
0411         if (sub == 1) {
0412           cHB->Print("H_TmeanHB.png");
0413           cHB->Clear();
0414         }
0415         if (sub == 2) {
0416           cHE->Print("H_TmeanHE.png");
0417           cHE->Clear();
0418         }
0419         if (sub == 3) {
0420           cONE->Print("H_TmeanHO.png");
0421           cONE->Clear();
0422         }
0423         if (sub == 4) {
0424           cHB->Print("H_TmeanHF.png");
0425           cHB->Clear();
0426         }
0427       }
0428       if (test == 5) {
0429         if (sub == 1) {
0430           cHB->Print("H_TmaxHB.png");
0431           cHB->Clear();
0432         }
0433         if (sub == 2) {
0434           cHE->Print("H_TmaxHE.png");
0435           cHE->Clear();
0436         }
0437         if (sub == 3) {
0438           cONE->Print("H_TmaxHO.png");
0439           cONE->Clear();
0440         }
0441         if (sub == 4) {
0442           cHB->Print("H_TmaxHF.png");
0443           cHB->Clear();
0444         }
0445       }
0446     }  // end sub
0447   }    //end test
0448 
0449   gStyle->SetOptStat(0);
0450   //================================================================================================================================
0451 
0452   //=======================================================================================================
0453   // 2-d histograms second definition
0454   //=========================================================
0455   TH2F *MapNumBadChanDepth[7][5][5];  // 1d Mapogramm for test,subdet, depth
0456   TH2F *MapNumChanDepth[7][5][5];     // 1d Mapogramm for test,subdet, depth
0457   TH2F *MapNumBadChanFull[7];         // 1d Mapogramm for test
0458   TH2F *MapNumChanFull[7];            // 1d Mapogramm for test
0459 
0460   //+++++++++++++++++++++++++++++
0461   // CapID
0462   //+++++++++++++++++++++++++++++
0463 
0464   MapNumBadChanDepth[0][1][1] = (TH2F *)hfile->Get("h_mapDepth1Error_HB");
0465   MapNumBadChanDepth[0][1][2] = (TH2F *)hfile->Get("h_mapDepth2Error_HB");
0466 
0467   MapNumBadChanDepth[0][2][1] = (TH2F *)hfile->Get("h_mapDepth1Error_HE");
0468   MapNumBadChanDepth[0][2][2] = (TH2F *)hfile->Get("h_mapDepth2Error_HE");
0469   MapNumBadChanDepth[0][2][3] = (TH2F *)hfile->Get("h_mapDepth3Error_HE");
0470 
0471   MapNumBadChanDepth[0][3][4] = (TH2F *)hfile->Get("h_mapDepth4Error_HO");
0472 
0473   MapNumBadChanDepth[0][4][1] = (TH2F *)hfile->Get("h_mapDepth1Error_HF");
0474   MapNumBadChanDepth[0][4][2] = (TH2F *)hfile->Get("h_mapDepth2Error_HF");
0475 
0476   MapNumBadChanFull[0] = (TH2F *)MapNumBadChanDepth[0][1][1]->Clone();
0477 
0478   MapNumChanDepth[0][1][1] = (TH2F *)hfile->Get("h_mapDepth1_HB");
0479   MapNumChanDepth[0][1][2] = (TH2F *)hfile->Get("h_mapDepth2_HB");
0480 
0481   MapNumChanDepth[0][2][1] = (TH2F *)hfile->Get("h_mapDepth1_HE");
0482   MapNumChanDepth[0][2][2] = (TH2F *)hfile->Get("h_mapDepth2_HE");
0483   MapNumChanDepth[0][2][3] = (TH2F *)hfile->Get("h_mapDepth3_HE");
0484 
0485   MapNumChanDepth[0][3][4] = (TH2F *)hfile->Get("h_mapDepth4_HO");
0486 
0487   MapNumChanDepth[0][4][1] = (TH2F *)hfile->Get("h_mapDepth1_HF");
0488   MapNumChanDepth[0][4][2] = (TH2F *)hfile->Get("h_mapDepth2_HF");
0489 
0490   MapNumChanFull[0] = (TH2F *)MapNumChanDepth[0][1][1]->Clone();
0491 
0492   //+++++++++++++++++++++++++++++
0493   // ADC Amplitude
0494   //+++++++++++++++++++++++++++++
0495 
0496   MapNumBadChanDepth[1][1][1] = (TH2F *)hfile->Get("h_2DsumADCAmplLS1");
0497   MapNumBadChanDepth[1][1][2] = (TH2F *)hfile->Get("h_2DsumADCAmplLS2");
0498 
0499   MapNumBadChanDepth[1][2][1] = (TH2F *)hfile->Get("h_2DsumADCAmplLS3");
0500   MapNumBadChanDepth[1][2][2] = (TH2F *)hfile->Get("h_2DsumADCAmplLS4");
0501   MapNumBadChanDepth[1][2][3] = (TH2F *)hfile->Get("h_2DsumADCAmplLS5");
0502 
0503   MapNumBadChanDepth[1][3][4] = (TH2F *)hfile->Get("h_2DsumADCAmplLS8");
0504 
0505   MapNumBadChanDepth[1][4][1] = (TH2F *)hfile->Get("h_2DsumADCAmplLS6");
0506   MapNumBadChanDepth[1][4][2] = (TH2F *)hfile->Get("h_2DsumADCAmplLS7");
0507 
0508   MapNumBadChanFull[1] = (TH2F *)MapNumBadChanDepth[1][1][1]->Clone();
0509 
0510   MapNumChanDepth[1][1][1] = (TH2F *)hfile->Get("h_2D0sumADCAmplLS1");
0511   MapNumChanDepth[1][1][2] = (TH2F *)hfile->Get("h_2D0sumADCAmplLS2");
0512 
0513   MapNumChanDepth[1][2][1] = (TH2F *)hfile->Get("h_2D0sumADCAmplLS3");
0514   MapNumChanDepth[1][2][2] = (TH2F *)hfile->Get("h_2D0sumADCAmplLS4");
0515   MapNumChanDepth[1][2][3] = (TH2F *)hfile->Get("h_2D0sumADCAmplLS5");
0516 
0517   MapNumChanDepth[1][3][4] = (TH2F *)hfile->Get("h_2D0sumADCAmplLS8");
0518 
0519   MapNumChanDepth[1][4][1] = (TH2F *)hfile->Get("h_2D0sumADCAmplLS6");
0520   MapNumChanDepth[1][4][2] = (TH2F *)hfile->Get("h_2D0sumADCAmplLS7");
0521 
0522   MapNumChanFull[1] = (TH2F *)MapNumChanDepth[1][1][1]->Clone();
0523 
0524   //+++++++++++++++++++++++++++++
0525   // Width
0526   //+++++++++++++++++++++++++++++
0527 
0528   MapNumBadChanDepth[2][1][1] = (TH2F *)hfile->Get("h_2DsumAmplitudeLS1");
0529   MapNumBadChanDepth[2][1][2] = (TH2F *)hfile->Get("h_2DsumAmplitudeLS2");
0530 
0531   MapNumBadChanDepth[2][2][1] = (TH2F *)hfile->Get("h_2DsumAmplitudeLS3");
0532   MapNumBadChanDepth[2][2][2] = (TH2F *)hfile->Get("h_2DsumAmplitudeLS4");
0533   MapNumBadChanDepth[2][2][3] = (TH2F *)hfile->Get("h_2DsumAmplitudeLS5");
0534 
0535   MapNumBadChanDepth[2][3][4] = (TH2F *)hfile->Get("h_2DsumAmplitudeLS8");
0536 
0537   MapNumBadChanDepth[2][4][1] = (TH2F *)hfile->Get("h_2DsumAmplitudeLS6");
0538   MapNumBadChanDepth[2][4][2] = (TH2F *)hfile->Get("h_2DsumAmplitudeLS7");
0539 
0540   MapNumBadChanFull[2] = (TH2F *)MapNumBadChanDepth[2][1][1]->Clone();
0541 
0542   MapNumChanDepth[2][1][1] = (TH2F *)hfile->Get("h_2D0sumAmplitudeLS1");
0543   MapNumChanDepth[2][1][2] = (TH2F *)hfile->Get("h_2D0sumAmplitudeLS2");
0544 
0545   MapNumChanDepth[2][2][1] = (TH2F *)hfile->Get("h_2D0sumAmplitudeLS3");
0546   MapNumChanDepth[2][2][2] = (TH2F *)hfile->Get("h_2D0sumAmplitudeLS4");
0547   MapNumChanDepth[2][2][3] = (TH2F *)hfile->Get("h_2D0sumAmplitudeLS5");
0548 
0549   MapNumChanDepth[2][3][4] = (TH2F *)hfile->Get("h_2D0sumAmplitudeLS8");
0550 
0551   MapNumChanDepth[2][4][1] = (TH2F *)hfile->Get("h_2D0sumAmplitudeLS6");
0552   MapNumChanDepth[2][4][2] = (TH2F *)hfile->Get("h_2D0sumAmplitudeLS7");
0553 
0554   MapNumChanFull[2] = (TH2F *)MapNumChanDepth[2][1][1]->Clone();
0555 
0556   //+++++++++++++++++++++++++++++
0557   // Ratio
0558   //+++++++++++++++++++++++++++++
0559 
0560   MapNumBadChanDepth[3][1][1] = (TH2F *)hfile->Get("h_2DsumAmplLS1");
0561   MapNumBadChanDepth[3][1][2] = (TH2F *)hfile->Get("h_2DsumAmplLS2");
0562 
0563   MapNumBadChanDepth[3][2][1] = (TH2F *)hfile->Get("h_2DsumAmplLS3");
0564   MapNumBadChanDepth[3][2][2] = (TH2F *)hfile->Get("h_2DsumAmplLS4");
0565   MapNumBadChanDepth[3][2][3] = (TH2F *)hfile->Get("h_2DsumAmplLS5");
0566 
0567   MapNumBadChanDepth[3][3][4] = (TH2F *)hfile->Get("h_2DsumAmplLS8");
0568 
0569   MapNumBadChanDepth[3][4][1] = (TH2F *)hfile->Get("h_2DsumAmplLS6");
0570   MapNumBadChanDepth[3][4][2] = (TH2F *)hfile->Get("h_2DsumAmplLS7");
0571 
0572   MapNumBadChanFull[3] = (TH2F *)MapNumBadChanDepth[3][1][1]->Clone();
0573 
0574   MapNumChanDepth[3][1][1] = (TH2F *)hfile->Get("h_2D0sumAmplLS1");
0575   MapNumChanDepth[3][1][2] = (TH2F *)hfile->Get("h_2D0sumAmplLS2");
0576 
0577   MapNumChanDepth[3][2][1] = (TH2F *)hfile->Get("h_2D0sumAmplLS3");
0578   MapNumChanDepth[3][2][2] = (TH2F *)hfile->Get("h_2D0sumAmplLS4");
0579   MapNumChanDepth[3][2][3] = (TH2F *)hfile->Get("h_2D0sumAmplLS5");
0580 
0581   MapNumChanDepth[3][3][4] = (TH2F *)hfile->Get("h_2D0sumAmplLS8");
0582 
0583   MapNumChanDepth[3][4][1] = (TH2F *)hfile->Get("h_2D0sumAmplLS6");
0584   MapNumChanDepth[3][4][2] = (TH2F *)hfile->Get("h_2D0sumAmplLS7");
0585 
0586   MapNumChanFull[3] = (TH2F *)MapNumChanDepth[3][1][1]->Clone();
0587 
0588   //+++++++++++++++++++++++++++++
0589   // Tmean
0590   //+++++++++++++++++++++++++++++
0591 
0592   MapNumBadChanDepth[4][1][1] = (TH2F *)hfile->Get("h_2DsumTSmeanALS1");
0593   MapNumBadChanDepth[4][1][2] = (TH2F *)hfile->Get("h_2DsumTSmeanALS2");
0594 
0595   MapNumBadChanDepth[4][2][1] = (TH2F *)hfile->Get("h_2DsumTSmeanALS3");
0596   MapNumBadChanDepth[4][2][2] = (TH2F *)hfile->Get("h_2DsumTSmeanALS4");
0597   MapNumBadChanDepth[4][2][3] = (TH2F *)hfile->Get("h_2DsumTSmeanALS5");
0598 
0599   MapNumBadChanDepth[4][3][4] = (TH2F *)hfile->Get("h_2DsumTSmeanALS8");
0600 
0601   MapNumBadChanDepth[4][4][1] = (TH2F *)hfile->Get("h_2DsumTSmeanALS6");
0602   MapNumBadChanDepth[4][4][2] = (TH2F *)hfile->Get("h_2DsumTSmeanALS7");
0603 
0604   MapNumBadChanFull[4] = (TH2F *)MapNumBadChanDepth[4][1][1]->Clone();
0605 
0606   MapNumChanDepth[4][1][1] = (TH2F *)hfile->Get("h_2D0sumTSmeanALS1");
0607   MapNumChanDepth[4][1][2] = (TH2F *)hfile->Get("h_2D0sumTSmeanALS2");
0608 
0609   MapNumChanDepth[4][2][1] = (TH2F *)hfile->Get("h_2D0sumTSmeanALS3");
0610   MapNumChanDepth[4][2][2] = (TH2F *)hfile->Get("h_2D0sumTSmeanALS4");
0611   MapNumChanDepth[4][2][3] = (TH2F *)hfile->Get("h_2D0sumTSmeanALS5");
0612 
0613   MapNumChanDepth[4][3][4] = (TH2F *)hfile->Get("h_2D0sumTSmeanALS8");
0614 
0615   MapNumChanDepth[4][4][1] = (TH2F *)hfile->Get("h_2D0sumTSmeanALS6");
0616   MapNumChanDepth[4][4][2] = (TH2F *)hfile->Get("h_2D0sumTSmeanALS7");
0617 
0618   MapNumChanFull[4] = (TH2F *)MapNumChanDepth[4][1][1]->Clone();
0619 
0620   //+++++++++++++++++++++++++++++
0621   // Tmax
0622   //+++++++++++++++++++++++++++++
0623 
0624   MapNumBadChanDepth[5][1][1] = (TH2F *)hfile->Get("h_2DsumTSmaxALS1");
0625   MapNumBadChanDepth[5][1][2] = (TH2F *)hfile->Get("h_2DsumTSmaxALS2");
0626 
0627   MapNumBadChanDepth[5][2][1] = (TH2F *)hfile->Get("h_2DsumTSmaxALS3");
0628   MapNumBadChanDepth[5][2][2] = (TH2F *)hfile->Get("h_2DsumTSmaxALS4");
0629   MapNumBadChanDepth[5][2][3] = (TH2F *)hfile->Get("h_2DsumTSmaxALS5");
0630 
0631   MapNumBadChanDepth[5][3][4] = (TH2F *)hfile->Get("h_2DsumTSmaxALS8");
0632 
0633   MapNumBadChanDepth[5][4][1] = (TH2F *)hfile->Get("h_2DsumTSmaxALS6");
0634   MapNumBadChanDepth[5][4][2] = (TH2F *)hfile->Get("h_2DsumTSmaxALS7");
0635 
0636   MapNumBadChanFull[5] = (TH2F *)MapNumBadChanDepth[5][1][1]->Clone();
0637 
0638   MapNumChanDepth[5][1][1] = (TH2F *)hfile->Get("h_2D0sumTSmaxALS1");
0639   MapNumChanDepth[5][1][2] = (TH2F *)hfile->Get("h_2D0sumTSmaxALS2");
0640 
0641   MapNumChanDepth[5][2][1] = (TH2F *)hfile->Get("h_2D0sumTSmaxALS3");
0642   MapNumChanDepth[5][2][2] = (TH2F *)hfile->Get("h_2D0sumTSmaxALS4");
0643   MapNumChanDepth[5][2][3] = (TH2F *)hfile->Get("h_2D0sumTSmaxALS5");
0644 
0645   MapNumChanDepth[5][3][4] = (TH2F *)hfile->Get("h_2D0sumTSmaxALS8");
0646 
0647   MapNumChanDepth[5][4][1] = (TH2F *)hfile->Get("h_2D0sumTSmaxALS6");
0648   MapNumChanDepth[5][4][2] = (TH2F *)hfile->Get("h_2D0sumTSmaxALS7");
0649 
0650   MapNumChanFull[5] = (TH2F *)MapNumChanDepth[5][1][1]->Clone();
0651 
0652   for (int test = 0; test <= 5; test++) {  //Test: 0,
0653     for (int sub = 1; sub <= 4; sub++) {   //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
0654       if (sub == 1)
0655         cHB->Divide(2, 1);
0656       if (sub == 2)
0657         cHE->Divide(3, 1);
0658       if (sub == 3)
0659         cONE->Divide(1, 1);
0660       if (sub == 4)
0661         cHB->Divide(2, 1);
0662       for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
0663         if (sub == 1)
0664           cHB->cd(k);
0665         if (sub == 2)
0666           cHE->cd(k);
0667         if (sub == 3)
0668           cONE->cd(k - 3);
0669         if (sub == 4)
0670           cHB->cd(k);
0671         MapNumBadChanDepth[test][sub][k]->Divide(
0672             MapNumBadChanDepth[test][sub][k], MapNumChanDepth[test][sub][k], 1, 1, "B");
0673 
0674         for (int x = 1; x <= MapNumBadChanFull[test]->GetXaxis()->GetNbins(); x++) {
0675           for (int y = 1; y <= MapNumBadChanFull[test]->GetYaxis()->GetNbins(); y++) {
0676             double ccc1 = MapNumBadChanDepth[test][sub][k]->GetBinContent(x, y);
0677             MapNumBadChanFull[test]->SetBinContent(x, y, MapNumBadChanFull[test]->GetBinContent(x, y) + ccc1);
0678           }  //end y
0679         }    //end x
0680 
0681         if (k == 1)
0682           MapNumBadChanDepth[test][sub][k]->SetTitle("Depth 1\b");
0683         if (k == 2)
0684           MapNumBadChanDepth[test][sub][k]->SetTitle("Depth 2\b");
0685         if (k == 3)
0686           MapNumBadChanDepth[test][sub][k]->SetTitle("Depth 3\b");
0687         if (k == 4)
0688           MapNumBadChanDepth[test][sub][k]->SetTitle("Depth 4\b");
0689         gPad->SetGridy();
0690         gPad->SetGridx();
0691         gPad->SetLogz();
0692         MapNumBadChanDepth[test][sub][k]->SetXTitle("#eta \b");
0693         MapNumBadChanDepth[test][sub][k]->SetYTitle("#phi \b");
0694         MapNumBadChanDepth[test][sub][k]->SetZTitle("Average estimator \b");
0695         MapNumBadChanDepth[test][sub][k]->SetTitleOffset(0.75, "Z");
0696         MapNumBadChanDepth[test][sub][k]->Draw("COLZ");
0697         MapNumBadChanDepth[test][sub][k]->GetYaxis()->SetRangeUser(0, 72.);
0698         //                MapNumBadChanDepth[test][sub][k]->GetZaxis()->SetRangeUser(0.0001, 1.);
0699       }
0700       if (test == 0) {
0701         if (sub == 1) {
0702           cHB->Print("MapCapIdErrorHB.png");
0703           cHB->Clear();
0704         }
0705         if (sub == 2) {
0706           cHE->Print("MapCapIdErrorHE.png");
0707           cHE->Clear();
0708         }
0709         if (sub == 3) {
0710           cONE->Print("MapCapIdErrorHO.png");
0711           cONE->Clear();
0712         }
0713         if (sub == 4) {
0714           cHB->Print("MapCapIdErrorHF.png");
0715           cHB->Clear();
0716         }
0717       }
0718       if (test == 1) {
0719         if (sub == 1) {
0720           cHB->Print("MapADCamplHB.png");
0721           cHB->Clear();
0722         }
0723         if (sub == 2) {
0724           cHE->Print("MapADCamplHE.png");
0725           cHE->Clear();
0726         }
0727         if (sub == 3) {
0728           cONE->Print("MapADCamplHO.png");
0729           cONE->Clear();
0730         }
0731         if (sub == 4) {
0732           cHB->Print("MapADCamplHF.png");
0733           cHB->Clear();
0734         }
0735       }
0736       if (test == 2) {
0737         if (sub == 1) {
0738           cHB->Print("MapWidthHB.png");
0739           cHB->Clear();
0740         }
0741         if (sub == 2) {
0742           cHE->Print("MapWidthHE.png");
0743           cHE->Clear();
0744         }
0745         if (sub == 3) {
0746           cONE->Print("MapWidthHO.png");
0747           cONE->Clear();
0748         }
0749         if (sub == 4) {
0750           cHB->Print("MapWidthHF.png");
0751           cHB->Clear();
0752         }
0753       }
0754       if (test == 3) {
0755         if (sub == 1) {
0756           cHB->Print("MapRatioHB.png");
0757           cHB->Clear();
0758         }
0759         if (sub == 2) {
0760           cHE->Print("MapRatioHE.png");
0761           cHE->Clear();
0762         }
0763         if (sub == 3) {
0764           cONE->Print("MapRatioHO.png");
0765           cONE->Clear();
0766         }
0767         if (sub == 4) {
0768           cHB->Print("MapRatioHF.png");
0769           cHB->Clear();
0770         }
0771       }
0772       if (test == 4) {
0773         if (sub == 1) {
0774           cHB->Print("MapTmeanHB.png");
0775           cHB->Clear();
0776         }
0777         if (sub == 2) {
0778           cHE->Print("MapTmeanHE.png");
0779           cHE->Clear();
0780         }
0781         if (sub == 3) {
0782           cONE->Print("MapTmeanHO.png");
0783           cONE->Clear();
0784         }
0785         if (sub == 4) {
0786           cHB->Print("MapTmeanHF.png");
0787           cHB->Clear();
0788         }
0789       }
0790       if (test == 5) {
0791         if (sub == 1) {
0792           cHB->Print("MapTmaxHB.png");
0793           cHB->Clear();
0794         }
0795         if (sub == 2) {
0796           cHE->Print("MapTmaxHE.png");
0797           cHE->Clear();
0798         }
0799         if (sub == 3) {
0800           cONE->Print("MapTmaxHO.png");
0801           cONE->Clear();
0802         }
0803         if (sub == 4) {
0804           cHB->Print("MapTmaxHF.png");
0805           cHB->Clear();
0806         }
0807       }
0808     }  // end sub
0809     cONE->Divide(1, 1);
0810     cONE->cd(1);
0811     gPad->SetGridy();
0812     gPad->SetGridx();
0813     gPad->SetLogz();
0814     MapNumBadChanFull[test]->SetTitle("All subdetectors\b");
0815     MapNumBadChanFull[test]->SetXTitle("#eta \b");
0816     MapNumBadChanFull[test]->SetYTitle("#phi \b");
0817     if (test == 0)
0818       MapNumBadChanFull[test]->SetZTitle("Average Nbcs \b");
0819     if (test != 0)
0820       MapNumBadChanFull[test]->SetZTitle("Average estimator \b");
0821     //   MapNumBadChanFull[test]->GetZaxis()->SetLabelSize(0.008);
0822     MapNumBadChanFull[test]->SetTitleOffset(0.75, "Z");
0823     MapNumBadChanFull[test]->Draw("COLZ");
0824     MapNumBadChanFull[test]->GetYaxis()->SetRangeUser(0, 72.);
0825     //         MapNumBadChanFull[test]->GetZaxis()->SetRangeUser(0.0001, 1.);
0826     if (test == 0) {
0827       cONE->Print("MapCapIdError.png");
0828       cONE->Clear();
0829     }
0830     if (test == 1) {
0831       cONE->Print("MapADCAmpl.png");
0832       cONE->Clear();
0833     }
0834     if (test == 2) {
0835       cONE->Print("MapWidth.png");
0836       cONE->Clear();
0837     }
0838     if (test == 3) {
0839       cONE->Print("MapRatio.png");
0840       cONE->Clear();
0841     }
0842     if (test == 4) {
0843       cONE->Print("MapTmean.png");
0844       cONE->Clear();
0845     }
0846     if (test == 5) {
0847       cONE->Print("MapTmax.png");
0848       cONE->Clear();
0849     }
0850   }  //end test
0851 
0852   //================================================================================================================================
0853 
0854   //=======================================================================================================
0855   // 1-d histograms third definition
0856 
0857   TH1F *HistNumBadChanDepth[7][5][8];     // 1d histogramm for test,subdet, depth
0858   TH1F *HistCutNumBadChanDepth[7][5][8];  // 1d histogramm for test,subdet, depth
0859   TH1F *HistNumChanDepth[7][5][8];        // 1d histogramm for test,subdet, depth
0860 
0861   //      TH1F *HistNumBadChanDepth[7][5][5];    // 1d histogramm for test,subdet, depth
0862   //      TH1F *HistCutNumBadChanDepth[7][5][5];    // 1d histogramm for test,subdet, depth
0863   //      TH1F *HistNumChanDepth[7][5][5];    // 1d histogramm for test,subdet, depth
0864 
0865   TH1F *HistNumBadChanFull[7];  // 1d histogramm for test
0866   TH1F *HistNumChanFull[7];     // 1d histogramm for test
0867 
0868   //+++++++++++++++++++++++++++++
0869   // Rate of Cap ID errors
0870   //+++++++++++++++++++++++++++++
0871 
0872   HistNumBadChanDepth[0][1][1] = (TH1F *)hfile->Get("h_runnbadchannels_depth1_HB");
0873   HistNumBadChanDepth[0][1][2] = (TH1F *)hfile->Get("h_runnbadchannels_depth2_HB");
0874 
0875   HistNumBadChanDepth[0][2][1] = (TH1F *)hfile->Get("h_runnbadchannels_depth1_HE");
0876   HistNumBadChanDepth[0][2][2] = (TH1F *)hfile->Get("h_runnbadchannels_depth2_HE");
0877   HistNumBadChanDepth[0][2][3] = (TH1F *)hfile->Get("h_runnbadchannels_depth3_HE");
0878 
0879   HistNumBadChanDepth[0][3][4] = (TH1F *)hfile->Get("h_runnbadchannels_depth4_HO");
0880 
0881   HistNumBadChanDepth[0][4][1] = (TH1F *)hfile->Get("h_runnbadchannels_depth1_HF");
0882   HistNumBadChanDepth[0][4][2] = (TH1F *)hfile->Get("h_runnbadchannels_depth2_HF");
0883 
0884   HistNumBadChanFull[0] = (TH1F *)HistNumBadChanDepth[0][1][1]->Clone();
0885 
0886   HistCutNumBadChanDepth[0][1][1] = (TH1F *)hfile->Get("h_runnbadchannels_depth1_HB");
0887   HistCutNumBadChanDepth[0][1][2] = (TH1F *)hfile->Get("h_runnbadchannels_depth2_HB");
0888 
0889   HistCutNumBadChanDepth[0][2][1] = (TH1F *)hfile->Get("h_runnbadchannels_depth1_HE");
0890   HistCutNumBadChanDepth[0][2][2] = (TH1F *)hfile->Get("h_runnbadchannels_depth2_HE");
0891   HistCutNumBadChanDepth[0][2][3] = (TH1F *)hfile->Get("h_runnbadchannels_depth3_HE");
0892 
0893   HistCutNumBadChanDepth[0][3][4] = (TH1F *)hfile->Get("h_runnbadchannels_depth4_HO");
0894 
0895   HistCutNumBadChanDepth[0][4][1] = (TH1F *)hfile->Get("h_runnbadchannels_depth1_HF");
0896   HistCutNumBadChanDepth[0][4][2] = (TH1F *)hfile->Get("h_runnbadchannels_depth2_HF");
0897 
0898   HistNumChanDepth[0][1][1] = (TH1F *)hfile->Get("h_runbadrate0_depth1_HB");
0899   HistNumChanDepth[0][1][2] = (TH1F *)hfile->Get("h_runbadrate0_depth2_HB");
0900 
0901   HistNumChanDepth[0][2][1] = (TH1F *)hfile->Get("h_runbadrate0_depth1_HE");
0902   HistNumChanDepth[0][2][2] = (TH1F *)hfile->Get("h_runbadrate0_depth2_HE");
0903   HistNumChanDepth[0][2][3] = (TH1F *)hfile->Get("h_runbadrate0_depth3_HE");
0904 
0905   HistNumChanDepth[0][3][4] = (TH1F *)hfile->Get("h_runbadrate0_depth4_HO");
0906 
0907   HistNumChanDepth[0][4][1] = (TH1F *)hfile->Get("h_runbadrate0_depth1_HF");
0908   HistNumChanDepth[0][4][2] = (TH1F *)hfile->Get("h_runbadrate0_depth2_HF");
0909 
0910   HistNumChanFull[0] = (TH1F *)HistNumChanDepth[0][1][1]->Clone();
0911 
0912   //+++++++++++++++++++++++++++++
0913   // ADC Amplitude
0914   //+++++++++++++++++++++++++++++
0915 
0916   //////////////////////
0917   // HB:
0918   HistNumBadChanDepth[1][1][1] = (TH1F *)hfile->Get("h_sumADCAmplperLS1");
0919   HistNumBadChanDepth[1][1][2] = (TH1F *)hfile->Get("h_sumADCAmplperLS2");
0920 
0921   // HE:
0922   HistNumBadChanDepth[1][2][1] = (TH1F *)hfile->Get("h_sumADCAmplperLS3");
0923   HistNumBadChanDepth[1][2][2] = (TH1F *)hfile->Get("h_sumADCAmplperLS4");
0924   HistNumBadChanDepth[1][2][3] = (TH1F *)hfile->Get("h_sumADCAmplperLS5");
0925   // HE upgrade:
0926   HistNumBadChanDepth[1][2][4] = (TH1F *)hfile->Get("h_sumADCAmplperLSdepth4HEu");
0927   HistNumBadChanDepth[1][2][5] = (TH1F *)hfile->Get("h_sumADCAmplperLSdepth5HEu");
0928   HistNumBadChanDepth[1][2][6] = (TH1F *)hfile->Get("h_sumADCAmplperLSdepth6HEu");
0929   HistNumBadChanDepth[1][2][7] = (TH1F *)hfile->Get("h_sumADCAmplperLSdepth7HEu");
0930 
0931   // HO:
0932   HistNumBadChanDepth[1][3][4] = (TH1F *)hfile->Get("h_sumADCAmplperLS8");
0933 
0934   // HF:
0935   HistNumBadChanDepth[1][4][1] = (TH1F *)hfile->Get("h_sumADCAmplperLS6");
0936   HistNumBadChanDepth[1][4][2] = (TH1F *)hfile->Get("h_sumADCAmplperLS7");
0937   // HF upgrade:
0938   HistNumBadChanDepth[1][4][3] = (TH1F *)hfile->Get("h_sumADCAmplperLS6u");
0939   HistNumBadChanDepth[1][4][4] = (TH1F *)hfile->Get("h_sumADCAmplperLS7u");
0940 
0941   // other cases:
0942   HistNumBadChanFull[1] = (TH1F *)HistNumBadChanDepth[1][1][1]->Clone();
0943 
0944   //////////////////////
0945   // HB:
0946   HistCutNumBadChanDepth[1][1][1] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS1");
0947   HistCutNumBadChanDepth[1][1][2] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS2");
0948 
0949   // HE:
0950   HistCutNumBadChanDepth[1][2][1] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS3");
0951   HistCutNumBadChanDepth[1][2][2] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS4");
0952   HistCutNumBadChanDepth[1][2][3] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS5");
0953   // HE upgrade:
0954   HistCutNumBadChanDepth[1][2][4] = (TH1F *)hfile->Get("h_sumCutADCAmplperLSdepth4HEu");
0955   HistCutNumBadChanDepth[1][2][5] = (TH1F *)hfile->Get("h_sumCutADCAmplperLSdepth5HEu");
0956   HistCutNumBadChanDepth[1][2][6] = (TH1F *)hfile->Get("h_sumCutADCAmplperLSdepth6HEu");
0957   HistCutNumBadChanDepth[1][2][7] = (TH1F *)hfile->Get("h_sumCutADCAmplperLSdepth7HEu");
0958 
0959   // HO:
0960   HistCutNumBadChanDepth[1][3][4] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS8");
0961 
0962   // HF:
0963   HistCutNumBadChanDepth[1][4][1] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS6");
0964   HistCutNumBadChanDepth[1][4][2] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS7");
0965   // HF upgrade:
0966   HistCutNumBadChanDepth[1][4][3] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS6u");
0967   HistCutNumBadChanDepth[1][4][4] = (TH1F *)hfile->Get("h_sumCutADCAmplperLS7u");
0968 
0969   //////////////////////
0970   // HB:
0971   HistNumChanDepth[1][1][1] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS1");
0972   HistNumChanDepth[1][1][2] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS2");
0973 
0974   // HE:
0975   HistNumChanDepth[1][2][1] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS3");
0976   HistNumChanDepth[1][2][2] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS4");
0977   HistNumChanDepth[1][2][3] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS5");
0978   // HE upgrade:
0979   HistNumChanDepth[1][2][4] = (TH1F *)hfile->Get("h_sum0ADCAmplperLSdepth4HEu");
0980   HistNumChanDepth[1][2][5] = (TH1F *)hfile->Get("h_sum0ADCAmplperLSdepth5HEu");
0981   HistNumChanDepth[1][2][6] = (TH1F *)hfile->Get("h_sum0ADCAmplperLSdepth6HEu");
0982   HistNumChanDepth[1][2][7] = (TH1F *)hfile->Get("h_sum0ADCAmplperLSdepth7HEu");
0983 
0984   // HO:
0985   HistNumChanDepth[1][3][4] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS8");
0986 
0987   // HF:
0988   HistNumChanDepth[1][4][1] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS6");
0989   HistNumChanDepth[1][4][2] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS7");
0990   // HF upgrade:
0991   HistNumChanDepth[1][4][3] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS6u");
0992   HistNumChanDepth[1][4][4] = (TH1F *)hfile->Get("h_sum0ADCAmplperLS7u");
0993 
0994   // other cases:
0995   HistNumChanFull[1] = (TH1F *)HistNumChanDepth[1][1][1]->Clone();
0996   // just initialization of [6] massive for alternative <A> calculation
0997   HistNumChanFull[6] = (TH1F *)HistNumChanDepth[1][1][1]->Clone();
0998 
0999   //+++++++++++++++++++++++++++++
1000   // Width
1001   //+++++++++++++++++++++++++++++
1002 
1003   HistNumBadChanDepth[2][1][1] = (TH1F *)hfile->Get("h_sumAmplitudeperLS1");
1004   HistNumBadChanDepth[2][1][2] = (TH1F *)hfile->Get("h_sumAmplitudeperLS2");
1005 
1006   HistNumBadChanDepth[2][2][1] = (TH1F *)hfile->Get("h_sumAmplitudeperLS3");
1007   HistNumBadChanDepth[2][2][2] = (TH1F *)hfile->Get("h_sumAmplitudeperLS4");
1008   HistNumBadChanDepth[2][2][3] = (TH1F *)hfile->Get("h_sumAmplitudeperLS5");
1009 
1010   HistNumBadChanDepth[2][3][4] = (TH1F *)hfile->Get("h_sumAmplitudeperLS8");
1011 
1012   HistNumBadChanDepth[2][4][1] = (TH1F *)hfile->Get("h_sumAmplitudeperLS6");
1013   HistNumBadChanDepth[2][4][2] = (TH1F *)hfile->Get("h_sumAmplitudeperLS7");
1014 
1015   HistNumBadChanFull[2] = (TH1F *)HistNumBadChanDepth[2][1][1]->Clone();
1016 
1017   HistCutNumBadChanDepth[2][1][1] = (TH1F *)hfile->Get("h_sumCutAmplitudeperLS1");
1018   HistCutNumBadChanDepth[2][1][2] = (TH1F *)hfile->Get("h_sumCutAmplitudeperLS2");
1019 
1020   HistCutNumBadChanDepth[2][2][1] = (TH1F *)hfile->Get("h_sumCutAmplitudeperLS3");
1021   HistCutNumBadChanDepth[2][2][2] = (TH1F *)hfile->Get("h_sumCutAmplitudeperLS4");
1022   HistCutNumBadChanDepth[2][2][3] = (TH1F *)hfile->Get("h_sumCutAmplitudeperLS5");
1023 
1024   HistCutNumBadChanDepth[2][3][4] = (TH1F *)hfile->Get("h_sumCutAmplitudeperLS8");
1025 
1026   HistCutNumBadChanDepth[2][4][1] = (TH1F *)hfile->Get("h_sumCutAmplitudeperLS6");
1027   HistCutNumBadChanDepth[2][4][2] = (TH1F *)hfile->Get("h_sumCutAmplitudeperLS7");
1028 
1029   HistNumChanDepth[2][1][1] = (TH1F *)hfile->Get("h_sum0AmplitudeperLS1");
1030   HistNumChanDepth[2][1][2] = (TH1F *)hfile->Get("h_sum0AmplitudeperLS2");
1031 
1032   HistNumChanDepth[2][2][1] = (TH1F *)hfile->Get("h_sum0AmplitudeperLS3");
1033   HistNumChanDepth[2][2][2] = (TH1F *)hfile->Get("h_sum0AmplitudeperLS4");
1034   HistNumChanDepth[2][2][3] = (TH1F *)hfile->Get("h_sum0AmplitudeperLS5");
1035 
1036   HistNumChanDepth[2][3][4] = (TH1F *)hfile->Get("h_sum0AmplitudeperLS8");
1037 
1038   HistNumChanDepth[2][4][1] = (TH1F *)hfile->Get("h_sum0AmplitudeperLS6");
1039   HistNumChanDepth[2][4][2] = (TH1F *)hfile->Get("h_sum0AmplitudeperLS7");
1040 
1041   HistNumChanFull[2] = (TH1F *)HistNumChanDepth[2][1][1]->Clone();
1042   //+++++++++++++++++++++++++++++
1043   // Ratio
1044   //+++++++++++++++++++++++++++++
1045 
1046   HistNumBadChanDepth[3][1][1] = (TH1F *)hfile->Get("h_sumAmplperLS1");
1047   HistNumBadChanDepth[3][1][2] = (TH1F *)hfile->Get("h_sumAmplperLS2");
1048 
1049   HistNumBadChanDepth[3][2][1] = (TH1F *)hfile->Get("h_sumAmplperLS3");
1050   HistNumBadChanDepth[3][2][2] = (TH1F *)hfile->Get("h_sumAmplperLS4");
1051   HistNumBadChanDepth[3][2][3] = (TH1F *)hfile->Get("h_sumAmplperLS5");
1052 
1053   HistNumBadChanDepth[3][3][4] = (TH1F *)hfile->Get("h_sumAmplperLS8");
1054 
1055   HistNumBadChanDepth[3][4][1] = (TH1F *)hfile->Get("h_sumAmplperLS6");
1056   HistNumBadChanDepth[3][4][2] = (TH1F *)hfile->Get("h_sumAmplperLS7");
1057 
1058   HistNumBadChanFull[3] = (TH1F *)HistNumBadChanDepth[3][1][1]->Clone();
1059 
1060   HistCutNumBadChanDepth[3][1][1] = (TH1F *)hfile->Get("h_sumCutAmplperLS1");
1061   HistCutNumBadChanDepth[3][1][2] = (TH1F *)hfile->Get("h_sumCutAmplperLS2");
1062 
1063   HistCutNumBadChanDepth[3][2][1] = (TH1F *)hfile->Get("h_sumCutAmplperLS3");
1064   HistCutNumBadChanDepth[3][2][2] = (TH1F *)hfile->Get("h_sumCutAmplperLS4");
1065   HistCutNumBadChanDepth[3][2][3] = (TH1F *)hfile->Get("h_sumCutAmplperLS5");
1066 
1067   HistCutNumBadChanDepth[3][3][4] = (TH1F *)hfile->Get("h_sumCutAmplperLS8");
1068 
1069   HistCutNumBadChanDepth[3][4][1] = (TH1F *)hfile->Get("h_sumCutAmplperLS6");
1070   HistCutNumBadChanDepth[3][4][2] = (TH1F *)hfile->Get("h_sumCutAmplperLS7");
1071 
1072   HistNumChanDepth[3][1][1] = (TH1F *)hfile->Get("h_sum0AmplperLS1");
1073   HistNumChanDepth[3][1][2] = (TH1F *)hfile->Get("h_sum0AmplperLS2");
1074 
1075   HistNumChanDepth[3][2][1] = (TH1F *)hfile->Get("h_sum0AmplperLS3");
1076   HistNumChanDepth[3][2][2] = (TH1F *)hfile->Get("h_sum0AmplperLS4");
1077   HistNumChanDepth[3][2][3] = (TH1F *)hfile->Get("h_sum0AmplperLS5");
1078 
1079   HistNumChanDepth[3][3][4] = (TH1F *)hfile->Get("h_sum0AmplperLS8");
1080 
1081   HistNumChanDepth[3][4][1] = (TH1F *)hfile->Get("h_sum0AmplperLS6");
1082   HistNumChanDepth[3][4][2] = (TH1F *)hfile->Get("h_sum0AmplperLS7");
1083 
1084   HistNumChanFull[3] = (TH1F *)HistNumChanDepth[3][1][1]->Clone();
1085   //+++++++++++++++++++++++++++++
1086   // Tmean
1087   //+++++++++++++++++++++++++++++
1088 
1089   HistNumBadChanDepth[4][1][1] = (TH1F *)hfile->Get("h_sumTSmeanAperLS1");
1090   HistNumBadChanDepth[4][1][2] = (TH1F *)hfile->Get("h_sumTSmeanAperLS2");
1091 
1092   HistNumBadChanDepth[4][2][1] = (TH1F *)hfile->Get("h_sumTSmeanAperLS3");
1093   HistNumBadChanDepth[4][2][2] = (TH1F *)hfile->Get("h_sumTSmeanAperLS4");
1094   HistNumBadChanDepth[4][2][3] = (TH1F *)hfile->Get("h_sumTSmeanAperLS5");
1095 
1096   HistNumBadChanDepth[4][3][4] = (TH1F *)hfile->Get("h_sumTSmeanAperLS8");
1097 
1098   HistNumBadChanDepth[4][4][1] = (TH1F *)hfile->Get("h_sumTSmeanAperLS6");
1099   HistNumBadChanDepth[4][4][2] = (TH1F *)hfile->Get("h_sumTSmeanAperLS7");
1100 
1101   HistNumBadChanFull[4] = (TH1F *)HistNumBadChanDepth[4][1][1]->Clone();
1102 
1103   HistCutNumBadChanDepth[4][1][1] = (TH1F *)hfile->Get("h_sumCutTSmeanAperLS1");
1104   HistCutNumBadChanDepth[4][1][2] = (TH1F *)hfile->Get("h_sumCutTSmeanAperLS2");
1105 
1106   HistCutNumBadChanDepth[4][2][1] = (TH1F *)hfile->Get("h_sumCutTSmeanAperLS3");
1107   HistCutNumBadChanDepth[4][2][2] = (TH1F *)hfile->Get("h_sumCutTSmeanAperLS4");
1108   HistCutNumBadChanDepth[4][2][3] = (TH1F *)hfile->Get("h_sumCutTSmeanAperLS5");
1109 
1110   HistCutNumBadChanDepth[4][3][4] = (TH1F *)hfile->Get("h_sumCutTSmeanAperLS8");
1111 
1112   HistCutNumBadChanDepth[4][4][1] = (TH1F *)hfile->Get("h_sumCutTSmeanAperLS6");
1113   HistCutNumBadChanDepth[4][4][2] = (TH1F *)hfile->Get("h_sumCutTSmeanAperLS7");
1114 
1115   HistNumChanDepth[4][1][1] = (TH1F *)hfile->Get("h_sum0TSmeanAperLS1");
1116   HistNumChanDepth[4][1][2] = (TH1F *)hfile->Get("h_sum0TSmeanAperLS2");
1117 
1118   HistNumChanDepth[4][2][1] = (TH1F *)hfile->Get("h_sum0TSmeanAperLS3");
1119   HistNumChanDepth[4][2][2] = (TH1F *)hfile->Get("h_sum0TSmeanAperLS4");
1120   HistNumChanDepth[4][2][3] = (TH1F *)hfile->Get("h_sum0TSmeanAperLS5");
1121 
1122   HistNumChanDepth[4][3][4] = (TH1F *)hfile->Get("h_sum0TSmeanAperLS8");
1123 
1124   HistNumChanDepth[4][4][1] = (TH1F *)hfile->Get("h_sum0TSmeanAperLS6");
1125   HistNumChanDepth[4][4][2] = (TH1F *)hfile->Get("h_sum0TSmeanAperLS7");
1126 
1127   HistNumChanFull[4] = (TH1F *)HistNumChanDepth[4][1][1]->Clone();
1128   //+++++++++++++++++++++++++++++
1129   // Tmax
1130   //+++++++++++++++++++++++++++++
1131 
1132   HistNumBadChanDepth[5][1][1] = (TH1F *)hfile->Get("h_sumTSmaxAperLS1");
1133   HistNumBadChanDepth[5][1][2] = (TH1F *)hfile->Get("h_sumTSmaxAperLS2");
1134 
1135   HistNumBadChanDepth[5][2][1] = (TH1F *)hfile->Get("h_sumTSmaxAperLS3");
1136   HistNumBadChanDepth[5][2][2] = (TH1F *)hfile->Get("h_sumTSmaxAperLS4");
1137   HistNumBadChanDepth[5][2][3] = (TH1F *)hfile->Get("h_sumTSmaxAperLS5");
1138 
1139   HistNumBadChanDepth[5][3][4] = (TH1F *)hfile->Get("h_sumTSmaxAperLS8");
1140 
1141   HistNumBadChanDepth[5][4][1] = (TH1F *)hfile->Get("h_sumTSmaxAperLS6");
1142   HistNumBadChanDepth[5][4][2] = (TH1F *)hfile->Get("h_sumTSmaxAperLS7");
1143 
1144   HistNumBadChanFull[5] = (TH1F *)HistNumBadChanDepth[5][1][1]->Clone();
1145 
1146   HistCutNumBadChanDepth[5][1][1] = (TH1F *)hfile->Get("h_sumCutTSmaxAperLS1");
1147   HistCutNumBadChanDepth[5][1][2] = (TH1F *)hfile->Get("h_sumCutTSmaxAperLS2");
1148 
1149   HistCutNumBadChanDepth[5][2][1] = (TH1F *)hfile->Get("h_sumCutTSmaxAperLS3");
1150   HistCutNumBadChanDepth[5][2][2] = (TH1F *)hfile->Get("h_sumCutTSmaxAperLS4");
1151   HistCutNumBadChanDepth[5][2][3] = (TH1F *)hfile->Get("h_sumCutTSmaxAperLS5");
1152 
1153   HistCutNumBadChanDepth[5][3][4] = (TH1F *)hfile->Get("h_sumCutTSmaxAperLS8");
1154 
1155   HistCutNumBadChanDepth[5][4][1] = (TH1F *)hfile->Get("h_sumCutTSmaxAperLS6");
1156   HistCutNumBadChanDepth[5][4][2] = (TH1F *)hfile->Get("h_sumCutTSmaxAperLS7");
1157 
1158   HistNumChanDepth[5][1][1] = (TH1F *)hfile->Get("h_sum0TSmaxAperLS1");
1159   HistNumChanDepth[5][1][2] = (TH1F *)hfile->Get("h_sum0TSmaxAperLS2");
1160 
1161   HistNumChanDepth[5][2][1] = (TH1F *)hfile->Get("h_sum0TSmaxAperLS3");
1162   HistNumChanDepth[5][2][2] = (TH1F *)hfile->Get("h_sum0TSmaxAperLS4");
1163   HistNumChanDepth[5][2][3] = (TH1F *)hfile->Get("h_sum0TSmaxAperLS5");
1164 
1165   HistNumChanDepth[5][3][4] = (TH1F *)hfile->Get("h_sum0TSmaxAperLS8");
1166 
1167   HistNumChanDepth[5][4][1] = (TH1F *)hfile->Get("h_sum0TSmaxAperLS6");
1168   HistNumChanDepth[5][4][2] = (TH1F *)hfile->Get("h_sum0TSmaxAperLS7");
1169 
1170   HistNumChanFull[5] = (TH1F *)HistNumChanDepth[5][1][1]->Clone();
1171 
1172   for (int test = 0; test <= 5; test++) {  //Test: =0(CapIdErrors), =1(Amplitude), =2...
1173     for (int sub = 1; sub <= 4; sub++) {   //Subdetector: 1-HB, 2-HE, 3-HO, 4-HF
1174       if (sub == 1)
1175         cHE->Divide(2, 1);  //HB
1176       if (sub == 2 && test != 1)
1177         cHE->Divide(3, 1);  //HE
1178       if (sub == 2 && test == 1) {
1179         cNine->Clear();
1180         cNine->Divide(3, 3);
1181       }  //HE upgrade with new depthes 4,5,6,7 for Amplitude test only
1182       if (sub == 3)
1183         cHB->Divide(1, 1);  //HO
1184       if (sub == 4 && test != 1)
1185         cHE->Divide(2, 1);  //HF
1186       if (sub == 4 && test == 1) {
1187         cFour1->Clear();
1188         cFour1->Divide(2, 2);
1189       }  // HF upgrade with new depthes 3 and 4 for Amplitude test only
1190 
1191       int kkkkkkmax = k_max[sub];
1192       if ((sub == 4 || sub == 2) && test == 1)
1193         kkkkkkmax = k_maxHFupgrade[sub];
1194       for (int k = k_min[sub]; k <= kkkkkkmax; k++) {  //Depth
1195         if (sub == 1)
1196           cHE->cd(k);  //HB
1197         if (sub == 2 && test != 1)
1198           cHE->cd(k);  //HE
1199         if (sub == 2 && test == 1)
1200           cNine->cd(k);  //HE upgrade with new depthes 4,5,6,7 for Amplitude test only
1201         if (sub == 3)
1202           cHB->cd(k - 3);  //HO
1203         if (sub == 4 && test != 1)
1204           cHE->cd(k);  //HF
1205         if (sub == 4 && test == 1)
1206           cFour1->cd(k);  // HF upgrade with new depthes 3 and 4 for Amplitude test only
1207         gPad->SetGridy();
1208         gPad->SetGridx();
1209         //                gPad->SetLogy();
1210 
1211         if (sub == 1 && k == 1) {
1212         } else {
1213           // use "else" because ...Full[test] are filled by estimastor for sub==1 && k== 1 at initialization of ...Full[test] variables
1214           for (int x = 1; x <= HistNumBadChanFull[test]->GetXaxis()->GetNbins(); x++) {
1215             double ccc1 = HistNumBadChanDepth[test][sub][k]->GetBinContent(x);
1216             HistNumBadChanFull[test]->SetBinContent(x, HistNumBadChanFull[test]->GetBinContent(x) + ccc1);
1217             double ccc2 = HistNumChanDepth[test][sub][k]->GetBinContent(x);
1218             HistNumChanFull[test]->SetBinContent(x, HistNumChanFull[test]->GetBinContent(x) + ccc2);
1219           }
1220         }  //end x
1221 
1222         // !!!!!!     change the sense of HistNumBadChanDepth: now it's averaged values(estimators)
1223         HistNumBadChanDepth[test][sub][k]->Divide(
1224             HistNumBadChanDepth[test][sub][k], HistNumChanDepth[test][sub][k], 1, 1, "B");
1225         // errors abnulling:
1226         for (int x = 1; x <= HistNumBadChanDepth[test][sub][k]->GetXaxis()->GetNbins(); x++) {
1227           HistNumBadChanDepth[test][sub][k]->SetBinError(float(x), 0.01);
1228         }
1229 
1230         //      int myMaxLum= HistNumBadChanDepth[test][sub][k]->GetBinContent(HistNumBadChanDepth[test][sub][k]->GetMaximumBin());
1231         //      cout<<"********************>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     myMaxLum = "<<myMaxLum<<"        MaxLum = "<<MaxLum<<endl;
1232         HistNumBadChanDepth[test][sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1233 
1234         //   //    //   //   //   //   //   //   //   //   //   //   //   //   //   //   //  //
1235         HistNumBadChanDepth[test][sub][k]->SetMarkerStyle(20);
1236         HistNumBadChanDepth[test][sub][k]->SetMarkerSize(0.4);
1237         HistNumBadChanDepth[test][sub][k]->GetYaxis()->SetLabelSize(0.04);
1238         if (k == 1)
1239           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 1\b");
1240         if (k == 2)
1241           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 2\b");
1242         if (k == 3)
1243           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 3\b");
1244         if (k == 4)
1245           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 4\b");
1246         if (k == 5)
1247           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 5\b");
1248         if (k == 6)
1249           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 6\b");
1250         if (k == 7)
1251           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 7\b");
1252         HistNumBadChanDepth[test][sub][k]->SetXTitle("LS \b");
1253         if (test == 0)
1254           HistNumBadChanDepth[test][sub][k]->SetYTitle("<Number of bad channels> \b");
1255         if (test != 0)
1256           HistNumBadChanDepth[test][sub][k]->SetYTitle("Averaged estimator \b");
1257         HistNumBadChanDepth[test][sub][k]->SetMarkerColor(2);
1258         HistNumBadChanDepth[test][sub][k]->SetLineColor(0);
1259         //      gPad->SetGridx();
1260         gPad->SetLogy();
1261         gPad->SetGridy();
1262         gPad->SetGridx();
1263         //      if (test == 1) HistNumBadChanDepth[test][sub][k]->SetMinimum(0.1);
1264         HistNumBadChanDepth[test][sub][k]->Draw("Error");
1265         /*
1266           if (k == 1) HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 1\b");
1267           if (k == 2) HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 2\b");
1268           if (k == 3) HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 3\b");
1269           if (k == 4) HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 4\b");
1270           HistNumBadChanDepth[test][sub][k]->SetXTitle("LS \b");
1271           if (test == 0) HistNumBadChanDepth[test][sub][k]->SetYTitle("<Number of bad channels> \b");
1272           if (test != 0) HistNumBadChanDepth[test][sub][k]->SetYTitle("Averaged estimator \b");
1273           
1274           if (MaxLum<=1000){
1275           HistNumBadChanDepth[test][sub][k]->SetMarkerStyle(20);
1276           HistNumBadChanDepth[test][sub][k]->SetMarkerSize(0.5);    
1277           HistNumBadChanDepth[test][sub][k]->SetMarkerColor(2);
1278           HistNumBadChanDepth[test][sub][k]->SetLineColor(0);
1279           HistNumBadChanDepth[test][sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1280           HistNumBadChanDepth[test][sub][k]->Draw("P");
1281           }
1282           else{
1283           HistNumBadChanDepth[test][sub][k]->SetLineColor(2);
1284           HistNumBadChanDepth[test][sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1285           HistNumBadChanDepth[test][sub][k]->Draw("L");
1286           } 
1287         */
1288         /*
1289         float min_x[] = {0,10000};
1290         float min_y[] = {(float)(Cut0[test][sub][k]),(float)(Cut0[test][sub][k])};
1291         TGraph* MIN = new TGraph(2, min_x, min_y);
1292         MIN->SetLineStyle(2);
1293         MIN->SetLineColor(5);
1294         MIN->SetLineWidth(2 + 100*100);
1295         MIN->SetFillStyle(3005);
1296         MIN->SetFillColor(5);
1297         gPad->SetGridy();
1298         gPad->SetGridx();
1299         MIN->Draw("L");
1300 */
1301 
1302         if (sub == 1) {
1303           cHE->Modified();
1304         }
1305         if (sub == 2 && test != 1) {
1306           cHE->Modified();
1307         }
1308         if (sub == 2 && test == 1) {
1309           cNine->Modified();
1310         }  // HE upgrade
1311         if (sub == 3) {
1312           cHB->Modified();
1313         }
1314         if (sub == 4 && test != 1) {
1315           cHE->Modified();
1316         }
1317         if (sub == 4 && test == 1) {
1318           cFour1->Modified();
1319         }  // HF upgrade
1320 
1321       }  // k loop
1322 
1323       if (test == 0) {
1324         if (sub == 1) {
1325           cHE->Print("HistNBCMNHB.png");
1326           cHE->Clear();
1327         }
1328         if (sub == 2) {
1329           cHE->Print("HistNBCMNHE.png");
1330           cHE->Clear();
1331         }
1332         if (sub == 3) {
1333           cHB->Print("HistNBCMNHO.png");
1334           cHB->Clear();
1335         }
1336         if (sub == 4) {
1337           cHE->Print("HistNBCMNHF.png");
1338           cHE->Clear();
1339         }
1340       }
1341       // Amplitude:
1342       if (test == 1) {
1343         if (sub == 1) {
1344           cHE->Print("HistADCamplHB.png");
1345           cHE->Clear();
1346         }
1347         //      if (sub==2) {cHE->Print("HistADCamplHE.png"); cHE->Clear();}
1348         if (sub == 2) {
1349           cNine->Print("HistADCamplHE.png");
1350           cNine->Clear();
1351         }  // HE upgrade
1352         if (sub == 3) {
1353           cHB->Print("HistADCamplHO.png");
1354           cHB->Clear();
1355         }
1356         if (sub == 4) {
1357           cFour1->Print("HistADCamplHF.png");
1358           cFour1->Clear();
1359         }  // HF upgrade
1360       }
1361       if (test == 2) {
1362         if (sub == 1) {
1363           cHE->Print("HistWidthHB.png");
1364           cHE->Clear();
1365         }
1366         if (sub == 2) {
1367           cHE->Print("HistWidthHE.png");
1368           cHE->Clear();
1369         }
1370         if (sub == 3) {
1371           cHB->Print("HistWidthHO.png");
1372           cHB->Clear();
1373         }
1374         if (sub == 4) {
1375           cHE->Print("HistWidthHF.png");
1376           cHE->Clear();
1377         }
1378       }
1379       if (test == 3) {
1380         if (sub == 1) {
1381           cHE->Print("HistRatioHB.png");
1382           cHE->Clear();
1383         }
1384         if (sub == 2) {
1385           cHE->Print("HistRatioHE.png");
1386           cHE->Clear();
1387         }
1388         if (sub == 3) {
1389           cHB->Print("HistRatioHO.png");
1390           cHB->Clear();
1391         }
1392         if (sub == 4) {
1393           cHE->Print("HistRatioHF.png");
1394           cHE->Clear();
1395         }
1396       }
1397       if (test == 4) {
1398         if (sub == 1) {
1399           cHE->Print("HistTmeanHB.png");
1400           cHE->Clear();
1401         }
1402         if (sub == 2) {
1403           cHE->Print("HistTmeanHE.png");
1404           cHE->Clear();
1405         }
1406         if (sub == 3) {
1407           cHB->Print("HistTmeanHO.png");
1408           cHB->Clear();
1409         }
1410         if (sub == 4) {
1411           cHE->Print("HistTmeanHF.png");
1412           cHE->Clear();
1413         }
1414       }
1415       if (test == 5) {
1416         if (sub == 1) {
1417           cHE->Print("HistTmaxHB.png");
1418           cHE->Clear();
1419         }
1420         if (sub == 2) {
1421           cHE->Print("HistTmaxHE.png");
1422           cHE->Clear();
1423         }
1424         if (sub == 3) {
1425           cHB->Print("HistTmaxHO.png");
1426           cHB->Clear();
1427         }
1428         if (sub == 4) {
1429           cHE->Print("HistTmaxHF.png");
1430           cHE->Clear();
1431         }
1432       }
1433     }  // end sub
1434     ///////////////////////////////////////////// other cases:
1435     if (test == 1) {
1436       for (int x = 1; x <= HistNumChanFull[6]->GetXaxis()->GetNbins(); x++) {
1437         HistNumChanFull[6]->SetBinContent(x, 0.0);
1438         int depthsubcount = 0.;
1439         for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HO, 4-HF
1440           int kkkkkkmax = k_max[sub];
1441           if (sub == 4 || sub == 2)
1442             kkkkkkmax = k_maxHFupgrade[sub];
1443           for (int k = k_min[sub]; k <= kkkkkkmax; k++) {  //Depth
1444             // line below is temporary, just to avoid contribution of HEP(M)17 in depthes 4,5,6,7 but keep in depthes 1,2,3
1445             if (sub == 2 && k > 3)
1446               break;
1447             depthsubcount++;
1448             double ccc1 = HistNumBadChanDepth[test][sub][k]->GetBinContent(x);
1449             HistNumChanFull[6]->SetBinContent(x, HistNumChanFull[6]->GetBinContent(x) + ccc1);
1450           }  //depth
1451         }    //sub
1452         if (depthsubcount > 0.) {
1453           HistNumChanFull[6]->SetBinContent(x, (HistNumChanFull[6]->GetBinContent(x)) / depthsubcount);
1454         } else {
1455           HistNumChanFull[6]->SetBinContent(x, (HistNumChanFull[6]->GetBinContent(x)) / 8.);
1456         }
1457       }  //x
1458     }    //test=1
1459     ////////////  //////   //////  //////  ////// //////
1460     if (test != 1) {
1461       cHB->Divide(1, 1);
1462       cHB->cd(1);
1463     } else {
1464       cHE->Divide(2, 1);
1465       cHE->cd(1);
1466     }
1467     HistNumBadChanFull[test]->Divide(HistNumBadChanFull[test], HistNumChanFull[test], 1, 1, "B");
1468     TH1F *kfitq = new TH1F("kfitq", "", MaxLum, 1., MaxLum + 1.);
1469     int nx = kfitq->GetXaxis()->GetNbins();
1470     for (int i = 1; i <= nx; i++) {
1471       double ccc1 = HistNumBadChanFull[test]->GetBinContent(i);
1472       if (ccc1 > 0.) {
1473         kfitq->Fill(float(i), ccc1);
1474         kfitq->SetBinError(float(i), 0.01);
1475       }
1476     }
1477     kfitq->SetMarkerStyle(20);
1478     kfitq->SetMarkerSize(0.4);
1479     kfitq->GetYaxis()->SetLabelSize(0.04);
1480     if (test == 0)
1481       kfitq->SetTitle("Average Nbch for whole Hcal \b");
1482     if (test != 0)
1483       kfitq->SetTitle("Averaged estimator for whole Hcal \b");
1484     kfitq->SetXTitle("LS \b");
1485     if (test == 0)
1486       kfitq->SetYTitle("<Number of bad channels> \b");
1487     if (test != 0)
1488       kfitq->SetYTitle("Averaged estimator \b");
1489     kfitq->SetMarkerColor(2);
1490     kfitq->SetLineColor(0);
1491     gPad->SetGridx();
1492     kfitq->Draw("Error");
1493     /* 
1494        HistNumBadChanFull[test]->SetMarkerStyle(20);
1495        HistNumBadChanFull[test]->SetMarkerSize(0.8);
1496        HistNumBadChanFull[test]->SetTitle("Averaged estimator for whole Hcal \b");
1497        HistNumBadChanFull[test]->SetXTitle("LS \b");
1498        if (test == 0) HistNumBadChanFull[test]->SetYTitle("<Number of bad channels> \b");
1499        if (test != 0) HistNumBadChanFull[test]->SetYTitle("Averaged estimator \b");
1500        if (MaxLum<=1000){
1501        HistNumBadChanFull[test]->SetMarkerColor(1);
1502        HistNumBadChanFull[test]->SetLineColor(0);
1503        HistNumBadChanFull[test]->Draw("P"); 
1504        }
1505        else {
1506        HistNumBadChanFull[test]->SetLineColor(1);
1507        HistNumBadChanFull[test]->Draw("L"); 
1508        }
1509     */
1510     if (test == 1) {
1511       cHE->cd(2);
1512       TH1F *lpuio = new TH1F("lpuio", "", MaxLum, 1., MaxLum + 1.);
1513       int nx = lpuio->GetXaxis()->GetNbins();
1514       for (int i = 1; i <= nx; i++) {
1515         double ccc1 = HistNumChanFull[6]->GetBinContent(i);
1516         if (ccc1 > 0.) {
1517           lpuio->Fill(float(i), ccc1);
1518           lpuio->SetBinError(float(i), 0.01);
1519         }
1520       }
1521       lpuio->SetMarkerStyle(20);
1522       lpuio->SetMarkerSize(0.4);
1523       lpuio->GetYaxis()->SetLabelSize(0.04);
1524       lpuio->SetTitle("Mean of Averaged Amplitudes over all Hcal sub-detectors \b");
1525       lpuio->SetXTitle("LS \b");
1526       lpuio->SetYTitle("Mean of Averaged estimator \b");
1527       lpuio->SetMarkerColor(2);
1528       lpuio->SetLineColor(0);
1529       gPad->SetGridx();
1530       lpuio->Draw("Error");
1531     }
1532     if (test == 0) {
1533       cHB->Print("HistCapID.png");
1534       cHB->Clear();
1535     }
1536     if (test == 1) {
1537       cHE->Print("HistADCAmpl.png");
1538       cHE->Clear();
1539     }
1540     if (test == 2) {
1541       cHB->Print("HistWidth.png");
1542       cHB->Clear();
1543     }
1544     if (test == 3) {
1545       cHB->Print("HistRatio.png");
1546       cHB->Clear();
1547     }
1548     if (test == 4) {
1549       cHB->Print("HistTmean.png");
1550       cHB->Clear();
1551     }
1552     if (test == 5) {
1553       cHB->Print("HistTmax.png");
1554       cHB->Clear();
1555     }
1556 
1557     // clean-up
1558     if (kfitq)
1559       delete kfitq;
1560   }  //end test
1561 
1562   //================================================================================================================================
1563 
1564   //=======================================================================================================333
1565   //CapID 1-d histograms
1566 
1567   TH1F *HistAbnormNumBadChanDepth[5][5];  // 1d histogramm for subdet, depth
1568 
1569   //+++++++++++++++++++++++++++++
1570   // Abnormal Bad Channels Rate of Cap ID errors  first set of histograms
1571   //+++++++++++++++++++++++++++++
1572 
1573   HistAbnormNumBadChanDepth[1][1] = (TH1F *)hfile->Get("h_runnbadchannelsC_depth1_HB");
1574   HistAbnormNumBadChanDepth[1][2] = (TH1F *)hfile->Get("h_runnbadchannelsC_depth2_HB");
1575   HistAbnormNumBadChanDepth[2][1] = (TH1F *)hfile->Get("h_runnbadchannelsC_depth1_HE");
1576   HistAbnormNumBadChanDepth[2][2] = (TH1F *)hfile->Get("h_runnbadchannelsC_depth2_HE");
1577   HistAbnormNumBadChanDepth[2][3] = (TH1F *)hfile->Get("h_runnbadchannelsC_depth3_HE");
1578   HistAbnormNumBadChanDepth[3][4] = (TH1F *)hfile->Get("h_runnbadchannelsC_depth4_HO");
1579   HistAbnormNumBadChanDepth[4][1] = (TH1F *)hfile->Get("h_runnbadchannelsC_depth1_HF");
1580   HistAbnormNumBadChanDepth[4][2] = (TH1F *)hfile->Get("h_runnbadchannelsC_depth2_HF");
1581 
1582   for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
1583     if (sub == 1)
1584       cHB->Divide(2, 1);
1585     if (sub == 2)
1586       cHE->Divide(3, 1);
1587     if (sub == 3)
1588       cONE->Divide(1, 1);
1589     if (sub == 4)
1590       cHB->Divide(2, 1);
1591     for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
1592       if (sub == 1)
1593         cHB->cd(k);
1594       if (sub == 2)
1595         cHE->cd(k);
1596       if (sub == 3)
1597         cONE->cd(k - 3);
1598       if (sub == 4)
1599         cHB->cd(k);
1600       gPad->SetGridy();
1601       gPad->SetGridx();
1602       //  gPad->SetLogy();
1603       HistAbnormNumBadChanDepth[sub][k]->Divide(
1604           HistAbnormNumBadChanDepth[sub][k], HistNumChanDepth[0][sub][k], 1, 1, "B");
1605       if (k == 1)
1606         HistAbnormNumBadChanDepth[sub][k]->SetTitle("Depth 1\b");
1607       if (k == 2)
1608         HistAbnormNumBadChanDepth[sub][k]->SetTitle("Depth 2\b");
1609       if (k == 3)
1610         HistAbnormNumBadChanDepth[sub][k]->SetTitle("Depth 3\b");
1611       if (k == 4)
1612         HistAbnormNumBadChanDepth[sub][k]->SetTitle("Depth 4\b");
1613       HistAbnormNumBadChanDepth[sub][k]->SetXTitle("LS \b");
1614       HistAbnormNumBadChanDepth[sub][k]->SetYTitle("< Number of bad channels > \b");
1615       if (MaxLum <= 1000) {
1616         HistAbnormNumBadChanDepth[sub][k]->SetMarkerStyle(20);
1617         HistAbnormNumBadChanDepth[sub][k]->SetMarkerSize(0.5);
1618         HistAbnormNumBadChanDepth[sub][k]->SetMarkerColor(1);
1619         HistAbnormNumBadChanDepth[sub][k]->SetLineColor(0);
1620         HistAbnormNumBadChanDepth[sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1621         HistAbnormNumBadChanDepth[sub][k]->Draw("P");
1622       } else {
1623         HistAbnormNumBadChanDepth[sub][k]->SetLineColor(1);
1624         HistAbnormNumBadChanDepth[sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1625         HistAbnormNumBadChanDepth[sub][k]->Draw("L");
1626       }
1627     }
1628     if (sub == 1) {
1629       cHB->Print("Hist_CAPID_Abnorm_HB.png");
1630       cHB->Clear();
1631     }
1632     if (sub == 2) {
1633       cHE->Print("Hist_CAPID_Abnorm_HE.png");
1634       cHE->Clear();
1635     }
1636     if (sub == 3) {
1637       cONE->Print("Hist_CAPID_Abnorm_HO.png");
1638       cONE->Clear();
1639     }
1640     if (sub == 4) {
1641       cHB->Print("Hist_CAPID_Abnorm_HF.png");
1642       cHB->Clear();
1643     }
1644   }  // end sub
1645 
1646   //+++++++++++++++++++++++++++++
1647   // Portions of bad channels events identified by Cap ID errors   third set of histograms
1648   //+++++++++++++++++++++++++++++
1649 
1650   TH1F *HistPortBadEventsDepth[5][5];  // 1d histogramm for subdet, depth
1651 
1652   HistPortBadEventsDepth[1][1] = (TH1F *)hfile->Get("h_runbadrateC_depth1_HB");
1653   HistPortBadEventsDepth[1][2] = (TH1F *)hfile->Get("h_runbadrateC_depth2_HB");
1654   HistPortBadEventsDepth[2][1] = (TH1F *)hfile->Get("h_runbadrateC_depth1_HE");
1655   HistPortBadEventsDepth[2][2] = (TH1F *)hfile->Get("h_runbadrateC_depth2_HE");
1656   HistPortBadEventsDepth[2][3] = (TH1F *)hfile->Get("h_runbadrateC_depth3_HE");
1657   HistPortBadEventsDepth[3][4] = (TH1F *)hfile->Get("h_runbadrateC_depth4_HO");
1658   HistPortBadEventsDepth[4][1] = (TH1F *)hfile->Get("h_runbadrateC_depth1_HF");
1659   HistPortBadEventsDepth[4][2] = (TH1F *)hfile->Get("h_runbadrateC_depth2_HF");
1660 
1661   TH1F *HistNumRateDepth[5][5];
1662   HistNumRateDepth[1][1] = (TH1F *)hfile->Get("h_runbadrate0_depth1_HB");
1663   HistNumRateDepth[1][2] = (TH1F *)hfile->Get("h_runbadrate0_depth2_HB");
1664   HistNumRateDepth[2][1] = (TH1F *)hfile->Get("h_runbadrate0_depth1_HE");
1665   HistNumRateDepth[2][2] = (TH1F *)hfile->Get("h_runbadrate0_depth2_HE");
1666   HistNumRateDepth[2][3] = (TH1F *)hfile->Get("h_runbadrate0_depth3_HE");
1667   HistNumRateDepth[3][4] = (TH1F *)hfile->Get("h_runbadrate0_depth4_HO");
1668   HistNumRateDepth[4][1] = (TH1F *)hfile->Get("h_runbadrate0_depth1_HF");
1669   HistNumRateDepth[4][2] = (TH1F *)hfile->Get("h_runbadrate0_depth2_HF");
1670 
1671   for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
1672     if (sub == 1)
1673       cHB->Divide(2, 1);
1674     if (sub == 2)
1675       cHE->Divide(3, 1);
1676     if (sub == 3)
1677       cONE->Divide(1, 1);
1678     if (sub == 4)
1679       cHB->Divide(2, 1);
1680     for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
1681       if (sub == 1)
1682         cHB->cd(k);
1683       if (sub == 2)
1684         cHE->cd(k);
1685       if (sub == 3)
1686         cONE->cd(k - 3);
1687       if (sub == 4)
1688         cHB->cd(k);
1689       gPad->SetGridy();
1690       gPad->SetGridx();
1691       //  gPad->SetLogy();
1692       HistPortBadEventsDepth[sub][k]->Divide(HistPortBadEventsDepth[sub][k], HistNumRateDepth[sub][k], 1, 1, "B");
1693 
1694       if (k == 1)
1695         HistPortBadEventsDepth[sub][k]->SetTitle("Depth 1\b");
1696       if (k == 2)
1697         HistPortBadEventsDepth[sub][k]->SetTitle("Depth 2\b");
1698       if (k == 3)
1699         HistPortBadEventsDepth[sub][k]->SetTitle("Depth 3\b");
1700       if (k == 4)
1701         HistPortBadEventsDepth[sub][k]->SetTitle("Depth 4\b");
1702       HistPortBadEventsDepth[sub][k]->SetXTitle("LS \b");
1703       HistPortBadEventsDepth[sub][k]->SetYTitle("< Number of bad channels > \b");
1704       if (MaxLum <= 1000) {
1705         HistPortBadEventsDepth[sub][k]->SetMarkerStyle(20);
1706         HistPortBadEventsDepth[sub][k]->SetMarkerSize(0.5);
1707         HistPortBadEventsDepth[sub][k]->SetMarkerColor(1);
1708         HistPortBadEventsDepth[sub][k]->SetLineColor(0);
1709         HistPortBadEventsDepth[sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1710         HistPortBadEventsDepth[sub][k]->Draw("P");
1711       } else {
1712         HistPortBadEventsDepth[sub][k]->SetLineColor(1);
1713         HistPortBadEventsDepth[sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1714         HistPortBadEventsDepth[sub][k]->Draw("L");
1715       }
1716     }
1717     if (sub == 1) {
1718       cHB->Print("HistPortHB.png");
1719       cHB->Clear();
1720     }
1721     if (sub == 2) {
1722       cHE->Print("HistPortHE.png");
1723       cHE->Clear();
1724     }
1725     if (sub == 3) {
1726       cONE->Print("HistPortHO.png");
1727       cONE->Clear();
1728     }
1729     if (sub == 4) {
1730       cHB->Print("HistPortHF.png");
1731       cHB->Clear();
1732     }
1733   }  // end sub
1734 
1735   //================================================================================================================================
1736 
1737   //+++++++++++++++++++++++++++++
1738   // Number of bad channels events identified by Cap ID errors   third set of histograms
1739   //+++++++++++++++++++++++++++++
1740 
1741   TH1F *HistNBadChsDepth[5][5];  // 1d histogramm for subdet, depth
1742 
1743   HistNBadChsDepth[1][1] = (TH1F *)hfile->Get("h_nbadchannels_depth1_HB");
1744   HistNBadChsDepth[1][2] = (TH1F *)hfile->Get("h_nbadchannels_depth2_HB");
1745   HistNBadChsDepth[2][1] = (TH1F *)hfile->Get("h_nbadchannels_depth1_HE");
1746   HistNBadChsDepth[2][2] = (TH1F *)hfile->Get("h_nbadchannels_depth2_HE");
1747   HistNBadChsDepth[2][3] = (TH1F *)hfile->Get("h_nbadchannels_depth3_HE");
1748   HistNBadChsDepth[3][4] = (TH1F *)hfile->Get("h_nbadchannels_depth4_HO");
1749   HistNBadChsDepth[4][1] = (TH1F *)hfile->Get("h_nbadchannels_depth1_HF");
1750   HistNBadChsDepth[4][2] = (TH1F *)hfile->Get("h_nbadchannels_depth2_HF");
1751 
1752   for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
1753     if (sub == 1)
1754       cHB->Divide(2, 1);
1755     if (sub == 2)
1756       cHE->Divide(3, 1);
1757     if (sub == 3)
1758       cONE->Divide(1, 1);
1759     if (sub == 4)
1760       cHB->Divide(2, 1);
1761     for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
1762       if (sub == 1)
1763         cHB->cd(k);
1764       if (sub == 2)
1765         cHE->cd(k);
1766       if (sub == 3)
1767         cONE->cd(k - 3);
1768       if (sub == 4)
1769         cHB->cd(k);
1770       gPad->SetGridy();
1771       gPad->SetGridx();
1772       gPad->SetLogy();
1773 
1774       if (k == 1)
1775         HistNBadChsDepth[sub][k]->SetTitle("Depth 1\b");
1776       if (k == 2)
1777         HistNBadChsDepth[sub][k]->SetTitle("Depth 2\b");
1778       if (k == 3)
1779         HistNBadChsDepth[sub][k]->SetTitle("Depth 3\b");
1780       if (k == 4)
1781         HistNBadChsDepth[sub][k]->SetTitle("Depth 4\b");
1782       HistNBadChsDepth[sub][k]->SetXTitle("Number of bad channels\b");
1783       HistNBadChsDepth[sub][k]->SetYTitle("Number of events\b");
1784       //         HistNBadChsDepth[sub][k]->SetMarkerStyle(20);
1785       //         HistNBadChsDepth[sub][k]->SetMarkerSize(0.5);
1786       //         HistNBadChsDepth[sub][k]->SetMarkerColor(1);
1787       //         HistNBadChsDepth[sub][k]->SetLineColor(0);
1788       HistNBadChsDepth[sub][k]->Draw("");
1789     }
1790     if (sub == 1) {
1791       cHB->Print("HistNBadChsHB.png");
1792       cHB->Clear();
1793     }
1794     if (sub == 2) {
1795       cHE->Print("HistNBadChsHE.png");
1796       cHE->Clear();
1797     }
1798     if (sub == 3) {
1799       cONE->Print("HistNBadChsHO.png");
1800       cONE->Clear();
1801     }
1802     if (sub == 4) {
1803       cHB->Print("HistNBadChsHF.png");
1804       cHB->Clear();
1805     }
1806   }  // end sub
1807 
1808   //====================================================================== HB                    :
1809   //====================================================================== HB                    :
1810   //====================================================================== HB                    :
1811   // Special test of errors type A and B in HB
1812   // AZ 08.02.2016
1813 
1814   int flagErrAB_HB[2];
1815   flagErrAB_HB[0] = -1;
1816   flagErrAB_HB[1] = -1;
1817   double avedelta_HB = 0.;
1818   int lastLumiBin_HB = -1;
1819   int LSofFirstErrB_HB = -1;
1820   {
1821     const int specCountA = 4;
1822     const int specColors[specCountA] = {1, 2, 3, 4};
1823     const TString hnames[specCountA][2] = {{"h_sumADCAmplperLS1_P1", "h_sum0ADCAmplperLS1_P1"},
1824                                            {"h_sumADCAmplperLS1_P2", "h_sum0ADCAmplperLS1_P2"},
1825                                            {"h_sumADCAmplperLS1_M1", "h_sum0ADCAmplperLS1_M1"},
1826                                            {"h_sumADCAmplperLS1_M2", "h_sum0ADCAmplperLS1_M2"}};
1827 
1828     std::vector<TH1F *> hV;
1829     THStack *hs = new THStack("hs", "ADCAmplerLS1");
1830     cHB->Clear();
1831     //    cHB->cd();
1832     cHB->Divide(2, 1);
1833     cHB->cd(1);
1834 
1835     ///////////////////////////////////////////////////////////////////////////
1836     for (int i = 0; i < specCountA; i++) {
1837       if (1)
1838         std::cout << "debugger: errA_HB : get histos for i=" << i << " " << hnames[i][0] << " and " << hnames[i][1]
1839                   << "\n";
1840       TH1F *h1 = (TH1F *)hfile->Get(hnames[i][0]);
1841       TH1F *h0 = (TH1F *)hfile->Get(hnames[i][1]);
1842       if (!h1 || !h0) {
1843         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
1844         ptext->AddText("Missing histo");
1845         if (!h1) {
1846           std::cout << "\tfailed to get " << hnames[i][0] << "\n";
1847           ptext->AddText(hnames[i][0]);
1848         }
1849         if (!h0) {
1850           std::cout << "\tfailed to get " << hnames[i][1] << "\n";
1851           ptext->AddText(hnames[i][1]);
1852         }
1853         ptext->Draw();
1854         continue;
1855       }
1856       TH1F *hERT1orig = (TH1F *)h1->Clone(Form("ERT1orig_%d", i));
1857       hERT1orig->Divide(h1, h0, 1, 1, "B");
1858 
1859       if ((lastLumiBin_HB < 0) && (i == 0)) {
1860         for (int ibin = hERT1orig->GetNbinsX(); ibin >= 1; ibin--) {
1861           if (hERT1orig->GetBinContent(ibin) == 0)
1862             lastLumiBin_HB = ibin;
1863           else
1864             break;
1865         }
1866         lastLumiBin_HB += 3;  // show more bins
1867         if (lastLumiBin_HB >= hERT1orig->GetNbinsX())
1868           lastLumiBin_HB = -1;
1869       }
1870       TH1F *hERT1 = NULL;
1871       if (lastLumiBin_HB > 1) {
1872         if (!copyContents(&hERT1, Form("ERT1_%d", i), "", hERT1orig, lastLumiBin_HB)) {
1873           std::cout << "code failed" << std::endl;
1874           gSystem->Exit(1);
1875         }
1876       } else
1877         hERT1 = hERT1orig;
1878 
1879       hERT1->GetXaxis()->SetTitle("<ADCAmpl> per LS HB: black-P1, red-P2,green-M1,blue-M2");
1880       hV.push_back(hERT1);
1881       hERT1->SetMarkerStyle(20);
1882       hERT1->SetMarkerSize(0.4);
1883       hERT1->SetXTitle("<A>(ev.in LS & ch.) - HB P1     -    iLS \b");
1884       hERT1->SetMarkerColor(specColors[i]);
1885       hERT1->SetLineColor(0);
1886       hs->Add(hERT1);
1887       delete h1;
1888       delete h0;
1889       if (hERT1 != hERT1orig)
1890         delete hERT1orig;
1891     }  /////////////////////////////////////////////////////////////////////////
1892     hs->Draw("LPE1 nostack");
1893     cHB->Update();  // activate the axes
1894     hs->GetXaxis()->SetTitle("<A> per LS: black-P1, red-P2,green-M1,blue-M2");
1895     hs->Draw("LPE1 nostack");
1896     gPad->SetGridy();
1897     /////////////////////////////////////////////////////////////////////////////////////////
1898 
1899     // AZ corrections 08.02.2016
1900     cHB->cd(2);
1901     TH1F *diff = new TH1F("diff", "", 100, 0., 4.);
1902 
1903     if (int(hV.size()) == specCountA) {
1904       flagErrAB_HB[0] = 0;  // If we have the expected number of histograms, set the flag
1905       double sumdelta = 0.;
1906       int nnndelta = 0;
1907       for (int ibin = 1; ibin <= hV[0]->GetNbinsX(); ibin++) {
1908         double delta = 0.;
1909         double maxdelta = 0.;
1910         for (unsigned int i = 0; i < hV.size(); i++) {
1911           const TH1F *hi = hV[i];
1912           for (unsigned int j = 1; j < hV.size(); j++) {
1913             const TH1F *hj = hV[j];
1914             delta = fabs(hi->GetBinContent(ibin) - hj->GetBinContent(ibin));
1915             if (delta > maxdelta)
1916               maxdelta = delta;
1917           }  //for
1918         }    //for
1919         if (maxdelta > 0.) {
1920           diff->Fill(maxdelta);
1921           sumdelta += maxdelta;
1922           nnndelta++;
1923         }
1924       }  //for ibin
1925       //      avedelta_HB = sumdelta/hV[0]->GetNbinsX();
1926       avedelta_HB = sumdelta / nnndelta;
1927       std::cout << "******************>>>>>>      ErrA_HB:  avedelta_HB = " << avedelta_HB << std::endl;
1928       if (avedelta_HB > 0.24 || (avedelta_HB < 0.14 && avedelta_HB > 0.)) {
1929         flagErrAB_HB[0] = 1;
1930       }  //if
1931     }    //hV.size
1932     diff->SetMarkerStyle(20);
1933     diff->SetMarkerSize(0.8);
1934     diff->SetXTitle("max difference \b");
1935     diff->SetMarkerColor(2);
1936     diff->SetLineColor(0);
1937     gPad->SetGridx();
1938     gPad->SetLogy();
1939     diff->Draw("Error");
1940     /////////////////////////////////////////////////////////////////////////
1941     cHB->Update();
1942     cHB->Print("HistErrA_HB.png");
1943     cHB->Clear();
1944     /////////////////////////////////////////////////////////////////////////
1945 
1946     // clean-up
1947     if (diff)
1948       delete diff;
1949     for (unsigned int i = 0; i < hV.size(); i++)
1950       delete hV[i];
1951   }  // ErrorA in HB
1952 
1953   ///////////////////////////////////////////////////////////////////////// errors B:
1954 
1955   {  // errors type B
1956     const int specCountB = 4;
1957     const TString hnames[specCountB][2] = {{"h_2DsumErrorBLS1", "h_2D0sumErrorBLS1"},
1958                                            {"h_sumErrorBperLS1", "h_sum0ErrorBperLS1"},
1959                                            {"h_2DsumErrorBLS2", "h_2D0sumErrorBLS2"},
1960                                            {"h_sumErrorBperLS2", "h_sum0ErrorBperLS2"}};
1961 
1962     for (int depth = 1; depth <= 2; depth++) {
1963       cHB->Clear();
1964       cHB->Divide(2, 1);
1965       cHB->cd(1);
1966 
1967       TH1F *hRate2orig = NULL;
1968       TH2F *h2Cefz6 = NULL;
1969       TString hname1 = hnames[2 * depth - 2][0];
1970       TString hname0 = hnames[2 * depth - 2][1];
1971       TH2F *twod1 = (TH2F *)hfile->Get(hname1);
1972       TH2F *twod0 = (TH2F *)hfile->Get(hname0);
1973       if (1)
1974         std::cout << "debugger: errB_HB depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
1975       if (!twod1 || !twod0) {
1976         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
1977         ptext->AddText("Missing histos");
1978         if (!twod1) {
1979           std::cout << "\tfailed to get " << hname1 << "\n";
1980           ptext->AddText(hname1);
1981         }
1982         if (!twod0) {
1983           std::cout << "\tfailed to get " << hname0 << "\n";
1984           ptext->AddText(hname0);
1985         }
1986         ptext->Draw();
1987       } else {
1988         h2Cefz6 = (TH2F *)twod1->Clone(Form("Cefz6_%d", depth));
1989         h2Cefz6->SetTitle(Form("HB Depth %d \b", depth));
1990         h2Cefz6->Divide(twod1, twod0, 1, 1, "B");
1991 
1992         gPad->SetGridy();
1993         gPad->SetGridx();
1994         gPad->SetLogz();
1995         h2Cefz6->SetTitle(Form("Depth %d \b", depth));
1996         h2Cefz6->SetMarkerStyle(20);
1997         h2Cefz6->SetMarkerSize(0.4);
1998         //  h2Cefz6->GetZaxis()->SetLabelSize(0.04);
1999         h2Cefz6->SetXTitle("#eta \b");
2000         h2Cefz6->SetYTitle("#phi \b");
2001         h2Cefz6->SetZTitle(Form("<ErrorB>  - HB Depth%d \b", depth));
2002         h2Cefz6->SetMarkerColor(2);
2003         h2Cefz6->SetLineColor(2);
2004         h2Cefz6->Draw("COLZ");
2005 
2006         delete twod1;
2007         delete twod0;
2008       }  // histos ok
2009 
2010       cHB->cd(2);
2011       hname1 = hnames[2 * depth - 1][0];
2012       hname0 = hnames[2 * depth - 1][1];
2013       TH1F *h1 = (TH1F *)hfile->Get(hname1);
2014       TH1F *h0 = (TH1F *)hfile->Get(hname0);
2015       if (1)
2016         std::cout << "errB_HB depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2017       if (!h1 || !h0) {
2018         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2019         ptext->AddText("Missing histo");
2020         if (!h1) {
2021           std::cout << "\tfailed to get " << hname1 << "\n";
2022           ptext->AddText(hname1);
2023         }
2024         if (!h0) {
2025           std::cout << "\tfailed to get " << hname0 << "\n";
2026           ptext->AddText(hname0);
2027         }
2028         ptext->Draw();
2029       } else {
2030         gPad->SetGridx();
2031         gPad->SetGridy();
2032         //  gPad->SetLogy();
2033         hRate2orig = (TH1F *)h1->Clone(Form("Rate2orig_%d", depth));
2034         hRate2orig->Divide(h1, h0, 1, 1, "B");
2035 
2036         TH1F *hRate2 = NULL;
2037         if (lastLumiBin_HB > 1) {
2038           if (!copyContents(&hRate2, Form("Rate2_%d", depth), "", hRate2orig, lastLumiBin_HB)) {
2039             std::cout << "code failed" << std::endl;
2040             gSystem->Exit(1);
2041           }
2042         } else
2043           hRate2 = hRate2orig;
2044 
2045         hRate2->SetTitle(Form("Depth %d \b", depth));
2046         hRate2->SetMarkerStyle(20);
2047         hRate2->SetMarkerSize(0.8);
2048         //  hRate2->GetZaxis()->SetLabelSize(0.04);
2049         hRate2->SetXTitle(Form("<ErrorB>(ev.in LS & ch.) - HB depth%d -    iLS \b", depth));
2050         hRate2->SetMarkerColor(2);
2051         hRate2->SetLineColor(0);
2052         hRate2->Draw("Error");
2053 
2054         if (LSofFirstErrB_HB == -1) {
2055           int nx = hRate2->GetXaxis()->GetNbins();
2056           for (int i = 1; i <= nx; i++) {
2057             double ccc1 = hRate2->GetBinContent(i);
2058             if (ccc1 > 0.) {
2059               cout << "****************>>>>>>>>>>> ErrB_HB bad LS start at iLS = " << i << " with rate = " << ccc1
2060                    << endl;
2061               LSofFirstErrB_HB = i;
2062               break;
2063             }
2064           }
2065         }
2066 
2067         delete h1;
2068         delete h0;
2069         if (hRate2 != hRate2orig) {
2070           delete hRate2orig;
2071           hRate2orig = hRate2;
2072         }
2073       }
2074 
2075       cHB->Update();
2076       cHB->Print(Form("HistErrB_HB_%d.png", depth));
2077       cHB->Clear();
2078       if (h2Cefz6)
2079         delete h2Cefz6;
2080       if (hRate2orig)
2081         delete hRate2orig;
2082     }
2083   }  // ErrorsB in HB
2084 
2085   //====================================================================== HE                    :
2086   //====================================================================== HE                    :
2087   //====================================================================== HE                    :
2088   // Special test of errors type A and B in HE
2089   // AZ 08.02.2016
2090 
2091   int flagErrAB_HE[2];
2092   flagErrAB_HE[0] = -1;
2093   flagErrAB_HE[1] = -1;
2094   double avedelta_HE = 0.;
2095   int lastLumiBin_HE = -1;
2096   int LSofFirstErrB_HE = -1;
2097   {
2098     const int specCountA = 4;
2099     const int specColors[specCountA] = {1, 2, 3, 4};
2100     const TString hnames[specCountA][2] = {{"h_sumADCAmplperLS3_P1", "h_sum0ADCAmplperLS3_P1"},
2101                                            {"h_sumADCAmplperLS3_P2", "h_sum0ADCAmplperLS3_P2"},
2102                                            {"h_sumADCAmplperLS3_M1", "h_sum0ADCAmplperLS3_M1"},
2103                                            {"h_sumADCAmplperLS3_M2", "h_sum0ADCAmplperLS3_M2"}};
2104 
2105     std::vector<TH1F *> hV;
2106     THStack *hs = new THStack("hs", "ADCAmplerLS1");
2107     cHB->Clear();
2108     //    cHB->cd();
2109     cHB->Divide(2, 1);
2110     cHB->cd(1);
2111 
2112     ///////////////////////////////////////////////////////////////////////////
2113     for (int i = 0; i < specCountA; i++) {
2114       if (1)
2115         std::cout << "debugger: errA_HE : get histos for i=" << i << " " << hnames[i][0] << " and " << hnames[i][1]
2116                   << "\n";
2117       TH1F *h1 = (TH1F *)hfile->Get(hnames[i][0]);
2118       TH1F *h0 = (TH1F *)hfile->Get(hnames[i][1]);
2119       if (!h1 || !h0) {
2120         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2121         ptext->AddText("Missing histo");
2122         if (!h1) {
2123           std::cout << "\tfailed to get " << hnames[i][0] << "\n";
2124           ptext->AddText(hnames[i][0]);
2125         }
2126         if (!h0) {
2127           std::cout << "\tfailed to get " << hnames[i][1] << "\n";
2128           ptext->AddText(hnames[i][1]);
2129         }
2130         ptext->Draw();
2131         continue;
2132       }
2133       TH1F *hERT1orig = (TH1F *)h1->Clone(Form("ERT1orig_%d", i));
2134       hERT1orig->Divide(h1, h0, 1, 1, "B");
2135 
2136       if ((lastLumiBin_HE < 0) && (i == 0)) {
2137         for (int ibin = hERT1orig->GetNbinsX(); ibin >= 1; ibin--) {
2138           if (hERT1orig->GetBinContent(ibin) == 0)
2139             lastLumiBin_HE = ibin;
2140           else
2141             break;
2142         }
2143         lastLumiBin_HE += 3;  // show more bins
2144         if (lastLumiBin_HE >= hERT1orig->GetNbinsX())
2145           lastLumiBin_HE = -1;
2146       }
2147       TH1F *hERT1 = NULL;
2148       if (lastLumiBin_HE > 1) {
2149         if (!copyContents(&hERT1, Form("ERT1_%d", i), "", hERT1orig, lastLumiBin_HE)) {
2150           std::cout << "code failed" << std::endl;
2151           gSystem->Exit(1);
2152         }
2153       } else
2154         hERT1 = hERT1orig;
2155 
2156       hERT1->GetXaxis()->SetTitle("<ADCAmpl> per LS HE: black-P1, red-P2,green-M1,blue-M2");
2157       hV.push_back(hERT1);
2158       hERT1->SetMarkerStyle(20);
2159       hERT1->SetMarkerSize(0.4);
2160       hERT1->SetXTitle("<A>(ev.in LS & ch.) - HE P1     -    iLS \b");
2161       hERT1->SetMarkerColor(specColors[i]);
2162       hERT1->SetLineColor(0);
2163       hs->Add(hERT1);
2164       delete h1;
2165       delete h0;
2166       if (hERT1 != hERT1orig)
2167         delete hERT1orig;
2168     }  /////////////////////////////////////////////////////////////////////////
2169     hs->Draw("LPE1 nostack");
2170     cHB->Update();  // activate the axes
2171     hs->GetXaxis()->SetTitle("<A> per LS: black-P1, red-P2,green-M1,blue-M2");
2172     hs->Draw("LPE1 nostack");
2173     gPad->SetGridy();
2174     /////////////////////////////////////////////////////////////////////////////////////////
2175 
2176     // AZ corrections 08.02.2016
2177     cHB->cd(2);
2178     TH1F *diff = new TH1F("diff", "", 100, 0., 4.);
2179 
2180     if (int(hV.size()) == specCountA) {
2181       flagErrAB_HE[0] = 0;  // If we have the expected number of histograms, set the flag
2182       double sumdelta = 0.;
2183       int nnndelta = 0;
2184       for (int ibin = 1; ibin <= hV[0]->GetNbinsX(); ibin++) {
2185         double delta = 0.;
2186         double maxdelta = 0.;
2187         for (unsigned int i = 0; i < hV.size(); i++) {
2188           const TH1F *hi = hV[i];
2189           for (unsigned int j = 1; j < hV.size(); j++) {
2190             const TH1F *hj = hV[j];
2191             delta = fabs(hi->GetBinContent(ibin) - hj->GetBinContent(ibin));
2192             if (delta > maxdelta)
2193               maxdelta = delta;
2194           }  //for
2195         }    //for
2196         if (maxdelta > 0.) {
2197           diff->Fill(maxdelta);
2198           sumdelta += maxdelta;
2199           nnndelta++;
2200         }
2201       }  //for ibin
2202       //      avedelta_HE = sumdelta/hV[0]->GetNbinsX();
2203       avedelta_HE = sumdelta / nnndelta;
2204       std::cout << "******************>>>>>>      ErrA_HE:  avedelta_HE = " << avedelta_HE << std::endl;
2205       if (avedelta_HE > 1.1 || (avedelta_HE < 0.5 && avedelta_HE > 0.)) {
2206         flagErrAB_HE[0] = 1;
2207       }  //if
2208     }    //hV.size
2209     diff->SetMarkerStyle(20);
2210     diff->SetMarkerSize(0.8);
2211     diff->SetXTitle("max difference \b");
2212     diff->SetMarkerColor(2);
2213     diff->SetLineColor(0);
2214     gPad->SetGridx();
2215     gPad->SetLogy();
2216     diff->Draw("Error");
2217     /////////////////////////////////////////////////////////////////////////
2218     cHB->Update();
2219     cHB->Print("HistErrA_HE.png");
2220     cHB->Clear();
2221     /////////////////////////////////////////////////////////////////////////
2222 
2223     // clean-up
2224     if (diff)
2225       delete diff;
2226     for (unsigned int i = 0; i < hV.size(); i++)
2227       delete hV[i];
2228   }  // ErrorA in HE
2229 
2230   ///////////////////////////////////////////////////////////////////////// errors B:
2231 
2232   {  // errors type B
2233     const int specCountB = 6;
2234     const TString hnames[specCountB][2] = {{"h_2DsumErrorBLS3", "h_2D0sumErrorBLS3"},
2235                                            {"h_sumErrorBperLS3", "h_sum0ErrorBperLS3"},
2236                                            {"h_2DsumErrorBLS4", "h_2D0sumErrorBLS4"},
2237                                            {"h_sumErrorBperLS4", "h_sum0ErrorBperLS4"},
2238                                            {"h_2DsumErrorBLS5", "h_2D0sumErrorBLS5"},
2239                                            {"h_sumErrorBperLS5", "h_sum0ErrorBperLS5"}};
2240 
2241     for (int depth = 1; depth <= 3; depth++) {
2242       cHB->Clear();
2243       cHB->Divide(2, 1);
2244       cHB->cd(1);
2245 
2246       TH1F *hRate2orig = NULL;
2247       TH2F *h2Cefz6 = NULL;
2248       TString hname1 = hnames[2 * depth - 2][0];
2249       TString hname0 = hnames[2 * depth - 2][1];
2250       TH2F *twod1 = (TH2F *)hfile->Get(hname1);
2251       TH2F *twod0 = (TH2F *)hfile->Get(hname0);
2252       if (1)
2253         std::cout << "debugger: errB_HE depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2254       if (!twod1 || !twod0) {
2255         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2256         ptext->AddText("Missing histos");
2257         if (!twod1) {
2258           std::cout << "\tfailed to get " << hname1 << "\n";
2259           ptext->AddText(hname1);
2260         }
2261         if (!twod0) {
2262           std::cout << "\tfailed to get " << hname0 << "\n";
2263           ptext->AddText(hname0);
2264         }
2265         ptext->Draw();
2266       } else {
2267         h2Cefz6 = (TH2F *)twod1->Clone(Form("Cefz6_%d", depth));
2268         h2Cefz6->SetTitle(Form("HE Depth %d \b", depth));
2269         h2Cefz6->Divide(twod1, twod0, 1, 1, "B");
2270 
2271         gPad->SetGridy();
2272         gPad->SetGridx();
2273         gPad->SetLogz();
2274         h2Cefz6->SetTitle(Form("Depth %d \b", depth));
2275         h2Cefz6->SetMarkerStyle(20);
2276         h2Cefz6->SetMarkerSize(0.4);
2277         //  h2Cefz6->GetZaxis()->SetLabelSize(0.04);
2278         h2Cefz6->SetXTitle("#eta \b");
2279         h2Cefz6->SetYTitle("#phi \b");
2280         h2Cefz6->SetZTitle(Form("<ErrorB>  - HE Depth%d \b", depth));
2281         h2Cefz6->SetMarkerColor(2);
2282         h2Cefz6->SetLineColor(2);
2283         h2Cefz6->Draw("COLZ");
2284 
2285         delete twod1;
2286         delete twod0;
2287       }  // histos ok
2288 
2289       cHB->cd(2);
2290       hname1 = hnames[2 * depth - 1][0];
2291       hname0 = hnames[2 * depth - 1][1];
2292       TH1F *h1 = (TH1F *)hfile->Get(hname1);
2293       TH1F *h0 = (TH1F *)hfile->Get(hname0);
2294       if (1)
2295         std::cout << "errB_HE depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2296       if (!h1 || !h0) {
2297         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2298         ptext->AddText("Missing histo");
2299         if (!h1) {
2300           std::cout << "\tfailed to get " << hname1 << "\n";
2301           ptext->AddText(hname1);
2302         }
2303         if (!h0) {
2304           std::cout << "\tfailed to get " << hname0 << "\n";
2305           ptext->AddText(hname0);
2306         }
2307         ptext->Draw();
2308       } else {
2309         gPad->SetGridx();
2310         gPad->SetGridy();
2311         //  gPad->SetLogy();
2312         hRate2orig = (TH1F *)h1->Clone(Form("Rate2orig_%d", depth));
2313         hRate2orig->Divide(h1, h0, 1, 1, "B");
2314 
2315         TH1F *hRate2 = NULL;
2316         if (lastLumiBin_HE > 1) {
2317           if (!copyContents(&hRate2, Form("Rate2_%d", depth), "", hRate2orig, lastLumiBin_HE)) {
2318             std::cout << "code failed" << std::endl;
2319             gSystem->Exit(1);
2320           }
2321         } else
2322           hRate2 = hRate2orig;
2323 
2324         hRate2->SetTitle(Form("Depth %d \b", depth));
2325         hRate2->SetMarkerStyle(20);
2326         hRate2->SetMarkerSize(0.8);
2327         //  hRate2->GetZaxis()->SetLabelSize(0.04);
2328         hRate2->SetXTitle(Form("<ErrorB>(ev.in LS & ch.) - HE depth%d -    iLS \b", depth));
2329         hRate2->SetMarkerColor(2);
2330         hRate2->SetLineColor(0);
2331         hRate2->Draw("Error");
2332 
2333         if (LSofFirstErrB_HE == -1) {
2334           int nx = hRate2->GetXaxis()->GetNbins();
2335           for (int i = 1; i <= nx; i++) {
2336             double ccc1 = hRate2->GetBinContent(i);
2337             if (ccc1 > 0.) {
2338               cout << "****************>>>>>>>>>>> ErrB_HE bad LS start at iLS = " << i << " with rate = " << ccc1
2339                    << endl;
2340               LSofFirstErrB_HE = i;
2341               break;
2342             }
2343           }
2344         }
2345 
2346         delete h1;
2347         delete h0;
2348         if (hRate2 != hRate2orig) {
2349           delete hRate2orig;
2350           hRate2orig = hRate2;
2351         }
2352       }
2353 
2354       cHB->Update();
2355       cHB->Print(Form("HistErrB_HE_%d.png", depth));
2356       cHB->Clear();
2357       if (h2Cefz6)
2358         delete h2Cefz6;
2359       if (hRate2orig)
2360         delete hRate2orig;
2361     }
2362   }  // ErrorsB in HE
2363 
2364   //====================================================================== HO                    :
2365   //====================================================================== HO                    :
2366   //====================================================================== HO                    :
2367   // Special test of errors type A and B in HO
2368   // AZ 08.02.2016
2369 
2370   int flagErrAB_HO[2];
2371   flagErrAB_HO[0] = -1;
2372   flagErrAB_HO[1] = -1;
2373   double avedelta_HO = 0.;
2374   int lastLumiBin_HO = -1;
2375   int LSofFirstErrB_HO = -1;
2376   {
2377     const int specCountA = 4;
2378     const int specColors[specCountA] = {1, 2, 3, 4};
2379     const TString hnames[specCountA][2] = {{"h_sumADCAmplperLS8_P1", "h_sum0ADCAmplperLS8_P1"},
2380                                            {"h_sumADCAmplperLS8_P2", "h_sum0ADCAmplperLS8_P2"},
2381                                            {"h_sumADCAmplperLS8_M1", "h_sum0ADCAmplperLS8_M1"},
2382                                            {"h_sumADCAmplperLS8_M2", "h_sum0ADCAmplperLS8_M2"}};
2383 
2384     std::vector<TH1F *> hV;
2385     THStack *hs = new THStack("hs", "ADCAmplerLS1");
2386     cHB->Clear();
2387     //    cHB->cd();
2388     cHB->Divide(2, 1);
2389     cHB->cd(1);
2390 
2391     ///////////////////////////////////////////////////////////////////////////
2392     for (int i = 0; i < specCountA; i++) {
2393       if (1)
2394         std::cout << "debugger: errA_HO : get histos for i=" << i << " " << hnames[i][0] << " and " << hnames[i][1]
2395                   << "\n";
2396       TH1F *h1 = (TH1F *)hfile->Get(hnames[i][0]);
2397       TH1F *h0 = (TH1F *)hfile->Get(hnames[i][1]);
2398       if (!h1 || !h0) {
2399         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2400         ptext->AddText("Missing histo");
2401         if (!h1) {
2402           std::cout << "\tfailed to get " << hnames[i][0] << "\n";
2403           ptext->AddText(hnames[i][0]);
2404         }
2405         if (!h0) {
2406           std::cout << "\tfailed to get " << hnames[i][1] << "\n";
2407           ptext->AddText(hnames[i][1]);
2408         }
2409         ptext->Draw();
2410         continue;
2411       }
2412       TH1F *hoRT1orig = (TH1F *)h1->Clone(Form("ERT1orig_%d", i));
2413       hoRT1orig->Divide(h1, h0, 1, 1, "B");
2414 
2415       if ((lastLumiBin_HO < 0) && (i == 0)) {
2416         for (int ibin = hoRT1orig->GetNbinsX(); ibin >= 1; ibin--) {
2417           if (hoRT1orig->GetBinContent(ibin) == 0)
2418             lastLumiBin_HO = ibin;
2419           else
2420             break;
2421         }
2422         lastLumiBin_HO += 3;  // show more bins
2423         if (lastLumiBin_HO >= hoRT1orig->GetNbinsX())
2424           lastLumiBin_HO = -1;
2425       }
2426       TH1F *hoRT1 = NULL;
2427       if (lastLumiBin_HO > 1) {
2428         if (!copyContents(&hoRT1, Form("ERT1_%d", i), "", hoRT1orig, lastLumiBin_HO)) {
2429           std::cout << "code failed" << std::endl;
2430           gSystem->Exit(1);
2431         }
2432       } else
2433         hoRT1 = hoRT1orig;
2434 
2435       hoRT1->GetXaxis()->SetTitle("<ADCAmpl> per LS HO: black-P1, red-P2,green-M1,blue-M2");
2436       hV.push_back(hoRT1);
2437       hoRT1->SetMarkerStyle(20);
2438       hoRT1->SetMarkerSize(0.4);
2439       hoRT1->SetXTitle("<A>(ev.in LS & ch.) - HO P1     -    iLS \b");
2440       hoRT1->SetMarkerColor(specColors[i]);
2441       hoRT1->SetLineColor(0);
2442       hs->Add(hoRT1);
2443       delete h1;
2444       delete h0;
2445       if (hoRT1 != hoRT1orig)
2446         delete hoRT1orig;
2447     }  /////////////////////////////////////////////////////////////////////////
2448     hs->Draw("LPE1 nostack");
2449     cHB->Update();  // activate tho axes
2450     hs->GetXaxis()->SetTitle("<A> per LS: black-P1, red-P2,green-M1,blue-M2");
2451     hs->Draw("LPE1 nostack");
2452     gPad->SetGridy();
2453     /////////////////////////////////////////////////////////////////////////////////////////
2454 
2455     // AZ corrections 08.02.2016
2456     cHB->cd(2);
2457     TH1F *diff = new TH1F("diff", "", 100, 0., 4.);
2458 
2459     if (int(hV.size()) == specCountA) {
2460       flagErrAB_HO[0] = 0;  // If we have tho expected number of histograms, set tho flag
2461       double sumdelta = 0.;
2462       int nnndelta = 0;
2463       for (int ibin = 1; ibin <= hV[0]->GetNbinsX(); ibin++) {
2464         double delta = 0.;
2465         double maxdelta = 0.;
2466         for (unsigned int i = 0; i < hV.size(); i++) {
2467           const TH1F *hi = hV[i];
2468           for (unsigned int j = 1; j < hV.size(); j++) {
2469             const TH1F *hj = hV[j];
2470             delta = fabs(hi->GetBinContent(ibin) - hj->GetBinContent(ibin));
2471             if (delta > maxdelta)
2472               maxdelta = delta;
2473           }  //for
2474         }    //for
2475         if (maxdelta > 0.) {
2476           diff->Fill(maxdelta);
2477           sumdelta += maxdelta;
2478           nnndelta++;
2479         }
2480       }  //for ibin
2481       //      avedelta_HO = sumdelta/hV[0]->GetNbinsX();
2482       avedelta_HO = sumdelta / nnndelta;
2483       std::cout << "******************>>>>>>      ErrA_HO:  avedelta_HO = " << avedelta_HO << std::endl;
2484       if (avedelta_HO > 0.8 || (avedelta_HO < 0.2 && avedelta_HO > 0.)) {
2485         flagErrAB_HO[0] = 1;
2486       }  //if
2487     }    //hV.size
2488     diff->SetMarkerStyle(20);
2489     diff->SetMarkerSize(0.8);
2490     diff->SetXTitle("max difference \b");
2491     diff->SetMarkerColor(2);
2492     diff->SetLineColor(0);
2493     gPad->SetGridx();
2494     gPad->SetLogy();
2495     diff->Draw("Error");
2496     /////////////////////////////////////////////////////////////////////////
2497     cHB->Update();
2498     cHB->Print("HistErrA_HO.png");
2499     cHB->Clear();
2500     /////////////////////////////////////////////////////////////////////////
2501 
2502     // clean-up
2503     if (diff)
2504       delete diff;
2505     for (unsigned int i = 0; i < hV.size(); i++)
2506       delete hV[i];
2507   }  // ErrorA in HO
2508 
2509   ///////////////////////////////////////////////////////////////////////// errors B:
2510 
2511   {  // errors type B
2512     const int specCountB = 2;
2513     const TString hnames[specCountB][2] = {{"h_2DsumErrorBLS8", "h_2D0sumErrorBLS8"},
2514                                            {"h_sumErrorBperLS8", "h_sum0ErrorBperLS8"}};
2515 
2516     for (int depth = 4; depth <= 4; depth++) {
2517       cHB->Clear();
2518       cHB->Divide(2, 1);
2519       cHB->cd(1);
2520 
2521       TH1F *hRate2orig = NULL;
2522       TH2F *h2Cefz6 = NULL;
2523       TString hname1 = hnames[2 * depth - 8][0];
2524       TString hname0 = hnames[2 * depth - 8][1];
2525       TH2F *twod1 = (TH2F *)hfile->Get(hname1);
2526       TH2F *twod0 = (TH2F *)hfile->Get(hname0);
2527       if (1)
2528         std::cout << "debugger: errB_HO depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2529       if (!twod1 || !twod0) {
2530         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2531         ptext->AddText("Missing histos");
2532         if (!twod1) {
2533           std::cout << "\tfailed to get " << hname1 << "\n";
2534           ptext->AddText(hname1);
2535         }
2536         if (!twod0) {
2537           std::cout << "\tfailed to get " << hname0 << "\n";
2538           ptext->AddText(hname0);
2539         }
2540         ptext->Draw();
2541       } else {
2542         h2Cefz6 = (TH2F *)twod1->Clone(Form("Cefz6_%d", depth));
2543         h2Cefz6->SetTitle(Form("HO Depth %d \b", depth));
2544         h2Cefz6->Divide(twod1, twod0, 1, 1, "B");
2545 
2546         gPad->SetGridy();
2547         gPad->SetGridx();
2548         gPad->SetLogz();
2549         h2Cefz6->SetTitle(Form("Depth %d \b", depth));
2550         h2Cefz6->SetMarkerStyle(20);
2551         h2Cefz6->SetMarkerSize(0.4);
2552         //  h2Cefz6->GetZaxis()->SetLabelSize(0.04);
2553         h2Cefz6->SetXTitle("#eta \b");
2554         h2Cefz6->SetYTitle("#phi \b");
2555         h2Cefz6->SetZTitle(Form("<ErrorB>  - HO Depth%d \b", depth));
2556         h2Cefz6->SetMarkerColor(2);
2557         h2Cefz6->SetLineColor(2);
2558         h2Cefz6->Draw("COLZ");
2559 
2560         delete twod1;
2561         delete twod0;
2562       }  // histos ok
2563 
2564       cHB->cd(2);
2565       hname1 = hnames[2 * depth - 7][0];
2566       hname0 = hnames[2 * depth - 7][1];
2567       TH1F *h1 = (TH1F *)hfile->Get(hname1);
2568       TH1F *h0 = (TH1F *)hfile->Get(hname0);
2569       if (1)
2570         std::cout << "errB_HO depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2571       if (!h1 || !h0) {
2572         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2573         ptext->AddText("Missing histo");
2574         if (!h1) {
2575           std::cout << "\tfailed to get " << hname1 << "\n";
2576           ptext->AddText(hname1);
2577         }
2578         if (!h0) {
2579           std::cout << "\tfailed to get " << hname0 << "\n";
2580           ptext->AddText(hname0);
2581         }
2582         ptext->Draw();
2583       } else {
2584         gPad->SetGridx();
2585         gPad->SetGridy();
2586         //  gPad->SetLogy();
2587         hRate2orig = (TH1F *)h1->Clone(Form("Rate2orig_%d", depth));
2588         hRate2orig->Divide(h1, h0, 1, 1, "B");
2589 
2590         TH1F *hRate2 = NULL;
2591         if (lastLumiBin_HO > 1) {
2592           if (!copyContents(&hRate2, Form("Rate2_%d", depth), "", hRate2orig, lastLumiBin_HO)) {
2593             std::cout << "code failed" << std::endl;
2594             gSystem->Exit(1);
2595           }
2596         } else
2597           hRate2 = hRate2orig;
2598 
2599         hRate2->SetTitle(Form("Depth %d \b", depth));
2600         hRate2->SetMarkerStyle(20);
2601         hRate2->SetMarkerSize(0.8);
2602         //  hRate2->GetZaxis()->SetLabelSize(0.04);
2603         hRate2->SetXTitle(Form("<ErrorB>(ev.in LS & ch.) - HO depth%d -    iLS \b", depth));
2604         hRate2->SetMarkerColor(2);
2605         hRate2->SetLineColor(0);
2606         hRate2->Draw("Error");
2607 
2608         if (LSofFirstErrB_HO == -1) {
2609           int nx = hRate2->GetXaxis()->GetNbins();
2610           for (int i = 1; i <= nx; i++) {
2611             double ccc1 = hRate2->GetBinContent(i);
2612             if (ccc1 > 0.) {
2613               cout << "****************>>>>>>>>>>> ErrB_HO bad LS start at iLS = " << i << " with rate = " << ccc1
2614                    << endl;
2615               LSofFirstErrB_HO = i;
2616               break;
2617             }
2618           }
2619         }
2620 
2621         delete h1;
2622         delete h0;
2623         if (hRate2 != hRate2orig) {
2624           delete hRate2orig;
2625           hRate2orig = hRate2;
2626         }
2627       }
2628 
2629       cHB->Update();
2630       cHB->Print(Form("HistErrB_HO_%d.png", depth));
2631       cHB->Clear();
2632       if (h2Cefz6)
2633         delete h2Cefz6;
2634       if (hRate2orig)
2635         delete hRate2orig;
2636     }
2637   }  // ErrorsB in HO
2638 
2639   //====================================================================== done by Andrius for HF:
2640   //====================================================================== done by Andrius for HF:
2641   //====================================================================== done by Andrius for HF:
2642   // Special test of errors type A and B in HF
2643 
2644   int flagErrAB_HF[2];
2645   flagErrAB_HF[0] = -1;
2646   flagErrAB_HF[1] = -1;
2647   double avedelta_HF = 0.;
2648   int lastLumiBin_HF = -1;
2649   int LSofFirstErrB_HF = -1;
2650   {
2651     const int specCountA = 4;
2652     const int specColors[specCountA] = {1, 2, 3, 4};
2653     const TString hnames[specCountA][2] = {{"h_sumADCAmplperLS6_P1", "h_sum0ADCAmplperLS6_P1"},
2654                                            {"h_sumADCAmplperLS6_P2", "h_sum0ADCAmplperLS6_P2"},
2655                                            {"h_sumADCAmplperLS6_M1", "h_sum0ADCAmplperLS6_M1"},
2656                                            {"h_sumADCAmplperLS6_M2", "h_sum0ADCAmplperLS6_M2"}};
2657 
2658     std::vector<TH1F *> hV;
2659     THStack *hs = new THStack("hs", "ADCAmplerLS6");
2660     cHB->Clear();
2661     //    cHB->cd();
2662     cHB->Divide(2, 1);
2663     cHB->cd(1);
2664 
2665     ///////////////////////////////////////////////////////////////////////////
2666     for (int i = 0; i < specCountA; i++) {
2667       if (1)
2668         std::cout << "debugger: errA_HF : get histos for i=" << i << " " << hnames[i][0] << " and " << hnames[i][1]
2669                   << "\n";
2670       TH1F *h1 = (TH1F *)hfile->Get(hnames[i][0]);
2671       TH1F *h0 = (TH1F *)hfile->Get(hnames[i][1]);
2672       if (!h1 || !h0) {
2673         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2674         ptext->AddText("Missing histo");
2675         if (!h1) {
2676           std::cout << "\tfailed to get " << hnames[i][0] << "\n";
2677           ptext->AddText(hnames[i][0]);
2678         }
2679         if (!h0) {
2680           std::cout << "\tfailed to get " << hnames[i][1] << "\n";
2681           ptext->AddText(hnames[i][1]);
2682         }
2683         ptext->Draw();
2684         continue;
2685       }
2686       TH1F *hERT1orig = (TH1F *)h1->Clone(Form("ERT1orig_%d", i));
2687       hERT1orig->Divide(h1, h0, 1, 1, "B");
2688 
2689       if ((lastLumiBin_HF < 0) && (i == 0)) {
2690         for (int ibin = hERT1orig->GetNbinsX(); ibin >= 1; ibin--) {
2691           if (hERT1orig->GetBinContent(ibin) == 0)
2692             lastLumiBin_HF = ibin;
2693           else
2694             break;
2695         }
2696         lastLumiBin_HF += 3;  // show more bins
2697         if (lastLumiBin_HF >= hERT1orig->GetNbinsX())
2698           lastLumiBin_HF = -1;
2699       }
2700       TH1F *hERT1 = NULL;
2701       if (lastLumiBin_HF > 1) {
2702         if (!copyContents(&hERT1, Form("ERT1_%d", i), "", hERT1orig, lastLumiBin_HF)) {
2703           std::cout << "code failed" << std::endl;
2704           gSystem->Exit(1);
2705         }
2706       } else
2707         hERT1 = hERT1orig;
2708 
2709       hERT1->GetXaxis()->SetTitle("<ADCAmpl> per LS HF: black-P1, red-P2,green-M1,blue-M2");
2710       hV.push_back(hERT1);
2711       hERT1->SetMarkerStyle(20);
2712       hERT1->SetMarkerSize(0.4);
2713       hERT1->SetXTitle("<A>(ev.in LS & ch.) - HF P1     -    iLS \b");
2714       hERT1->SetMarkerColor(specColors[i]);
2715       hERT1->SetLineColor(0);
2716       hs->Add(hERT1);
2717       delete h1;
2718       delete h0;
2719       if (hERT1 != hERT1orig)
2720         delete hERT1orig;
2721     }  /////////////////////////////////////////////////////////////////////////
2722     hs->Draw("LPE1 nostack");
2723     cHB->Update();  // activate the axes
2724     hs->GetXaxis()->SetTitle("<A> per LS: black-P1, red-P2,green-M1,blue-M2");
2725     hs->Draw("LPE1 nostack");
2726     gPad->SetGridy();
2727     /////////////////////////////////////////////////////////////////////////////////////////
2728 
2729     // AZ corrections 04.02.2016
2730     cHB->cd(2);
2731     TH1F *diff = new TH1F("diff", "", 100, 0., 4.);
2732 
2733     if (int(hV.size()) == specCountA) {
2734       flagErrAB_HF[0] = 0;  // If we have the expected number of histograms, set the flag
2735       double sumdelta = 0.;
2736       int nnndelta = 0;
2737       std::cout << "********   GetNbinsX  = " << hV[0]->GetNbinsX() << std::endl;
2738       for (int ibin = 1; ibin <= hV[0]->GetNbinsX(); ibin++) {
2739         double delta = 0.;
2740         double maxdelta = 0.;
2741         for (unsigned int i = 0; i < hV.size(); i++) {
2742           const TH1F *hi = hV[i];
2743           for (unsigned int j = 1; j < hV.size(); j++) {
2744             const TH1F *hj = hV[j];
2745             delta = fabs(hi->GetBinContent(ibin) - hj->GetBinContent(ibin));
2746             if (delta > maxdelta)
2747               maxdelta = delta;
2748           }  //for
2749         }    //for
2750         //  std::cout << "*****      ibin = " << ibin << " nnndelta= " << nnndelta << " maxdelta= " << maxdelta <<std::endl;
2751         if (maxdelta > 0.) {
2752           diff->Fill(maxdelta);
2753           sumdelta += maxdelta;
2754           nnndelta++;
2755         }
2756       }  //for ibin
2757       //      avedelta_HF = sumdelta/hV[0]->GetNbinsX();
2758       avedelta_HF = sumdelta / nnndelta;
2759       //      std::cout << "******************>>>>>>      ErrA_HF:  avedelta_HF = " << avedelta_HF << " Npoints for comparison= " << nnndelta <<std::endl;
2760       if (avedelta_HF > 2.4 || (avedelta_HF < 0.8 && avedelta_HF > 0.)) {
2761         flagErrAB_HF[0] = 1;
2762       }  //if
2763     }    //hV.size
2764     diff->SetMarkerStyle(20);
2765     diff->SetMarkerSize(0.8);
2766     diff->SetXTitle("max difference \b");
2767     diff->SetMarkerColor(2);
2768     diff->SetLineColor(0);
2769     gPad->SetGridx();
2770     gPad->SetLogy();
2771     diff->Draw("Error");
2772     /////////////////////////////////////////////////////////////////////////
2773     cHB->Update();
2774     cHB->Print("HistErrA_HF.png");
2775     cHB->Clear();
2776     /////////////////////////////////////////////////////////////////////////
2777     // clean-up
2778     if (diff)
2779       delete diff;
2780     for (unsigned int i = 0; i < hV.size(); i++)
2781       delete hV[i];
2782   }  // ErrorA in HF
2783   ////////////////////////////////////////////////////////// errors B:
2784   /////////////////////////
2785   {  // errors type B
2786     const int specCountB = 4;
2787     const TString hnames[specCountB][2] = {{"h_2DsumErrorBLS6", "h_2D0sumErrorBLS6"},
2788                                            {"h_sumErrorBperLS6", "h_sum0ErrorBperLS6"},
2789                                            {"h_2DsumErrorBLS7", "h_2D0sumErrorBLS7"},
2790                                            {"h_sumErrorBperLS7", "h_sum0ErrorBperLS7"}};
2791 
2792     for (int depth = 1; depth <= 2; depth++) {
2793       cHB->Clear();
2794       cHB->Divide(2, 1);
2795       cHB->cd(1);
2796       TH1F *hRate2orig = NULL;
2797       TH2F *h2Cefz6 = NULL;
2798       TString hname1 = hnames[2 * depth - 2][0];
2799       TString hname0 = hnames[2 * depth - 2][1];
2800       TH2F *twod1 = (TH2F *)hfile->Get(hname1);
2801       TH2F *twod0 = (TH2F *)hfile->Get(hname0);
2802       if (1)
2803         std::cout << "debugger: errB_HF depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2804       if (!twod1 || !twod0) {
2805         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2806         ptext->AddText("Missing histos");
2807         if (!twod1) {
2808           std::cout << "\tfailed to get " << hname1 << "\n";
2809           ptext->AddText(hname1);
2810         }
2811         if (!twod0) {
2812           std::cout << "\tfailed to get " << hname0 << "\n";
2813           ptext->AddText(hname0);
2814         }
2815         ptext->Draw();
2816       } else {
2817         h2Cefz6 = (TH2F *)twod1->Clone(Form("Cefz6_%d", depth));
2818         h2Cefz6->SetTitle(Form("HF Depth %d \b", depth));
2819         h2Cefz6->Divide(twod1, twod0, 1, 1, "B");
2820 
2821         gPad->SetGridy();
2822         gPad->SetGridx();
2823         gPad->SetLogz();
2824         h2Cefz6->SetTitle(Form("Depth %d \b", depth));
2825         h2Cefz6->SetMarkerStyle(20);
2826         h2Cefz6->SetMarkerSize(0.4);
2827         //  h2Cefz6->GetZaxis()->SetLabelSize(0.04);
2828         h2Cefz6->SetXTitle("#eta \b");
2829         h2Cefz6->SetYTitle("#phi \b");
2830         h2Cefz6->SetZTitle(Form("<ErrorB>  - HF Depth%d \b", depth));
2831         h2Cefz6->SetMarkerColor(2);
2832         h2Cefz6->SetLineColor(2);
2833         h2Cefz6->Draw("COLZ");
2834         delete twod1;
2835         delete twod0;
2836       }  // histos ok
2837       cHB->cd(2);
2838       hname1 = hnames[2 * depth - 1][0];
2839       hname0 = hnames[2 * depth - 1][1];
2840       TH1F *h1 = (TH1F *)hfile->Get(hname1);
2841       TH1F *h0 = (TH1F *)hfile->Get(hname0);
2842       if (1)
2843         std::cout << "errB_HF depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2844       if (!h1 || !h0) {
2845         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2846         ptext->AddText("Missing histo");
2847         if (!h1) {
2848           std::cout << "\tfailed to get " << hname1 << "\n";
2849           ptext->AddText(hname1);
2850         }
2851         if (!h0) {
2852           std::cout << "\tfailed to get " << hname0 << "\n";
2853           ptext->AddText(hname0);
2854         }
2855         ptext->Draw();
2856       } else {
2857         gPad->SetGridx();
2858         gPad->SetGridy();
2859         //  gPad->SetLogy();
2860         hRate2orig = (TH1F *)h1->Clone(Form("Rate2orig_%d", depth));
2861         hRate2orig->Divide(h1, h0, 1, 1, "B");
2862 
2863         TH1F *hRate2 = NULL;
2864         if (lastLumiBin_HF > 1) {
2865           if (!copyContents(&hRate2, Form("Rate2_%d", depth), "", hRate2orig, lastLumiBin_HF)) {
2866             std::cout << "code failed" << std::endl;
2867             gSystem->Exit(1);
2868           }
2869         } else
2870           hRate2 = hRate2orig;
2871         hRate2->SetTitle(Form("Depth %d \b", depth));
2872         hRate2->SetMarkerStyle(20);
2873         hRate2->SetMarkerSize(0.8);
2874         //  hRate2->GetZaxis()->SetLabelSize(0.04);
2875         hRate2->SetXTitle(Form("<ErrorB>(ev.in LS & ch.) - HF depth%d -    iLS \b", depth));
2876         hRate2->SetMarkerColor(2);
2877         hRate2->SetLineColor(0);
2878         hRate2->Draw("Error");
2879         if (LSofFirstErrB_HF == -1) {
2880           int nx = hRate2->GetXaxis()->GetNbins();
2881           for (int i = 1; i <= nx; i++) {
2882             double ccc1 = hRate2->GetBinContent(i);
2883             if (ccc1 > 0.) {
2884               cout << "****************>>>>>>>>>>> ErrB_HF bad LS start at iLS = " << i << " with rate = " << ccc1
2885                    << endl;
2886               LSofFirstErrB_HF = i;
2887               break;
2888             }
2889           }
2890         }
2891         delete h1;
2892         delete h0;
2893         if (hRate2 != hRate2orig) {
2894           delete hRate2orig;
2895           hRate2orig = hRate2;
2896         }
2897       }
2898       cHB->Update();
2899       cHB->Print(Form("HistErrB_HF_%d.png", depth));
2900       cHB->Clear();
2901       if (h2Cefz6)
2902         delete h2Cefz6;
2903       if (hRate2orig)
2904         delete hRate2orig;
2905     }
2906   }  // ErrorsB in HF
2907 
2908   /////////////////  Cross-check A-errors & Occupancies:
2909 
2910   //===============================================================================  err A HB
2911   /// errA with average Amplitudes
2912   // For  2D and  1D plots with Amplitude. Produces ChkErrA_HBx.png
2913 
2914   for (int depth = 1; depth <= 2; depth++) {
2915     TH2F *h2Ceff = NULL;
2916     TH2F *h2Diffe = NULL;
2917     //    TH1F* h1diffADCAmpl= NULL;
2918     TH2F *h3Ceff = NULL;
2919 
2920     cHE->Clear();
2921     cHE->Divide(3, 1);
2922 
2923     cHE->cd(1);
2924     // h_mapDepth1ADCAmpl_HB div h_mapDepth1_HB
2925     TString hname1 = Form("h_mapDepth%dADCAmpl_HB", depth);
2926     TString hname0 = Form("h_mapDepth%d_HB", depth);
2927     TH2F *twod1 = (TH2F *)hfile->Get(hname1);
2928     TH2F *twod0 = (TH2F *)hfile->Get(hname0);
2929     if (!twod1 || !twod0) {
2930       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2931       ptext->AddText("Missing histo");
2932       std::cout << "specHB test: failed to load " << hname1 << " and/or " << hname0 << "\n";
2933       if (!twod1)
2934         ptext->AddText(hname1);
2935       if (!twod0)
2936         ptext->AddText(hname0);
2937       ptext->Draw();
2938       continue;
2939     } else {
2940       // To IDENTIFY: see color different bins in eta-phi space
2941       h2Ceff = (TH2F *)twod1->Clone(Form("Ceff_HB%d", depth));
2942       h2Ceff->SetTitle(Form("HB Depth %d. (No cut) \b", depth));
2943       h2Ceff->Divide(twod1, twod0, 1, 1, "B");
2944 
2945       gPad->SetGridy();
2946       gPad->SetGridx();
2947       gPad->SetLogz();
2948       h2Ceff->SetMarkerStyle(20);
2949       h2Ceff->SetMarkerSize(0.4);
2950       //h2Ceff->GetZaxis()->SetLabelSize(0.08);
2951       h2Ceff->SetXTitle("#eta \b");
2952       h2Ceff->SetYTitle("#phi \b");
2953       h2Ceff->SetZTitle("h_mapDepth1ADCAmpl_HB \b");
2954       h2Ceff->SetMarkerColor(2);
2955       h2Ceff->SetLineColor(2);
2956       h2Ceff->Draw("COLZ");
2957     }
2958 
2959     cHE->cd(2);
2960     ///////////////////////////////////////
2961     if (h2Ceff) {
2962       // TO IDENTIFY: see red bins in eta-phi space
2963       h2Diffe = (TH2F *)h2Ceff->Clone(Form("Diffe_Depth%d_HB", depth));
2964       h2Diffe->SetTitle(Form("HB Depth %d. Cut avg(ADCAmpl) > 25 \b", depth));
2965       int nx = h2Ceff->GetXaxis()->GetNbins();
2966       int ny = h2Ceff->GetYaxis()->GetNbins();
2967       for (int i = 1; i <= nx; i++) {
2968         for (int j = 1; j <= ny; j++) {
2969           double ccc1 = h2Ceff->GetBinContent(i, j);
2970           h2Diffe->SetBinContent(i, j, 0.);
2971           if (ccc1 > 25.)
2972             h2Diffe->SetBinContent(i, j, ccc1);
2973         }
2974       }
2975       gPad->SetGridy();
2976       gPad->SetGridx();
2977       gPad->SetLogz();
2978       h2Diffe->SetMarkerStyle(20);
2979       h2Diffe->SetMarkerSize(0.4);
2980       //h2Diffe->GetZaxis()->SetLabelSize(0.08);
2981       h2Diffe->SetXTitle("#eta \b");
2982       h2Diffe->SetYTitle("#phi \b");
2983       h2Diffe->SetZTitle("<ADCAmpl> bigger 25.- HB Depth1 \b");
2984       h2Diffe->SetMarkerColor(2);
2985       h2Diffe->SetLineColor(2);
2986       h2Diffe->Draw("COLZ");
2987     }
2988 
2989     cHE->cd(3);
2990     TString hname3 = Form("h_mapDepth%dADCAmpl225Copy_HB", depth);
2991     TH2F *twod3 = (TH2F *)hfile->Get(hname3);
2992     if (!twod3 || !twod0) {
2993       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2994       ptext->AddText("Missing histo");
2995       std::cout << "specHB test: failed to load " << hname3 << " and/or " << hname0 << "\n";
2996       if (!twod3)
2997         ptext->AddText(hname3);
2998       if (!twod0)
2999         ptext->AddText(hname0);
3000       ptext->Draw();
3001       continue;
3002     } else {
3003       // To IDENTIFY: see color different bins in eta-phi space
3004       h3Ceff = (TH2F *)twod3->Clone(Form("CeffA_HB%d", depth));
3005       h3Ceff->SetTitle(Form("HB Depth %d. \b", depth));
3006       h3Ceff->Divide(twod3, twod0, 1, 1, "B");
3007       gPad->SetGridy();
3008       gPad->SetGridx();
3009       gPad->SetLogz();
3010       h3Ceff->SetMarkerStyle(20);
3011       h3Ceff->SetMarkerSize(0.4);
3012       //      h3Ceff->GetZaxis()->SetLabelSize(0.08);
3013       h3Ceff->SetXTitle("#eta \b");
3014       h3Ceff->SetYTitle("#phi \b");
3015       h3Ceff->SetZTitle("rate for channels of HB \b");
3016       h3Ceff->SetMarkerColor(2);
3017       h3Ceff->SetLineColor(2);
3018       h3Ceff->Draw("COLZ");
3019     }
3020 
3021     cHE->Update();
3022     cHE->Print(Form("ChkErrA_HB%d.png", depth));
3023     cHE->Clear();
3024 
3025     if (h2Ceff)
3026       delete h2Ceff;
3027     if (h2Diffe)
3028       delete h2Diffe;
3029     //    if (h1diffADCAmpl) delete h1diffADCAmpl;
3030     //  if (twod0) delete twod0;// do not delete - sometimes causes trouble later
3031     if (twod1)
3032       delete twod1;
3033     if (twod3)
3034       delete twod3;
3035     if (h3Ceff)
3036       delete h3Ceff;
3037   }  // depth
3038 
3039   //===============================================================================  err A HE
3040   /// errA with average Amplitudes
3041   // For  2D and  1D plots with Amplitude. Produces ChkErrA_HEx.png
3042 
3043   for (int depth = 1; depth <= 3; depth++) {
3044     TH2F *h2Ceff = NULL;
3045     TH2F *h2Diffe = NULL;
3046     //    TH1F* h1diffADCAmpl= NULL;
3047     TH2F *h3Ceff = NULL;
3048 
3049     cHE->Clear();
3050     cHE->Divide(3, 1);
3051 
3052     cHE->cd(1);
3053     // h_mapDepth1ADCAmpl_HE div h_mapDepth1_HE
3054     TString hname1 = Form("h_mapDepth%dADCAmpl_HE", depth);
3055     TString hname0 = Form("h_mapDepth%d_HE", depth);
3056     TH2F *twod1 = (TH2F *)hfile->Get(hname1);
3057     TH2F *twod0 = (TH2F *)hfile->Get(hname0);
3058     if (!twod1 || !twod0) {
3059       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3060       ptext->AddText("Missing histo");
3061       std::cout << "specHE test: failed to load " << hname1 << " and/or " << hname0 << "\n";
3062       if (!twod1)
3063         ptext->AddText(hname1);
3064       if (!twod0)
3065         ptext->AddText(hname0);
3066       ptext->Draw();
3067       continue;
3068     } else {
3069       // To IDENTIFY: see color different bins in eta-phi space
3070       h2Ceff = (TH2F *)twod1->Clone(Form("Ceff_HE%d", depth));
3071       h2Ceff->SetTitle(Form("HE Depth %d. (No cut) \b", depth));
3072       h2Ceff->Divide(twod1, twod0, 1, 1, "B");
3073 
3074       gPad->SetGridy();
3075       gPad->SetGridx();
3076       gPad->SetLogz();
3077       h2Ceff->SetMarkerStyle(20);
3078       h2Ceff->SetMarkerSize(0.4);
3079       //h2Ceff->GetZaxis()->SetLabelSize(0.08);
3080       h2Ceff->SetXTitle("#eta \b");
3081       h2Ceff->SetYTitle("#phi \b");
3082       h2Ceff->SetZTitle("h_mapDepth1ADCAmpl_HE \b");
3083       h2Ceff->SetMarkerColor(2);
3084       h2Ceff->SetLineColor(2);
3085       h2Ceff->Draw("COLZ");
3086     }
3087 
3088     cHE->cd(2);
3089     ///////////////////////////////////////
3090     if (h2Ceff) {
3091       // TO IDENTIFY: see red bins in eta-phi space
3092       h2Diffe = (TH2F *)h2Ceff->Clone(Form("Diffe_Depth%d_HE", depth));
3093       h2Diffe->SetTitle(Form("HE Depth %d. Cut avg(ADCAmpl) > 1000 fC \b", depth));
3094       int nx = h2Ceff->GetXaxis()->GetNbins();
3095       int ny = h2Ceff->GetYaxis()->GetNbins();
3096       for (int i = 1; i <= nx; i++) {
3097         for (int j = 1; j <= ny; j++) {
3098           double ccc1 = h2Ceff->GetBinContent(i, j);
3099           h2Diffe->SetBinContent(i, j, 0.);
3100           if (ccc1 > 1000.)
3101             h2Diffe->SetBinContent(i, j, ccc1);
3102         }
3103       }
3104       gPad->SetGridy();
3105       gPad->SetGridx();
3106       gPad->SetLogz();
3107       h2Diffe->SetMarkerStyle(20);
3108       h2Diffe->SetMarkerSize(0.4);
3109       //h2Diffe->GetZaxis()->SetLabelSize(0.08);
3110       h2Diffe->SetXTitle("#eta \b");
3111       h2Diffe->SetYTitle("#phi \b");
3112       h2Diffe->SetZTitle("<ADCAmpl> bigger 1000.fC - HE Depth1 \b");
3113       h2Diffe->SetMarkerColor(2);
3114       h2Diffe->SetLineColor(2);
3115       h2Diffe->Draw("COLZ");
3116     }
3117 
3118     cHE->cd(3);
3119     TString hname3 = Form("h_mapDepth%dADCAmpl225Copy_HE", depth);
3120     TH2F *twod3 = (TH2F *)hfile->Get(hname3);
3121     if (!twod3 || !twod0) {
3122       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3123       ptext->AddText("Missing histo");
3124       std::cout << "specHE test: failed to load " << hname3 << " and/or " << hname0 << "\n";
3125       if (!twod3)
3126         ptext->AddText(hname3);
3127       if (!twod0)
3128         ptext->AddText(hname0);
3129       ptext->Draw();
3130       continue;
3131     } else {
3132       // To IDENTIFY: see color different bins in eta-phi space
3133       h3Ceff = (TH2F *)twod3->Clone(Form("CeffA_HE%d", depth));
3134       h3Ceff->SetTitle(Form("HE Depth %d. \b", depth));
3135       h3Ceff->Divide(twod3, twod0, 1, 1, "B");
3136       gPad->SetGridy();
3137       gPad->SetGridx();
3138       gPad->SetLogz();
3139       h3Ceff->SetMarkerStyle(20);
3140       h3Ceff->SetMarkerSize(0.4);
3141       //      h3Ceff->GetZaxis()->SetLabelSize(0.08);
3142       h3Ceff->SetXTitle("#eta \b");
3143       h3Ceff->SetYTitle("#phi \b");
3144       h3Ceff->SetZTitle("rate for channels of HE \b");
3145       h3Ceff->SetMarkerColor(2);
3146       h3Ceff->SetLineColor(2);
3147       h3Ceff->Draw("COLZ");
3148     }
3149 
3150     cHE->Update();
3151     cHE->Print(Form("ChkErrA_HE%d.png", depth));
3152     cHE->Clear();
3153 
3154     if (h2Ceff)
3155       delete h2Ceff;
3156     if (h2Diffe)
3157       delete h2Diffe;
3158     //    if (h1diffADCAmpl) delete h1diffADCAmpl;
3159     //  if (twod0) delete twod0;// do not delete - sometimes causes trouble later
3160     if (twod1)
3161       delete twod1;
3162     if (twod3)
3163       delete twod3;
3164     if (h3Ceff)
3165       delete h3Ceff;
3166   }  // depth
3167 
3168   //===============================================================================  err A HO
3169   /// errA with average Amplitudes
3170   // For  2D and  1D plots with Amplitude. Produces ChkErrA_HOx.png
3171 
3172   for (int depth = 4; depth <= 4; depth++) {
3173     TH2F *h2Ceff = NULL;
3174     TH2F *h2Diffe = NULL;
3175     //    TH1F* h1diffADCAmpl= NULL;
3176     TH2F *h3Ceff = NULL;
3177 
3178     cHE->Clear();
3179     cHE->Divide(3, 1);
3180 
3181     cHE->cd(1);
3182     // h_mapDepth1ADCAmpl_HO div h_mapDepth1_HO
3183     TString hname1 = Form("h_mapDepth%dADCAmpl_HO", depth);
3184     TString hname0 = Form("h_mapDepth%d_HO", depth);
3185     TH2F *twod1 = (TH2F *)hfile->Get(hname1);
3186     TH2F *twod0 = (TH2F *)hfile->Get(hname0);
3187     if (!twod1 || !twod0) {
3188       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3189       ptext->AddText("Missing histo");
3190       std::cout << "specHO test: failed to load " << hname1 << " and/or " << hname0 << "\n";
3191       if (!twod1)
3192         ptext->AddText(hname1);
3193       if (!twod0)
3194         ptext->AddText(hname0);
3195       ptext->Draw();
3196       continue;
3197     } else {
3198       // To IDENTIFY: see color different bins in eta-phi space
3199       h2Ceff = (TH2F *)twod1->Clone(Form("Ceff_HO%d", depth));
3200       h2Ceff->SetTitle(Form("HO Depth %d. (No cut) \b", depth));
3201       h2Ceff->Divide(twod1, twod0, 1, 1, "B");
3202 
3203       gPad->SetGridy();
3204       gPad->SetGridx();
3205       gPad->SetLogz();
3206       h2Ceff->SetMarkerStyle(20);
3207       h2Ceff->SetMarkerSize(0.4);
3208       //h2Ceff->GetZaxis()->SetLabelSize(0.08);
3209       h2Ceff->SetXTitle("#eta \b");
3210       h2Ceff->SetYTitle("#phi \b");
3211       h2Ceff->SetZTitle("h_mapDepth1ADCAmpl_HO \b");
3212       h2Ceff->SetMarkerColor(2);
3213       h2Ceff->SetLineColor(2);
3214       h2Ceff->Draw("COLZ");
3215     }
3216 
3217     cHE->cd(2);
3218     ///////////////////////////////////////
3219     if (h2Ceff) {
3220       // TO IDENTIFY: see red bins in eta-phi space (applied cut on Aij: <20 || >3000
3221       h2Diffe = (TH2F *)h2Ceff->Clone(Form("Diffe_Depth%d_HO", depth));
3222       h2Diffe->SetTitle(Form("HO Depth %d. Cut avg(ADCAmpl) > 80 \b", depth));
3223       int nx = h2Ceff->GetXaxis()->GetNbins();
3224       int ny = h2Ceff->GetYaxis()->GetNbins();
3225       for (int i = 1; i <= nx; i++) {
3226         for (int j = 1; j <= ny; j++) {
3227           double ccc1 = h2Ceff->GetBinContent(i, j);
3228           h2Diffe->SetBinContent(i, j, 0.);
3229           if (ccc1 > 20.)
3230             h2Diffe->SetBinContent(i, j, ccc1);
3231         }
3232       }
3233       gPad->SetGridy();
3234       gPad->SetGridx();
3235       gPad->SetLogz();
3236       h2Diffe->SetMarkerStyle(20);
3237       h2Diffe->SetMarkerSize(0.4);
3238       //h2Diffe->GetZaxis()->SetLabelSize(0.08);
3239       h2Diffe->SetXTitle("#eta \b");
3240       h2Diffe->SetYTitle("#phi \b");
3241       h2Diffe->SetZTitle("<ADCAmpl> bigger 80.- HO Depth1 \b");
3242       h2Diffe->SetMarkerColor(2);
3243       h2Diffe->SetLineColor(2);
3244       h2Diffe->Draw("COLZ");
3245     }
3246 
3247     cHE->cd(3);
3248     TString hname3 = Form("h_mapDepth%dADCAmpl225Copy_HO", depth);
3249     TH2F *twod3 = (TH2F *)hfile->Get(hname3);
3250     if (!twod3 || !twod0) {
3251       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3252       ptext->AddText("Missing histo");
3253       std::cout << "specHO test: failed to load " << hname3 << " and/or " << hname0 << "\n";
3254       if (!twod3)
3255         ptext->AddText(hname3);
3256       if (!twod0)
3257         ptext->AddText(hname0);
3258       ptext->Draw();
3259       continue;
3260     } else {
3261       // To IDENTIFY: see color different bins in eta-phi space
3262       h3Ceff = (TH2F *)twod3->Clone(Form("CeffA_HO%d", depth));
3263       h3Ceff->SetTitle(Form("HO Depth %d. \b", depth));
3264       h3Ceff->Divide(twod3, twod0, 1, 1, "B");
3265       gPad->SetGridy();
3266       gPad->SetGridx();
3267       gPad->SetLogz();
3268       h3Ceff->SetMarkerStyle(20);
3269       h3Ceff->SetMarkerSize(0.4);
3270       //      h3Ceff->GetZaxis()->SetLabelSize(0.08);
3271       h3Ceff->SetXTitle("#eta \b");
3272       h3Ceff->SetYTitle("#phi \b");
3273       h3Ceff->SetZTitle("rate for channels of HO \b");
3274       h3Ceff->SetMarkerColor(2);
3275       h3Ceff->SetLineColor(2);
3276       h3Ceff->Draw("COLZ");
3277     }
3278 
3279     cHE->Update();
3280     cHE->Print(Form("ChkErrA_HO%d.png", depth));
3281     cHE->Clear();
3282 
3283     if (h2Ceff)
3284       delete h2Ceff;
3285     if (h2Diffe)
3286       delete h2Diffe;
3287     //    if (h1diffADCAmpl) delete h1diffADCAmpl;
3288     //  if (twod0) delete twod0;// do not delete - sometimes causes trouble later
3289     if (twod1)
3290       delete twod1;
3291     if (twod3)
3292       delete twod3;
3293     if (h3Ceff)
3294       delete h3Ceff;
3295   }  // depth
3296 
3297   //===============================================================================  err A HF
3298   /// errA with average Amplitudes
3299   // For  2D and  1D plots with Amplitude. Produces ChkErrA_HFx.png
3300 
3301   for (int depth = 1; depth <= 2; depth++) {
3302     TH2F *h2Ceff = NULL;
3303     TH2F *h2Diffe = NULL;
3304     //    TH1F* h1diffADCAmpl= NULL;
3305     TH2F *h3Ceff = NULL;
3306 
3307     cHE->Clear();
3308     cHE->Divide(3, 1);
3309 
3310     cHE->cd(1);
3311     // h_mapDepth1ADCAmpl_HF div h_mapDepth1_HF
3312     TString hname1 = Form("h_mapDepth%dADCAmpl_HF", depth);
3313     TString hname0 = Form("h_mapDepth%d_HF", depth);
3314     TH2F *twod1 = (TH2F *)hfile->Get(hname1);
3315     TH2F *twod0 = (TH2F *)hfile->Get(hname0);
3316     if (!twod1 || !twod0) {
3317       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3318       ptext->AddText("Missing histo");
3319       std::cout << "specHF test: failed to load " << hname1 << " and/or " << hname0 << "\n";
3320       if (!twod1)
3321         ptext->AddText(hname1);
3322       if (!twod0)
3323         ptext->AddText(hname0);
3324       ptext->Draw();
3325       continue;
3326     } else {
3327       // To IDENTIFY: see color different bins in eta-phi space
3328       h2Ceff = (TH2F *)twod1->Clone(Form("Ceff_HF%d", depth));
3329       h2Ceff->SetTitle(Form("HF Depth %d. (No cut) \b", depth));
3330       h2Ceff->Divide(twod1, twod0, 1, 1, "B");
3331 
3332       gPad->SetGridy();
3333       gPad->SetGridx();
3334       gPad->SetLogz();
3335       h2Ceff->SetMarkerStyle(20);
3336       h2Ceff->SetMarkerSize(0.4);
3337       //h2Ceff->GetZaxis()->SetLabelSize(0.08);
3338       h2Ceff->SetXTitle("#eta \b");
3339       h2Ceff->SetYTitle("#phi \b");
3340       h2Ceff->SetZTitle("h_mapDepth1ADCAmpl_HF \b");
3341       h2Ceff->SetMarkerColor(2);
3342       h2Ceff->SetLineColor(2);
3343       h2Ceff->Draw("COLZ");
3344     }
3345 
3346     cHE->cd(2);
3347     ///////////////////////////////////////
3348     if (h2Ceff) {
3349       // TO IDENTIFY: see red bins in eta-phi space (applied cut on Aij: <20 || >3000
3350       h2Diffe = (TH2F *)h2Ceff->Clone(Form("Diffe_Depth%d_HF", depth));
3351       h2Diffe->SetTitle(Form("HF Depth %d. Cut avg(ADCAmpl) > 20 \b", depth));
3352       int nx = h2Ceff->GetXaxis()->GetNbins();
3353       int ny = h2Ceff->GetYaxis()->GetNbins();
3354       for (int i = 1; i <= nx; i++) {
3355         for (int j = 1; j <= ny; j++) {
3356           double ccc1 = h2Ceff->GetBinContent(i, j);
3357           h2Diffe->SetBinContent(i, j, 0.);
3358           if (ccc1 > 20.)
3359             h2Diffe->SetBinContent(i, j, ccc1);
3360         }
3361       }
3362       gPad->SetGridy();
3363       gPad->SetGridx();
3364       gPad->SetLogz();
3365       h2Diffe->SetMarkerStyle(20);
3366       h2Diffe->SetMarkerSize(0.4);
3367       //h2Diffe->GetZaxis()->SetLabelSize(0.08);
3368       h2Diffe->SetXTitle("#eta \b");
3369       h2Diffe->SetYTitle("#phi \b");
3370       h2Diffe->SetZTitle("<ADCAmpl> bigger 20.- HF Depth1 \b");
3371       h2Diffe->SetMarkerColor(2);
3372       h2Diffe->SetLineColor(2);
3373       h2Diffe->Draw("COLZ");
3374     }
3375 
3376     cHE->cd(3);
3377     /*
3378     if (h2Ceff) {
3379       h1diffADCAmpl = new TH1F(Form("diffADCAmpl_Depth%d_HF",depth),"",
3380                    100, -20.,200.);
3381       h1diffADCAmpl->SetTitle(Form("HF Depth %d \b",depth));
3382       int nx = h2Ceff->GetXaxis()->GetNbins();
3383       int ny = h2Ceff->GetYaxis()->GetNbins();
3384       for (int i=1;i<=nx;i++) {
3385     for (int j=1;j<=ny;j++) {
3386       if(h2Ceff->GetBinContent(i,j) !=0 ) {
3387         double ccc1 =  h2Ceff->GetBinContent(i,j) ;
3388         h1diffADCAmpl->Fill(ccc1);
3389       }
3390     }
3391       }
3392       gPad->SetLogy();
3393       h1diffADCAmpl->SetMarkerStyle(20);
3394       h1diffADCAmpl->SetMarkerSize(0.4);
3395       h1diffADCAmpl->GetYaxis()->SetLabelSize(0.04);
3396       h1diffADCAmpl->SetXTitle("<ADCAmpl> in each cell \b");
3397       h1diffADCAmpl->SetMarkerColor(2);
3398       h1diffADCAmpl->SetLineColor(2);
3399       h1diffADCAmpl->Draw("");
3400     }
3401     */
3402     TString hname3 = Form("h_mapDepth%dADCAmpl225Copy_HF", depth);
3403     TH2F *twod3 = (TH2F *)hfile->Get(hname3);
3404     if (!twod3 || !twod0) {
3405       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3406       ptext->AddText("Missing histo");
3407       std::cout << "specHF test: failed to load " << hname3 << " and/or " << hname0 << "\n";
3408       if (!twod3)
3409         ptext->AddText(hname3);
3410       if (!twod0)
3411         ptext->AddText(hname0);
3412       ptext->Draw();
3413       continue;
3414     } else {
3415       // To IDENTIFY: see color different bins in eta-phi space
3416       h3Ceff = (TH2F *)twod3->Clone(Form("CeffA_HF%d", depth));
3417       h3Ceff->SetTitle(Form("HF Depth %d. \b", depth));
3418       h3Ceff->Divide(twod3, twod0, 1, 1, "B");
3419       gPad->SetGridy();
3420       gPad->SetGridx();
3421       gPad->SetLogz();
3422       h3Ceff->SetMarkerStyle(20);
3423       h3Ceff->SetMarkerSize(0.4);
3424       //      h3Ceff->GetZaxis()->SetLabelSize(0.08);
3425       h3Ceff->SetXTitle("#eta \b");
3426       h3Ceff->SetYTitle("#phi \b");
3427       h3Ceff->SetZTitle("rate for channels of HF \b");
3428       h3Ceff->SetMarkerColor(2);
3429       h3Ceff->SetLineColor(2);
3430       h3Ceff->Draw("COLZ");
3431     }
3432 
3433     cHE->Update();
3434     cHE->Print(Form("ChkErrA_HF%d.png", depth));
3435     cHE->Clear();
3436 
3437     if (h2Ceff)
3438       delete h2Ceff;
3439     if (h2Diffe)
3440       delete h2Diffe;
3441     //    if (h1diffADCAmpl) delete h1diffADCAmpl;
3442     //  if (twod0) delete twod0;// do not delete - sometimes causes trouble later
3443     if (twod1)
3444       delete twod1;
3445     if (twod3)
3446       delete twod3;
3447     if (h3Ceff)
3448       delete h3Ceff;
3449   }  // depth
3450 
3451   std::cout << "************>>>   average Amplitudes done" << std::endl;
3452 
3453   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3454   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3455   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3456   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3457   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3458 
3459   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RBX study:
3460   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RBX study:
3461   //////////////////////////////////////////////////////////////////////////////////////////////////////// RBX study:
3462   //////////////////////////////////////////////////////////////////////////////////// RBX study:
3463 
3464   cout << " RBX analysis START for  **************************" << endl;
3465   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3466   //  int njeta = 22; int njphi = 18; int lsmax=2600;
3467   int njeta = 22;
3468   int njphi = 18;
3469   int lsmax = 2600;
3470   cout << ">>>>>>>>>>>>>>>>>>>>>>>>     int njeta = 22; int njphi = 18; int lsmax=2600;                        "
3471        << endl;
3472 
3473   double alexall[njeta][njphi][lsmax];
3474 
3475   // for phi tables(!):
3476   double alexhb[njphi][lsmax];
3477   double alexhe[njphi][lsmax];
3478   double alexho[njphi][lsmax];
3479   double alexhf[njphi][lsmax];
3480 
3481   // for eta tables(!):
3482   double blexhb[njeta][lsmax];
3483   double blexhe[njeta][lsmax];
3484   double blexho[njeta][lsmax];
3485   double blexhf[njeta][lsmax];
3486 
3487   cout << ">>>>>>>>>>>>>>>>>>>>>>>>  alexall   [njeta][njphi][lsmax];                         " << endl;
3488   int maxbinsRBX = MaxLum;
3489   int nx = maxbinsRBX;  // # LS
3490   cout << ">>>>>>>>>>>>>>>>>>>>>>>>   maxbinsRBX = MaxLum;                          " << endl;
3491   if (MaxLum > lsmax)
3492     cout << "***********************************   ERROR ERROR ERROR ERROR:   MaxLum > 2600 " << endl;
3493   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3494 
3495   for (int i = 0; i < nx; i++) {
3496     for (int jphi = 0; jphi < njphi; jphi++) {
3497       alexhb[jphi][i] = 0.;
3498       alexhe[jphi][i] = 0.;
3499       alexho[jphi][i] = 0.;
3500       alexhf[jphi][i] = 0.;
3501 
3502       for (int jeta = 0; jeta < njeta; jeta++) {
3503         if (jphi == 0) {
3504           blexhb[jeta][i] = 0.;
3505           blexhe[jeta][i] = 0.;
3506           blexho[jeta][i] = 0.;
3507           blexhf[jeta][i] = 0.;
3508         }
3509 
3510         alexall[jeta][jphi][i] = 0.;
3511       }
3512     }
3513   }
3514 
3515   //////////
3516   /*
3517       // j = ietaphi = 1- 396
3518        int ietaphimax = 396;
3519       int ny = ietaphimax + 1 ;
3520       for (int j=1;j<ny;j++) {
3521       int jeta = (j-1)/znphi;
3522       int jphi = (j-1)-znphi*jeta+1;// jphi=1-18 
3523       jeta += 1;// jeta = 1-22      }
3524 // Outout is  jeta = 1-22   jphi=1-18 
3525 HB: j = 7,8,9,10            11,12,13,14
3526 HE: j = 3,4,5, 6, 7      14,15,16,17,18     
3527 HO: j = 7,8,9,10            11,12,13,14
3528 HF: j = 0,1,2, 3            18,19,20,21
3529 */
3530 
3531   ////////////////////////////////////////////////////////////////////////////////////     HB::  HBSTART HB: j = 7,8,9,10            11,12,13,14
3532   //======================================================================
3533   //======================================================================
3534   //======================================================================
3535   cout << " RBX general for HB **************************" << endl;
3536   TH2F *Ghb1KKK = (TH2F *)hfile->Get("h_2DsumADCAmplEtaPhiLs0");
3537   TH2F *Ghb1LLL = (TH2F *)hfile->Get("h_2DsumADCAmplEtaPhiLs00");
3538   TH2F *Ghb1 = (TH2F *)Ghb1LLL->Clone("Ghb1");
3539   Ghb1->Divide(Ghb1KKK, Ghb1LLL, 1, 1, "B");  // average A
3540   //    Ghb1->Sumw2();
3541   //      int nx = Ghb1->GetXaxis()->GetNbins(); // # LS
3542   int ny = Ghb1->GetYaxis()->GetNbins();  // # jetaphi indexes = 396 = 18*22
3543   //           cout<<"*****************************************      HB 54        ny=     "<< ny <<endl;
3544   for (int j = 1; j <= ny; j++) {
3545     int jeta = (j - 1) / njphi;  // jeta = 0-21
3546     if (jeta > 6 && jeta < 15) {
3547       int jphi = (j - 1) - njphi * jeta;  // jphi=0-17
3548       //       cout<<"HB 54        jeta=     "<< jeta <<"   jphi   =     "<<jphi  <<endl;
3549       // over LS:
3550       for (int i = 1; i <= nx; i++) {
3551         double ccc1 = Ghb1->GetBinContent(i, j);
3552         alexall[jeta][jphi][i - 1] = ccc1;
3553         //               if( i == 1 ) cout<<"HB 54  for LS=1      ccc1=     "<< ccc1 <<endl;
3554         //           if( ccc1 <= 0 ) cout<<"HB 54   ccc1=     "<< ccc1 <<"   iLS=     "<< i <<"   eta=     "<< jeta <<"   phi=     "<< jphi <<endl;
3555         //               cout<<"HB 54   ccc1=     "<< ccc1 <<"   j=     "<< j <<"   iLS=     "<< i <<"   eta=     "<< jeta <<"   phi=     "<< jphi <<endl;
3556       }  //i
3557     }    //if
3558   }      //j
3559   // clean-up
3560   if (Ghb1KKK)
3561     delete Ghb1KKK;
3562   if (Ghb1LLL)
3563     delete Ghb1LLL;
3564   //    if (Ghb1) delete Ghb1;
3565 
3566   //====================================================================== alexhb[k][i]
3567   for (int jphi = 0; jphi < njphi; jphi++) {
3568     for (int i = 0; i < nx; i++) {
3569       double sumccc1 = 0.;
3570       int isum = 0;
3571       for (int jeta = 0; jeta < njeta; jeta++) {
3572         double ccc1 = alexall[jeta][jphi][i];
3573         if (ccc1 > 0.) {
3574           sumccc1 += ccc1;
3575           isum++;
3576         }
3577       }  // for jeta
3578       if (isum > 0.)
3579         sumccc1 /= isum;
3580       alexhb[jphi][i] = sumccc1;
3581     }
3582   }  //for for
3583 
3584   //====================================================================== blexhb[k][i]
3585   for (int keta = 0; keta < njeta; keta++) {
3586     for (int i = 0; i < nx; i++) {
3587       double sumccc1 = 0.;
3588       int isum = 0;
3589       for (int kphi = 0; kphi < njphi; kphi++) {
3590         double ccc1 = alexall[keta][kphi][i];
3591         if (ccc1 > 0.) {
3592           sumccc1 += ccc1;
3593           isum++;
3594         }
3595       }  // for kphi
3596       if (isum > 0.)
3597         sumccc1 /= isum;
3598       blexhb[keta][i] = sumccc1;
3599     }
3600   }  //for for
3601 
3602   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3603   //========================================================================================== 11   HB:: 2D  jeta = 0 - 21       jphi =0 - 17
3604   //======================================================================
3605   //======================================================================
3606   //======================================================================
3607   //======================================================================
3608   cout << "      RBX HB  2D plot *****" << endl;
3609   cRBX1->Clear();
3610   /////////////////
3611   cRBX1->Divide(1, 1);
3612   cRBX1->cd(1);
3613   // int ietaphi = 0; ietaphi = ((k2+1)-1)*nphi + (k3+1) ;  k2=0-neta-1; k3=0-nphi-1; neta=18; nphi=22;
3614   //       TH2F* Ghb42D      = new TH2F("Ghb42D","",   22, -11., 11., 18, 0., 18. );
3615   //       TH2F* Ghb42D0     = new TH2F("Ghb42D0","",  22, -11., 11., 18, 0., 18. );
3616   TH2F *Ghb42D = new TH2F("Ghb42D", "", 23, -11.5, 11.5, 18, 0., 18.);
3617   TH2F *Ghb42D0 = new TH2F("Ghb42D0", "", 23, -11.5, 11.5, 18, 0., 18.);
3618   TH2F *Ghb42DF = (TH2F *)Ghb42D0->Clone("Ghb42DF");
3619   for (int jphi = 0; jphi < njphi; jphi++) {
3620     for (int jeta = 0; jeta < njeta; jeta++) {
3621       for (int i = 0; i < nx; i++) {
3622         double ccc1 = alexall[jeta][jphi][i];
3623         int neweta = jeta - 11 - 0.5;
3624         if (jeta >= 11)
3625           neweta = jeta - 11 + 1.5;
3626         if (ccc1 > 0.) {
3627           Ghb42D->Fill(neweta, jphi, ccc1);
3628           Ghb42D0->Fill(neweta, jphi, 1.);
3629         }
3630         //       if(ccc1>0.) {Ghb42D ->Fill(jeta-11,jphi,ccc1); Ghb42D0 ->Fill(jeta-11,jphi,1.); }
3631       }
3632     }
3633   }
3634   Ghb42DF->Divide(Ghb42D, Ghb42D0, 1, 1, "B");  // average A
3635   //    Ghb1->Sumw2();
3636   gPad->SetGridy();
3637   gPad->SetGridx();  //      gPad->SetLogz();
3638   Ghb42DF->SetMarkerStyle(20);
3639   Ghb42DF->SetMarkerSize(0.4);
3640   Ghb42DF->GetZaxis()->SetLabelSize(0.04);
3641   Ghb42DF->SetXTitle("<A>_RBX         #eta  \b");
3642   Ghb42DF->SetYTitle("      #phi \b");
3643   Ghb42DF->SetZTitle("<A>_RBX  - All \b");
3644   Ghb42DF->SetMarkerColor(2);
3645   Ghb42DF->SetLineColor(2);  //      Ghb42DF->SetMaximum(1.000);  //      Ghb42DF->SetMinimum(1.0);
3646   Ghb42DF->Draw("COLZ");
3647 
3648   /////////////////
3649   cRBX1->Update();
3650   cRBX1->Print("RBX-HB-2Dplot.png");
3651   cRBX1->Clear();
3652   // clean-up
3653   if (Ghb42D)
3654     delete Ghb42D;
3655   if (Ghb42D0)
3656     delete Ghb42D0;
3657   if (Ghb42DF)
3658     delete Ghb42DF;
3659 
3660   //========================================================================================== 61   HB:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
3661   //======================================================================
3662   //======================================================================
3663   //======================================================================
3664   //======================================================================
3665   cout << "      RBX HB  1D plot *****" << endl;
3666   cRBX1->Clear();
3667   /////////////////
3668   cRBX1->Divide(1, 1);
3669   cRBX1->cd(1);
3670   TH1F *GphiHB1D = new TH1F("GphiHB1D", "", 18, 0., 18.);
3671   TH1F *GphiHB1D0 = new TH1F("GphiHB1D0", "", 18, 0., 18.);
3672   TH1F *GphiHB1DF = (TH1F *)GphiHB1D0->Clone("GphiHB1DF");
3673   for (int jphi = 0; jphi < 18; jphi++) {
3674     for (int jeta = 0; jeta < 22; jeta++) {
3675       for (int i = 0; i < nx; i++) {
3676         double ccc1 = alexall[jeta][jphi][i];
3677         if (ccc1 > 0.) {
3678           GphiHB1D->Fill(jphi, ccc1);
3679           GphiHB1D0->Fill(jphi, 1.);
3680         }
3681       }
3682     }
3683   }
3684   //     GphiHB1D->Sumw2();GphiHB1D0->Sumw2();
3685   GphiHB1DF->Divide(GphiHB1D, GphiHB1D0, 1, 1, "B");  // average A
3686                                                       //     GphiHB1DF->Sumw2();
3687   for (int jphi = 1; jphi < 19; jphi++) {
3688     GphiHB1DF->SetBinError(jphi, 0.01);
3689   }
3690   gPad->SetGridy();
3691   gPad->SetGridx();  //      gPad->SetLogz();
3692   GphiHB1DF->SetMarkerStyle(20);
3693   GphiHB1DF->SetMarkerSize(1.4);
3694   GphiHB1DF->GetZaxis()->SetLabelSize(0.08);
3695   GphiHB1DF->SetXTitle("PHI of RBX\b");
3696   GphiHB1DF->SetYTitle(" <Amplitude> \b");
3697   GphiHB1DF->SetZTitle("<A>_PHI  - All \b");
3698   GphiHB1DF->SetMarkerColor(4);
3699   GphiHB1DF->SetLineColor(4);
3700   GphiHB1DF->SetMinimum(0.8);  //      GphiHB1DF->SetMaximum(1.000);
3701   GphiHB1DF->Draw("Error");
3702   /////////////////
3703   cRBX1->Update();
3704   cRBX1->Print("RBX-HB-1Dplot.png");
3705   cRBX1->Clear();
3706   // clean-up
3707   if (GphiHB1D)
3708     delete GphiHB1D;
3709   if (GphiHB1D0)
3710     delete GphiHB1D0;
3711   if (GphiHB1DF)
3712     delete GphiHB1DF;
3713 
3714   //========================================================================================== 62   HB:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
3715   //======================================================================
3716   //======================================================================
3717   //======================================================================
3718   //======================================================================
3719   cout << "      RBX HB 11D plot *eta*" << endl;
3720   cRBX1->Clear();
3721   /////////////////
3722   cRBX1->Divide(1, 1);
3723   cRBX1->cd(1);
3724   TH1F *GetaHB11D = new TH1F("GetaHB11D", "", 23, -11.5, 11.5);
3725   TH1F *GetaHB11D0 = new TH1F("GetaHB11D0", "", 23, -11.5, 11.5);
3726   TH1F *GetaHB11DF = (TH1F *)GetaHB11D0->Clone("GetaHB11DF");
3727 
3728   for (int jeta = 0; jeta < 22; jeta++) {
3729     for (int jphi = 0; jphi < 18; jphi++) {
3730       for (int i = 0; i < nx; i++) {
3731         double ccc1 = alexall[jeta][jphi][i];
3732         int neweta = jeta - 11 - 0.5;
3733         if (jeta >= 11)
3734           neweta = jeta - 11 + 1.5;
3735         if (ccc1 > 0.) {
3736           GetaHB11D->Fill(neweta, ccc1);
3737           GetaHB11D0->Fill(neweta, 1.);
3738           //           if( i == 0 ) cout<<"62  HB:  ibin=  "<< i <<"      jphi= "<< jphi <<"      jeta= "<< jeta <<"      A= "<< ccc1 <<endl;
3739         }
3740       }
3741     }
3742   }
3743   //     GetaHB11D->Sumw2();GetaHB11D0->Sumw2();
3744   GetaHB11DF->Divide(GetaHB11D, GetaHB11D0, 1, 1, "B");  // average A
3745                                                          //     GetaHB11DF->Sumw2();
3746   for (int jeta = 1; jeta < 24; jeta++) {
3747     GetaHB11DF->SetBinError(jeta, 0.01);
3748   }
3749   gPad->SetGridy();
3750   gPad->SetGridx();  //      gPad->SetLogz();
3751   GetaHB11DF->SetMarkerStyle(20);
3752   GetaHB11DF->SetMarkerSize(1.4);
3753   GetaHB11DF->GetZaxis()->SetLabelSize(0.08);
3754   GetaHB11DF->SetXTitle("#eta  \b");
3755   GetaHB11DF->SetYTitle("  <A> \b");
3756   GetaHB11DF->SetZTitle("<A>_ETA  - All \b");
3757   GetaHB11DF->SetMarkerColor(4);
3758   GetaHB11DF->SetLineColor(4);
3759   GetaHB11DF->SetMinimum(0.8);  //      GetaHB11DF->SetMaximum(1.000);
3760   GetaHB11DF->Draw("Error");
3761 
3762   /////////////////
3763   cRBX1->Update();
3764   cRBX1->Print("RBX-HB-11Dplot.png");
3765   cRBX1->Clear();
3766   // clean-up
3767   if (GetaHB11D)
3768     delete GetaHB11D;
3769   if (GetaHB11D0)
3770     delete GetaHB11D0;
3771   if (GetaHB11DF)
3772     delete GetaHB11DF;
3773 
3774   //========================================================================================== 22   HB:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
3775   //======================================================================
3776   //======================================================================22.11.2018
3777   //======================================================================
3778   //======================================================================
3779 
3780   gStyle->SetOptStat(1110000);
3781   cout << "      RBX HB  Ratio plots *****" << endl;
3782   cRBX31->Clear();
3783   /////////////////
3784   // gain stabilitY:
3785   // Rij = Aij / A1j , where i-over LSs, j-channels
3786   //
3787   //    nx = maxbinsRBX; // # LS
3788   //
3789   double ccc0HB = 0.;
3790   cRBX31->Divide(3, 1);
3791   //================
3792   cRBX31->cd(1);
3793   //    TH1F* Ghb5 = new TH1F("Ghb5","", nx, 1., nx+1.);
3794   TH1F *Ghb51 = new TH1F("Ghb51", "", nx, 1., nx + 1.);
3795   TH1F *Ghb50 = new TH1F("Ghb50", "", nx, 1., nx + 1.);
3796   TH1F *Ghb5 = (TH1F *)Ghb50->Clone("Ghb5");
3797   // j - etaphi index:
3798   for (int j = 1; j <= ny; j++) {
3799     ccc0HB = Ghb1->GetBinContent(1, j);
3800     //  if(ccc0HB <=0.) for (int i=1;i<=nx;i++) {double ccc2 =  Ghb1->GetBinContent(i,j);if(ccc2>0.){ccc0HB=ccc2;cout<<"!!! ccc0HB= "<<ccc0HB<<endl;break;} }
3801     if (ccc0HB <= 0.)
3802       for (int i = 1; i <= nx; i++) {
3803         double ccc2 = Ghb1->GetBinContent(i, j);
3804         if (ccc2 > 0.) {
3805           ccc0HB = ccc2;
3806           break;
3807         }
3808       }
3809     if (ccc0HB > 0.) {
3810       // i - # LSs:
3811       for (int i = 1; i <= nx; i++) {
3812         double ccc1 = Ghb1->GetBinContent(i, j);
3813         if (ccc1 > 0.) {
3814           double Rij = ccc1 / ccc0HB;
3815           //          Ghb5 ->Fill( float(i), Rij);
3816           Ghb51->Fill(float(i), Rij);
3817           Ghb50->Fill(float(i), 1.);
3818         }
3819       }
3820     }
3821   }
3822   Ghb5->Divide(Ghb51, Ghb50, 1, 1, "B");  // average A
3823   for (int i = 1; i <= nx; i++) {
3824     Ghb5->SetBinError(i, 0.0001);
3825   }
3826   Ghb5->SetMarkerStyle(20);
3827   Ghb5->SetMarkerSize(0.4);
3828   Ghb5->GetYaxis()->SetLabelSize(0.04);
3829   Ghb5->SetMarkerColor(2);
3830   Ghb5->SetLineColor(0);
3831   Ghb5->SetXTitle("        iLS  \b");
3832   Ghb5->SetYTitle("     <R> \b");
3833   Ghb5->SetTitle("<Ri> vs iLS \b");
3834   Ghb5->SetMinimum(0.);  //Ghb5->SetMaximum(2.5);
3835   //            gPad->SetLogy();
3836   gPad->SetGridy();
3837   gPad->SetGridx();
3838   Ghb5->SetStats(0);
3839   Ghb5->GetYaxis()->SetLabelSize(0.025);
3840   Ghb5->Draw("Error");
3841   //================
3842   cRBX31->cd(2);
3843   TH2F *Ghb60 = new TH2F("Ghb60", "", 22, -11., 11., 18, 0., 18.);
3844   TH2F *Ghb61 = new TH2F("Ghb61", "", 22, -11., 11., 18, 0., 18.);
3845   TH2F *Ghb6 = new TH2F("Ghb6", "", 22, -11., 11., 18, 0., 18.);
3846 
3847   TH2F *G20hb60 = new TH2F("G20hb60", "", 22, -11., 11., 18, 0., 18.);
3848   TH2F *G20hb61 = new TH2F("G20hb61", "", 22, -11., 11., 18, 0., 18.);
3849   TH2F *G20hb6 = new TH2F("G20hb6", "", 22, -11., 11., 18, 0., 18.);
3850   TH2F *G30hb60 = new TH2F("G30hb60", "", 22, -11., 11., 18, 0., 18.);
3851   TH2F *G30hb61 = new TH2F("G30hb61", "", 22, -11., 11., 18, 0., 18.);
3852   TH2F *G30hb6 = new TH2F("G30hb6", "", 22, -11., 11., 18, 0., 18.);
3853   TH2F *G40hb60 = new TH2F("G40hb60", "", 22, -11., 11., 18, 0., 18.);
3854   TH2F *G40hb61 = new TH2F("G40hb61", "", 22, -11., 11., 18, 0., 18.);
3855   TH2F *G40hb6 = new TH2F("G40hb6", "", 22, -11., 11., 18, 0., 18.);
3856   // j - etaphi index; i - # LSs;
3857   //
3858   // define mean and RMS:
3859   double sumjHB = 0.;
3860   int njHB = 0;
3861   double meanjHB = 0.;
3862   for (int j = 1; j <= ny; j++) {
3863     ccc0HB = Ghb1->GetBinContent(1, j);
3864     if (ccc0HB <= 0.)
3865       for (int i = 1; i <= nx; i++) {
3866         double ccc2 = Ghb1->GetBinContent(i, j);
3867         if (ccc2 > 0.) {
3868           ccc0HB = ccc2;
3869           break;
3870         }
3871       }
3872     if (ccc0HB > 0.) {
3873       for (int i = 1; i <= nx; i++) {
3874         double ccc1 = Ghb1->GetBinContent(i, j) / ccc0HB;
3875         if (ccc1 > 0.) {
3876           sumjHB += ccc1;
3877           njHB++;
3878         }
3879       }
3880       meanjHB = sumjHB / njHB;
3881     }
3882   }  // j
3883 
3884   double ssumjHB = 0.;
3885   njHB = 0;
3886   double sigmajHB = 0.;
3887   for (int j = 1; j <= ny; j++) {
3888     ccc0HB = Ghb1->GetBinContent(1, j);
3889     if (ccc0HB <= 0.)
3890       for (int i = 1; i <= nx; i++) {
3891         double ccc2 = Ghb1->GetBinContent(i, j);
3892         if (ccc2 > 0.) {
3893           ccc0HB = ccc2;
3894           break;
3895         }
3896       }
3897     if (ccc0HB > 0.) {
3898       for (int i = 1; i <= nx; i++) {
3899         double ccc1 = Ghb1->GetBinContent(i, j) / ccc0HB;
3900         if (ccc1 > 0.) {
3901           ssumjHB += (ccc1 - meanjHB) * (ccc1 - meanjHB);
3902           njHB++;
3903         }
3904       }
3905       sigmajHB = sqrt(ssumjHB / njHB);
3906     }
3907   }  // j
3908 
3909   double dif3rmsHBMIN = meanjHB - 3 * sigmajHB;
3910   if (dif3rmsHBMIN < 0.)
3911     dif3rmsHBMIN = 0.;
3912   double dif3rmsHBMAX = meanjHB + 3 * sigmajHB;
3913   cout << "22HB-2    meanjHB=  " << meanjHB << "  sigmajHB=  " << sigmajHB << "  dif3rmsHBMIN=  " << dif3rmsHBMIN
3914        << "  dif3rmsHBMAX=  " << dif3rmsHBMAX << endl;
3915 
3916   double MAXdif3rmsHBMIN = dif3rmsHBMIN;
3917   double MINdif3rmsHBMAX = dif3rmsHBMAX;
3918   if (MAXdif3rmsHBMIN < 0.95)
3919     MAXdif3rmsHBMIN = 0.95;
3920   if (MINdif3rmsHBMAX > 1.05)
3921     MINdif3rmsHBMAX = 1.05;
3922   cout << "22HB-2     MAXdif3rmsHBMIN=  " << MAXdif3rmsHBMIN << "     MINdif3rmsHBMAX=  " << MINdif3rmsHBMAX << endl;
3923   //
3924   for (int j = 1; j <= ny; j++) {
3925     ccc0HB = Ghb1->GetBinContent(1, j);
3926     if (ccc0HB <= 0.)
3927       for (int i = 1; i <= nx; i++) {
3928         double ccc2 = Ghb1->GetBinContent(i, j);
3929         if (ccc2 > 0.) {
3930           ccc0HB = ccc2;
3931           break;
3932         }
3933       }
3934     if (ccc0HB > 0.) {
3935       int jeta = (j - 1) / 18;         // jeta = 0-21
3936       int jphi = (j - 1) - 18 * jeta;  // jphi=0-17
3937       // i - # LSs:
3938       for (int i = 1; i <= nx; i++) {
3939         double ccc1 = Ghb1->GetBinContent(i, j);
3940         if (ccc1 > 0.) {
3941           double Rij = ccc1 / ccc0HB;
3942           if (Rij < MAXdif3rmsHBMIN || Rij > MINdif3rmsHBMAX) {
3943             Ghb61->Fill(jeta - 11, jphi, Rij);
3944             Ghb60->Fill(jeta - 11, jphi, 1.);
3945           }
3946           if (Rij < 0.8 || Rij > 1.2) {
3947             G20hb61->Fill(jeta - 11, jphi, Rij);
3948             G20hb60->Fill(jeta - 11, jphi, 1.);
3949           }
3950           if (Rij < 0.7 || Rij > 1.3) {
3951             G30hb61->Fill(jeta - 11, jphi, Rij);
3952             G30hb60->Fill(jeta - 11, jphi, 1.);
3953           }
3954           if (Rij < 0.6 || Rij > 1.4) {
3955             G40hb61->Fill(jeta - 11, jphi, Rij);
3956             G40hb60->Fill(jeta - 11, jphi, 1.);
3957           }
3958         }                                       //if(ccc1>0.
3959       }                                         // i
3960     }                                           //if(ccc0HB>0
3961   }                                             // j
3962   Ghb6->Divide(Ghb61, Ghb60, 1, 1, "B");        // average R
3963   G20hb6->Divide(G20hb61, G20hb60, 1, 1, "B");  // average R
3964   G30hb6->Divide(G30hb61, G30hb60, 1, 1, "B");  // average R
3965   G40hb6->Divide(G40hb61, G40hb60, 1, 1, "B");  // average R
3966 
3967   Ghb6->GetZaxis()->SetLabelSize(0.025);
3968   Ghb6->SetXTitle("             #eta  \b");
3969   Ghb6->SetYTitle("      #phi \b");
3970   Ghb6->SetTitle("<Rj> for |1-<R>| > 0.05 \b");
3971   Ghb6->SetStats(0);
3972   Ghb6->Draw("COLZ");
3973   //================
3974   cRBX31->cd(3);
3975   TH1F *Ghb7 = new TH1F("Ghb7", "", 120, 0.4, 1.6);
3976   // j - etaphi index:
3977   for (int j = 1; j <= ny; j++) {
3978     ccc0HB = Ghb1->GetBinContent(1, j);
3979     if (ccc0HB <= 0.)
3980       for (int i = 1; i <= nx; i++) {
3981         double ccc2 = Ghb1->GetBinContent(i, j);
3982         if (ccc2 > 0.) {
3983           ccc0HB = ccc2;
3984           break;
3985         }
3986       }
3987     if (ccc0HB > 0.) {
3988       // i - # LSs:
3989       for (int i = 1; i <= nx; i++) {
3990         double ccc1 = Ghb1->GetBinContent(i, j);
3991         if (ccc1 > 0.) {
3992           double Rij = ccc1 / ccc0HB;
3993           Ghb7->Fill(Rij);
3994         }
3995       }
3996     }
3997   }
3998   Ghb7->SetMarkerStyle(20);
3999   Ghb7->SetMarkerSize(0.4);
4000   Ghb7->GetYaxis()->SetLabelSize(0.04);
4001   Ghb7->SetMarkerColor(2);
4002   Ghb7->SetLineColor(0);
4003   Ghb7->SetYTitle("        N  \b");
4004   Ghb7->SetXTitle("     Rij \b");
4005   Ghb7->SetTitle(" Rij \b");
4006   //Ghb7->SetMinimum(0.8);Ghb7->SetMaximum(500.);
4007   gPad->SetGridy();
4008   gPad->SetGridx();  //            gPad->SetLogy();
4009   //      Ghb7->SetStats(1110000);
4010   Ghb7->GetYaxis()->SetLabelSize(0.025);
4011   Ghb7->Draw("Error");
4012   Float_t ymaxHB = Ghb7->GetMaximum();
4013   cout << "22HB-3   ymaxHB=  " << ymaxHB << "       MAXdif3rmsHBMIN=  " << MAXdif3rmsHBMIN
4014        << "         MINdif3rmsHBMAX=  " << MINdif3rmsHBMAX << endl;
4015   TLine *lineHB = new TLine(MAXdif3rmsHBMIN, 0., MAXdif3rmsHBMIN, ymaxHB);
4016   lineHB->SetLineColor(kBlue);
4017   lineHB->Draw();
4018   TLine *line1HB = new TLine(MINdif3rmsHBMAX, 0., MINdif3rmsHBMAX, ymaxHB);
4019   line1HB->SetLineColor(kBlue);
4020   line1HB->Draw();
4021   //================
4022   /////////////////
4023   cRBX31->Update();
4024   cRBX31->Print("RBX-HB-3plots.png");
4025   cRBX31->Clear();
4026   // clean-up
4027   if (Ghb5)
4028     delete Ghb5;
4029   if (Ghb60)
4030     delete Ghb60;
4031   if (Ghb61)
4032     delete Ghb61;
4033   if (Ghb6)
4034     delete Ghb6;
4035   if (Ghb7)
4036     delete Ghb7;
4037 
4038   if (G20hb60)
4039     delete G20hb60;
4040   if (G20hb61)
4041     delete G20hb61;
4042   if (G30hb60)
4043     delete G30hb60;
4044   if (G30hb61)
4045     delete G30hb61;
4046   if (G40hb60)
4047     delete G40hb60;
4048   if (G40hb61)
4049     delete G40hb61;
4050 
4051   if (Ghb1)
4052     delete Ghb1;
4053   //========================================================================================== 22-1   HB:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
4054   //======================================================================
4055   //======================================================================28.11.2018
4056   //======================================================================
4057   //======================================================================
4058 
4059   gStyle->SetOptStat(1110000);
4060   cout << "      RBX HB  Ratio plotsmore *****" << endl;
4061   cRBX31->Clear();
4062   /////////////////
4063   cRBX31->Divide(3, 1);
4064   //================
4065   cRBX31->cd(1);
4066   G20hb6->GetZaxis()->SetLabelSize(0.025);
4067   G20hb6->SetXTitle("             #eta  \b");
4068   G20hb6->SetYTitle("      #phi \b");
4069   G20hb6->SetTitle("<Rj> for |1-<R>| > 0.20 \b");
4070   G20hb6->SetStats(0);
4071   G20hb6->Draw("COLZ");
4072   //================
4073   cRBX31->cd(2);
4074   G30hb6->GetZaxis()->SetLabelSize(0.025);
4075   G30hb6->SetXTitle("             #eta  \b");
4076   G30hb6->SetYTitle("      #phi \b");
4077   G30hb6->SetTitle("<Rj> for |1-<R>| > 0.30 \b");
4078   G30hb6->SetStats(0);
4079   G30hb6->Draw("COLZ");
4080   //================
4081   cRBX31->cd(3);
4082   G40hb6->GetZaxis()->SetLabelSize(0.025);
4083   G40hb6->SetXTitle("             #eta  \b");
4084   G40hb6->SetYTitle("      #phi \b");
4085   G40hb6->SetTitle("<Rj> for |1-<R>| > 0.40 \b");
4086   G40hb6->SetStats(0);
4087   G40hb6->Draw("COLZ");
4088   //================
4089 
4090   /////////////////
4091   cRBX31->Update();
4092   cRBX31->Print("RBX-HB-3plotsmore.png");
4093   cRBX31->Clear();
4094 
4095   // clean-up
4096   if (G20hb6)
4097     delete G20hb6;
4098   if (G30hb6)
4099     delete G30hb6;
4100   if (G40hb6)
4101     delete G40hb6;
4102   gStyle->SetOptStat(0);
4103 
4104   ////////////////////////////////////////////////////////////////////////////////////
4105 
4106   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4107   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4108   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4109   for (int jphi = 0; jphi < njphi; jphi++) {
4110     for (int jeta = 0; jeta < njeta; jeta++) {
4111       for (int i = 0; i < nx; i++) {
4112         alexall[jeta][jphi][i] = 0.;
4113       }
4114     }
4115   }  // nulling
4116 
4117   ////////////////////////////////////////////////////////////////////////////////////   end HB RBX
4118 
4119   ////////////////////////////////////////////////////////////////////////////////////     HE::  HESTART HE: j = 3,4,5, 6, 7      14,15,16,17,18
4120   //======================================================================
4121   //======================================================================
4122   //======================================================================
4123   cout << " RBX general for HE **************************" << endl;
4124   TH2F *Ghe1KKK = (TH2F *)hfile->Get("h_2DsumADCAmplEtaPhiLs1");
4125   TH2F *Ghe1LLL = (TH2F *)hfile->Get("h_2DsumADCAmplEtaPhiLs10");
4126   TH2F *Ghe1 = (TH2F *)Ghe1LLL->Clone("Ghe1");
4127   Ghe1->Divide(Ghe1KKK, Ghe1LLL, 1, 1, "B");  // average A
4128   //    Ghe1->Sumw2();
4129   //      int nx = Ghe1->GetXaxis()->GetNbins(); // # LS
4130   //    nx = maxbinsRBX; // # LS
4131   ny = Ghe1->GetYaxis()->GetNbins();  // # jetaphi indexes
4132   for (int j = 1; j <= ny; j++) {
4133     int jeta = (j - 1) / njphi;  // jeta = 0-21
4134     if ((jeta < 8 && jeta > 2) || (jeta < 19 && jeta > 13)) {
4135       int jphi = (j - 1) - njphi * jeta;  // jphi=0-17
4136       //       cout<<"HE 54        jeta=     "<< jeta <<"   jphi   =     "<<jphi  <<endl;
4137       // over LS:
4138       for (int i = 1; i <= nx; i++) {
4139         double ccc1 = Ghe1->GetBinContent(i, j);
4140         alexall[jeta][jphi][i - 1] = ccc1;
4141         //       if( i == 1 ) cout<<"HE 54  for LS=1      ccc1=     "<< ccc1 <<endl;
4142       }  //i
4143     }    //if
4144   }      //j
4145   // clean-up
4146   if (Ghe1KKK)
4147     delete Ghe1KKK;
4148   if (Ghe1LLL)
4149     delete Ghe1LLL;
4150   //    if (Ghe1) delete Ghe1;
4151 
4152   //====================================================================== alexhe[k][i]
4153   for (int jphi = 0; jphi < njphi; jphi++) {
4154     for (int i = 0; i < nx; i++) {
4155       double sumccc1 = 0.;
4156       int isum = 0;
4157       for (int jeta = 0; jeta < njeta; jeta++) {
4158         double ccc1 = alexall[jeta][jphi][i];
4159         if (ccc1 > 0.) {
4160           sumccc1 += ccc1;
4161           isum++;
4162         }
4163       }  // for jeta
4164       if (isum > 0.)
4165         sumccc1 /= isum;
4166       alexhe[jphi][i] = sumccc1;
4167     }
4168   }  //for for
4169      //====================================================================== blexhe[k][i]
4170   for (int keta = 0; keta < njeta; keta++) {
4171     for (int i = 0; i < nx; i++) {
4172       double sumccc1 = 0.;
4173       int isum = 0;
4174       for (int kphi = 0; kphi < njphi; kphi++) {
4175         double ccc1 = alexall[keta][kphi][i];
4176         if (ccc1 > 0.) {
4177           sumccc1 += ccc1;
4178           isum++;
4179         }
4180       }  // for kphi
4181       if (isum > 0.)
4182         sumccc1 /= isum;
4183       blexhe[keta][i] = sumccc1;
4184     }
4185   }  //for for
4186   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4187   //========================================================================================== 21   HE:: 2D  jeta = 0 - 21       jphi =0 - 17
4188   //======================================================================
4189   //======================================================================
4190   //======================================================================
4191   //======================================================================
4192   cout << "      RBX HE  2D plot *****" << endl;
4193   cRBX1->Clear();
4194   /////////////////
4195   cRBX1->Divide(1, 1);
4196   cRBX1->cd(1);
4197   // int ietaphi = 0; ietaphi = ((k2+1)-1)*nphi + (k3+1) ;  k2=0-neta-1; k3=0-nphi-1; neta=18; nphi=22;
4198   TH2F *Ghe42D = new TH2F("Ghe42D", "", 23, -11.5, 11.5, 18, 0., 18.);
4199   TH2F *Ghe42D0 = new TH2F("Ghe42D0", "", 23, -11.5, 11.5, 18, 0., 18.);
4200   //       TH2F* Ghe42D      = new TH2F("Ghe42D","",   22, -11., 11., 18, 0., 18. );
4201   //       TH2F* Ghe42D0     = new TH2F("Ghe42D0","",  22, -11., 11., 18, 0., 18. );
4202   TH2F *Ghe42DF = (TH2F *)Ghe42D0->Clone("Ghe42DF");
4203   for (int jphi = 0; jphi < njphi; jphi++) {
4204     for (int jeta = 0; jeta < njeta; jeta++) {
4205       for (int i = 0; i < nx; i++) {
4206         double ccc1 = alexall[jeta][jphi][i];
4207         int neweta = jeta - 11 - 0.5;
4208         if (jeta >= 11)
4209           neweta = jeta - 11 + 1.5;
4210         if (ccc1 > 0.) {
4211           Ghe42D->Fill(neweta, jphi, ccc1);
4212           Ghe42D0->Fill(neweta, jphi, 1.);
4213         }
4214         //       if(ccc1>0.) {Ghe42D ->Fill(jeta-11,jphi,ccc1); Ghe42D0 ->Fill(jeta-11,jphi,1.); }
4215       }
4216     }
4217   }
4218   Ghe42DF->Divide(Ghe42D, Ghe42D0, 1, 1, "B");  // average A
4219   //    Ghe1->Sumw2();
4220   gPad->SetGridy();
4221   gPad->SetGridx();  //      gPad->SetLogz();
4222   Ghe42DF->SetMarkerStyle(20);
4223   Ghe42DF->SetMarkerSize(0.4);
4224   Ghe42DF->GetZaxis()->SetLabelSize(0.04);
4225   Ghe42DF->SetXTitle("<A>_RBX         #eta  \b");
4226   Ghe42DF->SetYTitle("      #phi \b");
4227   Ghe42DF->SetZTitle("<A>_RBX  - All \b");
4228   Ghe42DF->SetMarkerColor(2);
4229   Ghe42DF->SetLineColor(2);  //      Ghe42DF->SetMaximum(1.000);  //      Ghe42DF->SetMinimum(1.0);
4230   Ghe42DF->Draw("COLZ");
4231 
4232   /////////////////
4233   cRBX1->Update();
4234   cRBX1->Print("RBX-HE-2Dplot.png");
4235   cRBX1->Clear();
4236   // clean-up
4237   if (Ghe42D)
4238     delete Ghe42D;
4239   if (Ghe42D0)
4240     delete Ghe42D0;
4241   if (Ghe42DF)
4242     delete Ghe42DF;
4243 
4244   //========================================================================================== 61   HE:: 1D  j = 3,4,5, 6, 7      14,15,16,17,18         jphi =0 - 17
4245   //======================================================================
4246   //======================================================================
4247   //======================================================================
4248   //======================================================================
4249   cout << "      RBX HE  1D plot *****" << endl;
4250   cRBX1->Clear();
4251   /////////////////
4252   cRBX1->Divide(1, 1);
4253   cRBX1->cd(1);
4254   TH1F *GphiHE1D = new TH1F("GphiHE1D", "", 18, 0., 18.);
4255   TH1F *GphiHE1D0 = new TH1F("GphiHE1D0", "", 18, 0., 18.);
4256   TH1F *GphiHE1DF = (TH1F *)GphiHE1D0->Clone("GphiHE1DF");
4257   for (int jphi = 0; jphi < 18; jphi++) {
4258     for (int jeta = 0; jeta < 22; jeta++) {
4259       for (int i = 0; i < nx; i++) {
4260         double ccc1 = alexall[jeta][jphi][i];
4261         if (ccc1 > 0.) {
4262           GphiHE1D->Fill(jphi, ccc1);
4263           GphiHE1D0->Fill(jphi, 1.);
4264         }
4265       }
4266     }
4267   }
4268   //     GphiHE1D->Sumw2();GphiHE1D0->Sumw2();
4269   GphiHE1DF->Divide(GphiHE1D, GphiHE1D0, 1, 1, "B");  // average A
4270                                                       //     GphiHE1DF->Sumw2();
4271   for (int jphi = 1; jphi < 19; jphi++) {
4272     GphiHE1DF->SetBinError(jphi, 0.01);
4273   }
4274   gPad->SetGridy();
4275   gPad->SetGridx();  //      gPad->SetLogz();
4276   GphiHE1DF->SetMarkerStyle(20);
4277   GphiHE1DF->SetMarkerSize(1.4);
4278   GphiHE1DF->GetZaxis()->SetLabelSize(0.08);
4279   GphiHE1DF->SetXTitle("PHI of RBX\b");
4280   GphiHE1DF->SetYTitle(" <Amplitude> \b");
4281   GphiHE1DF->SetZTitle("<A>_PHI  - All \b");
4282   GphiHE1DF->SetMarkerColor(4);
4283   GphiHE1DF->SetLineColor(4);
4284   GphiHE1DF->SetMinimum(0.8);  //      GphiHE1DF->SetMaximum(1.000);
4285   GphiHE1DF->Draw("Error");
4286   /////////////////
4287   cRBX1->Update();
4288   cRBX1->Print("RBX-HE-1Dplot.png");
4289   cRBX1->Clear();
4290   // clean-up
4291   if (GphiHE1D)
4292     delete GphiHE1D;
4293   if (GphiHE1D0)
4294     delete GphiHE1D0;
4295   if (GphiHE1DF)
4296     delete GphiHE1DF;
4297 
4298   //========================================================================================== 62   HE:: 1D  j = 3,4,5, 6, 7      14,15,16,17,18        jphi =0 - 17
4299   //======================================================================
4300   //======================================================================
4301   //======================================================================
4302   //======================================================================
4303   cout << "      RBX HE 11D plot *eta*" << endl;
4304   cRBX1->Clear();
4305   /////////////////
4306   cRBX1->Divide(1, 1);
4307   cRBX1->cd(1);
4308   TH1F *GetaHE11D = new TH1F("GetaHE11D", "", 23, -11.5, 11.5);
4309   TH1F *GetaHE11D0 = new TH1F("GetaHE11D0", "", 23, -11.5, 11.5);
4310   TH1F *GetaHE11DF = (TH1F *)GetaHE11D0->Clone("GetaHE11DF");
4311 
4312   for (int jeta = 0; jeta < 22; jeta++) {
4313     for (int jphi = 0; jphi < 18; jphi++) {
4314       for (int i = 0; i < nx; i++) {
4315         double ccc1 = alexall[jeta][jphi][i];
4316         int neweta = jeta - 11 - 0.5;
4317         if (jeta >= 11)
4318           neweta = jeta - 11 + 1.5;
4319         if (ccc1 > 0.) {
4320           GetaHE11D->Fill(neweta, ccc1);
4321           GetaHE11D0->Fill(neweta, 1.);
4322           //           if( i == 0 ) cout<<"62  HE:  ibin=  "<< i <<"      jphi= "<< jphi <<"      jeta= "<< jeta <<"      A= "<< ccc1 <<endl;
4323         }
4324       }
4325     }
4326   }
4327   //     GetaHE11D->Sumw2();GetaHE11D0->Sumw2();
4328   GetaHE11DF->Divide(GetaHE11D, GetaHE11D0, 1, 1, "B");  // average A
4329                                                          //     GetaHE11DF->Sumw2();
4330   for (int jeta = 1; jeta < 24; jeta++) {
4331     GetaHE11DF->SetBinError(jeta, 0.01);
4332   }
4333   gPad->SetGridy();
4334   gPad->SetGridx();  //      gPad->SetLogz();
4335   GetaHE11DF->SetMarkerStyle(20);
4336   GetaHE11DF->SetMarkerSize(1.4);
4337   GetaHE11DF->GetZaxis()->SetLabelSize(0.08);
4338   GetaHE11DF->SetXTitle("#eta  \b");
4339   GetaHE11DF->SetYTitle("  <A> \b");
4340   GetaHE11DF->SetZTitle("<A>_ETA  - All \b");
4341   GetaHE11DF->SetMarkerColor(4);
4342   GetaHE11DF->SetLineColor(4);
4343   GetaHE11DF->SetMinimum(0.8);  //      GetaHE11DF->SetMaximum(1.000);
4344   GetaHE11DF->Draw("Error");
4345 
4346   /////////////////
4347   cRBX1->Update();
4348   cRBX1->Print("RBX-HE-11Dplot.png");
4349   cRBX1->Clear();
4350   // clean-up
4351   if (GetaHE11D)
4352     delete GetaHE11D;
4353   if (GetaHE11D0)
4354     delete GetaHE11D0;
4355   if (GetaHE11DF)
4356     delete GetaHE11DF;
4357 
4358   //========================================================================================== 22   HE:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
4359   //======================================================================
4360   //======================================================================22.11.2018
4361   //======================================================================
4362   //======================================================================
4363 
4364   gStyle->SetOptStat(1110000);
4365   cout << "      RBX HE  Ratio plots *****" << endl;
4366   cRBX31->Clear();
4367   /////////////////
4368   // gain stabilitY:
4369   // Rij = Aij / A1j , where i-over LSs, j-channels
4370   //
4371   //    nx = maxbinsRBX; // # LS
4372   //
4373   double ccc0HE = 0.;
4374   cRBX31->Divide(3, 1);
4375   //================
4376   cRBX31->cd(1);
4377   //      TH1F* Ghe5 = new TH1F("Ghe5","", nx, 1., nx+1.);
4378   TH1F *Ghe51 = new TH1F("Ghe51", "", nx, 1., nx + 1.);
4379   TH1F *Ghe50 = new TH1F("Ghe50", "", nx, 1., nx + 1.);
4380   TH1F *Ghe5 = (TH1F *)Ghe50->Clone("Ghe5");
4381   // j - etaphi index:
4382   for (int j = 1; j <= ny; j++) {
4383     ccc0HE = Ghe1->GetBinContent(1, j);
4384     //  if(ccc0HE <=0.) for (int i=1;i<=nx;i++) {double ccc2 =  Ghe1->GetBinContent(i,j);if(ccc2>0.){ccc0HE=ccc2;cout<<"!!! ccc0HE= "<<ccc0HE<<endl;break;} }
4385     if (ccc0HE <= 0.)
4386       for (int i = 1; i <= nx; i++) {
4387         double ccc2 = Ghe1->GetBinContent(i, j);
4388         if (ccc2 > 0.) {
4389           ccc0HE = ccc2;
4390           break;
4391         }
4392       }
4393     if (ccc0HE > 0.) {
4394       // i - # LSs:
4395       for (int i = 1; i <= nx; i++) {
4396         double ccc1 = Ghe1->GetBinContent(i, j);
4397         if (ccc1 > 0.) {
4398           double Rij = ccc1 / ccc0HE;
4399           //          Ghe5 ->Fill( float(i), Rij);
4400           Ghe51->Fill(float(i), Rij);
4401           Ghe50->Fill(float(i), 1.);
4402         }
4403       }
4404     }
4405   }
4406   Ghe5->Divide(Ghe51, Ghe50, 1, 1, "B");  // average A
4407   for (int i = 1; i <= nx; i++) {
4408     Ghe5->SetBinError(i, 0.0001);
4409   }
4410   Ghe5->SetMarkerStyle(20);
4411   Ghe5->SetMarkerSize(0.4);
4412   Ghe5->GetYaxis()->SetLabelSize(0.04);
4413   Ghe5->SetMarkerColor(2);
4414   Ghe5->SetLineColor(0);
4415   Ghe5->SetXTitle("        iLS  \b");
4416   Ghe5->SetYTitle("     <R> \b");
4417   Ghe5->SetTitle("<Ri> vs iLS \b");
4418   Ghe5->SetMinimum(0.);  //Ghe5->SetMaximum(2.5);
4419   //            gPad->SetLogy();
4420   gPad->SetGridy();
4421   gPad->SetGridx();
4422   Ghe5->SetStats(0);
4423   Ghe5->GetYaxis()->SetLabelSize(0.025);
4424   Ghe5->Draw("Error");
4425   //================
4426   cRBX31->cd(2);
4427   TH2F *Ghe60 = new TH2F("Ghe60", "", 22, -11., 11., 18, 0., 18.);
4428   TH2F *Ghe61 = new TH2F("Ghe61", "", 22, -11., 11., 18, 0., 18.);
4429   TH2F *Ghe6 = new TH2F("Ghe6", "", 22, -11., 11., 18, 0., 18.);
4430 
4431   TH2F *G20he60 = new TH2F("G20he60", "", 22, -11., 11., 18, 0., 18.);
4432   TH2F *G20he61 = new TH2F("G20he61", "", 22, -11., 11., 18, 0., 18.);
4433   TH2F *G20he6 = new TH2F("G20he6", "", 22, -11., 11., 18, 0., 18.);
4434   TH2F *G30he60 = new TH2F("G30he60", "", 22, -11., 11., 18, 0., 18.);
4435   TH2F *G30he61 = new TH2F("G30he61", "", 22, -11., 11., 18, 0., 18.);
4436   TH2F *G30he6 = new TH2F("G30he6", "", 22, -11., 11., 18, 0., 18.);
4437   TH2F *G40he60 = new TH2F("G40he60", "", 22, -11., 11., 18, 0., 18.);
4438   TH2F *G40he61 = new TH2F("G40he61", "", 22, -11., 11., 18, 0., 18.);
4439   TH2F *G40he6 = new TH2F("G40he6", "", 22, -11., 11., 18, 0., 18.);
4440   // j - etaphi index; i - # LSs;
4441   //
4442   // define mean and RMS:
4443   double sumjHE = 0.;
4444   int njHE = 0;
4445   double meanjHE = 0.;
4446   for (int j = 1; j <= ny; j++) {
4447     ccc0HE = Ghe1->GetBinContent(1, j);
4448     if (ccc0HE <= 0.)
4449       for (int i = 1; i <= nx; i++) {
4450         double ccc2 = Ghe1->GetBinContent(i, j);
4451         if (ccc2 > 0.) {
4452           ccc0HE = ccc2;
4453           break;
4454         }
4455       }
4456     if (ccc0HE > 0.) {
4457       for (int i = 1; i <= nx; i++) {
4458         double ccc1 = Ghe1->GetBinContent(i, j) / ccc0HE;
4459         if (ccc1 > 0.) {
4460           sumjHE += ccc1;
4461           njHE++;
4462         }
4463       }
4464       meanjHE = sumjHE / njHE;
4465     }
4466   }  // j
4467 
4468   double ssumjHE = 0.;
4469   njHE = 0;
4470   double sigmajHE = 0.;
4471   for (int j = 1; j <= ny; j++) {
4472     ccc0HE = Ghe1->GetBinContent(1, j);
4473     if (ccc0HE <= 0.)
4474       for (int i = 1; i <= nx; i++) {
4475         double ccc2 = Ghe1->GetBinContent(i, j);
4476         if (ccc2 > 0.) {
4477           ccc0HE = ccc2;
4478           break;
4479         }
4480       }
4481     if (ccc0HE > 0.) {
4482       for (int i = 1; i <= nx; i++) {
4483         double ccc1 = Ghe1->GetBinContent(i, j) / ccc0HE;
4484         if (ccc1 > 0.) {
4485           ssumjHE += (ccc1 - meanjHE) * (ccc1 - meanjHE);
4486           njHE++;
4487         }
4488       }
4489       sigmajHE = sqrt(ssumjHE / njHE);
4490     }
4491   }  // j
4492 
4493   double dif3rmsHEMIN = meanjHE - 3 * sigmajHE;
4494   if (dif3rmsHEMIN < 0.)
4495     dif3rmsHEMIN = 0.;
4496   double dif3rmsHEMAX = meanjHE + 3 * sigmajHE;
4497   cout << "22HE-2    meanjHE=  " << meanjHE << "  sigmajHE=  " << sigmajHE << "  dif3rmsHEMIN=  " << dif3rmsHEMIN
4498        << "  dif3rmsHEMAX=  " << dif3rmsHEMAX << endl;
4499 
4500   double MAXdif3rmsHEMIN = dif3rmsHEMIN;
4501   double MINdif3rmsHEMAX = dif3rmsHEMAX;
4502   if (MAXdif3rmsHEMIN < 0.95)
4503     MAXdif3rmsHEMIN = 0.95;
4504   if (MINdif3rmsHEMAX > 1.05)
4505     MINdif3rmsHEMAX = 1.05;
4506   cout << "22HE-2     MAXdif3rmsHEMIN=  " << MAXdif3rmsHEMIN << "     MINdif3rmsHEMAX=  " << MINdif3rmsHEMAX << endl;
4507   //
4508   for (int j = 1; j <= ny; j++) {
4509     ccc0HE = Ghe1->GetBinContent(1, j);
4510     if (ccc0HE <= 0.)
4511       for (int i = 1; i <= nx; i++) {
4512         double ccc2 = Ghe1->GetBinContent(i, j);
4513         if (ccc2 > 0.) {
4514           ccc0HE = ccc2;
4515           break;
4516         }
4517       }
4518     if (ccc0HE > 0.) {
4519       int jeta = (j - 1) / 18;         // jeta = 0-21
4520       int jphi = (j - 1) - 18 * jeta;  // jphi=0-17
4521       // i - # LSs:
4522       for (int i = 1; i <= nx; i++) {
4523         double ccc1 = Ghe1->GetBinContent(i, j);
4524         if (ccc1 > 0.) {
4525           double Rij = ccc1 / ccc0HE;
4526           if (Rij < MAXdif3rmsHEMIN || Rij > MINdif3rmsHEMAX) {
4527             Ghe61->Fill(jeta - 11, jphi, Rij);
4528             Ghe60->Fill(jeta - 11, jphi, 1.);
4529           }
4530           if (Rij < 0.8 || Rij > 1.2) {
4531             G20he61->Fill(jeta - 11, jphi, Rij);
4532             G20he60->Fill(jeta - 11, jphi, 1.);
4533           }
4534           if (Rij < 0.7 || Rij > 1.3) {
4535             G30he61->Fill(jeta - 11, jphi, Rij);
4536             G30he60->Fill(jeta - 11, jphi, 1.);
4537           }
4538           if (Rij < 0.6 || Rij > 1.4) {
4539             G40he61->Fill(jeta - 11, jphi, Rij);
4540             G40he60->Fill(jeta - 11, jphi, 1.);
4541           }
4542         }                                       //if(ccc1>0.
4543       }                                         // i
4544     }                                           //if(ccc0HE>0
4545   }                                             // j
4546   Ghe6->Divide(Ghe61, Ghe60, 1, 1, "B");        // average R
4547   G20he6->Divide(G20he61, G20he60, 1, 1, "B");  // average R
4548   G30he6->Divide(G30he61, G30he60, 1, 1, "B");  // average R
4549   G40he6->Divide(G40he61, G40he60, 1, 1, "B");  // average R
4550 
4551   //      Ghe6->SetLabelOffset (Float_t offset=0.005, Option_t *axis="X")//Set offset between axis and axis' labels
4552   //      Ghe6->GetZaxis()->SetLabelOffset(-0.05);
4553   Ghe6->GetZaxis()->SetLabelSize(0.025);
4554 
4555   Ghe6->SetXTitle("             #eta  \b");
4556   Ghe6->SetYTitle("      #phi \b");
4557   Ghe6->SetTitle(
4558       "<Rj> for |1-<R>| > 0.05 \b");  //      Ghe6->SetMaximum(1.000);  //      Ghe6->SetMinimum(1.0); //Ghe6->SetZTitle("Rij averaged over LSs \b"); //Ghe6->GetZaxis()->SetLabelSize(0.04); //Ghe6->SetMarkerStyle(20);// Ghe6->SetMarkerSize(0.4);//Ghe6->SetMarkerColor(2); //Ghe6->SetLineColor(2);
4559   //gStyle->SetOptStat(kFALSE);
4560   Ghe6->SetStats(0);
4561   Ghe6->Draw("COLZ");
4562   //================
4563   cRBX31->cd(3);
4564   TH1F *Ghe7 = new TH1F("Ghe7", "", 120, 0.4, 1.6);
4565   // j - etaphi index:
4566   for (int j = 1; j <= ny; j++) {
4567     ccc0HE = Ghe1->GetBinContent(1, j);
4568     if (ccc0HE <= 0.)
4569       for (int i = 1; i <= nx; i++) {
4570         double ccc2 = Ghe1->GetBinContent(i, j);
4571         if (ccc2 > 0.) {
4572           ccc0HE = ccc2;
4573           break;
4574         }
4575       }
4576     if (ccc0HE > 0.) {
4577       // i - # LSs:
4578       for (int i = 1; i <= nx; i++) {
4579         double ccc1 = Ghe1->GetBinContent(i, j);
4580         if (ccc1 > 0.) {
4581           double Rij = ccc1 / ccc0HE;
4582           Ghe7->Fill(Rij);
4583         }
4584       }
4585     }
4586   }
4587   Ghe7->SetMarkerStyle(20);
4588   Ghe7->SetMarkerSize(0.4);
4589   Ghe7->GetYaxis()->SetLabelSize(0.04);
4590   Ghe7->SetMarkerColor(2);
4591   Ghe7->SetLineColor(0);
4592   Ghe7->SetYTitle("        N  \b");
4593   Ghe7->SetXTitle("     Rij \b");
4594   Ghe7->SetTitle(" Rij \b");
4595   //Ghe7->SetMinimum(0.8);Ghe7->SetMaximum(500.);
4596   gPad->SetGridy();
4597   gPad->SetGridx();  //            gPad->SetLogy();
4598   //      Ghe7->SetStats(1110000);
4599   Ghe7->GetYaxis()->SetLabelSize(0.025);
4600   Ghe7->Draw("Error");
4601   Float_t ymaxHE = Ghe7->GetMaximum();
4602   cout << "22HE-3   ymaxHE=  " << ymaxHE << "       MAXdif3rmsHEMIN=  " << MAXdif3rmsHEMIN
4603        << "         MINdif3rmsHEMAX=  " << MINdif3rmsHEMAX << endl;
4604   TLine *lineHE = new TLine(MAXdif3rmsHEMIN, 0., MAXdif3rmsHEMIN, ymaxHE);
4605   lineHE->SetLineColor(kBlue);
4606   lineHE->Draw();
4607   TLine *line1HE = new TLine(MINdif3rmsHEMAX, 0., MINdif3rmsHEMAX, ymaxHE);
4608   line1HE->SetLineColor(kBlue);
4609   line1HE->Draw();
4610   //================
4611   /////////////////
4612   cRBX31->Update();
4613   cRBX31->Print("RBX-HE-3plots.png");
4614   cRBX31->Clear();
4615   // clean-up
4616   if (Ghe5)
4617     delete Ghe5;
4618   if (Ghe60)
4619     delete Ghe60;
4620   if (Ghe61)
4621     delete Ghe61;
4622   if (Ghe6)
4623     delete Ghe6;
4624   if (Ghe7)
4625     delete Ghe7;
4626 
4627   if (G20he60)
4628     delete G20he60;
4629   if (G20he61)
4630     delete G20he61;
4631   if (G30he60)
4632     delete G30he60;
4633   if (G30he61)
4634     delete G30he61;
4635   if (G40he60)
4636     delete G40he60;
4637   if (G40he61)
4638     delete G40he61;
4639 
4640   if (Ghe1)
4641     delete Ghe1;
4642   //========================================================================================== 22-1   HE:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
4643   //======================================================================
4644   //======================================================================28.11.2018
4645   //======================================================================
4646   //======================================================================
4647 
4648   gStyle->SetOptStat(1110000);
4649   cout << "      RBX HE  Ratio plotsmore *****" << endl;
4650   cRBX31->Clear();
4651   /////////////////
4652   cRBX31->Divide(3, 1);
4653   //================
4654   cRBX31->cd(1);
4655   G20he6->GetZaxis()->SetLabelSize(0.025);
4656   G20he6->SetXTitle("             #eta  \b");
4657   G20he6->SetYTitle("      #phi \b");
4658   G20he6->SetTitle("<Rj> for |1-<R>| > 0.20 \b");
4659   G20he6->SetStats(0);
4660   G20he6->Draw("COLZ");
4661   //================
4662   cRBX31->cd(2);
4663   G30he6->GetZaxis()->SetLabelSize(0.025);
4664   G30he6->SetXTitle("             #eta  \b");
4665   G30he6->SetYTitle("      #phi \b");
4666   G30he6->SetTitle("<Rj> for |1-<R>| > 0.30 \b");
4667   G30he6->SetStats(0);
4668   G30he6->Draw("COLZ");
4669   //================
4670   cRBX31->cd(3);
4671   G40he6->GetZaxis()->SetLabelSize(0.025);
4672   G40he6->SetXTitle("             #eta  \b");
4673   G40he6->SetYTitle("      #phi \b");
4674   G40he6->SetTitle("<Rj> for |1-<R>| > 0.40 \b");
4675   G40he6->SetStats(0);
4676   G40he6->Draw("COLZ");
4677   //================
4678 
4679   /////////////////
4680   cRBX31->Update();
4681   cRBX31->Print("RBX-HE-3plotsmore.png");
4682   cRBX31->Clear();
4683 
4684   // clean-up
4685   if (G20he6)
4686     delete G20he6;
4687   if (G30he6)
4688     delete G30he6;
4689   if (G40he6)
4690     delete G40he6;
4691   gStyle->SetOptStat(0);
4692   ////////////////////////////////////////////////////////////////////////////////////
4693 
4694   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4695   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4696   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4697   for (int jphi = 0; jphi < njphi; jphi++) {
4698     for (int jeta = 0; jeta < njeta; jeta++) {
4699       for (int i = 0; i < nx; i++) {
4700         alexall[jeta][jphi][i] = 0.;
4701       }
4702     }
4703   }  // nulling
4704 
4705   ////////////////////////////////////////////////////////////////////////////////////   end HE RBX
4706 
4707   ////////////////////////////////////////////////////////////////////////////////////     HO::  HOSTART HO: j = 7,8,9,10            11,12,13,14
4708   //======================================================================
4709   //======================================================================
4710   //======================================================================
4711   cout << " RBX general for HO **************************" << endl;
4712   TH2F *Gho1KKK = (TH2F *)hfile->Get("h_2DsumADCAmplEtaPhiLs2");
4713   TH2F *Gho1LLL = (TH2F *)hfile->Get("h_2DsumADCAmplEtaPhiLs20");
4714   TH2F *Gho1 = (TH2F *)Gho1LLL->Clone("Gho1");
4715   Gho1->Divide(Gho1KKK, Gho1LLL, 1, 1, "B");  // average A
4716   //    Gho1->Sumw2();
4717   //      int nx = Gho1->GetXaxis()->GetNbins(); // # LS
4718   //    nx = maxbinsRBX; // # LS
4719   ny = Gho1->GetYaxis()->GetNbins();  // # jetaphi indexes
4720   for (int j = 1; j <= ny; j++) {
4721     int jeta = (j - 1) / njphi;  // jeta = 0-21
4722     if (jeta < 15 && jeta > 6) {
4723       int jphi = (j - 1) - njphi * jeta;  // jphi=0-17
4724       //       cout<<"HO 54        jeta=     "<< jeta <<"   jphi   =     "<<jphi  <<endl;
4725       // over LS:
4726       for (int i = 1; i <= nx; i++) {
4727         double ccc1 = Gho1->GetBinContent(i, j);
4728         alexall[jeta][jphi][i - 1] = ccc1;
4729         //       if( i == 1 ) cout<<"HO 54  for LS=1      ccc1=     "<< ccc1 <<endl;
4730       }  //i
4731     }    //if
4732   }      //j
4733   // clean-up
4734   if (Gho1KKK)
4735     delete Gho1KKK;
4736   if (Gho1LLL)
4737     delete Gho1LLL;
4738   //    if (Gho1) delete Gho1;
4739 
4740   //====================================================================== alexho[k][i]
4741   for (int jphi = 0; jphi < njphi; jphi++) {
4742     for (int i = 0; i < nx; i++) {
4743       double sumccc1 = 0.;
4744       int isum = 0;
4745       for (int jeta = 0; jeta < njeta; jeta++) {
4746         double ccc1 = alexall[jeta][jphi][i];
4747         if (ccc1 > 0.) {
4748           sumccc1 += ccc1;
4749           isum++;
4750         }
4751       }  // for jeta
4752       if (isum > 0.)
4753         sumccc1 /= isum;
4754       alexho[jphi][i] = sumccc1;
4755     }
4756   }  //for for
4757      //====================================================================== blexho[k][i]
4758   for (int keta = 0; keta < njeta; keta++) {
4759     for (int i = 0; i < nx; i++) {
4760       double sumccc1 = 0.;
4761       int isum = 0;
4762       for (int kphi = 0; kphi < njphi; kphi++) {
4763         double ccc1 = alexall[keta][kphi][i];
4764         if (ccc1 > 0.) {
4765           sumccc1 += ccc1;
4766           isum++;
4767         }
4768       }  // for kphi
4769       if (isum > 0.)
4770         sumccc1 /= isum;
4771       blexho[keta][i] = sumccc1;
4772     }
4773   }  //for for
4774 
4775   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4776   //========================================================================================== 33   HO:: 2D  jeta = 0 - 21       jphi =0 - 17
4777   //======================================================================
4778   //======================================================================
4779   //======================================================================
4780   //======================================================================
4781   cout << "      RBX HO  2D plot *****" << endl;
4782   cRBX1->Clear();
4783   /////////////////
4784   cRBX1->Divide(1, 1);
4785   cRBX1->cd(1);
4786   // int ietaphi = 0; ietaphi = ((k2+1)-1)*nphi + (k3+1) ;  k2=0-neta-1; k3=0-nphi-1; neta=18; nphi=22;
4787   TH2F *Gho42D = new TH2F("Gho42D", "", 23, -11.5, 11.5, 18, 0., 18.);
4788   TH2F *Gho42D0 = new TH2F("Gho42D0", "", 23, -11.5, 11.5, 18, 0., 18.);
4789   //     TH2F* Gho42D      = new TH2F("Gho42D","",   22, -11., 11., 18, 0., 18. );
4790   //     TH2F* Gho42D0     = new TH2F("Gho42D0","",  22, -11., 11., 18, 0., 18. );
4791   TH2F *Gho42DF = (TH2F *)Gho42D0->Clone("Gho42DF");
4792   for (int jphi = 0; jphi < njphi; jphi++) {
4793     for (int jeta = 0; jeta < njeta; jeta++) {
4794       for (int i = 0; i < nx; i++) {
4795         double ccc1 = alexall[jeta][jphi][i];
4796         int neweta = jeta - 11 - 0.5;
4797         if (jeta >= 11)
4798           neweta = jeta - 11 + 1.5;
4799         if (ccc1 > 0.) {
4800           Gho42D->Fill(neweta, jphi, ccc1);
4801           Gho42D0->Fill(neweta, jphi, 1.);
4802         }
4803         //       if(ccc1>0.) {Gho42D ->Fill(jeta-11,jphi,ccc1); Gho42D0 ->Fill(jeta-11,jphi,1.); }
4804       }
4805     }
4806   }
4807   Gho42DF->Divide(Gho42D, Gho42D0, 1, 1, "B");  // average A
4808   //    Gho1->Sumw2();
4809   gPad->SetGridy();
4810   gPad->SetGridx();  //      gPad->SetLogz();
4811   Gho42DF->SetMarkerStyle(20);
4812   Gho42DF->SetMarkerSize(0.4);
4813   Gho42DF->GetZaxis()->SetLabelSize(0.04);
4814   Gho42DF->SetXTitle("<A>_RBX         #eta  \b");
4815   Gho42DF->SetYTitle("      #phi \b");
4816   Gho42DF->SetZTitle("<A>_RBX  - All \b");
4817   Gho42DF->SetMarkerColor(2);
4818   Gho42DF->SetLineColor(2);  //      Gho42DF->SetMaximum(1.000);  //      Gho42DF->SetMinimum(1.0);
4819   Gho42DF->Draw("COLZ");
4820 
4821   /////////////////
4822   cRBX1->Update();
4823   cRBX1->Print("RBX-HO-2Dplot.png");
4824   cRBX1->Clear();
4825   // clean-up
4826   if (Gho42D)
4827     delete Gho42D;
4828   if (Gho42D0)
4829     delete Gho42D0;
4830   if (Gho42DF)
4831     delete Gho42DF;
4832 
4833   //========================================================================================== 61   HO:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
4834   //======================================================================
4835   //======================================================================
4836   //======================================================================
4837   //======================================================================
4838   cout << "      RBX HO  1D plot *****" << endl;
4839   cRBX1->Clear();
4840   /////////////////
4841   cRBX1->Divide(1, 1);
4842   cRBX1->cd(1);
4843   TH1F *GphiHO1D = new TH1F("GphiHO1D", "", 18, 0., 18.);
4844   TH1F *GphiHO1D0 = new TH1F("GphiHO1D0", "", 18, 0., 18.);
4845   TH1F *GphiHO1DF = (TH1F *)GphiHO1D0->Clone("GphiHO1DF");
4846   for (int jphi = 0; jphi < 18; jphi++) {
4847     for (int jeta = 0; jeta < 22; jeta++) {
4848       for (int i = 0; i < nx; i++) {
4849         double ccc1 = alexall[jeta][jphi][i];
4850         if (ccc1 > 0.) {
4851           GphiHO1D->Fill(jphi, ccc1);
4852           GphiHO1D0->Fill(jphi, 1.);
4853         }
4854       }
4855     }
4856   }
4857   //     GphiHO1D->Sumw2();GphiHO1D0->Sumw2();
4858   GphiHO1DF->Divide(GphiHO1D, GphiHO1D0, 1, 1, "B");  // average A
4859                                                       //     GphiHO1DF->Sumw2();
4860   for (int jphi = 1; jphi < 19; jphi++) {
4861     GphiHO1DF->SetBinError(jphi, 0.01);
4862   }
4863   gPad->SetGridy();
4864   gPad->SetGridx();  //      gPad->SetLogz();
4865   GphiHO1DF->SetMarkerStyle(20);
4866   GphiHO1DF->SetMarkerSize(1.4);
4867   GphiHO1DF->GetZaxis()->SetLabelSize(0.08);
4868   GphiHO1DF->SetXTitle("PHI of RBX\b");
4869   GphiHO1DF->SetYTitle(" <Amplitude> \b");
4870   GphiHO1DF->SetZTitle("<A>_PHI  - All \b");
4871   GphiHO1DF->SetMarkerColor(4);
4872   GphiHO1DF->SetLineColor(4);
4873   GphiHO1DF->SetMinimum(0.8);  //      GphiHO1DF->SetMaximum(1.000);
4874   GphiHO1DF->Draw("Error");
4875   /////////////////
4876   cRBX1->Update();
4877   cRBX1->Print("RBX-HO-1Dplot.png");
4878   cRBX1->Clear();
4879   // clean-up
4880   if (GphiHO1D)
4881     delete GphiHO1D;
4882   if (GphiHO1D0)
4883     delete GphiHO1D0;
4884   if (GphiHO1DF)
4885     delete GphiHO1DF;
4886 
4887   //========================================================================================== 62   HO:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
4888   //======================================================================
4889   //======================================================================
4890   //======================================================================
4891   //======================================================================
4892   cout << "      RBX HO 11D plot *eta*" << endl;
4893   cRBX1->Clear();
4894   /////////////////
4895   cRBX1->Divide(1, 1);
4896   cRBX1->cd(1);
4897   TH1F *GetaHO11D = new TH1F("GetaHO11D", "", 23, -11.5, 11.5);
4898   TH1F *GetaHO11D0 = new TH1F("GetaHO11D0", "", 23, -11.5, 11.5);
4899   TH1F *GetaHO11DF = (TH1F *)GetaHO11D0->Clone("GetaHO11DF");
4900 
4901   for (int jeta = 0; jeta < 22; jeta++) {
4902     for (int jphi = 0; jphi < 18; jphi++) {
4903       for (int i = 0; i < nx; i++) {
4904         double ccc1 = alexall[jeta][jphi][i];
4905         int neweta = jeta - 11 - 0.5;
4906         if (jeta >= 11)
4907           neweta = jeta - 11 + 1.5;
4908         if (ccc1 > 0.) {
4909           GetaHO11D->Fill(neweta, ccc1);
4910           GetaHO11D0->Fill(neweta, 1.);
4911           //           if( i == 0 ) cout<<"62  HO:  ibin=  "<< i <<"      jphi= "<< jphi <<"      jeta= "<< jeta <<"      A= "<< ccc1 <<endl;
4912         }
4913       }
4914     }
4915   }
4916   //     GetaHO11D->Sumw2();GetaHO11D0->Sumw2();
4917   GetaHO11DF->Divide(GetaHO11D, GetaHO11D0, 1, 1, "B");  // average A
4918                                                          //     GetaHO11DF->Sumw2();
4919   for (int jeta = 1; jeta < 24; jeta++) {
4920     GetaHO11DF->SetBinError(jeta, 0.01);
4921   }
4922   gPad->SetGridy();
4923   gPad->SetGridx();  //      gPad->SetLogz();
4924   GetaHO11DF->SetMarkerStyle(20);
4925   GetaHO11DF->SetMarkerSize(1.4);
4926   GetaHO11DF->GetZaxis()->SetLabelSize(0.08);
4927   GetaHO11DF->SetXTitle("#eta  \b");
4928   GetaHO11DF->SetYTitle("  <A> \b");
4929   GetaHO11DF->SetZTitle("<A>_ETA  - All \b");
4930   GetaHO11DF->SetMarkerColor(4);
4931   GetaHO11DF->SetLineColor(4);
4932   GetaHO11DF->SetMinimum(0.8);  //      GetaHO11DF->SetMaximum(1.000);
4933   GetaHO11DF->Draw("Error");
4934 
4935   /////////////////
4936   cRBX1->Update();
4937   cRBX1->Print("RBX-HO-11Dplot.png");
4938   cRBX1->Clear();
4939   // clean-up
4940   if (GetaHO11D)
4941     delete GetaHO11D;
4942   if (GetaHO11D0)
4943     delete GetaHO11D0;
4944   if (GetaHO11DF)
4945     delete GetaHO11DF;
4946 
4947   //========================================================================================== 22   HO:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
4948   //======================================================================
4949   //======================================================================22.11.2018
4950   //======================================================================
4951   //======================================================================
4952 
4953   gStyle->SetOptStat(1110000);
4954   cout << "      RBX HO  Ratio plots *****" << endl;
4955   cRBX31->Clear();
4956   /////////////////
4957   // gain stabilitY:
4958   // Rij = Aij / A1j , where i-over LSs, j-channels
4959   //
4960   //    nx = maxbinsRBX; // # LS
4961   //
4962   double ccc0HO = 0.;
4963   cRBX31->Divide(3, 1);
4964   //================
4965   cRBX31->cd(1);
4966   //    TH1F* Gho5 = new TH1F("Gho5","", nx, 1., nx+1.);
4967   TH1F *Gho51 = new TH1F("Gho51", "", nx, 1., nx + 1.);
4968   TH1F *Gho50 = new TH1F("Gho50", "", nx, 1., nx + 1.);
4969   TH1F *Gho5 = (TH1F *)Gho50->Clone("Gho5");
4970   // j - etaphi index:
4971   for (int j = 1; j <= ny; j++) {
4972     ccc0HO = Gho1->GetBinContent(1, j);
4973     //  if(ccc0HO <=0.) for (int i=1;i<=nx;i++) {double ccc2 =  Gho1->GetBinContent(i,j);if(ccc2>0.){ccc0HO=ccc2;cout<<"!!! ccc0HO= "<<ccc0HO<<endl;break;} }
4974     if (ccc0HO <= 0.)
4975       for (int i = 1; i <= nx; i++) {
4976         double ccc2 = Gho1->GetBinContent(i, j);
4977         if (ccc2 > 0.) {
4978           ccc0HO = ccc2;
4979           break;
4980         }
4981       }
4982     if (ccc0HO > 0.) {
4983       // i - # LSs:
4984       for (int i = 1; i <= nx; i++) {
4985         double ccc1 = Gho1->GetBinContent(i, j);
4986         if (ccc1 > 0.) {
4987           double Rij = ccc1 / ccc0HO;
4988           //          Gho5 ->Fill( float(i), Rij);
4989           Gho51->Fill(float(i), Rij);
4990           Gho50->Fill(float(i), 1.);
4991         }
4992       }
4993     }
4994   }
4995   Gho5->Divide(Gho51, Gho50, 1, 1, "B");  // average A
4996   for (int i = 1; i <= nx; i++) {
4997     Gho5->SetBinError(i, 0.0001);
4998   }
4999   Gho5->SetMarkerStyle(20);
5000   Gho5->SetMarkerSize(0.4);
5001   Gho5->GetYaxis()->SetLabelSize(0.04);
5002   Gho5->SetMarkerColor(2);
5003   Gho5->SetLineColor(0);
5004   Gho5->SetXTitle("        iLS  \b");
5005   Gho5->SetYTitle("     <R> \b");
5006   Gho5->SetTitle("<Ri> vs iLS \b");
5007   Gho5->SetMinimum(0.);  //Gho5->SetMaximum(2.5);
5008   //            gPad->SetLogy();
5009   gPad->SetGridy();
5010   gPad->SetGridx();
5011   Gho5->SetStats(0);
5012   Gho5->GetYaxis()->SetLabelSize(0.025);
5013   Gho5->Draw("Error");
5014   //================
5015   cRBX31->cd(2);
5016   TH2F *Gho60 = new TH2F("Gho60", "", 22, -11., 11., 18, 0., 18.);
5017   TH2F *Gho61 = new TH2F("Gho61", "", 22, -11., 11., 18, 0., 18.);
5018   TH2F *Gho6 = new TH2F("Gho6", "", 22, -11., 11., 18, 0., 18.);
5019 
5020   TH2F *G20ho60 = new TH2F("G20ho60", "", 22, -11., 11., 18, 0., 18.);
5021   TH2F *G20ho61 = new TH2F("G20ho61", "", 22, -11., 11., 18, 0., 18.);
5022   TH2F *G20ho6 = new TH2F("G20ho6", "", 22, -11., 11., 18, 0., 18.);
5023   TH2F *G30ho60 = new TH2F("G30ho60", "", 22, -11., 11., 18, 0., 18.);
5024   TH2F *G30ho61 = new TH2F("G30ho61", "", 22, -11., 11., 18, 0., 18.);
5025   TH2F *G30ho6 = new TH2F("G30ho6", "", 22, -11., 11., 18, 0., 18.);
5026   TH2F *G40ho60 = new TH2F("G40ho60", "", 22, -11., 11., 18, 0., 18.);
5027   TH2F *G40ho61 = new TH2F("G40ho61", "", 22, -11., 11., 18, 0., 18.);
5028   TH2F *G40ho6 = new TH2F("G40ho6", "", 22, -11., 11., 18, 0., 18.);
5029 
5030   // j - etaphi index; i - # LSs;
5031   //
5032   // define mean and RMS:
5033   double sumjHO = 0.;
5034   int njHO = 0;
5035   double meanjHO = 0.;
5036   for (int j = 1; j <= ny; j++) {
5037     ccc0HO = Gho1->GetBinContent(1, j);
5038     if (ccc0HO <= 0.)
5039       for (int i = 1; i <= nx; i++) {
5040         double ccc2 = Gho1->GetBinContent(i, j);
5041         if (ccc2 > 0.) {
5042           ccc0HO = ccc2;
5043           break;
5044         }
5045       }
5046     if (ccc0HO > 0.) {
5047       for (int i = 1; i <= nx; i++) {
5048         double ccc1 = Gho1->GetBinContent(i, j) / ccc0HO;
5049         if (ccc1 > 0.) {
5050           sumjHO += ccc1;
5051           njHO++;
5052         }
5053       }
5054       meanjHO = sumjHO / njHO;
5055     }
5056   }  // j
5057 
5058   double ssumjHO = 0.;
5059   njHO = 0;
5060   double sigmajHO = 0.;
5061   for (int j = 1; j <= ny; j++) {
5062     ccc0HO = Gho1->GetBinContent(1, j);
5063     if (ccc0HO <= 0.)
5064       for (int i = 1; i <= nx; i++) {
5065         double ccc2 = Gho1->GetBinContent(i, j);
5066         if (ccc2 > 0.) {
5067           ccc0HO = ccc2;
5068           break;
5069         }
5070       }
5071     if (ccc0HO > 0.) {
5072       for (int i = 1; i <= nx; i++) {
5073         double ccc1 = Gho1->GetBinContent(i, j) / ccc0HO;
5074         if (ccc1 > 0.) {
5075           ssumjHO += (ccc1 - meanjHO) * (ccc1 - meanjHO);
5076           njHO++;
5077         }
5078       }
5079       sigmajHO = sqrt(ssumjHO / njHO);
5080     }
5081   }  // j
5082 
5083   double dif3rmsHOMIN = meanjHO - 3 * sigmajHO;
5084   if (dif3rmsHOMIN < 0.)
5085     dif3rmsHOMIN = 0.;
5086   double dif3rmsHOMAX = meanjHO + 3 * sigmajHO;
5087   cout << "22HO-2    meanjHO=  " << meanjHO << "  sigmajHO=  " << sigmajHO << "  dif3rmsHOMIN=  " << dif3rmsHOMIN
5088        << "  dif3rmsHOMAX=  " << dif3rmsHOMAX << endl;
5089 
5090   double MAXdif3rmsHOMIN = dif3rmsHOMIN;
5091   double MINdif3rmsHOMAX = dif3rmsHOMAX;
5092   if (MAXdif3rmsHOMIN < 0.95)
5093     MAXdif3rmsHOMIN = 0.95;
5094   if (MINdif3rmsHOMAX > 1.05)
5095     MINdif3rmsHOMAX = 1.05;
5096   cout << "22HO-2     MAXdif3rmsHOMIN=  " << MAXdif3rmsHOMIN << "     MINdif3rmsHOMAX=  " << MINdif3rmsHOMAX << endl;
5097   //
5098   for (int j = 1; j <= ny; j++) {
5099     ccc0HO = Gho1->GetBinContent(1, j);
5100     if (ccc0HO <= 0.)
5101       for (int i = 1; i <= nx; i++) {
5102         double ccc2 = Gho1->GetBinContent(i, j);
5103         if (ccc2 > 0.) {
5104           ccc0HO = ccc2;
5105           break;
5106         }
5107       }
5108     if (ccc0HO > 0.) {
5109       int jeta = (j - 1) / 18;         // jeta = 0-21
5110       int jphi = (j - 1) - 18 * jeta;  // jphi=0-17
5111       // i - # LSs:
5112       for (int i = 1; i <= nx; i++) {
5113         double ccc1 = Gho1->GetBinContent(i, j);
5114         if (ccc1 > 0.) {
5115           double Rij = ccc1 / ccc0HO;
5116           if (Rij < MAXdif3rmsHOMIN || Rij > MINdif3rmsHOMAX) {
5117             Gho61->Fill(jeta - 11, jphi, Rij);
5118             Gho60->Fill(jeta - 11, jphi, 1.);
5119           }
5120           if (Rij < 0.8 || Rij > 1.2) {
5121             G20ho61->Fill(jeta - 11, jphi, Rij);
5122             G20ho60->Fill(jeta - 11, jphi, 1.);
5123           }
5124           if (Rij < 0.7 || Rij > 1.3) {
5125             G30ho61->Fill(jeta - 11, jphi, Rij);
5126             G30ho60->Fill(jeta - 11, jphi, 1.);
5127           }
5128           if (Rij < 0.6 || Rij > 1.4) {
5129             G40ho61->Fill(jeta - 11, jphi, Rij);
5130             G40ho60->Fill(jeta - 11, jphi, 1.);
5131           }
5132         }                                       //if(ccc1>0.
5133       }                                         // i
5134     }                                           //if(ccc0HO>0
5135   }                                             // j
5136   Gho6->Divide(Gho61, Gho60, 1, 1, "B");        // average R
5137   G20ho6->Divide(G20ho61, G20ho60, 1, 1, "B");  // average R
5138   G30ho6->Divide(G30ho61, G30ho60, 1, 1, "B");  // average R
5139   G40ho6->Divide(G40ho61, G40ho60, 1, 1, "B");  // average R
5140   //      Gho6->SetLabelOffset (Float_t offset=0.005, Option_t *axis="X")//Set offset between axis and axis' labels
5141   //      Gho6->GetZaxis()->SetLabelOffset(-0.05);
5142   Gho6->GetZaxis()->SetLabelSize(0.025);
5143 
5144   Gho6->SetXTitle("             #eta  \b");
5145   Gho6->SetYTitle("      #phi \b");
5146   Gho6->SetTitle(
5147       "<Rj> for |1-<R>| > 0.05 \b");  //      Gho6->SetMaximum(1.000);  //      Gho6->SetMinimum(1.0); //Gho6->SetZTitle("Rij averaged over LSs \b"); //Gho6->GetZaxis()->SetLabelSize(0.04); //Gho6->SetMarkerStyle(20);// Gho6->SetMarkerSize(0.4);//Gho6->SetMarkerColor(2); //Gho6->SetLineColor(2);
5148   //gStyle->SetOptStat(kFALSE);
5149   Gho6->SetStats(0);
5150   Gho6->Draw("COLZ");
5151   //================
5152   cRBX31->cd(3);
5153   TH1F *Gho7 = new TH1F("Gho7", "", 120, 0.4, 1.6);
5154   // j - etaphi index:
5155   for (int j = 1; j <= ny; j++) {
5156     ccc0HO = Gho1->GetBinContent(1, j);
5157     if (ccc0HO <= 0.)
5158       for (int i = 1; i <= nx; i++) {
5159         double ccc2 = Gho1->GetBinContent(i, j);
5160         if (ccc2 > 0.) {
5161           ccc0HO = ccc2;
5162           break;
5163         }
5164       }
5165     if (ccc0HO > 0.) {
5166       // i - # LSs:
5167       for (int i = 1; i <= nx; i++) {
5168         double ccc1 = Gho1->GetBinContent(i, j);
5169         if (ccc1 > 0.) {
5170           double Rij = ccc1 / ccc0HO;
5171           Gho7->Fill(Rij);
5172         }
5173       }
5174     }
5175   }
5176   Gho7->SetMarkerStyle(20);
5177   Gho7->SetMarkerSize(0.4);
5178   Gho7->GetYaxis()->SetLabelSize(0.04);
5179   Gho7->SetMarkerColor(2);
5180   Gho7->SetLineColor(0);
5181   Gho7->SetYTitle("        N  \b");
5182   Gho7->SetXTitle("     Rij \b");
5183   Gho7->SetTitle(" Rij \b");
5184   //Gho7->SetMinimum(0.8);Gho7->SetMaximum(500.);
5185   gPad->SetGridy();
5186   gPad->SetGridx();  //            gPad->SetLogy();
5187   //      Gho7->SetStats(1110000);
5188   Gho7->GetYaxis()->SetLabelSize(0.025);
5189   Gho7->Draw("Error");
5190   Float_t ymaxHO = Gho7->GetMaximum();
5191   cout << "22HO-3   ymaxHO=  " << ymaxHO << "       MAXdif3rmsHOMIN=  " << MAXdif3rmsHOMIN
5192        << "         MINdif3rmsHOMAX=  " << MINdif3rmsHOMAX << endl;
5193   TLine *lineHO = new TLine(MAXdif3rmsHOMIN, 0., MAXdif3rmsHOMIN, ymaxHO);
5194   lineHO->SetLineColor(kBlue);
5195   lineHO->Draw();
5196   TLine *line1HO = new TLine(MINdif3rmsHOMAX, 0., MINdif3rmsHOMAX, ymaxHO);
5197   line1HO->SetLineColor(kBlue);
5198   line1HO->Draw();
5199   //================
5200   /////////////////
5201   cRBX31->Update();
5202   cRBX31->Print("RBX-HO-3plots.png");
5203   cRBX31->Clear();
5204   // clean-up
5205   if (Gho5)
5206     delete Gho5;
5207   if (Gho60)
5208     delete Gho60;
5209   if (Gho61)
5210     delete Gho61;
5211   if (Gho6)
5212     delete Gho6;
5213   if (Gho7)
5214     delete Gho7;
5215 
5216   if (G20ho60)
5217     delete G20ho60;
5218   if (G20ho61)
5219     delete G20ho61;
5220   if (G30ho60)
5221     delete G30ho60;
5222   if (G30ho61)
5223     delete G30ho61;
5224   if (G40ho60)
5225     delete G40ho60;
5226   if (G40ho61)
5227     delete G40ho61;
5228 
5229   if (Gho1)
5230     delete Gho1;
5231   //========================================================================================== 22-1   HO:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
5232   //======================================================================
5233   //======================================================================28.11.2018
5234   //======================================================================
5235   //======================================================================
5236 
5237   gStyle->SetOptStat(1110000);
5238   cout << "      RBX HO  Ratio plotsmore *****" << endl;
5239   cRBX31->Clear();
5240   /////////////////
5241   cRBX31->Divide(3, 1);
5242   //================
5243   cRBX31->cd(1);
5244   G20ho6->GetZaxis()->SetLabelSize(0.025);
5245   G20ho6->SetXTitle("             #eta  \b");
5246   G20ho6->SetYTitle("      #phi \b");
5247   G20ho6->SetTitle("<Rj> for |1-<R>| > 0.20 \b");
5248   G20ho6->SetStats(0);
5249   G20ho6->Draw("COLZ");
5250   //================
5251   cRBX31->cd(2);
5252   G30ho6->GetZaxis()->SetLabelSize(0.025);
5253   G30ho6->SetXTitle("             #eta  \b");
5254   G30ho6->SetYTitle("      #phi \b");
5255   G30ho6->SetTitle("<Rj> for |1-<R>| > 0.30 \b");
5256   G30ho6->SetStats(0);
5257   G30ho6->Draw("COLZ");
5258   //================
5259   cRBX31->cd(3);
5260   G40ho6->GetZaxis()->SetLabelSize(0.025);
5261   G40ho6->SetXTitle("             #eta  \b");
5262   G40ho6->SetYTitle("      #phi \b");
5263   G40ho6->SetTitle("<Rj> for |1-<R>| > 0.40 \b");
5264   G40ho6->SetStats(0);
5265   G40ho6->Draw("COLZ");
5266   //================
5267 
5268   /////////////////
5269   cRBX31->Update();
5270   cRBX31->Print("RBX-HO-3plotsmore.png");
5271   cRBX31->Clear();
5272 
5273   // clean-up
5274   if (G20ho6)
5275     delete G20ho6;
5276   if (G30ho6)
5277     delete G30ho6;
5278   if (G40ho6)
5279     delete G40ho6;
5280   gStyle->SetOptStat(0);
5281   ////////////////////////////////////////////////////////////////////////////////////
5282 
5283   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5284   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5285   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5286   for (int jphi = 0; jphi < njphi; jphi++) {
5287     for (int jeta = 0; jeta < njeta; jeta++) {
5288       for (int i = 0; i < nx; i++) {
5289         alexall[jeta][jphi][i] = 0.;
5290       }
5291     }
5292   }  // nulling
5293 
5294   ////////////////////////////////////////////////////////////////////////////////////   end HO RBX
5295 
5296   ////////////////////////////////////////////////////////////////////////////////////     HF::   HFSTART
5297   //======================================================================
5298   //======================================================================
5299   //======================================================================
5300   cout << " RBX general for HF **************************" << endl;
5301   TH2F *Ghf1KKK = (TH2F *)hfile->Get("h_2DsumADCAmplEtaPhiLs3");
5302   TH2F *Ghf1LLL = (TH2F *)hfile->Get("h_2DsumADCAmplEtaPhiLs30");
5303   TH2F *Ghf1 = (TH2F *)Ghf1LLL->Clone("Ghf1");
5304   Ghf1->Divide(Ghf1KKK, Ghf1LLL, 1, 1, "B");  // average A
5305   //    Ghf1->Sumw2();
5306   //      int nx = Ghf1->GetXaxis()->GetNbins(); // # LS
5307   //    nx = maxbinsRBX; // # LS
5308   ny = Ghf1->GetYaxis()->GetNbins();  // # jetaphi indexes
5309   for (int j = 1; j <= ny; j++) {
5310     int jeta = (j - 1) / njphi;  // jeta = 0-21
5311     if (jeta < 4 || jeta > 17) {
5312       int jphi = (j - 1) - njphi * jeta;  // jphi=0-17
5313       //       cout<<"HF 54        jeta=     "<< jeta <<"   jphi   =     "<<jphi  <<endl;
5314       // over LS:
5315       for (int i = 1; i <= nx; i++) {
5316         double ccc1 = Ghf1->GetBinContent(i, j);
5317         alexall[jeta][jphi][i - 1] = ccc1;
5318         //       if( i == 1 ) cout<<"HF 54  for LS=1      ccc1=     "<< ccc1 <<endl;
5319       }  //i
5320     }    //if
5321   }      //j
5322   // clean-up
5323   if (Ghf1KKK)
5324     delete Ghf1KKK;
5325   if (Ghf1LLL)
5326     delete Ghf1LLL;
5327   //    if (Ghf1) delete Ghf1;
5328 
5329   //====================================================================== alexhf[k][i]
5330   for (int jphi = 0; jphi < njphi; jphi++) {
5331     for (int i = 0; i < nx; i++) {
5332       double sumccc1 = 0.;
5333       int isum = 0;
5334       for (int jeta = 0; jeta < njeta; jeta++) {
5335         double ccc1 = alexall[jeta][jphi][i];
5336         if (ccc1 > 0.) {
5337           sumccc1 += ccc1;
5338           isum++;
5339         }
5340       }  // for jeta
5341       if (isum > 0.)
5342         sumccc1 /= isum;
5343       alexhf[jphi][i] = sumccc1;
5344     }
5345   }  //for for
5346      //====================================================================== blexhf[k][i]
5347   for (int keta = 0; keta < njeta; keta++) {
5348     for (int i = 0; i < nx; i++) {
5349       double sumccc1 = 0.;
5350       int isum = 0;
5351       for (int kphi = 0; kphi < njphi; kphi++) {
5352         double ccc1 = alexall[keta][kphi][i];
5353         if (ccc1 > 0.) {
5354           sumccc1 += ccc1;
5355           isum++;
5356         }
5357       }  // for kphi
5358       if (isum > 0.)
5359         sumccc1 /= isum;
5360       blexhf[keta][i] = sumccc1;
5361     }
5362   }  //for for
5363   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5364   //========================================================================================== 60   HF:: 2D  jeta = 0 - 21       jphi =0 - 17
5365   //======================================================================
5366   //======================================================================
5367   //======================================================================
5368   //======================================================================
5369   cout << "      RBX HF  2D plot *****" << endl;
5370   cRBX1->Clear();
5371   /////////////////
5372   cRBX1->Divide(1, 1);
5373   cRBX1->cd(1);
5374   // int ietaphi = 0; ietaphi = ((k2+1)-1)*nphi + (k3+1) ;  k2=0-neta-1; k3=0-nphi-1; neta=18; nphi=22;
5375   TH2F *Ghf42D = new TH2F("Ghf42D", "", 23, -11.5, 11.5, 18, 0., 18.);
5376   TH2F *Ghf42D0 = new TH2F("Ghf42D0", "", 23, -11.5, 11.5, 18, 0., 18.);
5377   //     TH2F* Ghf42D      = new TH2F("Ghf42D","",   22, -11., 11., 18, 0., 18. );
5378   //     TH2F* Ghf42D0     = new TH2F("Ghf42D0","",  22, -11., 11., 18, 0., 18. );
5379   TH2F *Ghf42DF = (TH2F *)Ghf42D0->Clone("Ghf42DF");
5380   for (int jphi = 0; jphi < njphi; jphi++) {
5381     for (int jeta = 0; jeta < njeta; jeta++) {
5382       for (int i = 0; i < nx; i++) {
5383         double ccc1 = alexall[jeta][jphi][i];
5384         int neweta = jeta - 11 - 0.5;
5385         if (jeta >= 11)
5386           neweta = jeta - 11 + 1.5;
5387         if (ccc1 > 0.) {
5388           Ghf42D->Fill(neweta, jphi, ccc1);
5389           Ghf42D0->Fill(neweta, jphi, 1.);
5390         }
5391         //       if(ccc1>0.) {Ghf42D ->Fill(jeta-11,jphi,ccc1); Ghf42D0 ->Fill(jeta-11,jphi,1.); }
5392       }
5393     }
5394   }
5395   Ghf42DF->Divide(Ghf42D, Ghf42D0, 1, 1, "B");  // average A
5396   //    Ghf1->Sumw2();
5397   gPad->SetGridy();
5398   gPad->SetGridx();  //      gPad->SetLogz();
5399   Ghf42DF->SetMarkerStyle(20);
5400   Ghf42DF->SetMarkerSize(0.4);
5401   Ghf42DF->GetZaxis()->SetLabelSize(0.04);
5402   Ghf42DF->SetXTitle("<A>_RBX         #eta  \b");
5403   Ghf42DF->SetYTitle("      #phi \b");
5404   Ghf42DF->SetZTitle("<A>_RBX  - All \b");
5405   Ghf42DF->SetMarkerColor(2);
5406   Ghf42DF->SetLineColor(2);  //      Ghf42DF->SetMaximum(1.000);  //      Ghf42DF->SetMinimum(1.0);
5407   Ghf42DF->Draw("COLZ");
5408 
5409   /////////////////
5410   cRBX1->Update();
5411   cRBX1->Print("RBX-HF-2Dplot.png");
5412   cRBX1->Clear();
5413   // clean-up
5414   if (Ghf42D)
5415     delete Ghf42D;
5416   if (Ghf42D0)
5417     delete Ghf42D0;
5418   if (Ghf42DF)
5419     delete Ghf42DF;
5420 
5421   //========================================================================================== 61   HF:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
5422   //======================================================================
5423   //======================================================================
5424   //======================================================================
5425   //======================================================================
5426   cout << "      RBX HF  1D plot *****" << endl;
5427   cRBX1->Clear();
5428   /////////////////
5429   cRBX1->Divide(1, 1);
5430   cRBX1->cd(1);
5431   TH1F *GphiHF1D = new TH1F("GphiHF1D", "", 18, 0., 18.);
5432   TH1F *GphiHF1D0 = new TH1F("GphiHF1D0", "", 18, 0., 18.);
5433   TH1F *GphiHF1DF = (TH1F *)GphiHF1D0->Clone("GphiHF1DF");
5434   for (int jphi = 0; jphi < 18; jphi++) {
5435     for (int jeta = 0; jeta < 22; jeta++) {
5436       for (int i = 0; i < nx; i++) {
5437         double ccc1 = alexall[jeta][jphi][i];
5438         if (ccc1 > 0.) {
5439           GphiHF1D->Fill(jphi, ccc1);
5440           GphiHF1D0->Fill(jphi, 1.);
5441         }
5442       }
5443     }
5444   }
5445   //     GphiHF1D->Sumw2();GphiHF1D0->Sumw2();
5446   GphiHF1DF->Divide(GphiHF1D, GphiHF1D0, 1, 1, "B");  // average A
5447                                                       //     GphiHF1DF->Sumw2();
5448   for (int jphi = 1; jphi < 19; jphi++) {
5449     GphiHF1DF->SetBinError(jphi, 0.01);
5450   }
5451   gPad->SetGridy();
5452   gPad->SetGridx();  //      gPad->SetLogz();
5453   GphiHF1DF->SetMarkerStyle(20);
5454   GphiHF1DF->SetMarkerSize(1.4);
5455   GphiHF1DF->GetZaxis()->SetLabelSize(0.08);
5456   GphiHF1DF->SetXTitle("PHI of RBX\b");
5457   GphiHF1DF->SetYTitle(" <Amplitude> \b");
5458   GphiHF1DF->SetZTitle("<A>_PHI  - All \b");
5459   GphiHF1DF->SetMarkerColor(4);
5460   GphiHF1DF->SetLineColor(4);
5461   GphiHF1DF->SetMinimum(0.8);  //      GphiHF1DF->SetMaximum(1.000);
5462   GphiHF1DF->Draw("Error");
5463   /////////////////
5464   cRBX1->Update();
5465   cRBX1->Print("RBX-HF-1Dplot.png");
5466   cRBX1->Clear();
5467   // clean-up
5468   if (GphiHF1D)
5469     delete GphiHF1D;
5470   if (GphiHF1D0)
5471     delete GphiHF1D0;
5472   if (GphiHF1DF)
5473     delete GphiHF1DF;
5474 
5475   //========================================================================================== 62   HF:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
5476   //======================================================================
5477   //======================================================================
5478   //======================================================================
5479   //======================================================================
5480   cout << "      RBX HF 11D plot *eta*" << endl;
5481   cRBX1->Clear();
5482   /////////////////
5483   cRBX1->Divide(1, 1);
5484   cRBX1->cd(1);
5485   TH1F *GetaHF11D = new TH1F("GetaHF11D", "", 23, -11.5, 11.5);
5486   TH1F *GetaHF11D0 = new TH1F("GetaHF11D0", "", 23, -11.5, 11.5);
5487   TH1F *GetaHF11DF = (TH1F *)GetaHF11D0->Clone("GetaHF11DF");
5488 
5489   for (int jeta = 0; jeta < 22; jeta++) {
5490     for (int jphi = 0; jphi < 18; jphi++) {
5491       for (int i = 0; i < nx; i++) {
5492         double ccc1 = alexall[jeta][jphi][i];
5493         int neweta = jeta - 11 - 0.5;
5494         if (jeta >= 11)
5495           neweta = jeta - 11 + 1.5;
5496         if (ccc1 > 0.) {
5497           GetaHF11D->Fill(neweta, ccc1);
5498           GetaHF11D0->Fill(neweta, 1.);
5499           //           if( i == 0 ) cout<<"62  HF:  ibin=  "<< i <<"      jphi= "<< jphi <<"      jeta= "<< jeta <<"      A= "<< ccc1 <<endl;
5500         }
5501       }
5502     }
5503   }
5504   //     GetaHF11D->Sumw2();GetaHF11D0->Sumw2();
5505   GetaHF11DF->Divide(GetaHF11D, GetaHF11D0, 1, 1, "B");  // average A
5506                                                          //     GetaHF11DF->Sumw2();
5507   for (int jeta = 1; jeta < 24; jeta++) {
5508     GetaHF11DF->SetBinError(jeta, 0.01);
5509   }
5510   gPad->SetGridy();
5511   gPad->SetGridx();  //      gPad->SetLogz();
5512   GetaHF11DF->SetMarkerStyle(20);
5513   GetaHF11DF->SetMarkerSize(1.4);
5514   GetaHF11DF->GetZaxis()->SetLabelSize(0.08);
5515   GetaHF11DF->SetXTitle("#eta  \b");
5516   GetaHF11DF->SetYTitle("  <A> \b");
5517   GetaHF11DF->SetZTitle("<A>_ETA  - All \b");
5518   GetaHF11DF->SetMarkerColor(4);
5519   GetaHF11DF->SetLineColor(4);
5520   GetaHF11DF->SetMinimum(0.8);  //      GetaHF11DF->SetMaximum(1.000);
5521   GetaHF11DF->Draw("Error");
5522 
5523   /////////////////
5524   cRBX1->Update();
5525   cRBX1->Print("RBX-HF-11Dplot.png");
5526   cRBX1->Clear();
5527   // clean-up
5528   if (GetaHF11D)
5529     delete GetaHF11D;
5530   if (GetaHF11D0)
5531     delete GetaHF11D0;
5532   if (GetaHF11DF)
5533     delete GetaHF11DF;
5534 
5535   //========================================================================================== 22   HF:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
5536   //======================================================================
5537   //======================================================================22.11.2018
5538   //======================================================================
5539   //======================================================================
5540 
5541   gStyle->SetOptStat(1110000);
5542   cout << "      RBX HF  Ratio plots *****" << endl;
5543   cRBX31->Clear();
5544   /////////////////
5545   // gain stabilitY:
5546   // Rij = Aij / A1j , where i-over LSs, j-channels
5547   //
5548   //    nx = maxbinsRBX; // # LS
5549   //
5550   double ccc0HF = 0.;
5551   cRBX31->Divide(3, 1);
5552   //================
5553   cRBX31->cd(1);
5554   //      TH1F* Ghf5 = new TH1F("Ghf5","", nx, 1., nx+1.);
5555   TH1F *Ghf51 = new TH1F("Ghf51", "", nx, 1., nx + 1.);
5556   TH1F *Ghf50 = new TH1F("Ghf50", "", nx, 1., nx + 1.);
5557   TH1F *Ghf5 = (TH1F *)Ghf50->Clone("Ghf5");
5558   // j - etaphi index:
5559   for (int j = 1; j <= ny; j++) {
5560     ccc0HF = Ghf1->GetBinContent(1, j);
5561     //  if(ccc0HF <=0.) for (int i=1;i<=nx;i++) {double ccc2 =  Ghf1->GetBinContent(i,j);if(ccc2>0.){ccc0HF=ccc2;cout<<"!!! ccc0HF= "<<ccc0HF<<endl;break;} }
5562     if (ccc0HF <= 0.)
5563       for (int i = 1; i <= nx; i++) {
5564         double ccc2 = Ghf1->GetBinContent(i, j);
5565         if (ccc2 > 0.) {
5566           ccc0HF = ccc2;
5567           break;
5568         }
5569       }
5570     if (ccc0HF > 0.) {
5571       // i - # LSs:
5572       for (int i = 1; i <= nx; i++) {
5573         double ccc1 = Ghf1->GetBinContent(i, j);
5574         if (ccc1 > 0.) {
5575           double Rij = ccc1 / ccc0HF;
5576           //     Ghf5 ->Fill( float(i), Rij);
5577           Ghf51->Fill(float(i), Rij);
5578           Ghf50->Fill(float(i), 1.);
5579         }
5580       }
5581     }
5582   }
5583   Ghf5->Divide(Ghf51, Ghf50, 1, 1, "B");  // average A
5584   for (int i = 1; i <= nx; i++) {
5585     Ghf5->SetBinError(i, 0.0001);
5586   }
5587   Ghf5->SetMarkerStyle(20);
5588   Ghf5->SetMarkerSize(0.4);
5589   Ghf5->GetYaxis()->SetLabelSize(0.04);
5590   Ghf5->SetMarkerColor(2);
5591   Ghf5->SetLineColor(0);
5592   Ghf5->SetXTitle("        iLS  \b");
5593   Ghf5->SetYTitle("     <R> \b");
5594   Ghf5->SetTitle("<Ri> vs iLS \b");
5595   Ghf5->SetMinimum(0.);  //Ghf5->SetMaximum(2.5);
5596   //            gPad->SetLogy();
5597   gPad->SetGridy();
5598   gPad->SetGridx();
5599   Ghf5->SetStats(0);
5600   Ghf5->GetYaxis()->SetLabelSize(0.025);
5601   Ghf5->Draw("Error");
5602   //================
5603   cRBX31->cd(2);
5604   TH2F *Ghf60 = new TH2F("Ghf60", "", 22, -11., 11., 18, 0., 18.);
5605   TH2F *Ghf61 = new TH2F("Ghf61", "", 22, -11., 11., 18, 0., 18.);
5606   TH2F *Ghf6 = new TH2F("Ghf6", "", 22, -11., 11., 18, 0., 18.);
5607 
5608   TH2F *G20hf60 = new TH2F("G20hf60", "", 22, -11., 11., 18, 0., 18.);
5609   TH2F *G20hf61 = new TH2F("G20hf61", "", 22, -11., 11., 18, 0., 18.);
5610   TH2F *G20hf6 = new TH2F("G20hf6", "", 22, -11., 11., 18, 0., 18.);
5611   TH2F *G30hf60 = new TH2F("G30hf60", "", 22, -11., 11., 18, 0., 18.);
5612   TH2F *G30hf61 = new TH2F("G30hf61", "", 22, -11., 11., 18, 0., 18.);
5613   TH2F *G30hf6 = new TH2F("G30hf6", "", 22, -11., 11., 18, 0., 18.);
5614   TH2F *G40hf60 = new TH2F("G40hf60", "", 22, -11., 11., 18, 0., 18.);
5615   TH2F *G40hf61 = new TH2F("G40hf61", "", 22, -11., 11., 18, 0., 18.);
5616   TH2F *G40hf6 = new TH2F("G40hf6", "", 22, -11., 11., 18, 0., 18.);
5617   // j - etaphi index; i - # LSs;
5618   //
5619   // define mean and RMS:
5620   double sumjHF = 0.;
5621   int njHF = 0;
5622   double meanjHF = 0.;
5623   for (int j = 1; j <= ny; j++) {
5624     ccc0HF = Ghf1->GetBinContent(1, j);
5625     if (ccc0HF <= 0.)
5626       for (int i = 1; i <= nx; i++) {
5627         double ccc2 = Ghf1->GetBinContent(i, j);
5628         if (ccc2 > 0.) {
5629           ccc0HF = ccc2;
5630           break;
5631         }
5632       }
5633     if (ccc0HF > 0.) {
5634       for (int i = 1; i <= nx; i++) {
5635         double ccc1 = Ghf1->GetBinContent(i, j) / ccc0HF;
5636         if (ccc1 > 0.) {
5637           sumjHF += ccc1;
5638           njHF++;
5639         }
5640       }
5641       meanjHF = sumjHF / njHF;
5642     }
5643   }  // j
5644 
5645   double ssumjHF = 0.;
5646   njHF = 0;
5647   double sigmajHF = 0.;
5648   for (int j = 1; j <= ny; j++) {
5649     ccc0HF = Ghf1->GetBinContent(1, j);
5650     if (ccc0HF <= 0.)
5651       for (int i = 1; i <= nx; i++) {
5652         double ccc2 = Ghf1->GetBinContent(i, j);
5653         if (ccc2 > 0.) {
5654           ccc0HF = ccc2;
5655           break;
5656         }
5657       }
5658     if (ccc0HF > 0.) {
5659       for (int i = 1; i <= nx; i++) {
5660         double ccc1 = Ghf1->GetBinContent(i, j) / ccc0HF;
5661         if (ccc1 > 0.) {
5662           ssumjHF += (ccc1 - meanjHF) * (ccc1 - meanjHF);
5663           njHF++;
5664         }
5665       }
5666       sigmajHF = sqrt(ssumjHF / njHF);
5667     }
5668   }  // j
5669 
5670   double dif3rmsHFMIN = meanjHF - 3 * sigmajHF;
5671   if (dif3rmsHFMIN < 0.)
5672     dif3rmsHFMIN = 0.;
5673   double dif3rmsHFMAX = meanjHF + 3 * sigmajHF;
5674   cout << "22HF-2    meanjHF=  " << meanjHF << "  sigmajHF=  " << sigmajHF << "  dif3rmsHFMIN=  " << dif3rmsHFMIN
5675        << "  dif3rmsHFMAX=  " << dif3rmsHFMAX << endl;
5676 
5677   double MAXdif3rmsHFMIN = dif3rmsHFMIN;
5678   double MINdif3rmsHFMAX = dif3rmsHFMAX;
5679   if (MAXdif3rmsHFMIN < 0.95)
5680     MAXdif3rmsHFMIN = 0.95;
5681   if (MINdif3rmsHFMAX > 1.05)
5682     MINdif3rmsHFMAX = 1.05;
5683   cout << "22HF-2     MAXdif3rmsHFMIN=  " << MAXdif3rmsHFMIN << "     MINdif3rmsHFMAX=  " << MINdif3rmsHFMAX << endl;
5684   //
5685   for (int j = 1; j <= ny; j++) {
5686     ccc0HF = Ghf1->GetBinContent(1, j);
5687     if (ccc0HF <= 0.)
5688       for (int i = 1; i <= nx; i++) {
5689         double ccc2 = Ghf1->GetBinContent(i, j);
5690         if (ccc2 > 0.) {
5691           ccc0HF = ccc2;
5692           break;
5693         }
5694       }
5695     if (ccc0HF > 0.) {
5696       int jeta = (j - 1) / 18;         // jeta = 0-21
5697       int jphi = (j - 1) - 18 * jeta;  // jphi=0-17
5698       // i - # LSs:
5699       for (int i = 1; i <= nx; i++) {
5700         double ccc1 = Ghf1->GetBinContent(i, j);
5701         if (ccc1 > 0.) {
5702           double Rij = ccc1 / ccc0HF;
5703           if (Rij < MAXdif3rmsHFMIN || Rij > MINdif3rmsHFMAX) {
5704             Ghf61->Fill(jeta - 11, jphi, Rij);
5705             Ghf60->Fill(jeta - 11, jphi, 1.);
5706           }
5707           if (Rij < 0.8 || Rij > 1.2) {
5708             G20hf61->Fill(jeta - 11, jphi, Rij);
5709             G20hf60->Fill(jeta - 11, jphi, 1.);
5710           }
5711           if (Rij < 0.7 || Rij > 1.3) {
5712             G30hf61->Fill(jeta - 11, jphi, Rij);
5713             G30hf60->Fill(jeta - 11, jphi, 1.);
5714           }
5715           if (Rij < 0.6 || Rij > 1.4) {
5716             G40hf61->Fill(jeta - 11, jphi, Rij);
5717             G40hf60->Fill(jeta - 11, jphi, 1.);
5718           }
5719         }                                       //if(ccc1>0.
5720       }                                         // i
5721     }                                           //if(ccc0HF>0
5722   }                                             // j
5723   Ghf6->Divide(Ghf61, Ghf60, 1, 1, "B");        // average R
5724   G20hf6->Divide(G20hf61, G20hf60, 1, 1, "B");  // average R
5725   G30hf6->Divide(G30hf61, G30hf60, 1, 1, "B");  // average R
5726   G40hf6->Divide(G40hf61, G40hf60, 1, 1, "B");  // average R
5727   //      Ghf6->SetLabelOffset (Float_t offset=0.005, Option_t *axis="X")//Set offset between axis and axis' labels
5728   //      Ghf6->GetZaxis()->SetLabelOffset(-0.05);
5729   Ghf6->GetZaxis()->SetLabelSize(0.025);
5730 
5731   Ghf6->SetXTitle("             #eta  \b");
5732   Ghf6->SetYTitle("      #phi \b");
5733   Ghf6->SetTitle(
5734       "<Rj> for |1-<R>| > 0.05 \b");  //      Ghf6->SetMaximum(1.000);  //      Ghf6->SetMinimum(1.0); //Ghf6->SetZTitle("Rij averaged over LSs \b"); //Ghf6->GetZaxis()->SetLabelSize(0.04); //Ghf6->SetMarkerStyle(20);// Ghf6->SetMarkerSize(0.4);//Ghf6->SetMarkerColor(2); //Ghf6->SetLineColor(2);
5735   //gStyle->SetOptStat(kFALSE);
5736   Ghf6->SetStats(0);
5737   Ghf6->Draw("COLZ");
5738   //================
5739   cRBX31->cd(3);
5740   TH1F *Ghf7 = new TH1F("Ghf7", "", 120, 0.4, 1.6);
5741   // j - etaphi index:
5742   for (int j = 1; j <= ny; j++) {
5743     ccc0HF = Ghf1->GetBinContent(1, j);
5744     if (ccc0HF <= 0.)
5745       for (int i = 1; i <= nx; i++) {
5746         double ccc2 = Ghf1->GetBinContent(i, j);
5747         if (ccc2 > 0.) {
5748           ccc0HF = ccc2;
5749           break;
5750         }
5751       }
5752     if (ccc0HF > 0.) {
5753       // i - # LSs:
5754       for (int i = 1; i <= nx; i++) {
5755         double ccc1 = Ghf1->GetBinContent(i, j);
5756         if (ccc1 > 0.) {
5757           double Rij = ccc1 / ccc0HF;
5758           Ghf7->Fill(Rij);
5759         }
5760       }
5761     }
5762   }
5763   Ghf7->SetMarkerStyle(20);
5764   Ghf7->SetMarkerSize(0.4);
5765   Ghf7->GetYaxis()->SetLabelSize(0.04);
5766   Ghf7->SetMarkerColor(2);
5767   Ghf7->SetLineColor(0);
5768   Ghf7->SetYTitle("        N  \b");
5769   Ghf7->SetXTitle("     Rij \b");
5770   Ghf7->SetTitle(" Rij \b");
5771   //Ghf7->SetMinimum(0.8);Ghf7->SetMaximum(500.);
5772   gPad->SetGridy();
5773   gPad->SetGridx();  //            gPad->SetLogy();
5774   //      Ghf7->SetStats(1110000);
5775   Ghf7->GetYaxis()->SetLabelSize(0.025);
5776   Ghf7->Draw("Error");
5777   Float_t ymaxHF = Ghf7->GetMaximum();
5778   cout << "22HF-3   ymaxHF=  " << ymaxHF << "       MAXdif3rmsHFMIN=  " << MAXdif3rmsHFMIN
5779        << "         MINdif3rmsHFMAX=  " << MINdif3rmsHFMAX << endl;
5780   TLine *lineHF = new TLine(MAXdif3rmsHFMIN, 0., MAXdif3rmsHFMIN, ymaxHF);
5781   lineHF->SetLineColor(kBlue);
5782   lineHF->Draw();
5783   TLine *line1HF = new TLine(MINdif3rmsHFMAX, 0., MINdif3rmsHFMAX, ymaxHF);
5784   line1HF->SetLineColor(kBlue);
5785   line1HF->Draw();
5786   //================
5787   /////////////////
5788   cRBX31->Update();
5789   cRBX31->Print("RBX-HF-3plots.png");
5790   cRBX31->Clear();
5791   // clean-up
5792   if (Ghf5)
5793     delete Ghf5;
5794   if (Ghf60)
5795     delete Ghf60;
5796   if (Ghf61)
5797     delete Ghf61;
5798   if (Ghf6)
5799     delete Ghf6;
5800   if (Ghf7)
5801     delete Ghf7;
5802 
5803   if (G20hf60)
5804     delete G20hf60;
5805   if (G20hf61)
5806     delete G20hf61;
5807   if (G30hf60)
5808     delete G30hf60;
5809   if (G30hf61)
5810     delete G30hf61;
5811   if (G40hf60)
5812     delete G40hf60;
5813   if (G40hf61)
5814     delete G40hf61;
5815 
5816   if (Ghf1)
5817     delete Ghf1;
5818   //========================================================================================== 22-1   HF:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
5819   //======================================================================
5820   //======================================================================28.11.2018
5821   //======================================================================
5822   //======================================================================
5823 
5824   gStyle->SetOptStat(1110000);
5825   cout << "      RBX HF  Ratio plotsmore *****" << endl;
5826   cRBX31->Clear();
5827   /////////////////
5828   cRBX31->Divide(3, 1);
5829   //================
5830   cRBX31->cd(1);
5831   G20hf6->GetZaxis()->SetLabelSize(0.025);
5832   G20hf6->SetXTitle("             #eta  \b");
5833   G20hf6->SetYTitle("      #phi \b");
5834   G20hf6->SetTitle("<Rj> for |1-<R>| > 0.20 \b");
5835   G20hf6->SetStats(0);
5836   G20hf6->Draw("COLZ");
5837   //================
5838   cRBX31->cd(2);
5839   G30hf6->GetZaxis()->SetLabelSize(0.025);
5840   G30hf6->SetXTitle("             #eta  \b");
5841   G30hf6->SetYTitle("      #phi \b");
5842   G30hf6->SetTitle("<Rj> for |1-<R>| > 0.30 \b");
5843   G30hf6->SetStats(0);
5844   G30hf6->Draw("COLZ");
5845   //================
5846   cRBX31->cd(3);
5847   G40hf6->GetZaxis()->SetLabelSize(0.025);
5848   G40hf6->SetXTitle("             #eta  \b");
5849   G40hf6->SetYTitle("      #phi \b");
5850   G40hf6->SetTitle("<Rj> for |1-<R>| > 0.40 \b");
5851   G40hf6->SetStats(0);
5852   G40hf6->Draw("COLZ");
5853   //================
5854 
5855   /////////////////
5856   cRBX31->Update();
5857   cRBX31->Print("RBX-HF-3plotsmore.png");
5858   cRBX31->Clear();
5859 
5860   // clean-up
5861   if (G20hf6)
5862     delete G20hf6;
5863   if (G30hf6)
5864     delete G30hf6;
5865   if (G40hf6)
5866     delete G40hf6;
5867   gStyle->SetOptStat(0);
5868   ////////////////////////////////////////////////////////////////////////////////////
5869   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5870   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5871   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5872   //////////////////////////////////////////////////////////////////////////////////// RBX  HF  study END:
5873 
5874   //////////////////////////////////////////////////////////////////////////////////// RBX study END:
5875 
5876   //////////////////////////////////////////////////////////////////////////////////// Special tests:
5877   //===============================================================================   occupancyHB
5878   // For occupancy plots. Produces OccPlots_HBx.png (x=1)
5879   int mymaxbins = MaxLum;
5880   {
5881     cHB->Clear();
5882     cHB->Divide(2, 1);
5883     /////////
5884     cHB->cd(1);
5885     TH2F *occhbm = (TH2F *)hfile->Get("h_RatioOccupancy_HBM");
5886     TH1F *uyhbm = new TH1F("uyhbm", "", mymaxbins, 1., mymaxbins + 1.);
5887     for (int i = 1; i <= occhbm->GetXaxis()->GetNbins(); i++) {
5888       double ccc1 = occhbm->GetBinContent(i);
5889       //      if(ccc1>0.)     cout<<" depth1_HB iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
5890       if (ccc1 > 0.)
5891         uyhbm->Fill(float(i), ccc1);
5892     }
5893     //      gPad->SetLogy();
5894     uyhbm->SetMarkerStyle(20);
5895     uyhbm->SetMarkerSize(0.6);
5896     uyhbm->GetYaxis()->SetLabelSize(0.04);
5897     uyhbm->SetXTitle("min/av occupancy - HBM \b");
5898     uyhbm->SetMarkerColor(2);
5899     uyhbm->SetLineColor(0);
5900     uyhbm->SetMaximum(1.0);
5901     uyhbm->SetMinimum(0.2);
5902     gPad->SetGridy();
5903     uyhbm->Draw("Error");
5904     /////////
5905     cHB->cd(2);
5906     TH2F *occhbp = (TH2F *)hfile->Get("h_RatioOccupancy_HBP");
5907     TH1F *uyhbp = new TH1F("uyhbp", "", mymaxbins, 1., mymaxbins + 1.);
5908     for (int i = 1; i <= occhbp->GetXaxis()->GetNbins(); i++) {
5909       double ccc1 = occhbp->GetBinContent(i);
5910       //      if(ccc1>0.)     cout<<" depth1_HB iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
5911       if (ccc1 > 0.)
5912         uyhbp->Fill(float(i), ccc1);
5913     }
5914     //      gPad->SetLogy();
5915     uyhbp->SetMarkerStyle(20);
5916     uyhbp->SetMarkerSize(0.6);
5917     uyhbp->GetYaxis()->SetLabelSize(0.04);
5918     uyhbp->SetXTitle("min/av occupancy - HBP \b");
5919     uyhbp->SetMarkerColor(2);
5920     uyhbp->SetLineColor(0);
5921     uyhbp->SetMaximum(1.0);
5922     uyhbp->SetMinimum(0.2);
5923     gPad->SetGridy();
5924     uyhbp->Draw("Error");
5925     /////////
5926 
5927     /////////
5928     cHB->Update();
5929     cHB->Print(Form("OccPlots_HB.png"));
5930     cHB->Clear();
5931 
5932     // clean-up
5933     if (occhbm)
5934       delete occhbm;
5935     if (uyhbm)
5936       delete uyhbm;
5937     if (occhbp)
5938       delete occhbp;
5939     if (uyhbp)
5940       delete uyhbp;
5941   }
5942   //===============================================================================   occupancyHE
5943   // For occupancy plots. Produces OccPlots_HEx.png (x=1)
5944   {
5945     cHB->Clear();
5946     cHB->Divide(2, 1);
5947     /////////
5948     cHB->cd(1);
5949     TH2F *occhem = (TH2F *)hfile->Get("h_RatioOccupancy_HEM");
5950     TH1F *uyhem = new TH1F("uyhem", "", mymaxbins, 1., mymaxbins + 1.);
5951     for (int i = 1; i <= occhem->GetXaxis()->GetNbins(); i++) {
5952       double ccc1 = occhem->GetBinContent(i);
5953       //      if(ccc1>0.)     cout<<" depth1_HE iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
5954       if (ccc1 > 0.)
5955         uyhem->Fill(float(i), ccc1);
5956     }
5957     //      gPad->SetLogy();
5958     uyhem->SetMarkerStyle(20);
5959     uyhem->SetMarkerSize(0.6);
5960     uyhem->GetYaxis()->SetLabelSize(0.04);
5961     uyhem->SetXTitle("min/av occupancy - HEM \b");
5962     uyhem->SetMarkerColor(2);
5963     uyhem->SetLineColor(0);
5964     uyhem->SetMaximum(1.0);
5965     uyhem->SetMinimum(0.2);
5966     gPad->SetGridy();
5967     uyhem->Draw("Error");
5968     /////////
5969     cHB->cd(2);
5970     TH2F *occhep = (TH2F *)hfile->Get("h_RatioOccupancy_HEP");
5971     TH1F *uyhep = new TH1F("uyhep", "", mymaxbins, 1., mymaxbins + 1.);
5972     for (int i = 1; i <= occhep->GetXaxis()->GetNbins(); i++) {
5973       double ccc1 = occhep->GetBinContent(i);
5974       //      if(ccc1>0.)     cout<<" depth1_HE iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
5975       if (ccc1 > 0.)
5976         uyhep->Fill(float(i), ccc1);
5977     }
5978     //      gPad->SetLogy();
5979     uyhep->SetMarkerStyle(20);
5980     uyhep->SetMarkerSize(0.6);
5981     uyhep->GetYaxis()->SetLabelSize(0.04);
5982     uyhep->SetXTitle("min/av occupancy - HEP \b");
5983     uyhep->SetMarkerColor(2);
5984     uyhep->SetLineColor(0);
5985     uyhep->SetMaximum(1.0);
5986     uyhep->SetMinimum(0.2);
5987     gPad->SetGridy();
5988     uyhep->Draw("Error");
5989     /////////
5990 
5991     /////////
5992     cHB->Update();
5993     cHB->Print(Form("OccPlots_HE.png"));
5994     cHB->Clear();
5995 
5996     // clean-up
5997     if (occhem)
5998       delete occhem;
5999     if (uyhem)
6000       delete uyhem;
6001     if (occhep)
6002       delete occhep;
6003     if (uyhep)
6004       delete uyhep;
6005   }
6006   //===============================================================================   occupancyHO
6007   // For occupancy plots. Produces OccPlots_HOx.png (x=1)
6008   {
6009     cHB->Clear();
6010     cHB->Divide(2, 1);
6011     /////////
6012     cHB->cd(1);
6013     TH2F *occhom = (TH2F *)hfile->Get("h_RatioOccupancy_HOM");
6014     TH1F *uyhom = new TH1F("uyhom", "", mymaxbins, 1., mymaxbins + 1.);
6015     for (int i = 1; i <= occhom->GetXaxis()->GetNbins(); i++) {
6016       double ccc1 = occhom->GetBinContent(i);
6017       //      if(ccc1>0.)     cout<<" depth1_HO iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
6018       if (ccc1 > 0.)
6019         uyhom->Fill(float(i), ccc1);
6020     }
6021     //      gPad->SetLogy();
6022     uyhom->SetMarkerStyle(20);
6023     uyhom->SetMarkerSize(0.6);
6024     uyhom->GetYaxis()->SetLabelSize(0.04);
6025     uyhom->SetXTitle("min/av occupancy - HOM \b");
6026     uyhom->SetMarkerColor(2);
6027     uyhom->SetLineColor(0);
6028     uyhom->SetMaximum(1.0);
6029     uyhom->SetMinimum(0.2);
6030     gPad->SetGridy();
6031     uyhom->Draw("Error");
6032     /////////
6033     cHB->cd(2);
6034     TH2F *occhop = (TH2F *)hfile->Get("h_RatioOccupancy_HOP");
6035     TH1F *uyhop = new TH1F("uyhop", "", mymaxbins, 1., mymaxbins + 1.);
6036     for (int i = 1; i <= occhop->GetXaxis()->GetNbins(); i++) {
6037       double ccc1 = occhop->GetBinContent(i);
6038       //      if(ccc1>0.)     cout<<" depth1_HO iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
6039       if (ccc1 > 0.)
6040         uyhop->Fill(float(i), ccc1);
6041     }
6042     //      gPad->SetLogy();
6043     uyhop->SetMarkerStyle(20);
6044     uyhop->SetMarkerSize(0.6);
6045     uyhop->GetYaxis()->SetLabelSize(0.04);
6046     uyhop->SetXTitle("min/av occupancy - HOP \b");
6047     uyhop->SetMarkerColor(2);
6048     uyhop->SetLineColor(0);
6049     uyhop->SetMaximum(1.0);
6050     uyhop->SetMinimum(0.2);
6051     gPad->SetGridy();
6052     uyhop->Draw("Error");
6053     /////////
6054 
6055     /////////
6056     cHB->Update();
6057     cHB->Print(Form("OccPlots_HO.png"));
6058     cHB->Clear();
6059 
6060     // clean-up
6061     if (occhom)
6062       delete occhom;
6063     if (uyhom)
6064       delete uyhom;
6065     if (occhop)
6066       delete occhop;
6067     if (uyhop)
6068       delete uyhop;
6069   }
6070   //===============================================================================   occupancyHF
6071   // For occupancy plots. Produces OccPlots_HFx.png (x=1)
6072   {
6073     cHB->Clear();
6074     cHB->Divide(2, 1);
6075     /////////
6076     cHB->cd(1);
6077     TH2F *occhfm = (TH2F *)hfile->Get("h_RatioOccupancy_HFM");
6078     TH1F *uyhfm = new TH1F("uyhfm", "", mymaxbins, 1., mymaxbins + 1.);
6079     for (int i = 1; i <= occhfm->GetXaxis()->GetNbins(); i++) {
6080       double ccc1 = occhfm->GetBinContent(i);
6081       //      if(ccc1>0.)     cout<<" depth1_HF iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
6082       if (ccc1 > 0.)
6083         uyhfm->Fill(float(i), ccc1);
6084     }
6085     //      gPad->SetLogy();
6086     uyhfm->SetMarkerStyle(20);
6087     uyhfm->SetMarkerSize(0.6);
6088     uyhfm->GetYaxis()->SetLabelSize(0.04);
6089     uyhfm->SetXTitle("min/av occupancy - HFM \b");
6090     uyhfm->SetMarkerColor(2);
6091     uyhfm->SetLineColor(0);
6092     uyhfm->SetMaximum(1.0);
6093     uyhfm->SetMinimum(0.2);
6094     gPad->SetGridy();
6095     uyhfm->Draw("Error");
6096     /////////
6097     cHB->cd(2);
6098     TH2F *occhfp = (TH2F *)hfile->Get("h_RatioOccupancy_HFP");
6099     TH1F *uyhfp = new TH1F("uyhfp", "", mymaxbins, 1., mymaxbins + 1.);
6100     for (int i = 1; i <= occhfp->GetXaxis()->GetNbins(); i++) {
6101       double ccc1 = occhfp->GetBinContent(i);
6102       //      if(ccc1>0.)     cout<<" depth1_HF iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
6103       if (ccc1 > 0.)
6104         uyhfp->Fill(float(i), ccc1);
6105     }
6106     //      gPad->SetLogy();
6107     uyhfp->SetMarkerStyle(20);
6108     uyhfp->SetMarkerSize(0.6);
6109     uyhfp->GetYaxis()->SetLabelSize(0.04);
6110     uyhfp->SetXTitle("min/av occupancy - HFP \b");
6111     uyhfp->SetMarkerColor(2);
6112     uyhfp->SetLineColor(0);
6113     uyhfp->SetMaximum(1.0);
6114     uyhfp->SetMinimum(0.2);
6115     gPad->SetGridy();
6116     uyhfp->Draw("Error");
6117     /////////
6118 
6119     /////////
6120     cHB->Update();
6121     cHB->Print(Form("OccPlots_HF.png"));
6122     cHB->Clear();
6123 
6124     // clean-up
6125     if (occhfm)
6126       delete occhfm;
6127     if (uyhfm)
6128       delete uyhfm;
6129     if (occhfp)
6130       delete occhfp;
6131     if (uyhfp)
6132       delete uyhfp;
6133   }
6134   std::cout << "************>>>   occupancy plots done" << std::endl;
6135 
6136   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6137   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6138   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6139   /// Summed Amplitude Plots:
6140   //*************************                        *****     Signal                   *****
6141   cout << ">>>>>>>>>>>>>>>>>>>>>>>>start Summed Amplitude Plots " << endl;
6142   int maxbins = MaxLum;
6143   cout << ">>>>   maxbins =     " << maxbins << endl;
6144   TH1F *SummedAmplitudeHisto[4];  // 1d histogramm for subdet
6145   SummedAmplitudeHisto[0] = (TH1F *)hfile->Get("h_averSIGNALsumamplitude_HB");
6146   SummedAmplitudeHisto[1] = (TH1F *)hfile->Get("h_averSIGNALsumamplitude_HE");
6147   SummedAmplitudeHisto[2] = (TH1F *)hfile->Get("h_averSIGNALsumamplitude_HO");
6148   SummedAmplitudeHisto[3] = (TH1F *)hfile->Get("h_averSIGNALsumamplitude_HF");
6149   TH1F *SummedAmplitudeOccupancyHisto[4];  // 1d histogramm for subdet
6150   SummedAmplitudeOccupancyHisto[0] = (TH1F *)hfile->Get("h_averSIGNALoccupancy_HB");
6151   SummedAmplitudeOccupancyHisto[1] = (TH1F *)hfile->Get("h_averSIGNALoccupancy_HE");
6152   SummedAmplitudeOccupancyHisto[2] = (TH1F *)hfile->Get("h_averSIGNALoccupancy_HO");
6153   SummedAmplitudeOccupancyHisto[3] = (TH1F *)hfile->Get("h_averSIGNALoccupancy_HF");
6154   for (int sub = 0; sub < 4; sub++) {
6155     cHE->Clear();
6156     cHE->Divide(2, 1);
6157     cHE->cd(1);
6158     TH1F *kslpq = new TH1F("kslpq", "", maxbins, 1., maxbins + 1.);
6159     //    cout<<">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   sub =     "<< sub <<endl;
6160     for (int i = 1; i <= kslpq->GetXaxis()->GetNbins(); i++) {
6161       double ccc1 = 0.;
6162       if (SummedAmplitudeHisto[sub])
6163         ccc1 = SummedAmplitudeHisto[sub]->GetBinContent(i);
6164       //          if(ccc1>0.)     cout<<"  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6165       if (ccc1 > 0.)
6166         kslpq->Fill(float(i), ccc1);
6167     }
6168     //      gPad->SetLogy();
6169     kslpq->SetMarkerStyle(20);
6170     kslpq->SetMarkerSize(0.8);
6171     kslpq->GetYaxis()->SetLabelSize(0.04);
6172     kslpq->SetXTitle("SumA of channels w/ signal per LS \b");
6173     kslpq->SetMarkerColor(2);
6174     kslpq->SetLineColor(0);
6175     //  kslpq->SetMinimum(0.8);
6176     gPad->SetGridx();
6177     kslpq->Draw("Error");
6178     /////////
6179     cHE->cd(2);
6180     TH1F *pqmks = new TH1F("pqmks", "", maxbins, 1., maxbins + 1.);
6181     for (int i = 1; i <= pqmks->GetXaxis()->GetNbins(); i++) {
6182       double ccc1 = 0.;
6183       if (SummedAmplitudeOccupancyHisto[sub])
6184         ccc1 = SummedAmplitudeOccupancyHisto[sub]->GetBinContent(i);
6185       //      if(ccc1>0.)     cout<<"  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6186       if (ccc1 > 0.)
6187         pqmks->Fill(float(i), ccc1);
6188     }
6189     //      gPad->SetLogy();
6190     pqmks->SetMarkerStyle(20);
6191     pqmks->SetMarkerSize(0.8);
6192     pqmks->GetYaxis()->SetLabelSize(0.04);
6193     pqmks->SetXTitle("Occupancy of channels w/ signal per LS  \b");
6194     pqmks->SetMarkerColor(4);
6195     pqmks->SetLineColor(0);
6196     //  pqmks->SetMinimum(0.8);
6197     gPad->SetGridx();
6198     pqmks->Draw("Error");
6199     cHE->Update();
6200     if (sub == 0)
6201       cHE->Print("SummedAmplitudesSignal_HB.png");
6202     if (sub == 1)
6203       cHE->Print("SummedAmplitudesSignal_HE.png");
6204     if (sub == 2)
6205       cHE->Print("SummedAmplitudesSignal_HO.png");
6206     if (sub == 3)
6207       cHE->Print("SummedAmplitudesSignal_HF.png");
6208     cHE->Clear();
6209     if (kslpq)
6210       delete kslpq;
6211     if (pqmks)
6212       delete pqmks;
6213   }  //for
6214   // clean-up
6215   //for (unsigned int i=0; i<4; i++) {delete SummedAmplitudeHisto[i];delete SummedAmplitudeOccupancyHisto[i];}
6216 
6217   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6218   /// Summed Amplitude Plots:
6219   //*************************                        *****     NoSignal                   *****
6220   cout << ">>>>>>>>>>>>>>>>>>>>>>>>start Summed Amplitude Plots NoSignal " << endl;
6221   TH1F *NoSignalSummedAmplitudeHisto[4];  // 1d histogramm for subdet
6222   NoSignalSummedAmplitudeHisto[0] = (TH1F *)hfile->Get("h_averNOSIGNALsumamplitude_HB");
6223   NoSignalSummedAmplitudeHisto[1] = (TH1F *)hfile->Get("h_averNOSIGNALsumamplitude_HE");
6224   NoSignalSummedAmplitudeHisto[2] = (TH1F *)hfile->Get("h_averNOSIGNALsumamplitude_HO");
6225   NoSignalSummedAmplitudeHisto[3] = (TH1F *)hfile->Get("h_averNOSIGNALsumamplitude_HF");
6226   TH1F *NoSignalSummedAmplitudeOccupancyHisto[4];  // 1d histogramm for subdet
6227   NoSignalSummedAmplitudeOccupancyHisto[0] = (TH1F *)hfile->Get("h_averNOSIGNALoccupancy_HB");
6228   NoSignalSummedAmplitudeOccupancyHisto[1] = (TH1F *)hfile->Get("h_averNOSIGNALoccupancy_HE");
6229   NoSignalSummedAmplitudeOccupancyHisto[2] = (TH1F *)hfile->Get("h_averNOSIGNALoccupancy_HO");
6230   NoSignalSummedAmplitudeOccupancyHisto[3] = (TH1F *)hfile->Get("h_averNOSIGNALoccupancy_HF");
6231   for (int sub = 0; sub < 4; sub++) {
6232     cHE->Clear();
6233     cHE->Divide(2, 1);
6234 
6235     cHE->cd(1);
6236     TH1F *kslpq = new TH1F("kslpq", "", maxbins, 1., maxbins + 1.);
6237     for (int i = 1; i <= kslpq->GetXaxis()->GetNbins(); i++) {
6238       double ccc1 = 0.;
6239       if (NoSignalSummedAmplitudeHisto[sub])
6240         ccc1 = NoSignalSummedAmplitudeHisto[sub]->GetBinContent(i);
6241       //      if(ccc1>0.)     cout<<"  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6242       if (ccc1 > 0.)
6243         kslpq->Fill(float(i), ccc1);
6244     }
6245     //      gPad->SetLogy();
6246     kslpq->SetMarkerStyle(20);
6247     kslpq->SetMarkerSize(0.8);
6248     kslpq->GetYaxis()->SetLabelSize(0.04);
6249     kslpq->SetXTitle("SumA of channels w/o signal per LS \b");
6250     kslpq->SetMarkerColor(2);
6251     kslpq->SetLineColor(0);
6252     if (sub == 0) {
6253       kslpq->SetMaximum(20000.);
6254       kslpq->SetMinimum(5000.);
6255     } else if (sub == 1) {
6256       kslpq->SetMaximum(40000.);
6257       kslpq->SetMinimum(0.);
6258     } else if (sub == 2) {
6259       kslpq->SetMaximum(10000.);
6260       kslpq->SetMinimum(15000.);
6261     } else if (sub == 3) {
6262       kslpq->SetMaximum(100000.);
6263       kslpq->SetMinimum(0.);
6264     }
6265     gPad->SetGridx();
6266     kslpq->Draw("Error");
6267     /////////
6268     cHE->cd(2);
6269     TH1F *pqmks = new TH1F("pqmks", "", maxbins, 1., maxbins + 1.);
6270     for (int i = 1; i <= pqmks->GetXaxis()->GetNbins(); i++) {
6271       double ccc1 = 0.;
6272       if (NoSignalSummedAmplitudeOccupancyHisto[sub])
6273         ccc1 = NoSignalSummedAmplitudeOccupancyHisto[sub]->GetBinContent(i);
6274       //      if(ccc1>0.)     cout<<"  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6275       if (ccc1 > 0.)
6276         pqmks->Fill(float(i), ccc1);
6277     }
6278     //      gPad->SetLogy();
6279     pqmks->SetMarkerStyle(20);
6280     pqmks->SetMarkerSize(0.8);
6281     pqmks->GetYaxis()->SetLabelSize(0.04);
6282     pqmks->SetXTitle("Occupancy of channels w/o signal per LS  \b");
6283     pqmks->SetMarkerColor(4);
6284     pqmks->SetLineColor(0);
6285     if (sub == 0) {
6286       pqmks->SetMaximum(600.);
6287       pqmks->SetMinimum(200.);
6288     } else if (sub == 1) {
6289       pqmks->SetMaximum(910.);
6290       pqmks->SetMinimum(10.);
6291     } else if (sub == 2) {
6292       pqmks->SetMaximum(200.);
6293       pqmks->SetMinimum(50.);
6294     } else if (sub == 3) {
6295       pqmks->SetMaximum(866.);
6296       pqmks->SetMinimum(856.);
6297     }
6298     gPad->SetGridx();
6299     pqmks->Draw("Error");
6300     cHE->Update();
6301     if (sub == 0)
6302       cHE->Print("NoSignalSummedAmplitudes_HB.png");
6303     if (sub == 1)
6304       cHE->Print("NoSignalSummedAmplitudes_HE.png");
6305     if (sub == 2)
6306       cHE->Print("NoSignalSummedAmplitudes_HO.png");
6307     if (sub == 3)
6308       cHE->Print("NoSignalSummedAmplitudes_HF.png");
6309     cHE->Clear();
6310     if (kslpq)
6311       delete kslpq;
6312     if (pqmks)
6313       delete pqmks;
6314   }  //for
6315   // clean-up
6316   //for (unsigned int i=0; i<4; i++) {delete NoSignalSummedAmplitudeHisto[i];delete NoSignalSummedAmplitudeOccupancyHisto[i];}
6317   //////////
6318 
6319   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6320   /// Summed Amplitude Plots:
6321   //*************************                        *****     MaxxValues                   *****
6322   cout << ">>>>>>>>>>>>>>>>>>>>>>>>start Summed Amplitude Plots Maxx " << endl;
6323   TH1F *MaxxSummedAmplitudeHisto[4];  // 1d histogramm for subdet
6324   MaxxSummedAmplitudeHisto[0] = (TH1F *)hfile->Get("h_maxxSUMAmpl_HB");
6325   MaxxSummedAmplitudeHisto[1] = (TH1F *)hfile->Get("h_maxxSUMAmpl_HE");
6326   MaxxSummedAmplitudeHisto[2] = (TH1F *)hfile->Get("h_maxxSUMAmpl_HO");
6327   MaxxSummedAmplitudeHisto[3] = (TH1F *)hfile->Get("h_maxxSUMAmpl_HF");
6328   TH1F *MaxxSummedAmplitudeOccupancyHisto[4];  // 1d histogramm for subdet
6329   MaxxSummedAmplitudeOccupancyHisto[0] = (TH1F *)hfile->Get("h_maxxOCCUP_HB");
6330   MaxxSummedAmplitudeOccupancyHisto[1] = (TH1F *)hfile->Get("h_maxxOCCUP_HE");
6331   MaxxSummedAmplitudeOccupancyHisto[2] = (TH1F *)hfile->Get("h_maxxOCCUP_HO");
6332   MaxxSummedAmplitudeOccupancyHisto[3] = (TH1F *)hfile->Get("h_maxxOCCUP_HF");
6333   TH1F *SAmplitudeHisto[4];  // 1d histogramm for subdet
6334   SAmplitudeHisto[0] = (TH1F *)hfile->Get("h_eventamplitude_HB");
6335   SAmplitudeHisto[1] = (TH1F *)hfile->Get("h_eventamplitude_HE");
6336   SAmplitudeHisto[2] = (TH1F *)hfile->Get("h_eventamplitude_HO");
6337   SAmplitudeHisto[3] = (TH1F *)hfile->Get("h_eventamplitude_HF");
6338   TH1F *OccupancyHisto[4];  // 1d histogramm for subdet
6339   OccupancyHisto[0] = (TH1F *)hfile->Get("h_eventoccupancy_HB");
6340   OccupancyHisto[1] = (TH1F *)hfile->Get("h_eventoccupancy_HE");
6341   OccupancyHisto[2] = (TH1F *)hfile->Get("h_eventoccupancy_HO");
6342   OccupancyHisto[3] = (TH1F *)hfile->Get("h_eventoccupancy_HF");
6343 
6344   int countamplmaxHB = 0;
6345   int countamplmaxHE = 0;
6346   int countamplmaxHO = 0;
6347   int countamplmaxHF = 0;
6348   int countoccumaxHB = 0;
6349   int countoccumaxHE = 0;
6350   int countoccumaxHO = 0;
6351   int countoccumaxHF = 0;
6352   unsigned long int countamplHB = 0;
6353   unsigned long int countamplHE = 0;
6354   unsigned long int countamplHO = 0;
6355   unsigned long int countamplHF = 0;
6356   unsigned long int countoccuHB = 0;
6357   unsigned long int countoccuHE = 0;
6358   unsigned long int countoccuHO = 0;
6359   unsigned long int countoccuHF = 0;
6360   gStyle->SetOptStat(110000);
6361   for (int sub = 0; sub < 4; sub++) {
6362     cFour->Clear();
6363     cFour->Divide(2, 2);
6364 
6365     cFour->cd(1);
6366     TH1F *lpqxc = new TH1F("lpqxc", "", maxbins, 1., maxbins + 1.);
6367     for (int i = 1; i <= lpqxc->GetXaxis()->GetNbins(); i++) {
6368       double ccc1 = 0.;
6369       if (MaxxSummedAmplitudeHisto[sub])
6370         ccc1 = MaxxSummedAmplitudeHisto[sub]->GetBinContent(i);
6371       //      if(ccc1>0.)     cout<<"111111111111111111111111111  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6372       if (ccc1 > 0.)
6373         lpqxc->Fill(float(i), ccc1);
6374       if (sub == 0 && ccc1 > 60000.)
6375         countamplmaxHB++;
6376       if (sub == 1 && ccc1 > 60000.)
6377         countamplmaxHE++;
6378       if (sub == 2 && ccc1 > 150000.)
6379         countamplmaxHO++;
6380       if (sub == 3 && ccc1 > 22000.)
6381         countamplmaxHF++;
6382     }
6383     //      gPad->SetLogy();
6384     lpqxc->SetMarkerStyle(20);
6385     lpqxc->SetMarkerSize(0.8);
6386     //    lpqxc->GetYaxis()->SetLabelSize(0.08);
6387     if (sub == 0)
6388       lpqxc->SetXTitle("HB: max SA over LS-events per LS \b");
6389     if (sub == 1)
6390       lpqxc->SetXTitle("HE: max SA over LS-events per LS \b");
6391     if (sub == 2)
6392       lpqxc->SetXTitle("HO: max SA over LS-events per LS \b");
6393     if (sub == 3)
6394       lpqxc->SetXTitle("HF: max SA over LS-events per LS \b");
6395     lpqxc->SetMarkerColor(2);
6396     lpqxc->SetLineColor(0);
6397     gPad->SetGridx();
6398     lpqxc->Draw("Error");
6399 
6400     /////////
6401     cFour->cd(2);
6402     TH1F *hpzlm = new TH1F("hpzlm", "", maxbins, 1., maxbins + 1.);
6403     for (int i = 1; i <= hpzlm->GetXaxis()->GetNbins(); i++) {
6404       double ccc1 = 0.;
6405       if (MaxxSummedAmplitudeOccupancyHisto[sub])
6406         ccc1 = MaxxSummedAmplitudeOccupancyHisto[sub]->GetBinContent(i);
6407       //    if(ccc1>0.)   cout<<"2222222222222222222222222  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6408       if (ccc1 > 0.)
6409         hpzlm->Fill(float(i), ccc1);
6410       if (sub == 0 && ccc1 > 2000.)
6411         countoccumaxHB++;
6412       if (sub == 1 && ccc1 > 1200.)
6413         countoccumaxHE++;
6414       if (sub == 2 && ccc1 > 2000.)
6415         countoccumaxHO++;
6416       if (sub == 3 && ccc1 > 860.)
6417         countoccumaxHF++;
6418     }
6419     //      gPad->SetLogy();
6420     hpzlm->SetMarkerStyle(20);
6421     hpzlm->SetMarkerSize(0.8);
6422     //    hpzlm->GetYaxis()->SetLabelSize(0.08);
6423     if (sub == 0)
6424       hpzlm->SetXTitle("HB: max Occupancy over LS-events per LS \b");
6425     if (sub == 1)
6426       hpzlm->SetXTitle("HE: max Occupancy over LS-events per LS \b");
6427     if (sub == 2)
6428       hpzlm->SetXTitle("HO: max Occupancy over LS-events per LS \b");
6429     if (sub == 3)
6430       hpzlm->SetXTitle("HF: max Occupancy over LS-events per LS \b");
6431     hpzlm->SetMarkerColor(4);
6432     hpzlm->SetLineColor(0);
6433     gPad->SetGridx();
6434     if (sub == 3) {
6435       hpzlm->SetMaximum(866.);
6436       hpzlm->SetMinimum(856.);
6437     }
6438     hpzlm->Draw("Error");
6439 
6440     /////////
6441     cFour->cd(3);
6442     gPad->SetLogy();
6443     if (SAmplitudeHisto[sub]) {
6444       for (int i = 1; i <= SAmplitudeHisto[sub]->GetXaxis()->GetNbins(); i++) {
6445         //      if(sub==0 && i * 800> 60000.) {
6446         //  cout<<">=>=>>=> countamplHB= "<<countamplHB<<" content = "<<SAmplitudeHisto[sub]->GetBinContent(i)<<" sub= "<<sub<<" i= "<<i<<  endl;
6447         //  countamplHB+=SAmplitudeHisto[sub]->GetBinContent(i);
6448         //      }
6449         if (sub == 0 && i * 800 > 60000.)
6450           countamplHB += SAmplitudeHisto[sub]->GetBinContent(i);
6451         if (sub == 1 && i * 1000 > 60000.)
6452           countamplHE += SAmplitudeHisto[sub]->GetBinContent(i);
6453         if (sub == 2 && i * 2500 > 150000.)
6454           countamplHO += SAmplitudeHisto[sub]->GetBinContent(i);
6455         if (sub == 3 && i * 1400 > 22000.)
6456           countamplHF += SAmplitudeHisto[sub]->GetBinContent(i);
6457       }
6458       SAmplitudeHisto[sub]->SetMarkerStyle(20);
6459       SAmplitudeHisto[sub]->SetMarkerSize(0.8);
6460       if (sub == 0)
6461         SAmplitudeHisto[sub]->SetTitle("HB event Amplitude\b");
6462       if (sub == 1)
6463         SAmplitudeHisto[sub]->SetTitle("HE event Amplitude\b");
6464       if (sub == 2)
6465         SAmplitudeHisto[sub]->SetTitle("HO event Amplitude\b");
6466       if (sub == 3)
6467         SAmplitudeHisto[sub]->SetTitle("HF event Amplitude\b");
6468       //    SAmplitudeHisto[sub]->GetYaxis()->SetLabelSize(0.08);
6469       SAmplitudeHisto[sub]->SetXTitle("event amplitude \b");
6470       SAmplitudeHisto[sub]->SetMarkerColor(2);
6471       SAmplitudeHisto[sub]->SetLineColor(2);
6472       SAmplitudeHisto[sub]->Draw("");
6473     }
6474     /////////
6475     cFour->cd(4);
6476     gPad->SetLogy();
6477     if (OccupancyHisto[sub]) {
6478       for (int i = 1; i <= OccupancyHisto[sub]->GetXaxis()->GetNbins(); i++) {
6479         if (sub == 0 && i * 30 > 2000.)
6480           countoccuHB += OccupancyHisto[sub]->GetBinContent(i);
6481         if (sub == 1 && i * 20 > 1200.)
6482           countoccuHE += OccupancyHisto[sub]->GetBinContent(i);
6483         if (sub == 2 && i * 25 > 2000.)
6484           countoccuHO += OccupancyHisto[sub]->GetBinContent(i);
6485         if (sub == 3 && i * 10 > 860.)
6486           countoccuHF += OccupancyHisto[sub]->GetBinContent(i);
6487       }
6488       OccupancyHisto[sub]->SetMarkerStyle(20);
6489       OccupancyHisto[sub]->SetMarkerSize(0.8);
6490       if (sub == 0)
6491         OccupancyHisto[sub]->SetTitle("HB event Occupancy\b");
6492       if (sub == 1)
6493         OccupancyHisto[sub]->SetTitle("HE event Occupancy\b");
6494       if (sub == 2)
6495         OccupancyHisto[sub]->SetTitle("HO event Occupancy\b");
6496       if (sub == 3)
6497         OccupancyHisto[sub]->SetTitle("HF event Occupancy\b");
6498       //    OccupancyHisto[sub]->GetYaxis()->SetLabelSize(0.08);
6499       OccupancyHisto[sub]->SetXTitle("event occupancy \b");
6500       OccupancyHisto[sub]->SetMarkerColor(4);
6501       OccupancyHisto[sub]->SetLineColor(4);
6502       OccupancyHisto[sub]->Draw("");
6503     }
6504 
6505     cFour->Update();
6506     if (sub == 0)
6507       cFour->Print("MaxxSummedAmplitudes_HB.png");
6508     if (sub == 1)
6509       cFour->Print("MaxxSummedAmplitudes_HE.png");
6510     if (sub == 2)
6511       cFour->Print("MaxxSummedAmplitudes_HO.png");
6512     if (sub == 3)
6513       cFour->Print("MaxxSummedAmplitudes_HF.png");
6514     cFour->Clear();
6515     if (lpqxc)
6516       delete lpqxc;
6517     if (hpzlm)
6518       delete hpzlm;
6519   }  //for
6520   gStyle->SetOptStat(0);
6521   //////////
6522   cout << ">=>=>>=> countamplmaxHB= " << countamplmaxHB << " countamplmaxHE= " << countamplmaxHE
6523        << " countamplmaxHO= " << countamplmaxHO << " countamplmaxHF= " << countamplmaxHF << endl;
6524   cout << ">=>=>>=> countoccumaxHB= " << countoccumaxHB << " countoccumaxHE= " << countoccumaxHE
6525        << " countoccumaxHO= " << countoccumaxHO << " countoccumaxHF= " << countoccumaxHF << endl;
6526   cout << ">=>=>>=> countamplHB= " << countamplHB << " countamplHE= " << countamplHE << " countamplHO= " << countamplHO
6527        << " countamplHF= " << countamplHF << endl;
6528   cout << ">=>=>>=> countoccuHB= " << countoccuHB << " countoccuHE= " << countoccuHE << " countoccuHO= " << countoccuHO
6529        << " countoccuHF= " << countoccuHF << endl;
6530 
6531   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6532   /// Summed Amplitude Plots:
6533   //*************************                        *****     channelsummedA over depths                   *****
6534   cout << ">>>>>>>>>>>>>>>>>>>>>>>>channelsummedA over depths " << endl;
6535   TH1F *ChannelDepthsummedAmplitudesPlots[4];  // 1d histogramm for subdet
6536   ChannelDepthsummedAmplitudesPlots[0] = (TH1F *)hfile->Get("h_sumamplitudechannel_HB");
6537   ChannelDepthsummedAmplitudesPlots[1] = (TH1F *)hfile->Get("h_sumamplitudechannel_HE");
6538   ChannelDepthsummedAmplitudesPlots[2] = (TH1F *)hfile->Get("h_sumamplitudechannel_HO");
6539   ChannelDepthsummedAmplitudesPlots[3] = (TH1F *)hfile->Get("h_sumamplitudechannel_HF");
6540   TLine *litebdt[4];
6541   if (ChannelDepthsummedAmplitudesPlots[0])
6542     litebdt[0] = new TLine(80., 0.8, 80., ChannelDepthsummedAmplitudesPlots[0]->GetBinContent(4) + 100.);
6543   if (ChannelDepthsummedAmplitudesPlots[1])
6544     litebdt[1] = new TLine(200., 0.8, 200., ChannelDepthsummedAmplitudesPlots[1]->GetBinContent(7) + 100.);
6545   if (ChannelDepthsummedAmplitudesPlots[2])
6546     litebdt[2] = new TLine(1200., 0.8, 1200., ChannelDepthsummedAmplitudesPlots[2]->GetBinContent(17) + 100.);
6547   if (ChannelDepthsummedAmplitudesPlots[3])
6548     litebdt[3] = new TLine(600., 0.8, 600., ChannelDepthsummedAmplitudesPlots[3]->GetBinContent(6) + 100.);
6549 
6550   gStyle->SetOptStat(110000);
6551   cFour1->Clear();
6552   cFour1->Divide(2, 2);
6553   for (int sub = 0; sub < 4; sub++) {
6554     if (sub == 0)
6555       cFour1->cd(1);
6556     if (sub == 1)
6557       cFour1->cd(2);
6558     if (sub == 2)
6559       cFour1->cd(3);
6560     if (sub == 3)
6561       cFour1->cd(4);
6562     gPad->SetLogy();
6563     ChannelDepthsummedAmplitudesPlots[sub]->SetMarkerStyle(20);
6564     ChannelDepthsummedAmplitudesPlots[sub]->SetMarkerSize(0.8);
6565     if (sub == 0)
6566       ChannelDepthsummedAmplitudesPlots[sub]->SetTitle("HB channel Amplitudes\b");
6567     if (sub == 1)
6568       ChannelDepthsummedAmplitudesPlots[sub]->SetTitle("HE channel Amplitudes\b");
6569     if (sub == 2)
6570       ChannelDepthsummedAmplitudesPlots[sub]->SetTitle("HO channel Amplitudes\b");
6571     if (sub == 3)
6572       ChannelDepthsummedAmplitudesPlots[sub]->SetTitle("HF channel Amplitudes\b");
6573     if (sub == 0)
6574       ChannelDepthsummedAmplitudesPlots[sub]->SetXTitle("HB channel depths summed Amplitudes \b");
6575     if (sub == 1)
6576       ChannelDepthsummedAmplitudesPlots[sub]->SetXTitle("HE channel depths summed Amplitudes \b");
6577     if (sub == 2)
6578       ChannelDepthsummedAmplitudesPlots[sub]->SetXTitle("HO channel depths summed Amplitudes \b");
6579     if (sub == 3)
6580       ChannelDepthsummedAmplitudesPlots[sub]->SetXTitle("HF channel depths summed Amplitudes \b");
6581     ChannelDepthsummedAmplitudesPlots[sub]->SetMarkerColor(2);
6582     ChannelDepthsummedAmplitudesPlots[sub]->SetLineColor(2);
6583     ChannelDepthsummedAmplitudesPlots[sub]->Draw("");
6584     litebdt[sub]->SetLineColor(kBlue);
6585     litebdt[sub]->Draw("s");
6586   }  //for
6587   cFour1->Update();
6588   cFour1->Print("ChannelDepthsummedAmplitudes.png");
6589   cFour1->Clear();
6590   gStyle->SetOptStat(0);
6591 
6592   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6593   /// Summed Amplitude Plots:
6594   //*************************                        *****     Ataildepth1_HB                 *****
6595   cout << ">>>>>>>>>>>>>>>>>>>>>>>>2DAtaildepth " << endl;
6596   //////////
6597   cHB->Clear();
6598   cHB->Divide(2, 1);
6599 
6600   TH2F *DAtaildepth1[2];  // 1d histogramm for subdet
6601   DAtaildepth1[0] = (TH2F *)hfile->Get("h_2DAtaildepth1_HB");
6602   DAtaildepth1[1] = (TH2F *)hfile->Get("h_2D0Ataildepth1_HB");
6603   cHB->cd(1);
6604   if (!DAtaildepth1[0] || !DAtaildepth1[1]) {
6605     cout << ">>>>>>>>>>>>>>>>>>>>>>>>Ataildepth1_HB EMPTY histoes for 2DAtaildepth 1" << endl;
6606   } else {
6607     TH2F *tail1 = (TH2F *)DAtaildepth1[0]->Clone("tail1");
6608     tail1->Divide(DAtaildepth1[0], DAtaildepth1[1], 1, 1, "B");
6609     //  tail1->Sumw2();
6610     gPad->SetGridy();
6611     gPad->SetGridx();
6612     gPad->SetLogz();
6613     tail1->SetMarkerStyle(20);
6614     tail1->SetMarkerSize(0.4);
6615     tail1->SetTitle("Amplitudes for tail-events (HBdepth1) \b");
6616     tail1->SetXTitle("#eta \b");
6617     tail1->SetYTitle("#phi \b");
6618     tail1->SetZTitle("2D <A> in the tail - HB Depth1 \b");
6619     tail1->SetMarkerColor(2);
6620     tail1->SetLineColor(2);
6621     tail1->Draw("COLZ");
6622   }
6623   TH2F *DAtaildepth2[2];  // 1d histogramm for subdet
6624   DAtaildepth2[0] = (TH2F *)hfile->Get("h_2DAtaildepth2_HB");
6625   DAtaildepth2[1] = (TH2F *)hfile->Get("h_2D0Ataildepth2_HB");
6626   cHB->cd(2);
6627   if (!DAtaildepth2[0] || !DAtaildepth2[1]) {
6628     cout << ">>>>>>>>>>>>>>>>>>>>>>>>Ataildepth1_HB EMPTY histoes for 2DAtaildepth 2" << endl;
6629   } else {
6630     TH2F *tail2 = (TH2F *)DAtaildepth2[0]->Clone("tail2");
6631     tail2->Divide(DAtaildepth2[0], DAtaildepth2[1], 1, 1, "B");
6632     //  tail2->Sumw2();
6633     gPad->SetGridy();
6634     gPad->SetGridx();
6635     gPad->SetLogz();
6636     tail2->SetMarkerStyle(20);
6637     tail2->SetMarkerSize(0.4);
6638     tail2->SetTitle("Amplitudes for tail-events (HBdepth2) \b");
6639     tail2->SetXTitle("#eta \b");
6640     tail2->SetYTitle("#phi \b");
6641     tail2->SetZTitle("2D <A> in the tail - HB Depth2 \b");
6642     tail2->SetMarkerColor(2);
6643     tail2->SetLineColor(2);
6644     tail2->Draw("COLZ");
6645   }
6646 
6647   cHB->Update();
6648   cHB->Print("AtaildepthHB.png");
6649   cHB->Clear();
6650 
6651   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6652   /// Summed Amplitude Plots:
6653   //*************************                        *****     sum(Signal+NoSignal) occupancy for HF                *****
6654   cout << ">>>>>>>>>>>>>>>>>>>>>>>>sumOccupancyHF " << endl;
6655   //////////
6656   cHB->Clear();
6657   cHB->Divide(1, 1);
6658   cHB->cd(1);
6659   if (SummedAmplitudeOccupancyHisto[3]) {
6660     TH1F *ufrew1 = (TH1F *)SummedAmplitudeOccupancyHisto[3]->Clone("ufrew1");
6661     if (SummedAmplitudeOccupancyHisto[3] && NoSignalSummedAmplitudeOccupancyHisto[3])
6662       ufrew1->Add(SummedAmplitudeOccupancyHisto[3], NoSignalSummedAmplitudeOccupancyHisto[3], 1, 1);
6663     ufrew1->GetXaxis()->SetRangeUser(1., maxbins + 1.);
6664     gPad->SetGridx();
6665     ufrew1->SetMarkerStyle(20);
6666     ufrew1->SetMarkerSize(0.8);
6667     ufrew1->GetYaxis()->SetLabelSize(0.04);
6668     ufrew1->SetTitle("HF Occupancy vs LS\b");
6669     ufrew1->SetXTitle("average occupancy per LS HF\b");
6670     ufrew1->SetMarkerColor(4);
6671     ufrew1->SetLineColor(0);
6672     ufrew1->SetMaximum(866.);
6673     ufrew1->SetMinimum(856.);
6674     ufrew1->Draw("Error");
6675     cHB->Update();
6676     cHB->Print("sumOccupancyHF.png");
6677     cHB->Clear();
6678     if (ufrew1)
6679       delete ufrew1;
6680   }
6681 
6682   //////////
6683   //////////
6684   //////////
6685   //////////
6686   //////////
6687   //////////
6688   //////////
6689   //====================================================================================================================
6690   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =====================================================================" << endl;
6691 
6692   //=====================================================================================================
6693   cout << ">>>>>>>>>>>>>>>>>>>>>>>> ==================================================" << endl;
6694 
6695   //=====================================================================================
6696   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =================================" << endl;
6697   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =================================" << endl;
6698   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =================================" << endl;
6699   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =================================" << endl;
6700 
6701   cout << ">>>>>>>             START NOW CREATING OF HTML PAGES      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
6702   //======================================================================
6703   // Creating each test kind for each subdet html pages:
6704   std::string raw_class;
6705   int ind = 0;
6706   ofstream htmlFile;
6707   for (int test = 0; test <= 5; test++) {  //Test: 0,
6708     for (int sub = 1; sub <= 4; sub++) {   //Subdetector: 1-HB, 2-HE, 3-HO, 4-HF
6709 
6710       //    cout<<"Creating each test kind for each subdet html pages:  test=  "<< test << "  sub= "  << sub <<    endl;
6711       if (test == 0) {
6712         if (sub == 1) {
6713           htmlFile.open("HB_CapID.html");
6714         }
6715         if (sub == 2) {
6716           htmlFile.open("HE_CapID.html");
6717         }
6718         if (sub == 3) {
6719           htmlFile.open("HO_CapID.html");
6720         }
6721         if (sub == 4) {
6722           htmlFile.open("HF_CapID.html");
6723         }
6724       }
6725       if (test == 1) {
6726         if (sub == 1) {
6727           htmlFile.open("HB_ADCampl.html");
6728         }
6729         if (sub == 2) {
6730           htmlFile.open("HE_ADCampl.html");
6731         }
6732         if (sub == 3) {
6733           htmlFile.open("HO_ADCampl.html");
6734         }
6735         if (sub == 4) {
6736           htmlFile.open("HF_ADCampl.html");
6737         }
6738       }
6739       if (test == 2) {
6740         if (sub == 1) {
6741           htmlFile.open("HB_Width.html");
6742         }
6743         if (sub == 2) {
6744           htmlFile.open("HE_Width.html");
6745         }
6746         if (sub == 3) {
6747           htmlFile.open("HO_Width.html");
6748         }
6749         if (sub == 4) {
6750           htmlFile.open("HF_Width.html");
6751         }
6752       }
6753       if (test == 3) {
6754         if (sub == 1) {
6755           htmlFile.open("HB_Ratio.html");
6756         }
6757         if (sub == 2) {
6758           htmlFile.open("HE_Ratio.html");
6759         }
6760         if (sub == 3) {
6761           htmlFile.open("HO_Ratio.html");
6762         }
6763         if (sub == 4) {
6764           htmlFile.open("HF_Ratio.html");
6765         }
6766       }
6767       if (test == 4) {
6768         if (sub == 1) {
6769           htmlFile.open("HB_Tmean.html");
6770         }
6771         if (sub == 2) {
6772           htmlFile.open("HE_Tmean.html");
6773         }
6774         if (sub == 3) {
6775           htmlFile.open("HO_Tmean.html");
6776         }
6777         if (sub == 4) {
6778           htmlFile.open("HF_Tmean.html");
6779         }
6780       }
6781       if (test == 5) {
6782         if (sub == 1) {
6783           htmlFile.open("HB_Tmax.html");
6784         }
6785         if (sub == 2) {
6786           htmlFile.open("HE_Tmax.html");
6787         }
6788         if (sub == 3) {
6789           htmlFile.open("HO_Tmax.html");
6790         }
6791         if (sub == 4) {
6792           htmlFile.open("HF_Tmax.html");
6793         }
6794       }
6795 
6796       htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
6797       htmlFile << "<head>" << std::endl;
6798       htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
6799       htmlFile << "<title> Certification Monitoring Tool </title>" << std::endl;
6800       htmlFile << "<style type=\"text/css\">" << std::endl;
6801       htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
6802                << std::endl;
6803       htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
6804       htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
6805                   "text-align: center;}"
6806                << std::endl;
6807       htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
6808       htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
6809       htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
6810       htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: #00FF00; }" << std::endl;
6811       htmlFile << "   td.s6 { font-family: arial, arial ce, helvetica; background-color: #FF0000; }" << std::endl;
6812       htmlFile << "</style>" << std::endl;
6813       htmlFile << "<body>" << std::endl;
6814 
6815       if (test == 0) {
6816         if (sub == 1)
6817           htmlFile << "<h1> Cap ID estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6818         if (sub == 2)
6819           htmlFile << "<h1> Cap ID estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6820         if (sub == 3)
6821           htmlFile << "<h1> Cap ID estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6822         if (sub == 4)
6823           htmlFile << "<h1> Cap ID estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6824       }
6825       if (test == 1) {
6826         if (sub == 1)
6827           htmlFile << "<h1> Mean ADC Amplitude estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6828         if (sub == 2)
6829           htmlFile << "<h1> Mean ADC Amplitude estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6830         if (sub == 3)
6831           htmlFile << "<h1> Mean ADC Amplitude estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6832         if (sub == 4)
6833           htmlFile << "<h1> Mean ADC Amplitude estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6834       }
6835       if (test == 2) {
6836         if (sub == 1)
6837           htmlFile << "<h1> Width estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6838         if (sub == 2)
6839           htmlFile << "<h1> Width estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6840         if (sub == 3)
6841           htmlFile << "<h1> Width estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6842         if (sub == 4)
6843           htmlFile << "<h1> Width estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6844       }
6845       if (test == 3) {
6846         if (sub == 1)
6847           htmlFile << "<h1> Ratio estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6848         if (sub == 2)
6849           htmlFile << "<h1> Ratio estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6850         if (sub == 3)
6851           htmlFile << "<h1> Ratio estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6852         if (sub == 4)
6853           htmlFile << "<h1> Ratio estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6854       }
6855       if (test == 4) {
6856         if (sub == 1)
6857           htmlFile << "<h1> Mean bin timing estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6858         if (sub == 2)
6859           htmlFile << "<h1> Mean bin timing estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6860         if (sub == 3)
6861           htmlFile << "<h1> Mean bin timing estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6862         if (sub == 4)
6863           htmlFile << "<h1> Mean bin timing estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6864       }
6865       if (test == 5) {
6866         if (sub == 1)
6867           htmlFile << "<h1> Maximum bin timing estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6868         if (sub == 2)
6869           htmlFile << "<h1> Maximum bin timing estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6870         if (sub == 3)
6871           htmlFile << "<h1> Maximum bin timing estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6872         if (sub == 4)
6873           htmlFile << "<h1> Maximum bin timing estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6874       }
6875 
6876       if (test == 1) {
6877         htmlFile << "<a name=\"Top\"></a>\n";
6878         htmlFile << "<b>Contents:<br>\n";
6879         htmlFile << "1. <a href=\"#Aij\">A_ij_LS (averaged over events in LS) </a><br>\n";
6880         htmlFile << "2. <a href=\"#OverflowAij\">A_ij_LS in overflow & underflow</a><br>\n";
6881         htmlFile << "3. <a href=\"#MainEstimator\">Main Estimator !!! </a><br>\n";
6882         htmlFile << "4. <a href=\"#ErrorA\">Error type A </a><br>\n";
6883         htmlFile << "5. <a href=\"#ErrorAaverage\">ErrorA cross check</a><br>\n";
6884         htmlFile << "6. <a href=\"#ErrorAoccupancy\">ErrorA occupancy plots</a><br>\n";
6885         htmlFile << "7. <a href=\"#ErrorB\">Error type B</a><br>\n";
6886         htmlFile << "8. <a href=\"#LSstatus\">Table of Average channel-Amplitude in Depthes over LSs </a><br>\n";
6887         htmlFile << "9. <a href=\"#RBXstatus\">RBX Status </a><br>\n";
6888         htmlFile << "10. <a href=\"#RBXPHItable\">Table of Average RBX-Amplitude in Phi over LSs </a><br>\n";
6889         htmlFile << "11. <a href=\"#RBXETAtable\">Table of Average RBX-Amplitude in Eta over LSs </a><br>\n";
6890         htmlFile << "12. <a href=\"#RBX3plots\">RBX A-Ratio to 1st LS: 3 plots </a><br>\n";
6891         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6892       }
6893 
6894       //     htmlFile << "<a href=\"#Top\">to top</a><br>\n";
6895 
6896       htmlFile << "<br>" << std::endl;
6897       if (test == 0) {
6898         htmlFile << "<h2> 0. Rate of CapID failures over all events of Run </h2>" << std::endl;
6899         htmlFile << "<h3> Channel legend: green - good, other colour - suspicious  </h3>" << std::endl;
6900         if (sub == 1)
6901           htmlFile << " <img src=\"MapCapIdErrorHB.png\" />" << std::endl;
6902         if (sub == 2)
6903           htmlFile << " <img src=\"MapCapIdErrorHE.png\" />" << std::endl;
6904         if (sub == 3)
6905           htmlFile << " <img src=\"MapCapIdErrorHO.png\" />" << std::endl;
6906         if (sub == 4)
6907           htmlFile << " <img src=\"MapCapIdErrorHF.png\" />" << std::endl;
6908       }
6909       if (test == 1)
6910         htmlFile << "<a name=\"Aij\"></a>\n";
6911       if (test != 0)
6912         htmlFile << "<h2> 1. Distribution of estimator averaged over events in LS, histogramed over all channels and "
6913                     "all LSs </h2>"
6914                  << std::endl;
6915       if (test == 0) {
6916         if (sub == 1)
6917           htmlFile << "<h2> 1.  Average Nbcs for only LS containing events with abnormal number of Bad channels >"
6918                    << CutAb[sub][1] << " (Depth1), " << CutAb[sub][2] << " (Depth2).</h2>" << std::endl;
6919         if (sub == 2)
6920           htmlFile << "<h2> 1.  Average Nbcs for only LS containing events with abnormal number of Bad channels >"
6921                    << CutAb[sub][1] << " (Depth1), " << CutAb[sub][2] << " (Depth2), " << CutAb[sub][3]
6922                    << " (Depth3).</h2>" << std::endl;
6923         if (sub == 3)
6924           htmlFile << "<h2> 1.  Average Nbcs for only LS containing events with abnormal number of Bad channels >"
6925                    << CutAb[sub][1] << " (Depth4).</h2>" << std::endl;
6926         if (sub == 4)
6927           htmlFile << "<h2> 1.  Average Nbcs for only LS containing events with abnormal number of Bad channels >"
6928                    << CutAb[sub][1] << " (Depth1), " << CutAb[sub][2] << " (Depth2).</h2>" << std::endl;
6929       }
6930 
6931       if (test != 0)
6932         htmlFile << "<h3> see Overflow and Underflow </h3>" << std::endl;
6933       if (test == 0)
6934         htmlFile << "<h3> Legend: dots correspond to BAD LS candidates.</h3>" << std::endl;
6935 
6936       if (test == 0) {
6937         if (sub == 1)
6938           htmlFile << " <img src=\"Hist_CAPID_Abnorm_HB.png\" />" << std::endl;
6939         if (sub == 2)
6940           htmlFile << " <img src=\"Hist_CAPID_Abnorm_HE.png\" />" << std::endl;
6941         if (sub == 3)
6942           htmlFile << " <img src=\"Hist_CAPID_Abnorm_HO.png\" />" << std::endl;
6943         if (sub == 4)
6944           htmlFile << " <img src=\"Hist_CAPID_Abnorm_HF.png\" />" << std::endl;
6945       }
6946       if (test == 1) {
6947         if (sub == 1)
6948           htmlFile << " <img src=\"H_ADCamplHB.png\" />" << std::endl;
6949         if (sub == 2)
6950           htmlFile << " <img src=\"H_ADCamplHE.png\" />" << std::endl;
6951         if (sub == 3)
6952           htmlFile << " <img src=\"H_ADCamplHO.png\" />" << std::endl;
6953         if (sub == 4)
6954           htmlFile << " <img src=\"H_ADCamplHF.png\" />" << std::endl;
6955       }
6956       if (test == 2) {
6957         if (sub == 1)
6958           htmlFile << " <img src=\"H_WidthHB.png\" />" << std::endl;
6959         if (sub == 2)
6960           htmlFile << " <img src=\"H_WidthHE.png\" />" << std::endl;
6961         if (sub == 3)
6962           htmlFile << " <img src=\"H_WidthHO.png\" />" << std::endl;
6963         if (sub == 4)
6964           htmlFile << " <img src=\"H_WidthHF.png\" />" << std::endl;
6965       }
6966       if (test == 3) {
6967         if (sub == 1)
6968           htmlFile << " <img src=\"H_RatioHB.png\" />" << std::endl;
6969         if (sub == 2)
6970           htmlFile << " <img src=\"H_RatioHE.png\" />" << std::endl;
6971         if (sub == 3)
6972           htmlFile << " <img src=\"H_RatioHO.png\" />" << std::endl;
6973         if (sub == 4)
6974           htmlFile << " <img src=\"H_RatioHF.png\" />" << std::endl;
6975       }
6976       if (test == 4) {
6977         if (sub == 1)
6978           htmlFile << " <img src=\"H_TmeanHB.png\" />" << std::endl;
6979         if (sub == 2)
6980           htmlFile << " <img src=\"H_TmeanHE.png\" />" << std::endl;
6981         if (sub == 3)
6982           htmlFile << " <img src=\"H_TmeanHO.png\" />" << std::endl;
6983         if (sub == 4)
6984           htmlFile << " <img src=\"H_TmeanHF.png\" />" << std::endl;
6985       }
6986       if (test == 5) {
6987         if (sub == 1)
6988           htmlFile << " <img src=\"H_TmaxHB.png\" />" << std::endl;
6989         if (sub == 2)
6990           htmlFile << " <img src=\"H_TmaxHE.png\" />" << std::endl;
6991         if (sub == 3)
6992           htmlFile << " <img src=\"H_TmaxHO.png\" />" << std::endl;
6993         if (sub == 4)
6994           htmlFile << " <img src=\"H_TmaxHF.png\" />" << std::endl;
6995       }
6996       htmlFile << "<br>" << std::endl;
6997       if (test == 1)
6998         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
6999 
7000       if (test == 0)
7001         htmlFile << "<h2> 2a.  Number of bad channels per event distribution in Run</h2>" << std::endl;
7002       if (test == 0)
7003         htmlFile << "<h3> Legends: dots correspond to BAD LS candidates.  </h3>" << std::endl;
7004       if (test == 0) {
7005         if (sub == 1)
7006           htmlFile << " <img src=\"HistNBadChsHB.png\" />" << std::endl;
7007         if (sub == 2)
7008           htmlFile << " <img src=\"HistNBadChsHE.png\" />" << std::endl;
7009         if (sub == 3)
7010           htmlFile << " <img src=\"HistNBadChsHO.png\" />" << std::endl;
7011         if (sub == 4)
7012           htmlFile << " <img src=\"HistNBadChsHF.png\" />" << std::endl;
7013       }
7014 
7015       if (test == 1)
7016         htmlFile << "<a name=\"OverflowAij\"></a>\n";
7017       if (test != 0)
7018         htmlFile << "<h2> 2. Estimator averaged over all events in the RUN for entries in overflow and underflow of "
7019                     "corresponding histogram above </h2>"
7020                  << std::endl;
7021       //              if (test !=0) htmlFile << "<h2> 2. Estimator averaged over all events in the RUN </h2>"<< std::endl;
7022       if (test == 0)
7023         htmlFile << "<h2> 2b. Averaged number of bad channels for each LS </h2>" << std::endl;
7024       //              if (test !=0) htmlFile << "<h3> Channel legend: white - good, other colour - bad.  </h3>"<< std::endl;
7025       if (test == 0) {
7026         if (sub == 1)
7027           htmlFile << "<h3> Legends: dots selected with following cuts: <td class=\"s6\" align=\"center\">"
7028                    << Cut0[test][sub][1] << " (Depth1), " << Cut0[test][sub][2]
7029                    << " (Depth2) correspond BAD LS.</td></h3>" << std::endl;
7030         if (sub == 2)
7031           htmlFile << "<h3> Legends: dots selected with following cuts: " << Cut0[test][sub][1] << " (Depth1), "
7032                    << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3) correspond BAD LS.</h3>"
7033                    << std::endl;
7034         if (sub == 3)
7035           htmlFile << "<h3> Legends: dots selected with following cuts: " << Cut0[test][sub][4]
7036                    << " (Depth4) correspond BAD LS.</h3>" << std::endl;
7037         if (sub == 4)
7038           htmlFile << "<h3> Legends: dots selected with following cuts: " << Cut0[test][sub][1] << " (Depth1), "
7039                    << Cut0[test][sub][2] << " (Depth2) correspond BAD LS.</h3>" << std::endl;
7040       }
7041       if (test == 0) {
7042         if (sub == 1)
7043           htmlFile << " <img src=\"HistNBCMNHB.png\" />" << std::endl;
7044         if (sub == 2)
7045           htmlFile << " <img src=\"HistNBCMNHE.png\" />" << std::endl;
7046         if (sub == 3)
7047           htmlFile << " <img src=\"HistNBCMNHO.png\" />" << std::endl;
7048         if (sub == 4)
7049           htmlFile << " <img src=\"HistNBCMNHF.png\" />" << std::endl;
7050       }
7051       if (test == 1) {
7052         if (sub == 1)
7053           htmlFile << " <img src=\"MapADCamplHB.png\" />" << std::endl;
7054         if (sub == 2)
7055           htmlFile << " <img src=\"MapADCamplHE.png\" />" << std::endl;
7056         if (sub == 3)
7057           htmlFile << " <img src=\"MapADCamplHO.png\" />" << std::endl;
7058         if (sub == 4)
7059           htmlFile << " <img src=\"MapADCamplHF.png\" />" << std::endl;
7060       }
7061       if (test == 2) {
7062         if (sub == 1)
7063           htmlFile << " <img src=\"MapWidthHB.png\" />" << std::endl;
7064         if (sub == 2)
7065           htmlFile << " <img src=\"MapWidthHE.png\" />" << std::endl;
7066         if (sub == 3)
7067           htmlFile << " <img src=\"MapWidthHO.png\" />" << std::endl;
7068         if (sub == 4)
7069           htmlFile << " <img src=\"MapWidthHF.png\" />" << std::endl;
7070       }
7071       if (test == 3) {
7072         if (sub == 1)
7073           htmlFile << " <img src=\"MapRatioHB.png\" />" << std::endl;
7074         if (sub == 2)
7075           htmlFile << " <img src=\"MapRatioHE.png\" />" << std::endl;
7076         if (sub == 3)
7077           htmlFile << " <img src=\"MapRatioHO.png\" />" << std::endl;
7078         if (sub == 4)
7079           htmlFile << " <img src=\"MapRatioHF.png\" />" << std::endl;
7080       }
7081       if (test == 4) {
7082         if (sub == 1)
7083           htmlFile << " <img src=\"MapTmeanHB.png\" />" << std::endl;
7084         if (sub == 2)
7085           htmlFile << " <img src=\"MapTmeanHE.png\" />" << std::endl;
7086         if (sub == 3)
7087           htmlFile << " <img src=\"MapTmeanHO.png\" />" << std::endl;
7088         if (sub == 4)
7089           htmlFile << " <img src=\"MapTmeanHF.png\" />" << std::endl;
7090       }
7091       if (test == 5) {
7092         if (sub == 1)
7093           htmlFile << " <img src=\"MapTmaxHB.png\" />" << std::endl;
7094         if (sub == 2)
7095           htmlFile << " <img src=\"MapTmaxHE.png\" />" << std::endl;
7096         if (sub == 3)
7097           htmlFile << " <img src=\"MapTmaxHO.png\" />" << std::endl;
7098         if (sub == 4)
7099           htmlFile << " <img src=\"MapTmaxHF.png\" />" << std::endl;
7100       }
7101       htmlFile << "<br>" << std::endl;
7102       if (test == 1)
7103         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7104 
7105       if (test == 1)
7106         htmlFile << "<a name=\"MainEstimator\"></a>\n";
7107       if (test != 0)
7108         htmlFile
7109             << "<h2> 3. Distribution of estimator averaged over events in LS and over all channels for each LS </h2>"
7110             << std::endl;
7111       if (test == 0) {
7112         if (sub == 1)
7113           htmlFile << "<h2> 3.  Portion of events with Nbcs>" << CutPo[sub][1] << " (Depth1), " << CutPo[sub][2]
7114                    << " (Depth2) in each LS.</h2>" << std::endl;
7115         if (sub == 2)
7116           htmlFile << "<h2> 3.  Portion of events with Nbcs>" << CutPo[sub][1] << " (Depth1), " << CutPo[sub][2]
7117                    << " (Depth2), " << CutPo[sub][3] << " (Depth3) in each LS.</h2>" << std::endl;
7118         if (sub == 3)
7119           htmlFile << "<h2> 3.  Portion of events with Nbcs>" << CutPo[sub][4] << " (Depth4) in each LS.</h2>"
7120                    << std::endl;
7121         if (sub == 4)
7122           htmlFile << "<h2> 3.  Portion of events with Nbcs>" << CutPo[sub][1] << " (Depth1), " << CutPo[sub][2]
7123                    << " (Depth2) in each LS.</h2>" << std::endl;
7124         htmlFile << "<h3> Legend: dots correspond to BAD LS candidates.</h3>" << std::endl;
7125       }
7126       if (test != 0) {
7127         if (sub == 1)
7128           htmlFile << "<h3> Legends:  dots selected with following cuts: <td class=\"s6\" align=\"center\">"
7129                    << Cut0[test][sub][1] << " (Depth1), " << Cut0[test][sub][2]
7130                    << " (Depth2) correspond BAD LS.</td></h3>" << std::endl;
7131         if (sub == 2)
7132           htmlFile << "<h3> Legends:  dots selected with following cuts: " << Cut0[test][sub][1] << " (Depth1), "
7133                    << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3), " << Cut0[test][sub][4]
7134                    << " (Depth4), " << Cut0[test][sub][5] << " (Depth5), " << Cut0[test][sub][6] << " (Depth6), "
7135                    << Cut0[test][sub][7] << " (Depth7) correspond BAD LS. </h3>" << std::endl;
7136         if (sub == 3)
7137           htmlFile << "<h3> Legends:  dots selected with following cuts: " << Cut0[test][sub][4]
7138                    << " (Depth4) correspond BAD LS. </h3>" << std::endl;
7139         if (sub == 4)
7140           htmlFile << "<h3> Legends:  dots selected with following cuts: " << Cut0[test][sub][1] << " (Depth1), "
7141                    << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3), " << Cut0[test][sub][4]
7142                    << " (Depth4) correspond BAD LS. </h3>" << std::endl;
7143       }
7144       if (test == 0) {
7145         if (sub == 1)
7146           htmlFile << " <img src=\"HistPortHB.png\" />" << std::endl;
7147         if (sub == 2)
7148           htmlFile << " <img src=\"HistPortHE.png\" />" << std::endl;
7149         if (sub == 3)
7150           htmlFile << " <img src=\"HistPortHO.png\" />" << std::endl;
7151         if (sub == 4)
7152           htmlFile << " <img src=\"HistPortHF.png\" />" << std::endl;
7153       }
7154       if (test == 1) {
7155         if (sub == 1)
7156           htmlFile << " <img src=\"HistADCamplHB.png\" />" << std::endl;
7157         if (sub == 2)
7158           htmlFile << " <img src=\"HistADCamplHE.png\" />" << std::endl;
7159         if (sub == 3)
7160           htmlFile << " <img src=\"HistADCamplHO.png\" />" << std::endl;
7161         if (sub == 4)
7162           htmlFile << " <img src=\"HistADCamplHF.png\" />" << std::endl;
7163       }
7164       if (test == 2) {
7165         if (sub == 1)
7166           htmlFile << " <img src=\"HistWidthHB.png\" />" << std::endl;
7167         if (sub == 2)
7168           htmlFile << " <img src=\"HistWidthHE.png\" />" << std::endl;
7169         if (sub == 3)
7170           htmlFile << " <img src=\"HistWidthHO.png\" />" << std::endl;
7171         if (sub == 4)
7172           htmlFile << " <img src=\"HistWidthHF.png\" />" << std::endl;
7173       }
7174       if (test == 3) {
7175         if (sub == 1)
7176           htmlFile << " <img src=\"HistRatioHB.png\" />" << std::endl;
7177         if (sub == 2)
7178           htmlFile << " <img src=\"HistRatioHE.png\" />" << std::endl;
7179         if (sub == 3)
7180           htmlFile << " <img src=\"HistRatioHO.png\" />" << std::endl;
7181         if (sub == 4)
7182           htmlFile << " <img src=\"HistRatioHF.png\" />" << std::endl;
7183       }
7184       if (test == 4) {
7185         if (sub == 1)
7186           htmlFile << " <img src=\"HistTmeanHB.png\" />" << std::endl;
7187         if (sub == 2)
7188           htmlFile << " <img src=\"HistTmeanHE.png\" />" << std::endl;
7189         if (sub == 3)
7190           htmlFile << " <img src=\"HistTmeanHO.png\" />" << std::endl;
7191         if (sub == 4)
7192           htmlFile << " <img src=\"HistTmeanHF.png\" />" << std::endl;
7193       }
7194       if (test == 5) {
7195         if (sub == 1)
7196           htmlFile << " <img src=\"HistTmaxHB.png\" />" << std::endl;
7197         if (sub == 2)
7198           htmlFile << " <img src=\"HistTmaxHE.png\" />" << std::endl;
7199         if (sub == 3)
7200           htmlFile << " <img src=\"HistTmaxHO.png\" />" << std::endl;
7201         if (sub == 4)
7202           htmlFile << " <img src=\"HistTmaxHF.png\" />" << std::endl;
7203       }
7204       htmlFile << "<br>" << std::endl;
7205 
7206       if (test == 1) {
7207         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7208         htmlFile << "<a name=\"ErrorA\"></a>\n";
7209         htmlFile << "<h2> 4. Error type A</h2>\n";
7210         htmlFile << "<h3> note: no sence to see plots of this item if max difference is too large(due to very high A "
7211                     "of some channels)</h3>\n";
7212         htmlFile << "<br>\n";
7213 
7214         //HB:
7215         if (sub == 1) {
7216           htmlFile << "<h3>Mean of max difference between dependencies to be within: 0.1-1.6 (p-p collisions) </h3>\n";
7217           htmlFile << " <img src=\"HistErrA_HB.png\" />\n";
7218           htmlFile << "<br>\n";
7219           if (flagErrAB_HB[0] == -1)
7220             htmlFile << "<h3>test was not possible</h3>\n";
7221           else if (flagErrAB_HB[0] == 0)
7222             htmlFile << "<h3> Fine:NoErrorA_HB (Mean of max difference " << avedelta_HB
7223                      << "  is within 0.1-1.6) </h3>\n";
7224           else if (flagErrAB_HB[0] == 1)
7225             htmlFile << "<<h3> ErrorA_HB is available once Mean of max difference " << avedelta_HB
7226                      << " is out 0.1-1.6 (p-p collisions)</font></h3>\n";
7227           else
7228             htmlFile << "<h3>auto-interpretation is not available</h3>\n";
7229           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7230 
7231           htmlFile << "<a name=\"ErrorAaverage\"></a>\n";
7232 
7233           htmlFile << "<h2> 5. Error type A cross check: see 2D pattern of channels   </h2>\n";
7234           htmlFile << "<h2> 1) with average channel Amplitudes(No cut), 2) with average channel Amplitudes(<A> >25), "
7235                       "3) with channel Amplitude (A<35);  </h2>\n";
7236           htmlFile << " <img src=\"ChkErrA_HB1.png\" /><br><br>\n";
7237           htmlFile << " <img src=\"ChkErrA_HB2.png\" /><br>\n";
7238           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7239 
7240           htmlFile << "<a name=\"ErrorAoccupancy\"></a>\n";
7241           htmlFile << "<h2> 6. Error type A: min/ave ratio for occupancy distributions with Amplitude bigger 25 "
7242                       "(HBM:neg.eta;HBP:pos.eta) </h2>\n";
7243           htmlFile << "<h2> FOR CROSS-CHECK OLNY !!!</h2>\n";
7244           htmlFile << "<h2> TO IDENTIFY A-type errors: for most of LSs the ratio to be lower 0.6 at least for HF- or "
7245                       "HF+ </h2>\n";
7246           htmlFile << "<h2> For runs without A-type errors: for most of LSs the ratio is higher 0.6 and is the same "
7247                       "for HF- and HF+ </h2>\n";
7248           htmlFile << " <img src=\"OccPlots_HB.png\" /><br><br>\n";
7249           htmlFile << "<br>\n";
7250           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7251 
7252           htmlFile << "<a name=\"ErrorB\"></a>\n";
7253           htmlFile << "<h2> 7. Error type B\n";
7254           htmlFile << "<h3> ErrorB identification: digi-collection size != 10.</h3>\n";
7255           htmlFile << " <img src=\"HistErrB_HB_1.png\" />\n<br>\n";
7256           htmlFile << " <img src=\"HistErrB_HB_2.png\" />\n<br>\n";
7257           htmlFile << "<br>\n";
7258           htmlFile << "<h3> if Error type B is available, it start from:    " << LSofFirstErrB_HB << "  LS </h3>\n";
7259           htmlFile << "<br>\n";
7260         }
7261 
7262         //HE:
7263         if (sub == 2) {
7264           htmlFile << "<h3>Mean of max difference between dependencies to be within: 0.2-1.8 (p-p collisions) </h3>\n";
7265           htmlFile << " <img src=\"HistErrA_HE.png\" />\n";
7266           htmlFile << "<br>\n";
7267           if (flagErrAB_HE[0] == -1)
7268             htmlFile << "<h3>test was not possible</h3>\n";
7269           else if (flagErrAB_HE[0] == 0)
7270             htmlFile << "<h3> Fine:NoErrorA_HE (Mean of max difference " << avedelta_HE
7271                      << "  is within 0.2-1.8) </h3>\n";
7272           else if (flagErrAB_HE[0] == 1)
7273             htmlFile << "<<h3> ErrorA_HE is available once Mean of max difference " << avedelta_HE
7274                      << " is out 0.2-1.8 (p-p collisions)</font></h3>\n";
7275           else
7276             htmlFile << "<h3>auto-interpretation is not available</h3>\n";
7277           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7278 
7279           htmlFile << "<a name=\"ErrorAaverage\"></a>\n";
7280 
7281           htmlFile << "<h2> 5. Error type A cross check: see 2D pattern of channels   </h2>\n";
7282           htmlFile << "<h2> 1) with average channel Amplitudes(No cut), 2) with average channel Amplitudes(<A> "
7283                       ">1000.fC), 3) with channel Amplitude (A<500fC);  </h2>\n";
7284           htmlFile << " <img src=\"ChkErrA_HE1.png\" /><br><br>\n";
7285           htmlFile << " <img src=\"ChkErrA_HE2.png\" /><br>\n";
7286           htmlFile << " <img src=\"ChkErrA_HE3.png\" /><br>\n";
7287           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7288 
7289           htmlFile << "<a name=\"ErrorAoccupancy\"></a>\n";
7290           htmlFile << "<h2> 6. Error type A: min/ave ratio for occupancy distributions with Amplitude bigger 35 "
7291                       "(HEM:neg.eta;HEP:pos.eta) </h2>\n";
7292           htmlFile << "<h2> FOR CROSS-CHECK OLNY !!!</h2>\n";
7293           htmlFile << "<h2> TO IDENTIFY A-type errors: for most of LSs the ratio to be lower 0.3 at least for HF- or "
7294                       "HF+ </h2>\n";
7295           htmlFile << "<h2> For runs without A-type errors: for most of LSs the ratio is higher 0.3 and is the same "
7296                       "for HF- and HF+ </h2>\n";
7297           htmlFile << " <img src=\"OccPlots_HE.png\" /><br><br>\n";
7298           htmlFile << "<br>\n";
7299           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7300 
7301           htmlFile << "<a name=\"ErrorB\"></a>\n";
7302           htmlFile << "<h2> 7. Error type B\n";
7303           htmlFile << "<h3> ErrorB identification: digi-collection size != 8.</h3>\n";
7304           htmlFile << " <img src=\"HistErrB_HE_1.png\" />\n<br>\n";
7305           htmlFile << " <img src=\"HistErrB_HE_2.png\" />\n<br>\n";
7306           htmlFile << " <img src=\"HistErrB_HE_3.png\" />\n<br>\n";
7307           htmlFile << "<br>\n";
7308           htmlFile << "<h3> if Error type B is available, it start from:    " << LSofFirstErrB_HE << "  LS </h3>\n";
7309           htmlFile << "<br>\n";
7310         }
7311 
7312         //HO:
7313         if (sub == 3) {
7314           htmlFile << "<h3>Mean of max difference between dependencies to be within: 0.1-1.5 (p-p collisions) </h3>\n";
7315           htmlFile << " <img src=\"HistErrA_HO.png\" />\n";
7316           htmlFile << "<br>\n";
7317           if (flagErrAB_HO[0] == -1)
7318             htmlFile << "<h3>test was not possible</h3>\n";
7319           else if (flagErrAB_HO[0] == 0)
7320             htmlFile << "<h3> Fine:NoErrorA_HO (Mean of max difference " << avedelta_HO
7321                      << "  is within 0.1-1.5) </h3>\n";
7322           else if (flagErrAB_HO[0] == 1)
7323             htmlFile << "<<h3> ErrorA_HO is available once Mean of max difference " << avedelta_HO
7324                      << " is out 0.1-1.5 (p-p collisions)</font></h3>\n";
7325           else
7326             htmlFile << "<h3>auto-interpretation is not available</h3>\n";
7327           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7328 
7329           htmlFile << "<a name=\"ErrorAaverage\"></a>\n";
7330 
7331           htmlFile << "<h2> 5. Error type A cross check: see 2D pattern of channels   </h2>\n";
7332           htmlFile << "<h2> 1) with average channel Amplitudes(No cut), 2) with average channel Amplitudes(<A> >80), "
7333                       "3) with channel Amplitude (A<100);  </h2>\n";
7334           //       htmlFile << "<h2> 2D. Cross check for error A</h2>\n";
7335           htmlFile << " <img src=\"ChkErrA_HO4.png\" /><br><br>\n";
7336           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7337 
7338           htmlFile << "<a name=\"ErrorAoccupancy\"></a>\n";
7339           htmlFile << "<h2> 6. Error type A: min/ave ratio for occupancy distributions with Amplitude bigger 80 "
7340                       "(HOM:neg.eta;HOP:pos.eta) </h2>\n";
7341           htmlFile << "<h2> FOR CROSS-CHECK OLNY !!!</h2>\n";
7342           htmlFile << "<h2> TO IDENTIFY A-type errors: for most of LSs the ratio to be lower 0.8 at least for HF- or "
7343                       "HF+ </h2>\n";
7344           htmlFile << "<h2> For runs without A-type errors: for most of LSs the ratio is higher 0.8 and is the same "
7345                       "for HF- and HF+ </h2>\n";
7346           htmlFile << " <img src=\"OccPlots_HO.png\" /><br><br>\n";
7347           htmlFile << "<br>\n";
7348           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7349 
7350           htmlFile << "<a name=\"ErrorB\"></a>\n";
7351           htmlFile << "<h2> 7. Error type B\n";
7352           htmlFile << "<h3> ErrorB identification: digi-collection size != 10. </h3>\n";
7353           htmlFile << " <img src=\"HistErrB_HO_4.png\" />\n<br>\n";
7354           htmlFile << "<br>\n";
7355           htmlFile << "<h3> if Error type B is available, it start from:    " << LSofFirstErrB_HO << "  LS </h3>\n";
7356           htmlFile << "<br>\n";
7357         }
7358 
7359         //HF:
7360         if (sub == 4) {
7361           //        flagSpecHF+=1;
7362           htmlFile << "<h3>Mean of max difference between dependencies to be within: 0.8-2.4 (p-p collisions) </h3>\n";
7363           htmlFile << " <img src=\"HistErrA_HF.png\" />\n";
7364           htmlFile << "<br>\n";
7365           if (flagErrAB_HF[0] == -1)
7366             htmlFile << "<h3>test was not possible</h3>\n";
7367           else if (flagErrAB_HF[0] == 0)
7368             htmlFile << "<h3> Fine:NoErrorA_HF (Mean of max difference " << avedelta_HF
7369                      << "  is within 0.8-2.4) </h3>\n";
7370           else if (flagErrAB_HF[0] == 1)
7371             htmlFile << "<<h3> ErrorA_HF is available once Mean of max difference " << avedelta_HF
7372                      << " is out 0.8-2.4 (p-p collisions)</font></h3>\n";
7373           else
7374             htmlFile << "<h3>auto-interpretation is not available</h3>\n";
7375           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7376 
7377           htmlFile << "<a name=\"ErrorAaverage\"></a>\n";
7378 
7379           htmlFile << "<h2> 5. Error type A cross check: see 2D pattern of channels   </h2>\n";
7380           htmlFile << "<h2> 1) with average channel Amplitudes(No cut), 2) with average channel Amplitudes(<A> >20), "
7381                       "3) with channel Amplitude (A<20);  </h2>\n";
7382           //       htmlFile << "<h2> 2D. Cross check for error A</h2>\n";
7383           htmlFile << " <img src=\"ChkErrA_HF1.png\" /><br><br>\n";
7384           htmlFile << " <img src=\"ChkErrA_HF2.png\" /><br>\n";
7385           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7386 
7387           htmlFile << "<a name=\"ErrorAoccupancy\"></a>\n";
7388           htmlFile << "<h2> 6. Error type A: min/ave ratio for occupancy distributions with Amplitude bigger 20 "
7389                       "(HFM:neg.eta;HFP:pos.eta) </h2>\n";
7390           htmlFile << "<h2> FOR CROSS-CHECK OLNY !!!</h2>\n";
7391           htmlFile << "<h2> TO IDENTIFY A-type errors: for most of LSs the ratio to be lower 0.8 at least for HF- or "
7392                       "HF+ </h2>\n";
7393           htmlFile << "<h2> For runs without A-type errors: for most of LSs the ratio is higher 0.8 and is the same "
7394                       "for HF- and HF+ </h2>\n";
7395           htmlFile << " <img src=\"OccPlots_HF.png\" /><br><br>\n";
7396           htmlFile << "<br>\n";
7397           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7398 
7399           htmlFile << "<a name=\"ErrorB\"></a>\n";
7400           htmlFile << "<h2> 7. Error type B\n";
7401           htmlFile << "<h3> ErrorB identification: digi-collection size != 4. </h3>\n";
7402           htmlFile << " <img src=\"HistErrB_HF_1.png\" />\n<br>\n";
7403           htmlFile << " <img src=\"HistErrB_HF_2.png\" />\n<br>\n";
7404           htmlFile << "<br>\n";
7405           htmlFile << "<h3> if Error type B is available, it start from:    " << LSofFirstErrB_HF << "  LS </h3>\n";
7406           htmlFile << "<br>\n";
7407         }
7408         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7409 
7410       }  //test=1 Amplitude
7411 
7412       if (test == 1)
7413         htmlFile << "<a name=\"LSstatus\"></a>\n";
7414       // Continue with common sections
7415       if (sub == 1) {
7416         htmlFile << "<h2> 8.Lumisection Status for HB: </h2>" << std::endl;
7417         htmlFile << "<h3> Legends: Red boxes correspond BAD LS selected with following cuts: <td class=\"s6\" "
7418                     "align=\"center\">"
7419                  << Cut0[test][sub][1] << " (Depth1), " << Cut0[test][sub][2] << " (Depth2). </td></h3>" << std::endl;
7420       }
7421       if (sub == 2) {
7422         htmlFile << "<h2> 8.Lumisection Status for HE: </h2>" << std::endl;
7423         htmlFile << "<h3> Legends: Red boxes correspond BAD LS selected with following cuts: " << Cut0[test][sub][1]
7424                  << " (Depth1), " << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3),"
7425                  << Cut0[test][sub][4] << " (Depth4)," << Cut0[test][sub][5] << " (Depth5)," << Cut0[test][sub][6]
7426                  << " (Depth6)," << Cut0[test][sub][7] << " (Depth7). </h3>" << std::endl;
7427       }
7428       if (sub == 3) {
7429         //      htmlFile << Form("<h2> %d.Lumisection Status for HO </h2>",4+flagSpecHF)<< std::endl;
7430         htmlFile << "<h2> 8.Lumisection Status for HO: </h2>" << std::endl;
7431         htmlFile << "<h3> Legends: Red boxes correspond BAD LS selected with following cuts: " << Cut0[test][sub][4]
7432                  << " (Depth4). </h3>" << std::endl;
7433       }
7434       if (sub == 4) {
7435         htmlFile << "<h2> 8.Lumisection Status for HF: </h2>" << std::endl;
7436         htmlFile << "<h3> Legends: Red boxes correspond BAD LS selected with following cuts: " << Cut0[test][sub][1]
7437                  << " (Depth1), " << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3), "
7438                  << Cut0[test][sub][4] << " (Depth4), </h3>" << std::endl;
7439       }
7440       htmlFile << "<br>" << std::endl;
7441       htmlFile << "<table>" << std::endl;
7442       htmlFile << "<tr>";
7443       htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
7444       //              htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
7445       htmlFile << "<td class=\"s1\" align=\"center\">Number of events</td>" << std::endl;
7446       /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7447 
7448       int kkkkkkmax = k_max[sub];
7449       if ((sub == 4 || sub == 2) && test == 1)
7450         kkkkkkmax = k_maxHFupgrade[sub];
7451       //       if (test==1 && sub==4) kkkkkkmax = k_maxHFupgrade[sub];
7452 
7453       if (test == 0)
7454         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7455           htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > Depth " << k << " </td>" << std::endl;
7456       if (test == 1)
7457         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7458           htmlFile << "<td class=\"s1\" align=\"center\">< A > Depth " << k << " </td>" << std::endl;
7459       if (test == 2)
7460         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7461           htmlFile << "<td class=\"s1\" align=\"center\">< W > Depth " << k << " </td>" << std::endl;
7462       if (test == 3)
7463         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7464           htmlFile << "<td class=\"s1\" align=\"center\">< R > Depth " << k << " </td>" << std::endl;
7465       if (test == 4)
7466         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7467           htmlFile << "<td class=\"s1\" align=\"center\">< TSn > Depth " << k << " </td>" << std::endl;
7468       if (test == 5)
7469         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7470           htmlFile << "<td class=\"s1\" align=\"center\">< TSx > Depth " << k << " </td>" << std::endl;
7471       htmlFile << "</tr>" << std::endl;
7472 
7473       ind = 0;
7474       for (int i = 1; i <= MaxLum; i++) {
7475         if ((ind % 2) == 1)
7476           raw_class = "<td class=\"s2\" align=\"center\">";
7477         else
7478           raw_class = "<td class=\"s3\" align=\"center\">";
7479         htmlFile << "<tr>" << std::endl;
7480         htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
7481         //                  htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
7482         htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
7483         for (int k = k_min[sub]; k <= kkkkkkmax; k++) {
7484           if (HistNumBadChanDepth[test][sub][k]->GetBinContent(i) > Cut0[test][sub][k]) {
7485             if (test == 1)
7486               htmlFile << "<td class=\"s6\" align=\"center\">"
7487                        << int(HistNumBadChanDepth[test][sub][k]->GetBinContent(i)) << "</td>" << std::endl;
7488             else
7489               htmlFile << "<td class=\"s6\" align=\"center\">" << (HistNumBadChanDepth[test][sub][k]->GetBinContent(i))
7490                        << "</td>" << std::endl;
7491           } else {
7492             if (test == 1)
7493               htmlFile << raw_class << int(HistNumBadChanDepth[test][sub][k]->GetBinContent(i)) << "</td>" << std::endl;
7494             else
7495               htmlFile << raw_class << (HistNumBadChanDepth[test][sub][k]->GetBinContent(i)) << "</td>" << std::endl;
7496           }
7497         }
7498         htmlFile << "</tr>" << std::endl;
7499         ind += 1;
7500       }
7501       htmlFile << "</table>" << std::endl;
7502 
7503       htmlFile << "<br>" << std::endl;
7504       if (test == 1)
7505         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7506       htmlFile << "<br>" << std::endl;
7507 
7508       // Only for Amplitudes (test=1):
7509       /// RBX:
7510       if (test == 1) {
7511         ///////////////////////////////////////////////////////////////////////////////////////////////////
7512         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    9. RBXstatus
7513         htmlFile << "<a name=\"RBXstatus\"></a>\n";
7514 
7515         //HB j = 7,8,9,10            11,12,13,14
7516         if (sub == 1) {
7517           htmlFile << "<h2> 9. Average Amplitudes of RBX for HB: </h2>" << std::endl;
7518           htmlFile << "<h3> where </h3>" << std::endl;
7519           htmlFile << "<h3> jeta = 7,8,9,10 (Negative direction); ............&& ............  jeta = 11,12,13,14 "
7520                       "(Positive direction);  </h3>"
7521                    << std::endl;
7522           htmlFile << "<h3> jphi =  0, 1,..... 16, 17 </h3>" << std::endl;
7523           //           htmlFile << "<h3> jphi =  0, 1, 2, 3, 4, 5 (range 1) ............&& ............  jphi =  6, 7, 8, 9,10,11 (range 2) ............&& ............  jphi = 12,13,14,15,16,17 (range 3)</h3>"<< std::endl;
7524           htmlFile << " <img src=\"RBX-HB-2Dplot.png\" />\n";
7525           htmlFile << "<br>\n";
7526 
7527           htmlFile << "<h2> Average Amplitudes of RBX-PHI for HB: </h2>" << std::endl;
7528           htmlFile << " <img src=\"RBX-HB-1Dplot.png\" />\n";
7529           htmlFile << "<br>\n";
7530 
7531           htmlFile << "<h2> Average Amplitudes of RBX-ETA for HB: </h2>" << std::endl;
7532           htmlFile << " <img src=\"RBX-HB-11Dplot.png\" />\n";
7533           htmlFile << "<br>\n";
7534 
7535           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7536         }
7537         // HE: j = 3,4,5, 6, 7      14,15,16,17,18
7538         if (sub == 2) {
7539           htmlFile << "<h2> 9. Averaged Amplitudes of RBX for HE: </h2>" << std::endl;
7540           htmlFile << "<h3> where </h3>" << std::endl;
7541           htmlFile << "<h3> jeta = 3,4,5, 6, 7 (Negative direction); ............&& ............  jeta = "
7542                       "14,15,16,17,18 (Positive direction);  </h3>"
7543                    << std::endl;
7544           htmlFile << "<h3> jphi =  0, 1,..... 16, 17 </h3>" << std::endl;
7545           //           htmlFile << "<h3> jphi =  0, 1, 2, 3, 4, 5 (range 1) ............&& ............  jphi =  6, 7, 8, 9,10,11 (range 2) ............&& ............  jphi = 12,13,14,15,16,17 (range 3)</h3>"<< std::endl;
7546           htmlFile << " <img src=\"RBX-HE-2Dplot.png\" />\n";
7547           htmlFile << "<br>\n";
7548 
7549           htmlFile << "<h2> Average Amplitudes of RBX-PHI for HE: </h2>" << std::endl;
7550           htmlFile << " <img src=\"RBX-HE-1Dplot.png\" />\n";
7551           htmlFile << "<br>\n";
7552 
7553           htmlFile << "<h2> Average Amplitudes of RBX-ETA for HE: </h2>" << std::endl;
7554           htmlFile << " <img src=\"RBX-HE-11Dplot.png\" />\n";
7555           htmlFile << "<br>\n";
7556 
7557           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7558         }
7559         // HO:   j = 7,8,9,10            11,12,13,14
7560         if (sub == 3) {
7561           htmlFile << "<h2> 9. Averaged Amplitudes of RBX for HO: </h2>" << std::endl;
7562           htmlFile << "<h3> where </h3>" << std::endl;
7563           htmlFile << "<h3> jeta = 7,8,9,10 (Negative direction); ............&& ............  jeta = 11,12,13,14 "
7564                       "(Positive direction);  </h3>"
7565                    << std::endl;
7566           htmlFile << "<h3> jphi =  0, 1,..... 16, 17 </h3>" << std::endl;
7567           //           htmlFile << "<h3> jphi =  0, 1, 2, 3, 4, 5 (range 1) ............&& ............  jphi =  6, 7, 8, 9,10,11 (range 2) ............&& ............  jphi = 12,13,14,15,16,17 (range 3)</h3>"<< std::endl;
7568           htmlFile << " <img src=\"RBX-HO-2Dplot.png\" />\n";
7569           htmlFile << "<br>\n";
7570 
7571           htmlFile << "<h2> Average Amplitudes of RBX-PHI for HO: </h2>" << std::endl;
7572           htmlFile << " <img src=\"RBX-HO-1Dplot.png\" />\n";
7573           htmlFile << "<br>\n";
7574 
7575           htmlFile << "<h2> Average Amplitudes of RBX-ETA for HO: </h2>" << std::endl;
7576           htmlFile << " <img src=\"RBX-HO-11Dplot.png\" />\n";
7577           htmlFile << "<br>\n";
7578 
7579           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7580         }
7581         //HF:j = 0,1,2, 3            18,19,20,21
7582         if (sub == 4) {
7583           htmlFile << "<h2> 9. Averaged Amplitudes of RBX for HF: </h2>" << std::endl;
7584           htmlFile << "<h3> where </h3>" << std::endl;
7585           htmlFile << "<h3> jeta = 0,1,2, 3 (Negative direction); ............&& ............  jeta = 18,19,20,21 "
7586                       "(Positive direction);  </h3>"
7587                    << std::endl;
7588           htmlFile << "<h3> jphi =  0, 1,..... 16, 17 </h3>" << std::endl;
7589           //           htmlFile << "<h3> jphi =  0, 1, 2, 3, 4, 5 (range 1) ............&& ............  jphi =  6, 7, 8, 9,10,11 (range 2) ............&& ............  jphi = 12,13,14,15,16,17 (range 3)</h3>"<< std::endl;
7590           htmlFile << " <img src=\"RBX-HF-2Dplot.png\" />\n";
7591           htmlFile << "<br>\n";
7592 
7593           htmlFile << "<h2> Average Amplitudes of RBX-PHI for HF: </h2>" << std::endl;
7594           htmlFile << " <img src=\"RBX-HF-1Dplot.png\" />\n";
7595           htmlFile << "<br>\n";
7596 
7597           htmlFile << "<h2> Average Amplitudes of RBX-ETA for HF: </h2>" << std::endl;
7598           htmlFile << " <img src=\"RBX-HF-11Dplot.png\" />\n";
7599           htmlFile << "<br>\n";
7600 
7601           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7602         }
7603         htmlFile << "<br>" << std::endl;
7604 
7605         ///////////////////////////////////////////////////////////////////////////////////////////////////
7606         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    10. RBXPHItable
7607 
7608         htmlFile << "<a name=\"RBXPHItable\"></a>\n";
7609         int cutA_ALL = 0;
7610         //       float cutA_HB = 100.;float cutA_HE = 1000000.;float cutA_HO = 150.;float cutA_HF = 500.;
7611         if (sub == 1) {
7612           htmlFile << "<h2> 10. Average RBX-Amplitude in Phi over LSs for HB: </h2>" << std::endl;
7613           htmlFile
7614               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7615               << cutA_HB << std::endl;
7616           cutA_ALL = cutA_HB;
7617         }
7618         if (sub == 2) {
7619           htmlFile << "<h2> 10. Average RBX-Amplitude in Phi over LSs for HE: </h2>" << std::endl;
7620           htmlFile
7621               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7622               << cutA_HE << std::endl;
7623           cutA_ALL = cutA_HE;
7624         }
7625         if (sub == 3) {
7626           htmlFile << "<h2> 10. Average RBX-Amplitude in Phi over LSs for HO: </h2>" << std::endl;
7627           htmlFile
7628               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7629               << cutA_HO << std::endl;
7630           cutA_ALL = cutA_HO;
7631         }
7632         if (sub == 4) {
7633           htmlFile << "<h2> 10. Average RBX-Amplitude in Phi over LSs for HF: </h2>" << std::endl;
7634           htmlFile
7635               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7636               << cutA_HF << std::endl;
7637           cutA_ALL = cutA_HF;
7638         }
7639 
7640         htmlFile << "<br>" << std::endl;
7641         htmlFile << "<table>" << std::endl;
7642         htmlFile << "<tr>";
7643         htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
7644         //              htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
7645         htmlFile << "<td class=\"s1\" align=\"center\">Number of events</td>" << std::endl;
7646         /////////////////////////////////////////////////////
7647 
7648         // k is jphi
7649         for (int k = 0; k < njphi; k++)
7650           htmlFile << "<td class=\"s1\" align=\"center\"> iPHI " << k << " </td>" << std::endl;
7651         htmlFile << "</tr>" << std::endl;
7652         //////////////
7653 
7654         ind = 0;
7655         // i is LS
7656         for (int i = 1; i <= MaxLum; i++) {
7657           if ((ind % 2) == 1)
7658             raw_class = "<td class=\"s2\" align=\"center\">";
7659           else
7660             raw_class = "<td class=\"s3\" align=\"center\">";
7661           htmlFile << "<tr>" << std::endl;
7662           htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
7663           //                  htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
7664           htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
7665 
7666           // k is jphi
7667           for (int k = 0; k < njphi; k++) {
7668             if (sub == 1) {
7669               if (int(alexhb[k][i - 1]) > cutA_ALL) {
7670                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(alexhb[k][i - 1]) << "</td>" << std::endl;
7671               } else {
7672                 htmlFile << raw_class << int(alexhb[k][i - 1]) << "</td>" << std::endl;
7673               }
7674             }  // HB end
7675             if (sub == 2) {
7676               if (int(alexhe[k][i - 1]) > cutA_ALL) {
7677                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(alexhe[k][i - 1]) << "</td>" << std::endl;
7678               } else {
7679                 htmlFile << raw_class << int(alexhe[k][i - 1]) << "</td>" << std::endl;
7680               }
7681             }  // HE end
7682             if (sub == 3) {
7683               if (int(alexho[k][i - 1]) > cutA_ALL) {
7684                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(alexho[k][i - 1]) << "</td>" << std::endl;
7685               } else {
7686                 htmlFile << raw_class << int(alexho[k][i - 1]) << "</td>" << std::endl;
7687               }
7688             }  // HO end
7689             if (sub == 4) {
7690               if (int(alexhf[k][i - 1]) > cutA_ALL) {
7691                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(alexhf[k][i - 1]) << "</td>" << std::endl;
7692               } else {
7693                 htmlFile << raw_class << int(alexhf[k][i - 1]) << "</td>" << std::endl;
7694               }
7695             }  // HF end
7696                ////////////////////////
7697           }    // k over PHI-RBX
7698           htmlFile << "</tr>" << std::endl;
7699           ind += 1;
7700         }  // i over LSs
7701         htmlFile << "</table>" << std::endl;
7702         htmlFile << "<br>" << std::endl;
7703         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7704         htmlFile << "<br>" << std::endl;
7705         //////////////////////////////////////////////////////////////////////////////////////////    11. RBXETAtable
7706 
7707         htmlFile << "<a name=\"RBXETAtable\"></a>\n";
7708         int cutB_ALL = 0;
7709         //       float cutB_HB = 100.;float cutB_HE = 1000000.;float cutB_HO = 150.;float cutB_HF = 500.;
7710         if (sub == 1) {
7711           htmlFile << "<h2> 11. Average RBX-Amplitude in Eta over LSs for HB: </h2>" << std::endl;
7712           htmlFile
7713               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7714               << cutB_HB << std::endl;
7715           cutB_ALL = cutB_HB;
7716         }
7717         if (sub == 2) {
7718           htmlFile << "<h2> 11. Average RBX-Amplitude in Eta over LSs for HE: </h2>" << std::endl;
7719           htmlFile
7720               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7721               << cutB_HE << std::endl;
7722           cutB_ALL = cutB_HE;
7723         }
7724         if (sub == 3) {
7725           htmlFile << "<h2> 11. Average RBX-Amplitude in Eta over LSs for HO: </h2>" << std::endl;
7726           htmlFile
7727               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7728               << cutB_HO << std::endl;
7729           cutB_ALL = cutB_HO;
7730         }
7731         if (sub == 4) {
7732           htmlFile << "<h2> 11. Average RBX-Amplitude in Eta over LSs for HF: </h2>" << std::endl;
7733           htmlFile
7734               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7735               << cutB_HF << std::endl;
7736           cutB_ALL = cutB_HF;
7737         }
7738 
7739         htmlFile << "<br>" << std::endl;
7740         htmlFile << "<table>" << std::endl;
7741         htmlFile << "<tr>";
7742         htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
7743         //              htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
7744         htmlFile << "<td class=\"s1\" align=\"center\">Number of events</td>" << std::endl;
7745         /////////////////////////////////////////////////////
7746 
7747         // k is jeta
7748         for (int k = 0; k < njeta; k++)
7749           htmlFile << "<td class=\"s1\" align=\"center\"> iETA " << k << " </td>" << std::endl;
7750         htmlFile << "</tr>" << std::endl;
7751         //////////////
7752 
7753         ind = 0;
7754         // i is LS
7755         for (int i = 1; i <= MaxLum; i++) {
7756           if ((ind % 2) == 1)
7757             raw_class = "<td class=\"s2\" align=\"center\">";
7758           else
7759             raw_class = "<td class=\"s3\" align=\"center\">";
7760           htmlFile << "<tr>" << std::endl;
7761           htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
7762           //                  htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
7763           htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
7764 
7765           // k is jeta
7766           for (int k = 0; k < njeta; k++) {
7767             if (sub == 1) {
7768               if (int(blexhb[k][i - 1]) > cutB_ALL) {
7769                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(blexhb[k][i - 1]) << "</td>" << std::endl;
7770               } else {
7771                 htmlFile << raw_class << int(blexhb[k][i - 1]) << "</td>" << std::endl;
7772               }
7773             }  // HB end
7774             if (sub == 2) {
7775               if (int(blexhe[k][i - 1]) > cutB_ALL) {
7776                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(blexhe[k][i - 1]) << "</td>" << std::endl;
7777               } else {
7778                 htmlFile << raw_class << int(blexhe[k][i - 1]) << "</td>" << std::endl;
7779               }
7780             }  // HE end
7781             if (sub == 3) {
7782               if (int(blexho[k][i - 1]) > cutB_ALL) {
7783                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(blexho[k][i - 1]) << "</td>" << std::endl;
7784               } else {
7785                 htmlFile << raw_class << int(blexho[k][i - 1]) << "</td>" << std::endl;
7786               }
7787             }  // HO end
7788             if (sub == 4) {
7789               if (int(blexhf[k][i - 1]) > cutB_ALL) {
7790                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(blexhf[k][i - 1]) << "</td>" << std::endl;
7791               } else {
7792                 htmlFile << raw_class << int(blexhf[k][i - 1]) << "</td>" << std::endl;
7793               }
7794             }  // HF end
7795                ////////////////////////
7796           }    // k over ETA-RBX
7797           htmlFile << "</tr>" << std::endl;
7798           ind += 1;
7799         }  // i over LSs
7800         htmlFile << "</table>" << std::endl;
7801         htmlFile << "<br>" << std::endl;
7802         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7803         htmlFile << "<br>" << std::endl;
7804         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7805 
7806         ///////////////////////////////////////////////////////////////////////////////////////////////////
7807         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    12. RBX3plots
7808         htmlFile << "<a name=\"RBX3plots\"></a>\n";
7809         htmlFile << "<br>\n";
7810         htmlFile << "<h2> 12. (Rij) - RBX-amplitudes normilized on reference LS (~=1st) </h2>" << std::endl;
7811         htmlFile << "<h3> ( Rji . . is ratio of . . . . A_j_i . . to . . A_j_ref . . . . for . . j-RBX . . and . . "
7812                     "i-LS . ) </h3>"
7813                  << std::endl;
7814 
7815         htmlFile << "<br>\n";
7816         htmlFile << "<h2> . . . . . . . . . . . . . . 1) . average Ri vs iLS:. . . . . . . . . . . . . . . . . . . . . "
7817                     ". . 2) . average Rj shown for Rij outside meanValue range either 0.95-1.05 or 3RMS: . . . . . . . "
7818                     ". . . . . . . . . . . . . . . . . . 3) . Rij: </h2>"
7819                  << std::endl;
7820         htmlFile << "<br>\n";
7821         if (sub == 1) {
7822           htmlFile << " <img src=\"RBX-HB-3plots.png\" />\n";
7823         }
7824         if (sub == 2) {
7825           htmlFile << " <img src=\"RBX-HE-3plots.png\" />\n";
7826         }
7827         if (sub == 3) {
7828           htmlFile << " <img src=\"RBX-HO-3plots.png\" />\n";
7829         }
7830         if (sub == 4) {
7831           htmlFile << " <img src=\"RBX-HF-3plots.png\" />\n";
7832         }
7833         htmlFile << "<br>\n";
7834 
7835         htmlFile << "<br>\n";
7836         htmlFile << "<h2> . 4). average Rj shown for Rij outside meanValue range 0.80-1.20: . . . . . . . .5) . "
7837                     "average Rj shown for Rij outside meanValue range 0.70-1.30:   . . . . . . . .6). average Rj shown "
7838                     "for Rij outside meanValue range 0.60-1.40: </h2>"
7839                  << std::endl;
7840         htmlFile << "<br>\n";
7841         if (sub == 1) {
7842           htmlFile << " <img src=\"RBX-HB-3plotsmore.png\" />\n";
7843         }
7844         if (sub == 2) {
7845           htmlFile << " <img src=\"RBX-HE-3plotsmore.png\" />\n";
7846         }
7847         if (sub == 3) {
7848           htmlFile << " <img src=\"RBX-HO-3plotsmore.png\" />\n";
7849         }
7850         if (sub == 4) {
7851           htmlFile << " <img src=\"RBX-HF-3plotsmore.png\" />\n";
7852         }
7853         htmlFile << "<br>\n";
7854 
7855         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7856 
7857         //=========================================================
7858 
7859       }  // test=1
7860 
7861       //===============================================================================
7862 
7863       htmlFile.close();
7864     }  // sub main loop
7865   }    //test main loop
7866   //===============================================================================
7867   //===============================================================================
7868   //===============================================================================
7869   //===============================================================================
7870   //===============================================================================
7871 
7872   //======================================================================
7873   // Creating tests  html pages:
7874 
7875   for (int test = 0; test <= 5; test++) {  //Test: 0,
7876     if (test == 0)
7877       htmlFile.open("CapID_GL.html");
7878     if (test == 1)
7879       htmlFile.open("ADCampl_GL.html");
7880     if (test == 2)
7881       htmlFile.open("Width_GL.html");
7882     if (test == 3)
7883       htmlFile.open("Ratio_GL.html");
7884     if (test == 4)
7885       htmlFile.open("Tmean_GL.html");
7886     if (test == 5)
7887       htmlFile.open("Tmax_GL.html");
7888 
7889     //  cout<<"Creating tests  html pages:  test=  "<< test <<     endl;
7890 
7891     htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
7892     htmlFile << "<head>" << std::endl;
7893     htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
7894     htmlFile << "<title> Certification Monitoring Tool </title>" << std::endl;
7895     htmlFile << "<style type=\"text/css\">" << std::endl;
7896     htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
7897              << std::endl;
7898     htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
7899     htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
7900                 "text-align: center;}"
7901              << std::endl;
7902     htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
7903     htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
7904     htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
7905     htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: #00FF00; }" << std::endl;
7906     htmlFile << "   td.s6 { font-family: arial, arial ce, helvetica; background-color: #FF0000; }" << std::endl;
7907     htmlFile << "</style>" << std::endl;
7908     htmlFile << "<body>" << std::endl;
7909     if (test == 0)
7910       htmlFile << "<h1> CAP ID ERRORS, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7911     if (test == 1)
7912       htmlFile << "<h1> ADC AMPLITIDE, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7913     if (test == 2)
7914       htmlFile << "<h1> WIDTH, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7915     if (test == 3)
7916       htmlFile << "<h1> RATIO, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7917     if (test == 4)
7918       htmlFile << "<h1> TIMING MEAN, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7919     if (test == 5)
7920       htmlFile << "<h1> TIMING MAX, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7921     htmlFile << "<br>" << std::endl;
7922     htmlFile << "<h2> 1.  Map of suspicious channels with this criterion for whole HCAL </h2>" << std::endl;
7923     htmlFile << "<h3> Channel legend: green - good, other colour - suspicious  </h3>" << std::endl;
7924     htmlFile << "<br>" << std::endl;
7925     if (test == 0)
7926       htmlFile << " <img src=\"MapCapIdError.png\" />" << std::endl;
7927     if (test == 1)
7928       htmlFile << " <img src=\"MapADCAmpl.png\" />" << std::endl;
7929     if (test == 2)
7930       htmlFile << " <img src=\"MapWidth.png\" />" << std::endl;
7931     if (test == 3)
7932       htmlFile << " <img src=\"MapRatio.png\" />" << std::endl;
7933     if (test == 4)
7934       htmlFile << " <img src=\"MapTmean.png\" />" << std::endl;
7935     if (test == 5)
7936       htmlFile << " <img src=\"MapTmax.png\" />" << std::endl;
7937     htmlFile << "<br>" << std::endl;
7938     htmlFile << "<h2> 2.  For whole HCAL: </h2>" << std::endl;
7939     htmlFile << "<br>" << std::endl;
7940     if (test == 0)
7941       htmlFile << " <img src=\"HistCapID.png\" />" << std::endl;
7942     if (test == 1)
7943       htmlFile << " <img src=\"HistADCAmpl.png\" />" << std::endl;
7944     if (test == 2)
7945       htmlFile << " <img src=\"HistWidth.png\" />" << std::endl;
7946     if (test == 3)
7947       htmlFile << " <img src=\"HistRatio.png\" />" << std::endl;
7948     if (test == 4)
7949       htmlFile << " <img src=\"HistTmean.png\" />" << std::endl;
7950     if (test == 5)
7951       htmlFile << " <img src=\"HistTmax.png\" />" << std::endl;
7952     htmlFile << "<br>" << std::endl;
7953     htmlFile << "<h2> 3. Status of subdetectors </h2>" << std::endl;
7954     htmlFile << "<table width=\"400\">" << std::endl;
7955     htmlFile << "<tr>" << std::endl;
7956     if (test == 0) {
7957       htmlFile << "  <td><a "
7958                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
7959                   "HcalRemoteMonitoring/CMT/GLOBAL_"
7960                << runnumber << "/HB_CapID.html\">HB</a></td>" << std::endl;
7961       htmlFile << "  <td><a "
7962                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
7963                   "HcalRemoteMonitoring/CMT/GLOBAL_"
7964                << runnumber << "/HE_CapID.html\">HE</a></td>" << std::endl;
7965       htmlFile << "  <td><a "
7966                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
7967                   "HcalRemoteMonitoring/CMT/GLOBAL_"
7968                << runnumber << "/HO_CapID.html\">HO</a></td>" << std::endl;
7969       htmlFile << "  <td><a "
7970                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
7971                   "HcalRemoteMonitoring/CMT/GLOBAL_"
7972                << runnumber << "/HF_CapID.html\">HF</a></td>" << std::endl;
7973     }
7974     if (test == 1) {
7975       // AZ 07.11.2018
7976       /*
7977       htmlFile << "  <td><a href=\"HB_ADCampl.html\">HB</a></td>"<< std::endl;
7978       htmlFile << "  <td><a href=\"HE_ADCampl.html\">HE</a></td>"<< std::endl;
7979       htmlFile << "  <td><a href=\"HO_ADCampl.html\">HO</a></td>"<< std::endl;
7980       htmlFile << "  <td><a href=\"HF_ADCampl.html\">HF</a></td>"<< std::endl;
7981 */
7982       htmlFile << "  <td><a "
7983                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
7984                   "HcalRemoteMonitoring/CMT/GLOBAL_"
7985                << runnumber << "/HB_ADCampl.html\">HB</a></td>" << std::endl;
7986       htmlFile << "  <td><a "
7987                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
7988                   "HcalRemoteMonitoring/CMT/GLOBAL_"
7989                << runnumber << "/HE_ADCampl.html\">HE</a></td>" << std::endl;
7990       htmlFile << "  <td><a "
7991                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
7992                   "HcalRemoteMonitoring/CMT/GLOBAL_"
7993                << runnumber << "/HO_ADCampl.html\">HO</a></td>" << std::endl;
7994       htmlFile << "  <td><a "
7995                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
7996                   "HcalRemoteMonitoring/CMT/GLOBAL_"
7997                << runnumber << "/HF_ADCampl.html\">HF</a></td>" << std::endl;
7998     }
7999     if (test == 2) {
8000       htmlFile << "  <td><a "
8001                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8002                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8003                << runnumber << "/HB_Width.html\">HB</a></td>" << std::endl;
8004       htmlFile << "  <td><a "
8005                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8006                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8007                << runnumber << "/HE_Width.html\">HE</a></td>" << std::endl;
8008       htmlFile << "  <td><a "
8009                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8010                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8011                << runnumber << "/HO_Width.html\">HO</a></td>" << std::endl;
8012       htmlFile << "  <td><a "
8013                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8014                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8015                << runnumber << "/HF_Width.html\">HF</a></td>" << std::endl;
8016     }
8017     if (test == 3) {
8018       htmlFile << "  <td><a "
8019                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8020                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8021                << runnumber << "/HB_Ratio.html\">HB</a></td>" << std::endl;
8022       htmlFile << "  <td><a "
8023                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8024                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8025                << runnumber << "/HE_Ratio.html\">HE</a></td>" << std::endl;
8026       htmlFile << "  <td><a "
8027                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8028                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8029                << runnumber << "/HO_Ratio.html\">HO</a></td>" << std::endl;
8030       htmlFile << "  <td><a "
8031                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8032                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8033                << runnumber << "/HF_Ratio.html\">HF</a></td>" << std::endl;
8034     }
8035     if (test == 4) {
8036       htmlFile << "  <td><a "
8037                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8038                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8039                << runnumber << "/HB_Tmean.html\">HB</a></td>" << std::endl;
8040       htmlFile << "  <td><a "
8041                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8042                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8043                << runnumber << "/HE_Tmean.html\">HE</a></td>" << std::endl;
8044       htmlFile << "  <td><a "
8045                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8046                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8047                << runnumber << "/HO_Tmean.html\">HO</a></td>" << std::endl;
8048       htmlFile << "  <td><a "
8049                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8050                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8051                << runnumber << "/HF_Tmean.html\">HF</a></td>" << std::endl;
8052     }
8053     if (test == 5) {
8054       htmlFile << "  <td><a "
8055                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8056                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8057                << runnumber << "/HB_Tmax.html\">HB</a></td>" << std::endl;
8058       htmlFile << "  <td><a "
8059                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8060                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8061                << runnumber << "/HE_Tmax.html\">HE</a></td>" << std::endl;
8062       htmlFile << "  <td><a "
8063                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8064                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8065                << runnumber << "/HO_Tmax.html\">HO</a></td>" << std::endl;
8066       htmlFile << "  <td><a "
8067                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8068                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8069                << runnumber << "/HF_Tmax.html\">HF</a></td>" << std::endl;
8070     }
8071 
8072     htmlFile << "</tr>" << std::endl;
8073     htmlFile << "</table>" << std::endl;
8074     htmlFile << "<br>" << std::endl;
8075     //  cout<<"Creating tests  html pages:  111111" <<     endl;
8076 
8077     if (test != 0)
8078       htmlFile << "<h2> 4. Table of estimator-values in sub-detectors for ONLY suspicious LSs </h3>" << std::endl;
8079     if (test == 0)
8080       htmlFile << "<h2> 4. Table of average Nbcs in sub-detectors for ONLY suspicious LSs </h3>" << std::endl;
8081     htmlFile << "<table>" << std::endl;
8082     htmlFile << "<tr>";
8083     htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
8084     //     htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
8085     htmlFile << "<td class=\"s1\" align=\"center\">Number of events</td>" << std::endl;
8086     ////////////////////////////////////////////////////////////////////////////////////////////////////
8087     for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HO, 4-HF
8088 
8089       //    cout<<"Creating each test kind for each subdet html pages:  test=  "<< test << "  sub= "  << sub <<    endl;
8090       int kkkkkkmax = k_max[sub];
8091       if ((sub == 4 || sub == 2) && test == 1)
8092         kkkkkkmax = k_maxHFupgrade[sub];
8093       //       if (test==1 && sub==4) kkkkkkmax = k_maxHFupgrade[sub];
8094       if (sub == 1) {
8095         if (test == 0)
8096           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8097             htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > HBdep " << k << " </td>" << std::endl;
8098         if (test == 1)
8099           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8100             htmlFile << "<td class=\"s1\" align=\"center\">< A > HBdepth " << k << " </td>" << std::endl;
8101         if (test == 2)
8102           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8103             htmlFile << "<td class=\"s1\" align=\"center\">< W > HBdepth " << k << " </td>" << std::endl;
8104         if (test == 3)
8105           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8106             htmlFile << "<td class=\"s1\" align=\"center\">< R > HBdepth " << k << " </td>" << std::endl;
8107         if (test == 4)
8108           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8109             htmlFile << "<td class=\"s1\" align=\"center\">< TSn > HBdep " << k << " </td>" << std::endl;
8110         if (test == 5)
8111           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8112             htmlFile << "<td class=\"s1\" align=\"center\">< TSx > HBdep " << k << " </td>" << std::endl;
8113       }  //
8114       if (sub == 2) {
8115         if (test == 0)
8116           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8117             htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > HEdep " << k << " </td>" << std::endl;
8118         if (test == 1)
8119           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8120             htmlFile << "<td class=\"s1\" align=\"center\">< A > HEdepth " << k << " </td>" << std::endl;
8121         if (test == 2)
8122           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8123             htmlFile << "<td class=\"s1\" align=\"center\">< W > HEdepth " << k << " </td>" << std::endl;
8124         if (test == 3)
8125           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8126             htmlFile << "<td class=\"s1\" align=\"center\">< R > HEdepth " << k << " </td>" << std::endl;
8127         if (test == 4)
8128           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8129             htmlFile << "<td class=\"s1\" align=\"center\">< TSn > HEdep " << k << " </td>" << std::endl;
8130         if (test == 5)
8131           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8132             htmlFile << "<td class=\"s1\" align=\"center\">< TSx > HEdep " << k << " </td>" << std::endl;
8133       }  //
8134       if (sub == 3) {
8135         if (test == 0)
8136           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8137             htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > HOdep " << k << " </td>" << std::endl;
8138         if (test == 1)
8139           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8140             htmlFile << "<td class=\"s1\" align=\"center\">< A > HOdepth " << k << " </td>" << std::endl;
8141         if (test == 2)
8142           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8143             htmlFile << "<td class=\"s1\" align=\"center\">< W > HOdepth " << k << " </td>" << std::endl;
8144         if (test == 3)
8145           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8146             htmlFile << "<td class=\"s1\" align=\"center\">< R > HOdepth " << k << " </td>" << std::endl;
8147         if (test == 4)
8148           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8149             htmlFile << "<td class=\"s1\" align=\"center\">< TSn > HOdep " << k << " </td>" << std::endl;
8150         if (test == 5)
8151           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8152             htmlFile << "<td class=\"s1\" align=\"center\">< TSx > HOdep " << k << " </td>" << std::endl;
8153       }  //
8154       if (sub == 4) {
8155         if (test == 0)
8156           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8157             htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > HFdep " << k << " </td>" << std::endl;
8158         if (test == 1)
8159           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8160             htmlFile << "<td class=\"s1\" align=\"center\">< A > HFdepth " << k << " </td>" << std::endl;
8161         if (test == 2)
8162           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8163             htmlFile << "<td class=\"s1\" align=\"center\">< W > HFdepth " << k << " </td>" << std::endl;
8164         if (test == 3)
8165           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8166             htmlFile << "<td class=\"s1\" align=\"center\">< R > HFdepth " << k << " </td>" << std::endl;
8167         if (test == 4)
8168           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8169             htmlFile << "<td class=\"s1\" align=\"center\">< TSn > HFdep " << k << " </td>" << std::endl;
8170         if (test == 5)
8171           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8172             htmlFile << "<td class=\"s1\" align=\"center\">< TSx > HFdep " << k << " </td>" << std::endl;
8173       }  //
8174     }    // sub
8175     htmlFile << "</tr>" << std::endl;
8176 
8177     //    htmlFile << "<td class=\"s1\" align=\"center\">HB Depth 1</td>"<< std::endl;
8178     //    htmlFile << "<td class=\"s1\" align=\"center\">HB Depth 2</td>"  << std::endl;
8179     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 1</td>"   << std::endl;
8180     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 2</td>"   << std::endl;
8181     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 3</td>"   << std::endl;
8182     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 4</td>"   << std::endl;
8183     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 5</td>"   << std::endl;
8184     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 6</td>"   << std::endl;
8185     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 7</td>"   << std::endl;
8186     //    htmlFile << "<td class=\"s1\" align=\"center\">HO Depth 4</td>"   << std::endl;
8187     //    htmlFile << "<td class=\"s1\" align=\"center\">HF Depth 1</td>"   << std::endl;
8188     //    htmlFile << "<td class=\"s1\" align=\"center\">HF Depth 2</td>"   << std::endl;
8189     //    htmlFile << "<td class=\"s1\" align=\"center\">HF Depth 3</td>"   << std::endl;
8190     //    htmlFile << "<td class=\"s1\" align=\"center\">HF Depth 4</td>"   << std::endl;
8191     //    htmlFile << "</tr>"   << std::endl;
8192 
8193     ind = 0;
8194     //  cout<<"Creating tests  html pages:  222222" <<     endl;
8195     for (int i = 1; i <= MaxLum; i++) {
8196       // define al least one exceed in any sub-detector
8197       int met = 0;
8198       for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
8199         int kkkkkkmax = k_max[sub];
8200         if ((sub == 4 || sub == 2) && test == 1)
8201           kkkkkkmax = k_maxHFupgrade[sub];
8202         for (int k = k_min[sub]; k <= kkkkkkmax; k++) {
8203           // line below is temporary, just to avoid contribution of HEP(M)17 in depthes 4,5,6,7 but keep in depthes 1,2,3
8204           if (sub == 2 && k > 3) {
8205           } else {
8206             if (HistNumBadChanDepth[test][sub][k]->GetBinContent(i) > Cut0[test][sub][k])
8207               met = 1;
8208           }
8209         }  //depth
8210       }    //sub
8211       // if exceed then plot the line for all sub-detectors
8212       if (met == 1) {
8213         if ((ind % 2) == 1)
8214           raw_class = "<td class=\"s2\" align=\"center\">";
8215         else
8216           raw_class = "<td class=\"s3\" align=\"center\">";
8217         htmlFile << "<tr>" << std::endl;
8218         htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
8219         //            htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
8220         htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
8221         for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
8222           int kkkkkkmax = k_max[sub];
8223           if ((sub == 4 || sub == 2) && test == 1)
8224             kkkkkkmax = k_maxHFupgrade[sub];
8225           for (int k = k_min[sub]; k <= kkkkkkmax; k++) {
8226             if (HistNumBadChanDepth[test][sub][k]->GetBinContent(i) > Cut0[test][sub][k])
8227               htmlFile << "<td class=\"s6\" align=\"center\">" << HistNumBadChanDepth[test][sub][k]->GetBinContent(i)
8228                        << "</td>" << std::endl;
8229             else
8230               htmlFile << raw_class << HistNumBadChanDepth[test][sub][k]->GetBinContent(i) << "</td>" << std::endl;
8231             //       htmlFile << "</tr>" << std::endl;
8232             /*
8233           if (HistNumBadChanDepth[test][1][1]->GetBinContent(i) > Cut0[test][1][1])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][1][1]->GetBinContent(i)<<"</td>"<< std::endl;
8234           else htmlFile <<raw_class<<HistNumBadChanDepth[test][1][1]->GetBinContent(i)<<"</td>"<< std::endl;   
8235           if (HistNumBadChanDepth[test][1][2]->GetBinContent(i) > Cut0[test][1][2])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][1][2]->GetBinContent(i)<<"</td>"<< std::endl;
8236           else htmlFile <<raw_class<<HistNumBadChanDepth[test][1][2]->GetBinContent(i)<<"</td>"<< std::endl;        
8237           if (HistNumBadChanDepth[test][2][1]->GetBinContent(i) > Cut0[test][2][1])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][2][1]->GetBinContent(i)<<"</td>"<< std::endl;
8238           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][1]->GetBinContent(i)<<"</td>"<< std::endl;        
8239           if (HistNumBadChanDepth[test][2][2]->GetBinContent(i) > Cut0[test][2][2])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][2][2]->GetBinContent(i)<<"</td>"<< std::endl;
8240           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][2]->GetBinContent(i)<<"</td>"<< std::endl;        
8241           if (HistNumBadChanDepth[test][2][3]->GetBinContent(i) > Cut0[test][2][3])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][2][3]->GetBinContent(i)<<"</td>"<< std::endl;
8242           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][3]->GetBinContent(i)<<"</td>"<< std::endl;        
8243           if (HistNumBadChanDepth[test][2][4]->GetBinContent(i) > Cut0[test][2][4])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][2][4]->GetBinContent(i)<<"</td>"<< std::endl;
8244           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][4]->GetBinContent(i)<<"</td>"<< std::endl;        
8245           if (HistNumBadChanDepth[test][2][5]->GetBinContent(i) > Cut0[test][2][5])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][2][5]->GetBinContent(i)<<"</td>"<< std::endl;
8246           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][5]->GetBinContent(i)<<"</td>"<< std::endl;        
8247           if (HistNumBadChanDepth[test][2][6]->GetBinContent(i) > Cut0[test][2][6])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][2][6]->GetBinContent(i)<<"</td>"<< std::endl;
8248           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][6]->GetBinContent(i)<<"</td>"<< std::endl;        
8249           if (HistNumBadChanDepth[test][2][7]->GetBinContent(i) > Cut0[test][2][7])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][2][7]->GetBinContent(i)<<"</td>"<< std::endl;
8250           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][7]->GetBinContent(i)<<"</td>"<< std::endl;        
8251           if (HistNumBadChanDepth[test][3][4]->GetBinContent(i) > Cut0[test][3][4])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][3][4]->GetBinContent(i)<<"</td>"<< std::endl;
8252           else htmlFile <<raw_class<<HistNumBadChanDepth[test][3][4]->GetBinContent(i)<<"</td>"<< std::endl;        
8253           if (HistNumBadChanDepth[test][4][1]->GetBinContent(i) > Cut0[test][4][1])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][4][1]->GetBinContent(i)<<"</td>"<< std::endl;
8254           else htmlFile <<raw_class<<HistNumBadChanDepth[test][4][1]->GetBinContent(i)<<"</td>"<< std::endl;      
8255           if (HistNumBadChanDepth[test][4][2]->GetBinContent(i) > Cut0[test][4][2])  htmlFile << "<td class=\"s6\" align=\"center\">"<<HistNumBadChanDepth[test][4][2]->GetBinContent(i)<<"</td>"<< std::endl;
8256           else htmlFile <<raw_class<<HistNumBadChanDepth[test][4][2]->GetBinContent(i)<<"</td>"<< std::endl;
8257         */
8258           }  //k depthes
8259         }    //sub
8260         htmlFile << "</tr>" << std::endl;
8261         ind += 1;
8262       }  // met=1
8263     }    //i bin lines
8264     //  cout<<"Creating tests  html pages:  333333" <<     endl;
8265     htmlFile << "</table>" << std::endl;
8266     htmlFile << "<br>" << std::endl;
8267     htmlFile << "</body> " << std::endl;
8268     htmlFile << "</html> " << std::endl;
8269     htmlFile.close();
8270   }  //test
8271   //======================================================================
8272   //    cout<<"for summed Amplitudes of each sub-detector" <<     endl;
8273 
8274   // for summed Amplitudes of each sub-detector
8275   htmlFile.open("SummedAmplitudes_GL.html");
8276   htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
8277   htmlFile << "<head>" << std::endl;
8278   htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
8279   htmlFile << "<title> for summed Amplitudes of each sub-detector </title>" << std::endl;
8280   htmlFile << "<style type=\"text/css\">" << std::endl;
8281   htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
8282            << std::endl;
8283   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
8284   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
8285               "text-align: center;}"
8286            << std::endl;
8287   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
8288   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
8289   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
8290   htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: #00FF00; }" << std::endl;
8291   htmlFile << "   td.s6 { font-family: arial, arial ce, helvetica; background-color: #FF0000; }" << std::endl;
8292 
8293   htmlFile << "</style>" << std::endl;
8294   htmlFile << "<body>" << std::endl;
8295   htmlFile << "<h1> Averaged Summed Amplitudes & corresponding occupancy of each sub-detector in Global Run = "
8296            << runnumber << " </h1>" << std::endl;
8297   htmlFile << "<a name=\"Top\"></a>\n";
8298   htmlFile << "<b>Contents:<br>\n";
8299   htmlFile << "1. <a href=\"#SAhigh\">average SA&Occupancy for Signal  </a><br>\n";
8300   htmlFile << "2. <a href=\"#SAlow\">average SA&Occupancy for NoSignal </a><br>\n";
8301   htmlFile << "3. <a href=\"#SAmax\"> maxSA & maxOccupancy; SA & Occupancy; </a><br>\n";
8302   htmlFile << "4. <a href=\"#FullTable\">Table(avA; avSA; avOccupancy; maxSA; maxOccupancy;) </a><br>\n";
8303 
8304   htmlFile << "<h2> Clarifying on averaged Summed Amplitude (avSA) : </h2>" << std::endl;
8305   htmlFile << "<h3> Summed Amplitudes (SA) are averaged over all events of each LS: avSA_LS = SUM (SA_eventsInLS) / "
8306               "N_eventsInLS ,</h3>"
8307            << std::endl;
8308   htmlFile << "<h3> where SA = SUM(A_i) ,and means that Amplitude is summed over all sub-detector channels, </h3>"
8309            << std::endl;
8310   htmlFile << "<h3> where A_i = SUM(A_depth) denotes channel amplitude summed over depths;  </h3>" << std::endl;
8311   //  htmlFile << "  <td><a href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/HcalRemoteMonitoring/CMT/GLOBAL_"<<runnumber<<"/HELP.html\"> Description of criteria for bad channel selection</a></td>"<< std::endl;
8312   htmlFile << "  <td><a "
8313               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8314               "HcalRemoteMonitoring/CMT/SAwriteup.html\"> see more details for SummedAmplitudes</a></td>"
8315            << std::endl;
8316   htmlFile << "<h2> Apply cuts on A_i to take into account channels with or/and without a'la Signal: </h2>"
8317            << std::endl;
8318   htmlFile << " <img src=\"ChannelDepthsummedAmplitudes.png\" />" << std::endl;
8319   htmlFile << "<br>" << std::endl;
8320   htmlFile << "<br>" << std::endl;
8321   htmlFile << "<a name=\"SAhigh\"></a>\n";
8322   htmlFile << "<h1> 1.  for channels with signal </h1>" << std::endl;
8323   htmlFile << "<br>" << std::endl;
8324   htmlFile << "<h2> for HB: A_i> 80; </h2>" << std::endl;
8325   htmlFile << " <img src=\"SummedAmplitudesSignal_HB.png\" />" << std::endl;
8326   htmlFile << "<br>" << std::endl;
8327   htmlFile << "<h2> for HE: A_i> 200;</h2>" << std::endl;
8328   htmlFile << " <img src=\"SummedAmplitudesSignal_HE.png\" />" << std::endl;
8329   htmlFile << "<br>" << std::endl;
8330   htmlFile << "<h2> for HO: A_i> 1200;</h2>" << std::endl;
8331   htmlFile << " <img src=\"SummedAmplitudesSignal_HO.png\" />" << std::endl;
8332   htmlFile << "<br>" << std::endl;
8333   htmlFile << "<h2> for HF: A_i> 600;</h2>" << std::endl;
8334   htmlFile << " <img src=\"SummedAmplitudesSignal_HF.png\" />" << std::endl;
8335   htmlFile << "<br>" << std::endl;
8336   htmlFile << "<a href=\"#Top\">to top</a><br>\n";
8337 
8338   htmlFile << "<a name=\"SAlow\"></a>\n";
8339   htmlFile << "<h1> 2.  for channels w/o signal </h1>" << std::endl;
8340   htmlFile << "<br>" << std::endl;
8341   htmlFile << "<h2> for HB: A_i< 80;</h2>" << std::endl;
8342   htmlFile << " <img src=\"NoSignalSummedAmplitudes_HB.png\" />" << std::endl;
8343   htmlFile << "<br>" << std::endl;
8344   htmlFile << "<h2> for HE:  A_i< 200;</h2>" << std::endl;
8345   htmlFile << " <img src=\"NoSignalSummedAmplitudes_HE.png\" />" << std::endl;
8346   htmlFile << "<br>" << std::endl;
8347   htmlFile << "<h2> for HO: A_i< 1200;</h2>" << std::endl;
8348   htmlFile << " <img src=\"NoSignalSummedAmplitudes_HO.png\" />" << std::endl;
8349   htmlFile << "<br>" << std::endl;
8350   htmlFile << "<h2> for HF: A_i< 600;</h2>" << std::endl;
8351   htmlFile << " <img src=\"NoSignalSummedAmplitudes_HF.png\" />" << std::endl;
8352   htmlFile << "<br>" << std::endl;
8353   htmlFile << "<a href=\"#Top\">to top</a><br>\n";
8354 
8355   htmlFile << "<br>" << std::endl;
8356   htmlFile << "<br>" << std::endl;
8357   htmlFile << "<a name=\"SAmax\"></a>\n";
8358   htmlFile << "<h1> 3. four plots: ---1--->  max SA ---2---> max Occupancy ---3--->  SA ---4---> Occupancy over all "
8359               "events of LS </h1>"
8360            << std::endl;
8361   htmlFile << "<br>" << std::endl;
8362 
8363   htmlFile << "<h2> for HB: maxSA vs LS, masOccupancy vs LS, SA, Occupancy </h2>" << std::endl;
8364   htmlFile << " <img src=\"MaxxSummedAmplitudes_HB.png\" />" << std::endl;
8365   htmlFile << "<h2>"
8366               " ......(forCut:SAmax>60000) N= "
8367            << countamplmaxHB << " ...... (forCut:OCCUPmax>2000) N= " << countoccumaxHB << " </h2>" << std::endl;
8368   htmlFile << "<h2>"
8369               " ......(forCut:SA>60000) N= "
8370            << countamplHB << " ...... (forCut:OCCUP>2000) N= " << countoccuHB << " </h2>" << std::endl;
8371   htmlFile << "<br>" << std::endl;
8372   htmlFile << "<h3> ONLY for HB (cross-check): channel Amplitudes for events in the Tail (averaged): </h3>"
8373            << std::endl;
8374   htmlFile << " <img src=\"AtaildepthHB.png\" />" << std::endl;
8375   htmlFile << "<br>" << std::endl;
8376 
8377   htmlFile << "<h2> for HE: maxSA vs LS, masOccupancy vs LS, SA, Occupancy </h2>" << std::endl;
8378   htmlFile << " <img src=\"MaxxSummedAmplitudes_HE.png\" />" << std::endl;
8379   htmlFile << "<h2>"
8380               " ......(forCut:SAmax>60000) N= "
8381            << countamplmaxHE << " ...... (forCut:OCCUPmax>1200) N= " << countoccumaxHE << " </h2>" << std::endl;
8382   htmlFile << "<h2>"
8383               " ......(forCut:SA>60000) N= "
8384            << countamplHE << " ...... (forCut:OCCUP>1200) N= " << countoccuHE << " </h2>" << std::endl;
8385   htmlFile << "<br>" << std::endl;
8386 
8387   htmlFile << "<h2> for HO: maxSA vs LS, masOccupancy vs LS, SA, Occupancy </h2>" << std::endl;
8388   htmlFile << " <img src=\"MaxxSummedAmplitudes_HO.png\" />" << std::endl;
8389   htmlFile << "<h2>"
8390               " ......(forCut:SAmax>150000) N= "
8391            << countamplmaxHO << " ...... (forCut:OCCUPmax>2000) N= " << countoccumaxHO << " </h2>" << std::endl;
8392   htmlFile << "<h2>"
8393               " ......(forCut:SA>150000) N= "
8394            << countamplHO << " ...... (forCut:OCCUP>2000) N= " << countoccuHO << " </h2>" << std::endl;
8395   htmlFile << "<br>" << std::endl;
8396 
8397   htmlFile << "<h2> for HF: maxSA vs LS, masOccupancy vs LS, SA, Occupancy </h2>" << std::endl;
8398   htmlFile << " <img src=\"MaxxSummedAmplitudes_HF.png\" />" << std::endl;
8399   htmlFile << "<h2>"
8400               " ......(forCut:SAmax>22000) N= "
8401            << countamplmaxHF << " ...... (forCut:OCCUPmax>860) N= " << countoccumaxHF << " </h2>" << std::endl;
8402   htmlFile << "<h2>"
8403               " ......(forCut:SA>22000) N= "
8404            << countamplHF << " ...... (forCut:OCCUP>860) N= " << countoccuHF << " </h2>" << std::endl;
8405   htmlFile << "<br>" << std::endl;
8406   htmlFile << "<h2> Occupancy HF (ONLY) vs LS </h2>" << std::endl;
8407   htmlFile << " <img src=\"sumOccupancyHF.png\" />" << std::endl;
8408   htmlFile << "<br>" << std::endl;
8409   htmlFile << "<a href=\"#Top\">to top</a><br>\n";
8410 
8411   htmlFile << "<a name=\"FullTable\"></a>\n";
8412   htmlFile << "<h2> 4.Lumisection Status:  </h2>" << std::endl;
8413   htmlFile << "<h3> Legends: HBdepth1 red boxes correspond LSs selected with cut: <td class=\"s6\" align=\"center\">"
8414            << Cut0[1][1][1] << std::endl;
8415   htmlFile << "<h3> Legends: HEdepth1 red boxes correspond LSs selected with cut: <td class=\"s6\" align=\"center\">"
8416            << Cut0[1][2][1] << std::endl;
8417   htmlFile << "<h3> Legends: HOdepth4 red boxes correspond LSs selected with cut: <td class=\"s6\" align=\"center\">"
8418            << Cut0[1][3][4] << std::endl;
8419   htmlFile << "<h3> Legends: HFdepth1 red boxes correspond LSs selected with cut: <td class=\"s6\" align=\"center\">"
8420            << Cut0[1][4][1] << std::endl;
8421   htmlFile << "<br>" << std::endl;
8422   // SummedAmplitudeHisto[i]   SummedAmplitudeOccupancyHisto[i]      NoSignalSummedAmplitudeHisto[i]      NoSignalSummedAmplitudeOccupancyHisto[i]; i=0-3;(HF:i=3)
8423   htmlFile << "<br>" << std::endl;
8424   htmlFile << "<table>" << std::endl;
8425   htmlFile << "<tr>";
8426   htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
8427   //              htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
8428   htmlFile << "<td class=\"s1\" align=\"center\"> Num.of ev.</td>" << std::endl;
8429 
8430   //       for (int k=k_min[sub];k<=k_max[sub]; k++) htmlFile << "<td class=\"s1\" align=\"center\">< A > Depth "<< k <<" </td>"  << std::endl;
8431   //       for (int sub=1;sub<=4;sub++) htmlFile << "<td class=\"s1\" align=\"center\">< A > Depth1, sub "<< sub <<" </td>"  << std::endl;
8432 
8433   htmlFile << "<td class=\"s1\" align=\"center\">< A >HB Depth1</td>" << std::endl;
8434   htmlFile << "<td class=\"s1\" align=\"center\">< A >HE Depth1</td>" << std::endl;
8435   htmlFile << "<td class=\"s1\" align=\"center\">< A >HO Depth4</td>" << std::endl;
8436   htmlFile << "<td class=\"s1\" align=\"center\">< A >HF Depth1</td>" << std::endl;
8437 
8438   htmlFile << "<td class=\"s1\" align=\"center\">< SA >HB (Signal) </td>" << std::endl;
8439   htmlFile << "<td class=\"s1\" align=\"center\">< Occup. > HB (Signal) </td>" << std::endl;
8440   htmlFile << "<td class=\"s1\" align=\"center\">< SA >HF (Signal) </td>" << std::endl;
8441   htmlFile << "<td class=\"s1\" align=\"center\">< Occup. > HF (Signal) </td>" << std::endl;
8442 
8443   htmlFile << "<td class=\"s1\" align=\"center\">< SA >HB (NoSignal) </td>" << std::endl;
8444   htmlFile << "<td class=\"s1\" align=\"center\">< Occup. > HB (NoSignal) </td>" << std::endl;
8445   htmlFile << "<td class=\"s1\" align=\"center\">< SA >HF (NoSignal) </td>" << std::endl;
8446   htmlFile << "<td class=\"s1\" align=\"center\">< Occup. > HF (NoSignal) </td>" << std::endl;
8447 
8448   htmlFile << "<td class=\"s1\" align=\"center\"> maxSA HB  </td>" << std::endl;
8449   htmlFile << "<td class=\"s1\" align=\"center\"> maxOccup. HB </td>" << std::endl;
8450   htmlFile << "<td class=\"s1\" align=\"center\"> maxSA HF  </td>" << std::endl;
8451   htmlFile << "<td class=\"s1\" align=\"center\"> maxOccup. HF </td>" << std::endl;
8452 
8453   htmlFile << "</tr>" << std::endl;
8454 
8455   ind = 0;
8456   for (int i = 1; i <= MaxLum; i++) {
8457     if ((ind % 2) == 1)
8458       raw_class = "<td class=\"s2\" align=\"center\">";
8459     else
8460       raw_class = "<td class=\"s3\" align=\"center\">";
8461     htmlFile << "<tr>" << std::endl;
8462 
8463     htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
8464 
8465     //                  htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
8466     htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
8467 
8468     // (test==1)  <Amplitude>
8469     int test = 1;
8470     //       for (int k=k_min[sub];k<=k_max[sub]; k++) {
8471     for (int sub = 1; sub <= 4; sub++) {
8472       for (int k = k_min[sub]; k <= k_min[sub]; k++) {
8473         if (HistNumBadChanDepth[test][sub][k]->GetBinContent(i) > Cut0[test][sub][k])
8474           htmlFile << "<td class=\"s6\" align=\"center\">" << HistNumBadChanDepth[test][sub][k]->GetBinContent(i)
8475                    << "</td>" << std::endl;
8476 
8477         else
8478           htmlFile << raw_class << HistNumBadChanDepth[test][sub][k]->GetBinContent(i) << "</td>" << std::endl;
8479       }
8480     }
8481     if (SummedAmplitudeHisto[0]) {
8482       htmlFile << raw_class << SummedAmplitudeHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8483       htmlFile << raw_class << SummedAmplitudeOccupancyHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8484       htmlFile << raw_class << SummedAmplitudeHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8485       htmlFile << raw_class << SummedAmplitudeOccupancyHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8486 
8487       htmlFile << raw_class << NoSignalSummedAmplitudeHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8488       htmlFile << raw_class << NoSignalSummedAmplitudeOccupancyHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8489       htmlFile << raw_class << NoSignalSummedAmplitudeHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8490       htmlFile << raw_class << NoSignalSummedAmplitudeOccupancyHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8491 
8492       htmlFile << raw_class << MaxxSummedAmplitudeHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8493       htmlFile << raw_class << MaxxSummedAmplitudeOccupancyHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8494       htmlFile << raw_class << MaxxSummedAmplitudeHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8495       htmlFile << raw_class << MaxxSummedAmplitudeOccupancyHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8496     }
8497     htmlFile << "</tr>" << std::endl;
8498     ind += 1;
8499   }
8500   htmlFile << "</table>" << std::endl;
8501   htmlFile << "<a href=\"#Top\">to top</a><br>\n";
8502 
8503   htmlFile << "<br>" << std::endl;
8504   htmlFile << "</body> " << std::endl;
8505   htmlFile << "</html> " << std::endl;
8506   htmlFile.close();
8507 
8508   //====================================================================== // Creating description of html-files
8509 
8510   /*    
8511     //======================================================================
8512   // Creating description HELP.html file: 
8513   htmlFile.open("HELP.html");  
8514   htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">"<< std::endl;
8515   htmlFile << "<head>"<< std::endl;
8516   htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>"<< std::endl;
8517   htmlFile << "<title> Certification Monitoring Tool </title>"<< std::endl;
8518   htmlFile << "<style type=\"text/css\">"<< std::endl;
8519   htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"<< std::endl;
8520   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }"<< std::endl;
8521   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; text-align: center;}"<< std::endl;
8522   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }"<< std::endl;
8523   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }"<< std::endl;
8524   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }"<< std::endl;
8525   htmlFile << "</style>"<< std::endl;
8526   htmlFile << "<body>"<< std::endl;
8527   htmlFile << "<h1>  Description of Remote Monitoring Tool criteria for bad channel selection</h1>"<< std::endl;
8528   htmlFile << "<br>"<< std::endl;
8529   htmlFile << "<h3> -  CAPID Errors assuming we inspect CAPID non-rotation,error & validation bits, and for this criterion - no need to apply any cuts to select bcs.</h3> "<< std::endl;
8530   htmlFile << "<br>"<< std::endl;
8531   htmlFile << "<h3> - Amplitude is full amplitude collected over all time slices </h3> "<< std::endl;
8532   htmlFile << "<h3> - Ratio criterion is where we define as a bad, the channels, for which the signal portion in 4 middle TSs(plus one, minus two around TS with maximal amplitude) is out of some range of reasonable values </h3> "<< std::endl;
8533   htmlFile << "<br>"<< std::endl;
8534   htmlFile << "<h3> - Width of shape distribution. Width is defined as square root from dispersion. </h3> "<< std::endl;
8535   htmlFile << "<br>"<< std::endl;
8536   htmlFile << "<h3> - Mean TS time slice position of adc signal. </h3> "<< std::endl;
8537   htmlFile << "<br>"<< std::endl;
8538   htmlFile << "<h3> - TS number of maximum signal </h3> "<< std::endl;
8539   htmlFile << "<br>"<< std::endl; 
8540   htmlFile << "<h3>  For more details see https://twiki.cern.ch/twiki/bin/viewauth/CMS/HcalRemoteCertificationMonitoring </h3> "<< std::endl;   
8541   htmlFile << "</body> " << std::endl;
8542   htmlFile << "</html> " << std::endl; 
8543   htmlFile.close();
8544 */
8545   //======================================================================
8546   // Creating description CMTresults.html file:
8547   htmlFile.open("CMTresults.html");
8548   htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
8549   htmlFile << "<head>" << std::endl;
8550   htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
8551   htmlFile << "<title> Certification Monitoring Tool </title>" << std::endl;
8552   htmlFile << "<style type=\"text/css\">" << std::endl;
8553   htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
8554            << std::endl;
8555   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
8556   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
8557               "text-align: center;}"
8558            << std::endl;
8559   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
8560   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
8561   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
8562   htmlFile << "</style>" << std::endl;
8563   htmlFile << "<body>" << std::endl;
8564   htmlFile << "<h1>  LS-certification (recommendation) from analysis of CMT-dependencies of THIS run </h1>"
8565            << std::endl;
8566   htmlFile << "<br>" << std::endl;
8567   htmlFile << "<br>" << std::endl;
8568   htmlFile << "<h2> - List of suspicious LSs:  </h2> " << std::endl;
8569   htmlFile << "<br>" << std::endl;
8570   htmlFile << "<h3> to be added </h3> " << std::endl;
8571   htmlFile << "<br>" << std::endl;
8572   htmlFile << "<br>" << std::endl;
8573   htmlFile << "<br>" << std::endl;
8574   htmlFile << "<h2> - Comments: </h2> " << std::endl;
8575   htmlFile << "<br>" << std::endl;
8576   htmlFile << "<h3> to be added </h3> " << std::endl;
8577   htmlFile << "<br>" << std::endl;
8578   htmlFile << "<br>" << std::endl;
8579   htmlFile << "<br>" << std::endl;
8580   htmlFile << "</body> " << std::endl;
8581   htmlFile << "</html> " << std::endl;
8582   htmlFile.close();
8583 
8584   //======================================================================
8585   // Creating main html file:
8586 
8587   htmlFile.open("LumiList.html");
8588   htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
8589   htmlFile << "<head>" << std::endl;
8590   htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
8591   htmlFile << "<title> Certification Monitoring Tool </title>" << std::endl;
8592   htmlFile << "<style type=\"text/css\">" << std::endl;
8593   htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
8594            << std::endl;
8595   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
8596   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
8597               "text-align: center;}"
8598            << std::endl;
8599   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
8600   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
8601   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
8602   htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: #00FF00; }" << std::endl;
8603   htmlFile << "   td.s6 { font-family: arial, arial ce, helvetica; background-color: #FF0000; }" << std::endl;
8604 
8605   htmlFile << "</style>" << std::endl;
8606   htmlFile << "<body>" << std::endl;
8607 
8608   htmlFile << "<h1> Certification Monitoring Tool, GLOBAL RUN = " << runnumber << ". </h1>" << std::endl;
8609   htmlFile << "<br>" << std::endl;
8610   htmlFile << "  <td><a "
8611               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8612               "HcalRemoteMonitoring/CMT/GLOBAL_"
8613            << runnumber << "/CMTresults.html\">  CMT-analysis RESULTS (for this run) </a></td>" << std::endl;
8614   htmlFile << "<br>" << std::endl;
8615   htmlFile << "<br>" << std::endl;
8616 
8617   //  htmlFile << "<h2> 1. General information </h2>"<< std::endl;
8618   htmlFile << "<h2> 1. General information     (Full number of LS = " << MaxLum << " ). </h2>" << std::endl;
8619   htmlFile << " <img src=\"LumiEvent.png\" />" << std::endl;
8620   htmlFile << "<br>" << std::endl;
8621 
8622   htmlFile << "<h2> 2. HCAL status for different criteria </h2>" << std::endl;
8623   //  htmlFile << "  <td><a href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/HcalRemoteMonitoring/CMT/GLOBAL_"<<runnumber<<"/HELP.html\"> Description of criteria for bad channel selection</a></td>"<< std::endl;
8624   htmlFile << "  <td><a "
8625               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8626               "HcalRemoteMonitoring/CMT/HELP.html\"> Description of criteria for bad channel selection</a></td>"
8627            << std::endl;
8628   htmlFile << "<br>" << std::endl;
8629   htmlFile << "<table width=\"600\">" << std::endl;
8630   htmlFile << "<tr>" << std::endl;
8631   htmlFile << "  <td><a "
8632               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8633               "HcalRemoteMonitoring/CMT/GLOBAL_"
8634            << runnumber << "/CapID_GL.html\">Cap ID errors</a></td>" << std::endl;
8635   // AZ 18.03.2018 zhokin 22.02.2019
8636   htmlFile << "  <td><a "
8637               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8638               "HcalRemoteMonitoring/CMT/GLOBAL_"
8639            << runnumber << "/ADCampl_GL.html\">Amplitude</a></td>" << std::endl;
8640   //htmlFile << "  <td><a  href=\"ADCampl_GL.html\">Amplitude</a></td>"<< std::endl;
8641   htmlFile << "  <td><a "
8642               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8643               "HcalRemoteMonitoring/CMT/GLOBAL_"
8644            << runnumber << "/Width_GL.html\">Width</a></td>" << std::endl;
8645   htmlFile << "  <td><a "
8646               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8647               "HcalRemoteMonitoring/CMT/GLOBAL_"
8648            << runnumber << "/Ratio_GL.html\">Ratio</a></td>" << std::endl;
8649   htmlFile << "  <td><a "
8650               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8651               "HcalRemoteMonitoring/CMT/GLOBAL_"
8652            << runnumber << "/Tmean_GL.html\">TS mean</a></td>" << std::endl;
8653   htmlFile << "  <td><a "
8654               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8655               "HcalRemoteMonitoring/CMT/GLOBAL_"
8656            << runnumber << "/Tmax_GL.html\">TS max</a></td>" << std::endl;
8657 
8658   htmlFile << "  <td><a "
8659               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8660               "HcalRemoteMonitoring/CMT/GLOBAL_"
8661            << runnumber << "/SummedAmplitudes_GL.html\">SummedAmplitudes</a></td>" << std::endl;
8662 
8663   htmlFile << "</tr>" << std::endl;
8664   htmlFile << "</table>" << std::endl;
8665   htmlFile << "<br>" << std::endl;
8666   htmlFile << "</body> " << std::endl;
8667   htmlFile << "</html> " << std::endl;
8668   htmlFile.close();
8669   //======================================================================
8670 
8671   //======================================================================
8672   // Close and delete all possible things:
8673   hfile->Close();
8674   //  hfile->Delete();
8675   //  Exit Root
8676   gSystem->Exit(0);
8677   //======================================================================
8678 }
8679 
8680 // ------------------------------------------------------------
8681 
8682 int copyContents(TH1F **hDest, TString hname, TString htitle, const TH1F *hSrc, int lastBin) {
8683   if (lastBin > hSrc->GetNbinsX()) {
8684     std::cout << "copyContents from " << hSrc->GetName() << ": histo has " << hSrc->GetNbinsX()
8685               << " bins, when lastBin=" << lastBin << " was requested\n";
8686     return 0;
8687   }
8688 
8689   (*hDest) = new TH1F(hname, htitle, lastBin, 0, lastBin);
8690   (*hDest)->SetDirectory(0);
8691   (*hDest)->SetStats(0);
8692 
8693   for (int ibin = 1; ibin <= lastBin; ibin++) {
8694     (*hDest)->SetBinContent(ibin, hSrc->GetBinContent(ibin));
8695     (*hDest)->SetBinError(ibin, hSrc->GetBinError(ibin));
8696   }
8697   return 1;
8698 }
8699 
8700 // ------------------------------------------------------------