Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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   std::string dirnm = "Analyzer";
0034   gROOT->Reset();
0035   gROOT->SetStyle("Plain");
0036   gStyle->SetOptStat(0);
0037   gStyle->SetOptTitle(1);
0038 
0039   if (argc < 1)
0040     return 1;
0041   char fname[300];
0042   sprintf(fname, "%s", argv[1]);
0043   std::cout << fname << std::endl;
0044 
0045   //======================================================================
0046   // Connect the input files, parameters and get the 2-d histogram in memory
0047   //    TFile *hfile= new TFile("GlobalHist.root", "READ");
0048   string promt = (string)fname;
0049   string runnumber = "";
0050   for (unsigned int i = promt.size() - 11; i < promt.size() - 5; i++)
0051     runnumber += fname[i];
0052 
0053   TFile *hfile = new TFile(fname, "READ");
0054   hfile->ls();
0055   TDirectory *dir = (TDirectory *)hfile->FindObjectAny(dirnm.c_str());
0056 
0057   // Cut [test][sub][depth]
0058   //                              Empty                         HB                           HE                                                     HO                          HF
0059   double Cut0[7][5][8] = {
0060       {{0., 0., 0., 0., 0., 0., 0., 0.},
0061        {0., 1.0, 1.0, 0., 0., 0., 0., 0.},
0062        {0., 1., 1., 1., 0., 0., 0., 0.},
0063        {0., 0., 0., 0., 1., 0., 0., 0.},
0064        {0., 1., 1., 0., 0., 0., 0., 0.}},  //CapID  0,HB,HE,HO,HF
0065       //      {{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
0066       {{0., 0., 0., 0., 0., 0., 0., 0.},
0067        {0., 3500., 3500., 3500., 3500., 0., 0., 0.},
0068        {0., 12000., 4500., 3500., 3500., 4000., 4500., 5500.},
0069        {0., 0., 0., 0., 200., 0., 0., 0.},
0070        {0., 4500., 4500., 4500., 4500., 0., 0., 0.}},  //Amplitude  0,HB,HE,HO,HF
0071       {{0., 0., 0., 0., 0., 0., 0., 0.},
0072        {0., 3., 3., 0., 0., 0., 0., 0.},
0073        {0., 3., 3., 3., 0., 0., 0., 0.},
0074        {0., 0., 0., 0., 3., 0., 0., 0.},
0075        {0., 2., 2., 0., 0., 0., 0., 0.}},  //Width  0,HB,HE,HO,HF
0076       {{0., 0., 0., 0., 0., 0., 0., 0.},
0077        {0., 0.4, 0.4, 0., 0., 0., 0., 0.},
0078        {0., 0.4, 0.4, 0.4, 0., 0., 0., 0.},
0079        {0., 0., 0., 0., 0.4, 0., 0., 0.},
0080        {0., 0.8, 0.8, 0., 0., 0., 0., 0.}},  //Ratio  0,HB,HE,HO,HF
0081       {{0., 0., 0., 0., 0., 0., 0., 0.},
0082        {0., 4.7, 4.7, 0., 0., 0., 0., 0.},
0083        {0., 4.8, 4.8, 5.0, 0., 0., 0., 0.},
0084        {0., 0., 0., 0., 4.8, 0., 0., 0.},
0085        {0., 4.0, 4.0, 0., 0., 0., 0., 0.}},  //TSn  0,HB,HE,HO,HF
0086       {{0., 0., 0., 0., 0., 0., 0., 0.},
0087        {0., 3.5, 3.5, 0., 0., 0., 0., 0.},
0088        {0., 4.0, 4.0, 4.0, 0., 0., 0., 0.},
0089        {0., 0., 0., 0., 3., 0., 0., 0.},
0090        {0., 3.5, 3.5, 0., 0., 0., 0., 0.}},  //TSx  0,HB,HE,HO,HF
0091       {{0., 0., 0., 0., 0., 0., 0., 0.},
0092        {0., 0., 0., 0., 0., 0., 0., 0.},
0093        {0., 0., 0., 0., 0., 0., 0., 0.},
0094        {0., 0., 0., 0., 0., 0., 0., 0.},
0095        {0., 0., 0., 0., 0., 0., 0., 0.}}};  //Empty
0096 
0097   double CutAb[5][8] = {{0., 0., 0., 0., 0., 0., 0., 0.},
0098                         {0., 20., 7., 0., 0., 0., 0., 0.},
0099                         {0., 16., 13., 4., 0., 0., 0., 0.},
0100                         {0., 0., 0., 0., 45., 0., 0., 0.},
0101                         {0., 10., 5., 0., 0., 0., 0., 0.}};  // cut 1 for CapIdErrors 0,HB,HE,HO,HF
0102 
0103   double CutPo[5][8] = {{0., 0., 0., 0., 0., 0., 0., 0.},
0104                         {0., 9., 3., 0., 0., 0., 0., 0.},
0105                         {0., 8., 6., 2., 0., 0., 0., 0.},
0106                         {0., 0., 0., 0., 20., 0., 0., 0.},
0107                         {0., 5., 3., 0., 0., 0., 0., 0.}};  //cut 3 for CapIdErrors (portions) 0,HB,HE,HO,HF
0108 
0109   //======================================================================
0110 
0111   // CUTs FOR IPHI RBX:
0112   int cutA_HB = 100;
0113   int cutA_HE = 6000;
0114   int cutA_HO = 150;
0115   int cutA_HF = 500;
0116   // CUTs FOR IETA RBX:
0117   int cutB_HB = 100;
0118   int cutB_HE = 10000;
0119   int cutB_HO = 150;
0120   int cutB_HF = 500;
0121 
0122   //======================================================================
0123   // Prepare histograms and plot them to .png files
0124   TCanvas *c1 = new TCanvas("c1", "Hcal4test", 200, 10, 700, 900);
0125 
0126   TCanvas *cHB = new TCanvas("cHB", "cHB", 1000, 500);
0127   TCanvas *cHE = new TCanvas("cHE", "cHE", 1500, 500);
0128   TCanvas *cONE = new TCanvas("cONE", "cONE", 500, 500);
0129   TCanvas *cFour = new TCanvas("cFour", "cFour", 1500, 1000);
0130   TCanvas *cFour1 = new TCanvas("cFour1", "cFour1", 1200, 800);
0131   TCanvas *cNine = new TCanvas("cNine", "cNine", 1500, 1500);
0132 
0133   // RBX:
0134   //  TCanvas *c4x6 = new TCanvas("c4x6","c4x6",1500,3000);
0135   TCanvas *c4x6 = new TCanvas("c4x6", "c4x6", 1200, 2400);
0136   //TCanvas *c5x6 = new TCanvas("c5x6","c5x6",2000,3000);
0137   TCanvas *c5x6 = new TCanvas("c5x6", "c5x6", 1500, 2400);
0138   //  TCanvas *cRBX1 = new TCanvas("cRBX1","cRBX1",200,10,1300,1110);
0139   TCanvas *cRBX1 = new TCanvas("cRBX1", "cRBX1", 1200, 1000);
0140   //
0141   //         TCanvas *cRBX31 = new TCanvas("cRBX31","cRBX31",1800,600);
0142   TCanvas *cRBX31 = new TCanvas("cRBX31", "cRBX31", 1860, 600);
0143   //         TCanvas *cRBX31 = new TCanvas("cRBX31","cRBX31",200,10,,1800,600);
0144 
0145   //  char *str = (char*)alloca(10000);
0146 
0147   int k_min[5] = {0, 1, 1, 4, 1};  // minimum depth for each subdet HB HE HO HF
0148 
0149   int k_max[5] = {0, 2, 3, 4, 2};  // maximum depth for each subdet HB HE HO HF
0150   //  int k_maxupgrade[5]={0,2,3,4,4}; // maximum depth for each subdet HB HE HO HF
0151   int k_maxupgrade[5] = {0, 4, 7, 4, 4};  // maximum depth for each subdet HB HE HO HF
0152 
0153   // with TfileService implementation, change everywhere below:     hfile->Get     to     dir->FindObjectAny
0154   //+++++++++++++++++++++++++++++
0155   // Lumi iLumi and number of events
0156   //+++++++++++++++++++++++++++++
0157   cHB->Divide(2, 1);
0158   cHB->cd(1);
0159   TH1F *LumLum = (TH1F *)dir->FindObjectAny("h_lsnumber_per_eachLS");
0160   int MaxLumDanila = LumLum->GetBinContent(LumLum->GetMaximumBin());  // old variant of Danila
0161   cout << " MaxLumDanila=     " << MaxLumDanila << endl;
0162   gPad->SetGridy();
0163   gPad->SetGridx();
0164   LumLum->SetMarkerStyle(10);
0165   LumLum->SetMarkerSize(0.8);
0166   LumLum->GetYaxis()->SetLabelSize(0.04);
0167   LumLum->SetTitle("Cont. number per LS  \b");
0168   LumLum->SetXTitle("Cont.number \b");
0169   LumLum->SetYTitle("Ls \b");
0170   LumLum->SetMarkerColor(4);
0171   LumLum->SetLineColor(0);
0172   LumLum->SetMinimum(0.8);
0173   LumLum->GetXaxis()->SetRangeUser(0, MaxLumDanila);
0174   LumLum->Draw("Error");
0175 
0176   cHB->cd(2);
0177   TH1F *LumiEv = (TH1F *)dir->FindObjectAny("h_nevents_per_eachRealLS");
0178   int MaxLum0 = LumiEv->GetBinContent(LumiEv->GetMaximumBin());
0179   int MaxLum = 0;
0180   for (int i = 1; i <= LumiEv->GetXaxis()->GetNbins(); i++) {
0181     if (LumiEv->GetBinContent(i)) {
0182       MaxLum = i;
0183     }
0184   }
0185   cout << " MaxLum0=     " << MaxLum0 << " MaxLum=     " << MaxLum << endl;
0186 
0187   gPad->SetGridy();
0188   gPad->SetGridx();
0189   gPad->SetLogy();
0190   //            gPad->SetLogx();
0191   LumiEv->GetYaxis()->SetLabelSize(0.04);
0192   LumiEv->SetTitle("Number of events per LS");
0193   LumiEv->SetXTitle("LS");
0194   LumiEv->SetYTitle("Number of events ");
0195   LumiEv->SetMarkerStyle(10);
0196   LumiEv->SetMarkerSize(0.8);
0197   LumiEv->SetMarkerColor(4);
0198   LumiEv->SetLineColor(0);
0199   //      LumiEv->SetMinimum(0.8);
0200   LumiEv->GetXaxis()->SetRangeUser(0, MaxLum);
0201   LumiEv->Draw("Error");
0202 
0203   cHB->Print("LumiEvent.png");
0204   cHB->Clear();
0205 
0206   //=======================================================================================================
0207   // Shape criteria: 1d histogram first definition
0208   //=======================================================================================================
0209   TH1F *H_NumBadChanDepth[7][5][5];  // 1d histogramm for test,subdet, depth
0210 
0211   //+++++++++++++++++++++++++++++
0212   // ADC Amplitude
0213   //+++++++++++++++++++++++++++++
0214 
0215   H_NumBadChanDepth[1][1][1] = (TH1F *)dir->FindObjectAny("h_sumADCAmplLS1");
0216   H_NumBadChanDepth[1][1][2] = (TH1F *)dir->FindObjectAny("h_sumADCAmplLS2");
0217 
0218   H_NumBadChanDepth[1][2][1] = (TH1F *)dir->FindObjectAny("h_sumADCAmplLS3");
0219   H_NumBadChanDepth[1][2][2] = (TH1F *)dir->FindObjectAny("h_sumADCAmplLS4");
0220   H_NumBadChanDepth[1][2][3] = (TH1F *)dir->FindObjectAny("h_sumADCAmplLS5");
0221 
0222   H_NumBadChanDepth[1][3][4] = (TH1F *)dir->FindObjectAny("h_sumADCAmplLS8");
0223 
0224   H_NumBadChanDepth[1][4][1] = (TH1F *)dir->FindObjectAny("h_sumADCAmplLS6");
0225   H_NumBadChanDepth[1][4][2] = (TH1F *)dir->FindObjectAny("h_sumADCAmplLS7");
0226 
0227   //+++++++++++++++++++++++++++++
0228   // Width
0229   //+++++++++++++++++++++++++++++
0230 
0231   H_NumBadChanDepth[2][1][1] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeLS1");
0232   H_NumBadChanDepth[2][1][2] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeLS2");
0233 
0234   H_NumBadChanDepth[2][2][1] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeLS3");
0235   H_NumBadChanDepth[2][2][2] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeLS4");
0236   H_NumBadChanDepth[2][2][3] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeLS5");
0237 
0238   H_NumBadChanDepth[2][3][4] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeLS8");
0239 
0240   H_NumBadChanDepth[2][4][1] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeLS6");
0241   H_NumBadChanDepth[2][4][2] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeLS7");
0242 
0243   //+++++++++++++++++++++++++++++
0244   // Ratio
0245   //+++++++++++++++++++++++++++++
0246 
0247   H_NumBadChanDepth[3][1][1] = (TH1F *)dir->FindObjectAny("h_sumAmplLS1");
0248   H_NumBadChanDepth[3][1][2] = (TH1F *)dir->FindObjectAny("h_sumAmplLS2");
0249 
0250   H_NumBadChanDepth[3][2][1] = (TH1F *)dir->FindObjectAny("h_sumAmplLS3");
0251   H_NumBadChanDepth[3][2][2] = (TH1F *)dir->FindObjectAny("h_sumAmplLS4");
0252   H_NumBadChanDepth[3][2][3] = (TH1F *)dir->FindObjectAny("h_sumAmplLS5");
0253 
0254   H_NumBadChanDepth[3][3][4] = (TH1F *)dir->FindObjectAny("h_sumAmplLS8");
0255 
0256   H_NumBadChanDepth[3][4][1] = (TH1F *)dir->FindObjectAny("h_sumAmplLS6");
0257   H_NumBadChanDepth[3][4][2] = (TH1F *)dir->FindObjectAny("h_sumAmplLS7");
0258 
0259   //+++++++++++++++++++++++++++++
0260   // Tmean
0261   //+++++++++++++++++++++++++++++
0262 
0263   H_NumBadChanDepth[4][1][1] = (TH1F *)dir->FindObjectAny("h_sumTSmeanALS1");
0264   H_NumBadChanDepth[4][1][2] = (TH1F *)dir->FindObjectAny("h_sumTSmeanALS2");
0265 
0266   H_NumBadChanDepth[4][2][1] = (TH1F *)dir->FindObjectAny("h_sumTSmeanALS3");
0267   H_NumBadChanDepth[4][2][2] = (TH1F *)dir->FindObjectAny("h_sumTSmeanALS4");
0268   H_NumBadChanDepth[4][2][3] = (TH1F *)dir->FindObjectAny("h_sumTSmeanALS5");
0269 
0270   H_NumBadChanDepth[4][3][4] = (TH1F *)dir->FindObjectAny("h_sumTSmeanALS8");
0271 
0272   H_NumBadChanDepth[4][4][1] = (TH1F *)dir->FindObjectAny("h_sumTSmeanALS6");
0273   H_NumBadChanDepth[4][4][2] = (TH1F *)dir->FindObjectAny("h_sumTSmeanALS7");
0274 
0275   //+++++++++++++++++++++++++++++
0276   // Tmax
0277   //+++++++++++++++++++++++++++++
0278 
0279   H_NumBadChanDepth[5][1][1] = (TH1F *)dir->FindObjectAny("h_sumTSmaxALS1");
0280   H_NumBadChanDepth[5][1][2] = (TH1F *)dir->FindObjectAny("h_sumTSmaxALS2");
0281 
0282   H_NumBadChanDepth[5][2][1] = (TH1F *)dir->FindObjectAny("h_sumTSmaxALS3");
0283   H_NumBadChanDepth[5][2][2] = (TH1F *)dir->FindObjectAny("h_sumTSmaxALS4");
0284   H_NumBadChanDepth[5][2][3] = (TH1F *)dir->FindObjectAny("h_sumTSmaxALS5");
0285 
0286   H_NumBadChanDepth[5][3][4] = (TH1F *)dir->FindObjectAny("h_sumTSmaxALS8");
0287 
0288   H_NumBadChanDepth[5][4][1] = (TH1F *)dir->FindObjectAny("h_sumTSmaxALS6");
0289   H_NumBadChanDepth[5][4][2] = (TH1F *)dir->FindObjectAny("h_sumTSmaxALS7");
0290 
0291   gStyle->SetOptStat(110000);
0292 
0293   for (int test = 1; test <= 5; test++) {  //Test: 0,
0294     for (int sub = 1; sub <= 4; sub++) {   //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
0295       if (sub == 1)
0296         cHB->Divide(2, 1);
0297       if (sub == 2)
0298         cHE->Divide(3, 1);
0299       if (sub == 3)
0300         cONE->Divide(1, 1);
0301       if (sub == 4)
0302         cHB->Divide(2, 1);
0303       for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
0304         if (sub == 1)
0305           cHB->cd(k);
0306         if (sub == 2)
0307           cHE->cd(k);
0308         if (sub == 3)
0309           cONE->cd(k - 3);
0310         if (sub == 4)
0311           cHB->cd(k);
0312         gPad->SetGridy();
0313         gPad->SetGridx();
0314         gPad->SetLogy();
0315         H_NumBadChanDepth[test][sub][k]->SetMarkerStyle(20);
0316         H_NumBadChanDepth[test][sub][k]->SetMarkerSize(0.8);
0317         if (k == 1)
0318           H_NumBadChanDepth[test][sub][k]->SetTitle("Depth 1\b");
0319         if (k == 2)
0320           H_NumBadChanDepth[test][sub][k]->SetTitle("Depth 2\b");
0321         if (k == 3)
0322           H_NumBadChanDepth[test][sub][k]->SetTitle("Depth 3\b");
0323         if (k == 4)
0324           H_NumBadChanDepth[test][sub][k]->SetTitle("Depth 4\b");
0325         if (test == 1)
0326           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <Amplitude> \b");
0327         if (test == 2)
0328           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <Width> \b");
0329         if (test == 3)
0330           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <Ratio> \b");
0331         if (test == 4)
0332           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <TS mean> \b");
0333         if (test == 5)
0334           H_NumBadChanDepth[test][sub][k]->SetXTitle(" <TS max> \b");
0335         H_NumBadChanDepth[test][sub][k]->SetYTitle("Number of channel-LSs\b");
0336         H_NumBadChanDepth[test][sub][k]->SetMarkerColor(4);
0337         H_NumBadChanDepth[test][sub][k]->SetLineColor(0);
0338         //                H_NumBadChanDepth[test][sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
0339         H_NumBadChanDepth[test][sub][k]->SetMinimum(0.8);
0340         H_NumBadChanDepth[test][sub][k]->Draw("Error");
0341       }
0342       if (test == 0) {
0343         if (sub == 1) {
0344           cHB->Print("H_NBCMNHB.png");
0345           cHB->Clear();
0346         }
0347         if (sub == 2) {
0348           cHE->Print("H_NBCMNHE.png");
0349           cHE->Clear();
0350         }
0351         if (sub == 3) {
0352           cONE->Print("H_NBCMNHO.png");
0353           cONE->Clear();
0354         }
0355         if (sub == 4) {
0356           cHB->Print("H_NBCMNHF.png");
0357           cHB->Clear();
0358         }
0359       }
0360 
0361       if (test == 1) {
0362         if (sub == 1) {
0363           cHB->Print("H_ADCamplHB.png");
0364           cHB->Clear();
0365         }
0366         if (sub == 2) {
0367           cHE->Print("H_ADCamplHE.png");
0368           cHE->Clear();
0369         }
0370         if (sub == 3) {
0371           cONE->Print("H_ADCamplHO.png");
0372           cONE->Clear();
0373         }
0374         if (sub == 4) {
0375           cHB->Print("H_ADCamplHF.png");
0376           cHB->Clear();
0377         }
0378       }
0379       if (test == 2) {
0380         if (sub == 1) {
0381           cHB->Print("H_WidthHB.png");
0382           cHB->Clear();
0383         }
0384         if (sub == 2) {
0385           cHE->Print("H_WidthHE.png");
0386           cHE->Clear();
0387         }
0388         if (sub == 3) {
0389           cONE->Print("H_WidthHO.png");
0390           cONE->Clear();
0391         }
0392         if (sub == 4) {
0393           cHB->Print("H_WidthHF.png");
0394           cHB->Clear();
0395         }
0396       }
0397       if (test == 3) {
0398         if (sub == 1) {
0399           cHB->Print("H_RatioHB.png");
0400           cHB->Clear();
0401         }
0402         if (sub == 2) {
0403           cHE->Print("H_RatioHE.png");
0404           cHE->Clear();
0405         }
0406         if (sub == 3) {
0407           cONE->Print("H_RatioHO.png");
0408           cONE->Clear();
0409         }
0410         if (sub == 4) {
0411           cHB->Print("H_RatioHF.png");
0412           cHB->Clear();
0413         }
0414       }
0415       if (test == 4) {
0416         if (sub == 1) {
0417           cHB->Print("H_TmeanHB.png");
0418           cHB->Clear();
0419         }
0420         if (sub == 2) {
0421           cHE->Print("H_TmeanHE.png");
0422           cHE->Clear();
0423         }
0424         if (sub == 3) {
0425           cONE->Print("H_TmeanHO.png");
0426           cONE->Clear();
0427         }
0428         if (sub == 4) {
0429           cHB->Print("H_TmeanHF.png");
0430           cHB->Clear();
0431         }
0432       }
0433       if (test == 5) {
0434         if (sub == 1) {
0435           cHB->Print("H_TmaxHB.png");
0436           cHB->Clear();
0437         }
0438         if (sub == 2) {
0439           cHE->Print("H_TmaxHE.png");
0440           cHE->Clear();
0441         }
0442         if (sub == 3) {
0443           cONE->Print("H_TmaxHO.png");
0444           cONE->Clear();
0445         }
0446         if (sub == 4) {
0447           cHB->Print("H_TmaxHF.png");
0448           cHB->Clear();
0449         }
0450       }
0451     }  // end sub
0452   }    //end test
0453 
0454   gStyle->SetOptStat(0);
0455   //================================================================================================================================
0456 
0457   //=======================================================================================================
0458   // 2-d histograms second definition
0459   //=========================================================
0460   TH2F *MapNumBadChanDepth[7][5][5];  // 1d Mapogramm for test,subdet, depth
0461   TH2F *MapNumChanDepth[7][5][5];     // 1d Mapogramm for test,subdet, depth
0462   TH2F *MapNumBadChanFull[7];         // 1d Mapogramm for test
0463   TH2F *MapNumChanFull[7];            // 1d Mapogramm for test
0464 
0465   //+++++++++++++++++++++++++++++
0466   // CapID
0467   //+++++++++++++++++++++++++++++
0468 
0469   MapNumBadChanDepth[0][1][1] = (TH2F *)dir->FindObjectAny("h_mapDepth1Error_HB");
0470   MapNumBadChanDepth[0][1][2] = (TH2F *)dir->FindObjectAny("h_mapDepth2Error_HB");
0471 
0472   MapNumBadChanDepth[0][2][1] = (TH2F *)dir->FindObjectAny("h_mapDepth1Error_HE");
0473   MapNumBadChanDepth[0][2][2] = (TH2F *)dir->FindObjectAny("h_mapDepth2Error_HE");
0474   MapNumBadChanDepth[0][2][3] = (TH2F *)dir->FindObjectAny("h_mapDepth3Error_HE");
0475 
0476   MapNumBadChanDepth[0][3][4] = (TH2F *)dir->FindObjectAny("h_mapDepth4Error_HO");
0477 
0478   MapNumBadChanDepth[0][4][1] = (TH2F *)dir->FindObjectAny("h_mapDepth1Error_HF");
0479   MapNumBadChanDepth[0][4][2] = (TH2F *)dir->FindObjectAny("h_mapDepth2Error_HF");
0480 
0481   MapNumBadChanFull[0] = (TH2F *)MapNumBadChanDepth[0][1][1]->Clone();
0482 
0483   MapNumChanDepth[0][1][1] = (TH2F *)dir->FindObjectAny("h_mapDepth1_HB");
0484   MapNumChanDepth[0][1][2] = (TH2F *)dir->FindObjectAny("h_mapDepth2_HB");
0485 
0486   MapNumChanDepth[0][2][1] = (TH2F *)dir->FindObjectAny("h_mapDepth1_HE");
0487   MapNumChanDepth[0][2][2] = (TH2F *)dir->FindObjectAny("h_mapDepth2_HE");
0488   MapNumChanDepth[0][2][3] = (TH2F *)dir->FindObjectAny("h_mapDepth3_HE");
0489 
0490   MapNumChanDepth[0][3][4] = (TH2F *)dir->FindObjectAny("h_mapDepth4_HO");
0491 
0492   MapNumChanDepth[0][4][1] = (TH2F *)dir->FindObjectAny("h_mapDepth1_HF");
0493   MapNumChanDepth[0][4][2] = (TH2F *)dir->FindObjectAny("h_mapDepth2_HF");
0494 
0495   MapNumChanFull[0] = (TH2F *)MapNumChanDepth[0][1][1]->Clone();
0496 
0497   //+++++++++++++++++++++++++++++
0498   // ADC Amplitude
0499   //+++++++++++++++++++++++++++++
0500 
0501   MapNumBadChanDepth[1][1][1] = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplLS1");
0502   MapNumBadChanDepth[1][1][2] = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplLS2");
0503 
0504   MapNumBadChanDepth[1][2][1] = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplLS3");
0505   MapNumBadChanDepth[1][2][2] = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplLS4");
0506   MapNumBadChanDepth[1][2][3] = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplLS5");
0507 
0508   MapNumBadChanDepth[1][3][4] = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplLS8");
0509 
0510   MapNumBadChanDepth[1][4][1] = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplLS6");
0511   MapNumBadChanDepth[1][4][2] = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplLS7");
0512 
0513   MapNumBadChanFull[1] = (TH2F *)MapNumBadChanDepth[1][1][1]->Clone();
0514 
0515   MapNumChanDepth[1][1][1] = (TH2F *)dir->FindObjectAny("h_2D0sumADCAmplLS1");
0516   MapNumChanDepth[1][1][2] = (TH2F *)dir->FindObjectAny("h_2D0sumADCAmplLS2");
0517 
0518   MapNumChanDepth[1][2][1] = (TH2F *)dir->FindObjectAny("h_2D0sumADCAmplLS3");
0519   MapNumChanDepth[1][2][2] = (TH2F *)dir->FindObjectAny("h_2D0sumADCAmplLS4");
0520   MapNumChanDepth[1][2][3] = (TH2F *)dir->FindObjectAny("h_2D0sumADCAmplLS5");
0521 
0522   MapNumChanDepth[1][3][4] = (TH2F *)dir->FindObjectAny("h_2D0sumADCAmplLS8");
0523 
0524   MapNumChanDepth[1][4][1] = (TH2F *)dir->FindObjectAny("h_2D0sumADCAmplLS6");
0525   MapNumChanDepth[1][4][2] = (TH2F *)dir->FindObjectAny("h_2D0sumADCAmplLS7");
0526 
0527   MapNumChanFull[1] = (TH2F *)MapNumChanDepth[1][1][1]->Clone();
0528 
0529   //+++++++++++++++++++++++++++++
0530   // Width
0531   //+++++++++++++++++++++++++++++
0532 
0533   MapNumBadChanDepth[2][1][1] = (TH2F *)dir->FindObjectAny("h_2DsumAmplitudeLS1");
0534   MapNumBadChanDepth[2][1][2] = (TH2F *)dir->FindObjectAny("h_2DsumAmplitudeLS2");
0535 
0536   MapNumBadChanDepth[2][2][1] = (TH2F *)dir->FindObjectAny("h_2DsumAmplitudeLS3");
0537   MapNumBadChanDepth[2][2][2] = (TH2F *)dir->FindObjectAny("h_2DsumAmplitudeLS4");
0538   MapNumBadChanDepth[2][2][3] = (TH2F *)dir->FindObjectAny("h_2DsumAmplitudeLS5");
0539 
0540   MapNumBadChanDepth[2][3][4] = (TH2F *)dir->FindObjectAny("h_2DsumAmplitudeLS8");
0541 
0542   MapNumBadChanDepth[2][4][1] = (TH2F *)dir->FindObjectAny("h_2DsumAmplitudeLS6");
0543   MapNumBadChanDepth[2][4][2] = (TH2F *)dir->FindObjectAny("h_2DsumAmplitudeLS7");
0544 
0545   MapNumBadChanFull[2] = (TH2F *)MapNumBadChanDepth[2][1][1]->Clone();
0546 
0547   MapNumChanDepth[2][1][1] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplitudeLS1");
0548   MapNumChanDepth[2][1][2] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplitudeLS2");
0549 
0550   MapNumChanDepth[2][2][1] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplitudeLS3");
0551   MapNumChanDepth[2][2][2] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplitudeLS4");
0552   MapNumChanDepth[2][2][3] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplitudeLS5");
0553 
0554   MapNumChanDepth[2][3][4] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplitudeLS8");
0555 
0556   MapNumChanDepth[2][4][1] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplitudeLS6");
0557   MapNumChanDepth[2][4][2] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplitudeLS7");
0558 
0559   MapNumChanFull[2] = (TH2F *)MapNumChanDepth[2][1][1]->Clone();
0560 
0561   //+++++++++++++++++++++++++++++
0562   // Ratio
0563   //+++++++++++++++++++++++++++++
0564 
0565   MapNumBadChanDepth[3][1][1] = (TH2F *)dir->FindObjectAny("h_2DsumAmplLS1");
0566   MapNumBadChanDepth[3][1][2] = (TH2F *)dir->FindObjectAny("h_2DsumAmplLS2");
0567 
0568   MapNumBadChanDepth[3][2][1] = (TH2F *)dir->FindObjectAny("h_2DsumAmplLS3");
0569   MapNumBadChanDepth[3][2][2] = (TH2F *)dir->FindObjectAny("h_2DsumAmplLS4");
0570   MapNumBadChanDepth[3][2][3] = (TH2F *)dir->FindObjectAny("h_2DsumAmplLS5");
0571 
0572   MapNumBadChanDepth[3][3][4] = (TH2F *)dir->FindObjectAny("h_2DsumAmplLS8");
0573 
0574   MapNumBadChanDepth[3][4][1] = (TH2F *)dir->FindObjectAny("h_2DsumAmplLS6");
0575   MapNumBadChanDepth[3][4][2] = (TH2F *)dir->FindObjectAny("h_2DsumAmplLS7");
0576 
0577   MapNumBadChanFull[3] = (TH2F *)MapNumBadChanDepth[3][1][1]->Clone();
0578 
0579   MapNumChanDepth[3][1][1] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplLS1");
0580   MapNumChanDepth[3][1][2] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplLS2");
0581 
0582   MapNumChanDepth[3][2][1] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplLS3");
0583   MapNumChanDepth[3][2][2] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplLS4");
0584   MapNumChanDepth[3][2][3] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplLS5");
0585 
0586   MapNumChanDepth[3][3][4] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplLS8");
0587 
0588   MapNumChanDepth[3][4][1] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplLS6");
0589   MapNumChanDepth[3][4][2] = (TH2F *)dir->FindObjectAny("h_2D0sumAmplLS7");
0590 
0591   MapNumChanFull[3] = (TH2F *)MapNumChanDepth[3][1][1]->Clone();
0592 
0593   //+++++++++++++++++++++++++++++
0594   // Tmean
0595   //+++++++++++++++++++++++++++++
0596 
0597   MapNumBadChanDepth[4][1][1] = (TH2F *)dir->FindObjectAny("h_2DsumTSmeanALS1");
0598   MapNumBadChanDepth[4][1][2] = (TH2F *)dir->FindObjectAny("h_2DsumTSmeanALS2");
0599 
0600   MapNumBadChanDepth[4][2][1] = (TH2F *)dir->FindObjectAny("h_2DsumTSmeanALS3");
0601   MapNumBadChanDepth[4][2][2] = (TH2F *)dir->FindObjectAny("h_2DsumTSmeanALS4");
0602   MapNumBadChanDepth[4][2][3] = (TH2F *)dir->FindObjectAny("h_2DsumTSmeanALS5");
0603 
0604   MapNumBadChanDepth[4][3][4] = (TH2F *)dir->FindObjectAny("h_2DsumTSmeanALS8");
0605 
0606   MapNumBadChanDepth[4][4][1] = (TH2F *)dir->FindObjectAny("h_2DsumTSmeanALS6");
0607   MapNumBadChanDepth[4][4][2] = (TH2F *)dir->FindObjectAny("h_2DsumTSmeanALS7");
0608 
0609   MapNumBadChanFull[4] = (TH2F *)MapNumBadChanDepth[4][1][1]->Clone();
0610 
0611   MapNumChanDepth[4][1][1] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmeanALS1");
0612   MapNumChanDepth[4][1][2] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmeanALS2");
0613 
0614   MapNumChanDepth[4][2][1] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmeanALS3");
0615   MapNumChanDepth[4][2][2] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmeanALS4");
0616   MapNumChanDepth[4][2][3] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmeanALS5");
0617 
0618   MapNumChanDepth[4][3][4] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmeanALS8");
0619 
0620   MapNumChanDepth[4][4][1] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmeanALS6");
0621   MapNumChanDepth[4][4][2] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmeanALS7");
0622 
0623   MapNumChanFull[4] = (TH2F *)MapNumChanDepth[4][1][1]->Clone();
0624 
0625   //+++++++++++++++++++++++++++++
0626   // Tmax
0627   //+++++++++++++++++++++++++++++
0628 
0629   MapNumBadChanDepth[5][1][1] = (TH2F *)dir->FindObjectAny("h_2DsumTSmaxALS1");
0630   MapNumBadChanDepth[5][1][2] = (TH2F *)dir->FindObjectAny("h_2DsumTSmaxALS2");
0631 
0632   MapNumBadChanDepth[5][2][1] = (TH2F *)dir->FindObjectAny("h_2DsumTSmaxALS3");
0633   MapNumBadChanDepth[5][2][2] = (TH2F *)dir->FindObjectAny("h_2DsumTSmaxALS4");
0634   MapNumBadChanDepth[5][2][3] = (TH2F *)dir->FindObjectAny("h_2DsumTSmaxALS5");
0635 
0636   MapNumBadChanDepth[5][3][4] = (TH2F *)dir->FindObjectAny("h_2DsumTSmaxALS8");
0637 
0638   MapNumBadChanDepth[5][4][1] = (TH2F *)dir->FindObjectAny("h_2DsumTSmaxALS6");
0639   MapNumBadChanDepth[5][4][2] = (TH2F *)dir->FindObjectAny("h_2DsumTSmaxALS7");
0640 
0641   MapNumBadChanFull[5] = (TH2F *)MapNumBadChanDepth[5][1][1]->Clone();
0642 
0643   MapNumChanDepth[5][1][1] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmaxALS1");
0644   MapNumChanDepth[5][1][2] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmaxALS2");
0645 
0646   MapNumChanDepth[5][2][1] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmaxALS3");
0647   MapNumChanDepth[5][2][2] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmaxALS4");
0648   MapNumChanDepth[5][2][3] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmaxALS5");
0649 
0650   MapNumChanDepth[5][3][4] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmaxALS8");
0651 
0652   MapNumChanDepth[5][4][1] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmaxALS6");
0653   MapNumChanDepth[5][4][2] = (TH2F *)dir->FindObjectAny("h_2D0sumTSmaxALS7");
0654 
0655   MapNumChanFull[5] = (TH2F *)MapNumChanDepth[5][1][1]->Clone();
0656 
0657   for (int test = 0; test <= 5; test++) {  //Test: 0,
0658     for (int sub = 1; sub <= 4; sub++) {   //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
0659       if (sub == 1)
0660         cHB->Divide(2, 1);
0661       if (sub == 2)
0662         cHE->Divide(3, 1);
0663       if (sub == 3)
0664         cONE->Divide(1, 1);
0665       if (sub == 4)
0666         cHB->Divide(2, 1);
0667       for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
0668         if (sub == 1)
0669           cHB->cd(k);
0670         if (sub == 2)
0671           cHE->cd(k);
0672         if (sub == 3)
0673           cONE->cd(k - 3);
0674         if (sub == 4)
0675           cHB->cd(k);
0676         MapNumBadChanDepth[test][sub][k]->Divide(
0677             MapNumBadChanDepth[test][sub][k], MapNumChanDepth[test][sub][k], 1, 1, "B");
0678 
0679         for (int x = 1; x <= MapNumBadChanFull[test]->GetXaxis()->GetNbins(); x++) {
0680           for (int y = 1; y <= MapNumBadChanFull[test]->GetYaxis()->GetNbins(); y++) {
0681             double ccc1 = MapNumBadChanDepth[test][sub][k]->GetBinContent(x, y);
0682             MapNumBadChanFull[test]->SetBinContent(x, y, MapNumBadChanFull[test]->GetBinContent(x, y) + ccc1);
0683           }  //end y
0684         }    //end x
0685 
0686         if (k == 1)
0687           MapNumBadChanDepth[test][sub][k]->SetTitle("Depth 1\b");
0688         if (k == 2)
0689           MapNumBadChanDepth[test][sub][k]->SetTitle("Depth 2\b");
0690         if (k == 3)
0691           MapNumBadChanDepth[test][sub][k]->SetTitle("Depth 3\b");
0692         if (k == 4)
0693           MapNumBadChanDepth[test][sub][k]->SetTitle("Depth 4\b");
0694         gPad->SetGridy();
0695         gPad->SetGridx();
0696         gPad->SetLogz();
0697         MapNumBadChanDepth[test][sub][k]->SetXTitle("#eta \b");
0698         MapNumBadChanDepth[test][sub][k]->SetYTitle("#phi \b");
0699         MapNumBadChanDepth[test][sub][k]->SetZTitle("Average estimator \b");
0700         MapNumBadChanDepth[test][sub][k]->SetTitleOffset(0.75, "Z");
0701         MapNumBadChanDepth[test][sub][k]->Draw("COLZ");
0702         MapNumBadChanDepth[test][sub][k]->GetYaxis()->SetRangeUser(0, 72.);
0703         //                MapNumBadChanDepth[test][sub][k]->GetZaxis()->SetRangeUser(0.0001, 1.);
0704       }
0705       if (test == 0) {
0706         if (sub == 1) {
0707           cHB->Print("MapCapIdErrorHB.png");
0708           cHB->Clear();
0709         }
0710         if (sub == 2) {
0711           cHE->Print("MapCapIdErrorHE.png");
0712           cHE->Clear();
0713         }
0714         if (sub == 3) {
0715           cONE->Print("MapCapIdErrorHO.png");
0716           cONE->Clear();
0717         }
0718         if (sub == 4) {
0719           cHB->Print("MapCapIdErrorHF.png");
0720           cHB->Clear();
0721         }
0722       }
0723       if (test == 1) {
0724         if (sub == 1) {
0725           cHB->Print("MapADCamplHB.png");
0726           cHB->Clear();
0727         }
0728         if (sub == 2) {
0729           cHE->Print("MapADCamplHE.png");
0730           cHE->Clear();
0731         }
0732         if (sub == 3) {
0733           cONE->Print("MapADCamplHO.png");
0734           cONE->Clear();
0735         }
0736         if (sub == 4) {
0737           cHB->Print("MapADCamplHF.png");
0738           cHB->Clear();
0739         }
0740       }
0741       if (test == 2) {
0742         if (sub == 1) {
0743           cHB->Print("MapWidthHB.png");
0744           cHB->Clear();
0745         }
0746         if (sub == 2) {
0747           cHE->Print("MapWidthHE.png");
0748           cHE->Clear();
0749         }
0750         if (sub == 3) {
0751           cONE->Print("MapWidthHO.png");
0752           cONE->Clear();
0753         }
0754         if (sub == 4) {
0755           cHB->Print("MapWidthHF.png");
0756           cHB->Clear();
0757         }
0758       }
0759       if (test == 3) {
0760         if (sub == 1) {
0761           cHB->Print("MapRatioHB.png");
0762           cHB->Clear();
0763         }
0764         if (sub == 2) {
0765           cHE->Print("MapRatioHE.png");
0766           cHE->Clear();
0767         }
0768         if (sub == 3) {
0769           cONE->Print("MapRatioHO.png");
0770           cONE->Clear();
0771         }
0772         if (sub == 4) {
0773           cHB->Print("MapRatioHF.png");
0774           cHB->Clear();
0775         }
0776       }
0777       if (test == 4) {
0778         if (sub == 1) {
0779           cHB->Print("MapTmeanHB.png");
0780           cHB->Clear();
0781         }
0782         if (sub == 2) {
0783           cHE->Print("MapTmeanHE.png");
0784           cHE->Clear();
0785         }
0786         if (sub == 3) {
0787           cONE->Print("MapTmeanHO.png");
0788           cONE->Clear();
0789         }
0790         if (sub == 4) {
0791           cHB->Print("MapTmeanHF.png");
0792           cHB->Clear();
0793         }
0794       }
0795       if (test == 5) {
0796         if (sub == 1) {
0797           cHB->Print("MapTmaxHB.png");
0798           cHB->Clear();
0799         }
0800         if (sub == 2) {
0801           cHE->Print("MapTmaxHE.png");
0802           cHE->Clear();
0803         }
0804         if (sub == 3) {
0805           cONE->Print("MapTmaxHO.png");
0806           cONE->Clear();
0807         }
0808         if (sub == 4) {
0809           cHB->Print("MapTmaxHF.png");
0810           cHB->Clear();
0811         }
0812       }
0813     }  // end sub
0814     cONE->Divide(1, 1);
0815     cONE->cd(1);
0816     gPad->SetGridy();
0817     gPad->SetGridx();
0818     gPad->SetLogz();
0819     MapNumBadChanFull[test]->SetTitle("All subdetectors\b");
0820     MapNumBadChanFull[test]->SetXTitle("#eta \b");
0821     MapNumBadChanFull[test]->SetYTitle("#phi \b");
0822     if (test == 0)
0823       MapNumBadChanFull[test]->SetZTitle("Average Nbcs \b");
0824     if (test != 0)
0825       MapNumBadChanFull[test]->SetZTitle("Average estimator \b");
0826     //   MapNumBadChanFull[test]->GetZaxis()->SetLabelSize(0.008);
0827     MapNumBadChanFull[test]->SetTitleOffset(0.75, "Z");
0828     MapNumBadChanFull[test]->Draw("COLZ");
0829     MapNumBadChanFull[test]->GetYaxis()->SetRangeUser(0, 72.);
0830     //         MapNumBadChanFull[test]->GetZaxis()->SetRangeUser(0.0001, 1.);
0831     if (test == 0) {
0832       cONE->Print("MapCapIdError.png");
0833       cONE->Clear();
0834     }
0835     if (test == 1) {
0836       cONE->Print("MapADCAmpl.png");
0837       cONE->Clear();
0838     }
0839     if (test == 2) {
0840       cONE->Print("MapWidth.png");
0841       cONE->Clear();
0842     }
0843     if (test == 3) {
0844       cONE->Print("MapRatio.png");
0845       cONE->Clear();
0846     }
0847     if (test == 4) {
0848       cONE->Print("MapTmean.png");
0849       cONE->Clear();
0850     }
0851     if (test == 5) {
0852       cONE->Print("MapTmax.png");
0853       cONE->Clear();
0854     }
0855   }  //end test
0856 
0857   //================================================================================================================================
0858 
0859   //=======================================================================================================
0860   // 1-d histograms third definition
0861 
0862   TH1F *HistNumBadChanDepth[7][5][8];     // 1d histogramm for test,subdet, depth
0863   TH1F *HistCutNumBadChanDepth[7][5][8];  // 1d histogramm for test,subdet, depth
0864   TH1F *HistNumChanDepth[7][5][8];        // 1d histogramm for test,subdet, depth
0865 
0866   //      TH1F *HistNumBadChanDepth[7][5][5];    // 1d histogramm for test,subdet, depth
0867   //      TH1F *HistCutNumBadChanDepth[7][5][5];    // 1d histogramm for test,subdet, depth
0868   //      TH1F *HistNumChanDepth[7][5][5];    // 1d histogramm for test,subdet, depth
0869 
0870   TH1F *HistNumBadChanFull[7];  // 1d histogramm for test
0871   TH1F *HistNumChanFull[7];     // 1d histogramm for test
0872 
0873   //+++++++++++++++++++++++++++++
0874   // Rate of Cap ID errors
0875   //+++++++++++++++++++++++++++++
0876 
0877   HistNumBadChanDepth[0][1][1] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth1_HB");
0878   HistNumBadChanDepth[0][1][2] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth2_HB");
0879 
0880   HistNumBadChanDepth[0][2][1] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth1_HE");
0881   HistNumBadChanDepth[0][2][2] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth2_HE");
0882   HistNumBadChanDepth[0][2][3] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth3_HE");
0883 
0884   HistNumBadChanDepth[0][3][4] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth4_HO");
0885 
0886   HistNumBadChanDepth[0][4][1] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth1_HF");
0887   HistNumBadChanDepth[0][4][2] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth2_HF");
0888 
0889   HistNumBadChanFull[0] = (TH1F *)HistNumBadChanDepth[0][1][1]->Clone();
0890 
0891   HistCutNumBadChanDepth[0][1][1] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth1_HB");
0892   HistCutNumBadChanDepth[0][1][2] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth2_HB");
0893 
0894   HistCutNumBadChanDepth[0][2][1] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth1_HE");
0895   HistCutNumBadChanDepth[0][2][2] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth2_HE");
0896   HistCutNumBadChanDepth[0][2][3] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth3_HE");
0897 
0898   HistCutNumBadChanDepth[0][3][4] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth4_HO");
0899 
0900   HistCutNumBadChanDepth[0][4][1] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth1_HF");
0901   HistCutNumBadChanDepth[0][4][2] = (TH1F *)dir->FindObjectAny("h_runnbadchannels_depth2_HF");
0902 
0903   HistNumChanDepth[0][1][1] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth1_HB");
0904   HistNumChanDepth[0][1][2] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth2_HB");
0905 
0906   HistNumChanDepth[0][2][1] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth1_HE");
0907   HistNumChanDepth[0][2][2] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth2_HE");
0908   HistNumChanDepth[0][2][3] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth3_HE");
0909 
0910   HistNumChanDepth[0][3][4] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth4_HO");
0911 
0912   HistNumChanDepth[0][4][1] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth1_HF");
0913   HistNumChanDepth[0][4][2] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth2_HF");
0914 
0915   HistNumChanFull[0] = (TH1F *)HistNumChanDepth[0][1][1]->Clone();
0916 
0917   //+++++++++++++++++++++++++++++
0918   // ADC Amplitude
0919   //+++++++++++++++++++++++++++++
0920 
0921   //////////////////////
0922   // HB:
0923   HistNumBadChanDepth[1][1][1] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS1");
0924   HistNumBadChanDepth[1][1][2] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS2");
0925   // HB upgrade:
0926   HistNumBadChanDepth[1][1][3] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLSdepth3HBu");
0927   HistNumBadChanDepth[1][1][4] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLSdepth4HBu");
0928 
0929   // HE:
0930   HistNumBadChanDepth[1][2][1] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS3");
0931   HistNumBadChanDepth[1][2][2] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS4");
0932   HistNumBadChanDepth[1][2][3] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS5");
0933   // HE upgrade:
0934   HistNumBadChanDepth[1][2][4] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLSdepth4HEu");
0935   HistNumBadChanDepth[1][2][5] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLSdepth5HEu");
0936   HistNumBadChanDepth[1][2][6] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLSdepth6HEu");
0937   HistNumBadChanDepth[1][2][7] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLSdepth7HEu");
0938 
0939   // HO:
0940   HistNumBadChanDepth[1][3][4] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS8");
0941 
0942   // HF:
0943   HistNumBadChanDepth[1][4][1] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS6");
0944   HistNumBadChanDepth[1][4][2] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS7");
0945   // HF upgrade:
0946   HistNumBadChanDepth[1][4][3] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS6u");
0947   HistNumBadChanDepth[1][4][4] = (TH1F *)dir->FindObjectAny("h_sumADCAmplperLS7u");
0948 
0949   // other cases:
0950   HistNumBadChanFull[1] = (TH1F *)HistNumBadChanDepth[1][1][1]->Clone();
0951 
0952   //////////////////////
0953   // HB:
0954   HistCutNumBadChanDepth[1][1][1] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS1");
0955   HistCutNumBadChanDepth[1][1][2] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS2");
0956   // HB upgrade:
0957   HistCutNumBadChanDepth[1][1][3] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLSdepth3HBu");
0958   HistCutNumBadChanDepth[1][1][4] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLSdepth4HBu");
0959 
0960   // HE:
0961   HistCutNumBadChanDepth[1][2][1] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS3");
0962   HistCutNumBadChanDepth[1][2][2] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS4");
0963   HistCutNumBadChanDepth[1][2][3] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS5");
0964   // HE upgrade:
0965   HistCutNumBadChanDepth[1][2][4] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLSdepth4HEu");
0966   HistCutNumBadChanDepth[1][2][5] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLSdepth5HEu");
0967   HistCutNumBadChanDepth[1][2][6] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLSdepth6HEu");
0968   HistCutNumBadChanDepth[1][2][7] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLSdepth7HEu");
0969 
0970   // HO:
0971   HistCutNumBadChanDepth[1][3][4] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS8");
0972 
0973   // HF:
0974   HistCutNumBadChanDepth[1][4][1] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS6");
0975   HistCutNumBadChanDepth[1][4][2] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS7");
0976   // HF upgrade:
0977   HistCutNumBadChanDepth[1][4][3] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS6u");
0978   HistCutNumBadChanDepth[1][4][4] = (TH1F *)dir->FindObjectAny("h_sumCutADCAmplperLS7u");
0979 
0980   //////////////////////
0981   // HB:
0982   HistNumChanDepth[1][1][1] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS1");
0983   HistNumChanDepth[1][1][2] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS2");
0984   // HB upgrade:
0985   HistNumChanDepth[1][1][3] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLSdepth3HBu");
0986   HistNumChanDepth[1][1][4] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLSdepth4HBu");
0987 
0988   // HE:
0989   HistNumChanDepth[1][2][1] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS3");
0990   HistNumChanDepth[1][2][2] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS4");
0991   HistNumChanDepth[1][2][3] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS5");
0992   // HE upgrade:
0993   HistNumChanDepth[1][2][4] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLSdepth4HEu");
0994   HistNumChanDepth[1][2][5] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLSdepth5HEu");
0995   HistNumChanDepth[1][2][6] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLSdepth6HEu");
0996   HistNumChanDepth[1][2][7] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLSdepth7HEu");
0997 
0998   // HO:
0999   HistNumChanDepth[1][3][4] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS8");
1000 
1001   // HF:
1002   HistNumChanDepth[1][4][1] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS6");
1003   HistNumChanDepth[1][4][2] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS7");
1004   // HF upgrade:
1005   HistNumChanDepth[1][4][3] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS6u");
1006   HistNumChanDepth[1][4][4] = (TH1F *)dir->FindObjectAny("h_sum0ADCAmplperLS7u");
1007 
1008   // other cases:
1009   HistNumChanFull[1] = (TH1F *)HistNumChanDepth[1][1][1]->Clone();
1010   // just initialization of [6] massive for alternative <A> calculation
1011   HistNumChanFull[6] = (TH1F *)HistNumChanDepth[1][1][1]->Clone();
1012 
1013   //+++++++++++++++++++++++++++++
1014   // Width
1015   //+++++++++++++++++++++++++++++
1016 
1017   HistNumBadChanDepth[2][1][1] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeperLS1");
1018   HistNumBadChanDepth[2][1][2] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeperLS2");
1019 
1020   HistNumBadChanDepth[2][2][1] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeperLS3");
1021   HistNumBadChanDepth[2][2][2] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeperLS4");
1022   HistNumBadChanDepth[2][2][3] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeperLS5");
1023 
1024   HistNumBadChanDepth[2][3][4] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeperLS8");
1025 
1026   HistNumBadChanDepth[2][4][1] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeperLS6");
1027   HistNumBadChanDepth[2][4][2] = (TH1F *)dir->FindObjectAny("h_sumAmplitudeperLS7");
1028 
1029   HistNumBadChanFull[2] = (TH1F *)HistNumBadChanDepth[2][1][1]->Clone();
1030 
1031   HistCutNumBadChanDepth[2][1][1] = (TH1F *)dir->FindObjectAny("h_sumCutAmplitudeperLS1");
1032   HistCutNumBadChanDepth[2][1][2] = (TH1F *)dir->FindObjectAny("h_sumCutAmplitudeperLS2");
1033 
1034   HistCutNumBadChanDepth[2][2][1] = (TH1F *)dir->FindObjectAny("h_sumCutAmplitudeperLS3");
1035   HistCutNumBadChanDepth[2][2][2] = (TH1F *)dir->FindObjectAny("h_sumCutAmplitudeperLS4");
1036   HistCutNumBadChanDepth[2][2][3] = (TH1F *)dir->FindObjectAny("h_sumCutAmplitudeperLS5");
1037 
1038   HistCutNumBadChanDepth[2][3][4] = (TH1F *)dir->FindObjectAny("h_sumCutAmplitudeperLS8");
1039 
1040   HistCutNumBadChanDepth[2][4][1] = (TH1F *)dir->FindObjectAny("h_sumCutAmplitudeperLS6");
1041   HistCutNumBadChanDepth[2][4][2] = (TH1F *)dir->FindObjectAny("h_sumCutAmplitudeperLS7");
1042 
1043   HistNumChanDepth[2][1][1] = (TH1F *)dir->FindObjectAny("h_sum0AmplitudeperLS1");
1044   HistNumChanDepth[2][1][2] = (TH1F *)dir->FindObjectAny("h_sum0AmplitudeperLS2");
1045 
1046   HistNumChanDepth[2][2][1] = (TH1F *)dir->FindObjectAny("h_sum0AmplitudeperLS3");
1047   HistNumChanDepth[2][2][2] = (TH1F *)dir->FindObjectAny("h_sum0AmplitudeperLS4");
1048   HistNumChanDepth[2][2][3] = (TH1F *)dir->FindObjectAny("h_sum0AmplitudeperLS5");
1049 
1050   HistNumChanDepth[2][3][4] = (TH1F *)dir->FindObjectAny("h_sum0AmplitudeperLS8");
1051 
1052   HistNumChanDepth[2][4][1] = (TH1F *)dir->FindObjectAny("h_sum0AmplitudeperLS6");
1053   HistNumChanDepth[2][4][2] = (TH1F *)dir->FindObjectAny("h_sum0AmplitudeperLS7");
1054 
1055   HistNumChanFull[2] = (TH1F *)HistNumChanDepth[2][1][1]->Clone();
1056   //+++++++++++++++++++++++++++++
1057   // Ratio
1058   //+++++++++++++++++++++++++++++
1059 
1060   HistNumBadChanDepth[3][1][1] = (TH1F *)dir->FindObjectAny("h_sumAmplperLS1");
1061   HistNumBadChanDepth[3][1][2] = (TH1F *)dir->FindObjectAny("h_sumAmplperLS2");
1062 
1063   HistNumBadChanDepth[3][2][1] = (TH1F *)dir->FindObjectAny("h_sumAmplperLS3");
1064   HistNumBadChanDepth[3][2][2] = (TH1F *)dir->FindObjectAny("h_sumAmplperLS4");
1065   HistNumBadChanDepth[3][2][3] = (TH1F *)dir->FindObjectAny("h_sumAmplperLS5");
1066 
1067   HistNumBadChanDepth[3][3][4] = (TH1F *)dir->FindObjectAny("h_sumAmplperLS8");
1068 
1069   HistNumBadChanDepth[3][4][1] = (TH1F *)dir->FindObjectAny("h_sumAmplperLS6");
1070   HistNumBadChanDepth[3][4][2] = (TH1F *)dir->FindObjectAny("h_sumAmplperLS7");
1071 
1072   HistNumBadChanFull[3] = (TH1F *)HistNumBadChanDepth[3][1][1]->Clone();
1073 
1074   HistCutNumBadChanDepth[3][1][1] = (TH1F *)dir->FindObjectAny("h_sumCutAmplperLS1");
1075   HistCutNumBadChanDepth[3][1][2] = (TH1F *)dir->FindObjectAny("h_sumCutAmplperLS2");
1076 
1077   HistCutNumBadChanDepth[3][2][1] = (TH1F *)dir->FindObjectAny("h_sumCutAmplperLS3");
1078   HistCutNumBadChanDepth[3][2][2] = (TH1F *)dir->FindObjectAny("h_sumCutAmplperLS4");
1079   HistCutNumBadChanDepth[3][2][3] = (TH1F *)dir->FindObjectAny("h_sumCutAmplperLS5");
1080 
1081   HistCutNumBadChanDepth[3][3][4] = (TH1F *)dir->FindObjectAny("h_sumCutAmplperLS8");
1082 
1083   HistCutNumBadChanDepth[3][4][1] = (TH1F *)dir->FindObjectAny("h_sumCutAmplperLS6");
1084   HistCutNumBadChanDepth[3][4][2] = (TH1F *)dir->FindObjectAny("h_sumCutAmplperLS7");
1085 
1086   HistNumChanDepth[3][1][1] = (TH1F *)dir->FindObjectAny("h_sum0AmplperLS1");
1087   HistNumChanDepth[3][1][2] = (TH1F *)dir->FindObjectAny("h_sum0AmplperLS2");
1088 
1089   HistNumChanDepth[3][2][1] = (TH1F *)dir->FindObjectAny("h_sum0AmplperLS3");
1090   HistNumChanDepth[3][2][2] = (TH1F *)dir->FindObjectAny("h_sum0AmplperLS4");
1091   HistNumChanDepth[3][2][3] = (TH1F *)dir->FindObjectAny("h_sum0AmplperLS5");
1092 
1093   HistNumChanDepth[3][3][4] = (TH1F *)dir->FindObjectAny("h_sum0AmplperLS8");
1094 
1095   HistNumChanDepth[3][4][1] = (TH1F *)dir->FindObjectAny("h_sum0AmplperLS6");
1096   HistNumChanDepth[3][4][2] = (TH1F *)dir->FindObjectAny("h_sum0AmplperLS7");
1097 
1098   HistNumChanFull[3] = (TH1F *)HistNumChanDepth[3][1][1]->Clone();
1099   //+++++++++++++++++++++++++++++
1100   // Tmean
1101   //+++++++++++++++++++++++++++++
1102 
1103   HistNumBadChanDepth[4][1][1] = (TH1F *)dir->FindObjectAny("h_sumTSmeanAperLS1");
1104   HistNumBadChanDepth[4][1][2] = (TH1F *)dir->FindObjectAny("h_sumTSmeanAperLS2");
1105 
1106   HistNumBadChanDepth[4][2][1] = (TH1F *)dir->FindObjectAny("h_sumTSmeanAperLS3");
1107   HistNumBadChanDepth[4][2][2] = (TH1F *)dir->FindObjectAny("h_sumTSmeanAperLS4");
1108   HistNumBadChanDepth[4][2][3] = (TH1F *)dir->FindObjectAny("h_sumTSmeanAperLS5");
1109 
1110   HistNumBadChanDepth[4][3][4] = (TH1F *)dir->FindObjectAny("h_sumTSmeanAperLS8");
1111 
1112   HistNumBadChanDepth[4][4][1] = (TH1F *)dir->FindObjectAny("h_sumTSmeanAperLS6");
1113   HistNumBadChanDepth[4][4][2] = (TH1F *)dir->FindObjectAny("h_sumTSmeanAperLS7");
1114 
1115   HistNumBadChanFull[4] = (TH1F *)HistNumBadChanDepth[4][1][1]->Clone();
1116 
1117   HistCutNumBadChanDepth[4][1][1] = (TH1F *)dir->FindObjectAny("h_sumCutTSmeanAperLS1");
1118   HistCutNumBadChanDepth[4][1][2] = (TH1F *)dir->FindObjectAny("h_sumCutTSmeanAperLS2");
1119 
1120   HistCutNumBadChanDepth[4][2][1] = (TH1F *)dir->FindObjectAny("h_sumCutTSmeanAperLS3");
1121   HistCutNumBadChanDepth[4][2][2] = (TH1F *)dir->FindObjectAny("h_sumCutTSmeanAperLS4");
1122   HistCutNumBadChanDepth[4][2][3] = (TH1F *)dir->FindObjectAny("h_sumCutTSmeanAperLS5");
1123 
1124   HistCutNumBadChanDepth[4][3][4] = (TH1F *)dir->FindObjectAny("h_sumCutTSmeanAperLS8");
1125 
1126   HistCutNumBadChanDepth[4][4][1] = (TH1F *)dir->FindObjectAny("h_sumCutTSmeanAperLS6");
1127   HistCutNumBadChanDepth[4][4][2] = (TH1F *)dir->FindObjectAny("h_sumCutTSmeanAperLS7");
1128 
1129   HistNumChanDepth[4][1][1] = (TH1F *)dir->FindObjectAny("h_sum0TSmeanAperLS1");
1130   HistNumChanDepth[4][1][2] = (TH1F *)dir->FindObjectAny("h_sum0TSmeanAperLS2");
1131 
1132   HistNumChanDepth[4][2][1] = (TH1F *)dir->FindObjectAny("h_sum0TSmeanAperLS3");
1133   HistNumChanDepth[4][2][2] = (TH1F *)dir->FindObjectAny("h_sum0TSmeanAperLS4");
1134   HistNumChanDepth[4][2][3] = (TH1F *)dir->FindObjectAny("h_sum0TSmeanAperLS5");
1135 
1136   HistNumChanDepth[4][3][4] = (TH1F *)dir->FindObjectAny("h_sum0TSmeanAperLS8");
1137 
1138   HistNumChanDepth[4][4][1] = (TH1F *)dir->FindObjectAny("h_sum0TSmeanAperLS6");
1139   HistNumChanDepth[4][4][2] = (TH1F *)dir->FindObjectAny("h_sum0TSmeanAperLS7");
1140 
1141   HistNumChanFull[4] = (TH1F *)HistNumChanDepth[4][1][1]->Clone();
1142   //+++++++++++++++++++++++++++++
1143   // Tmax
1144   //+++++++++++++++++++++++++++++
1145 
1146   HistNumBadChanDepth[5][1][1] = (TH1F *)dir->FindObjectAny("h_sumTSmaxAperLS1");
1147   HistNumBadChanDepth[5][1][2] = (TH1F *)dir->FindObjectAny("h_sumTSmaxAperLS2");
1148 
1149   HistNumBadChanDepth[5][2][1] = (TH1F *)dir->FindObjectAny("h_sumTSmaxAperLS3");
1150   HistNumBadChanDepth[5][2][2] = (TH1F *)dir->FindObjectAny("h_sumTSmaxAperLS4");
1151   HistNumBadChanDepth[5][2][3] = (TH1F *)dir->FindObjectAny("h_sumTSmaxAperLS5");
1152 
1153   HistNumBadChanDepth[5][3][4] = (TH1F *)dir->FindObjectAny("h_sumTSmaxAperLS8");
1154 
1155   HistNumBadChanDepth[5][4][1] = (TH1F *)dir->FindObjectAny("h_sumTSmaxAperLS6");
1156   HistNumBadChanDepth[5][4][2] = (TH1F *)dir->FindObjectAny("h_sumTSmaxAperLS7");
1157 
1158   HistNumBadChanFull[5] = (TH1F *)HistNumBadChanDepth[5][1][1]->Clone();
1159 
1160   HistCutNumBadChanDepth[5][1][1] = (TH1F *)dir->FindObjectAny("h_sumCutTSmaxAperLS1");
1161   HistCutNumBadChanDepth[5][1][2] = (TH1F *)dir->FindObjectAny("h_sumCutTSmaxAperLS2");
1162 
1163   HistCutNumBadChanDepth[5][2][1] = (TH1F *)dir->FindObjectAny("h_sumCutTSmaxAperLS3");
1164   HistCutNumBadChanDepth[5][2][2] = (TH1F *)dir->FindObjectAny("h_sumCutTSmaxAperLS4");
1165   HistCutNumBadChanDepth[5][2][3] = (TH1F *)dir->FindObjectAny("h_sumCutTSmaxAperLS5");
1166 
1167   HistCutNumBadChanDepth[5][3][4] = (TH1F *)dir->FindObjectAny("h_sumCutTSmaxAperLS8");
1168 
1169   HistCutNumBadChanDepth[5][4][1] = (TH1F *)dir->FindObjectAny("h_sumCutTSmaxAperLS6");
1170   HistCutNumBadChanDepth[5][4][2] = (TH1F *)dir->FindObjectAny("h_sumCutTSmaxAperLS7");
1171 
1172   HistNumChanDepth[5][1][1] = (TH1F *)dir->FindObjectAny("h_sum0TSmaxAperLS1");
1173   HistNumChanDepth[5][1][2] = (TH1F *)dir->FindObjectAny("h_sum0TSmaxAperLS2");
1174 
1175   HistNumChanDepth[5][2][1] = (TH1F *)dir->FindObjectAny("h_sum0TSmaxAperLS3");
1176   HistNumChanDepth[5][2][2] = (TH1F *)dir->FindObjectAny("h_sum0TSmaxAperLS4");
1177   HistNumChanDepth[5][2][3] = (TH1F *)dir->FindObjectAny("h_sum0TSmaxAperLS5");
1178 
1179   HistNumChanDepth[5][3][4] = (TH1F *)dir->FindObjectAny("h_sum0TSmaxAperLS8");
1180 
1181   HistNumChanDepth[5][4][1] = (TH1F *)dir->FindObjectAny("h_sum0TSmaxAperLS6");
1182   HistNumChanDepth[5][4][2] = (TH1F *)dir->FindObjectAny("h_sum0TSmaxAperLS7");
1183 
1184   HistNumChanFull[5] = (TH1F *)HistNumChanDepth[5][1][1]->Clone();
1185 
1186   for (int test = 0; test <= 5; test++) {  //Test: =0(CapIdErrors), =1(Amplitude), =2...
1187     for (int sub = 1; sub <= 4; sub++) {   //Subdetector: 1-HB, 2-HE, 3-HO, 4-HF
1188       if (sub == 1 && test != 1)
1189         cHE->Divide(2, 1);  //HB
1190       if (sub == 1 && test == 1) {
1191         cFour1->Clear();
1192         cFour1->Divide(2, 2);
1193       }  //HB upgrade with new depthes 3,4 for Amplitude test only
1194       if (sub == 2 && test != 1)
1195         cHE->Divide(3, 1);  //HE
1196       if (sub == 2 && test == 1) {
1197         cNine->Clear();
1198         cNine->Divide(3, 3);
1199       }  //HE upgrade with new depthes 4,5,6,7 for Amplitude test only
1200       if (sub == 3)
1201         cHB->Divide(1, 1);  //HO
1202       if (sub == 4 && test != 1)
1203         cHE->Divide(2, 1);  //HF
1204       if (sub == 4 && test == 1) {
1205         cFour1->Clear();
1206         cFour1->Divide(2, 2);
1207       }  // HF upgrade with new depthes 3 and 4 for Amplitude test only
1208 
1209       int kkkkkkmax = k_max[sub];
1210       //      if ( (sub==4 || sub==2) && test==1) kkkkkkmax = k_maxupgrade[sub];
1211       if ((sub == 4 || sub == 2 || sub == 1) && test == 1)
1212         kkkkkkmax = k_maxupgrade[sub];
1213       for (int k = k_min[sub]; k <= kkkkkkmax; k++) {  //Depth
1214         if (sub == 1 && test != 1)
1215           cHE->cd(k);  //HB
1216         if (sub == 1 && test == 1)
1217           cFour1->cd(k);  //HB
1218         if (sub == 2 && test != 1)
1219           cHE->cd(k);  //HE
1220         if (sub == 2 && test == 1)
1221           cNine->cd(k);  //HE upgrade with new depthes 4,5,6,7 for Amplitude test only
1222         if (sub == 3)
1223           cHB->cd(k - 3);  //HO
1224         if (sub == 4 && test != 1)
1225           cHE->cd(k);  //HF
1226         if (sub == 4 && test == 1)
1227           cFour1->cd(k);  // HF upgrade with new depthes 3 and 4 for Amplitude test only
1228         gPad->SetGridy();
1229         gPad->SetGridx();
1230         //                gPad->SetLogy();
1231 
1232         if (sub == 1 && k == 1) {
1233         } else {
1234           // use "else" because ...Full[test] are filled by estimastor for sub==1 && k== 1 at initialization of ...Full[test] variables
1235           for (int x = 1; x <= HistNumBadChanFull[test]->GetXaxis()->GetNbins(); x++) {
1236             double ccc1 = HistNumBadChanDepth[test][sub][k]->GetBinContent(x);
1237             HistNumBadChanFull[test]->SetBinContent(x, HistNumBadChanFull[test]->GetBinContent(x) + ccc1);
1238             double ccc2 = HistNumChanDepth[test][sub][k]->GetBinContent(x);
1239             HistNumChanFull[test]->SetBinContent(x, HistNumChanFull[test]->GetBinContent(x) + ccc2);
1240           }
1241         }  //end x
1242 
1243         // !!!!!!     change the sense of HistNumBadChanDepth: now it's averaged values(estimators)
1244         HistNumBadChanDepth[test][sub][k]->Divide(
1245             HistNumBadChanDepth[test][sub][k], HistNumChanDepth[test][sub][k], 1, 1, "B");
1246         // errors abnulling:
1247         for (int x = 1; x <= HistNumBadChanDepth[test][sub][k]->GetXaxis()->GetNbins(); x++) {
1248           HistNumBadChanDepth[test][sub][k]->SetBinError(float(x), 0.01);
1249         }
1250 
1251         //      int myMaxLum= HistNumBadChanDepth[test][sub][k]->GetBinContent(HistNumBadChanDepth[test][sub][k]->GetMaximumBin());
1252         //      cout<<"********************>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>     myMaxLum = "<<myMaxLum<<"        MaxLum = "<<MaxLum<<endl;
1253         HistNumBadChanDepth[test][sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1254 
1255         //   //    //   //   //   //   //   //   //   //   //   //   //   //   //   //   //  //
1256         HistNumBadChanDepth[test][sub][k]->SetMarkerStyle(20);
1257         HistNumBadChanDepth[test][sub][k]->SetMarkerSize(0.4);
1258         HistNumBadChanDepth[test][sub][k]->GetYaxis()->SetLabelSize(0.04);
1259         if (k == 1)
1260           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 1\b");
1261         if (k == 2)
1262           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 2\b");
1263         if (k == 3)
1264           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 3\b");
1265         if (k == 4)
1266           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 4\b");
1267         if (k == 5)
1268           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 5\b");
1269         if (k == 6)
1270           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 6\b");
1271         if (k == 7)
1272           HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 7\b");
1273         HistNumBadChanDepth[test][sub][k]->SetXTitle("LS \b");
1274         if (test == 0)
1275           HistNumBadChanDepth[test][sub][k]->SetYTitle("<Number of bad channels> \b");
1276         if (test != 0)
1277           HistNumBadChanDepth[test][sub][k]->SetYTitle("Averaged estimator \b");
1278         HistNumBadChanDepth[test][sub][k]->SetMarkerColor(2);
1279         HistNumBadChanDepth[test][sub][k]->SetLineColor(0);
1280         //      gPad->SetGridx();
1281         gPad->SetLogy();
1282         gPad->SetGridy();
1283         gPad->SetGridx();
1284         //      if (test == 1) HistNumBadChanDepth[test][sub][k]->SetMinimum(0.1);
1285         HistNumBadChanDepth[test][sub][k]->Draw("Error");
1286         /*
1287           if (k == 1) HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 1\b");
1288           if (k == 2) HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 2\b");
1289           if (k == 3) HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 3\b");
1290           if (k == 4) HistNumBadChanDepth[test][sub][k]->SetTitle("Depth 4\b");
1291           HistNumBadChanDepth[test][sub][k]->SetXTitle("LS \b");
1292           if (test == 0) HistNumBadChanDepth[test][sub][k]->SetYTitle("<Number of bad channels> \b");
1293           if (test != 0) HistNumBadChanDepth[test][sub][k]->SetYTitle("Averaged estimator \b");
1294           
1295           if (MaxLum<=1000){
1296           HistNumBadChanDepth[test][sub][k]->SetMarkerStyle(20);
1297           HistNumBadChanDepth[test][sub][k]->SetMarkerSize(0.5);    
1298           HistNumBadChanDepth[test][sub][k]->SetMarkerColor(2);
1299           HistNumBadChanDepth[test][sub][k]->SetLineColor(0);
1300           HistNumBadChanDepth[test][sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1301           HistNumBadChanDepth[test][sub][k]->Draw("P");
1302           }
1303           else{
1304           HistNumBadChanDepth[test][sub][k]->SetLineColor(2);
1305           HistNumBadChanDepth[test][sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1306           HistNumBadChanDepth[test][sub][k]->Draw("L");
1307           } 
1308         */
1309         /*
1310         float min_x[] = {0,10000};
1311         float min_y[] = {(float)(Cut0[test][sub][k]),(float)(Cut0[test][sub][k])};
1312         TGraph* MIN = new TGraph(2, min_x, min_y);
1313         MIN->SetLineStyle(2);
1314         MIN->SetLineColor(5);
1315         MIN->SetLineWidth(2 + 100*100);
1316         MIN->SetFillStyle(3005);
1317         MIN->SetFillColor(5);
1318         gPad->SetGridy();
1319         gPad->SetGridx();
1320         MIN->Draw("L");
1321 */
1322 
1323         if (sub == 1 && test != 1) {
1324           cHE->Modified();
1325         }
1326         if (sub == 1 && test == 1) {
1327           cFour1->Modified();
1328         }  // HB upgrade
1329         if (sub == 2 && test != 1) {
1330           cHE->Modified();
1331         }
1332         if (sub == 2 && test == 1) {
1333           cNine->Modified();
1334         }  // HE upgrade
1335         if (sub == 3) {
1336           cHB->Modified();
1337         }
1338         if (sub == 4 && test != 1) {
1339           cHE->Modified();
1340         }
1341         if (sub == 4 && test == 1) {
1342           cFour1->Modified();
1343         }  // HF upgrade
1344 
1345       }  // k loop
1346 
1347       if (test == 0) {
1348         if (sub == 1) {
1349           cHE->Print("HistNBCMNHB.png");
1350           cHE->Clear();
1351         }
1352         if (sub == 2) {
1353           cHE->Print("HistNBCMNHE.png");
1354           cHE->Clear();
1355         }
1356         if (sub == 3) {
1357           cHB->Print("HistNBCMNHO.png");
1358           cHB->Clear();
1359         }
1360         if (sub == 4) {
1361           cHE->Print("HistNBCMNHF.png");
1362           cHE->Clear();
1363         }
1364       }
1365       // Amplitude:
1366       if (test == 1) {
1367         if (sub == 1) {
1368           cFour1->Print("HistADCamplHB.png");
1369           cFour1->Clear();
1370         }  // HB upgrade
1371         if (sub == 2) {
1372           cNine->Print("HistADCamplHE.png");
1373           cNine->Clear();
1374         }  // HE upgrade
1375         if (sub == 3) {
1376           cHB->Print("HistADCamplHO.png");
1377           cHB->Clear();
1378         }
1379         if (sub == 4) {
1380           cFour1->Print("HistADCamplHF.png");
1381           cFour1->Clear();
1382         }  // HF upgrade
1383       }
1384       if (test == 2) {
1385         if (sub == 1) {
1386           cHE->Print("HistWidthHB.png");
1387           cHE->Clear();
1388         }
1389         if (sub == 2) {
1390           cHE->Print("HistWidthHE.png");
1391           cHE->Clear();
1392         }
1393         if (sub == 3) {
1394           cHB->Print("HistWidthHO.png");
1395           cHB->Clear();
1396         }
1397         if (sub == 4) {
1398           cHE->Print("HistWidthHF.png");
1399           cHE->Clear();
1400         }
1401       }
1402       if (test == 3) {
1403         if (sub == 1) {
1404           cHE->Print("HistRatioHB.png");
1405           cHE->Clear();
1406         }
1407         if (sub == 2) {
1408           cHE->Print("HistRatioHE.png");
1409           cHE->Clear();
1410         }
1411         if (sub == 3) {
1412           cHB->Print("HistRatioHO.png");
1413           cHB->Clear();
1414         }
1415         if (sub == 4) {
1416           cHE->Print("HistRatioHF.png");
1417           cHE->Clear();
1418         }
1419       }
1420       if (test == 4) {
1421         if (sub == 1) {
1422           cHE->Print("HistTmeanHB.png");
1423           cHE->Clear();
1424         }
1425         if (sub == 2) {
1426           cHE->Print("HistTmeanHE.png");
1427           cHE->Clear();
1428         }
1429         if (sub == 3) {
1430           cHB->Print("HistTmeanHO.png");
1431           cHB->Clear();
1432         }
1433         if (sub == 4) {
1434           cHE->Print("HistTmeanHF.png");
1435           cHE->Clear();
1436         }
1437       }
1438       if (test == 5) {
1439         if (sub == 1) {
1440           cHE->Print("HistTmaxHB.png");
1441           cHE->Clear();
1442         }
1443         if (sub == 2) {
1444           cHE->Print("HistTmaxHE.png");
1445           cHE->Clear();
1446         }
1447         if (sub == 3) {
1448           cHB->Print("HistTmaxHO.png");
1449           cHB->Clear();
1450         }
1451         if (sub == 4) {
1452           cHE->Print("HistTmaxHF.png");
1453           cHE->Clear();
1454         }
1455       }
1456     }  // end sub
1457     ///////////////////////////////////////////// other cases:
1458     if (test == 1) {
1459       for (int x = 1; x <= HistNumChanFull[6]->GetXaxis()->GetNbins(); x++) {
1460         HistNumChanFull[6]->SetBinContent(x, 0.0);
1461         int depthsubcount = 0.;
1462         for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HO, 4-HF
1463           int kkkkkkmax = k_max[sub];
1464           if (sub == 4 || sub == 2 || sub == 1)
1465             kkkkkkmax = k_maxupgrade[sub];
1466           //          if ( sub==4 || sub==2) kkkkkkmax = k_maxupgrade[sub];
1467           for (int k = k_min[sub]; k <= kkkkkkmax; k++) {  //Depth
1468             // 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
1469             //      if(sub==2 && k>3 ) break;
1470             depthsubcount++;
1471             double ccc1 = HistNumBadChanDepth[test][sub][k]->GetBinContent(x);
1472             HistNumChanFull[6]->SetBinContent(x, HistNumChanFull[6]->GetBinContent(x) + ccc1);
1473           }  //depth
1474         }    //sub
1475         if (depthsubcount > 0.) {
1476           HistNumChanFull[6]->SetBinContent(x, (HistNumChanFull[6]->GetBinContent(x)) / depthsubcount);
1477         } else {
1478           HistNumChanFull[6]->SetBinContent(x, (HistNumChanFull[6]->GetBinContent(x)) / 8.);
1479         }
1480       }  //x
1481     }    //test=1
1482     ////////////  //////   //////  //////  ////// //////
1483     if (test != 1) {
1484       cHB->Divide(1, 1);
1485       cHB->cd(1);
1486     } else {
1487       cHE->Divide(2, 1);
1488       cHE->cd(1);
1489     }
1490     HistNumBadChanFull[test]->Divide(HistNumBadChanFull[test], HistNumChanFull[test], 1, 1, "B");
1491     TH1F *kfitq = new TH1F("kfitq", "", MaxLum, 1., MaxLum + 1.);
1492     int nx = kfitq->GetXaxis()->GetNbins();
1493     for (int i = 1; i <= nx; i++) {
1494       double ccc1 = HistNumBadChanFull[test]->GetBinContent(i);
1495       if (ccc1 > 0.) {
1496         kfitq->Fill(float(i), ccc1);
1497         kfitq->SetBinError(float(i), 0.01);
1498       }
1499     }
1500     kfitq->SetMarkerStyle(20);
1501     kfitq->SetMarkerSize(0.4);
1502     kfitq->GetYaxis()->SetLabelSize(0.04);
1503     if (test == 0)
1504       kfitq->SetTitle("Average Nbch for whole Hcal \b");
1505     if (test != 0)
1506       kfitq->SetTitle("Averaged estimator for whole Hcal \b");
1507     kfitq->SetXTitle("LS \b");
1508     if (test == 0)
1509       kfitq->SetYTitle("<Number of bad channels> \b");
1510     if (test != 0)
1511       kfitq->SetYTitle("Averaged estimator \b");
1512     kfitq->SetMarkerColor(2);
1513     kfitq->SetLineColor(0);
1514     gPad->SetGridx();
1515     kfitq->Draw("Error");
1516     /* 
1517        HistNumBadChanFull[test]->SetMarkerStyle(20);
1518        HistNumBadChanFull[test]->SetMarkerSize(0.8);
1519        HistNumBadChanFull[test]->SetTitle("Averaged estimator for whole Hcal \b");
1520        HistNumBadChanFull[test]->SetXTitle("LS \b");
1521        if (test == 0) HistNumBadChanFull[test]->SetYTitle("<Number of bad channels> \b");
1522        if (test != 0) HistNumBadChanFull[test]->SetYTitle("Averaged estimator \b");
1523        if (MaxLum<=1000){
1524        HistNumBadChanFull[test]->SetMarkerColor(1);
1525        HistNumBadChanFull[test]->SetLineColor(0);
1526        HistNumBadChanFull[test]->Draw("P"); 
1527        }
1528        else {
1529        HistNumBadChanFull[test]->SetLineColor(1);
1530        HistNumBadChanFull[test]->Draw("L"); 
1531        }
1532     */
1533     if (test == 1) {
1534       cHE->cd(2);
1535       TH1F *lpuio = new TH1F("lpuio", "", MaxLum, 1., MaxLum + 1.);
1536       int nx = lpuio->GetXaxis()->GetNbins();
1537       for (int i = 1; i <= nx; i++) {
1538         double ccc1 = HistNumChanFull[6]->GetBinContent(i);
1539         if (ccc1 > 0.) {
1540           lpuio->Fill(float(i), ccc1);
1541           lpuio->SetBinError(float(i), 0.01);
1542         }
1543       }
1544       lpuio->SetMarkerStyle(20);
1545       lpuio->SetMarkerSize(0.4);
1546       lpuio->GetYaxis()->SetLabelSize(0.04);
1547       lpuio->SetTitle("Mean of Averaged Amplitudes over all Hcal sub-detectors \b");
1548       lpuio->SetXTitle("LS \b");
1549       lpuio->SetYTitle("Mean of Averaged estimator \b");
1550       lpuio->SetMarkerColor(2);
1551       lpuio->SetLineColor(0);
1552       gPad->SetGridx();
1553       lpuio->Draw("Error");
1554     }
1555     if (test == 0) {
1556       cHB->Print("HistCapID.png");
1557       cHB->Clear();
1558     }
1559     if (test == 1) {
1560       cHE->Print("HistADCAmpl.png");
1561       cHE->Clear();
1562     }
1563     if (test == 2) {
1564       cHB->Print("HistWidth.png");
1565       cHB->Clear();
1566     }
1567     if (test == 3) {
1568       cHB->Print("HistRatio.png");
1569       cHB->Clear();
1570     }
1571     if (test == 4) {
1572       cHB->Print("HistTmean.png");
1573       cHB->Clear();
1574     }
1575     if (test == 5) {
1576       cHB->Print("HistTmax.png");
1577       cHB->Clear();
1578     }
1579 
1580     // clean-up
1581     if (kfitq)
1582       delete kfitq;
1583   }  //end test
1584 
1585   //================================================================================================================================
1586 
1587   //=======================================================================================================333
1588   //CapID 1-d histograms
1589 
1590   TH1F *HistAbnormNumBadChanDepth[5][5];  // 1d histogramm for subdet, depth
1591 
1592   //+++++++++++++++++++++++++++++
1593   // Abnormal Bad Channels Rate of Cap ID errors  first set of histograms
1594   //+++++++++++++++++++++++++++++
1595 
1596   HistAbnormNumBadChanDepth[1][1] = (TH1F *)dir->FindObjectAny("h_runnbadchannelsC_depth1_HB");
1597   HistAbnormNumBadChanDepth[1][2] = (TH1F *)dir->FindObjectAny("h_runnbadchannelsC_depth2_HB");
1598   HistAbnormNumBadChanDepth[2][1] = (TH1F *)dir->FindObjectAny("h_runnbadchannelsC_depth1_HE");
1599   HistAbnormNumBadChanDepth[2][2] = (TH1F *)dir->FindObjectAny("h_runnbadchannelsC_depth2_HE");
1600   HistAbnormNumBadChanDepth[2][3] = (TH1F *)dir->FindObjectAny("h_runnbadchannelsC_depth3_HE");
1601   HistAbnormNumBadChanDepth[3][4] = (TH1F *)dir->FindObjectAny("h_runnbadchannelsC_depth4_HO");
1602   HistAbnormNumBadChanDepth[4][1] = (TH1F *)dir->FindObjectAny("h_runnbadchannelsC_depth1_HF");
1603   HistAbnormNumBadChanDepth[4][2] = (TH1F *)dir->FindObjectAny("h_runnbadchannelsC_depth2_HF");
1604 
1605   for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
1606     if (sub == 1)
1607       cHB->Divide(2, 1);
1608     if (sub == 2)
1609       cHE->Divide(3, 1);
1610     if (sub == 3)
1611       cONE->Divide(1, 1);
1612     if (sub == 4)
1613       cHB->Divide(2, 1);
1614     for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
1615       if (sub == 1)
1616         cHB->cd(k);
1617       if (sub == 2)
1618         cHE->cd(k);
1619       if (sub == 3)
1620         cONE->cd(k - 3);
1621       if (sub == 4)
1622         cHB->cd(k);
1623       gPad->SetGridy();
1624       gPad->SetGridx();
1625       //  gPad->SetLogy();
1626       HistAbnormNumBadChanDepth[sub][k]->Divide(
1627           HistAbnormNumBadChanDepth[sub][k], HistNumChanDepth[0][sub][k], 1, 1, "B");
1628       if (k == 1)
1629         HistAbnormNumBadChanDepth[sub][k]->SetTitle("Depth 1\b");
1630       if (k == 2)
1631         HistAbnormNumBadChanDepth[sub][k]->SetTitle("Depth 2\b");
1632       if (k == 3)
1633         HistAbnormNumBadChanDepth[sub][k]->SetTitle("Depth 3\b");
1634       if (k == 4)
1635         HistAbnormNumBadChanDepth[sub][k]->SetTitle("Depth 4\b");
1636       HistAbnormNumBadChanDepth[sub][k]->SetXTitle("LS \b");
1637       HistAbnormNumBadChanDepth[sub][k]->SetYTitle("< Number of bad channels > \b");
1638       if (MaxLum <= 1000) {
1639         HistAbnormNumBadChanDepth[sub][k]->SetMarkerStyle(20);
1640         HistAbnormNumBadChanDepth[sub][k]->SetMarkerSize(0.5);
1641         HistAbnormNumBadChanDepth[sub][k]->SetMarkerColor(1);
1642         HistAbnormNumBadChanDepth[sub][k]->SetLineColor(0);
1643         HistAbnormNumBadChanDepth[sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1644         HistAbnormNumBadChanDepth[sub][k]->Draw("P");
1645       } else {
1646         HistAbnormNumBadChanDepth[sub][k]->SetLineColor(1);
1647         HistAbnormNumBadChanDepth[sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1648         HistAbnormNumBadChanDepth[sub][k]->Draw("L");
1649       }
1650     }
1651     if (sub == 1) {
1652       cHB->Print("Hist_CAPID_Abnorm_HB.png");
1653       cHB->Clear();
1654     }
1655     if (sub == 2) {
1656       cHE->Print("Hist_CAPID_Abnorm_HE.png");
1657       cHE->Clear();
1658     }
1659     if (sub == 3) {
1660       cONE->Print("Hist_CAPID_Abnorm_HO.png");
1661       cONE->Clear();
1662     }
1663     if (sub == 4) {
1664       cHB->Print("Hist_CAPID_Abnorm_HF.png");
1665       cHB->Clear();
1666     }
1667   }  // end sub
1668 
1669   //+++++++++++++++++++++++++++++
1670   // Portions of bad channels events identified by Cap ID errors   third set of histograms
1671   //+++++++++++++++++++++++++++++
1672 
1673   TH1F *HistPortBadEventsDepth[5][5];  // 1d histogramm for subdet, depth
1674 
1675   HistPortBadEventsDepth[1][1] = (TH1F *)dir->FindObjectAny("h_runbadrateC_depth1_HB");
1676   HistPortBadEventsDepth[1][2] = (TH1F *)dir->FindObjectAny("h_runbadrateC_depth2_HB");
1677   HistPortBadEventsDepth[2][1] = (TH1F *)dir->FindObjectAny("h_runbadrateC_depth1_HE");
1678   HistPortBadEventsDepth[2][2] = (TH1F *)dir->FindObjectAny("h_runbadrateC_depth2_HE");
1679   HistPortBadEventsDepth[2][3] = (TH1F *)dir->FindObjectAny("h_runbadrateC_depth3_HE");
1680   HistPortBadEventsDepth[3][4] = (TH1F *)dir->FindObjectAny("h_runbadrateC_depth4_HO");
1681   HistPortBadEventsDepth[4][1] = (TH1F *)dir->FindObjectAny("h_runbadrateC_depth1_HF");
1682   HistPortBadEventsDepth[4][2] = (TH1F *)dir->FindObjectAny("h_runbadrateC_depth2_HF");
1683 
1684   TH1F *HistNumRateDepth[5][5];
1685   HistNumRateDepth[1][1] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth1_HB");
1686   HistNumRateDepth[1][2] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth2_HB");
1687   HistNumRateDepth[2][1] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth1_HE");
1688   HistNumRateDepth[2][2] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth2_HE");
1689   HistNumRateDepth[2][3] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth3_HE");
1690   HistNumRateDepth[3][4] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth4_HO");
1691   HistNumRateDepth[4][1] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth1_HF");
1692   HistNumRateDepth[4][2] = (TH1F *)dir->FindObjectAny("h_runbadrate0_depth2_HF");
1693 
1694   for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
1695     if (sub == 1)
1696       cHB->Divide(2, 1);
1697     if (sub == 2)
1698       cHE->Divide(3, 1);
1699     if (sub == 3)
1700       cONE->Divide(1, 1);
1701     if (sub == 4)
1702       cHB->Divide(2, 1);
1703     for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
1704       if (sub == 1)
1705         cHB->cd(k);
1706       if (sub == 2)
1707         cHE->cd(k);
1708       if (sub == 3)
1709         cONE->cd(k - 3);
1710       if (sub == 4)
1711         cHB->cd(k);
1712       gPad->SetGridy();
1713       gPad->SetGridx();
1714       //  gPad->SetLogy();
1715       HistPortBadEventsDepth[sub][k]->Divide(HistPortBadEventsDepth[sub][k], HistNumRateDepth[sub][k], 1, 1, "B");
1716 
1717       if (k == 1)
1718         HistPortBadEventsDepth[sub][k]->SetTitle("Depth 1\b");
1719       if (k == 2)
1720         HistPortBadEventsDepth[sub][k]->SetTitle("Depth 2\b");
1721       if (k == 3)
1722         HistPortBadEventsDepth[sub][k]->SetTitle("Depth 3\b");
1723       if (k == 4)
1724         HistPortBadEventsDepth[sub][k]->SetTitle("Depth 4\b");
1725       HistPortBadEventsDepth[sub][k]->SetXTitle("LS \b");
1726       HistPortBadEventsDepth[sub][k]->SetYTitle("< Number of bad channels > \b");
1727       if (MaxLum <= 1000) {
1728         HistPortBadEventsDepth[sub][k]->SetMarkerStyle(20);
1729         HistPortBadEventsDepth[sub][k]->SetMarkerSize(0.5);
1730         HistPortBadEventsDepth[sub][k]->SetMarkerColor(1);
1731         HistPortBadEventsDepth[sub][k]->SetLineColor(0);
1732         HistPortBadEventsDepth[sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1733         HistPortBadEventsDepth[sub][k]->Draw("P");
1734       } else {
1735         HistPortBadEventsDepth[sub][k]->SetLineColor(1);
1736         HistPortBadEventsDepth[sub][k]->GetXaxis()->SetRangeUser(0, MaxLum);
1737         HistPortBadEventsDepth[sub][k]->Draw("L");
1738       }
1739     }
1740     if (sub == 1) {
1741       cHB->Print("HistPortHB.png");
1742       cHB->Clear();
1743     }
1744     if (sub == 2) {
1745       cHE->Print("HistPortHE.png");
1746       cHE->Clear();
1747     }
1748     if (sub == 3) {
1749       cONE->Print("HistPortHO.png");
1750       cONE->Clear();
1751     }
1752     if (sub == 4) {
1753       cHB->Print("HistPortHF.png");
1754       cHB->Clear();
1755     }
1756   }  // end sub
1757 
1758   //================================================================================================================================
1759 
1760   //+++++++++++++++++++++++++++++
1761   // Number of bad channels events identified by Cap ID errors   third set of histograms
1762   //+++++++++++++++++++++++++++++
1763 
1764   TH1F *HistNBadChsDepth[5][5];  // 1d histogramm for subdet, depth
1765 
1766   HistNBadChsDepth[1][1] = (TH1F *)dir->FindObjectAny("h_nbadchannels_depth1_HB");
1767   HistNBadChsDepth[1][2] = (TH1F *)dir->FindObjectAny("h_nbadchannels_depth2_HB");
1768   HistNBadChsDepth[2][1] = (TH1F *)dir->FindObjectAny("h_nbadchannels_depth1_HE");
1769   HistNBadChsDepth[2][2] = (TH1F *)dir->FindObjectAny("h_nbadchannels_depth2_HE");
1770   HistNBadChsDepth[2][3] = (TH1F *)dir->FindObjectAny("h_nbadchannels_depth3_HE");
1771   HistNBadChsDepth[3][4] = (TH1F *)dir->FindObjectAny("h_nbadchannels_depth4_HO");
1772   HistNBadChsDepth[4][1] = (TH1F *)dir->FindObjectAny("h_nbadchannels_depth1_HF");
1773   HistNBadChsDepth[4][2] = (TH1F *)dir->FindObjectAny("h_nbadchannels_depth2_HF");
1774 
1775   for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
1776     if (sub == 1)
1777       cHB->Divide(2, 1);
1778     if (sub == 2)
1779       cHE->Divide(3, 1);
1780     if (sub == 3)
1781       cONE->Divide(1, 1);
1782     if (sub == 4)
1783       cHB->Divide(2, 1);
1784     for (int k = k_min[sub]; k <= k_max[sub]; k++) {  //Depth
1785       if (sub == 1)
1786         cHB->cd(k);
1787       if (sub == 2)
1788         cHE->cd(k);
1789       if (sub == 3)
1790         cONE->cd(k - 3);
1791       if (sub == 4)
1792         cHB->cd(k);
1793       gPad->SetGridy();
1794       gPad->SetGridx();
1795       gPad->SetLogy();
1796 
1797       if (k == 1)
1798         HistNBadChsDepth[sub][k]->SetTitle("Depth 1\b");
1799       if (k == 2)
1800         HistNBadChsDepth[sub][k]->SetTitle("Depth 2\b");
1801       if (k == 3)
1802         HistNBadChsDepth[sub][k]->SetTitle("Depth 3\b");
1803       if (k == 4)
1804         HistNBadChsDepth[sub][k]->SetTitle("Depth 4\b");
1805       HistNBadChsDepth[sub][k]->SetXTitle("Number of bad channels\b");
1806       HistNBadChsDepth[sub][k]->SetYTitle("Number of events\b");
1807       //         HistNBadChsDepth[sub][k]->SetMarkerStyle(20);
1808       //         HistNBadChsDepth[sub][k]->SetMarkerSize(0.5);
1809       //         HistNBadChsDepth[sub][k]->SetMarkerColor(1);
1810       //         HistNBadChsDepth[sub][k]->SetLineColor(0);
1811       HistNBadChsDepth[sub][k]->Draw("");
1812     }
1813     if (sub == 1) {
1814       cHB->Print("HistNBadChsHB.png");
1815       cHB->Clear();
1816     }
1817     if (sub == 2) {
1818       cHE->Print("HistNBadChsHE.png");
1819       cHE->Clear();
1820     }
1821     if (sub == 3) {
1822       cONE->Print("HistNBadChsHO.png");
1823       cONE->Clear();
1824     }
1825     if (sub == 4) {
1826       cHB->Print("HistNBadChsHF.png");
1827       cHB->Clear();
1828     }
1829   }  // end sub
1830 
1831   //====================================================================== HB                    :
1832   //====================================================================== HB                    :
1833   //====================================================================== HB                    :
1834   // Special test of errors type A and B in HB
1835   // AZ 08.02.2016
1836 
1837   int flagErrAB_HB[2];
1838   flagErrAB_HB[0] = -1;
1839   flagErrAB_HB[1] = -1;
1840   double avedelta_HB = 0.;
1841   int lastLumiBin_HB = -1;
1842   int LSofFirstErrB_HB = -1;
1843   {
1844     const int specCountA = 4;
1845     const int specColors[specCountA] = {1, 2, 3, 4};
1846     const TString hnames[specCountA][2] = {{"h_sumADCAmplperLS1_P1", "h_sum0ADCAmplperLS1_P1"},
1847                                            {"h_sumADCAmplperLS1_P2", "h_sum0ADCAmplperLS1_P2"},
1848                                            {"h_sumADCAmplperLS1_M1", "h_sum0ADCAmplperLS1_M1"},
1849                                            {"h_sumADCAmplperLS1_M2", "h_sum0ADCAmplperLS1_M2"}};
1850 
1851     std::vector<TH1F *> hV;
1852     THStack *hs = new THStack("hs", "ADCAmplerLS1");
1853     cHB->Clear();
1854     //    cHB->cd();
1855     cHB->Divide(2, 1);
1856     cHB->cd(1);
1857 
1858     ///////////////////////////////////////////////////////////////////////////
1859     for (int i = 0; i < specCountA; i++) {
1860       if (1)
1861         std::cout << "debugger: errA_HB : get histos for i=" << i << " " << hnames[i][0] << " and " << hnames[i][1]
1862                   << "\n";
1863       TH1F *h1 = (TH1F *)dir->FindObjectAny(hnames[i][0]);
1864       TH1F *h0 = (TH1F *)dir->FindObjectAny(hnames[i][1]);
1865       if (!h1 || !h0) {
1866         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
1867         ptext->AddText("Missing histo");
1868         if (!h1) {
1869           std::cout << "\tfailed to get " << hnames[i][0] << "\n";
1870           ptext->AddText(hnames[i][0]);
1871         }
1872         if (!h0) {
1873           std::cout << "\tfailed to get " << hnames[i][1] << "\n";
1874           ptext->AddText(hnames[i][1]);
1875         }
1876         ptext->Draw();
1877         continue;
1878       }
1879       TH1F *hERT1orig = (TH1F *)h1->Clone(Form("ERT1orig_%d", i));
1880       hERT1orig->Divide(h1, h0, 1, 1, "B");
1881 
1882       if ((lastLumiBin_HB < 0) && (i == 0)) {
1883         for (int ibin = hERT1orig->GetNbinsX(); ibin >= 1; ibin--) {
1884           if (hERT1orig->GetBinContent(ibin) == 0)
1885             lastLumiBin_HB = ibin;
1886           else
1887             break;
1888         }
1889         lastLumiBin_HB += 3;  // show more bins
1890         if (lastLumiBin_HB >= hERT1orig->GetNbinsX())
1891           lastLumiBin_HB = -1;
1892       }
1893       TH1F *hERT1 = NULL;
1894       if (lastLumiBin_HB > 1) {
1895         if (!copyContents(&hERT1, Form("ERT1_%d", i), "", hERT1orig, lastLumiBin_HB)) {
1896           std::cout << "code failed" << std::endl;
1897           gSystem->Exit(1);
1898         }
1899       } else
1900         hERT1 = hERT1orig;
1901 
1902       hERT1->GetXaxis()->SetTitle("<ADCAmpl> per LS HB: black-P1, red-P2,green-M1,blue-M2");
1903       hV.push_back(hERT1);
1904       hERT1->SetMarkerStyle(20);
1905       hERT1->SetMarkerSize(0.4);
1906       hERT1->SetXTitle("<A>(ev.in LS & ch.) - HB P1     -    iLS \b");
1907       hERT1->SetMarkerColor(specColors[i]);
1908       hERT1->SetLineColor(0);
1909       hs->Add(hERT1);
1910       delete h1;
1911       delete h0;
1912       if (hERT1 != hERT1orig)
1913         delete hERT1orig;
1914     }  /////////////////////////////////////////////////////////////////////////
1915     hs->Draw("LPE1 nostack");
1916     cHB->Update();  // activate the axes
1917     hs->GetXaxis()->SetTitle("<A> per LS: black-P1, red-P2,green-M1,blue-M2");
1918     hs->Draw("LPE1 nostack");
1919     gPad->SetGridy();
1920     /////////////////////////////////////////////////////////////////////////////////////////
1921 
1922     // AZ corrections 08.02.2016
1923     cHB->cd(2);
1924     TH1F *diff = new TH1F("diff", "", 100, 0., 4.);
1925 
1926     if (int(hV.size()) == specCountA) {
1927       flagErrAB_HB[0] = 0;  // If we have the expected number of histograms, set the flag
1928       double sumdelta = 0.;
1929       int nnndelta = 0;
1930       for (int ibin = 1; ibin <= hV[0]->GetNbinsX(); ibin++) {
1931         double delta = 0.;
1932         double maxdelta = 0.;
1933         for (unsigned int i = 0; i < hV.size(); i++) {
1934           const TH1F *hi = hV[i];
1935           for (unsigned int j = 1; j < hV.size(); j++) {
1936             const TH1F *hj = hV[j];
1937             delta = fabs(hi->GetBinContent(ibin) - hj->GetBinContent(ibin));
1938             if (delta > maxdelta)
1939               maxdelta = delta;
1940           }  //for
1941         }    //for
1942         if (maxdelta > 0.) {
1943           diff->Fill(maxdelta);
1944           sumdelta += maxdelta;
1945           nnndelta++;
1946         }
1947       }  //for ibin
1948       //      avedelta_HB = sumdelta/hV[0]->GetNbinsX();
1949       avedelta_HB = sumdelta / nnndelta;
1950       std::cout << "******************>>>>>>      ErrA_HB:  avedelta_HB = " << avedelta_HB << std::endl;
1951       if (avedelta_HB > 0.24 || (avedelta_HB < 0.14 && avedelta_HB > 0.)) {
1952         flagErrAB_HB[0] = 1;
1953       }  //if
1954     }    //hV.size
1955     diff->SetMarkerStyle(20);
1956     diff->SetMarkerSize(0.8);
1957     diff->SetXTitle("max difference \b");
1958     diff->SetMarkerColor(2);
1959     diff->SetLineColor(0);
1960     gPad->SetGridx();
1961     gPad->SetLogy();
1962     diff->Draw("Error");
1963     /////////////////////////////////////////////////////////////////////////
1964     cHB->Update();
1965     cHB->Print("HistErrA_HB.png");
1966     cHB->Clear();
1967     /////////////////////////////////////////////////////////////////////////
1968 
1969     // clean-up
1970     if (diff)
1971       delete diff;
1972     for (unsigned int i = 0; i < hV.size(); i++)
1973       delete hV[i];
1974   }  // ErrorA in HB
1975 
1976   ///////////////////////////////////////////////////////////////////////// errors B:
1977 
1978   {  // errors type B
1979     const int specCountB = 4;
1980     const TString hnames[specCountB][2] = {{"h_2DsumErrorBLS1", "h_2D0sumErrorBLS1"},
1981                                            {"h_sumErrorBperLS1", "h_sum0ErrorBperLS1"},
1982                                            {"h_2DsumErrorBLS2", "h_2D0sumErrorBLS2"},
1983                                            {"h_sumErrorBperLS2", "h_sum0ErrorBperLS2"}};
1984 
1985     for (int depth = 1; depth <= 2; depth++) {
1986       cHB->Clear();
1987       cHB->Divide(2, 1);
1988       cHB->cd(1);
1989 
1990       TH1F *hRate2orig = NULL;
1991       TH2F *h2Cefz6 = NULL;
1992       TString hname1 = hnames[2 * depth - 2][0];
1993       TString hname0 = hnames[2 * depth - 2][1];
1994       TH2F *twod1 = (TH2F *)dir->FindObjectAny(hname1);
1995       TH2F *twod0 = (TH2F *)dir->FindObjectAny(hname0);
1996       if (1)
1997         std::cout << "debugger: errB_HB depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
1998       if (!twod1 || !twod0) {
1999         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2000         ptext->AddText("Missing histos");
2001         if (!twod1) {
2002           std::cout << "\tfailed to get " << hname1 << "\n";
2003           ptext->AddText(hname1);
2004         }
2005         if (!twod0) {
2006           std::cout << "\tfailed to get " << hname0 << "\n";
2007           ptext->AddText(hname0);
2008         }
2009         ptext->Draw();
2010       } else {
2011         h2Cefz6 = (TH2F *)twod1->Clone(Form("Cefz6_%d", depth));
2012         h2Cefz6->SetTitle(Form("HB Depth %d \b", depth));
2013         h2Cefz6->Divide(twod1, twod0, 1, 1, "B");
2014 
2015         gPad->SetGridy();
2016         gPad->SetGridx();
2017         gPad->SetLogz();
2018         h2Cefz6->SetTitle(Form("Depth %d \b", depth));
2019         h2Cefz6->SetMarkerStyle(20);
2020         h2Cefz6->SetMarkerSize(0.4);
2021         //  h2Cefz6->GetZaxis()->SetLabelSize(0.04);
2022         h2Cefz6->SetXTitle("#eta \b");
2023         h2Cefz6->SetYTitle("#phi \b");
2024         h2Cefz6->SetZTitle(Form("<ErrorB>  - HB Depth%d \b", depth));
2025         h2Cefz6->SetMarkerColor(2);
2026         h2Cefz6->SetLineColor(2);
2027         h2Cefz6->Draw("COLZ");
2028 
2029         delete twod1;
2030         delete twod0;
2031       }  // histos ok
2032 
2033       cHB->cd(2);
2034       hname1 = hnames[2 * depth - 1][0];
2035       hname0 = hnames[2 * depth - 1][1];
2036       TH1F *h1 = (TH1F *)dir->FindObjectAny(hname1);
2037       TH1F *h0 = (TH1F *)dir->FindObjectAny(hname0);
2038       if (1)
2039         std::cout << "errB_HB depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2040       if (!h1 || !h0) {
2041         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2042         ptext->AddText("Missing histo");
2043         if (!h1) {
2044           std::cout << "\tfailed to get " << hname1 << "\n";
2045           ptext->AddText(hname1);
2046         }
2047         if (!h0) {
2048           std::cout << "\tfailed to get " << hname0 << "\n";
2049           ptext->AddText(hname0);
2050         }
2051         ptext->Draw();
2052       } else {
2053         gPad->SetGridx();
2054         gPad->SetGridy();
2055         //  gPad->SetLogy();
2056         hRate2orig = (TH1F *)h1->Clone(Form("Rate2orig_%d", depth));
2057         hRate2orig->Divide(h1, h0, 1, 1, "B");
2058 
2059         TH1F *hRate2 = NULL;
2060         if (lastLumiBin_HB > 1) {
2061           if (!copyContents(&hRate2, Form("Rate2_%d", depth), "", hRate2orig, lastLumiBin_HB)) {
2062             std::cout << "code failed" << std::endl;
2063             gSystem->Exit(1);
2064           }
2065         } else
2066           hRate2 = hRate2orig;
2067 
2068         hRate2->SetTitle(Form("Depth %d \b", depth));
2069         hRate2->SetMarkerStyle(20);
2070         hRate2->SetMarkerSize(0.8);
2071         //  hRate2->GetZaxis()->SetLabelSize(0.04);
2072         hRate2->SetXTitle(Form("<ErrorB>(ev.in LS & ch.) - HB depth%d -    iLS \b", depth));
2073         hRate2->SetMarkerColor(2);
2074         hRate2->SetLineColor(0);
2075         hRate2->Draw("Error");
2076 
2077         if (LSofFirstErrB_HB == -1) {
2078           int nx = hRate2->GetXaxis()->GetNbins();
2079           for (int i = 1; i <= nx; i++) {
2080             double ccc1 = hRate2->GetBinContent(i);
2081             if (ccc1 > 0.) {
2082               cout << "****************>>>>>>>>>>> ErrB_HB bad LS start at iLS = " << i << " with rate = " << ccc1
2083                    << endl;
2084               LSofFirstErrB_HB = i;
2085               break;
2086             }
2087           }
2088         }
2089 
2090         delete h1;
2091         delete h0;
2092         if (hRate2 != hRate2orig) {
2093           delete hRate2orig;
2094           hRate2orig = hRate2;
2095         }
2096       }
2097 
2098       cHB->Update();
2099       cHB->Print(Form("HistErrB_HB_%d.png", depth));
2100       cHB->Clear();
2101       if (h2Cefz6)
2102         delete h2Cefz6;
2103       if (hRate2orig)
2104         delete hRate2orig;
2105     }
2106   }  // ErrorsB in HB
2107 
2108   //====================================================================== HE                    :
2109   //====================================================================== HE                    :
2110   //====================================================================== HE                    :
2111   // Special test of errors type A and B in HE
2112   // AZ 08.02.2016
2113 
2114   int flagErrAB_HE[2];
2115   flagErrAB_HE[0] = -1;
2116   flagErrAB_HE[1] = -1;
2117   double avedelta_HE = 0.;
2118   int lastLumiBin_HE = -1;
2119   int LSofFirstErrB_HE = -1;
2120   {
2121     const int specCountA = 4;
2122     const int specColors[specCountA] = {1, 2, 3, 4};
2123     const TString hnames[specCountA][2] = {{"h_sumADCAmplperLS3_P1", "h_sum0ADCAmplperLS3_P1"},
2124                                            {"h_sumADCAmplperLS3_P2", "h_sum0ADCAmplperLS3_P2"},
2125                                            {"h_sumADCAmplperLS3_M1", "h_sum0ADCAmplperLS3_M1"},
2126                                            {"h_sumADCAmplperLS3_M2", "h_sum0ADCAmplperLS3_M2"}};
2127 
2128     std::vector<TH1F *> hV;
2129     THStack *hs = new THStack("hs", "ADCAmplerLS1");
2130     cHB->Clear();
2131     //    cHB->cd();
2132     cHB->Divide(2, 1);
2133     cHB->cd(1);
2134 
2135     ///////////////////////////////////////////////////////////////////////////
2136     for (int i = 0; i < specCountA; i++) {
2137       if (1)
2138         std::cout << "debugger: errA_HE : get histos for i=" << i << " " << hnames[i][0] << " and " << hnames[i][1]
2139                   << "\n";
2140       TH1F *h1 = (TH1F *)dir->FindObjectAny(hnames[i][0]);
2141       TH1F *h0 = (TH1F *)dir->FindObjectAny(hnames[i][1]);
2142       if (!h1 || !h0) {
2143         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2144         ptext->AddText("Missing histo");
2145         if (!h1) {
2146           std::cout << "\tfailed to get " << hnames[i][0] << "\n";
2147           ptext->AddText(hnames[i][0]);
2148         }
2149         if (!h0) {
2150           std::cout << "\tfailed to get " << hnames[i][1] << "\n";
2151           ptext->AddText(hnames[i][1]);
2152         }
2153         ptext->Draw();
2154         continue;
2155       }
2156       TH1F *hERT1orig = (TH1F *)h1->Clone(Form("ERT1orig_%d", i));
2157       hERT1orig->Divide(h1, h0, 1, 1, "B");
2158 
2159       if ((lastLumiBin_HE < 0) && (i == 0)) {
2160         for (int ibin = hERT1orig->GetNbinsX(); ibin >= 1; ibin--) {
2161           if (hERT1orig->GetBinContent(ibin) == 0)
2162             lastLumiBin_HE = ibin;
2163           else
2164             break;
2165         }
2166         lastLumiBin_HE += 3;  // show more bins
2167         if (lastLumiBin_HE >= hERT1orig->GetNbinsX())
2168           lastLumiBin_HE = -1;
2169       }
2170       TH1F *hERT1 = NULL;
2171       if (lastLumiBin_HE > 1) {
2172         if (!copyContents(&hERT1, Form("ERT1_%d", i), "", hERT1orig, lastLumiBin_HE)) {
2173           std::cout << "code failed" << std::endl;
2174           gSystem->Exit(1);
2175         }
2176       } else
2177         hERT1 = hERT1orig;
2178 
2179       hERT1->GetXaxis()->SetTitle("<ADCAmpl> per LS HE: black-P1, red-P2,green-M1,blue-M2");
2180       hV.push_back(hERT1);
2181       hERT1->SetMarkerStyle(20);
2182       hERT1->SetMarkerSize(0.4);
2183       hERT1->SetXTitle("<A>(ev.in LS & ch.) - HE P1     -    iLS \b");
2184       hERT1->SetMarkerColor(specColors[i]);
2185       hERT1->SetLineColor(0);
2186       hs->Add(hERT1);
2187       delete h1;
2188       delete h0;
2189       if (hERT1 != hERT1orig)
2190         delete hERT1orig;
2191     }  /////////////////////////////////////////////////////////////////////////
2192     hs->Draw("LPE1 nostack");
2193     cHB->Update();  // activate the axes
2194     hs->GetXaxis()->SetTitle("<A> per LS: black-P1, red-P2,green-M1,blue-M2");
2195     hs->Draw("LPE1 nostack");
2196     gPad->SetGridy();
2197     /////////////////////////////////////////////////////////////////////////////////////////
2198 
2199     // AZ corrections 08.02.2016
2200     cHB->cd(2);
2201     TH1F *diff = new TH1F("diff", "", 100, 0., 4.);
2202 
2203     if (int(hV.size()) == specCountA) {
2204       flagErrAB_HE[0] = 0;  // If we have the expected number of histograms, set the flag
2205       double sumdelta = 0.;
2206       int nnndelta = 0;
2207       for (int ibin = 1; ibin <= hV[0]->GetNbinsX(); ibin++) {
2208         double delta = 0.;
2209         double maxdelta = 0.;
2210         for (unsigned int i = 0; i < hV.size(); i++) {
2211           const TH1F *hi = hV[i];
2212           for (unsigned int j = 1; j < hV.size(); j++) {
2213             const TH1F *hj = hV[j];
2214             delta = fabs(hi->GetBinContent(ibin) - hj->GetBinContent(ibin));
2215             if (delta > maxdelta)
2216               maxdelta = delta;
2217           }  //for
2218         }    //for
2219         if (maxdelta > 0.) {
2220           diff->Fill(maxdelta);
2221           sumdelta += maxdelta;
2222           nnndelta++;
2223         }
2224       }  //for ibin
2225       //      avedelta_HE = sumdelta/hV[0]->GetNbinsX();
2226       avedelta_HE = sumdelta / nnndelta;
2227       std::cout << "******************>>>>>>      ErrA_HE:  avedelta_HE = " << avedelta_HE << std::endl;
2228       if (avedelta_HE > 1.1 || (avedelta_HE < 0.5 && avedelta_HE > 0.)) {
2229         flagErrAB_HE[0] = 1;
2230       }  //if
2231     }    //hV.size
2232     diff->SetMarkerStyle(20);
2233     diff->SetMarkerSize(0.8);
2234     diff->SetXTitle("max difference \b");
2235     diff->SetMarkerColor(2);
2236     diff->SetLineColor(0);
2237     gPad->SetGridx();
2238     gPad->SetLogy();
2239     diff->Draw("Error");
2240     /////////////////////////////////////////////////////////////////////////
2241     cHB->Update();
2242     cHB->Print("HistErrA_HE.png");
2243     cHB->Clear();
2244     /////////////////////////////////////////////////////////////////////////
2245 
2246     // clean-up
2247     if (diff)
2248       delete diff;
2249     for (unsigned int i = 0; i < hV.size(); i++)
2250       delete hV[i];
2251   }  // ErrorA in HE
2252 
2253   ///////////////////////////////////////////////////////////////////////// errors B:
2254 
2255   {  // errors type B
2256     const int specCountB = 6;
2257     const TString hnames[specCountB][2] = {{"h_2DsumErrorBLS3", "h_2D0sumErrorBLS3"},
2258                                            {"h_sumErrorBperLS3", "h_sum0ErrorBperLS3"},
2259                                            {"h_2DsumErrorBLS4", "h_2D0sumErrorBLS4"},
2260                                            {"h_sumErrorBperLS4", "h_sum0ErrorBperLS4"},
2261                                            {"h_2DsumErrorBLS5", "h_2D0sumErrorBLS5"},
2262                                            {"h_sumErrorBperLS5", "h_sum0ErrorBperLS5"}};
2263 
2264     for (int depth = 1; depth <= 3; depth++) {
2265       cHB->Clear();
2266       cHB->Divide(2, 1);
2267       cHB->cd(1);
2268 
2269       TH1F *hRate2orig = NULL;
2270       TH2F *h2Cefz6 = NULL;
2271       TString hname1 = hnames[2 * depth - 2][0];
2272       TString hname0 = hnames[2 * depth - 2][1];
2273       TH2F *twod1 = (TH2F *)dir->FindObjectAny(hname1);
2274       TH2F *twod0 = (TH2F *)dir->FindObjectAny(hname0);
2275       if (1)
2276         std::cout << "debugger: errB_HE depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2277       if (!twod1 || !twod0) {
2278         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2279         ptext->AddText("Missing histos");
2280         if (!twod1) {
2281           std::cout << "\tfailed to get " << hname1 << "\n";
2282           ptext->AddText(hname1);
2283         }
2284         if (!twod0) {
2285           std::cout << "\tfailed to get " << hname0 << "\n";
2286           ptext->AddText(hname0);
2287         }
2288         ptext->Draw();
2289       } else {
2290         h2Cefz6 = (TH2F *)twod1->Clone(Form("Cefz6_%d", depth));
2291         h2Cefz6->SetTitle(Form("HE Depth %d \b", depth));
2292         h2Cefz6->Divide(twod1, twod0, 1, 1, "B");
2293 
2294         gPad->SetGridy();
2295         gPad->SetGridx();
2296         gPad->SetLogz();
2297         h2Cefz6->SetTitle(Form("Depth %d \b", depth));
2298         h2Cefz6->SetMarkerStyle(20);
2299         h2Cefz6->SetMarkerSize(0.4);
2300         //  h2Cefz6->GetZaxis()->SetLabelSize(0.04);
2301         h2Cefz6->SetXTitle("#eta \b");
2302         h2Cefz6->SetYTitle("#phi \b");
2303         h2Cefz6->SetZTitle(Form("<ErrorB>  - HE Depth%d \b", depth));
2304         h2Cefz6->SetMarkerColor(2);
2305         h2Cefz6->SetLineColor(2);
2306         h2Cefz6->Draw("COLZ");
2307 
2308         delete twod1;
2309         delete twod0;
2310       }  // histos ok
2311 
2312       cHB->cd(2);
2313       hname1 = hnames[2 * depth - 1][0];
2314       hname0 = hnames[2 * depth - 1][1];
2315       TH1F *h1 = (TH1F *)dir->FindObjectAny(hname1);
2316       TH1F *h0 = (TH1F *)dir->FindObjectAny(hname0);
2317       if (1)
2318         std::cout << "errB_HE depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2319       if (!h1 || !h0) {
2320         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2321         ptext->AddText("Missing histo");
2322         if (!h1) {
2323           std::cout << "\tfailed to get " << hname1 << "\n";
2324           ptext->AddText(hname1);
2325         }
2326         if (!h0) {
2327           std::cout << "\tfailed to get " << hname0 << "\n";
2328           ptext->AddText(hname0);
2329         }
2330         ptext->Draw();
2331       } else {
2332         gPad->SetGridx();
2333         gPad->SetGridy();
2334         //  gPad->SetLogy();
2335         hRate2orig = (TH1F *)h1->Clone(Form("Rate2orig_%d", depth));
2336         hRate2orig->Divide(h1, h0, 1, 1, "B");
2337 
2338         TH1F *hRate2 = NULL;
2339         if (lastLumiBin_HE > 1) {
2340           if (!copyContents(&hRate2, Form("Rate2_%d", depth), "", hRate2orig, lastLumiBin_HE)) {
2341             std::cout << "code failed" << std::endl;
2342             gSystem->Exit(1);
2343           }
2344         } else
2345           hRate2 = hRate2orig;
2346 
2347         hRate2->SetTitle(Form("Depth %d \b", depth));
2348         hRate2->SetMarkerStyle(20);
2349         hRate2->SetMarkerSize(0.8);
2350         //  hRate2->GetZaxis()->SetLabelSize(0.04);
2351         hRate2->SetXTitle(Form("<ErrorB>(ev.in LS & ch.) - HE depth%d -    iLS \b", depth));
2352         hRate2->SetMarkerColor(2);
2353         hRate2->SetLineColor(0);
2354         hRate2->Draw("Error");
2355 
2356         if (LSofFirstErrB_HE == -1) {
2357           int nx = hRate2->GetXaxis()->GetNbins();
2358           for (int i = 1; i <= nx; i++) {
2359             double ccc1 = hRate2->GetBinContent(i);
2360             if (ccc1 > 0.) {
2361               cout << "****************>>>>>>>>>>> ErrB_HE bad LS start at iLS = " << i << " with rate = " << ccc1
2362                    << endl;
2363               LSofFirstErrB_HE = i;
2364               break;
2365             }
2366           }
2367         }
2368 
2369         delete h1;
2370         delete h0;
2371         if (hRate2 != hRate2orig) {
2372           delete hRate2orig;
2373           hRate2orig = hRate2;
2374         }
2375       }
2376 
2377       cHB->Update();
2378       cHB->Print(Form("HistErrB_HE_%d.png", depth));
2379       cHB->Clear();
2380       if (h2Cefz6)
2381         delete h2Cefz6;
2382       if (hRate2orig)
2383         delete hRate2orig;
2384     }
2385   }  // ErrorsB in HE
2386 
2387   //====================================================================== HO                    :
2388   //====================================================================== HO                    :
2389   //====================================================================== HO                    :
2390   // Special test of errors type A and B in HO
2391   // AZ 08.02.2016
2392 
2393   int flagErrAB_HO[2];
2394   flagErrAB_HO[0] = -1;
2395   flagErrAB_HO[1] = -1;
2396   double avedelta_HO = 0.;
2397   int lastLumiBin_HO = -1;
2398   int LSofFirstErrB_HO = -1;
2399   {
2400     const int specCountA = 4;
2401     const int specColors[specCountA] = {1, 2, 3, 4};
2402     const TString hnames[specCountA][2] = {{"h_sumADCAmplperLS8_P1", "h_sum0ADCAmplperLS8_P1"},
2403                                            {"h_sumADCAmplperLS8_P2", "h_sum0ADCAmplperLS8_P2"},
2404                                            {"h_sumADCAmplperLS8_M1", "h_sum0ADCAmplperLS8_M1"},
2405                                            {"h_sumADCAmplperLS8_M2", "h_sum0ADCAmplperLS8_M2"}};
2406 
2407     std::vector<TH1F *> hV;
2408     THStack *hs = new THStack("hs", "ADCAmplerLS1");
2409     cHB->Clear();
2410     //    cHB->cd();
2411     cHB->Divide(2, 1);
2412     cHB->cd(1);
2413 
2414     ///////////////////////////////////////////////////////////////////////////
2415     for (int i = 0; i < specCountA; i++) {
2416       if (1)
2417         std::cout << "debugger: errA_HO : get histos for i=" << i << " " << hnames[i][0] << " and " << hnames[i][1]
2418                   << "\n";
2419       TH1F *h1 = (TH1F *)dir->FindObjectAny(hnames[i][0]);
2420       TH1F *h0 = (TH1F *)dir->FindObjectAny(hnames[i][1]);
2421       if (!h1 || !h0) {
2422         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2423         ptext->AddText("Missing histo");
2424         if (!h1) {
2425           std::cout << "\tfailed to get " << hnames[i][0] << "\n";
2426           ptext->AddText(hnames[i][0]);
2427         }
2428         if (!h0) {
2429           std::cout << "\tfailed to get " << hnames[i][1] << "\n";
2430           ptext->AddText(hnames[i][1]);
2431         }
2432         ptext->Draw();
2433         continue;
2434       }
2435       TH1F *hoRT1orig = (TH1F *)h1->Clone(Form("ERT1orig_%d", i));
2436       hoRT1orig->Divide(h1, h0, 1, 1, "B");
2437 
2438       if ((lastLumiBin_HO < 0) && (i == 0)) {
2439         for (int ibin = hoRT1orig->GetNbinsX(); ibin >= 1; ibin--) {
2440           if (hoRT1orig->GetBinContent(ibin) == 0)
2441             lastLumiBin_HO = ibin;
2442           else
2443             break;
2444         }
2445         lastLumiBin_HO += 3;  // show more bins
2446         if (lastLumiBin_HO >= hoRT1orig->GetNbinsX())
2447           lastLumiBin_HO = -1;
2448       }
2449       TH1F *hoRT1 = NULL;
2450       if (lastLumiBin_HO > 1) {
2451         if (!copyContents(&hoRT1, Form("ERT1_%d", i), "", hoRT1orig, lastLumiBin_HO)) {
2452           std::cout << "code failed" << std::endl;
2453           gSystem->Exit(1);
2454         }
2455       } else
2456         hoRT1 = hoRT1orig;
2457 
2458       hoRT1->GetXaxis()->SetTitle("<ADCAmpl> per LS HO: black-P1, red-P2,green-M1,blue-M2");
2459       hV.push_back(hoRT1);
2460       hoRT1->SetMarkerStyle(20);
2461       hoRT1->SetMarkerSize(0.4);
2462       hoRT1->SetXTitle("<A>(ev.in LS & ch.) - HO P1     -    iLS \b");
2463       hoRT1->SetMarkerColor(specColors[i]);
2464       hoRT1->SetLineColor(0);
2465       hs->Add(hoRT1);
2466       delete h1;
2467       delete h0;
2468       if (hoRT1 != hoRT1orig)
2469         delete hoRT1orig;
2470     }  /////////////////////////////////////////////////////////////////////////
2471     hs->Draw("LPE1 nostack");
2472     cHB->Update();  // activate tho axes
2473     hs->GetXaxis()->SetTitle("<A> per LS: black-P1, red-P2,green-M1,blue-M2");
2474     hs->Draw("LPE1 nostack");
2475     gPad->SetGridy();
2476     /////////////////////////////////////////////////////////////////////////////////////////
2477 
2478     // AZ corrections 08.02.2016
2479     cHB->cd(2);
2480     TH1F *diff = new TH1F("diff", "", 100, 0., 4.);
2481 
2482     if (int(hV.size()) == specCountA) {
2483       flagErrAB_HO[0] = 0;  // If we have tho expected number of histograms, set tho flag
2484       double sumdelta = 0.;
2485       int nnndelta = 0;
2486       for (int ibin = 1; ibin <= hV[0]->GetNbinsX(); ibin++) {
2487         double delta = 0.;
2488         double maxdelta = 0.;
2489         for (unsigned int i = 0; i < hV.size(); i++) {
2490           const TH1F *hi = hV[i];
2491           for (unsigned int j = 1; j < hV.size(); j++) {
2492             const TH1F *hj = hV[j];
2493             delta = fabs(hi->GetBinContent(ibin) - hj->GetBinContent(ibin));
2494             if (delta > maxdelta)
2495               maxdelta = delta;
2496           }  //for
2497         }    //for
2498         if (maxdelta > 0.) {
2499           diff->Fill(maxdelta);
2500           sumdelta += maxdelta;
2501           nnndelta++;
2502         }
2503       }  //for ibin
2504       //      avedelta_HO = sumdelta/hV[0]->GetNbinsX();
2505       avedelta_HO = sumdelta / nnndelta;
2506       std::cout << "******************>>>>>>      ErrA_HO:  avedelta_HO = " << avedelta_HO << std::endl;
2507       if (avedelta_HO > 0.8 || (avedelta_HO < 0.2 && avedelta_HO > 0.)) {
2508         flagErrAB_HO[0] = 1;
2509       }  //if
2510     }    //hV.size
2511     diff->SetMarkerStyle(20);
2512     diff->SetMarkerSize(0.8);
2513     diff->SetXTitle("max difference \b");
2514     diff->SetMarkerColor(2);
2515     diff->SetLineColor(0);
2516     gPad->SetGridx();
2517     gPad->SetLogy();
2518     diff->Draw("Error");
2519     /////////////////////////////////////////////////////////////////////////
2520     cHB->Update();
2521     cHB->Print("HistErrA_HO.png");
2522     cHB->Clear();
2523     /////////////////////////////////////////////////////////////////////////
2524 
2525     // clean-up
2526     if (diff)
2527       delete diff;
2528     for (unsigned int i = 0; i < hV.size(); i++)
2529       delete hV[i];
2530   }  // ErrorA in HO
2531 
2532   ///////////////////////////////////////////////////////////////////////// errors B:
2533 
2534   {  // errors type B
2535     const int specCountB = 2;
2536     const TString hnames[specCountB][2] = {{"h_2DsumErrorBLS8", "h_2D0sumErrorBLS8"},
2537                                            {"h_sumErrorBperLS8", "h_sum0ErrorBperLS8"}};
2538 
2539     for (int depth = 4; depth <= 4; depth++) {
2540       cHB->Clear();
2541       cHB->Divide(2, 1);
2542       cHB->cd(1);
2543 
2544       TH1F *hRate2orig = NULL;
2545       TH2F *h2Cefz6 = NULL;
2546       TString hname1 = hnames[2 * depth - 8][0];
2547       TString hname0 = hnames[2 * depth - 8][1];
2548       TH2F *twod1 = (TH2F *)dir->FindObjectAny(hname1);
2549       TH2F *twod0 = (TH2F *)dir->FindObjectAny(hname0);
2550       if (1)
2551         std::cout << "debugger: errB_HO depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2552       if (!twod1 || !twod0) {
2553         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2554         ptext->AddText("Missing histos");
2555         if (!twod1) {
2556           std::cout << "\tfailed to get " << hname1 << "\n";
2557           ptext->AddText(hname1);
2558         }
2559         if (!twod0) {
2560           std::cout << "\tfailed to get " << hname0 << "\n";
2561           ptext->AddText(hname0);
2562         }
2563         ptext->Draw();
2564       } else {
2565         h2Cefz6 = (TH2F *)twod1->Clone(Form("Cefz6_%d", depth));
2566         h2Cefz6->SetTitle(Form("HO Depth %d \b", depth));
2567         h2Cefz6->Divide(twod1, twod0, 1, 1, "B");
2568 
2569         gPad->SetGridy();
2570         gPad->SetGridx();
2571         gPad->SetLogz();
2572         h2Cefz6->SetTitle(Form("Depth %d \b", depth));
2573         h2Cefz6->SetMarkerStyle(20);
2574         h2Cefz6->SetMarkerSize(0.4);
2575         //  h2Cefz6->GetZaxis()->SetLabelSize(0.04);
2576         h2Cefz6->SetXTitle("#eta \b");
2577         h2Cefz6->SetYTitle("#phi \b");
2578         h2Cefz6->SetZTitle(Form("<ErrorB>  - HO Depth%d \b", depth));
2579         h2Cefz6->SetMarkerColor(2);
2580         h2Cefz6->SetLineColor(2);
2581         h2Cefz6->Draw("COLZ");
2582 
2583         delete twod1;
2584         delete twod0;
2585       }  // histos ok
2586 
2587       cHB->cd(2);
2588       hname1 = hnames[2 * depth - 7][0];
2589       hname0 = hnames[2 * depth - 7][1];
2590       TH1F *h1 = (TH1F *)dir->FindObjectAny(hname1);
2591       TH1F *h0 = (TH1F *)dir->FindObjectAny(hname0);
2592       if (1)
2593         std::cout << "errB_HO depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2594       if (!h1 || !h0) {
2595         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2596         ptext->AddText("Missing histo");
2597         if (!h1) {
2598           std::cout << "\tfailed to get " << hname1 << "\n";
2599           ptext->AddText(hname1);
2600         }
2601         if (!h0) {
2602           std::cout << "\tfailed to get " << hname0 << "\n";
2603           ptext->AddText(hname0);
2604         }
2605         ptext->Draw();
2606       } else {
2607         gPad->SetGridx();
2608         gPad->SetGridy();
2609         //  gPad->SetLogy();
2610         hRate2orig = (TH1F *)h1->Clone(Form("Rate2orig_%d", depth));
2611         hRate2orig->Divide(h1, h0, 1, 1, "B");
2612 
2613         TH1F *hRate2 = NULL;
2614         if (lastLumiBin_HO > 1) {
2615           if (!copyContents(&hRate2, Form("Rate2_%d", depth), "", hRate2orig, lastLumiBin_HO)) {
2616             std::cout << "code failed" << std::endl;
2617             gSystem->Exit(1);
2618           }
2619         } else
2620           hRate2 = hRate2orig;
2621 
2622         hRate2->SetTitle(Form("Depth %d \b", depth));
2623         hRate2->SetMarkerStyle(20);
2624         hRate2->SetMarkerSize(0.8);
2625         //  hRate2->GetZaxis()->SetLabelSize(0.04);
2626         hRate2->SetXTitle(Form("<ErrorB>(ev.in LS & ch.) - HO depth%d -    iLS \b", depth));
2627         hRate2->SetMarkerColor(2);
2628         hRate2->SetLineColor(0);
2629         hRate2->Draw("Error");
2630 
2631         if (LSofFirstErrB_HO == -1) {
2632           int nx = hRate2->GetXaxis()->GetNbins();
2633           for (int i = 1; i <= nx; i++) {
2634             double ccc1 = hRate2->GetBinContent(i);
2635             if (ccc1 > 0.) {
2636               cout << "****************>>>>>>>>>>> ErrB_HO bad LS start at iLS = " << i << " with rate = " << ccc1
2637                    << endl;
2638               LSofFirstErrB_HO = i;
2639               break;
2640             }
2641           }
2642         }
2643 
2644         delete h1;
2645         delete h0;
2646         if (hRate2 != hRate2orig) {
2647           delete hRate2orig;
2648           hRate2orig = hRate2;
2649         }
2650       }
2651 
2652       cHB->Update();
2653       cHB->Print(Form("HistErrB_HO_%d.png", depth));
2654       cHB->Clear();
2655       if (h2Cefz6)
2656         delete h2Cefz6;
2657       if (hRate2orig)
2658         delete hRate2orig;
2659     }
2660   }  // ErrorsB in HO
2661 
2662   //====================================================================== done by Andrius for HF:
2663   //====================================================================== done by Andrius for HF:
2664   //====================================================================== done by Andrius for HF:
2665   // Special test of errors type A and B in HF
2666 
2667   int flagErrAB_HF[2];
2668   flagErrAB_HF[0] = -1;
2669   flagErrAB_HF[1] = -1;
2670   double avedelta_HF = 0.;
2671   int lastLumiBin_HF = -1;
2672   int LSofFirstErrB_HF = -1;
2673   {
2674     const int specCountA = 4;
2675     const int specColors[specCountA] = {1, 2, 3, 4};
2676     const TString hnames[specCountA][2] = {{"h_sumADCAmplperLS6_P1", "h_sum0ADCAmplperLS6_P1"},
2677                                            {"h_sumADCAmplperLS6_P2", "h_sum0ADCAmplperLS6_P2"},
2678                                            {"h_sumADCAmplperLS6_M1", "h_sum0ADCAmplperLS6_M1"},
2679                                            {"h_sumADCAmplperLS6_M2", "h_sum0ADCAmplperLS6_M2"}};
2680 
2681     std::vector<TH1F *> hV;
2682     THStack *hs = new THStack("hs", "ADCAmplerLS6");
2683     cHB->Clear();
2684     //    cHB->cd();
2685     cHB->Divide(2, 1);
2686     cHB->cd(1);
2687 
2688     ///////////////////////////////////////////////////////////////////////////
2689     for (int i = 0; i < specCountA; i++) {
2690       if (1)
2691         std::cout << "debugger: errA_HF : get histos for i=" << i << " " << hnames[i][0] << " and " << hnames[i][1]
2692                   << "\n";
2693       TH1F *h1 = (TH1F *)dir->FindObjectAny(hnames[i][0]);
2694       TH1F *h0 = (TH1F *)dir->FindObjectAny(hnames[i][1]);
2695       if (!h1 || !h0) {
2696         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2697         ptext->AddText("Missing histo");
2698         if (!h1) {
2699           std::cout << "\tfailed to get " << hnames[i][0] << "\n";
2700           ptext->AddText(hnames[i][0]);
2701         }
2702         if (!h0) {
2703           std::cout << "\tfailed to get " << hnames[i][1] << "\n";
2704           ptext->AddText(hnames[i][1]);
2705         }
2706         ptext->Draw();
2707         continue;
2708       }
2709       TH1F *hERT1orig = (TH1F *)h1->Clone(Form("ERT1orig_%d", i));
2710       hERT1orig->Divide(h1, h0, 1, 1, "B");
2711 
2712       if ((lastLumiBin_HF < 0) && (i == 0)) {
2713         for (int ibin = hERT1orig->GetNbinsX(); ibin >= 1; ibin--) {
2714           if (hERT1orig->GetBinContent(ibin) == 0)
2715             lastLumiBin_HF = ibin;
2716           else
2717             break;
2718         }
2719         lastLumiBin_HF += 3;  // show more bins
2720         if (lastLumiBin_HF >= hERT1orig->GetNbinsX())
2721           lastLumiBin_HF = -1;
2722       }
2723       TH1F *hERT1 = NULL;
2724       if (lastLumiBin_HF > 1) {
2725         if (!copyContents(&hERT1, Form("ERT1_%d", i), "", hERT1orig, lastLumiBin_HF)) {
2726           std::cout << "code failed" << std::endl;
2727           gSystem->Exit(1);
2728         }
2729       } else
2730         hERT1 = hERT1orig;
2731 
2732       hERT1->GetXaxis()->SetTitle("<ADCAmpl> per LS HF: black-P1, red-P2,green-M1,blue-M2");
2733       hV.push_back(hERT1);
2734       hERT1->SetMarkerStyle(20);
2735       hERT1->SetMarkerSize(0.4);
2736       hERT1->SetXTitle("<A>(ev.in LS & ch.) - HF P1     -    iLS \b");
2737       hERT1->SetMarkerColor(specColors[i]);
2738       hERT1->SetLineColor(0);
2739       hs->Add(hERT1);
2740       delete h1;
2741       delete h0;
2742       if (hERT1 != hERT1orig)
2743         delete hERT1orig;
2744     }  /////////////////////////////////////////////////////////////////////////
2745     hs->Draw("LPE1 nostack");
2746     cHB->Update();  // activate the axes
2747     hs->GetXaxis()->SetTitle("<A> per LS: black-P1, red-P2,green-M1,blue-M2");
2748     hs->Draw("LPE1 nostack");
2749     gPad->SetGridy();
2750     /////////////////////////////////////////////////////////////////////////////////////////
2751 
2752     // AZ corrections 04.02.2016
2753     cHB->cd(2);
2754     TH1F *diff = new TH1F("diff", "", 100, 0., 4.);
2755 
2756     if (int(hV.size()) == specCountA) {
2757       flagErrAB_HF[0] = 0;  // If we have the expected number of histograms, set the flag
2758       double sumdelta = 0.;
2759       int nnndelta = 0;
2760       std::cout << "********   GetNbinsX  = " << hV[0]->GetNbinsX() << std::endl;
2761       for (int ibin = 1; ibin <= hV[0]->GetNbinsX(); ibin++) {
2762         double delta = 0.;
2763         double maxdelta = 0.;
2764         for (unsigned int i = 0; i < hV.size(); i++) {
2765           const TH1F *hi = hV[i];
2766           for (unsigned int j = 1; j < hV.size(); j++) {
2767             const TH1F *hj = hV[j];
2768             delta = fabs(hi->GetBinContent(ibin) - hj->GetBinContent(ibin));
2769             if (delta > maxdelta)
2770               maxdelta = delta;
2771           }  //for
2772         }    //for
2773         //  std::cout << "*****      ibin = " << ibin << " nnndelta= " << nnndelta << " maxdelta= " << maxdelta <<std::endl;
2774         if (maxdelta > 0.) {
2775           diff->Fill(maxdelta);
2776           sumdelta += maxdelta;
2777           nnndelta++;
2778         }
2779       }  //for ibin
2780       //      avedelta_HF = sumdelta/hV[0]->GetNbinsX();
2781       avedelta_HF = sumdelta / nnndelta;
2782       //      std::cout << "******************>>>>>>      ErrA_HF:  avedelta_HF = " << avedelta_HF << " Npoints for comparison= " << nnndelta <<std::endl;
2783       if (avedelta_HF > 2.4 || (avedelta_HF < 0.8 && avedelta_HF > 0.)) {
2784         flagErrAB_HF[0] = 1;
2785       }  //if
2786     }    //hV.size
2787     diff->SetMarkerStyle(20);
2788     diff->SetMarkerSize(0.8);
2789     diff->SetXTitle("max difference \b");
2790     diff->SetMarkerColor(2);
2791     diff->SetLineColor(0);
2792     gPad->SetGridx();
2793     gPad->SetLogy();
2794     diff->Draw("Error");
2795     /////////////////////////////////////////////////////////////////////////
2796     cHB->Update();
2797     cHB->Print("HistErrA_HF.png");
2798     cHB->Clear();
2799     /////////////////////////////////////////////////////////////////////////
2800     // clean-up
2801     if (diff)
2802       delete diff;
2803     for (unsigned int i = 0; i < hV.size(); i++)
2804       delete hV[i];
2805   }  // ErrorA in HF
2806   ////////////////////////////////////////////////////////// errors B:
2807   /////////////////////////
2808   {  // errors type B
2809     const int specCountB = 4;
2810     const TString hnames[specCountB][2] = {{"h_2DsumErrorBLS6", "h_2D0sumErrorBLS6"},
2811                                            {"h_sumErrorBperLS6", "h_sum0ErrorBperLS6"},
2812                                            {"h_2DsumErrorBLS7", "h_2D0sumErrorBLS7"},
2813                                            {"h_sumErrorBperLS7", "h_sum0ErrorBperLS7"}};
2814 
2815     for (int depth = 1; depth <= 2; depth++) {
2816       cHB->Clear();
2817       cHB->Divide(2, 1);
2818       cHB->cd(1);
2819       TH1F *hRate2orig = NULL;
2820       TH2F *h2Cefz6 = NULL;
2821       TString hname1 = hnames[2 * depth - 2][0];
2822       TString hname0 = hnames[2 * depth - 2][1];
2823       TH2F *twod1 = (TH2F *)dir->FindObjectAny(hname1);
2824       TH2F *twod0 = (TH2F *)dir->FindObjectAny(hname0);
2825       if (1)
2826         std::cout << "debugger: errB_HF depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2827       if (!twod1 || !twod0) {
2828         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2829         ptext->AddText("Missing histos");
2830         if (!twod1) {
2831           std::cout << "\tfailed to get " << hname1 << "\n";
2832           ptext->AddText(hname1);
2833         }
2834         if (!twod0) {
2835           std::cout << "\tfailed to get " << hname0 << "\n";
2836           ptext->AddText(hname0);
2837         }
2838         ptext->Draw();
2839       } else {
2840         h2Cefz6 = (TH2F *)twod1->Clone(Form("Cefz6_%d", depth));
2841         h2Cefz6->SetTitle(Form("HF Depth %d \b", depth));
2842         h2Cefz6->Divide(twod1, twod0, 1, 1, "B");
2843 
2844         gPad->SetGridy();
2845         gPad->SetGridx();
2846         gPad->SetLogz();
2847         h2Cefz6->SetTitle(Form("Depth %d \b", depth));
2848         h2Cefz6->SetMarkerStyle(20);
2849         h2Cefz6->SetMarkerSize(0.4);
2850         //  h2Cefz6->GetZaxis()->SetLabelSize(0.04);
2851         h2Cefz6->SetXTitle("#eta \b");
2852         h2Cefz6->SetYTitle("#phi \b");
2853         h2Cefz6->SetZTitle(Form("<ErrorB>  - HF Depth%d \b", depth));
2854         h2Cefz6->SetMarkerColor(2);
2855         h2Cefz6->SetLineColor(2);
2856         h2Cefz6->Draw("COLZ");
2857         delete twod1;
2858         delete twod0;
2859       }  // histos ok
2860       cHB->cd(2);
2861       hname1 = hnames[2 * depth - 1][0];
2862       hname0 = hnames[2 * depth - 1][1];
2863       TH1F *h1 = (TH1F *)dir->FindObjectAny(hname1);
2864       TH1F *h0 = (TH1F *)dir->FindObjectAny(hname0);
2865       if (1)
2866         std::cout << "errB_HF depth=" << depth << ". get 2D histos " << hname1 << " and " << hname0 << "\n";
2867       if (!h1 || !h0) {
2868         TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2869         ptext->AddText("Missing histo");
2870         if (!h1) {
2871           std::cout << "\tfailed to get " << hname1 << "\n";
2872           ptext->AddText(hname1);
2873         }
2874         if (!h0) {
2875           std::cout << "\tfailed to get " << hname0 << "\n";
2876           ptext->AddText(hname0);
2877         }
2878         ptext->Draw();
2879       } else {
2880         gPad->SetGridx();
2881         gPad->SetGridy();
2882         //  gPad->SetLogy();
2883         hRate2orig = (TH1F *)h1->Clone(Form("Rate2orig_%d", depth));
2884         hRate2orig->Divide(h1, h0, 1, 1, "B");
2885 
2886         TH1F *hRate2 = NULL;
2887         if (lastLumiBin_HF > 1) {
2888           if (!copyContents(&hRate2, Form("Rate2_%d", depth), "", hRate2orig, lastLumiBin_HF)) {
2889             std::cout << "code failed" << std::endl;
2890             gSystem->Exit(1);
2891           }
2892         } else
2893           hRate2 = hRate2orig;
2894         hRate2->SetTitle(Form("Depth %d \b", depth));
2895         hRate2->SetMarkerStyle(20);
2896         hRate2->SetMarkerSize(0.8);
2897         //  hRate2->GetZaxis()->SetLabelSize(0.04);
2898         hRate2->SetXTitle(Form("<ErrorB>(ev.in LS & ch.) - HF depth%d -    iLS \b", depth));
2899         hRate2->SetMarkerColor(2);
2900         hRate2->SetLineColor(0);
2901         hRate2->Draw("Error");
2902         if (LSofFirstErrB_HF == -1) {
2903           int nx = hRate2->GetXaxis()->GetNbins();
2904           for (int i = 1; i <= nx; i++) {
2905             double ccc1 = hRate2->GetBinContent(i);
2906             if (ccc1 > 0.) {
2907               cout << "****************>>>>>>>>>>> ErrB_HF bad LS start at iLS = " << i << " with rate = " << ccc1
2908                    << endl;
2909               LSofFirstErrB_HF = i;
2910               break;
2911             }
2912           }
2913         }
2914         delete h1;
2915         delete h0;
2916         if (hRate2 != hRate2orig) {
2917           delete hRate2orig;
2918           hRate2orig = hRate2;
2919         }
2920       }
2921       cHB->Update();
2922       cHB->Print(Form("HistErrB_HF_%d.png", depth));
2923       cHB->Clear();
2924       if (h2Cefz6)
2925         delete h2Cefz6;
2926       if (hRate2orig)
2927         delete hRate2orig;
2928     }
2929   }  // ErrorsB in HF
2930 
2931   /////////////////  Cross-check A-errors & Occupancies:
2932 
2933   //===============================================================================  err A HB
2934   /// errA with average Amplitudes
2935   // For  2D and  1D plots with Amplitude. Produces ChkErrA_HBx.png
2936 
2937   for (int depth = 1; depth <= 2; depth++) {
2938     TH2F *h2Ceff = NULL;
2939     TH2F *h2Diffe = NULL;
2940     //    TH1F* h1diffADCAmpl= NULL;
2941     TH2F *h3Ceff = NULL;
2942 
2943     cHE->Clear();
2944     cHE->Divide(3, 1);
2945 
2946     cHE->cd(1);
2947     // h_mapDepth1ADCAmpl_HB div h_mapDepth1_HB
2948     TString hname1 = Form("h_mapDepth%dADCAmpl_HB", depth);
2949     TString hname0 = Form("h_mapDepth%d_HB", depth);
2950     TH2F *twod1 = (TH2F *)dir->FindObjectAny(hname1);
2951     TH2F *twod0 = (TH2F *)dir->FindObjectAny(hname0);
2952     if (!twod1 || !twod0) {
2953       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
2954       ptext->AddText("Missing histo");
2955       std::cout << "specHB test: failed to load " << hname1 << " and/or " << hname0 << "\n";
2956       if (!twod1)
2957         ptext->AddText(hname1);
2958       if (!twod0)
2959         ptext->AddText(hname0);
2960       ptext->Draw();
2961       continue;
2962     } else {
2963       // To IDENTIFY: see color different bins in eta-phi space
2964       h2Ceff = (TH2F *)twod1->Clone(Form("Ceff_HB%d", depth));
2965       h2Ceff->SetTitle(Form("HB Depth %d. (No cut) \b", depth));
2966       h2Ceff->Divide(twod1, twod0, 1, 1, "B");
2967 
2968       gPad->SetGridy();
2969       gPad->SetGridx();
2970       gPad->SetLogz();
2971       h2Ceff->SetMarkerStyle(20);
2972       h2Ceff->SetMarkerSize(0.4);
2973       //h2Ceff->GetZaxis()->SetLabelSize(0.08);
2974       h2Ceff->SetXTitle("#eta \b");
2975       h2Ceff->SetYTitle("#phi \b");
2976       h2Ceff->SetZTitle("h_mapDepth1ADCAmpl_HB \b");
2977       h2Ceff->SetMarkerColor(2);
2978       h2Ceff->SetLineColor(2);
2979       h2Ceff->Draw("COLZ");
2980     }
2981 
2982     cHE->cd(2);
2983     ///////////////////////////////////////
2984     if (h2Ceff) {
2985       // TO IDENTIFY: see red bins in eta-phi space
2986       h2Diffe = (TH2F *)h2Ceff->Clone(Form("Diffe_Depth%d_HB", depth));
2987       h2Diffe->SetTitle(Form("HB Depth %d. Cut avg(ADCAmpl) > 25 \b", depth));
2988       int nx = h2Ceff->GetXaxis()->GetNbins();
2989       int ny = h2Ceff->GetYaxis()->GetNbins();
2990       for (int i = 1; i <= nx; i++) {
2991         for (int j = 1; j <= ny; j++) {
2992           double ccc1 = h2Ceff->GetBinContent(i, j);
2993           h2Diffe->SetBinContent(i, j, 0.);
2994           if (ccc1 > 25.)
2995             h2Diffe->SetBinContent(i, j, ccc1);
2996         }
2997       }
2998       gPad->SetGridy();
2999       gPad->SetGridx();
3000       gPad->SetLogz();
3001       h2Diffe->SetMarkerStyle(20);
3002       h2Diffe->SetMarkerSize(0.4);
3003       //h2Diffe->GetZaxis()->SetLabelSize(0.08);
3004       h2Diffe->SetXTitle("#eta \b");
3005       h2Diffe->SetYTitle("#phi \b");
3006       h2Diffe->SetZTitle("<ADCAmpl> bigger 25.- HB Depth1 \b");
3007       h2Diffe->SetMarkerColor(2);
3008       h2Diffe->SetLineColor(2);
3009       h2Diffe->Draw("COLZ");
3010     }
3011 
3012     cHE->cd(3);
3013     TString hname3 = Form("h_mapDepth%dADCAmpl225Copy_HB", depth);
3014     TH2F *twod3 = (TH2F *)dir->FindObjectAny(hname3);
3015     if (!twod3 || !twod0) {
3016       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3017       ptext->AddText("Missing histo");
3018       std::cout << "specHB test: failed to load " << hname3 << " and/or " << hname0 << "\n";
3019       if (!twod3)
3020         ptext->AddText(hname3);
3021       if (!twod0)
3022         ptext->AddText(hname0);
3023       ptext->Draw();
3024       continue;
3025     } else {
3026       // To IDENTIFY: see color different bins in eta-phi space
3027       h3Ceff = (TH2F *)twod3->Clone(Form("CeffA_HB%d", depth));
3028       h3Ceff->SetTitle(Form("HB Depth %d. \b", depth));
3029       h3Ceff->Divide(twod3, twod0, 1, 1, "B");
3030       gPad->SetGridy();
3031       gPad->SetGridx();
3032       gPad->SetLogz();
3033       h3Ceff->SetMarkerStyle(20);
3034       h3Ceff->SetMarkerSize(0.4);
3035       //      h3Ceff->GetZaxis()->SetLabelSize(0.08);
3036       h3Ceff->SetXTitle("#eta \b");
3037       h3Ceff->SetYTitle("#phi \b");
3038       h3Ceff->SetZTitle("rate for channels of HB \b");
3039       h3Ceff->SetMarkerColor(2);
3040       h3Ceff->SetLineColor(2);
3041       h3Ceff->Draw("COLZ");
3042     }
3043 
3044     cHE->Update();
3045     cHE->Print(Form("ChkErrA_HB%d.png", depth));
3046     cHE->Clear();
3047 
3048     if (h2Ceff)
3049       delete h2Ceff;
3050     if (h2Diffe)
3051       delete h2Diffe;
3052     //    if (h1diffADCAmpl) delete h1diffADCAmpl;
3053     //  if (twod0) delete twod0;// do not delete - sometimes causes trouble later
3054     if (twod1)
3055       delete twod1;
3056     if (twod3)
3057       delete twod3;
3058     if (h3Ceff)
3059       delete h3Ceff;
3060   }  // depth
3061 
3062   //===============================================================================  err A HE
3063   /// errA with average Amplitudes
3064   // For  2D and  1D plots with Amplitude. Produces ChkErrA_HEx.png
3065 
3066   for (int depth = 1; depth <= 3; depth++) {
3067     TH2F *h2Ceff = NULL;
3068     TH2F *h2Diffe = NULL;
3069     //    TH1F* h1diffADCAmpl= NULL;
3070     TH2F *h3Ceff = NULL;
3071 
3072     cHE->Clear();
3073     cHE->Divide(3, 1);
3074 
3075     cHE->cd(1);
3076     // h_mapDepth1ADCAmpl_HE div h_mapDepth1_HE
3077     TString hname1 = Form("h_mapDepth%dADCAmpl_HE", depth);
3078     TString hname0 = Form("h_mapDepth%d_HE", depth);
3079     TH2F *twod1 = (TH2F *)dir->FindObjectAny(hname1);
3080     TH2F *twod0 = (TH2F *)dir->FindObjectAny(hname0);
3081     if (!twod1 || !twod0) {
3082       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3083       ptext->AddText("Missing histo");
3084       std::cout << "specHE test: failed to load " << hname1 << " and/or " << hname0 << "\n";
3085       if (!twod1)
3086         ptext->AddText(hname1);
3087       if (!twod0)
3088         ptext->AddText(hname0);
3089       ptext->Draw();
3090       continue;
3091     } else {
3092       // To IDENTIFY: see color different bins in eta-phi space
3093       h2Ceff = (TH2F *)twod1->Clone(Form("Ceff_HE%d", depth));
3094       h2Ceff->SetTitle(Form("HE Depth %d. (No cut) \b", depth));
3095       h2Ceff->Divide(twod1, twod0, 1, 1, "B");
3096 
3097       gPad->SetGridy();
3098       gPad->SetGridx();
3099       gPad->SetLogz();
3100       h2Ceff->SetMarkerStyle(20);
3101       h2Ceff->SetMarkerSize(0.4);
3102       //h2Ceff->GetZaxis()->SetLabelSize(0.08);
3103       h2Ceff->SetXTitle("#eta \b");
3104       h2Ceff->SetYTitle("#phi \b");
3105       h2Ceff->SetZTitle("h_mapDepth1ADCAmpl_HE \b");
3106       h2Ceff->SetMarkerColor(2);
3107       h2Ceff->SetLineColor(2);
3108       h2Ceff->Draw("COLZ");
3109     }
3110 
3111     cHE->cd(2);
3112     ///////////////////////////////////////
3113     if (h2Ceff) {
3114       // TO IDENTIFY: see red bins in eta-phi space
3115       h2Diffe = (TH2F *)h2Ceff->Clone(Form("Diffe_Depth%d_HE", depth));
3116       h2Diffe->SetTitle(Form("HE Depth %d. Cut avg(ADCAmpl) > 1000 fC \b", depth));
3117       int nx = h2Ceff->GetXaxis()->GetNbins();
3118       int ny = h2Ceff->GetYaxis()->GetNbins();
3119       for (int i = 1; i <= nx; i++) {
3120         for (int j = 1; j <= ny; j++) {
3121           double ccc1 = h2Ceff->GetBinContent(i, j);
3122           h2Diffe->SetBinContent(i, j, 0.);
3123           if (ccc1 > 1000.)
3124             h2Diffe->SetBinContent(i, j, ccc1);
3125         }
3126       }
3127       gPad->SetGridy();
3128       gPad->SetGridx();
3129       gPad->SetLogz();
3130       h2Diffe->SetMarkerStyle(20);
3131       h2Diffe->SetMarkerSize(0.4);
3132       //h2Diffe->GetZaxis()->SetLabelSize(0.08);
3133       h2Diffe->SetXTitle("#eta \b");
3134       h2Diffe->SetYTitle("#phi \b");
3135       h2Diffe->SetZTitle("<ADCAmpl> bigger 1000.fC - HE Depth1 \b");
3136       h2Diffe->SetMarkerColor(2);
3137       h2Diffe->SetLineColor(2);
3138       h2Diffe->Draw("COLZ");
3139     }
3140 
3141     cHE->cd(3);
3142     TString hname3 = Form("h_mapDepth%dADCAmpl225Copy_HE", depth);
3143     TH2F *twod3 = (TH2F *)dir->FindObjectAny(hname3);
3144     if (!twod3 || !twod0) {
3145       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3146       ptext->AddText("Missing histo");
3147       std::cout << "specHE test: failed to load " << hname3 << " and/or " << hname0 << "\n";
3148       if (!twod3)
3149         ptext->AddText(hname3);
3150       if (!twod0)
3151         ptext->AddText(hname0);
3152       ptext->Draw();
3153       continue;
3154     } else {
3155       // To IDENTIFY: see color different bins in eta-phi space
3156       h3Ceff = (TH2F *)twod3->Clone(Form("CeffA_HE%d", depth));
3157       h3Ceff->SetTitle(Form("HE Depth %d. \b", depth));
3158       h3Ceff->Divide(twod3, twod0, 1, 1, "B");
3159       gPad->SetGridy();
3160       gPad->SetGridx();
3161       gPad->SetLogz();
3162       h3Ceff->SetMarkerStyle(20);
3163       h3Ceff->SetMarkerSize(0.4);
3164       //      h3Ceff->GetZaxis()->SetLabelSize(0.08);
3165       h3Ceff->SetXTitle("#eta \b");
3166       h3Ceff->SetYTitle("#phi \b");
3167       h3Ceff->SetZTitle("rate for channels of HE \b");
3168       h3Ceff->SetMarkerColor(2);
3169       h3Ceff->SetLineColor(2);
3170       h3Ceff->Draw("COLZ");
3171     }
3172 
3173     cHE->Update();
3174     cHE->Print(Form("ChkErrA_HE%d.png", depth));
3175     cHE->Clear();
3176 
3177     if (h2Ceff)
3178       delete h2Ceff;
3179     if (h2Diffe)
3180       delete h2Diffe;
3181     //    if (h1diffADCAmpl) delete h1diffADCAmpl;
3182     //  if (twod0) delete twod0;// do not delete - sometimes causes trouble later
3183     if (twod1)
3184       delete twod1;
3185     if (twod3)
3186       delete twod3;
3187     if (h3Ceff)
3188       delete h3Ceff;
3189   }  // depth
3190 
3191   //===============================================================================  err A HO
3192   /// errA with average Amplitudes
3193   // For  2D and  1D plots with Amplitude. Produces ChkErrA_HOx.png
3194 
3195   for (int depth = 4; depth <= 4; depth++) {
3196     TH2F *h2Ceff = NULL;
3197     TH2F *h2Diffe = NULL;
3198     //    TH1F* h1diffADCAmpl= NULL;
3199     TH2F *h3Ceff = NULL;
3200 
3201     cHE->Clear();
3202     cHE->Divide(3, 1);
3203 
3204     cHE->cd(1);
3205     // h_mapDepth1ADCAmpl_HO div h_mapDepth1_HO
3206     TString hname1 = Form("h_mapDepth%dADCAmpl_HO", depth);
3207     TString hname0 = Form("h_mapDepth%d_HO", depth);
3208     TH2F *twod1 = (TH2F *)dir->FindObjectAny(hname1);
3209     TH2F *twod0 = (TH2F *)dir->FindObjectAny(hname0);
3210     if (!twod1 || !twod0) {
3211       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3212       ptext->AddText("Missing histo");
3213       std::cout << "specHO test: failed to load " << hname1 << " and/or " << hname0 << "\n";
3214       if (!twod1)
3215         ptext->AddText(hname1);
3216       if (!twod0)
3217         ptext->AddText(hname0);
3218       ptext->Draw();
3219       continue;
3220     } else {
3221       // To IDENTIFY: see color different bins in eta-phi space
3222       h2Ceff = (TH2F *)twod1->Clone(Form("Ceff_HO%d", depth));
3223       h2Ceff->SetTitle(Form("HO Depth %d. (No cut) \b", depth));
3224       h2Ceff->Divide(twod1, twod0, 1, 1, "B");
3225 
3226       gPad->SetGridy();
3227       gPad->SetGridx();
3228       gPad->SetLogz();
3229       h2Ceff->SetMarkerStyle(20);
3230       h2Ceff->SetMarkerSize(0.4);
3231       //h2Ceff->GetZaxis()->SetLabelSize(0.08);
3232       h2Ceff->SetXTitle("#eta \b");
3233       h2Ceff->SetYTitle("#phi \b");
3234       h2Ceff->SetZTitle("h_mapDepth1ADCAmpl_HO \b");
3235       h2Ceff->SetMarkerColor(2);
3236       h2Ceff->SetLineColor(2);
3237       h2Ceff->Draw("COLZ");
3238     }
3239 
3240     cHE->cd(2);
3241     ///////////////////////////////////////
3242     if (h2Ceff) {
3243       // TO IDENTIFY: see red bins in eta-phi space (applied cut on Aij: <20 || >3000
3244       h2Diffe = (TH2F *)h2Ceff->Clone(Form("Diffe_Depth%d_HO", depth));
3245       h2Diffe->SetTitle(Form("HO Depth %d. Cut avg(ADCAmpl) > 80 \b", depth));
3246       int nx = h2Ceff->GetXaxis()->GetNbins();
3247       int ny = h2Ceff->GetYaxis()->GetNbins();
3248       for (int i = 1; i <= nx; i++) {
3249         for (int j = 1; j <= ny; j++) {
3250           double ccc1 = h2Ceff->GetBinContent(i, j);
3251           h2Diffe->SetBinContent(i, j, 0.);
3252           if (ccc1 > 20.)
3253             h2Diffe->SetBinContent(i, j, ccc1);
3254         }
3255       }
3256       gPad->SetGridy();
3257       gPad->SetGridx();
3258       gPad->SetLogz();
3259       h2Diffe->SetMarkerStyle(20);
3260       h2Diffe->SetMarkerSize(0.4);
3261       //h2Diffe->GetZaxis()->SetLabelSize(0.08);
3262       h2Diffe->SetXTitle("#eta \b");
3263       h2Diffe->SetYTitle("#phi \b");
3264       h2Diffe->SetZTitle("<ADCAmpl> bigger 80.- HO Depth1 \b");
3265       h2Diffe->SetMarkerColor(2);
3266       h2Diffe->SetLineColor(2);
3267       h2Diffe->Draw("COLZ");
3268     }
3269 
3270     cHE->cd(3);
3271     TString hname3 = Form("h_mapDepth%dADCAmpl225Copy_HO", depth);
3272     TH2F *twod3 = (TH2F *)dir->FindObjectAny(hname3);
3273     if (!twod3 || !twod0) {
3274       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3275       ptext->AddText("Missing histo");
3276       std::cout << "specHO test: failed to load " << hname3 << " and/or " << hname0 << "\n";
3277       if (!twod3)
3278         ptext->AddText(hname3);
3279       if (!twod0)
3280         ptext->AddText(hname0);
3281       ptext->Draw();
3282       continue;
3283     } else {
3284       // To IDENTIFY: see color different bins in eta-phi space
3285       h3Ceff = (TH2F *)twod3->Clone(Form("CeffA_HO%d", depth));
3286       h3Ceff->SetTitle(Form("HO Depth %d. \b", depth));
3287       h3Ceff->Divide(twod3, twod0, 1, 1, "B");
3288       gPad->SetGridy();
3289       gPad->SetGridx();
3290       gPad->SetLogz();
3291       h3Ceff->SetMarkerStyle(20);
3292       h3Ceff->SetMarkerSize(0.4);
3293       //      h3Ceff->GetZaxis()->SetLabelSize(0.08);
3294       h3Ceff->SetXTitle("#eta \b");
3295       h3Ceff->SetYTitle("#phi \b");
3296       h3Ceff->SetZTitle("rate for channels of HO \b");
3297       h3Ceff->SetMarkerColor(2);
3298       h3Ceff->SetLineColor(2);
3299       h3Ceff->Draw("COLZ");
3300     }
3301 
3302     cHE->Update();
3303     cHE->Print(Form("ChkErrA_HO%d.png", depth));
3304     cHE->Clear();
3305 
3306     if (h2Ceff)
3307       delete h2Ceff;
3308     if (h2Diffe)
3309       delete h2Diffe;
3310     //    if (h1diffADCAmpl) delete h1diffADCAmpl;
3311     //  if (twod0) delete twod0;// do not delete - sometimes causes trouble later
3312     if (twod1)
3313       delete twod1;
3314     if (twod3)
3315       delete twod3;
3316     if (h3Ceff)
3317       delete h3Ceff;
3318   }  // depth
3319 
3320   //===============================================================================  err A HF
3321   /// errA with average Amplitudes
3322   // For  2D and  1D plots with Amplitude. Produces ChkErrA_HFx.png
3323 
3324   for (int depth = 1; depth <= 2; depth++) {
3325     TH2F *h2Ceff = NULL;
3326     TH2F *h2Diffe = NULL;
3327     //    TH1F* h1diffADCAmpl= NULL;
3328     TH2F *h3Ceff = NULL;
3329 
3330     cHE->Clear();
3331     cHE->Divide(3, 1);
3332 
3333     cHE->cd(1);
3334     // h_mapDepth1ADCAmpl_HF div h_mapDepth1_HF
3335     TString hname1 = Form("h_mapDepth%dADCAmpl_HF", depth);
3336     TString hname0 = Form("h_mapDepth%d_HF", depth);
3337     TH2F *twod1 = (TH2F *)dir->FindObjectAny(hname1);
3338     TH2F *twod0 = (TH2F *)dir->FindObjectAny(hname0);
3339     if (!twod1 || !twod0) {
3340       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3341       ptext->AddText("Missing histo");
3342       std::cout << "specHF test: failed to load " << hname1 << " and/or " << hname0 << "\n";
3343       if (!twod1)
3344         ptext->AddText(hname1);
3345       if (!twod0)
3346         ptext->AddText(hname0);
3347       ptext->Draw();
3348       continue;
3349     } else {
3350       // To IDENTIFY: see color different bins in eta-phi space
3351       h2Ceff = (TH2F *)twod1->Clone(Form("Ceff_HF%d", depth));
3352       h2Ceff->SetTitle(Form("HF Depth %d. (No cut) \b", depth));
3353       h2Ceff->Divide(twod1, twod0, 1, 1, "B");
3354 
3355       gPad->SetGridy();
3356       gPad->SetGridx();
3357       gPad->SetLogz();
3358       h2Ceff->SetMarkerStyle(20);
3359       h2Ceff->SetMarkerSize(0.4);
3360       //h2Ceff->GetZaxis()->SetLabelSize(0.08);
3361       h2Ceff->SetXTitle("#eta \b");
3362       h2Ceff->SetYTitle("#phi \b");
3363       h2Ceff->SetZTitle("h_mapDepth1ADCAmpl_HF \b");
3364       h2Ceff->SetMarkerColor(2);
3365       h2Ceff->SetLineColor(2);
3366       h2Ceff->Draw("COLZ");
3367     }
3368 
3369     cHE->cd(2);
3370     ///////////////////////////////////////
3371     if (h2Ceff) {
3372       // TO IDENTIFY: see red bins in eta-phi space (applied cut on Aij: <20 || >3000
3373       h2Diffe = (TH2F *)h2Ceff->Clone(Form("Diffe_Depth%d_HF", depth));
3374       h2Diffe->SetTitle(Form("HF Depth %d. Cut avg(ADCAmpl) > 20 \b", depth));
3375       int nx = h2Ceff->GetXaxis()->GetNbins();
3376       int ny = h2Ceff->GetYaxis()->GetNbins();
3377       for (int i = 1; i <= nx; i++) {
3378         for (int j = 1; j <= ny; j++) {
3379           double ccc1 = h2Ceff->GetBinContent(i, j);
3380           h2Diffe->SetBinContent(i, j, 0.);
3381           if (ccc1 > 20.)
3382             h2Diffe->SetBinContent(i, j, ccc1);
3383         }
3384       }
3385       gPad->SetGridy();
3386       gPad->SetGridx();
3387       gPad->SetLogz();
3388       h2Diffe->SetMarkerStyle(20);
3389       h2Diffe->SetMarkerSize(0.4);
3390       //h2Diffe->GetZaxis()->SetLabelSize(0.08);
3391       h2Diffe->SetXTitle("#eta \b");
3392       h2Diffe->SetYTitle("#phi \b");
3393       h2Diffe->SetZTitle("<ADCAmpl> bigger 20.- HF Depth1 \b");
3394       h2Diffe->SetMarkerColor(2);
3395       h2Diffe->SetLineColor(2);
3396       h2Diffe->Draw("COLZ");
3397     }
3398 
3399     cHE->cd(3);
3400     /*
3401     if (h2Ceff) {
3402       h1diffADCAmpl = new TH1F(Form("diffADCAmpl_Depth%d_HF",depth),"",
3403                    100, -20.,200.);
3404       h1diffADCAmpl->SetTitle(Form("HF Depth %d \b",depth));
3405       int nx = h2Ceff->GetXaxis()->GetNbins();
3406       int ny = h2Ceff->GetYaxis()->GetNbins();
3407       for (int i=1;i<=nx;i++) {
3408     for (int j=1;j<=ny;j++) {
3409       if(h2Ceff->GetBinContent(i,j) !=0 ) {
3410         double ccc1 =  h2Ceff->GetBinContent(i,j) ;
3411         h1diffADCAmpl->Fill(ccc1);
3412       }
3413     }
3414       }
3415       gPad->SetLogy();
3416       h1diffADCAmpl->SetMarkerStyle(20);
3417       h1diffADCAmpl->SetMarkerSize(0.4);
3418       h1diffADCAmpl->GetYaxis()->SetLabelSize(0.04);
3419       h1diffADCAmpl->SetXTitle("<ADCAmpl> in each cell \b");
3420       h1diffADCAmpl->SetMarkerColor(2);
3421       h1diffADCAmpl->SetLineColor(2);
3422       h1diffADCAmpl->Draw("");
3423     }
3424     */
3425     TString hname3 = Form("h_mapDepth%dADCAmpl225Copy_HF", depth);
3426     TH2F *twod3 = (TH2F *)dir->FindObjectAny(hname3);
3427     if (!twod3 || !twod0) {
3428       TPaveText *ptext = new TPaveText(0.05, 0.85, 0.95, 0.95);
3429       ptext->AddText("Missing histo");
3430       std::cout << "specHF test: failed to load " << hname3 << " and/or " << hname0 << "\n";
3431       if (!twod3)
3432         ptext->AddText(hname3);
3433       if (!twod0)
3434         ptext->AddText(hname0);
3435       ptext->Draw();
3436       continue;
3437     } else {
3438       // To IDENTIFY: see color different bins in eta-phi space
3439       h3Ceff = (TH2F *)twod3->Clone(Form("CeffA_HF%d", depth));
3440       h3Ceff->SetTitle(Form("HF Depth %d. \b", depth));
3441       h3Ceff->Divide(twod3, twod0, 1, 1, "B");
3442       gPad->SetGridy();
3443       gPad->SetGridx();
3444       gPad->SetLogz();
3445       h3Ceff->SetMarkerStyle(20);
3446       h3Ceff->SetMarkerSize(0.4);
3447       //      h3Ceff->GetZaxis()->SetLabelSize(0.08);
3448       h3Ceff->SetXTitle("#eta \b");
3449       h3Ceff->SetYTitle("#phi \b");
3450       h3Ceff->SetZTitle("rate for channels of HF \b");
3451       h3Ceff->SetMarkerColor(2);
3452       h3Ceff->SetLineColor(2);
3453       h3Ceff->Draw("COLZ");
3454     }
3455 
3456     cHE->Update();
3457     cHE->Print(Form("ChkErrA_HF%d.png", depth));
3458     cHE->Clear();
3459 
3460     if (h2Ceff)
3461       delete h2Ceff;
3462     if (h2Diffe)
3463       delete h2Diffe;
3464     //    if (h1diffADCAmpl) delete h1diffADCAmpl;
3465     //  if (twod0) delete twod0;// do not delete - sometimes causes trouble later
3466     if (twod1)
3467       delete twod1;
3468     if (twod3)
3469       delete twod3;
3470     if (h3Ceff)
3471       delete h3Ceff;
3472   }  // depth
3473 
3474   std::cout << "************>>>   average Amplitudes done" << std::endl;
3475 
3476   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3477   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3478   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3479   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3480   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3481 
3482   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RBX study:
3483   //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RBX study:
3484   //////////////////////////////////////////////////////////////////////////////////////////////////////// RBX study:
3485   //////////////////////////////////////////////////////////////////////////////////// RBX study:
3486 
3487   cout << " RBX analysis START for  **************************" << endl;
3488   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3489   //  int njeta = 22; int njphi = 18; int lsmax=2600;
3490   int njeta = 22;
3491   int njphi = 18;
3492   int lsmax = 1800;
3493   cout << ">>>>>>>>>>>>>>>>>>>>>>>>     int njeta = 22; int njphi = 18; int lsmax=2600;                        "
3494        << endl;
3495 
3496   double alexall[njeta][njphi][lsmax];
3497 
3498   // for phi tables(!):
3499   double alexhb[njphi][lsmax];
3500   double alexhe[njphi][lsmax];
3501   double alexho[njphi][lsmax];
3502   double alexhf[njphi][lsmax];
3503 
3504   // for eta tables(!):
3505   double blexhb[njeta][lsmax];
3506   double blexhe[njeta][lsmax];
3507   double blexho[njeta][lsmax];
3508   double blexhf[njeta][lsmax];
3509 
3510   cout << ">>>>>>>>>>>>>>>>>>>>>>>>  alexall   [njeta][njphi][lsmax];                         " << endl;
3511   int maxbinsRBX = MaxLum;
3512   int nx = maxbinsRBX;  // # LS
3513   cout << ">>>>>>>>>>>>>>>>>>>>>>>>   maxbinsRBX = MaxLum;                          " << endl;
3514   if (MaxLum > lsmax)
3515     cout << "***********************************   ERROR ERROR ERROR ERROR:   MaxLum > 2600 " << endl;
3516   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
3517 
3518   for (int i = 0; i < nx; i++) {
3519     for (int jphi = 0; jphi < njphi; jphi++) {
3520       alexhb[jphi][i] = 0.;
3521       alexhe[jphi][i] = 0.;
3522       alexho[jphi][i] = 0.;
3523       alexhf[jphi][i] = 0.;
3524 
3525       for (int jeta = 0; jeta < njeta; jeta++) {
3526         if (jphi == 0) {
3527           blexhb[jeta][i] = 0.;
3528           blexhe[jeta][i] = 0.;
3529           blexho[jeta][i] = 0.;
3530           blexhf[jeta][i] = 0.;
3531         }
3532 
3533         alexall[jeta][jphi][i] = 0.;
3534       }
3535     }
3536   }
3537 
3538   //////////
3539   /*
3540       // j = ietaphi = 1- 396
3541        int ietaphimax = 396;
3542       int ny = ietaphimax + 1 ;
3543       for (int j=1;j<ny;j++) {
3544       int jeta = (j-1)/znphi;
3545       int jphi = (j-1)-znphi*jeta+1;// jphi=1-18 
3546       jeta += 1;// jeta = 1-22      }
3547 // Outout is  jeta = 1-22   jphi=1-18 
3548 HB: j = 7,8,9,10            11,12,13,14
3549 HE: j = 3,4,5, 6, 7      14,15,16,17,18     
3550 HO: j = 7,8,9,10            11,12,13,14
3551 HF: j = 0,1,2, 3            18,19,20,21
3552 */
3553 
3554   ////////////////////////////////////////////////////////////////////////////////////     HB::  HBSTART HB: j = 7,8,9,10            11,12,13,14
3555   //======================================================================
3556   //======================================================================
3557   //======================================================================
3558   cout << " RBX general for HB **************************" << endl;
3559   TH2F *Ghb1KKK = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplEtaPhiLs0");
3560   TH2F *Ghb1LLL = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplEtaPhiLs00");
3561   TH2F *Ghb1 = (TH2F *)Ghb1LLL->Clone("Ghb1");
3562   Ghb1->Divide(Ghb1KKK, Ghb1LLL, 1, 1, "B");  // average A
3563   //    Ghb1->Sumw2();
3564   //      int nx = Ghb1->GetXaxis()->GetNbins(); // # LS
3565   int ny = Ghb1->GetYaxis()->GetNbins();  // # jetaphi indexes = 396 = 18*22
3566   //           cout<<"*****************************************      HB 54        ny=     "<< ny <<endl;
3567   for (int j = 1; j <= ny; j++) {
3568     int jeta = (j - 1) / njphi;  // jeta = 0-21
3569     if (jeta > 6 && jeta < 15) {
3570       int jphi = (j - 1) - njphi * jeta;  // jphi=0-17
3571       //       cout<<"HB 54        jeta=     "<< jeta <<"   jphi   =     "<<jphi  <<endl;
3572       // over LS:
3573       for (int i = 1; i <= nx; i++) {
3574         double ccc1 = Ghb1->GetBinContent(i, j);
3575         alexall[jeta][jphi][i - 1] = ccc1;
3576         //               if( i == 1 ) cout<<"HB 54  for LS=1      ccc1=     "<< ccc1 <<endl;
3577         //           if( ccc1 <= 0 ) cout<<"HB 54   ccc1=     "<< ccc1 <<"   iLS=     "<< i <<"   eta=     "<< jeta <<"   phi=     "<< jphi <<endl;
3578         //               cout<<"HB 54   ccc1=     "<< ccc1 <<"   j=     "<< j <<"   iLS=     "<< i <<"   eta=     "<< jeta <<"   phi=     "<< jphi <<endl;
3579       }  //i
3580     }    //if
3581   }      //j
3582   // clean-up
3583   if (Ghb1KKK)
3584     delete Ghb1KKK;
3585   if (Ghb1LLL)
3586     delete Ghb1LLL;
3587   //    if (Ghb1) delete Ghb1;
3588 
3589   //====================================================================== alexhb[k][i]
3590   for (int jphi = 0; jphi < njphi; jphi++) {
3591     for (int i = 0; i < nx; i++) {
3592       double sumccc1 = 0.;
3593       int isum = 0;
3594       for (int jeta = 0; jeta < njeta; jeta++) {
3595         double ccc1 = alexall[jeta][jphi][i];
3596         if (ccc1 > 0.) {
3597           sumccc1 += ccc1;
3598           isum++;
3599         }
3600       }  // for jeta
3601       if (isum > 0.)
3602         sumccc1 /= isum;
3603       alexhb[jphi][i] = sumccc1;
3604     }
3605   }  //for for
3606 
3607   //====================================================================== blexhb[k][i]
3608   for (int keta = 0; keta < njeta; keta++) {
3609     for (int i = 0; i < nx; i++) {
3610       double sumccc1 = 0.;
3611       int isum = 0;
3612       for (int kphi = 0; kphi < njphi; kphi++) {
3613         double ccc1 = alexall[keta][kphi][i];
3614         if (ccc1 > 0.) {
3615           sumccc1 += ccc1;
3616           isum++;
3617         }
3618       }  // for kphi
3619       if (isum > 0.)
3620         sumccc1 /= isum;
3621       blexhb[keta][i] = sumccc1;
3622     }
3623   }  //for for
3624 
3625   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3626   //========================================================================================== 11   HB:: 2D  jeta = 0 - 21       jphi =0 - 17
3627   //======================================================================
3628   //======================================================================
3629   //======================================================================
3630   //======================================================================
3631   cout << "      RBX HB  2D plot *****" << endl;
3632   cRBX1->Clear();
3633   /////////////////
3634   cRBX1->Divide(1, 1);
3635   cRBX1->cd(1);
3636   // int ietaphi = 0; ietaphi = ((k2+1)-1)*nphi + (k3+1) ;  k2=0-neta-1; k3=0-nphi-1; neta=18; nphi=22;
3637   //       TH2F* Ghb42D      = new TH2F("Ghb42D","",   22, -11., 11., 18, 0., 18. );
3638   //       TH2F* Ghb42D0     = new TH2F("Ghb42D0","",  22, -11., 11., 18, 0., 18. );
3639   TH2F *Ghb42D = new TH2F("Ghb42D", "", 23, -11.5, 11.5, 18, 0., 18.);
3640   TH2F *Ghb42D0 = new TH2F("Ghb42D0", "", 23, -11.5, 11.5, 18, 0., 18.);
3641   TH2F *Ghb42DF = (TH2F *)Ghb42D0->Clone("Ghb42DF");
3642   for (int jphi = 0; jphi < njphi; jphi++) {
3643     for (int jeta = 0; jeta < njeta; jeta++) {
3644       for (int i = 0; i < nx; i++) {
3645         double ccc1 = alexall[jeta][jphi][i];
3646         int neweta = jeta - 11 - 0.5;
3647         if (jeta >= 11)
3648           neweta = jeta - 11 + 1.5;
3649         if (ccc1 > 0.) {
3650           Ghb42D->Fill(neweta, jphi, ccc1);
3651           Ghb42D0->Fill(neweta, jphi, 1.);
3652         }
3653         //       if(ccc1>0.) {Ghb42D ->Fill(jeta-11,jphi,ccc1); Ghb42D0 ->Fill(jeta-11,jphi,1.); }
3654       }
3655     }
3656   }
3657   Ghb42DF->Divide(Ghb42D, Ghb42D0, 1, 1, "B");  // average A
3658   //    Ghb1->Sumw2();
3659   gPad->SetGridy();
3660   gPad->SetGridx();  //      gPad->SetLogz();
3661   Ghb42DF->SetMarkerStyle(20);
3662   Ghb42DF->SetMarkerSize(0.4);
3663   Ghb42DF->GetZaxis()->SetLabelSize(0.04);
3664   Ghb42DF->SetXTitle("<A>_RBX         #eta  \b");
3665   Ghb42DF->SetYTitle("      #phi \b");
3666   Ghb42DF->SetZTitle("<A>_RBX  - All \b");
3667   Ghb42DF->SetMarkerColor(2);
3668   Ghb42DF->SetLineColor(2);  //      Ghb42DF->SetMaximum(1.000);  //      Ghb42DF->SetMinimum(1.0);
3669   Ghb42DF->Draw("COLZ");
3670 
3671   /////////////////
3672   cRBX1->Update();
3673   cRBX1->Print("RBX-HB-2Dplot.png");
3674   cRBX1->Clear();
3675   // clean-up
3676   if (Ghb42D)
3677     delete Ghb42D;
3678   if (Ghb42D0)
3679     delete Ghb42D0;
3680   if (Ghb42DF)
3681     delete Ghb42DF;
3682 
3683   //========================================================================================== 61   HB:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
3684   //======================================================================
3685   //======================================================================
3686   //======================================================================
3687   //======================================================================
3688   cout << "      RBX HB  1D plot *****" << endl;
3689   cRBX1->Clear();
3690   /////////////////
3691   cRBX1->Divide(1, 1);
3692   cRBX1->cd(1);
3693   TH1F *GphiHB1D = new TH1F("GphiHB1D", "", 18, 0., 18.);
3694   TH1F *GphiHB1D0 = new TH1F("GphiHB1D0", "", 18, 0., 18.);
3695   TH1F *GphiHB1DF = (TH1F *)GphiHB1D0->Clone("GphiHB1DF");
3696   for (int jphi = 0; jphi < 18; jphi++) {
3697     for (int jeta = 0; jeta < 22; jeta++) {
3698       for (int i = 0; i < nx; i++) {
3699         double ccc1 = alexall[jeta][jphi][i];
3700         if (ccc1 > 0.) {
3701           GphiHB1D->Fill(jphi, ccc1);
3702           GphiHB1D0->Fill(jphi, 1.);
3703         }
3704       }
3705     }
3706   }
3707   //     GphiHB1D->Sumw2();GphiHB1D0->Sumw2();
3708   GphiHB1DF->Divide(GphiHB1D, GphiHB1D0, 1, 1, "B");  // average A
3709                                                       //     GphiHB1DF->Sumw2();
3710   for (int jphi = 1; jphi < 19; jphi++) {
3711     GphiHB1DF->SetBinError(jphi, 0.01);
3712   }
3713   gPad->SetGridy();
3714   gPad->SetGridx();  //      gPad->SetLogz();
3715   GphiHB1DF->SetMarkerStyle(20);
3716   GphiHB1DF->SetMarkerSize(1.4);
3717   GphiHB1DF->GetZaxis()->SetLabelSize(0.08);
3718   GphiHB1DF->SetXTitle("PHI of RBX\b");
3719   GphiHB1DF->SetYTitle(" <Amplitude> \b");
3720   GphiHB1DF->SetZTitle("<A>_PHI  - All \b");
3721   GphiHB1DF->SetMarkerColor(4);
3722   GphiHB1DF->SetLineColor(4);
3723   GphiHB1DF->SetMinimum(0.8);  //      GphiHB1DF->SetMaximum(1.000);
3724   GphiHB1DF->Draw("Error");
3725   /////////////////
3726   cRBX1->Update();
3727   cRBX1->Print("RBX-HB-1Dplot.png");
3728   cRBX1->Clear();
3729   // clean-up
3730   if (GphiHB1D)
3731     delete GphiHB1D;
3732   if (GphiHB1D0)
3733     delete GphiHB1D0;
3734   if (GphiHB1DF)
3735     delete GphiHB1DF;
3736 
3737   //========================================================================================== 62   HB:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
3738   //======================================================================
3739   //======================================================================
3740   //======================================================================
3741   //======================================================================
3742   cout << "      RBX HB 11D plot *eta*" << endl;
3743   cRBX1->Clear();
3744   /////////////////
3745   cRBX1->Divide(1, 1);
3746   cRBX1->cd(1);
3747   TH1F *GetaHB11D = new TH1F("GetaHB11D", "", 23, -11.5, 11.5);
3748   TH1F *GetaHB11D0 = new TH1F("GetaHB11D0", "", 23, -11.5, 11.5);
3749   TH1F *GetaHB11DF = (TH1F *)GetaHB11D0->Clone("GetaHB11DF");
3750 
3751   for (int jeta = 0; jeta < 22; jeta++) {
3752     for (int jphi = 0; jphi < 18; jphi++) {
3753       for (int i = 0; i < nx; i++) {
3754         double ccc1 = alexall[jeta][jphi][i];
3755         int neweta = jeta - 11 - 0.5;
3756         if (jeta >= 11)
3757           neweta = jeta - 11 + 1.5;
3758         if (ccc1 > 0.) {
3759           GetaHB11D->Fill(neweta, ccc1);
3760           GetaHB11D0->Fill(neweta, 1.);
3761           //           if( i == 0 ) cout<<"62  HB:  ibin=  "<< i <<"      jphi= "<< jphi <<"      jeta= "<< jeta <<"      A= "<< ccc1 <<endl;
3762         }
3763       }
3764     }
3765   }
3766   //     GetaHB11D->Sumw2();GetaHB11D0->Sumw2();
3767   GetaHB11DF->Divide(GetaHB11D, GetaHB11D0, 1, 1, "B");  // average A
3768                                                          //     GetaHB11DF->Sumw2();
3769   for (int jeta = 1; jeta < 24; jeta++) {
3770     GetaHB11DF->SetBinError(jeta, 0.01);
3771   }
3772   gPad->SetGridy();
3773   gPad->SetGridx();  //      gPad->SetLogz();
3774   GetaHB11DF->SetMarkerStyle(20);
3775   GetaHB11DF->SetMarkerSize(1.4);
3776   GetaHB11DF->GetZaxis()->SetLabelSize(0.08);
3777   GetaHB11DF->SetXTitle("#eta  \b");
3778   GetaHB11DF->SetYTitle("  <A> \b");
3779   GetaHB11DF->SetZTitle("<A>_ETA  - All \b");
3780   GetaHB11DF->SetMarkerColor(4);
3781   GetaHB11DF->SetLineColor(4);
3782   GetaHB11DF->SetMinimum(0.8);  //      GetaHB11DF->SetMaximum(1.000);
3783   GetaHB11DF->Draw("Error");
3784 
3785   /////////////////
3786   cRBX1->Update();
3787   cRBX1->Print("RBX-HB-11Dplot.png");
3788   cRBX1->Clear();
3789   // clean-up
3790   if (GetaHB11D)
3791     delete GetaHB11D;
3792   if (GetaHB11D0)
3793     delete GetaHB11D0;
3794   if (GetaHB11DF)
3795     delete GetaHB11DF;
3796 
3797   //========================================================================================== 22   HB:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
3798   //======================================================================
3799   //======================================================================22.11.2018
3800   //======================================================================
3801   //======================================================================
3802 
3803   gStyle->SetOptStat(1110000);
3804   cout << "      RBX HB  Ratio plots *****" << endl;
3805   cRBX31->Clear();
3806   /////////////////
3807   // gain stabilitY:
3808   // Rij = Aij / A1j , where i-over LSs, j-channels
3809   //
3810   //    nx = maxbinsRBX; // # LS
3811   //
3812   double ccc0HB = 0.;
3813   cRBX31->Divide(3, 1);
3814   //================
3815   cRBX31->cd(1);
3816   //    TH1F* Ghb5 = new TH1F("Ghb5","", nx, 1., nx+1.);
3817   TH1F *Ghb51 = new TH1F("Ghb51", "", nx, 1., nx + 1.);
3818   TH1F *Ghb50 = new TH1F("Ghb50", "", nx, 1., nx + 1.);
3819   TH1F *Ghb5 = (TH1F *)Ghb50->Clone("Ghb5");
3820   // j - etaphi index:
3821   for (int j = 1; j <= ny; j++) {
3822     ccc0HB = Ghb1->GetBinContent(1, j);
3823     //  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;} }
3824     if (ccc0HB <= 0.)
3825       for (int i = 1; i <= nx; i++) {
3826         double ccc2 = Ghb1->GetBinContent(i, j);
3827         if (ccc2 > 0.) {
3828           ccc0HB = ccc2;
3829           break;
3830         }
3831       }
3832     if (ccc0HB > 0.) {
3833       // i - # LSs:
3834       for (int i = 1; i <= nx; i++) {
3835         double ccc1 = Ghb1->GetBinContent(i, j);
3836         if (ccc1 > 0.) {
3837           double Rij = ccc1 / ccc0HB;
3838           //          Ghb5 ->Fill( float(i), Rij);
3839           Ghb51->Fill(float(i), Rij);
3840           Ghb50->Fill(float(i), 1.);
3841         }
3842       }
3843     }
3844   }
3845   Ghb5->Divide(Ghb51, Ghb50, 1, 1, "B");  // average A
3846   for (int i = 1; i <= nx; i++) {
3847     Ghb5->SetBinError(i, 0.0001);
3848   }
3849   Ghb5->SetMarkerStyle(20);
3850   Ghb5->SetMarkerSize(0.4);
3851   Ghb5->GetYaxis()->SetLabelSize(0.04);
3852   Ghb5->SetMarkerColor(2);
3853   Ghb5->SetLineColor(0);
3854   Ghb5->SetXTitle("        iLS  \b");
3855   Ghb5->SetYTitle("     <R> \b");
3856   Ghb5->SetTitle("<Ri> vs iLS \b");
3857   Ghb5->SetMinimum(0.);  //Ghb5->SetMaximum(2.5);
3858   //            gPad->SetLogy();
3859   gPad->SetGridy();
3860   gPad->SetGridx();
3861   Ghb5->SetStats(0);
3862   Ghb5->GetYaxis()->SetLabelSize(0.025);
3863   Ghb5->Draw("Error");
3864   //================
3865   cRBX31->cd(2);
3866   TH2F *Ghb60 = new TH2F("Ghb60", "", 22, -11., 11., 18, 0., 18.);
3867   TH2F *Ghb61 = new TH2F("Ghb61", "", 22, -11., 11., 18, 0., 18.);
3868   TH2F *Ghb6 = new TH2F("Ghb6", "", 22, -11., 11., 18, 0., 18.);
3869 
3870   TH2F *G20hb60 = new TH2F("G20hb60", "", 22, -11., 11., 18, 0., 18.);
3871   TH2F *G20hb61 = new TH2F("G20hb61", "", 22, -11., 11., 18, 0., 18.);
3872   TH2F *G20hb6 = new TH2F("G20hb6", "", 22, -11., 11., 18, 0., 18.);
3873   TH2F *G30hb60 = new TH2F("G30hb60", "", 22, -11., 11., 18, 0., 18.);
3874   TH2F *G30hb61 = new TH2F("G30hb61", "", 22, -11., 11., 18, 0., 18.);
3875   TH2F *G30hb6 = new TH2F("G30hb6", "", 22, -11., 11., 18, 0., 18.);
3876   TH2F *G40hb60 = new TH2F("G40hb60", "", 22, -11., 11., 18, 0., 18.);
3877   TH2F *G40hb61 = new TH2F("G40hb61", "", 22, -11., 11., 18, 0., 18.);
3878   TH2F *G40hb6 = new TH2F("G40hb6", "", 22, -11., 11., 18, 0., 18.);
3879   // j - etaphi index; i - # LSs;
3880   //
3881   // define mean and RMS:
3882   double sumjHB = 0.;
3883   int njHB = 0;
3884   double meanjHB = 0.;
3885   for (int j = 1; j <= ny; j++) {
3886     ccc0HB = Ghb1->GetBinContent(1, j);
3887     if (ccc0HB <= 0.)
3888       for (int i = 1; i <= nx; i++) {
3889         double ccc2 = Ghb1->GetBinContent(i, j);
3890         if (ccc2 > 0.) {
3891           ccc0HB = ccc2;
3892           break;
3893         }
3894       }
3895     if (ccc0HB > 0.) {
3896       for (int i = 1; i <= nx; i++) {
3897         double ccc1 = Ghb1->GetBinContent(i, j) / ccc0HB;
3898         if (ccc1 > 0.) {
3899           sumjHB += ccc1;
3900           njHB++;
3901         }
3902       }
3903       meanjHB = sumjHB / njHB;
3904     }
3905   }  // j
3906 
3907   double ssumjHB = 0.;
3908   njHB = 0;
3909   double sigmajHB = 0.;
3910   for (int j = 1; j <= ny; j++) {
3911     ccc0HB = Ghb1->GetBinContent(1, j);
3912     if (ccc0HB <= 0.)
3913       for (int i = 1; i <= nx; i++) {
3914         double ccc2 = Ghb1->GetBinContent(i, j);
3915         if (ccc2 > 0.) {
3916           ccc0HB = ccc2;
3917           break;
3918         }
3919       }
3920     if (ccc0HB > 0.) {
3921       for (int i = 1; i <= nx; i++) {
3922         double ccc1 = Ghb1->GetBinContent(i, j) / ccc0HB;
3923         if (ccc1 > 0.) {
3924           ssumjHB += (ccc1 - meanjHB) * (ccc1 - meanjHB);
3925           njHB++;
3926         }
3927       }
3928       sigmajHB = sqrt(ssumjHB / njHB);
3929     }
3930   }  // j
3931 
3932   double dif3rmsHBMIN = meanjHB - 3 * sigmajHB;
3933   if (dif3rmsHBMIN < 0.)
3934     dif3rmsHBMIN = 0.;
3935   double dif3rmsHBMAX = meanjHB + 3 * sigmajHB;
3936   cout << "22HB-2    meanjHB=  " << meanjHB << "  sigmajHB=  " << sigmajHB << "  dif3rmsHBMIN=  " << dif3rmsHBMIN
3937        << "  dif3rmsHBMAX=  " << dif3rmsHBMAX << endl;
3938 
3939   double MAXdif3rmsHBMIN = dif3rmsHBMIN;
3940   double MINdif3rmsHBMAX = dif3rmsHBMAX;
3941   if (MAXdif3rmsHBMIN < 0.95)
3942     MAXdif3rmsHBMIN = 0.95;
3943   if (MINdif3rmsHBMAX > 1.05)
3944     MINdif3rmsHBMAX = 1.05;
3945   cout << "22HB-2     MAXdif3rmsHBMIN=  " << MAXdif3rmsHBMIN << "     MINdif3rmsHBMAX=  " << MINdif3rmsHBMAX << endl;
3946   //
3947   for (int j = 1; j <= ny; j++) {
3948     ccc0HB = Ghb1->GetBinContent(1, j);
3949     if (ccc0HB <= 0.)
3950       for (int i = 1; i <= nx; i++) {
3951         double ccc2 = Ghb1->GetBinContent(i, j);
3952         if (ccc2 > 0.) {
3953           ccc0HB = ccc2;
3954           break;
3955         }
3956       }
3957     if (ccc0HB > 0.) {
3958       int jeta = (j - 1) / 18;         // jeta = 0-21
3959       int jphi = (j - 1) - 18 * jeta;  // jphi=0-17
3960       // i - # LSs:
3961       for (int i = 1; i <= nx; i++) {
3962         double ccc1 = Ghb1->GetBinContent(i, j);
3963         if (ccc1 > 0.) {
3964           double Rij = ccc1 / ccc0HB;
3965           if (Rij < MAXdif3rmsHBMIN || Rij > MINdif3rmsHBMAX) {
3966             Ghb61->Fill(jeta - 11, jphi, Rij);
3967             Ghb60->Fill(jeta - 11, jphi, 1.);
3968           }
3969           if (Rij < 0.8 || Rij > 1.2) {
3970             G20hb61->Fill(jeta - 11, jphi, Rij);
3971             G20hb60->Fill(jeta - 11, jphi, 1.);
3972           }
3973           if (Rij < 0.7 || Rij > 1.3) {
3974             G30hb61->Fill(jeta - 11, jphi, Rij);
3975             G30hb60->Fill(jeta - 11, jphi, 1.);
3976           }
3977           if (Rij < 0.6 || Rij > 1.4) {
3978             G40hb61->Fill(jeta - 11, jphi, Rij);
3979             G40hb60->Fill(jeta - 11, jphi, 1.);
3980           }
3981         }                                       //if(ccc1>0.
3982       }                                         // i
3983     }                                           //if(ccc0HB>0
3984   }                                             // j
3985   Ghb6->Divide(Ghb61, Ghb60, 1, 1, "B");        // average R
3986   G20hb6->Divide(G20hb61, G20hb60, 1, 1, "B");  // average R
3987   G30hb6->Divide(G30hb61, G30hb60, 1, 1, "B");  // average R
3988   G40hb6->Divide(G40hb61, G40hb60, 1, 1, "B");  // average R
3989 
3990   Ghb6->GetZaxis()->SetLabelSize(0.025);
3991   Ghb6->SetXTitle("             #eta  \b");
3992   Ghb6->SetYTitle("      #phi \b");
3993   Ghb6->SetTitle("<Rj> for |1-<R>| > 0.05 \b");
3994   Ghb6->SetStats(0);
3995   Ghb6->Draw("COLZ");
3996   //================
3997   cRBX31->cd(3);
3998   TH1F *Ghb7 = new TH1F("Ghb7", "", 120, 0.4, 1.6);
3999   // j - etaphi index:
4000   for (int j = 1; j <= ny; j++) {
4001     ccc0HB = Ghb1->GetBinContent(1, j);
4002     if (ccc0HB <= 0.)
4003       for (int i = 1; i <= nx; i++) {
4004         double ccc2 = Ghb1->GetBinContent(i, j);
4005         if (ccc2 > 0.) {
4006           ccc0HB = ccc2;
4007           break;
4008         }
4009       }
4010     if (ccc0HB > 0.) {
4011       // i - # LSs:
4012       for (int i = 1; i <= nx; i++) {
4013         double ccc1 = Ghb1->GetBinContent(i, j);
4014         if (ccc1 > 0.) {
4015           double Rij = ccc1 / ccc0HB;
4016           Ghb7->Fill(Rij);
4017         }
4018       }
4019     }
4020   }
4021   Ghb7->SetMarkerStyle(20);
4022   Ghb7->SetMarkerSize(0.4);
4023   Ghb7->GetYaxis()->SetLabelSize(0.04);
4024   Ghb7->SetMarkerColor(2);
4025   Ghb7->SetLineColor(0);
4026   Ghb7->SetYTitle("        N  \b");
4027   Ghb7->SetXTitle("     Rij \b");
4028   Ghb7->SetTitle(" Rij \b");
4029   //Ghb7->SetMinimum(0.8);Ghb7->SetMaximum(500.);
4030   gPad->SetGridy();
4031   gPad->SetGridx();  //            gPad->SetLogy();
4032   //      Ghb7->SetStats(1110000);
4033   Ghb7->GetYaxis()->SetLabelSize(0.025);
4034   Ghb7->Draw("Error");
4035   Float_t ymaxHB = Ghb7->GetMaximum();
4036   cout << "22HB-3   ymaxHB=  " << ymaxHB << "       MAXdif3rmsHBMIN=  " << MAXdif3rmsHBMIN
4037        << "         MINdif3rmsHBMAX=  " << MINdif3rmsHBMAX << endl;
4038   TLine *lineHB = new TLine(MAXdif3rmsHBMIN, 0., MAXdif3rmsHBMIN, ymaxHB);
4039   lineHB->SetLineColor(kBlue);
4040   lineHB->Draw();
4041   TLine *line1HB = new TLine(MINdif3rmsHBMAX, 0., MINdif3rmsHBMAX, ymaxHB);
4042   line1HB->SetLineColor(kBlue);
4043   line1HB->Draw();
4044   //================
4045   /////////////////
4046   cRBX31->Update();
4047   cRBX31->Print("RBX-HB-3plots.png");
4048   cRBX31->Clear();
4049   // clean-up
4050   if (Ghb5)
4051     delete Ghb5;
4052   if (Ghb60)
4053     delete Ghb60;
4054   if (Ghb61)
4055     delete Ghb61;
4056   if (Ghb6)
4057     delete Ghb6;
4058   if (Ghb7)
4059     delete Ghb7;
4060 
4061   if (G20hb60)
4062     delete G20hb60;
4063   if (G20hb61)
4064     delete G20hb61;
4065   if (G30hb60)
4066     delete G30hb60;
4067   if (G30hb61)
4068     delete G30hb61;
4069   if (G40hb60)
4070     delete G40hb60;
4071   if (G40hb61)
4072     delete G40hb61;
4073 
4074   if (Ghb1)
4075     delete Ghb1;
4076   //========================================================================================== 22-1   HB:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
4077   //======================================================================
4078   //======================================================================28.11.2018
4079   //======================================================================
4080   //======================================================================
4081 
4082   gStyle->SetOptStat(1110000);
4083   cout << "      RBX HB  Ratio plotsmore *****" << endl;
4084   cRBX31->Clear();
4085   /////////////////
4086   cRBX31->Divide(3, 1);
4087   //================
4088   cRBX31->cd(1);
4089   G20hb6->GetZaxis()->SetLabelSize(0.025);
4090   G20hb6->SetXTitle("             #eta  \b");
4091   G20hb6->SetYTitle("      #phi \b");
4092   G20hb6->SetTitle("<Rj> for |1-<R>| > 0.20 \b");
4093   G20hb6->SetStats(0);
4094   G20hb6->Draw("COLZ");
4095   //================
4096   cRBX31->cd(2);
4097   G30hb6->GetZaxis()->SetLabelSize(0.025);
4098   G30hb6->SetXTitle("             #eta  \b");
4099   G30hb6->SetYTitle("      #phi \b");
4100   G30hb6->SetTitle("<Rj> for |1-<R>| > 0.30 \b");
4101   G30hb6->SetStats(0);
4102   G30hb6->Draw("COLZ");
4103   //================
4104   cRBX31->cd(3);
4105   G40hb6->GetZaxis()->SetLabelSize(0.025);
4106   G40hb6->SetXTitle("             #eta  \b");
4107   G40hb6->SetYTitle("      #phi \b");
4108   G40hb6->SetTitle("<Rj> for |1-<R>| > 0.40 \b");
4109   G40hb6->SetStats(0);
4110   G40hb6->Draw("COLZ");
4111   //================
4112 
4113   /////////////////
4114   cRBX31->Update();
4115   cRBX31->Print("RBX-HB-3plotsmore.png");
4116   cRBX31->Clear();
4117 
4118   // clean-up
4119   if (G20hb6)
4120     delete G20hb6;
4121   if (G30hb6)
4122     delete G30hb6;
4123   if (G40hb6)
4124     delete G40hb6;
4125   gStyle->SetOptStat(0);
4126 
4127   ////////////////////////////////////////////////////////////////////////////////////
4128 
4129   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4130   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4131   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4132   for (int jphi = 0; jphi < njphi; jphi++) {
4133     for (int jeta = 0; jeta < njeta; jeta++) {
4134       for (int i = 0; i < nx; i++) {
4135         alexall[jeta][jphi][i] = 0.;
4136       }
4137     }
4138   }  // nulling
4139 
4140   ////////////////////////////////////////////////////////////////////////////////////   end HB RBX
4141 
4142   ////////////////////////////////////////////////////////////////////////////////////     HE::  HESTART HE: j = 3,4,5, 6, 7      14,15,16,17,18
4143   //======================================================================
4144   //======================================================================
4145   //======================================================================
4146   cout << " RBX general for HE **************************" << endl;
4147   TH2F *Ghe1KKK = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplEtaPhiLs1");
4148   TH2F *Ghe1LLL = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplEtaPhiLs10");
4149   TH2F *Ghe1 = (TH2F *)Ghe1LLL->Clone("Ghe1");
4150   Ghe1->Divide(Ghe1KKK, Ghe1LLL, 1, 1, "B");  // average A
4151   //    Ghe1->Sumw2();
4152   //      int nx = Ghe1->GetXaxis()->GetNbins(); // # LS
4153   //    nx = maxbinsRBX; // # LS
4154   ny = Ghe1->GetYaxis()->GetNbins();  // # jetaphi indexes
4155   for (int j = 1; j <= ny; j++) {
4156     int jeta = (j - 1) / njphi;  // jeta = 0-21
4157     if ((jeta < 8 && jeta > 2) || (jeta < 19 && jeta > 13)) {
4158       int jphi = (j - 1) - njphi * jeta;  // jphi=0-17
4159       //       cout<<"HE 54        jeta=     "<< jeta <<"   jphi   =     "<<jphi  <<endl;
4160       // over LS:
4161       for (int i = 1; i <= nx; i++) {
4162         double ccc1 = Ghe1->GetBinContent(i, j);
4163         alexall[jeta][jphi][i - 1] = ccc1;
4164         //       if( i == 1 ) cout<<"HE 54  for LS=1      ccc1=     "<< ccc1 <<endl;
4165       }  //i
4166     }    //if
4167   }      //j
4168   // clean-up
4169   if (Ghe1KKK)
4170     delete Ghe1KKK;
4171   if (Ghe1LLL)
4172     delete Ghe1LLL;
4173   //    if (Ghe1) delete Ghe1;
4174 
4175   //====================================================================== alexhe[k][i]
4176   for (int jphi = 0; jphi < njphi; jphi++) {
4177     for (int i = 0; i < nx; i++) {
4178       double sumccc1 = 0.;
4179       int isum = 0;
4180       for (int jeta = 0; jeta < njeta; jeta++) {
4181         double ccc1 = alexall[jeta][jphi][i];
4182         if (ccc1 > 0.) {
4183           sumccc1 += ccc1;
4184           isum++;
4185         }
4186       }  // for jeta
4187       if (isum > 0.)
4188         sumccc1 /= isum;
4189       alexhe[jphi][i] = sumccc1;
4190     }
4191   }  //for for
4192      //====================================================================== blexhe[k][i]
4193   for (int keta = 0; keta < njeta; keta++) {
4194     for (int i = 0; i < nx; i++) {
4195       double sumccc1 = 0.;
4196       int isum = 0;
4197       for (int kphi = 0; kphi < njphi; kphi++) {
4198         double ccc1 = alexall[keta][kphi][i];
4199         if (ccc1 > 0.) {
4200           sumccc1 += ccc1;
4201           isum++;
4202         }
4203       }  // for kphi
4204       if (isum > 0.)
4205         sumccc1 /= isum;
4206       blexhe[keta][i] = sumccc1;
4207     }
4208   }  //for for
4209   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4210   //========================================================================================== 21   HE:: 2D  jeta = 0 - 21       jphi =0 - 17
4211   //======================================================================
4212   //======================================================================
4213   //======================================================================
4214   //======================================================================
4215   cout << "      RBX HE  2D plot *****" << endl;
4216   cRBX1->Clear();
4217   /////////////////
4218   cRBX1->Divide(1, 1);
4219   cRBX1->cd(1);
4220   // int ietaphi = 0; ietaphi = ((k2+1)-1)*nphi + (k3+1) ;  k2=0-neta-1; k3=0-nphi-1; neta=18; nphi=22;
4221   TH2F *Ghe42D = new TH2F("Ghe42D", "", 23, -11.5, 11.5, 18, 0., 18.);
4222   TH2F *Ghe42D0 = new TH2F("Ghe42D0", "", 23, -11.5, 11.5, 18, 0., 18.);
4223   //       TH2F* Ghe42D      = new TH2F("Ghe42D","",   22, -11., 11., 18, 0., 18. );
4224   //       TH2F* Ghe42D0     = new TH2F("Ghe42D0","",  22, -11., 11., 18, 0., 18. );
4225   TH2F *Ghe42DF = (TH2F *)Ghe42D0->Clone("Ghe42DF");
4226   for (int jphi = 0; jphi < njphi; jphi++) {
4227     for (int jeta = 0; jeta < njeta; jeta++) {
4228       for (int i = 0; i < nx; i++) {
4229         double ccc1 = alexall[jeta][jphi][i];
4230         int neweta = jeta - 11 - 0.5;
4231         if (jeta >= 11)
4232           neweta = jeta - 11 + 1.5;
4233         if (ccc1 > 0.) {
4234           Ghe42D->Fill(neweta, jphi, ccc1);
4235           Ghe42D0->Fill(neweta, jphi, 1.);
4236         }
4237         //       if(ccc1>0.) {Ghe42D ->Fill(jeta-11,jphi,ccc1); Ghe42D0 ->Fill(jeta-11,jphi,1.); }
4238       }
4239     }
4240   }
4241   Ghe42DF->Divide(Ghe42D, Ghe42D0, 1, 1, "B");  // average A
4242   //    Ghe1->Sumw2();
4243   gPad->SetGridy();
4244   gPad->SetGridx();  //      gPad->SetLogz();
4245   Ghe42DF->SetMarkerStyle(20);
4246   Ghe42DF->SetMarkerSize(0.4);
4247   Ghe42DF->GetZaxis()->SetLabelSize(0.04);
4248   Ghe42DF->SetXTitle("<A>_RBX         #eta  \b");
4249   Ghe42DF->SetYTitle("      #phi \b");
4250   Ghe42DF->SetZTitle("<A>_RBX  - All \b");
4251   Ghe42DF->SetMarkerColor(2);
4252   Ghe42DF->SetLineColor(2);  //      Ghe42DF->SetMaximum(1.000);  //      Ghe42DF->SetMinimum(1.0);
4253   Ghe42DF->Draw("COLZ");
4254 
4255   /////////////////
4256   cRBX1->Update();
4257   cRBX1->Print("RBX-HE-2Dplot.png");
4258   cRBX1->Clear();
4259   // clean-up
4260   if (Ghe42D)
4261     delete Ghe42D;
4262   if (Ghe42D0)
4263     delete Ghe42D0;
4264   if (Ghe42DF)
4265     delete Ghe42DF;
4266 
4267   //========================================================================================== 61   HE:: 1D  j = 3,4,5, 6, 7      14,15,16,17,18         jphi =0 - 17
4268   //======================================================================
4269   //======================================================================
4270   //======================================================================
4271   //======================================================================
4272   cout << "      RBX HE  1D plot *****" << endl;
4273   cRBX1->Clear();
4274   /////////////////
4275   cRBX1->Divide(1, 1);
4276   cRBX1->cd(1);
4277   TH1F *GphiHE1D = new TH1F("GphiHE1D", "", 18, 0., 18.);
4278   TH1F *GphiHE1D0 = new TH1F("GphiHE1D0", "", 18, 0., 18.);
4279   TH1F *GphiHE1DF = (TH1F *)GphiHE1D0->Clone("GphiHE1DF");
4280   for (int jphi = 0; jphi < 18; jphi++) {
4281     for (int jeta = 0; jeta < 22; jeta++) {
4282       for (int i = 0; i < nx; i++) {
4283         double ccc1 = alexall[jeta][jphi][i];
4284         if (ccc1 > 0.) {
4285           GphiHE1D->Fill(jphi, ccc1);
4286           GphiHE1D0->Fill(jphi, 1.);
4287         }
4288       }
4289     }
4290   }
4291   //     GphiHE1D->Sumw2();GphiHE1D0->Sumw2();
4292   GphiHE1DF->Divide(GphiHE1D, GphiHE1D0, 1, 1, "B");  // average A
4293                                                       //     GphiHE1DF->Sumw2();
4294   for (int jphi = 1; jphi < 19; jphi++) {
4295     GphiHE1DF->SetBinError(jphi, 0.01);
4296   }
4297   gPad->SetGridy();
4298   gPad->SetGridx();  //      gPad->SetLogz();
4299   GphiHE1DF->SetMarkerStyle(20);
4300   GphiHE1DF->SetMarkerSize(1.4);
4301   GphiHE1DF->GetZaxis()->SetLabelSize(0.08);
4302   GphiHE1DF->SetXTitle("PHI of RBX\b");
4303   GphiHE1DF->SetYTitle(" <Amplitude> \b");
4304   GphiHE1DF->SetZTitle("<A>_PHI  - All \b");
4305   GphiHE1DF->SetMarkerColor(4);
4306   GphiHE1DF->SetLineColor(4);
4307   GphiHE1DF->SetMinimum(0.8);  //      GphiHE1DF->SetMaximum(1.000);
4308   GphiHE1DF->Draw("Error");
4309   /////////////////
4310   cRBX1->Update();
4311   cRBX1->Print("RBX-HE-1Dplot.png");
4312   cRBX1->Clear();
4313   // clean-up
4314   if (GphiHE1D)
4315     delete GphiHE1D;
4316   if (GphiHE1D0)
4317     delete GphiHE1D0;
4318   if (GphiHE1DF)
4319     delete GphiHE1DF;
4320 
4321   //========================================================================================== 62   HE:: 1D  j = 3,4,5, 6, 7      14,15,16,17,18        jphi =0 - 17
4322   //======================================================================
4323   //======================================================================
4324   //======================================================================
4325   //======================================================================
4326   cout << "      RBX HE 11D plot *eta*" << endl;
4327   cRBX1->Clear();
4328   /////////////////
4329   cRBX1->Divide(1, 1);
4330   cRBX1->cd(1);
4331   TH1F *GetaHE11D = new TH1F("GetaHE11D", "", 23, -11.5, 11.5);
4332   TH1F *GetaHE11D0 = new TH1F("GetaHE11D0", "", 23, -11.5, 11.5);
4333   TH1F *GetaHE11DF = (TH1F *)GetaHE11D0->Clone("GetaHE11DF");
4334 
4335   for (int jeta = 0; jeta < 22; jeta++) {
4336     for (int jphi = 0; jphi < 18; jphi++) {
4337       for (int i = 0; i < nx; i++) {
4338         double ccc1 = alexall[jeta][jphi][i];
4339         int neweta = jeta - 11 - 0.5;
4340         if (jeta >= 11)
4341           neweta = jeta - 11 + 1.5;
4342         if (ccc1 > 0.) {
4343           GetaHE11D->Fill(neweta, ccc1);
4344           GetaHE11D0->Fill(neweta, 1.);
4345           //           if( i == 0 ) cout<<"62  HE:  ibin=  "<< i <<"      jphi= "<< jphi <<"      jeta= "<< jeta <<"      A= "<< ccc1 <<endl;
4346         }
4347       }
4348     }
4349   }
4350   //     GetaHE11D->Sumw2();GetaHE11D0->Sumw2();
4351   GetaHE11DF->Divide(GetaHE11D, GetaHE11D0, 1, 1, "B");  // average A
4352                                                          //     GetaHE11DF->Sumw2();
4353   for (int jeta = 1; jeta < 24; jeta++) {
4354     GetaHE11DF->SetBinError(jeta, 0.01);
4355   }
4356   gPad->SetGridy();
4357   gPad->SetGridx();  //      gPad->SetLogz();
4358   GetaHE11DF->SetMarkerStyle(20);
4359   GetaHE11DF->SetMarkerSize(1.4);
4360   GetaHE11DF->GetZaxis()->SetLabelSize(0.08);
4361   GetaHE11DF->SetXTitle("#eta  \b");
4362   GetaHE11DF->SetYTitle("  <A> \b");
4363   GetaHE11DF->SetZTitle("<A>_ETA  - All \b");
4364   GetaHE11DF->SetMarkerColor(4);
4365   GetaHE11DF->SetLineColor(4);
4366   GetaHE11DF->SetMinimum(0.8);  //      GetaHE11DF->SetMaximum(1.000);
4367   GetaHE11DF->Draw("Error");
4368 
4369   /////////////////
4370   cRBX1->Update();
4371   cRBX1->Print("RBX-HE-11Dplot.png");
4372   cRBX1->Clear();
4373   // clean-up
4374   if (GetaHE11D)
4375     delete GetaHE11D;
4376   if (GetaHE11D0)
4377     delete GetaHE11D0;
4378   if (GetaHE11DF)
4379     delete GetaHE11DF;
4380 
4381   //========================================================================================== 22   HE:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
4382   //======================================================================
4383   //======================================================================22.11.2018
4384   //======================================================================
4385   //======================================================================
4386 
4387   gStyle->SetOptStat(1110000);
4388   cout << "      RBX HE  Ratio plots *****" << endl;
4389   cRBX31->Clear();
4390   /////////////////
4391   // gain stabilitY:
4392   // Rij = Aij / A1j , where i-over LSs, j-channels
4393   //
4394   //    nx = maxbinsRBX; // # LS
4395   //
4396   double ccc0HE = 0.;
4397   cRBX31->Divide(3, 1);
4398   //================
4399   cRBX31->cd(1);
4400   //      TH1F* Ghe5 = new TH1F("Ghe5","", nx, 1., nx+1.);
4401   TH1F *Ghe51 = new TH1F("Ghe51", "", nx, 1., nx + 1.);
4402   TH1F *Ghe50 = new TH1F("Ghe50", "", nx, 1., nx + 1.);
4403   TH1F *Ghe5 = (TH1F *)Ghe50->Clone("Ghe5");
4404   // j - etaphi index:
4405   for (int j = 1; j <= ny; j++) {
4406     ccc0HE = Ghe1->GetBinContent(1, j);
4407     //  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;} }
4408     if (ccc0HE <= 0.)
4409       for (int i = 1; i <= nx; i++) {
4410         double ccc2 = Ghe1->GetBinContent(i, j);
4411         if (ccc2 > 0.) {
4412           ccc0HE = ccc2;
4413           break;
4414         }
4415       }
4416     if (ccc0HE > 0.) {
4417       // i - # LSs:
4418       for (int i = 1; i <= nx; i++) {
4419         double ccc1 = Ghe1->GetBinContent(i, j);
4420         if (ccc1 > 0.) {
4421           double Rij = ccc1 / ccc0HE;
4422           //          Ghe5 ->Fill( float(i), Rij);
4423           Ghe51->Fill(float(i), Rij);
4424           Ghe50->Fill(float(i), 1.);
4425         }
4426       }
4427     }
4428   }
4429   Ghe5->Divide(Ghe51, Ghe50, 1, 1, "B");  // average A
4430   for (int i = 1; i <= nx; i++) {
4431     Ghe5->SetBinError(i, 0.0001);
4432   }
4433   Ghe5->SetMarkerStyle(20);
4434   Ghe5->SetMarkerSize(0.4);
4435   Ghe5->GetYaxis()->SetLabelSize(0.04);
4436   Ghe5->SetMarkerColor(2);
4437   Ghe5->SetLineColor(0);
4438   Ghe5->SetXTitle("        iLS  \b");
4439   Ghe5->SetYTitle("     <R> \b");
4440   Ghe5->SetTitle("<Ri> vs iLS \b");
4441   Ghe5->SetMinimum(0.);  //Ghe5->SetMaximum(2.5);
4442   //            gPad->SetLogy();
4443   gPad->SetGridy();
4444   gPad->SetGridx();
4445   Ghe5->SetStats(0);
4446   Ghe5->GetYaxis()->SetLabelSize(0.025);
4447   Ghe5->Draw("Error");
4448   //================
4449   cRBX31->cd(2);
4450   TH2F *Ghe60 = new TH2F("Ghe60", "", 22, -11., 11., 18, 0., 18.);
4451   TH2F *Ghe61 = new TH2F("Ghe61", "", 22, -11., 11., 18, 0., 18.);
4452   TH2F *Ghe6 = new TH2F("Ghe6", "", 22, -11., 11., 18, 0., 18.);
4453 
4454   TH2F *G20he60 = new TH2F("G20he60", "", 22, -11., 11., 18, 0., 18.);
4455   TH2F *G20he61 = new TH2F("G20he61", "", 22, -11., 11., 18, 0., 18.);
4456   TH2F *G20he6 = new TH2F("G20he6", "", 22, -11., 11., 18, 0., 18.);
4457   TH2F *G30he60 = new TH2F("G30he60", "", 22, -11., 11., 18, 0., 18.);
4458   TH2F *G30he61 = new TH2F("G30he61", "", 22, -11., 11., 18, 0., 18.);
4459   TH2F *G30he6 = new TH2F("G30he6", "", 22, -11., 11., 18, 0., 18.);
4460   TH2F *G40he60 = new TH2F("G40he60", "", 22, -11., 11., 18, 0., 18.);
4461   TH2F *G40he61 = new TH2F("G40he61", "", 22, -11., 11., 18, 0., 18.);
4462   TH2F *G40he6 = new TH2F("G40he6", "", 22, -11., 11., 18, 0., 18.);
4463   // j - etaphi index; i - # LSs;
4464   //
4465   // define mean and RMS:
4466   double sumjHE = 0.;
4467   int njHE = 0;
4468   double meanjHE = 0.;
4469   for (int j = 1; j <= ny; j++) {
4470     ccc0HE = Ghe1->GetBinContent(1, j);
4471     if (ccc0HE <= 0.)
4472       for (int i = 1; i <= nx; i++) {
4473         double ccc2 = Ghe1->GetBinContent(i, j);
4474         if (ccc2 > 0.) {
4475           ccc0HE = ccc2;
4476           break;
4477         }
4478       }
4479     if (ccc0HE > 0.) {
4480       for (int i = 1; i <= nx; i++) {
4481         double ccc1 = Ghe1->GetBinContent(i, j) / ccc0HE;
4482         if (ccc1 > 0.) {
4483           sumjHE += ccc1;
4484           njHE++;
4485         }
4486       }
4487       meanjHE = sumjHE / njHE;
4488     }
4489   }  // j
4490 
4491   double ssumjHE = 0.;
4492   njHE = 0;
4493   double sigmajHE = 0.;
4494   for (int j = 1; j <= ny; j++) {
4495     ccc0HE = Ghe1->GetBinContent(1, j);
4496     if (ccc0HE <= 0.)
4497       for (int i = 1; i <= nx; i++) {
4498         double ccc2 = Ghe1->GetBinContent(i, j);
4499         if (ccc2 > 0.) {
4500           ccc0HE = ccc2;
4501           break;
4502         }
4503       }
4504     if (ccc0HE > 0.) {
4505       for (int i = 1; i <= nx; i++) {
4506         double ccc1 = Ghe1->GetBinContent(i, j) / ccc0HE;
4507         if (ccc1 > 0.) {
4508           ssumjHE += (ccc1 - meanjHE) * (ccc1 - meanjHE);
4509           njHE++;
4510         }
4511       }
4512       sigmajHE = sqrt(ssumjHE / njHE);
4513     }
4514   }  // j
4515 
4516   double dif3rmsHEMIN = meanjHE - 3 * sigmajHE;
4517   if (dif3rmsHEMIN < 0.)
4518     dif3rmsHEMIN = 0.;
4519   double dif3rmsHEMAX = meanjHE + 3 * sigmajHE;
4520   cout << "22HE-2    meanjHE=  " << meanjHE << "  sigmajHE=  " << sigmajHE << "  dif3rmsHEMIN=  " << dif3rmsHEMIN
4521        << "  dif3rmsHEMAX=  " << dif3rmsHEMAX << endl;
4522 
4523   double MAXdif3rmsHEMIN = dif3rmsHEMIN;
4524   double MINdif3rmsHEMAX = dif3rmsHEMAX;
4525   if (MAXdif3rmsHEMIN < 0.95)
4526     MAXdif3rmsHEMIN = 0.95;
4527   if (MINdif3rmsHEMAX > 1.05)
4528     MINdif3rmsHEMAX = 1.05;
4529   cout << "22HE-2     MAXdif3rmsHEMIN=  " << MAXdif3rmsHEMIN << "     MINdif3rmsHEMAX=  " << MINdif3rmsHEMAX << endl;
4530   //
4531   for (int j = 1; j <= ny; j++) {
4532     ccc0HE = Ghe1->GetBinContent(1, j);
4533     if (ccc0HE <= 0.)
4534       for (int i = 1; i <= nx; i++) {
4535         double ccc2 = Ghe1->GetBinContent(i, j);
4536         if (ccc2 > 0.) {
4537           ccc0HE = ccc2;
4538           break;
4539         }
4540       }
4541     if (ccc0HE > 0.) {
4542       int jeta = (j - 1) / 18;         // jeta = 0-21
4543       int jphi = (j - 1) - 18 * jeta;  // jphi=0-17
4544       // i - # LSs:
4545       for (int i = 1; i <= nx; i++) {
4546         double ccc1 = Ghe1->GetBinContent(i, j);
4547         if (ccc1 > 0.) {
4548           double Rij = ccc1 / ccc0HE;
4549           if (Rij < MAXdif3rmsHEMIN || Rij > MINdif3rmsHEMAX) {
4550             Ghe61->Fill(jeta - 11, jphi, Rij);
4551             Ghe60->Fill(jeta - 11, jphi, 1.);
4552           }
4553           if (Rij < 0.8 || Rij > 1.2) {
4554             G20he61->Fill(jeta - 11, jphi, Rij);
4555             G20he60->Fill(jeta - 11, jphi, 1.);
4556           }
4557           if (Rij < 0.7 || Rij > 1.3) {
4558             G30he61->Fill(jeta - 11, jphi, Rij);
4559             G30he60->Fill(jeta - 11, jphi, 1.);
4560           }
4561           if (Rij < 0.6 || Rij > 1.4) {
4562             G40he61->Fill(jeta - 11, jphi, Rij);
4563             G40he60->Fill(jeta - 11, jphi, 1.);
4564           }
4565         }                                       //if(ccc1>0.
4566       }                                         // i
4567     }                                           //if(ccc0HE>0
4568   }                                             // j
4569   Ghe6->Divide(Ghe61, Ghe60, 1, 1, "B");        // average R
4570   G20he6->Divide(G20he61, G20he60, 1, 1, "B");  // average R
4571   G30he6->Divide(G30he61, G30he60, 1, 1, "B");  // average R
4572   G40he6->Divide(G40he61, G40he60, 1, 1, "B");  // average R
4573 
4574   //      Ghe6->SetLabelOffset (Float_t offset=0.005, Option_t *axis="X")//Set offset between axis and axis' labels
4575   //      Ghe6->GetZaxis()->SetLabelOffset(-0.05);
4576   Ghe6->GetZaxis()->SetLabelSize(0.025);
4577 
4578   Ghe6->SetXTitle("             #eta  \b");
4579   Ghe6->SetYTitle("      #phi \b");
4580   Ghe6->SetTitle(
4581       "<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);
4582   //gStyle->SetOptStat(kFALSE);
4583   Ghe6->SetStats(0);
4584   Ghe6->Draw("COLZ");
4585   //================
4586   cRBX31->cd(3);
4587   TH1F *Ghe7 = new TH1F("Ghe7", "", 120, 0.4, 1.6);
4588   // j - etaphi index:
4589   for (int j = 1; j <= ny; j++) {
4590     ccc0HE = Ghe1->GetBinContent(1, j);
4591     if (ccc0HE <= 0.)
4592       for (int i = 1; i <= nx; i++) {
4593         double ccc2 = Ghe1->GetBinContent(i, j);
4594         if (ccc2 > 0.) {
4595           ccc0HE = ccc2;
4596           break;
4597         }
4598       }
4599     if (ccc0HE > 0.) {
4600       // i - # LSs:
4601       for (int i = 1; i <= nx; i++) {
4602         double ccc1 = Ghe1->GetBinContent(i, j);
4603         if (ccc1 > 0.) {
4604           double Rij = ccc1 / ccc0HE;
4605           Ghe7->Fill(Rij);
4606         }
4607       }
4608     }
4609   }
4610   Ghe7->SetMarkerStyle(20);
4611   Ghe7->SetMarkerSize(0.4);
4612   Ghe7->GetYaxis()->SetLabelSize(0.04);
4613   Ghe7->SetMarkerColor(2);
4614   Ghe7->SetLineColor(0);
4615   Ghe7->SetYTitle("        N  \b");
4616   Ghe7->SetXTitle("     Rij \b");
4617   Ghe7->SetTitle(" Rij \b");
4618   //Ghe7->SetMinimum(0.8);Ghe7->SetMaximum(500.);
4619   gPad->SetGridy();
4620   gPad->SetGridx();  //            gPad->SetLogy();
4621   //      Ghe7->SetStats(1110000);
4622   Ghe7->GetYaxis()->SetLabelSize(0.025);
4623   Ghe7->Draw("Error");
4624   Float_t ymaxHE = Ghe7->GetMaximum();
4625   cout << "22HE-3   ymaxHE=  " << ymaxHE << "       MAXdif3rmsHEMIN=  " << MAXdif3rmsHEMIN
4626        << "         MINdif3rmsHEMAX=  " << MINdif3rmsHEMAX << endl;
4627   TLine *lineHE = new TLine(MAXdif3rmsHEMIN, 0., MAXdif3rmsHEMIN, ymaxHE);
4628   lineHE->SetLineColor(kBlue);
4629   lineHE->Draw();
4630   TLine *line1HE = new TLine(MINdif3rmsHEMAX, 0., MINdif3rmsHEMAX, ymaxHE);
4631   line1HE->SetLineColor(kBlue);
4632   line1HE->Draw();
4633   //================
4634   /////////////////
4635   cRBX31->Update();
4636   cRBX31->Print("RBX-HE-3plots.png");
4637   cRBX31->Clear();
4638   // clean-up
4639   if (Ghe5)
4640     delete Ghe5;
4641   if (Ghe60)
4642     delete Ghe60;
4643   if (Ghe61)
4644     delete Ghe61;
4645   if (Ghe6)
4646     delete Ghe6;
4647   if (Ghe7)
4648     delete Ghe7;
4649 
4650   if (G20he60)
4651     delete G20he60;
4652   if (G20he61)
4653     delete G20he61;
4654   if (G30he60)
4655     delete G30he60;
4656   if (G30he61)
4657     delete G30he61;
4658   if (G40he60)
4659     delete G40he60;
4660   if (G40he61)
4661     delete G40he61;
4662 
4663   if (Ghe1)
4664     delete Ghe1;
4665   //========================================================================================== 22-1   HE:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
4666   //======================================================================
4667   //======================================================================28.11.2018
4668   //======================================================================
4669   //======================================================================
4670 
4671   gStyle->SetOptStat(1110000);
4672   cout << "      RBX HE  Ratio plotsmore *****" << endl;
4673   cRBX31->Clear();
4674   /////////////////
4675   cRBX31->Divide(3, 1);
4676   //================
4677   cRBX31->cd(1);
4678   G20he6->GetZaxis()->SetLabelSize(0.025);
4679   G20he6->SetXTitle("             #eta  \b");
4680   G20he6->SetYTitle("      #phi \b");
4681   G20he6->SetTitle("<Rj> for |1-<R>| > 0.20 \b");
4682   G20he6->SetStats(0);
4683   G20he6->Draw("COLZ");
4684   //================
4685   cRBX31->cd(2);
4686   G30he6->GetZaxis()->SetLabelSize(0.025);
4687   G30he6->SetXTitle("             #eta  \b");
4688   G30he6->SetYTitle("      #phi \b");
4689   G30he6->SetTitle("<Rj> for |1-<R>| > 0.30 \b");
4690   G30he6->SetStats(0);
4691   G30he6->Draw("COLZ");
4692   //================
4693   cRBX31->cd(3);
4694   G40he6->GetZaxis()->SetLabelSize(0.025);
4695   G40he6->SetXTitle("             #eta  \b");
4696   G40he6->SetYTitle("      #phi \b");
4697   G40he6->SetTitle("<Rj> for |1-<R>| > 0.40 \b");
4698   G40he6->SetStats(0);
4699   G40he6->Draw("COLZ");
4700   //================
4701 
4702   /////////////////
4703   cRBX31->Update();
4704   cRBX31->Print("RBX-HE-3plotsmore.png");
4705   cRBX31->Clear();
4706 
4707   // clean-up
4708   if (G20he6)
4709     delete G20he6;
4710   if (G30he6)
4711     delete G30he6;
4712   if (G40he6)
4713     delete G40he6;
4714   gStyle->SetOptStat(0);
4715   ////////////////////////////////////////////////////////////////////////////////////
4716 
4717   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4718   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4719   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
4720   for (int jphi = 0; jphi < njphi; jphi++) {
4721     for (int jeta = 0; jeta < njeta; jeta++) {
4722       for (int i = 0; i < nx; i++) {
4723         alexall[jeta][jphi][i] = 0.;
4724       }
4725     }
4726   }  // nulling
4727 
4728   ////////////////////////////////////////////////////////////////////////////////////   end HE RBX
4729 
4730   ////////////////////////////////////////////////////////////////////////////////////     HO::  HOSTART HO: j = 7,8,9,10            11,12,13,14
4731   //======================================================================
4732   //======================================================================
4733   //======================================================================
4734   cout << " RBX general for HO **************************" << endl;
4735   TH2F *Gho1KKK = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplEtaPhiLs2");
4736   TH2F *Gho1LLL = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplEtaPhiLs20");
4737   TH2F *Gho1 = (TH2F *)Gho1LLL->Clone("Gho1");
4738   Gho1->Divide(Gho1KKK, Gho1LLL, 1, 1, "B");  // average A
4739   //    Gho1->Sumw2();
4740   //      int nx = Gho1->GetXaxis()->GetNbins(); // # LS
4741   //    nx = maxbinsRBX; // # LS
4742   ny = Gho1->GetYaxis()->GetNbins();  // # jetaphi indexes
4743   for (int j = 1; j <= ny; j++) {
4744     int jeta = (j - 1) / njphi;  // jeta = 0-21
4745     if (jeta < 15 && jeta > 6) {
4746       int jphi = (j - 1) - njphi * jeta;  // jphi=0-17
4747       //       cout<<"HO 54        jeta=     "<< jeta <<"   jphi   =     "<<jphi  <<endl;
4748       // over LS:
4749       for (int i = 1; i <= nx; i++) {
4750         double ccc1 = Gho1->GetBinContent(i, j);
4751         alexall[jeta][jphi][i - 1] = ccc1;
4752         //       if( i == 1 ) cout<<"HO 54  for LS=1      ccc1=     "<< ccc1 <<endl;
4753       }  //i
4754     }    //if
4755   }      //j
4756   // clean-up
4757   if (Gho1KKK)
4758     delete Gho1KKK;
4759   if (Gho1LLL)
4760     delete Gho1LLL;
4761   //    if (Gho1) delete Gho1;
4762 
4763   //====================================================================== alexho[k][i]
4764   for (int jphi = 0; jphi < njphi; jphi++) {
4765     for (int i = 0; i < nx; i++) {
4766       double sumccc1 = 0.;
4767       int isum = 0;
4768       for (int jeta = 0; jeta < njeta; jeta++) {
4769         double ccc1 = alexall[jeta][jphi][i];
4770         if (ccc1 > 0.) {
4771           sumccc1 += ccc1;
4772           isum++;
4773         }
4774       }  // for jeta
4775       if (isum > 0.)
4776         sumccc1 /= isum;
4777       alexho[jphi][i] = sumccc1;
4778     }
4779   }  //for for
4780      //====================================================================== blexho[k][i]
4781   for (int keta = 0; keta < njeta; keta++) {
4782     for (int i = 0; i < nx; i++) {
4783       double sumccc1 = 0.;
4784       int isum = 0;
4785       for (int kphi = 0; kphi < njphi; kphi++) {
4786         double ccc1 = alexall[keta][kphi][i];
4787         if (ccc1 > 0.) {
4788           sumccc1 += ccc1;
4789           isum++;
4790         }
4791       }  // for kphi
4792       if (isum > 0.)
4793         sumccc1 /= isum;
4794       blexho[keta][i] = sumccc1;
4795     }
4796   }  //for for
4797 
4798   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4799   //========================================================================================== 33   HO:: 2D  jeta = 0 - 21       jphi =0 - 17
4800   //======================================================================
4801   //======================================================================
4802   //======================================================================
4803   //======================================================================
4804   cout << "      RBX HO  2D plot *****" << endl;
4805   cRBX1->Clear();
4806   /////////////////
4807   cRBX1->Divide(1, 1);
4808   cRBX1->cd(1);
4809   // int ietaphi = 0; ietaphi = ((k2+1)-1)*nphi + (k3+1) ;  k2=0-neta-1; k3=0-nphi-1; neta=18; nphi=22;
4810   TH2F *Gho42D = new TH2F("Gho42D", "", 23, -11.5, 11.5, 18, 0., 18.);
4811   TH2F *Gho42D0 = new TH2F("Gho42D0", "", 23, -11.5, 11.5, 18, 0., 18.);
4812   //     TH2F* Gho42D      = new TH2F("Gho42D","",   22, -11., 11., 18, 0., 18. );
4813   //     TH2F* Gho42D0     = new TH2F("Gho42D0","",  22, -11., 11., 18, 0., 18. );
4814   TH2F *Gho42DF = (TH2F *)Gho42D0->Clone("Gho42DF");
4815   for (int jphi = 0; jphi < njphi; jphi++) {
4816     for (int jeta = 0; jeta < njeta; jeta++) {
4817       for (int i = 0; i < nx; i++) {
4818         double ccc1 = alexall[jeta][jphi][i];
4819         int neweta = jeta - 11 - 0.5;
4820         if (jeta >= 11)
4821           neweta = jeta - 11 + 1.5;
4822         if (ccc1 > 0.) {
4823           Gho42D->Fill(neweta, jphi, ccc1);
4824           Gho42D0->Fill(neweta, jphi, 1.);
4825         }
4826         //       if(ccc1>0.) {Gho42D ->Fill(jeta-11,jphi,ccc1); Gho42D0 ->Fill(jeta-11,jphi,1.); }
4827       }
4828     }
4829   }
4830   Gho42DF->Divide(Gho42D, Gho42D0, 1, 1, "B");  // average A
4831   //    Gho1->Sumw2();
4832   gPad->SetGridy();
4833   gPad->SetGridx();  //      gPad->SetLogz();
4834   Gho42DF->SetMarkerStyle(20);
4835   Gho42DF->SetMarkerSize(0.4);
4836   Gho42DF->GetZaxis()->SetLabelSize(0.04);
4837   Gho42DF->SetXTitle("<A>_RBX         #eta  \b");
4838   Gho42DF->SetYTitle("      #phi \b");
4839   Gho42DF->SetZTitle("<A>_RBX  - All \b");
4840   Gho42DF->SetMarkerColor(2);
4841   Gho42DF->SetLineColor(2);  //      Gho42DF->SetMaximum(1.000);  //      Gho42DF->SetMinimum(1.0);
4842   Gho42DF->Draw("COLZ");
4843 
4844   /////////////////
4845   cRBX1->Update();
4846   cRBX1->Print("RBX-HO-2Dplot.png");
4847   cRBX1->Clear();
4848   // clean-up
4849   if (Gho42D)
4850     delete Gho42D;
4851   if (Gho42D0)
4852     delete Gho42D0;
4853   if (Gho42DF)
4854     delete Gho42DF;
4855 
4856   //========================================================================================== 61   HO:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
4857   //======================================================================
4858   //======================================================================
4859   //======================================================================
4860   //======================================================================
4861   cout << "      RBX HO  1D plot *****" << endl;
4862   cRBX1->Clear();
4863   /////////////////
4864   cRBX1->Divide(1, 1);
4865   cRBX1->cd(1);
4866   TH1F *GphiHO1D = new TH1F("GphiHO1D", "", 18, 0., 18.);
4867   TH1F *GphiHO1D0 = new TH1F("GphiHO1D0", "", 18, 0., 18.);
4868   TH1F *GphiHO1DF = (TH1F *)GphiHO1D0->Clone("GphiHO1DF");
4869   for (int jphi = 0; jphi < 18; jphi++) {
4870     for (int jeta = 0; jeta < 22; jeta++) {
4871       for (int i = 0; i < nx; i++) {
4872         double ccc1 = alexall[jeta][jphi][i];
4873         if (ccc1 > 0.) {
4874           GphiHO1D->Fill(jphi, ccc1);
4875           GphiHO1D0->Fill(jphi, 1.);
4876         }
4877       }
4878     }
4879   }
4880   //     GphiHO1D->Sumw2();GphiHO1D0->Sumw2();
4881   GphiHO1DF->Divide(GphiHO1D, GphiHO1D0, 1, 1, "B");  // average A
4882                                                       //     GphiHO1DF->Sumw2();
4883   for (int jphi = 1; jphi < 19; jphi++) {
4884     GphiHO1DF->SetBinError(jphi, 0.01);
4885   }
4886   gPad->SetGridy();
4887   gPad->SetGridx();  //      gPad->SetLogz();
4888   GphiHO1DF->SetMarkerStyle(20);
4889   GphiHO1DF->SetMarkerSize(1.4);
4890   GphiHO1DF->GetZaxis()->SetLabelSize(0.08);
4891   GphiHO1DF->SetXTitle("PHI of RBX\b");
4892   GphiHO1DF->SetYTitle(" <Amplitude> \b");
4893   GphiHO1DF->SetZTitle("<A>_PHI  - All \b");
4894   GphiHO1DF->SetMarkerColor(4);
4895   GphiHO1DF->SetLineColor(4);
4896   GphiHO1DF->SetMinimum(0.8);  //      GphiHO1DF->SetMaximum(1.000);
4897   GphiHO1DF->Draw("Error");
4898   /////////////////
4899   cRBX1->Update();
4900   cRBX1->Print("RBX-HO-1Dplot.png");
4901   cRBX1->Clear();
4902   // clean-up
4903   if (GphiHO1D)
4904     delete GphiHO1D;
4905   if (GphiHO1D0)
4906     delete GphiHO1D0;
4907   if (GphiHO1DF)
4908     delete GphiHO1DF;
4909 
4910   //========================================================================================== 62   HO:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
4911   //======================================================================
4912   //======================================================================
4913   //======================================================================
4914   //======================================================================
4915   cout << "      RBX HO 11D plot *eta*" << endl;
4916   cRBX1->Clear();
4917   /////////////////
4918   cRBX1->Divide(1, 1);
4919   cRBX1->cd(1);
4920   TH1F *GetaHO11D = new TH1F("GetaHO11D", "", 23, -11.5, 11.5);
4921   TH1F *GetaHO11D0 = new TH1F("GetaHO11D0", "", 23, -11.5, 11.5);
4922   TH1F *GetaHO11DF = (TH1F *)GetaHO11D0->Clone("GetaHO11DF");
4923 
4924   for (int jeta = 0; jeta < 22; jeta++) {
4925     for (int jphi = 0; jphi < 18; jphi++) {
4926       for (int i = 0; i < nx; i++) {
4927         double ccc1 = alexall[jeta][jphi][i];
4928         int neweta = jeta - 11 - 0.5;
4929         if (jeta >= 11)
4930           neweta = jeta - 11 + 1.5;
4931         if (ccc1 > 0.) {
4932           GetaHO11D->Fill(neweta, ccc1);
4933           GetaHO11D0->Fill(neweta, 1.);
4934           //           if( i == 0 ) cout<<"62  HO:  ibin=  "<< i <<"      jphi= "<< jphi <<"      jeta= "<< jeta <<"      A= "<< ccc1 <<endl;
4935         }
4936       }
4937     }
4938   }
4939   //     GetaHO11D->Sumw2();GetaHO11D0->Sumw2();
4940   GetaHO11DF->Divide(GetaHO11D, GetaHO11D0, 1, 1, "B");  // average A
4941                                                          //     GetaHO11DF->Sumw2();
4942   for (int jeta = 1; jeta < 24; jeta++) {
4943     GetaHO11DF->SetBinError(jeta, 0.01);
4944   }
4945   gPad->SetGridy();
4946   gPad->SetGridx();  //      gPad->SetLogz();
4947   GetaHO11DF->SetMarkerStyle(20);
4948   GetaHO11DF->SetMarkerSize(1.4);
4949   GetaHO11DF->GetZaxis()->SetLabelSize(0.08);
4950   GetaHO11DF->SetXTitle("#eta  \b");
4951   GetaHO11DF->SetYTitle("  <A> \b");
4952   GetaHO11DF->SetZTitle("<A>_ETA  - All \b");
4953   GetaHO11DF->SetMarkerColor(4);
4954   GetaHO11DF->SetLineColor(4);
4955   GetaHO11DF->SetMinimum(0.8);  //      GetaHO11DF->SetMaximum(1.000);
4956   GetaHO11DF->Draw("Error");
4957 
4958   /////////////////
4959   cRBX1->Update();
4960   cRBX1->Print("RBX-HO-11Dplot.png");
4961   cRBX1->Clear();
4962   // clean-up
4963   if (GetaHO11D)
4964     delete GetaHO11D;
4965   if (GetaHO11D0)
4966     delete GetaHO11D0;
4967   if (GetaHO11DF)
4968     delete GetaHO11DF;
4969 
4970   //========================================================================================== 22   HO:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
4971   //======================================================================
4972   //======================================================================22.11.2018
4973   //======================================================================
4974   //======================================================================
4975 
4976   gStyle->SetOptStat(1110000);
4977   cout << "      RBX HO  Ratio plots *****" << endl;
4978   cRBX31->Clear();
4979   /////////////////
4980   // gain stabilitY:
4981   // Rij = Aij / A1j , where i-over LSs, j-channels
4982   //
4983   //    nx = maxbinsRBX; // # LS
4984   //
4985   double ccc0HO = 0.;
4986   cRBX31->Divide(3, 1);
4987   //================
4988   cRBX31->cd(1);
4989   //    TH1F* Gho5 = new TH1F("Gho5","", nx, 1., nx+1.);
4990   TH1F *Gho51 = new TH1F("Gho51", "", nx, 1., nx + 1.);
4991   TH1F *Gho50 = new TH1F("Gho50", "", nx, 1., nx + 1.);
4992   TH1F *Gho5 = (TH1F *)Gho50->Clone("Gho5");
4993   // j - etaphi index:
4994   for (int j = 1; j <= ny; j++) {
4995     ccc0HO = Gho1->GetBinContent(1, j);
4996     //  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;} }
4997     if (ccc0HO <= 0.)
4998       for (int i = 1; i <= nx; i++) {
4999         double ccc2 = Gho1->GetBinContent(i, j);
5000         if (ccc2 > 0.) {
5001           ccc0HO = ccc2;
5002           break;
5003         }
5004       }
5005     if (ccc0HO > 0.) {
5006       // i - # LSs:
5007       for (int i = 1; i <= nx; i++) {
5008         double ccc1 = Gho1->GetBinContent(i, j);
5009         if (ccc1 > 0.) {
5010           double Rij = ccc1 / ccc0HO;
5011           //          Gho5 ->Fill( float(i), Rij);
5012           Gho51->Fill(float(i), Rij);
5013           Gho50->Fill(float(i), 1.);
5014         }
5015       }
5016     }
5017   }
5018   Gho5->Divide(Gho51, Gho50, 1, 1, "B");  // average A
5019   for (int i = 1; i <= nx; i++) {
5020     Gho5->SetBinError(i, 0.0001);
5021   }
5022   Gho5->SetMarkerStyle(20);
5023   Gho5->SetMarkerSize(0.4);
5024   Gho5->GetYaxis()->SetLabelSize(0.04);
5025   Gho5->SetMarkerColor(2);
5026   Gho5->SetLineColor(0);
5027   Gho5->SetXTitle("        iLS  \b");
5028   Gho5->SetYTitle("     <R> \b");
5029   Gho5->SetTitle("<Ri> vs iLS \b");
5030   Gho5->SetMinimum(0.);  //Gho5->SetMaximum(2.5);
5031   //            gPad->SetLogy();
5032   gPad->SetGridy();
5033   gPad->SetGridx();
5034   Gho5->SetStats(0);
5035   Gho5->GetYaxis()->SetLabelSize(0.025);
5036   Gho5->Draw("Error");
5037   //================
5038   cRBX31->cd(2);
5039   TH2F *Gho60 = new TH2F("Gho60", "", 22, -11., 11., 18, 0., 18.);
5040   TH2F *Gho61 = new TH2F("Gho61", "", 22, -11., 11., 18, 0., 18.);
5041   TH2F *Gho6 = new TH2F("Gho6", "", 22, -11., 11., 18, 0., 18.);
5042 
5043   TH2F *G20ho60 = new TH2F("G20ho60", "", 22, -11., 11., 18, 0., 18.);
5044   TH2F *G20ho61 = new TH2F("G20ho61", "", 22, -11., 11., 18, 0., 18.);
5045   TH2F *G20ho6 = new TH2F("G20ho6", "", 22, -11., 11., 18, 0., 18.);
5046   TH2F *G30ho60 = new TH2F("G30ho60", "", 22, -11., 11., 18, 0., 18.);
5047   TH2F *G30ho61 = new TH2F("G30ho61", "", 22, -11., 11., 18, 0., 18.);
5048   TH2F *G30ho6 = new TH2F("G30ho6", "", 22, -11., 11., 18, 0., 18.);
5049   TH2F *G40ho60 = new TH2F("G40ho60", "", 22, -11., 11., 18, 0., 18.);
5050   TH2F *G40ho61 = new TH2F("G40ho61", "", 22, -11., 11., 18, 0., 18.);
5051   TH2F *G40ho6 = new TH2F("G40ho6", "", 22, -11., 11., 18, 0., 18.);
5052 
5053   // j - etaphi index; i - # LSs;
5054   //
5055   // define mean and RMS:
5056   double sumjHO = 0.;
5057   int njHO = 0;
5058   double meanjHO = 0.;
5059   for (int j = 1; j <= ny; j++) {
5060     ccc0HO = Gho1->GetBinContent(1, j);
5061     if (ccc0HO <= 0.)
5062       for (int i = 1; i <= nx; i++) {
5063         double ccc2 = Gho1->GetBinContent(i, j);
5064         if (ccc2 > 0.) {
5065           ccc0HO = ccc2;
5066           break;
5067         }
5068       }
5069     if (ccc0HO > 0.) {
5070       for (int i = 1; i <= nx; i++) {
5071         double ccc1 = Gho1->GetBinContent(i, j) / ccc0HO;
5072         if (ccc1 > 0.) {
5073           sumjHO += ccc1;
5074           njHO++;
5075         }
5076       }
5077       meanjHO = sumjHO / njHO;
5078     }
5079   }  // j
5080 
5081   double ssumjHO = 0.;
5082   njHO = 0;
5083   double sigmajHO = 0.;
5084   for (int j = 1; j <= ny; j++) {
5085     ccc0HO = Gho1->GetBinContent(1, j);
5086     if (ccc0HO <= 0.)
5087       for (int i = 1; i <= nx; i++) {
5088         double ccc2 = Gho1->GetBinContent(i, j);
5089         if (ccc2 > 0.) {
5090           ccc0HO = ccc2;
5091           break;
5092         }
5093       }
5094     if (ccc0HO > 0.) {
5095       for (int i = 1; i <= nx; i++) {
5096         double ccc1 = Gho1->GetBinContent(i, j) / ccc0HO;
5097         if (ccc1 > 0.) {
5098           ssumjHO += (ccc1 - meanjHO) * (ccc1 - meanjHO);
5099           njHO++;
5100         }
5101       }
5102       sigmajHO = sqrt(ssumjHO / njHO);
5103     }
5104   }  // j
5105 
5106   double dif3rmsHOMIN = meanjHO - 3 * sigmajHO;
5107   if (dif3rmsHOMIN < 0.)
5108     dif3rmsHOMIN = 0.;
5109   double dif3rmsHOMAX = meanjHO + 3 * sigmajHO;
5110   cout << "22HO-2    meanjHO=  " << meanjHO << "  sigmajHO=  " << sigmajHO << "  dif3rmsHOMIN=  " << dif3rmsHOMIN
5111        << "  dif3rmsHOMAX=  " << dif3rmsHOMAX << endl;
5112 
5113   double MAXdif3rmsHOMIN = dif3rmsHOMIN;
5114   double MINdif3rmsHOMAX = dif3rmsHOMAX;
5115   if (MAXdif3rmsHOMIN < 0.95)
5116     MAXdif3rmsHOMIN = 0.95;
5117   if (MINdif3rmsHOMAX > 1.05)
5118     MINdif3rmsHOMAX = 1.05;
5119   cout << "22HO-2     MAXdif3rmsHOMIN=  " << MAXdif3rmsHOMIN << "     MINdif3rmsHOMAX=  " << MINdif3rmsHOMAX << endl;
5120   //
5121   for (int j = 1; j <= ny; j++) {
5122     ccc0HO = Gho1->GetBinContent(1, j);
5123     if (ccc0HO <= 0.)
5124       for (int i = 1; i <= nx; i++) {
5125         double ccc2 = Gho1->GetBinContent(i, j);
5126         if (ccc2 > 0.) {
5127           ccc0HO = ccc2;
5128           break;
5129         }
5130       }
5131     if (ccc0HO > 0.) {
5132       int jeta = (j - 1) / 18;         // jeta = 0-21
5133       int jphi = (j - 1) - 18 * jeta;  // jphi=0-17
5134       // i - # LSs:
5135       for (int i = 1; i <= nx; i++) {
5136         double ccc1 = Gho1->GetBinContent(i, j);
5137         if (ccc1 > 0.) {
5138           double Rij = ccc1 / ccc0HO;
5139           if (Rij < MAXdif3rmsHOMIN || Rij > MINdif3rmsHOMAX) {
5140             Gho61->Fill(jeta - 11, jphi, Rij);
5141             Gho60->Fill(jeta - 11, jphi, 1.);
5142           }
5143           if (Rij < 0.8 || Rij > 1.2) {
5144             G20ho61->Fill(jeta - 11, jphi, Rij);
5145             G20ho60->Fill(jeta - 11, jphi, 1.);
5146           }
5147           if (Rij < 0.7 || Rij > 1.3) {
5148             G30ho61->Fill(jeta - 11, jphi, Rij);
5149             G30ho60->Fill(jeta - 11, jphi, 1.);
5150           }
5151           if (Rij < 0.6 || Rij > 1.4) {
5152             G40ho61->Fill(jeta - 11, jphi, Rij);
5153             G40ho60->Fill(jeta - 11, jphi, 1.);
5154           }
5155         }                                       //if(ccc1>0.
5156       }                                         // i
5157     }                                           //if(ccc0HO>0
5158   }                                             // j
5159   Gho6->Divide(Gho61, Gho60, 1, 1, "B");        // average R
5160   G20ho6->Divide(G20ho61, G20ho60, 1, 1, "B");  // average R
5161   G30ho6->Divide(G30ho61, G30ho60, 1, 1, "B");  // average R
5162   G40ho6->Divide(G40ho61, G40ho60, 1, 1, "B");  // average R
5163   //      Gho6->SetLabelOffset (Float_t offset=0.005, Option_t *axis="X")//Set offset between axis and axis' labels
5164   //      Gho6->GetZaxis()->SetLabelOffset(-0.05);
5165   Gho6->GetZaxis()->SetLabelSize(0.025);
5166 
5167   Gho6->SetXTitle("             #eta  \b");
5168   Gho6->SetYTitle("      #phi \b");
5169   Gho6->SetTitle(
5170       "<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);
5171   //gStyle->SetOptStat(kFALSE);
5172   Gho6->SetStats(0);
5173   Gho6->Draw("COLZ");
5174   //================
5175   cRBX31->cd(3);
5176   TH1F *Gho7 = new TH1F("Gho7", "", 120, 0.4, 1.6);
5177   // j - etaphi index:
5178   for (int j = 1; j <= ny; j++) {
5179     ccc0HO = Gho1->GetBinContent(1, j);
5180     if (ccc0HO <= 0.)
5181       for (int i = 1; i <= nx; i++) {
5182         double ccc2 = Gho1->GetBinContent(i, j);
5183         if (ccc2 > 0.) {
5184           ccc0HO = ccc2;
5185           break;
5186         }
5187       }
5188     if (ccc0HO > 0.) {
5189       // i - # LSs:
5190       for (int i = 1; i <= nx; i++) {
5191         double ccc1 = Gho1->GetBinContent(i, j);
5192         if (ccc1 > 0.) {
5193           double Rij = ccc1 / ccc0HO;
5194           Gho7->Fill(Rij);
5195         }
5196       }
5197     }
5198   }
5199   Gho7->SetMarkerStyle(20);
5200   Gho7->SetMarkerSize(0.4);
5201   Gho7->GetYaxis()->SetLabelSize(0.04);
5202   Gho7->SetMarkerColor(2);
5203   Gho7->SetLineColor(0);
5204   Gho7->SetYTitle("        N  \b");
5205   Gho7->SetXTitle("     Rij \b");
5206   Gho7->SetTitle(" Rij \b");
5207   //Gho7->SetMinimum(0.8);Gho7->SetMaximum(500.);
5208   gPad->SetGridy();
5209   gPad->SetGridx();  //            gPad->SetLogy();
5210   //      Gho7->SetStats(1110000);
5211   Gho7->GetYaxis()->SetLabelSize(0.025);
5212   Gho7->Draw("Error");
5213   Float_t ymaxHO = Gho7->GetMaximum();
5214   cout << "22HO-3   ymaxHO=  " << ymaxHO << "       MAXdif3rmsHOMIN=  " << MAXdif3rmsHOMIN
5215        << "         MINdif3rmsHOMAX=  " << MINdif3rmsHOMAX << endl;
5216   TLine *lineHO = new TLine(MAXdif3rmsHOMIN, 0., MAXdif3rmsHOMIN, ymaxHO);
5217   lineHO->SetLineColor(kBlue);
5218   lineHO->Draw();
5219   TLine *line1HO = new TLine(MINdif3rmsHOMAX, 0., MINdif3rmsHOMAX, ymaxHO);
5220   line1HO->SetLineColor(kBlue);
5221   line1HO->Draw();
5222   //================
5223   /////////////////
5224   cRBX31->Update();
5225   cRBX31->Print("RBX-HO-3plots.png");
5226   cRBX31->Clear();
5227   // clean-up
5228   if (Gho5)
5229     delete Gho5;
5230   if (Gho60)
5231     delete Gho60;
5232   if (Gho61)
5233     delete Gho61;
5234   if (Gho6)
5235     delete Gho6;
5236   if (Gho7)
5237     delete Gho7;
5238 
5239   if (G20ho60)
5240     delete G20ho60;
5241   if (G20ho61)
5242     delete G20ho61;
5243   if (G30ho60)
5244     delete G30ho60;
5245   if (G30ho61)
5246     delete G30ho61;
5247   if (G40ho60)
5248     delete G40ho60;
5249   if (G40ho61)
5250     delete G40ho61;
5251 
5252   if (Gho1)
5253     delete Gho1;
5254   //========================================================================================== 22-1   HO:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
5255   //======================================================================
5256   //======================================================================28.11.2018
5257   //======================================================================
5258   //======================================================================
5259 
5260   gStyle->SetOptStat(1110000);
5261   cout << "      RBX HO  Ratio plotsmore *****" << endl;
5262   cRBX31->Clear();
5263   /////////////////
5264   cRBX31->Divide(3, 1);
5265   //================
5266   cRBX31->cd(1);
5267   G20ho6->GetZaxis()->SetLabelSize(0.025);
5268   G20ho6->SetXTitle("             #eta  \b");
5269   G20ho6->SetYTitle("      #phi \b");
5270   G20ho6->SetTitle("<Rj> for |1-<R>| > 0.20 \b");
5271   G20ho6->SetStats(0);
5272   G20ho6->Draw("COLZ");
5273   //================
5274   cRBX31->cd(2);
5275   G30ho6->GetZaxis()->SetLabelSize(0.025);
5276   G30ho6->SetXTitle("             #eta  \b");
5277   G30ho6->SetYTitle("      #phi \b");
5278   G30ho6->SetTitle("<Rj> for |1-<R>| > 0.30 \b");
5279   G30ho6->SetStats(0);
5280   G30ho6->Draw("COLZ");
5281   //================
5282   cRBX31->cd(3);
5283   G40ho6->GetZaxis()->SetLabelSize(0.025);
5284   G40ho6->SetXTitle("             #eta  \b");
5285   G40ho6->SetYTitle("      #phi \b");
5286   G40ho6->SetTitle("<Rj> for |1-<R>| > 0.40 \b");
5287   G40ho6->SetStats(0);
5288   G40ho6->Draw("COLZ");
5289   //================
5290 
5291   /////////////////
5292   cRBX31->Update();
5293   cRBX31->Print("RBX-HO-3plotsmore.png");
5294   cRBX31->Clear();
5295 
5296   // clean-up
5297   if (G20ho6)
5298     delete G20ho6;
5299   if (G30ho6)
5300     delete G30ho6;
5301   if (G40ho6)
5302     delete G40ho6;
5303   gStyle->SetOptStat(0);
5304   ////////////////////////////////////////////////////////////////////////////////////
5305 
5306   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5307   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5308   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5309   for (int jphi = 0; jphi < njphi; jphi++) {
5310     for (int jeta = 0; jeta < njeta; jeta++) {
5311       for (int i = 0; i < nx; i++) {
5312         alexall[jeta][jphi][i] = 0.;
5313       }
5314     }
5315   }  // nulling
5316 
5317   ////////////////////////////////////////////////////////////////////////////////////   end HO RBX
5318 
5319   ////////////////////////////////////////////////////////////////////////////////////     HF::   HFSTART
5320   //======================================================================
5321   //======================================================================
5322   //======================================================================
5323   cout << " RBX general for HF **************************" << endl;
5324   TH2F *Ghf1KKK = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplEtaPhiLs3");
5325   TH2F *Ghf1LLL = (TH2F *)dir->FindObjectAny("h_2DsumADCAmplEtaPhiLs30");
5326   TH2F *Ghf1 = (TH2F *)Ghf1LLL->Clone("Ghf1");
5327   Ghf1->Divide(Ghf1KKK, Ghf1LLL, 1, 1, "B");  // average A
5328   //    Ghf1->Sumw2();
5329   //      int nx = Ghf1->GetXaxis()->GetNbins(); // # LS
5330   //    nx = maxbinsRBX; // # LS
5331   ny = Ghf1->GetYaxis()->GetNbins();  // # jetaphi indexes
5332   for (int j = 1; j <= ny; j++) {
5333     int jeta = (j - 1) / njphi;  // jeta = 0-21
5334     if (jeta < 4 || jeta > 17) {
5335       int jphi = (j - 1) - njphi * jeta;  // jphi=0-17
5336       //       cout<<"HF 54        jeta=     "<< jeta <<"   jphi   =     "<<jphi  <<endl;
5337       // over LS:
5338       for (int i = 1; i <= nx; i++) {
5339         double ccc1 = Ghf1->GetBinContent(i, j);
5340         alexall[jeta][jphi][i - 1] = ccc1;
5341         //       if( i == 1 ) cout<<"HF 54  for LS=1      ccc1=     "<< ccc1 <<endl;
5342       }  //i
5343     }    //if
5344   }      //j
5345   // clean-up
5346   if (Ghf1KKK)
5347     delete Ghf1KKK;
5348   if (Ghf1LLL)
5349     delete Ghf1LLL;
5350   //    if (Ghf1) delete Ghf1;
5351 
5352   //====================================================================== alexhf[k][i]
5353   for (int jphi = 0; jphi < njphi; jphi++) {
5354     for (int i = 0; i < nx; i++) {
5355       double sumccc1 = 0.;
5356       int isum = 0;
5357       for (int jeta = 0; jeta < njeta; jeta++) {
5358         double ccc1 = alexall[jeta][jphi][i];
5359         if (ccc1 > 0.) {
5360           sumccc1 += ccc1;
5361           isum++;
5362         }
5363       }  // for jeta
5364       if (isum > 0.)
5365         sumccc1 /= isum;
5366       alexhf[jphi][i] = sumccc1;
5367     }
5368   }  //for for
5369      //====================================================================== blexhf[k][i]
5370   for (int keta = 0; keta < njeta; keta++) {
5371     for (int i = 0; i < nx; i++) {
5372       double sumccc1 = 0.;
5373       int isum = 0;
5374       for (int kphi = 0; kphi < njphi; kphi++) {
5375         double ccc1 = alexall[keta][kphi][i];
5376         if (ccc1 > 0.) {
5377           sumccc1 += ccc1;
5378           isum++;
5379         }
5380       }  // for kphi
5381       if (isum > 0.)
5382         sumccc1 /= isum;
5383       blexhf[keta][i] = sumccc1;
5384     }
5385   }  //for for
5386   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5387   //========================================================================================== 60   HF:: 2D  jeta = 0 - 21       jphi =0 - 17
5388   //======================================================================
5389   //======================================================================
5390   //======================================================================
5391   //======================================================================
5392   cout << "      RBX HF  2D plot *****" << endl;
5393   cRBX1->Clear();
5394   /////////////////
5395   cRBX1->Divide(1, 1);
5396   cRBX1->cd(1);
5397   // int ietaphi = 0; ietaphi = ((k2+1)-1)*nphi + (k3+1) ;  k2=0-neta-1; k3=0-nphi-1; neta=18; nphi=22;
5398   TH2F *Ghf42D = new TH2F("Ghf42D", "", 23, -11.5, 11.5, 18, 0., 18.);
5399   TH2F *Ghf42D0 = new TH2F("Ghf42D0", "", 23, -11.5, 11.5, 18, 0., 18.);
5400   //     TH2F* Ghf42D      = new TH2F("Ghf42D","",   22, -11., 11., 18, 0., 18. );
5401   //     TH2F* Ghf42D0     = new TH2F("Ghf42D0","",  22, -11., 11., 18, 0., 18. );
5402   TH2F *Ghf42DF = (TH2F *)Ghf42D0->Clone("Ghf42DF");
5403   for (int jphi = 0; jphi < njphi; jphi++) {
5404     for (int jeta = 0; jeta < njeta; jeta++) {
5405       for (int i = 0; i < nx; i++) {
5406         double ccc1 = alexall[jeta][jphi][i];
5407         int neweta = jeta - 11 - 0.5;
5408         if (jeta >= 11)
5409           neweta = jeta - 11 + 1.5;
5410         if (ccc1 > 0.) {
5411           Ghf42D->Fill(neweta, jphi, ccc1);
5412           Ghf42D0->Fill(neweta, jphi, 1.);
5413         }
5414         //       if(ccc1>0.) {Ghf42D ->Fill(jeta-11,jphi,ccc1); Ghf42D0 ->Fill(jeta-11,jphi,1.); }
5415       }
5416     }
5417   }
5418   Ghf42DF->Divide(Ghf42D, Ghf42D0, 1, 1, "B");  // average A
5419   //    Ghf1->Sumw2();
5420   gPad->SetGridy();
5421   gPad->SetGridx();  //      gPad->SetLogz();
5422   Ghf42DF->SetMarkerStyle(20);
5423   Ghf42DF->SetMarkerSize(0.4);
5424   Ghf42DF->GetZaxis()->SetLabelSize(0.04);
5425   Ghf42DF->SetXTitle("<A>_RBX         #eta  \b");
5426   Ghf42DF->SetYTitle("      #phi \b");
5427   Ghf42DF->SetZTitle("<A>_RBX  - All \b");
5428   Ghf42DF->SetMarkerColor(2);
5429   Ghf42DF->SetLineColor(2);  //      Ghf42DF->SetMaximum(1.000);  //      Ghf42DF->SetMinimum(1.0);
5430   Ghf42DF->Draw("COLZ");
5431 
5432   /////////////////
5433   cRBX1->Update();
5434   cRBX1->Print("RBX-HF-2Dplot.png");
5435   cRBX1->Clear();
5436   // clean-up
5437   if (Ghf42D)
5438     delete Ghf42D;
5439   if (Ghf42D0)
5440     delete Ghf42D0;
5441   if (Ghf42DF)
5442     delete Ghf42DF;
5443 
5444   //========================================================================================== 61   HF:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
5445   //======================================================================
5446   //======================================================================
5447   //======================================================================
5448   //======================================================================
5449   cout << "      RBX HF  1D plot *****" << endl;
5450   cRBX1->Clear();
5451   /////////////////
5452   cRBX1->Divide(1, 1);
5453   cRBX1->cd(1);
5454   TH1F *GphiHF1D = new TH1F("GphiHF1D", "", 18, 0., 18.);
5455   TH1F *GphiHF1D0 = new TH1F("GphiHF1D0", "", 18, 0., 18.);
5456   TH1F *GphiHF1DF = (TH1F *)GphiHF1D0->Clone("GphiHF1DF");
5457   for (int jphi = 0; jphi < 18; jphi++) {
5458     for (int jeta = 0; jeta < 22; jeta++) {
5459       for (int i = 0; i < nx; i++) {
5460         double ccc1 = alexall[jeta][jphi][i];
5461         if (ccc1 > 0.) {
5462           GphiHF1D->Fill(jphi, ccc1);
5463           GphiHF1D0->Fill(jphi, 1.);
5464         }
5465       }
5466     }
5467   }
5468   //     GphiHF1D->Sumw2();GphiHF1D0->Sumw2();
5469   GphiHF1DF->Divide(GphiHF1D, GphiHF1D0, 1, 1, "B");  // average A
5470                                                       //     GphiHF1DF->Sumw2();
5471   for (int jphi = 1; jphi < 19; jphi++) {
5472     GphiHF1DF->SetBinError(jphi, 0.01);
5473   }
5474   gPad->SetGridy();
5475   gPad->SetGridx();  //      gPad->SetLogz();
5476   GphiHF1DF->SetMarkerStyle(20);
5477   GphiHF1DF->SetMarkerSize(1.4);
5478   GphiHF1DF->GetZaxis()->SetLabelSize(0.08);
5479   GphiHF1DF->SetXTitle("PHI of RBX\b");
5480   GphiHF1DF->SetYTitle(" <Amplitude> \b");
5481   GphiHF1DF->SetZTitle("<A>_PHI  - All \b");
5482   GphiHF1DF->SetMarkerColor(4);
5483   GphiHF1DF->SetLineColor(4);
5484   GphiHF1DF->SetMinimum(0.8);  //      GphiHF1DF->SetMaximum(1.000);
5485   GphiHF1DF->Draw("Error");
5486   /////////////////
5487   cRBX1->Update();
5488   cRBX1->Print("RBX-HF-1Dplot.png");
5489   cRBX1->Clear();
5490   // clean-up
5491   if (GphiHF1D)
5492     delete GphiHF1D;
5493   if (GphiHF1D0)
5494     delete GphiHF1D0;
5495   if (GphiHF1DF)
5496     delete GphiHF1DF;
5497 
5498   //========================================================================================== 62   HF:: 1D  j = 7,8,9,10 ; 11,12,13,14       jphi =0 - 17
5499   //======================================================================
5500   //======================================================================
5501   //======================================================================
5502   //======================================================================
5503   cout << "      RBX HF 11D plot *eta*" << endl;
5504   cRBX1->Clear();
5505   /////////////////
5506   cRBX1->Divide(1, 1);
5507   cRBX1->cd(1);
5508   TH1F *GetaHF11D = new TH1F("GetaHF11D", "", 23, -11.5, 11.5);
5509   TH1F *GetaHF11D0 = new TH1F("GetaHF11D0", "", 23, -11.5, 11.5);
5510   TH1F *GetaHF11DF = (TH1F *)GetaHF11D0->Clone("GetaHF11DF");
5511 
5512   for (int jeta = 0; jeta < 22; jeta++) {
5513     for (int jphi = 0; jphi < 18; jphi++) {
5514       for (int i = 0; i < nx; i++) {
5515         double ccc1 = alexall[jeta][jphi][i];
5516         int neweta = jeta - 11 - 0.5;
5517         if (jeta >= 11)
5518           neweta = jeta - 11 + 1.5;
5519         if (ccc1 > 0.) {
5520           GetaHF11D->Fill(neweta, ccc1);
5521           GetaHF11D0->Fill(neweta, 1.);
5522           //           if( i == 0 ) cout<<"62  HF:  ibin=  "<< i <<"      jphi= "<< jphi <<"      jeta= "<< jeta <<"      A= "<< ccc1 <<endl;
5523         }
5524       }
5525     }
5526   }
5527   //     GetaHF11D->Sumw2();GetaHF11D0->Sumw2();
5528   GetaHF11DF->Divide(GetaHF11D, GetaHF11D0, 1, 1, "B");  // average A
5529                                                          //     GetaHF11DF->Sumw2();
5530   for (int jeta = 1; jeta < 24; jeta++) {
5531     GetaHF11DF->SetBinError(jeta, 0.01);
5532   }
5533   gPad->SetGridy();
5534   gPad->SetGridx();  //      gPad->SetLogz();
5535   GetaHF11DF->SetMarkerStyle(20);
5536   GetaHF11DF->SetMarkerSize(1.4);
5537   GetaHF11DF->GetZaxis()->SetLabelSize(0.08);
5538   GetaHF11DF->SetXTitle("#eta  \b");
5539   GetaHF11DF->SetYTitle("  <A> \b");
5540   GetaHF11DF->SetZTitle("<A>_ETA  - All \b");
5541   GetaHF11DF->SetMarkerColor(4);
5542   GetaHF11DF->SetLineColor(4);
5543   GetaHF11DF->SetMinimum(0.8);  //      GetaHF11DF->SetMaximum(1.000);
5544   GetaHF11DF->Draw("Error");
5545 
5546   /////////////////
5547   cRBX1->Update();
5548   cRBX1->Print("RBX-HF-11Dplot.png");
5549   cRBX1->Clear();
5550   // clean-up
5551   if (GetaHF11D)
5552     delete GetaHF11D;
5553   if (GetaHF11D0)
5554     delete GetaHF11D0;
5555   if (GetaHF11DF)
5556     delete GetaHF11DF;
5557 
5558   //========================================================================================== 22   HF:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
5559   //======================================================================
5560   //======================================================================22.11.2018
5561   //======================================================================
5562   //======================================================================
5563 
5564   gStyle->SetOptStat(1110000);
5565   cout << "      RBX HF  Ratio plots *****" << endl;
5566   cRBX31->Clear();
5567   /////////////////
5568   // gain stabilitY:
5569   // Rij = Aij / A1j , where i-over LSs, j-channels
5570   //
5571   //    nx = maxbinsRBX; // # LS
5572   //
5573   double ccc0HF = 0.;
5574   cRBX31->Divide(3, 1);
5575   //================
5576   cRBX31->cd(1);
5577   //      TH1F* Ghf5 = new TH1F("Ghf5","", nx, 1., nx+1.);
5578   TH1F *Ghf51 = new TH1F("Ghf51", "", nx, 1., nx + 1.);
5579   TH1F *Ghf50 = new TH1F("Ghf50", "", nx, 1., nx + 1.);
5580   TH1F *Ghf5 = (TH1F *)Ghf50->Clone("Ghf5");
5581   // j - etaphi index:
5582   for (int j = 1; j <= ny; j++) {
5583     ccc0HF = Ghf1->GetBinContent(1, j);
5584     //  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;} }
5585     if (ccc0HF <= 0.)
5586       for (int i = 1; i <= nx; i++) {
5587         double ccc2 = Ghf1->GetBinContent(i, j);
5588         if (ccc2 > 0.) {
5589           ccc0HF = ccc2;
5590           break;
5591         }
5592       }
5593     if (ccc0HF > 0.) {
5594       // i - # LSs:
5595       for (int i = 1; i <= nx; i++) {
5596         double ccc1 = Ghf1->GetBinContent(i, j);
5597         if (ccc1 > 0.) {
5598           double Rij = ccc1 / ccc0HF;
5599           //     Ghf5 ->Fill( float(i), Rij);
5600           Ghf51->Fill(float(i), Rij);
5601           Ghf50->Fill(float(i), 1.);
5602         }
5603       }
5604     }
5605   }
5606   Ghf5->Divide(Ghf51, Ghf50, 1, 1, "B");  // average A
5607   for (int i = 1; i <= nx; i++) {
5608     Ghf5->SetBinError(i, 0.0001);
5609   }
5610   Ghf5->SetMarkerStyle(20);
5611   Ghf5->SetMarkerSize(0.4);
5612   Ghf5->GetYaxis()->SetLabelSize(0.04);
5613   Ghf5->SetMarkerColor(2);
5614   Ghf5->SetLineColor(0);
5615   Ghf5->SetXTitle("        iLS  \b");
5616   Ghf5->SetYTitle("     <R> \b");
5617   Ghf5->SetTitle("<Ri> vs iLS \b");
5618   Ghf5->SetMinimum(0.);  //Ghf5->SetMaximum(2.5);
5619   //            gPad->SetLogy();
5620   gPad->SetGridy();
5621   gPad->SetGridx();
5622   Ghf5->SetStats(0);
5623   Ghf5->GetYaxis()->SetLabelSize(0.025);
5624   Ghf5->Draw("Error");
5625   //================
5626   cRBX31->cd(2);
5627   TH2F *Ghf60 = new TH2F("Ghf60", "", 22, -11., 11., 18, 0., 18.);
5628   TH2F *Ghf61 = new TH2F("Ghf61", "", 22, -11., 11., 18, 0., 18.);
5629   TH2F *Ghf6 = new TH2F("Ghf6", "", 22, -11., 11., 18, 0., 18.);
5630 
5631   TH2F *G20hf60 = new TH2F("G20hf60", "", 22, -11., 11., 18, 0., 18.);
5632   TH2F *G20hf61 = new TH2F("G20hf61", "", 22, -11., 11., 18, 0., 18.);
5633   TH2F *G20hf6 = new TH2F("G20hf6", "", 22, -11., 11., 18, 0., 18.);
5634   TH2F *G30hf60 = new TH2F("G30hf60", "", 22, -11., 11., 18, 0., 18.);
5635   TH2F *G30hf61 = new TH2F("G30hf61", "", 22, -11., 11., 18, 0., 18.);
5636   TH2F *G30hf6 = new TH2F("G30hf6", "", 22, -11., 11., 18, 0., 18.);
5637   TH2F *G40hf60 = new TH2F("G40hf60", "", 22, -11., 11., 18, 0., 18.);
5638   TH2F *G40hf61 = new TH2F("G40hf61", "", 22, -11., 11., 18, 0., 18.);
5639   TH2F *G40hf6 = new TH2F("G40hf6", "", 22, -11., 11., 18, 0., 18.);
5640   // j - etaphi index; i - # LSs;
5641   //
5642   // define mean and RMS:
5643   double sumjHF = 0.;
5644   int njHF = 0;
5645   double meanjHF = 0.;
5646   for (int j = 1; j <= ny; j++) {
5647     ccc0HF = Ghf1->GetBinContent(1, j);
5648     if (ccc0HF <= 0.)
5649       for (int i = 1; i <= nx; i++) {
5650         double ccc2 = Ghf1->GetBinContent(i, j);
5651         if (ccc2 > 0.) {
5652           ccc0HF = ccc2;
5653           break;
5654         }
5655       }
5656     if (ccc0HF > 0.) {
5657       for (int i = 1; i <= nx; i++) {
5658         double ccc1 = Ghf1->GetBinContent(i, j) / ccc0HF;
5659         if (ccc1 > 0.) {
5660           sumjHF += ccc1;
5661           njHF++;
5662         }
5663       }
5664       meanjHF = sumjHF / njHF;
5665     }
5666   }  // j
5667 
5668   double ssumjHF = 0.;
5669   njHF = 0;
5670   double sigmajHF = 0.;
5671   for (int j = 1; j <= ny; j++) {
5672     ccc0HF = Ghf1->GetBinContent(1, j);
5673     if (ccc0HF <= 0.)
5674       for (int i = 1; i <= nx; i++) {
5675         double ccc2 = Ghf1->GetBinContent(i, j);
5676         if (ccc2 > 0.) {
5677           ccc0HF = ccc2;
5678           break;
5679         }
5680       }
5681     if (ccc0HF > 0.) {
5682       for (int i = 1; i <= nx; i++) {
5683         double ccc1 = Ghf1->GetBinContent(i, j) / ccc0HF;
5684         if (ccc1 > 0.) {
5685           ssumjHF += (ccc1 - meanjHF) * (ccc1 - meanjHF);
5686           njHF++;
5687         }
5688       }
5689       sigmajHF = sqrt(ssumjHF / njHF);
5690     }
5691   }  // j
5692 
5693   double dif3rmsHFMIN = meanjHF - 3 * sigmajHF;
5694   if (dif3rmsHFMIN < 0.)
5695     dif3rmsHFMIN = 0.;
5696   double dif3rmsHFMAX = meanjHF + 3 * sigmajHF;
5697   cout << "22HF-2    meanjHF=  " << meanjHF << "  sigmajHF=  " << sigmajHF << "  dif3rmsHFMIN=  " << dif3rmsHFMIN
5698        << "  dif3rmsHFMAX=  " << dif3rmsHFMAX << endl;
5699 
5700   double MAXdif3rmsHFMIN = dif3rmsHFMIN;
5701   double MINdif3rmsHFMAX = dif3rmsHFMAX;
5702   if (MAXdif3rmsHFMIN < 0.95)
5703     MAXdif3rmsHFMIN = 0.95;
5704   if (MINdif3rmsHFMAX > 1.05)
5705     MINdif3rmsHFMAX = 1.05;
5706   cout << "22HF-2     MAXdif3rmsHFMIN=  " << MAXdif3rmsHFMIN << "     MINdif3rmsHFMAX=  " << MINdif3rmsHFMAX << endl;
5707   //
5708   for (int j = 1; j <= ny; j++) {
5709     ccc0HF = Ghf1->GetBinContent(1, j);
5710     if (ccc0HF <= 0.)
5711       for (int i = 1; i <= nx; i++) {
5712         double ccc2 = Ghf1->GetBinContent(i, j);
5713         if (ccc2 > 0.) {
5714           ccc0HF = ccc2;
5715           break;
5716         }
5717       }
5718     if (ccc0HF > 0.) {
5719       int jeta = (j - 1) / 18;         // jeta = 0-21
5720       int jphi = (j - 1) - 18 * jeta;  // jphi=0-17
5721       // i - # LSs:
5722       for (int i = 1; i <= nx; i++) {
5723         double ccc1 = Ghf1->GetBinContent(i, j);
5724         if (ccc1 > 0.) {
5725           double Rij = ccc1 / ccc0HF;
5726           if (Rij < MAXdif3rmsHFMIN || Rij > MINdif3rmsHFMAX) {
5727             Ghf61->Fill(jeta - 11, jphi, Rij);
5728             Ghf60->Fill(jeta - 11, jphi, 1.);
5729           }
5730           if (Rij < 0.8 || Rij > 1.2) {
5731             G20hf61->Fill(jeta - 11, jphi, Rij);
5732             G20hf60->Fill(jeta - 11, jphi, 1.);
5733           }
5734           if (Rij < 0.7 || Rij > 1.3) {
5735             G30hf61->Fill(jeta - 11, jphi, Rij);
5736             G30hf60->Fill(jeta - 11, jphi, 1.);
5737           }
5738           if (Rij < 0.6 || Rij > 1.4) {
5739             G40hf61->Fill(jeta - 11, jphi, Rij);
5740             G40hf60->Fill(jeta - 11, jphi, 1.);
5741           }
5742         }                                       //if(ccc1>0.
5743       }                                         // i
5744     }                                           //if(ccc0HF>0
5745   }                                             // j
5746   Ghf6->Divide(Ghf61, Ghf60, 1, 1, "B");        // average R
5747   G20hf6->Divide(G20hf61, G20hf60, 1, 1, "B");  // average R
5748   G30hf6->Divide(G30hf61, G30hf60, 1, 1, "B");  // average R
5749   G40hf6->Divide(G40hf61, G40hf60, 1, 1, "B");  // average R
5750   //      Ghf6->SetLabelOffset (Float_t offset=0.005, Option_t *axis="X")//Set offset between axis and axis' labels
5751   //      Ghf6->GetZaxis()->SetLabelOffset(-0.05);
5752   Ghf6->GetZaxis()->SetLabelSize(0.025);
5753 
5754   Ghf6->SetXTitle("             #eta  \b");
5755   Ghf6->SetYTitle("      #phi \b");
5756   Ghf6->SetTitle(
5757       "<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);
5758   //gStyle->SetOptStat(kFALSE);
5759   Ghf6->SetStats(0);
5760   Ghf6->Draw("COLZ");
5761   //================
5762   cRBX31->cd(3);
5763   TH1F *Ghf7 = new TH1F("Ghf7", "", 120, 0.4, 1.6);
5764   // j - etaphi index:
5765   for (int j = 1; j <= ny; j++) {
5766     ccc0HF = Ghf1->GetBinContent(1, j);
5767     if (ccc0HF <= 0.)
5768       for (int i = 1; i <= nx; i++) {
5769         double ccc2 = Ghf1->GetBinContent(i, j);
5770         if (ccc2 > 0.) {
5771           ccc0HF = ccc2;
5772           break;
5773         }
5774       }
5775     if (ccc0HF > 0.) {
5776       // i - # LSs:
5777       for (int i = 1; i <= nx; i++) {
5778         double ccc1 = Ghf1->GetBinContent(i, j);
5779         if (ccc1 > 0.) {
5780           double Rij = ccc1 / ccc0HF;
5781           Ghf7->Fill(Rij);
5782         }
5783       }
5784     }
5785   }
5786   Ghf7->SetMarkerStyle(20);
5787   Ghf7->SetMarkerSize(0.4);
5788   Ghf7->GetYaxis()->SetLabelSize(0.04);
5789   Ghf7->SetMarkerColor(2);
5790   Ghf7->SetLineColor(0);
5791   Ghf7->SetYTitle("        N  \b");
5792   Ghf7->SetXTitle("     Rij \b");
5793   Ghf7->SetTitle(" Rij \b");
5794   //Ghf7->SetMinimum(0.8);Ghf7->SetMaximum(500.);
5795   gPad->SetGridy();
5796   gPad->SetGridx();  //            gPad->SetLogy();
5797   //      Ghf7->SetStats(1110000);
5798   Ghf7->GetYaxis()->SetLabelSize(0.025);
5799   Ghf7->Draw("Error");
5800   Float_t ymaxHF = Ghf7->GetMaximum();
5801   cout << "22HF-3   ymaxHF=  " << ymaxHF << "       MAXdif3rmsHFMIN=  " << MAXdif3rmsHFMIN
5802        << "         MINdif3rmsHFMAX=  " << MINdif3rmsHFMAX << endl;
5803   TLine *lineHF = new TLine(MAXdif3rmsHFMIN, 0., MAXdif3rmsHFMIN, ymaxHF);
5804   lineHF->SetLineColor(kBlue);
5805   lineHF->Draw();
5806   TLine *line1HF = new TLine(MINdif3rmsHFMAX, 0., MINdif3rmsHFMAX, ymaxHF);
5807   line1HF->SetLineColor(kBlue);
5808   line1HF->Draw();
5809   //================
5810   /////////////////
5811   cRBX31->Update();
5812   cRBX31->Print("RBX-HF-3plots.png");
5813   cRBX31->Clear();
5814   // clean-up
5815   if (Ghf5)
5816     delete Ghf5;
5817   if (Ghf60)
5818     delete Ghf60;
5819   if (Ghf61)
5820     delete Ghf61;
5821   if (Ghf6)
5822     delete Ghf6;
5823   if (Ghf7)
5824     delete Ghf7;
5825 
5826   if (G20hf60)
5827     delete G20hf60;
5828   if (G20hf61)
5829     delete G20hf61;
5830   if (G30hf60)
5831     delete G30hf60;
5832   if (G30hf61)
5833     delete G30hf61;
5834   if (G40hf60)
5835     delete G40hf60;
5836   if (G40hf61)
5837     delete G40hf61;
5838 
5839   if (Ghf1)
5840     delete Ghf1;
5841   //========================================================================================== 22-1   HF:: Ratio plots   jeta = 0 - 21       jphi =0 - 17
5842   //======================================================================
5843   //======================================================================28.11.2018
5844   //======================================================================
5845   //======================================================================
5846 
5847   gStyle->SetOptStat(1110000);
5848   cout << "      RBX HF  Ratio plotsmore *****" << endl;
5849   cRBX31->Clear();
5850   /////////////////
5851   cRBX31->Divide(3, 1);
5852   //================
5853   cRBX31->cd(1);
5854   G20hf6->GetZaxis()->SetLabelSize(0.025);
5855   G20hf6->SetXTitle("             #eta  \b");
5856   G20hf6->SetYTitle("      #phi \b");
5857   G20hf6->SetTitle("<Rj> for |1-<R>| > 0.20 \b");
5858   G20hf6->SetStats(0);
5859   G20hf6->Draw("COLZ");
5860   //================
5861   cRBX31->cd(2);
5862   G30hf6->GetZaxis()->SetLabelSize(0.025);
5863   G30hf6->SetXTitle("             #eta  \b");
5864   G30hf6->SetYTitle("      #phi \b");
5865   G30hf6->SetTitle("<Rj> for |1-<R>| > 0.30 \b");
5866   G30hf6->SetStats(0);
5867   G30hf6->Draw("COLZ");
5868   //================
5869   cRBX31->cd(3);
5870   G40hf6->GetZaxis()->SetLabelSize(0.025);
5871   G40hf6->SetXTitle("             #eta  \b");
5872   G40hf6->SetYTitle("      #phi \b");
5873   G40hf6->SetTitle("<Rj> for |1-<R>| > 0.40 \b");
5874   G40hf6->SetStats(0);
5875   G40hf6->Draw("COLZ");
5876   //================
5877 
5878   /////////////////
5879   cRBX31->Update();
5880   cRBX31->Print("RBX-HF-3plotsmore.png");
5881   cRBX31->Clear();
5882 
5883   // clean-up
5884   if (G20hf6)
5885     delete G20hf6;
5886   if (G30hf6)
5887     delete G30hf6;
5888   if (G40hf6)
5889     delete G40hf6;
5890   gStyle->SetOptStat(0);
5891   ////////////////////////////////////////////////////////////////////////////////////
5892   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5893   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5894   cout << ">>>>>>>>>>>>>>>>>>>>>>>>                             " << endl;
5895   //////////////////////////////////////////////////////////////////////////////////// RBX  HF  study END:
5896 
5897   //////////////////////////////////////////////////////////////////////////////////// RBX study END:
5898 
5899   //////////////////////////////////////////////////////////////////////////////////// Special tests:
5900   //===============================================================================   occupancyHB
5901   // For occupancy plots. Produces OccPlots_HBx.png (x=1)
5902   int mymaxbins = MaxLum;
5903   {
5904     cHB->Clear();
5905     cHB->Divide(2, 1);
5906     /////////
5907     cHB->cd(1);
5908     TH2F *occhbm = (TH2F *)dir->FindObjectAny("h_RatioOccupancy_HBM");
5909     TH1F *uyhbm = new TH1F("uyhbm", "", mymaxbins, 1., mymaxbins + 1.);
5910     for (int i = 1; i <= occhbm->GetXaxis()->GetNbins(); i++) {
5911       double ccc1 = occhbm->GetBinContent(i);
5912       //      if(ccc1>0.)     cout<<" depth1_HB iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
5913       if (ccc1 > 0.)
5914         uyhbm->Fill(float(i), ccc1);
5915     }
5916     //      gPad->SetLogy();
5917     uyhbm->SetMarkerStyle(20);
5918     uyhbm->SetMarkerSize(0.6);
5919     uyhbm->GetYaxis()->SetLabelSize(0.04);
5920     uyhbm->SetXTitle("min/av occupancy - HBM \b");
5921     uyhbm->SetMarkerColor(2);
5922     uyhbm->SetLineColor(0);
5923     uyhbm->SetMaximum(1.0);
5924     uyhbm->SetMinimum(0.2);
5925     gPad->SetGridy();
5926     uyhbm->Draw("Error");
5927     /////////
5928     cHB->cd(2);
5929     TH2F *occhbp = (TH2F *)dir->FindObjectAny("h_RatioOccupancy_HBP");
5930     TH1F *uyhbp = new TH1F("uyhbp", "", mymaxbins, 1., mymaxbins + 1.);
5931     for (int i = 1; i <= occhbp->GetXaxis()->GetNbins(); i++) {
5932       double ccc1 = occhbp->GetBinContent(i);
5933       //      if(ccc1>0.)     cout<<" depth1_HB iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
5934       if (ccc1 > 0.)
5935         uyhbp->Fill(float(i), ccc1);
5936     }
5937     //      gPad->SetLogy();
5938     uyhbp->SetMarkerStyle(20);
5939     uyhbp->SetMarkerSize(0.6);
5940     uyhbp->GetYaxis()->SetLabelSize(0.04);
5941     uyhbp->SetXTitle("min/av occupancy - HBP \b");
5942     uyhbp->SetMarkerColor(2);
5943     uyhbp->SetLineColor(0);
5944     uyhbp->SetMaximum(1.0);
5945     uyhbp->SetMinimum(0.2);
5946     gPad->SetGridy();
5947     uyhbp->Draw("Error");
5948     /////////
5949 
5950     /////////
5951     cHB->Update();
5952     cHB->Print(Form("OccPlots_HB.png"));
5953     cHB->Clear();
5954 
5955     // clean-up
5956     if (occhbm)
5957       delete occhbm;
5958     if (uyhbm)
5959       delete uyhbm;
5960     if (occhbp)
5961       delete occhbp;
5962     if (uyhbp)
5963       delete uyhbp;
5964   }
5965   //===============================================================================   occupancyHE
5966   // For occupancy plots. Produces OccPlots_HEx.png (x=1)
5967   {
5968     cHB->Clear();
5969     cHB->Divide(2, 1);
5970     /////////
5971     cHB->cd(1);
5972     TH2F *occhem = (TH2F *)dir->FindObjectAny("h_RatioOccupancy_HEM");
5973     TH1F *uyhem = new TH1F("uyhem", "", mymaxbins, 1., mymaxbins + 1.);
5974     for (int i = 1; i <= occhem->GetXaxis()->GetNbins(); i++) {
5975       double ccc1 = occhem->GetBinContent(i);
5976       //      if(ccc1>0.)     cout<<" depth1_HE iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
5977       if (ccc1 > 0.)
5978         uyhem->Fill(float(i), ccc1);
5979     }
5980     //      gPad->SetLogy();
5981     uyhem->SetMarkerStyle(20);
5982     uyhem->SetMarkerSize(0.6);
5983     uyhem->GetYaxis()->SetLabelSize(0.04);
5984     uyhem->SetXTitle("min/av occupancy - HEM \b");
5985     uyhem->SetMarkerColor(2);
5986     uyhem->SetLineColor(0);
5987     uyhem->SetMaximum(1.0);
5988     uyhem->SetMinimum(0.2);
5989     gPad->SetGridy();
5990     uyhem->Draw("Error");
5991     /////////
5992     cHB->cd(2);
5993     TH2F *occhep = (TH2F *)dir->FindObjectAny("h_RatioOccupancy_HEP");
5994     TH1F *uyhep = new TH1F("uyhep", "", mymaxbins, 1., mymaxbins + 1.);
5995     for (int i = 1; i <= occhep->GetXaxis()->GetNbins(); i++) {
5996       double ccc1 = occhep->GetBinContent(i);
5997       //      if(ccc1>0.)     cout<<" depth1_HE iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
5998       if (ccc1 > 0.)
5999         uyhep->Fill(float(i), ccc1);
6000     }
6001     //      gPad->SetLogy();
6002     uyhep->SetMarkerStyle(20);
6003     uyhep->SetMarkerSize(0.6);
6004     uyhep->GetYaxis()->SetLabelSize(0.04);
6005     uyhep->SetXTitle("min/av occupancy - HEP \b");
6006     uyhep->SetMarkerColor(2);
6007     uyhep->SetLineColor(0);
6008     uyhep->SetMaximum(1.0);
6009     uyhep->SetMinimum(0.2);
6010     gPad->SetGridy();
6011     uyhep->Draw("Error");
6012     /////////
6013 
6014     /////////
6015     cHB->Update();
6016     cHB->Print(Form("OccPlots_HE.png"));
6017     cHB->Clear();
6018 
6019     // clean-up
6020     if (occhem)
6021       delete occhem;
6022     if (uyhem)
6023       delete uyhem;
6024     if (occhep)
6025       delete occhep;
6026     if (uyhep)
6027       delete uyhep;
6028   }
6029   //===============================================================================   occupancyHO
6030   // For occupancy plots. Produces OccPlots_HOx.png (x=1)
6031   {
6032     cHB->Clear();
6033     cHB->Divide(2, 1);
6034     /////////
6035     cHB->cd(1);
6036     TH2F *occhom = (TH2F *)dir->FindObjectAny("h_RatioOccupancy_HOM");
6037     TH1F *uyhom = new TH1F("uyhom", "", mymaxbins, 1., mymaxbins + 1.);
6038     for (int i = 1; i <= occhom->GetXaxis()->GetNbins(); i++) {
6039       double ccc1 = occhom->GetBinContent(i);
6040       //      if(ccc1>0.)     cout<<" depth1_HO iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
6041       if (ccc1 > 0.)
6042         uyhom->Fill(float(i), ccc1);
6043     }
6044     //      gPad->SetLogy();
6045     uyhom->SetMarkerStyle(20);
6046     uyhom->SetMarkerSize(0.6);
6047     uyhom->GetYaxis()->SetLabelSize(0.04);
6048     uyhom->SetXTitle("min/av occupancy - HOM \b");
6049     uyhom->SetMarkerColor(2);
6050     uyhom->SetLineColor(0);
6051     uyhom->SetMaximum(1.0);
6052     uyhom->SetMinimum(0.2);
6053     gPad->SetGridy();
6054     uyhom->Draw("Error");
6055     /////////
6056     cHB->cd(2);
6057     TH2F *occhop = (TH2F *)dir->FindObjectAny("h_RatioOccupancy_HOP");
6058     TH1F *uyhop = new TH1F("uyhop", "", mymaxbins, 1., mymaxbins + 1.);
6059     for (int i = 1; i <= occhop->GetXaxis()->GetNbins(); i++) {
6060       double ccc1 = occhop->GetBinContent(i);
6061       //      if(ccc1>0.)     cout<<" depth1_HO iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
6062       if (ccc1 > 0.)
6063         uyhop->Fill(float(i), ccc1);
6064     }
6065     //      gPad->SetLogy();
6066     uyhop->SetMarkerStyle(20);
6067     uyhop->SetMarkerSize(0.6);
6068     uyhop->GetYaxis()->SetLabelSize(0.04);
6069     uyhop->SetXTitle("min/av occupancy - HOP \b");
6070     uyhop->SetMarkerColor(2);
6071     uyhop->SetLineColor(0);
6072     uyhop->SetMaximum(1.0);
6073     uyhop->SetMinimum(0.2);
6074     gPad->SetGridy();
6075     uyhop->Draw("Error");
6076     /////////
6077 
6078     /////////
6079     cHB->Update();
6080     cHB->Print(Form("OccPlots_HO.png"));
6081     cHB->Clear();
6082 
6083     // clean-up
6084     if (occhom)
6085       delete occhom;
6086     if (uyhom)
6087       delete uyhom;
6088     if (occhop)
6089       delete occhop;
6090     if (uyhop)
6091       delete uyhop;
6092   }
6093   //===============================================================================   occupancyHF
6094   // For occupancy plots. Produces OccPlots_HFx.png (x=1)
6095   {
6096     cHB->Clear();
6097     cHB->Divide(2, 1);
6098     /////////
6099     cHB->cd(1);
6100     TH2F *occhfm = (TH2F *)dir->FindObjectAny("h_RatioOccupancy_HFM");
6101     TH1F *uyhfm = new TH1F("uyhfm", "", mymaxbins, 1., mymaxbins + 1.);
6102     for (int i = 1; i <= occhfm->GetXaxis()->GetNbins(); i++) {
6103       double ccc1 = occhfm->GetBinContent(i);
6104       //      if(ccc1>0.)     cout<<" depth1_HF iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
6105       if (ccc1 > 0.)
6106         uyhfm->Fill(float(i), ccc1);
6107     }
6108     //      gPad->SetLogy();
6109     uyhfm->SetMarkerStyle(20);
6110     uyhfm->SetMarkerSize(0.6);
6111     uyhfm->GetYaxis()->SetLabelSize(0.04);
6112     uyhfm->SetXTitle("min/av occupancy - HFM \b");
6113     uyhfm->SetMarkerColor(2);
6114     uyhfm->SetLineColor(0);
6115     uyhfm->SetMaximum(1.0);
6116     uyhfm->SetMinimum(0.2);
6117     gPad->SetGridy();
6118     uyhfm->Draw("Error");
6119     /////////
6120     cHB->cd(2);
6121     TH2F *occhfp = (TH2F *)dir->FindObjectAny("h_RatioOccupancy_HFP");
6122     TH1F *uyhfp = new TH1F("uyhfp", "", mymaxbins, 1., mymaxbins + 1.);
6123     for (int i = 1; i <= occhfp->GetXaxis()->GetNbins(); i++) {
6124       double ccc1 = occhfp->GetBinContent(i);
6125       //      if(ccc1>0.)     cout<<" depth1_HF iLS = "<<i<<" <As> per LS= "<<ccc1<<endl;
6126       if (ccc1 > 0.)
6127         uyhfp->Fill(float(i), ccc1);
6128     }
6129     //      gPad->SetLogy();
6130     uyhfp->SetMarkerStyle(20);
6131     uyhfp->SetMarkerSize(0.6);
6132     uyhfp->GetYaxis()->SetLabelSize(0.04);
6133     uyhfp->SetXTitle("min/av occupancy - HFP \b");
6134     uyhfp->SetMarkerColor(2);
6135     uyhfp->SetLineColor(0);
6136     uyhfp->SetMaximum(1.0);
6137     uyhfp->SetMinimum(0.2);
6138     gPad->SetGridy();
6139     uyhfp->Draw("Error");
6140     /////////
6141 
6142     /////////
6143     cHB->Update();
6144     cHB->Print(Form("OccPlots_HF.png"));
6145     cHB->Clear();
6146 
6147     // clean-up
6148     if (occhfm)
6149       delete occhfm;
6150     if (uyhfm)
6151       delete uyhfm;
6152     if (occhfp)
6153       delete occhfp;
6154     if (uyhfp)
6155       delete uyhfp;
6156   }
6157   std::cout << "************>>>   occupancy plots done" << std::endl;
6158 
6159   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6160   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6161   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6162   /// Summed Amplitude Plots:
6163   //*************************                        *****     Signal                   *****
6164   cout << ">>>>>>>>>>>>>>>>>>>>>>>>start Summed Amplitude Plots " << endl;
6165   int maxbins = MaxLum;
6166   cout << ">>>>   maxbins =     " << maxbins << endl;
6167   TH1F *SummedAmplitudeHisto[4];  // 1d histogramm for subdet
6168   SummedAmplitudeHisto[0] = (TH1F *)dir->FindObjectAny("h_averSIGNALsumamplitude_HB");
6169   SummedAmplitudeHisto[1] = (TH1F *)dir->FindObjectAny("h_averSIGNALsumamplitude_HE");
6170   SummedAmplitudeHisto[2] = (TH1F *)dir->FindObjectAny("h_averSIGNALsumamplitude_HO");
6171   SummedAmplitudeHisto[3] = (TH1F *)dir->FindObjectAny("h_averSIGNALsumamplitude_HF");
6172   TH1F *SummedAmplitudeOccupancyHisto[4];  // 1d histogramm for subdet
6173   SummedAmplitudeOccupancyHisto[0] = (TH1F *)dir->FindObjectAny("h_averSIGNALoccupancy_HB");
6174   SummedAmplitudeOccupancyHisto[1] = (TH1F *)dir->FindObjectAny("h_averSIGNALoccupancy_HE");
6175   SummedAmplitudeOccupancyHisto[2] = (TH1F *)dir->FindObjectAny("h_averSIGNALoccupancy_HO");
6176   SummedAmplitudeOccupancyHisto[3] = (TH1F *)dir->FindObjectAny("h_averSIGNALoccupancy_HF");
6177   for (int sub = 0; sub < 4; sub++) {
6178     cHE->Clear();
6179     cHE->Divide(2, 1);
6180     cHE->cd(1);
6181     TH1F *kslpq = new TH1F("kslpq", "", maxbins, 1., maxbins + 1.);
6182     //    cout<<">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   sub =     "<< sub <<endl;
6183     for (int i = 1; i <= kslpq->GetXaxis()->GetNbins(); i++) {
6184       double ccc1 = 0.;
6185       if (SummedAmplitudeHisto[sub])
6186         ccc1 = SummedAmplitudeHisto[sub]->GetBinContent(i);
6187       //          if(ccc1>0.)     cout<<"  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6188       if (ccc1 > 0.)
6189         kslpq->Fill(float(i), ccc1);
6190     }
6191     //      gPad->SetLogy();
6192     kslpq->SetMarkerStyle(20);
6193     kslpq->SetMarkerSize(0.8);
6194     kslpq->GetYaxis()->SetLabelSize(0.04);
6195     kslpq->SetXTitle("SumA of channels w/ signal per LS \b");
6196     kslpq->SetMarkerColor(2);
6197     kslpq->SetLineColor(0);
6198     //  kslpq->SetMinimum(0.8);
6199     gPad->SetGridx();
6200     kslpq->Draw("Error");
6201     /////////
6202     cHE->cd(2);
6203     TH1F *pqmks = new TH1F("pqmks", "", maxbins, 1., maxbins + 1.);
6204     for (int i = 1; i <= pqmks->GetXaxis()->GetNbins(); i++) {
6205       double ccc1 = 0.;
6206       if (SummedAmplitudeOccupancyHisto[sub])
6207         ccc1 = SummedAmplitudeOccupancyHisto[sub]->GetBinContent(i);
6208       //      if(ccc1>0.)     cout<<"  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6209       if (ccc1 > 0.)
6210         pqmks->Fill(float(i), ccc1);
6211     }
6212     //      gPad->SetLogy();
6213     pqmks->SetMarkerStyle(20);
6214     pqmks->SetMarkerSize(0.8);
6215     pqmks->GetYaxis()->SetLabelSize(0.04);
6216     pqmks->SetXTitle("Occupancy of channels w/ signal per LS  \b");
6217     pqmks->SetMarkerColor(4);
6218     pqmks->SetLineColor(0);
6219     //  pqmks->SetMinimum(0.8);
6220     gPad->SetGridx();
6221     pqmks->Draw("Error");
6222     cHE->Update();
6223     if (sub == 0)
6224       cHE->Print("SummedAmplitudesSignal_HB.png");
6225     if (sub == 1)
6226       cHE->Print("SummedAmplitudesSignal_HE.png");
6227     if (sub == 2)
6228       cHE->Print("SummedAmplitudesSignal_HO.png");
6229     if (sub == 3)
6230       cHE->Print("SummedAmplitudesSignal_HF.png");
6231     cHE->Clear();
6232     if (kslpq)
6233       delete kslpq;
6234     if (pqmks)
6235       delete pqmks;
6236   }  //for
6237   // clean-up
6238   //for (unsigned int i=0; i<4; i++) {delete SummedAmplitudeHisto[i];delete SummedAmplitudeOccupancyHisto[i];}
6239 
6240   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6241   /// Summed Amplitude Plots:
6242   //*************************                        *****     NoSignal                   *****
6243   cout << ">>>>>>>>>>>>>>>>>>>>>>>>start Summed Amplitude Plots NoSignal " << endl;
6244   TH1F *NoSignalSummedAmplitudeHisto[4];  // 1d histogramm for subdet
6245   NoSignalSummedAmplitudeHisto[0] = (TH1F *)dir->FindObjectAny("h_averNOSIGNALsumamplitude_HB");
6246   NoSignalSummedAmplitudeHisto[1] = (TH1F *)dir->FindObjectAny("h_averNOSIGNALsumamplitude_HE");
6247   NoSignalSummedAmplitudeHisto[2] = (TH1F *)dir->FindObjectAny("h_averNOSIGNALsumamplitude_HO");
6248   NoSignalSummedAmplitudeHisto[3] = (TH1F *)dir->FindObjectAny("h_averNOSIGNALsumamplitude_HF");
6249   TH1F *NoSignalSummedAmplitudeOccupancyHisto[4];  // 1d histogramm for subdet
6250   NoSignalSummedAmplitudeOccupancyHisto[0] = (TH1F *)dir->FindObjectAny("h_averNOSIGNALoccupancy_HB");
6251   NoSignalSummedAmplitudeOccupancyHisto[1] = (TH1F *)dir->FindObjectAny("h_averNOSIGNALoccupancy_HE");
6252   NoSignalSummedAmplitudeOccupancyHisto[2] = (TH1F *)dir->FindObjectAny("h_averNOSIGNALoccupancy_HO");
6253   NoSignalSummedAmplitudeOccupancyHisto[3] = (TH1F *)dir->FindObjectAny("h_averNOSIGNALoccupancy_HF");
6254   for (int sub = 0; sub < 4; sub++) {
6255     cHE->Clear();
6256     cHE->Divide(2, 1);
6257 
6258     cHE->cd(1);
6259     TH1F *kslpq = new TH1F("kslpq", "", maxbins, 1., maxbins + 1.);
6260     for (int i = 1; i <= kslpq->GetXaxis()->GetNbins(); i++) {
6261       double ccc1 = 0.;
6262       if (NoSignalSummedAmplitudeHisto[sub])
6263         ccc1 = NoSignalSummedAmplitudeHisto[sub]->GetBinContent(i);
6264       //      if(ccc1>0.)     cout<<"  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6265       if (ccc1 > 0.)
6266         kslpq->Fill(float(i), ccc1);
6267     }
6268     //      gPad->SetLogy();
6269     kslpq->SetMarkerStyle(20);
6270     kslpq->SetMarkerSize(0.8);
6271     kslpq->GetYaxis()->SetLabelSize(0.04);
6272     kslpq->SetXTitle("SumA of channels w/o signal per LS \b");
6273     kslpq->SetMarkerColor(2);
6274     kslpq->SetLineColor(0);
6275     if (sub == 0) {
6276       kslpq->SetMaximum(20000.);
6277       kslpq->SetMinimum(5000.);
6278     } else if (sub == 1) {
6279       kslpq->SetMaximum(40000.);
6280       kslpq->SetMinimum(0.);
6281     } else if (sub == 2) {
6282       kslpq->SetMaximum(10000.);
6283       kslpq->SetMinimum(15000.);
6284     } else if (sub == 3) {
6285       kslpq->SetMaximum(100000.);
6286       kslpq->SetMinimum(0.);
6287     }
6288     gPad->SetGridx();
6289     kslpq->Draw("Error");
6290     /////////
6291     cHE->cd(2);
6292     TH1F *pqmks = new TH1F("pqmks", "", maxbins, 1., maxbins + 1.);
6293     for (int i = 1; i <= pqmks->GetXaxis()->GetNbins(); i++) {
6294       double ccc1 = 0.;
6295       if (NoSignalSummedAmplitudeOccupancyHisto[sub])
6296         ccc1 = NoSignalSummedAmplitudeOccupancyHisto[sub]->GetBinContent(i);
6297       //      if(ccc1>0.)     cout<<"  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6298       if (ccc1 > 0.)
6299         pqmks->Fill(float(i), ccc1);
6300     }
6301     //      gPad->SetLogy();
6302     pqmks->SetMarkerStyle(20);
6303     pqmks->SetMarkerSize(0.8);
6304     pqmks->GetYaxis()->SetLabelSize(0.04);
6305     pqmks->SetXTitle("Occupancy of channels w/o signal per LS  \b");
6306     pqmks->SetMarkerColor(4);
6307     pqmks->SetLineColor(0);
6308     if (sub == 0) {
6309       pqmks->SetMaximum(600.);
6310       pqmks->SetMinimum(200.);
6311     } else if (sub == 1) {
6312       pqmks->SetMaximum(910.);
6313       pqmks->SetMinimum(10.);
6314     } else if (sub == 2) {
6315       pqmks->SetMaximum(200.);
6316       pqmks->SetMinimum(50.);
6317     } else if (sub == 3) {
6318       pqmks->SetMaximum(866.);
6319       pqmks->SetMinimum(856.);
6320     }
6321     gPad->SetGridx();
6322     pqmks->Draw("Error");
6323     cHE->Update();
6324     if (sub == 0)
6325       cHE->Print("NoSignalSummedAmplitudes_HB.png");
6326     if (sub == 1)
6327       cHE->Print("NoSignalSummedAmplitudes_HE.png");
6328     if (sub == 2)
6329       cHE->Print("NoSignalSummedAmplitudes_HO.png");
6330     if (sub == 3)
6331       cHE->Print("NoSignalSummedAmplitudes_HF.png");
6332     cHE->Clear();
6333     if (kslpq)
6334       delete kslpq;
6335     if (pqmks)
6336       delete pqmks;
6337   }  //for
6338   // clean-up
6339   //for (unsigned int i=0; i<4; i++) {delete NoSignalSummedAmplitudeHisto[i];delete NoSignalSummedAmplitudeOccupancyHisto[i];}
6340   //////////
6341 
6342   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6343   /// Summed Amplitude Plots:
6344   //*************************                        *****     MaxxValues                   *****
6345   cout << ">>>>>>>>>>>>>>>>>>>>>>>>start Summed Amplitude Plots Maxx " << endl;
6346   TH1F *MaxxSummedAmplitudeHisto[4];  // 1d histogramm for subdet
6347   MaxxSummedAmplitudeHisto[0] = (TH1F *)dir->FindObjectAny("h_maxxSUMAmpl_HB");
6348   MaxxSummedAmplitudeHisto[1] = (TH1F *)dir->FindObjectAny("h_maxxSUMAmpl_HE");
6349   MaxxSummedAmplitudeHisto[2] = (TH1F *)dir->FindObjectAny("h_maxxSUMAmpl_HO");
6350   MaxxSummedAmplitudeHisto[3] = (TH1F *)dir->FindObjectAny("h_maxxSUMAmpl_HF");
6351   TH1F *MaxxSummedAmplitudeOccupancyHisto[4];  // 1d histogramm for subdet
6352   MaxxSummedAmplitudeOccupancyHisto[0] = (TH1F *)dir->FindObjectAny("h_maxxOCCUP_HB");
6353   MaxxSummedAmplitudeOccupancyHisto[1] = (TH1F *)dir->FindObjectAny("h_maxxOCCUP_HE");
6354   MaxxSummedAmplitudeOccupancyHisto[2] = (TH1F *)dir->FindObjectAny("h_maxxOCCUP_HO");
6355   MaxxSummedAmplitudeOccupancyHisto[3] = (TH1F *)dir->FindObjectAny("h_maxxOCCUP_HF");
6356   TH1F *SAmplitudeHisto[4];  // 1d histogramm for subdet
6357   SAmplitudeHisto[0] = (TH1F *)dir->FindObjectAny("h_eventamplitude_HB");
6358   SAmplitudeHisto[1] = (TH1F *)dir->FindObjectAny("h_eventamplitude_HE");
6359   SAmplitudeHisto[2] = (TH1F *)dir->FindObjectAny("h_eventamplitude_HO");
6360   SAmplitudeHisto[3] = (TH1F *)dir->FindObjectAny("h_eventamplitude_HF");
6361   TH1F *OccupancyHisto[4];  // 1d histogramm for subdet
6362   OccupancyHisto[0] = (TH1F *)dir->FindObjectAny("h_eventoccupancy_HB");
6363   OccupancyHisto[1] = (TH1F *)dir->FindObjectAny("h_eventoccupancy_HE");
6364   OccupancyHisto[2] = (TH1F *)dir->FindObjectAny("h_eventoccupancy_HO");
6365   OccupancyHisto[3] = (TH1F *)dir->FindObjectAny("h_eventoccupancy_HF");
6366 
6367   int countamplmaxHB = 0;
6368   int countamplmaxHE = 0;
6369   int countamplmaxHO = 0;
6370   int countamplmaxHF = 0;
6371   int countoccumaxHB = 0;
6372   int countoccumaxHE = 0;
6373   int countoccumaxHO = 0;
6374   int countoccumaxHF = 0;
6375   unsigned long int countamplHB = 0;
6376   unsigned long int countamplHE = 0;
6377   unsigned long int countamplHO = 0;
6378   unsigned long int countamplHF = 0;
6379   unsigned long int countoccuHB = 0;
6380   unsigned long int countoccuHE = 0;
6381   unsigned long int countoccuHO = 0;
6382   unsigned long int countoccuHF = 0;
6383   gStyle->SetOptStat(110000);
6384   for (int sub = 0; sub < 4; sub++) {
6385     cFour->Clear();
6386     cFour->Divide(2, 2);
6387 
6388     cFour->cd(1);
6389     TH1F *lpqxc = new TH1F("lpqxc", "", maxbins, 1., maxbins + 1.);
6390     for (int i = 1; i <= lpqxc->GetXaxis()->GetNbins(); i++) {
6391       double ccc1 = 0.;
6392       if (MaxxSummedAmplitudeHisto[sub])
6393         ccc1 = MaxxSummedAmplitudeHisto[sub]->GetBinContent(i);
6394       //      if(ccc1>0.)     cout<<"111111111111111111111111111  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6395       if (ccc1 > 0.)
6396         lpqxc->Fill(float(i), ccc1);
6397       if (sub == 0 && ccc1 > 60000.)
6398         countamplmaxHB++;
6399       if (sub == 1 && ccc1 > 60000.)
6400         countamplmaxHE++;
6401       if (sub == 2 && ccc1 > 150000.)
6402         countamplmaxHO++;
6403       if (sub == 3 && ccc1 > 22000.)
6404         countamplmaxHF++;
6405     }
6406     //      gPad->SetLogy();
6407     lpqxc->SetMarkerStyle(20);
6408     lpqxc->SetMarkerSize(0.8);
6409     //    lpqxc->GetYaxis()->SetLabelSize(0.08);
6410     if (sub == 0)
6411       lpqxc->SetXTitle("HB: max SA over LS-events per LS \b");
6412     if (sub == 1)
6413       lpqxc->SetXTitle("HE: max SA over LS-events per LS \b");
6414     if (sub == 2)
6415       lpqxc->SetXTitle("HO: max SA over LS-events per LS \b");
6416     if (sub == 3)
6417       lpqxc->SetXTitle("HF: max SA over LS-events per LS \b");
6418     lpqxc->SetMarkerColor(2);
6419     lpqxc->SetLineColor(0);
6420     gPad->SetGridx();
6421     lpqxc->Draw("Error");
6422 
6423     /////////
6424     cFour->cd(2);
6425     TH1F *hpzlm = new TH1F("hpzlm", "", maxbins, 1., maxbins + 1.);
6426     for (int i = 1; i <= hpzlm->GetXaxis()->GetNbins(); i++) {
6427       double ccc1 = 0.;
6428       if (MaxxSummedAmplitudeOccupancyHisto[sub])
6429         ccc1 = MaxxSummedAmplitudeOccupancyHisto[sub]->GetBinContent(i);
6430       //    if(ccc1>0.)   cout<<"2222222222222222222222222  iLS = "<<i<<"  LS= "<<ccc1<<endl;
6431       if (ccc1 > 0.)
6432         hpzlm->Fill(float(i), ccc1);
6433       if (sub == 0 && ccc1 > 2000.)
6434         countoccumaxHB++;
6435       if (sub == 1 && ccc1 > 1200.)
6436         countoccumaxHE++;
6437       if (sub == 2 && ccc1 > 2000.)
6438         countoccumaxHO++;
6439       if (sub == 3 && ccc1 > 860.)
6440         countoccumaxHF++;
6441     }
6442     //      gPad->SetLogy();
6443     hpzlm->SetMarkerStyle(20);
6444     hpzlm->SetMarkerSize(0.8);
6445     //    hpzlm->GetYaxis()->SetLabelSize(0.08);
6446     if (sub == 0)
6447       hpzlm->SetXTitle("HB: max Occupancy over LS-events per LS \b");
6448     if (sub == 1)
6449       hpzlm->SetXTitle("HE: max Occupancy over LS-events per LS \b");
6450     if (sub == 2)
6451       hpzlm->SetXTitle("HO: max Occupancy over LS-events per LS \b");
6452     if (sub == 3)
6453       hpzlm->SetXTitle("HF: max Occupancy over LS-events per LS \b");
6454     hpzlm->SetMarkerColor(4);
6455     hpzlm->SetLineColor(0);
6456     gPad->SetGridx();
6457     if (sub == 3) {
6458       hpzlm->SetMaximum(866.);
6459       hpzlm->SetMinimum(856.);
6460     }
6461     hpzlm->Draw("Error");
6462 
6463     /////////
6464     cFour->cd(3);
6465     gPad->SetLogy();
6466     if (SAmplitudeHisto[sub]) {
6467       for (int i = 1; i <= SAmplitudeHisto[sub]->GetXaxis()->GetNbins(); i++) {
6468         //      if(sub==0 && i * 800> 60000.) {
6469         //  cout<<">=>=>>=> countamplHB= "<<countamplHB<<" content = "<<SAmplitudeHisto[sub]->GetBinContent(i)<<" sub= "<<sub<<" i= "<<i<<  endl;
6470         //  countamplHB+=SAmplitudeHisto[sub]->GetBinContent(i);
6471         //      }
6472         if (sub == 0 && i * 800 > 60000.)
6473           countamplHB += SAmplitudeHisto[sub]->GetBinContent(i);
6474         if (sub == 1 && i * 1000 > 60000.)
6475           countamplHE += SAmplitudeHisto[sub]->GetBinContent(i);
6476         if (sub == 2 && i * 2500 > 150000.)
6477           countamplHO += SAmplitudeHisto[sub]->GetBinContent(i);
6478         if (sub == 3 && i * 1400 > 22000.)
6479           countamplHF += SAmplitudeHisto[sub]->GetBinContent(i);
6480       }
6481       SAmplitudeHisto[sub]->SetMarkerStyle(20);
6482       SAmplitudeHisto[sub]->SetMarkerSize(0.8);
6483       if (sub == 0)
6484         SAmplitudeHisto[sub]->SetTitle("HB event Amplitude\b");
6485       if (sub == 1)
6486         SAmplitudeHisto[sub]->SetTitle("HE event Amplitude\b");
6487       if (sub == 2)
6488         SAmplitudeHisto[sub]->SetTitle("HO event Amplitude\b");
6489       if (sub == 3)
6490         SAmplitudeHisto[sub]->SetTitle("HF event Amplitude\b");
6491       //    SAmplitudeHisto[sub]->GetYaxis()->SetLabelSize(0.08);
6492       SAmplitudeHisto[sub]->SetXTitle("event amplitude \b");
6493       SAmplitudeHisto[sub]->SetMarkerColor(2);
6494       SAmplitudeHisto[sub]->SetLineColor(2);
6495       SAmplitudeHisto[sub]->Draw("");
6496     }
6497     /////////
6498     cFour->cd(4);
6499     gPad->SetLogy();
6500     if (OccupancyHisto[sub]) {
6501       for (int i = 1; i <= OccupancyHisto[sub]->GetXaxis()->GetNbins(); i++) {
6502         if (sub == 0 && i * 30 > 2000.)
6503           countoccuHB += OccupancyHisto[sub]->GetBinContent(i);
6504         if (sub == 1 && i * 20 > 1200.)
6505           countoccuHE += OccupancyHisto[sub]->GetBinContent(i);
6506         if (sub == 2 && i * 25 > 2000.)
6507           countoccuHO += OccupancyHisto[sub]->GetBinContent(i);
6508         if (sub == 3 && i * 10 > 860.)
6509           countoccuHF += OccupancyHisto[sub]->GetBinContent(i);
6510       }
6511       OccupancyHisto[sub]->SetMarkerStyle(20);
6512       OccupancyHisto[sub]->SetMarkerSize(0.8);
6513       if (sub == 0)
6514         OccupancyHisto[sub]->SetTitle("HB event Occupancy\b");
6515       if (sub == 1)
6516         OccupancyHisto[sub]->SetTitle("HE event Occupancy\b");
6517       if (sub == 2)
6518         OccupancyHisto[sub]->SetTitle("HO event Occupancy\b");
6519       if (sub == 3)
6520         OccupancyHisto[sub]->SetTitle("HF event Occupancy\b");
6521       //    OccupancyHisto[sub]->GetYaxis()->SetLabelSize(0.08);
6522       OccupancyHisto[sub]->SetXTitle("event occupancy \b");
6523       OccupancyHisto[sub]->SetMarkerColor(4);
6524       OccupancyHisto[sub]->SetLineColor(4);
6525       OccupancyHisto[sub]->Draw("");
6526     }
6527 
6528     cFour->Update();
6529     if (sub == 0)
6530       cFour->Print("MaxxSummedAmplitudes_HB.png");
6531     if (sub == 1)
6532       cFour->Print("MaxxSummedAmplitudes_HE.png");
6533     if (sub == 2)
6534       cFour->Print("MaxxSummedAmplitudes_HO.png");
6535     if (sub == 3)
6536       cFour->Print("MaxxSummedAmplitudes_HF.png");
6537     cFour->Clear();
6538     if (lpqxc)
6539       delete lpqxc;
6540     if (hpzlm)
6541       delete hpzlm;
6542   }  //for
6543   gStyle->SetOptStat(0);
6544   //////////
6545   cout << ">=>=>>=> countamplmaxHB= " << countamplmaxHB << " countamplmaxHE= " << countamplmaxHE
6546        << " countamplmaxHO= " << countamplmaxHO << " countamplmaxHF= " << countamplmaxHF << endl;
6547   cout << ">=>=>>=> countoccumaxHB= " << countoccumaxHB << " countoccumaxHE= " << countoccumaxHE
6548        << " countoccumaxHO= " << countoccumaxHO << " countoccumaxHF= " << countoccumaxHF << endl;
6549   cout << ">=>=>>=> countamplHB= " << countamplHB << " countamplHE= " << countamplHE << " countamplHO= " << countamplHO
6550        << " countamplHF= " << countamplHF << endl;
6551   cout << ">=>=>>=> countoccuHB= " << countoccuHB << " countoccuHE= " << countoccuHE << " countoccuHO= " << countoccuHO
6552        << " countoccuHF= " << countoccuHF << endl;
6553 
6554   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6555   /// Summed Amplitude Plots:
6556   //*************************                        *****     channelsummedA over depths                   *****
6557   cout << ">>>>>>>>>>>>>>>>>>>>>>>>channelsummedA over depths " << endl;
6558   TH1F *ChannelDepthsummedAmplitudesPlots[4];  // 1d histogramm for subdet
6559   ChannelDepthsummedAmplitudesPlots[0] = (TH1F *)dir->FindObjectAny("h_sumamplitudechannel_HB");
6560   ChannelDepthsummedAmplitudesPlots[1] = (TH1F *)dir->FindObjectAny("h_sumamplitudechannel_HE");
6561   ChannelDepthsummedAmplitudesPlots[2] = (TH1F *)dir->FindObjectAny("h_sumamplitudechannel_HO");
6562   ChannelDepthsummedAmplitudesPlots[3] = (TH1F *)dir->FindObjectAny("h_sumamplitudechannel_HF");
6563   TLine *litebdt[4];
6564   if (ChannelDepthsummedAmplitudesPlots[0])
6565     litebdt[0] = new TLine(80., 0.8, 80., ChannelDepthsummedAmplitudesPlots[0]->GetBinContent(4) + 100.);
6566   if (ChannelDepthsummedAmplitudesPlots[1])
6567     litebdt[1] = new TLine(200., 0.8, 200., ChannelDepthsummedAmplitudesPlots[1]->GetBinContent(7) + 100.);
6568   if (ChannelDepthsummedAmplitudesPlots[2])
6569     litebdt[2] = new TLine(1200., 0.8, 1200., ChannelDepthsummedAmplitudesPlots[2]->GetBinContent(17) + 100.);
6570   if (ChannelDepthsummedAmplitudesPlots[3])
6571     litebdt[3] = new TLine(600., 0.8, 600., ChannelDepthsummedAmplitudesPlots[3]->GetBinContent(6) + 100.);
6572 
6573   gStyle->SetOptStat(110000);
6574   cFour1->Clear();
6575   cFour1->Divide(2, 2);
6576   for (int sub = 0; sub < 4; sub++) {
6577     if (sub == 0)
6578       cFour1->cd(1);
6579     if (sub == 1)
6580       cFour1->cd(2);
6581     if (sub == 2)
6582       cFour1->cd(3);
6583     if (sub == 3)
6584       cFour1->cd(4);
6585     gPad->SetLogy();
6586     ChannelDepthsummedAmplitudesPlots[sub]->SetMarkerStyle(20);
6587     ChannelDepthsummedAmplitudesPlots[sub]->SetMarkerSize(0.8);
6588     if (sub == 0)
6589       ChannelDepthsummedAmplitudesPlots[sub]->SetTitle("HB channel Amplitudes\b");
6590     if (sub == 1)
6591       ChannelDepthsummedAmplitudesPlots[sub]->SetTitle("HE channel Amplitudes\b");
6592     if (sub == 2)
6593       ChannelDepthsummedAmplitudesPlots[sub]->SetTitle("HO channel Amplitudes\b");
6594     if (sub == 3)
6595       ChannelDepthsummedAmplitudesPlots[sub]->SetTitle("HF channel Amplitudes\b");
6596     if (sub == 0)
6597       ChannelDepthsummedAmplitudesPlots[sub]->SetXTitle("HB channel depths summed Amplitudes \b");
6598     if (sub == 1)
6599       ChannelDepthsummedAmplitudesPlots[sub]->SetXTitle("HE channel depths summed Amplitudes \b");
6600     if (sub == 2)
6601       ChannelDepthsummedAmplitudesPlots[sub]->SetXTitle("HO channel depths summed Amplitudes \b");
6602     if (sub == 3)
6603       ChannelDepthsummedAmplitudesPlots[sub]->SetXTitle("HF channel depths summed Amplitudes \b");
6604     ChannelDepthsummedAmplitudesPlots[sub]->SetMarkerColor(2);
6605     ChannelDepthsummedAmplitudesPlots[sub]->SetLineColor(2);
6606     ChannelDepthsummedAmplitudesPlots[sub]->Draw("");
6607     litebdt[sub]->SetLineColor(kBlue);
6608     litebdt[sub]->Draw("s");
6609   }  //for
6610   cFour1->Update();
6611   cFour1->Print("ChannelDepthsummedAmplitudes.png");
6612   cFour1->Clear();
6613   gStyle->SetOptStat(0);
6614 
6615   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6616   /// Summed Amplitude Plots:
6617   //*************************                        *****     Ataildepth1_HB                 *****
6618   cout << ">>>>>>>>>>>>>>>>>>>>>>>>2DAtaildepth " << endl;
6619   //////////
6620   cHB->Clear();
6621   cHB->Divide(2, 1);
6622 
6623   TH2F *DAtaildepth1[2];  // 1d histogramm for subdet
6624   DAtaildepth1[0] = (TH2F *)dir->FindObjectAny("h_2DAtaildepth1_HB");
6625   DAtaildepth1[1] = (TH2F *)dir->FindObjectAny("h_2D0Ataildepth1_HB");
6626   cHB->cd(1);
6627   if (!DAtaildepth1[0] || !DAtaildepth1[1]) {
6628     cout << ">>>>>>>>>>>>>>>>>>>>>>>>Ataildepth1_HB EMPTY histoes for 2DAtaildepth 1" << endl;
6629   } else {
6630     TH2F *tail1 = (TH2F *)DAtaildepth1[0]->Clone("tail1");
6631     tail1->Divide(DAtaildepth1[0], DAtaildepth1[1], 1, 1, "B");
6632     //  tail1->Sumw2();
6633     gPad->SetGridy();
6634     gPad->SetGridx();
6635     gPad->SetLogz();
6636     tail1->SetMarkerStyle(20);
6637     tail1->SetMarkerSize(0.4);
6638     tail1->SetTitle("Amplitudes for tail-events (HBdepth1) \b");
6639     tail1->SetXTitle("#eta \b");
6640     tail1->SetYTitle("#phi \b");
6641     tail1->SetZTitle("2D <A> in the tail - HB Depth1 \b");
6642     tail1->SetMarkerColor(2);
6643     tail1->SetLineColor(2);
6644     tail1->Draw("COLZ");
6645   }
6646   TH2F *DAtaildepth2[2];  // 1d histogramm for subdet
6647   DAtaildepth2[0] = (TH2F *)dir->FindObjectAny("h_2DAtaildepth2_HB");
6648   DAtaildepth2[1] = (TH2F *)dir->FindObjectAny("h_2D0Ataildepth2_HB");
6649   cHB->cd(2);
6650   if (!DAtaildepth2[0] || !DAtaildepth2[1]) {
6651     cout << ">>>>>>>>>>>>>>>>>>>>>>>>Ataildepth1_HB EMPTY histoes for 2DAtaildepth 2" << endl;
6652   } else {
6653     TH2F *tail2 = (TH2F *)DAtaildepth2[0]->Clone("tail2");
6654     tail2->Divide(DAtaildepth2[0], DAtaildepth2[1], 1, 1, "B");
6655     //  tail2->Sumw2();
6656     gPad->SetGridy();
6657     gPad->SetGridx();
6658     gPad->SetLogz();
6659     tail2->SetMarkerStyle(20);
6660     tail2->SetMarkerSize(0.4);
6661     tail2->SetTitle("Amplitudes for tail-events (HBdepth2) \b");
6662     tail2->SetXTitle("#eta \b");
6663     tail2->SetYTitle("#phi \b");
6664     tail2->SetZTitle("2D <A> in the tail - HB Depth2 \b");
6665     tail2->SetMarkerColor(2);
6666     tail2->SetLineColor(2);
6667     tail2->Draw("COLZ");
6668   }
6669 
6670   cHB->Update();
6671   cHB->Print("AtaildepthHB.png");
6672   cHB->Clear();
6673 
6674   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6675   /// Summed Amplitude Plots:
6676   //*************************                        *****     sum(Signal+NoSignal) occupancy for HF                *****
6677   cout << ">>>>>>>>>>>>>>>>>>>>>>>>sumOccupancyHF " << endl;
6678   //////////
6679   cHB->Clear();
6680   cHB->Divide(1, 1);
6681   cHB->cd(1);
6682   if (SummedAmplitudeOccupancyHisto[3]) {
6683     TH1F *ufrew1 = (TH1F *)SummedAmplitudeOccupancyHisto[3]->Clone("ufrew1");
6684     if (SummedAmplitudeOccupancyHisto[3] && NoSignalSummedAmplitudeOccupancyHisto[3])
6685       ufrew1->Add(SummedAmplitudeOccupancyHisto[3], NoSignalSummedAmplitudeOccupancyHisto[3], 1, 1);
6686     ufrew1->GetXaxis()->SetRangeUser(1., maxbins + 1.);
6687     gPad->SetGridx();
6688     ufrew1->SetMarkerStyle(20);
6689     ufrew1->SetMarkerSize(0.8);
6690     ufrew1->GetYaxis()->SetLabelSize(0.04);
6691     ufrew1->SetTitle("HF Occupancy vs LS\b");
6692     ufrew1->SetXTitle("average occupancy per LS HF\b");
6693     ufrew1->SetMarkerColor(4);
6694     ufrew1->SetLineColor(0);
6695     ufrew1->SetMaximum(866.);
6696     ufrew1->SetMinimum(856.);
6697     ufrew1->Draw("Error");
6698     cHB->Update();
6699     cHB->Print("sumOccupancyHF.png");
6700     cHB->Clear();
6701     if (ufrew1)
6702       delete ufrew1;
6703   }
6704 
6705   //////////
6706   //////////
6707   //////////
6708   //////////
6709   //////////
6710   //////////
6711   //////////
6712   //====================================================================================================================
6713   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =====================================================================" << endl;
6714 
6715   //=====================================================================================================
6716   cout << ">>>>>>>>>>>>>>>>>>>>>>>> ==================================================" << endl;
6717 
6718   //=====================================================================================
6719   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =================================" << endl;
6720   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =================================" << endl;
6721   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =================================" << endl;
6722   cout << ">>>>>>>>>>>>>>>>>>>>>>>> =================================" << endl;
6723 
6724   cout << ">>>>>>>             START NOW CREATING OF HTML PAGES      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
6725   //======================================================================
6726   // Creating each test kind for each subdet html pages:
6727   std::string raw_class;
6728   int ind = 0;
6729   ofstream htmlFile;
6730   for (int test = 0; test <= 5; test++) {  //Test: 0,
6731     for (int sub = 1; sub <= 4; sub++) {   //Subdetector: 1-HB, 2-HE, 3-HO, 4-HF
6732 
6733       //    cout<<"Creating each test kind for each subdet html pages:  test=  "<< test << "  sub= "  << sub <<    endl;
6734       if (test == 0) {
6735         if (sub == 1) {
6736           htmlFile.open("HB_CapID.html");
6737         }
6738         if (sub == 2) {
6739           htmlFile.open("HE_CapID.html");
6740         }
6741         if (sub == 3) {
6742           htmlFile.open("HO_CapID.html");
6743         }
6744         if (sub == 4) {
6745           htmlFile.open("HF_CapID.html");
6746         }
6747       }
6748       if (test == 1) {
6749         if (sub == 1) {
6750           htmlFile.open("HB_ADCampl.html");
6751         }
6752         if (sub == 2) {
6753           htmlFile.open("HE_ADCampl.html");
6754         }
6755         if (sub == 3) {
6756           htmlFile.open("HO_ADCampl.html");
6757         }
6758         if (sub == 4) {
6759           htmlFile.open("HF_ADCampl.html");
6760         }
6761       }
6762       if (test == 2) {
6763         if (sub == 1) {
6764           htmlFile.open("HB_Width.html");
6765         }
6766         if (sub == 2) {
6767           htmlFile.open("HE_Width.html");
6768         }
6769         if (sub == 3) {
6770           htmlFile.open("HO_Width.html");
6771         }
6772         if (sub == 4) {
6773           htmlFile.open("HF_Width.html");
6774         }
6775       }
6776       if (test == 3) {
6777         if (sub == 1) {
6778           htmlFile.open("HB_Ratio.html");
6779         }
6780         if (sub == 2) {
6781           htmlFile.open("HE_Ratio.html");
6782         }
6783         if (sub == 3) {
6784           htmlFile.open("HO_Ratio.html");
6785         }
6786         if (sub == 4) {
6787           htmlFile.open("HF_Ratio.html");
6788         }
6789       }
6790       if (test == 4) {
6791         if (sub == 1) {
6792           htmlFile.open("HB_Tmean.html");
6793         }
6794         if (sub == 2) {
6795           htmlFile.open("HE_Tmean.html");
6796         }
6797         if (sub == 3) {
6798           htmlFile.open("HO_Tmean.html");
6799         }
6800         if (sub == 4) {
6801           htmlFile.open("HF_Tmean.html");
6802         }
6803       }
6804       if (test == 5) {
6805         if (sub == 1) {
6806           htmlFile.open("HB_Tmax.html");
6807         }
6808         if (sub == 2) {
6809           htmlFile.open("HE_Tmax.html");
6810         }
6811         if (sub == 3) {
6812           htmlFile.open("HO_Tmax.html");
6813         }
6814         if (sub == 4) {
6815           htmlFile.open("HF_Tmax.html");
6816         }
6817       }
6818 
6819       htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
6820       htmlFile << "<head>" << std::endl;
6821       htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
6822       htmlFile << "<title> Certification Monitoring Tool </title>" << std::endl;
6823       htmlFile << "<style type=\"text/css\">" << std::endl;
6824       htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
6825                << std::endl;
6826       htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
6827       htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
6828                   "text-align: center;}"
6829                << std::endl;
6830       htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
6831       htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
6832       htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
6833       htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: #00FF00; }" << std::endl;
6834       htmlFile << "   td.s6 { font-family: arial, arial ce, helvetica; background-color: #FF0000; }" << std::endl;
6835       htmlFile << "</style>" << std::endl;
6836       htmlFile << "<body>" << std::endl;
6837 
6838       if (test == 0) {
6839         if (sub == 1)
6840           htmlFile << "<h1> Cap ID estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6841         if (sub == 2)
6842           htmlFile << "<h1> Cap ID estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6843         if (sub == 3)
6844           htmlFile << "<h1> Cap ID estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6845         if (sub == 4)
6846           htmlFile << "<h1> Cap ID estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6847       }
6848       if (test == 1) {
6849         if (sub == 1)
6850           htmlFile << "<h1> Mean ADC Amplitude estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6851         if (sub == 2)
6852           htmlFile << "<h1> Mean ADC Amplitude estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6853         if (sub == 3)
6854           htmlFile << "<h1> Mean ADC Amplitude estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6855         if (sub == 4)
6856           htmlFile << "<h1> Mean ADC Amplitude estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6857       }
6858       if (test == 2) {
6859         if (sub == 1)
6860           htmlFile << "<h1> Width estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6861         if (sub == 2)
6862           htmlFile << "<h1> Width estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6863         if (sub == 3)
6864           htmlFile << "<h1> Width estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6865         if (sub == 4)
6866           htmlFile << "<h1> Width estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6867       }
6868       if (test == 3) {
6869         if (sub == 1)
6870           htmlFile << "<h1> Ratio estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6871         if (sub == 2)
6872           htmlFile << "<h1> Ratio estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6873         if (sub == 3)
6874           htmlFile << "<h1> Ratio estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6875         if (sub == 4)
6876           htmlFile << "<h1> Ratio estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6877       }
6878       if (test == 4) {
6879         if (sub == 1)
6880           htmlFile << "<h1> Mean bin timing estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6881         if (sub == 2)
6882           htmlFile << "<h1> Mean bin timing estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6883         if (sub == 3)
6884           htmlFile << "<h1> Mean bin timing estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6885         if (sub == 4)
6886           htmlFile << "<h1> Mean bin timing estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6887       }
6888       if (test == 5) {
6889         if (sub == 1)
6890           htmlFile << "<h1> Maximum bin timing estimator for HB, RUN = " << runnumber << " </h1>" << std::endl;
6891         if (sub == 2)
6892           htmlFile << "<h1> Maximum bin timing estimator for HE, RUN = " << runnumber << " </h1>" << std::endl;
6893         if (sub == 3)
6894           htmlFile << "<h1> Maximum bin timing estimator for HO, RUN = " << runnumber << " </h1>" << std::endl;
6895         if (sub == 4)
6896           htmlFile << "<h1> Maximum bin timing estimator for HF, RUN = " << runnumber << " </h1>" << std::endl;
6897       }
6898 
6899       if (test == 1) {
6900         htmlFile << "<a name=\"Top\"></a>\n";
6901         htmlFile << "<b>Contents:<br>\n";
6902         htmlFile << "1. <a href=\"#Aij\">A_ij_LS (averaged over events in LS) </a><br>\n";
6903         htmlFile << "2. <a href=\"#OverflowAij\">A_ij_LS in overflow & underflow</a><br>\n";
6904         htmlFile << "3. <a href=\"#MainEstimator\">Main Estimator !!! </a><br>\n";
6905         htmlFile << "4. <a href=\"#ErrorA\">Error type A </a><br>\n";
6906         htmlFile << "5. <a href=\"#ErrorAaverage\">ErrorA cross check</a><br>\n";
6907         htmlFile << "6. <a href=\"#ErrorAoccupancy\">ErrorA occupancy plots</a><br>\n";
6908         htmlFile << "7. <a href=\"#ErrorB\">Error type B</a><br>\n";
6909         htmlFile << "8. <a href=\"#LSstatus\">Table of Average channel-Amplitude in Depthes over LSs </a><br>\n";
6910         htmlFile << "9. <a href=\"#RBXstatus\">RBX Status </a><br>\n";
6911         htmlFile << "10. <a href=\"#RBXPHItable\">Table of Average RBX-Amplitude in Phi over LSs </a><br>\n";
6912         htmlFile << "11. <a href=\"#RBXETAtable\">Table of Average RBX-Amplitude in Eta over LSs </a><br>\n";
6913         htmlFile << "12. <a href=\"#RBX3plots\">RBX A-Ratio to 1st LS: 3 plots </a><br>\n";
6914         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6915       }
6916 
6917       //     htmlFile << "<a href=\"#Top\">to top</a><br>\n";
6918 
6919       htmlFile << "<br>" << std::endl;
6920       if (test == 0) {
6921         htmlFile << "<h2> 0. Rate of CapID failures over all events of Run </h2>" << std::endl;
6922         htmlFile << "<h3> Channel legend: green - good, other colour - suspicious  </h3>" << std::endl;
6923         if (sub == 1)
6924           htmlFile << " <img src=\"MapCapIdErrorHB.png\" />" << std::endl;
6925         if (sub == 2)
6926           htmlFile << " <img src=\"MapCapIdErrorHE.png\" />" << std::endl;
6927         if (sub == 3)
6928           htmlFile << " <img src=\"MapCapIdErrorHO.png\" />" << std::endl;
6929         if (sub == 4)
6930           htmlFile << " <img src=\"MapCapIdErrorHF.png\" />" << std::endl;
6931       }
6932       if (test == 1)
6933         htmlFile << "<a name=\"Aij\"></a>\n";
6934       if (test != 0)
6935         htmlFile << "<h2> 1. Distribution of estimator averaged over events in LS, histogramed over all channels and "
6936                     "all LSs </h2>"
6937                  << std::endl;
6938       if (test == 0) {
6939         if (sub == 1)
6940           htmlFile << "<h2> 1.  Average Nbcs for only LS containing events with abnormal number of Bad channels >"
6941                    << CutAb[sub][1] << " (Depth1), " << CutAb[sub][2] << " (Depth2).</h2>" << std::endl;
6942         if (sub == 2)
6943           htmlFile << "<h2> 1.  Average Nbcs for only LS containing events with abnormal number of Bad channels >"
6944                    << CutAb[sub][1] << " (Depth1), " << CutAb[sub][2] << " (Depth2), " << CutAb[sub][3]
6945                    << " (Depth3).</h2>" << std::endl;
6946         if (sub == 3)
6947           htmlFile << "<h2> 1.  Average Nbcs for only LS containing events with abnormal number of Bad channels >"
6948                    << CutAb[sub][1] << " (Depth4).</h2>" << std::endl;
6949         if (sub == 4)
6950           htmlFile << "<h2> 1.  Average Nbcs for only LS containing events with abnormal number of Bad channels >"
6951                    << CutAb[sub][1] << " (Depth1), " << CutAb[sub][2] << " (Depth2).</h2>" << std::endl;
6952       }
6953 
6954       if (test != 0)
6955         htmlFile << "<h3> see Overflow and Underflow </h3>" << std::endl;
6956       if (test == 0)
6957         htmlFile << "<h3> Legend: dots correspond to BAD LS candidates.</h3>" << std::endl;
6958 
6959       if (test == 0) {
6960         if (sub == 1)
6961           htmlFile << " <img src=\"Hist_CAPID_Abnorm_HB.png\" />" << std::endl;
6962         if (sub == 2)
6963           htmlFile << " <img src=\"Hist_CAPID_Abnorm_HE.png\" />" << std::endl;
6964         if (sub == 3)
6965           htmlFile << " <img src=\"Hist_CAPID_Abnorm_HO.png\" />" << std::endl;
6966         if (sub == 4)
6967           htmlFile << " <img src=\"Hist_CAPID_Abnorm_HF.png\" />" << std::endl;
6968       }
6969       if (test == 1) {
6970         if (sub == 1)
6971           htmlFile << " <img src=\"H_ADCamplHB.png\" />" << std::endl;
6972         if (sub == 2)
6973           htmlFile << " <img src=\"H_ADCamplHE.png\" />" << std::endl;
6974         if (sub == 3)
6975           htmlFile << " <img src=\"H_ADCamplHO.png\" />" << std::endl;
6976         if (sub == 4)
6977           htmlFile << " <img src=\"H_ADCamplHF.png\" />" << std::endl;
6978       }
6979       if (test == 2) {
6980         if (sub == 1)
6981           htmlFile << " <img src=\"H_WidthHB.png\" />" << std::endl;
6982         if (sub == 2)
6983           htmlFile << " <img src=\"H_WidthHE.png\" />" << std::endl;
6984         if (sub == 3)
6985           htmlFile << " <img src=\"H_WidthHO.png\" />" << std::endl;
6986         if (sub == 4)
6987           htmlFile << " <img src=\"H_WidthHF.png\" />" << std::endl;
6988       }
6989       if (test == 3) {
6990         if (sub == 1)
6991           htmlFile << " <img src=\"H_RatioHB.png\" />" << std::endl;
6992         if (sub == 2)
6993           htmlFile << " <img src=\"H_RatioHE.png\" />" << std::endl;
6994         if (sub == 3)
6995           htmlFile << " <img src=\"H_RatioHO.png\" />" << std::endl;
6996         if (sub == 4)
6997           htmlFile << " <img src=\"H_RatioHF.png\" />" << std::endl;
6998       }
6999       if (test == 4) {
7000         if (sub == 1)
7001           htmlFile << " <img src=\"H_TmeanHB.png\" />" << std::endl;
7002         if (sub == 2)
7003           htmlFile << " <img src=\"H_TmeanHE.png\" />" << std::endl;
7004         if (sub == 3)
7005           htmlFile << " <img src=\"H_TmeanHO.png\" />" << std::endl;
7006         if (sub == 4)
7007           htmlFile << " <img src=\"H_TmeanHF.png\" />" << std::endl;
7008       }
7009       if (test == 5) {
7010         if (sub == 1)
7011           htmlFile << " <img src=\"H_TmaxHB.png\" />" << std::endl;
7012         if (sub == 2)
7013           htmlFile << " <img src=\"H_TmaxHE.png\" />" << std::endl;
7014         if (sub == 3)
7015           htmlFile << " <img src=\"H_TmaxHO.png\" />" << std::endl;
7016         if (sub == 4)
7017           htmlFile << " <img src=\"H_TmaxHF.png\" />" << std::endl;
7018       }
7019       htmlFile << "<br>" << std::endl;
7020       if (test == 1)
7021         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7022 
7023       if (test == 0)
7024         htmlFile << "<h2> 2a.  Number of bad channels per event distribution in Run</h2>" << std::endl;
7025       if (test == 0)
7026         htmlFile << "<h3> Legends: dots correspond to BAD LS candidates.  </h3>" << std::endl;
7027       if (test == 0) {
7028         if (sub == 1)
7029           htmlFile << " <img src=\"HistNBadChsHB.png\" />" << std::endl;
7030         if (sub == 2)
7031           htmlFile << " <img src=\"HistNBadChsHE.png\" />" << std::endl;
7032         if (sub == 3)
7033           htmlFile << " <img src=\"HistNBadChsHO.png\" />" << std::endl;
7034         if (sub == 4)
7035           htmlFile << " <img src=\"HistNBadChsHF.png\" />" << std::endl;
7036       }
7037 
7038       if (test == 1)
7039         htmlFile << "<a name=\"OverflowAij\"></a>\n";
7040       if (test != 0)
7041         htmlFile << "<h2> 2. Estimator averaged over all events in the RUN for entries in overflow and underflow of "
7042                     "corresponding histogram above </h2>"
7043                  << std::endl;
7044       //              if (test !=0) htmlFile << "<h2> 2. Estimator averaged over all events in the RUN </h2>"<< std::endl;
7045       if (test == 0)
7046         htmlFile << "<h2> 2b. Averaged number of bad channels for each LS </h2>" << std::endl;
7047       //              if (test !=0) htmlFile << "<h3> Channel legend: white - good, other colour - bad.  </h3>"<< std::endl;
7048       if (test == 0) {
7049         if (sub == 1)
7050           htmlFile << "<h3> Legends: dots selected with following cuts: <td class=\"s6\" align=\"center\">"
7051                    << Cut0[test][sub][1] << " (Depth1), " << Cut0[test][sub][2]
7052                    << " (Depth2) correspond BAD LS.</td></h3>" << std::endl;
7053         if (sub == 2)
7054           htmlFile << "<h3> Legends: dots selected with following cuts: " << Cut0[test][sub][1] << " (Depth1), "
7055                    << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3) correspond BAD LS.</h3>"
7056                    << std::endl;
7057         if (sub == 3)
7058           htmlFile << "<h3> Legends: dots selected with following cuts: " << Cut0[test][sub][4]
7059                    << " (Depth4) correspond BAD LS.</h3>" << std::endl;
7060         if (sub == 4)
7061           htmlFile << "<h3> Legends: dots selected with following cuts: " << Cut0[test][sub][1] << " (Depth1), "
7062                    << Cut0[test][sub][2] << " (Depth2) correspond BAD LS.</h3>" << std::endl;
7063       }
7064       if (test == 0) {
7065         if (sub == 1)
7066           htmlFile << " <img src=\"HistNBCMNHB.png\" />" << std::endl;
7067         if (sub == 2)
7068           htmlFile << " <img src=\"HistNBCMNHE.png\" />" << std::endl;
7069         if (sub == 3)
7070           htmlFile << " <img src=\"HistNBCMNHO.png\" />" << std::endl;
7071         if (sub == 4)
7072           htmlFile << " <img src=\"HistNBCMNHF.png\" />" << std::endl;
7073       }
7074       if (test == 1) {
7075         if (sub == 1)
7076           htmlFile << " <img src=\"MapADCamplHB.png\" />" << std::endl;
7077         if (sub == 2)
7078           htmlFile << " <img src=\"MapADCamplHE.png\" />" << std::endl;
7079         if (sub == 3)
7080           htmlFile << " <img src=\"MapADCamplHO.png\" />" << std::endl;
7081         if (sub == 4)
7082           htmlFile << " <img src=\"MapADCamplHF.png\" />" << std::endl;
7083       }
7084       if (test == 2) {
7085         if (sub == 1)
7086           htmlFile << " <img src=\"MapWidthHB.png\" />" << std::endl;
7087         if (sub == 2)
7088           htmlFile << " <img src=\"MapWidthHE.png\" />" << std::endl;
7089         if (sub == 3)
7090           htmlFile << " <img src=\"MapWidthHO.png\" />" << std::endl;
7091         if (sub == 4)
7092           htmlFile << " <img src=\"MapWidthHF.png\" />" << std::endl;
7093       }
7094       if (test == 3) {
7095         if (sub == 1)
7096           htmlFile << " <img src=\"MapRatioHB.png\" />" << std::endl;
7097         if (sub == 2)
7098           htmlFile << " <img src=\"MapRatioHE.png\" />" << std::endl;
7099         if (sub == 3)
7100           htmlFile << " <img src=\"MapRatioHO.png\" />" << std::endl;
7101         if (sub == 4)
7102           htmlFile << " <img src=\"MapRatioHF.png\" />" << std::endl;
7103       }
7104       if (test == 4) {
7105         if (sub == 1)
7106           htmlFile << " <img src=\"MapTmeanHB.png\" />" << std::endl;
7107         if (sub == 2)
7108           htmlFile << " <img src=\"MapTmeanHE.png\" />" << std::endl;
7109         if (sub == 3)
7110           htmlFile << " <img src=\"MapTmeanHO.png\" />" << std::endl;
7111         if (sub == 4)
7112           htmlFile << " <img src=\"MapTmeanHF.png\" />" << std::endl;
7113       }
7114       if (test == 5) {
7115         if (sub == 1)
7116           htmlFile << " <img src=\"MapTmaxHB.png\" />" << std::endl;
7117         if (sub == 2)
7118           htmlFile << " <img src=\"MapTmaxHE.png\" />" << std::endl;
7119         if (sub == 3)
7120           htmlFile << " <img src=\"MapTmaxHO.png\" />" << std::endl;
7121         if (sub == 4)
7122           htmlFile << " <img src=\"MapTmaxHF.png\" />" << std::endl;
7123       }
7124       htmlFile << "<br>" << std::endl;
7125       if (test == 1)
7126         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7127 
7128       if (test == 1)
7129         htmlFile << "<a name=\"MainEstimator\"></a>\n";
7130       if (test != 0)
7131         htmlFile
7132             << "<h2> 3. Distribution of estimator averaged over events in LS and over all channels for each LS </h2>"
7133             << std::endl;
7134       if (test == 0) {
7135         if (sub == 1)
7136           htmlFile << "<h2> 3.  Portion of events with Nbcs>" << CutPo[sub][1] << " (Depth1), " << CutPo[sub][2]
7137                    << " (Depth2) in each LS.</h2>" << std::endl;
7138         if (sub == 2)
7139           htmlFile << "<h2> 3.  Portion of events with Nbcs>" << CutPo[sub][1] << " (Depth1), " << CutPo[sub][2]
7140                    << " (Depth2), " << CutPo[sub][3] << " (Depth3) in each LS.</h2>" << std::endl;
7141         if (sub == 3)
7142           htmlFile << "<h2> 3.  Portion of events with Nbcs>" << CutPo[sub][4] << " (Depth4) in each LS.</h2>"
7143                    << std::endl;
7144         if (sub == 4)
7145           htmlFile << "<h2> 3.  Portion of events with Nbcs>" << CutPo[sub][1] << " (Depth1), " << CutPo[sub][2]
7146                    << " (Depth2) in each LS.</h2>" << std::endl;
7147         htmlFile << "<h3> Legend: dots correspond to BAD LS candidates.</h3>" << std::endl;
7148       }
7149       if (test != 0) {
7150         if (sub == 1)
7151           htmlFile << "<h3> Legends:  dots selected with following cuts: <td class=\"s6\" align=\"center\">"
7152                    << Cut0[test][sub][1] << " (Depth1), " << Cut0[test][sub][2]
7153                    << " (Depth2) correspond BAD LS.</td></h3>" << std::endl;
7154         if (sub == 2)
7155           htmlFile << "<h3> Legends:  dots selected with following cuts: " << Cut0[test][sub][1] << " (Depth1), "
7156                    << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3), " << Cut0[test][sub][4]
7157                    << " (Depth4), " << Cut0[test][sub][5] << " (Depth5), " << Cut0[test][sub][6] << " (Depth6), "
7158                    << Cut0[test][sub][7] << " (Depth7) correspond BAD LS. </h3>" << std::endl;
7159         if (sub == 3)
7160           htmlFile << "<h3> Legends:  dots selected with following cuts: " << Cut0[test][sub][4]
7161                    << " (Depth4) correspond BAD LS. </h3>" << std::endl;
7162         if (sub == 4)
7163           htmlFile << "<h3> Legends:  dots selected with following cuts: " << Cut0[test][sub][1] << " (Depth1), "
7164                    << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3), " << Cut0[test][sub][4]
7165                    << " (Depth4) correspond BAD LS. </h3>" << std::endl;
7166       }
7167       if (test == 0) {
7168         if (sub == 1)
7169           htmlFile << " <img src=\"HistPortHB.png\" />" << std::endl;
7170         if (sub == 2)
7171           htmlFile << " <img src=\"HistPortHE.png\" />" << std::endl;
7172         if (sub == 3)
7173           htmlFile << " <img src=\"HistPortHO.png\" />" << std::endl;
7174         if (sub == 4)
7175           htmlFile << " <img src=\"HistPortHF.png\" />" << std::endl;
7176       }
7177       if (test == 1) {
7178         if (sub == 1)
7179           htmlFile << " <img src=\"HistADCamplHB.png\" />" << std::endl;
7180         if (sub == 2)
7181           htmlFile << " <img src=\"HistADCamplHE.png\" />" << std::endl;
7182         if (sub == 3)
7183           htmlFile << " <img src=\"HistADCamplHO.png\" />" << std::endl;
7184         if (sub == 4)
7185           htmlFile << " <img src=\"HistADCamplHF.png\" />" << std::endl;
7186       }
7187       if (test == 2) {
7188         if (sub == 1)
7189           htmlFile << " <img src=\"HistWidthHB.png\" />" << std::endl;
7190         if (sub == 2)
7191           htmlFile << " <img src=\"HistWidthHE.png\" />" << std::endl;
7192         if (sub == 3)
7193           htmlFile << " <img src=\"HistWidthHO.png\" />" << std::endl;
7194         if (sub == 4)
7195           htmlFile << " <img src=\"HistWidthHF.png\" />" << std::endl;
7196       }
7197       if (test == 3) {
7198         if (sub == 1)
7199           htmlFile << " <img src=\"HistRatioHB.png\" />" << std::endl;
7200         if (sub == 2)
7201           htmlFile << " <img src=\"HistRatioHE.png\" />" << std::endl;
7202         if (sub == 3)
7203           htmlFile << " <img src=\"HistRatioHO.png\" />" << std::endl;
7204         if (sub == 4)
7205           htmlFile << " <img src=\"HistRatioHF.png\" />" << std::endl;
7206       }
7207       if (test == 4) {
7208         if (sub == 1)
7209           htmlFile << " <img src=\"HistTmeanHB.png\" />" << std::endl;
7210         if (sub == 2)
7211           htmlFile << " <img src=\"HistTmeanHE.png\" />" << std::endl;
7212         if (sub == 3)
7213           htmlFile << " <img src=\"HistTmeanHO.png\" />" << std::endl;
7214         if (sub == 4)
7215           htmlFile << " <img src=\"HistTmeanHF.png\" />" << std::endl;
7216       }
7217       if (test == 5) {
7218         if (sub == 1)
7219           htmlFile << " <img src=\"HistTmaxHB.png\" />" << std::endl;
7220         if (sub == 2)
7221           htmlFile << " <img src=\"HistTmaxHE.png\" />" << std::endl;
7222         if (sub == 3)
7223           htmlFile << " <img src=\"HistTmaxHO.png\" />" << std::endl;
7224         if (sub == 4)
7225           htmlFile << " <img src=\"HistTmaxHF.png\" />" << std::endl;
7226       }
7227       htmlFile << "<br>" << std::endl;
7228 
7229       if (test == 1) {
7230         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7231         htmlFile << "<a name=\"ErrorA\"></a>\n";
7232         htmlFile << "<h2> 4. Error type A</h2>\n";
7233         htmlFile << "<h3> note: no sence to see plots of this item if max difference is too large(due to very high A "
7234                     "of some channels)</h3>\n";
7235         htmlFile << "<br>\n";
7236 
7237         //HB:
7238         if (sub == 1) {
7239           htmlFile << "<h3>Mean of max difference between dependencies to be within: 0.1-1.6 (p-p collisions) </h3>\n";
7240           htmlFile << " <img src=\"HistErrA_HB.png\" />\n";
7241           htmlFile << "<br>\n";
7242           if (flagErrAB_HB[0] == -1)
7243             htmlFile << "<h3>test was not possible</h3>\n";
7244           else if (flagErrAB_HB[0] == 0)
7245             htmlFile << "<h3> Fine:NoErrorA_HB (Mean of max difference " << avedelta_HB
7246                      << "  is within 0.1-1.6) </h3>\n";
7247           else if (flagErrAB_HB[0] == 1)
7248             htmlFile << "<<h3> ErrorA_HB is available once Mean of max difference " << avedelta_HB
7249                      << " is out 0.1-1.6 (p-p collisions)</font></h3>\n";
7250           else
7251             htmlFile << "<h3>auto-interpretation is not available</h3>\n";
7252           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7253 
7254           htmlFile << "<a name=\"ErrorAaverage\"></a>\n";
7255 
7256           htmlFile << "<h2> 5. Error type A cross check: see 2D pattern of channels   </h2>\n";
7257           htmlFile << "<h2> 1) with average channel Amplitudes(No cut), 2) with average channel Amplitudes(<A> >25), "
7258                       "3) with channel Amplitude (A<35);  </h2>\n";
7259           htmlFile << " <img src=\"ChkErrA_HB1.png\" /><br><br>\n";
7260           htmlFile << " <img src=\"ChkErrA_HB2.png\" /><br>\n";
7261           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7262 
7263           htmlFile << "<a name=\"ErrorAoccupancy\"></a>\n";
7264           htmlFile << "<h2> 6. Error type A: min/ave ratio for occupancy distributions with Amplitude bigger 25 "
7265                       "(HBM:neg.eta;HBP:pos.eta) </h2>\n";
7266           htmlFile << "<h2> FOR CROSS-CHECK OLNY !!!</h2>\n";
7267           htmlFile << "<h2> TO IDENTIFY A-type errors: for most of LSs the ratio to be lower 0.6 at least for HF- or "
7268                       "HF+ </h2>\n";
7269           htmlFile << "<h2> For runs without A-type errors: for most of LSs the ratio is higher 0.6 and is the same "
7270                       "for HF- and HF+ </h2>\n";
7271           htmlFile << " <img src=\"OccPlots_HB.png\" /><br><br>\n";
7272           htmlFile << "<br>\n";
7273           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7274 
7275           htmlFile << "<a name=\"ErrorB\"></a>\n";
7276           htmlFile << "<h2> 7. Error type B\n";
7277           htmlFile << "<h3> ErrorB identification: digi-collection size != 10.</h3>\n";
7278           htmlFile << " <img src=\"HistErrB_HB_1.png\" />\n<br>\n";
7279           htmlFile << " <img src=\"HistErrB_HB_2.png\" />\n<br>\n";
7280           htmlFile << "<br>\n";
7281           htmlFile << "<h3> if Error type B is available, it start from:    " << LSofFirstErrB_HB << "  LS </h3>\n";
7282           htmlFile << "<br>\n";
7283         }
7284 
7285         //HE:
7286         if (sub == 2) {
7287           htmlFile << "<h3>Mean of max difference between dependencies to be within: 0.2-1.8 (p-p collisions) </h3>\n";
7288           htmlFile << " <img src=\"HistErrA_HE.png\" />\n";
7289           htmlFile << "<br>\n";
7290           if (flagErrAB_HE[0] == -1)
7291             htmlFile << "<h3>test was not possible</h3>\n";
7292           else if (flagErrAB_HE[0] == 0)
7293             htmlFile << "<h3> Fine:NoErrorA_HE (Mean of max difference " << avedelta_HE
7294                      << "  is within 0.2-1.8) </h3>\n";
7295           else if (flagErrAB_HE[0] == 1)
7296             htmlFile << "<<h3> ErrorA_HE is available once Mean of max difference " << avedelta_HE
7297                      << " is out 0.2-1.8 (p-p collisions)</font></h3>\n";
7298           else
7299             htmlFile << "<h3>auto-interpretation is not available</h3>\n";
7300           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7301 
7302           htmlFile << "<a name=\"ErrorAaverage\"></a>\n";
7303 
7304           htmlFile << "<h2> 5. Error type A cross check: see 2D pattern of channels   </h2>\n";
7305           htmlFile << "<h2> 1) with average channel Amplitudes(No cut), 2) with average channel Amplitudes(<A> "
7306                       ">1000.fC), 3) with channel Amplitude (A<500fC);  </h2>\n";
7307           htmlFile << " <img src=\"ChkErrA_HE1.png\" /><br><br>\n";
7308           htmlFile << " <img src=\"ChkErrA_HE2.png\" /><br>\n";
7309           htmlFile << " <img src=\"ChkErrA_HE3.png\" /><br>\n";
7310           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7311 
7312           htmlFile << "<a name=\"ErrorAoccupancy\"></a>\n";
7313           htmlFile << "<h2> 6. Error type A: min/ave ratio for occupancy distributions with Amplitude bigger 35 "
7314                       "(HEM:neg.eta;HEP:pos.eta) </h2>\n";
7315           htmlFile << "<h2> FOR CROSS-CHECK OLNY !!!</h2>\n";
7316           htmlFile << "<h2> TO IDENTIFY A-type errors: for most of LSs the ratio to be lower 0.3 at least for HF- or "
7317                       "HF+ </h2>\n";
7318           htmlFile << "<h2> For runs without A-type errors: for most of LSs the ratio is higher 0.3 and is the same "
7319                       "for HF- and HF+ </h2>\n";
7320           htmlFile << " <img src=\"OccPlots_HE.png\" /><br><br>\n";
7321           htmlFile << "<br>\n";
7322           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7323 
7324           htmlFile << "<a name=\"ErrorB\"></a>\n";
7325           htmlFile << "<h2> 7. Error type B\n";
7326           htmlFile << "<h3> ErrorB identification: digi-collection size != 8.</h3>\n";
7327           htmlFile << " <img src=\"HistErrB_HE_1.png\" />\n<br>\n";
7328           htmlFile << " <img src=\"HistErrB_HE_2.png\" />\n<br>\n";
7329           htmlFile << " <img src=\"HistErrB_HE_3.png\" />\n<br>\n";
7330           htmlFile << "<br>\n";
7331           htmlFile << "<h3> if Error type B is available, it start from:    " << LSofFirstErrB_HE << "  LS </h3>\n";
7332           htmlFile << "<br>\n";
7333         }
7334 
7335         //HO:
7336         if (sub == 3) {
7337           htmlFile << "<h3>Mean of max difference between dependencies to be within: 0.1-1.5 (p-p collisions) </h3>\n";
7338           htmlFile << " <img src=\"HistErrA_HO.png\" />\n";
7339           htmlFile << "<br>\n";
7340           if (flagErrAB_HO[0] == -1)
7341             htmlFile << "<h3>test was not possible</h3>\n";
7342           else if (flagErrAB_HO[0] == 0)
7343             htmlFile << "<h3> Fine:NoErrorA_HO (Mean of max difference " << avedelta_HO
7344                      << "  is within 0.1-1.5) </h3>\n";
7345           else if (flagErrAB_HO[0] == 1)
7346             htmlFile << "<<h3> ErrorA_HO is available once Mean of max difference " << avedelta_HO
7347                      << " is out 0.1-1.5 (p-p collisions)</font></h3>\n";
7348           else
7349             htmlFile << "<h3>auto-interpretation is not available</h3>\n";
7350           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7351 
7352           htmlFile << "<a name=\"ErrorAaverage\"></a>\n";
7353 
7354           htmlFile << "<h2> 5. Error type A cross check: see 2D pattern of channels   </h2>\n";
7355           htmlFile << "<h2> 1) with average channel Amplitudes(No cut), 2) with average channel Amplitudes(<A> >80), "
7356                       "3) with channel Amplitude (A<100);  </h2>\n";
7357           //       htmlFile << "<h2> 2D. Cross check for error A</h2>\n";
7358           htmlFile << " <img src=\"ChkErrA_HO4.png\" /><br><br>\n";
7359           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7360 
7361           htmlFile << "<a name=\"ErrorAoccupancy\"></a>\n";
7362           htmlFile << "<h2> 6. Error type A: min/ave ratio for occupancy distributions with Amplitude bigger 80 "
7363                       "(HOM:neg.eta;HOP:pos.eta) </h2>\n";
7364           htmlFile << "<h2> FOR CROSS-CHECK OLNY !!!</h2>\n";
7365           htmlFile << "<h2> TO IDENTIFY A-type errors: for most of LSs the ratio to be lower 0.8 at least for HF- or "
7366                       "HF+ </h2>\n";
7367           htmlFile << "<h2> For runs without A-type errors: for most of LSs the ratio is higher 0.8 and is the same "
7368                       "for HF- and HF+ </h2>\n";
7369           htmlFile << " <img src=\"OccPlots_HO.png\" /><br><br>\n";
7370           htmlFile << "<br>\n";
7371           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7372 
7373           htmlFile << "<a name=\"ErrorB\"></a>\n";
7374           htmlFile << "<h2> 7. Error type B\n";
7375           htmlFile << "<h3> ErrorB identification: digi-collection size != 10. </h3>\n";
7376           htmlFile << " <img src=\"HistErrB_HO_4.png\" />\n<br>\n";
7377           htmlFile << "<br>\n";
7378           htmlFile << "<h3> if Error type B is available, it start from:    " << LSofFirstErrB_HO << "  LS </h3>\n";
7379           htmlFile << "<br>\n";
7380         }
7381 
7382         //HF:
7383         if (sub == 4) {
7384           //        flagSpecHF+=1;
7385           htmlFile << "<h3>Mean of max difference between dependencies to be within: 0.8-2.4 (p-p collisions) </h3>\n";
7386           htmlFile << " <img src=\"HistErrA_HF.png\" />\n";
7387           htmlFile << "<br>\n";
7388           if (flagErrAB_HF[0] == -1)
7389             htmlFile << "<h3>test was not possible</h3>\n";
7390           else if (flagErrAB_HF[0] == 0)
7391             htmlFile << "<h3> Fine:NoErrorA_HF (Mean of max difference " << avedelta_HF
7392                      << "  is within 0.8-2.4) </h3>\n";
7393           else if (flagErrAB_HF[0] == 1)
7394             htmlFile << "<<h3> ErrorA_HF is available once Mean of max difference " << avedelta_HF
7395                      << " is out 0.8-2.4 (p-p collisions)</font></h3>\n";
7396           else
7397             htmlFile << "<h3>auto-interpretation is not available</h3>\n";
7398           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7399 
7400           htmlFile << "<a name=\"ErrorAaverage\"></a>\n";
7401 
7402           htmlFile << "<h2> 5. Error type A cross check: see 2D pattern of channels   </h2>\n";
7403           htmlFile << "<h2> 1) with average channel Amplitudes(No cut), 2) with average channel Amplitudes(<A> >20), "
7404                       "3) with channel Amplitude (A<20);  </h2>\n";
7405           //       htmlFile << "<h2> 2D. Cross check for error A</h2>\n";
7406           htmlFile << " <img src=\"ChkErrA_HF1.png\" /><br><br>\n";
7407           htmlFile << " <img src=\"ChkErrA_HF2.png\" /><br>\n";
7408           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7409 
7410           htmlFile << "<a name=\"ErrorAoccupancy\"></a>\n";
7411           htmlFile << "<h2> 6. Error type A: min/ave ratio for occupancy distributions with Amplitude bigger 20 "
7412                       "(HFM:neg.eta;HFP:pos.eta) </h2>\n";
7413           htmlFile << "<h2> FOR CROSS-CHECK OLNY !!!</h2>\n";
7414           htmlFile << "<h2> TO IDENTIFY A-type errors: for most of LSs the ratio to be lower 0.8 at least for HF- or "
7415                       "HF+ </h2>\n";
7416           htmlFile << "<h2> For runs without A-type errors: for most of LSs the ratio is higher 0.8 and is the same "
7417                       "for HF- and HF+ </h2>\n";
7418           htmlFile << " <img src=\"OccPlots_HF.png\" /><br><br>\n";
7419           htmlFile << "<br>\n";
7420           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7421 
7422           htmlFile << "<a name=\"ErrorB\"></a>\n";
7423           htmlFile << "<h2> 7. Error type B\n";
7424           htmlFile << "<h3> ErrorB identification: digi-collection size != 4. </h3>\n";
7425           htmlFile << " <img src=\"HistErrB_HF_1.png\" />\n<br>\n";
7426           htmlFile << " <img src=\"HistErrB_HF_2.png\" />\n<br>\n";
7427           htmlFile << "<br>\n";
7428           htmlFile << "<h3> if Error type B is available, it start from:    " << LSofFirstErrB_HF << "  LS </h3>\n";
7429           htmlFile << "<br>\n";
7430         }
7431         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7432 
7433       }  //test=1 Amplitude
7434 
7435       if (test == 1)
7436         htmlFile << "<a name=\"LSstatus\"></a>\n";
7437       // Continue with common sections
7438       if (sub == 1) {
7439         htmlFile << "<h2> 8.Lumisection Status for HB: </h2>" << std::endl;
7440         //       htmlFile << "<h3> Legends: Red boxes correspond BAD LS selected with following cuts: <td class=\"s6\" align=\"center\">"<<Cut0[test][sub][1]<<" (Depth1), "<<Cut0[test][sub][2]<<" (Depth2). </td></h3>"<< std::endl;
7441         htmlFile << "<h3> Legends: Red boxes correspond BAD LS selected with following cuts: " << Cut0[test][sub][1]
7442                  << " (Depth1), " << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3), "
7443                  << Cut0[test][sub][4] << " (Depth4), </h3>" << std::endl;
7444       }
7445       if (sub == 2) {
7446         htmlFile << "<h2> 8.Lumisection Status for HE: </h2>" << std::endl;
7447         htmlFile << "<h3> Legends: Red boxes correspond BAD LS selected with following cuts: " << Cut0[test][sub][1]
7448                  << " (Depth1), " << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3),"
7449                  << Cut0[test][sub][4] << " (Depth4)," << Cut0[test][sub][5] << " (Depth5)," << Cut0[test][sub][6]
7450                  << " (Depth6)," << Cut0[test][sub][7] << " (Depth7). </h3>" << std::endl;
7451       }
7452       if (sub == 3) {
7453         //      htmlFile << Form("<h2> %d.Lumisection Status for HO </h2>",4+flagSpecHF)<< std::endl;
7454         htmlFile << "<h2> 8.Lumisection Status for HO: </h2>" << std::endl;
7455         htmlFile << "<h3> Legends: Red boxes correspond BAD LS selected with following cuts: " << Cut0[test][sub][4]
7456                  << " (Depth4). </h3>" << std::endl;
7457       }
7458       if (sub == 4) {
7459         htmlFile << "<h2> 8.Lumisection Status for HF: </h2>" << std::endl;
7460         htmlFile << "<h3> Legends: Red boxes correspond BAD LS selected with following cuts: " << Cut0[test][sub][1]
7461                  << " (Depth1), " << Cut0[test][sub][2] << " (Depth2), " << Cut0[test][sub][3] << " (Depth3), "
7462                  << Cut0[test][sub][4] << " (Depth4), </h3>" << std::endl;
7463       }
7464       htmlFile << "<br>" << std::endl;
7465       htmlFile << "<table>" << std::endl;
7466       htmlFile << "<tr>";
7467       htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
7468       //              htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
7469       htmlFile << "<td class=\"s1\" align=\"center\">Number of events</td>" << std::endl;
7470       /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7471 
7472       int kkkkkkmax = k_max[sub];
7473       if ((sub == 4 || sub == 2 || sub == 1) && test == 1)
7474         kkkkkkmax = k_maxupgrade[sub];
7475       //      if ( (sub==4 || sub==2) && test==1) kkkkkkmax = k_maxupgrade[sub];
7476       //       if (test==1 && sub==4) kkkkkkmax = k_maxupgrade[sub];
7477 
7478       if (test == 0)
7479         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7480           htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > Depth " << k << " </td>" << std::endl;
7481       if (test == 1)
7482         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7483           htmlFile << "<td class=\"s1\" align=\"center\">< A > Depth " << k << " </td>" << std::endl;
7484       if (test == 2)
7485         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7486           htmlFile << "<td class=\"s1\" align=\"center\">< W > Depth " << k << " </td>" << std::endl;
7487       if (test == 3)
7488         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7489           htmlFile << "<td class=\"s1\" align=\"center\">< R > Depth " << k << " </td>" << std::endl;
7490       if (test == 4)
7491         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7492           htmlFile << "<td class=\"s1\" align=\"center\">< TSn > Depth " << k << " </td>" << std::endl;
7493       if (test == 5)
7494         for (int k = k_min[sub]; k <= kkkkkkmax; k++)
7495           htmlFile << "<td class=\"s1\" align=\"center\">< TSx > Depth " << k << " </td>" << std::endl;
7496       htmlFile << "</tr>" << std::endl;
7497 
7498       ind = 0;
7499       for (int i = 1; i <= MaxLum; i++) {
7500         if ((ind % 2) == 1)
7501           raw_class = "<td class=\"s2\" align=\"center\">";
7502         else
7503           raw_class = "<td class=\"s3\" align=\"center\">";
7504         htmlFile << "<tr>" << std::endl;
7505         htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
7506         //                  htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
7507         htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
7508         for (int k = k_min[sub]; k <= kkkkkkmax; k++) {
7509           if (HistNumBadChanDepth[test][sub][k]->GetBinContent(i) > Cut0[test][sub][k]) {
7510             if (test == 1)
7511               htmlFile << "<td class=\"s6\" align=\"center\">"
7512                        << int(HistNumBadChanDepth[test][sub][k]->GetBinContent(i)) << "</td>" << std::endl;
7513             else
7514               htmlFile << "<td class=\"s6\" align=\"center\">" << (HistNumBadChanDepth[test][sub][k]->GetBinContent(i))
7515                        << "</td>" << std::endl;
7516           } else {
7517             if (test == 1)
7518               htmlFile << raw_class << int(HistNumBadChanDepth[test][sub][k]->GetBinContent(i)) << "</td>" << std::endl;
7519             else
7520               htmlFile << raw_class << (HistNumBadChanDepth[test][sub][k]->GetBinContent(i)) << "</td>" << std::endl;
7521           }
7522         }
7523         htmlFile << "</tr>" << std::endl;
7524         ind += 1;
7525       }
7526       htmlFile << "</table>" << std::endl;
7527 
7528       htmlFile << "<br>" << std::endl;
7529       if (test == 1)
7530         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7531       htmlFile << "<br>" << std::endl;
7532 
7533       // Only for Amplitudes (test=1):
7534       /// RBX:
7535       if (test == 1) {
7536         ///////////////////////////////////////////////////////////////////////////////////////////////////
7537         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    9. RBXstatus
7538         htmlFile << "<a name=\"RBXstatus\"></a>\n";
7539 
7540         //HB j = 7,8,9,10            11,12,13,14
7541         if (sub == 1) {
7542           htmlFile << "<h2> 9. Average Amplitudes of RBX for HB: </h2>" << std::endl;
7543           htmlFile << "<h3> where </h3>" << std::endl;
7544           htmlFile << "<h3> jeta = 7,8,9,10 (Negative direction); ............&& ............  jeta = 11,12,13,14 "
7545                       "(Positive direction);  </h3>"
7546                    << std::endl;
7547           htmlFile << "<h3> jphi =  0, 1,..... 16, 17 </h3>" << std::endl;
7548           //           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;
7549           htmlFile << " <img src=\"RBX-HB-2Dplot.png\" />\n";
7550           htmlFile << "<br>\n";
7551 
7552           htmlFile << "<h2> Average Amplitudes of RBX-PHI for HB: </h2>" << std::endl;
7553           htmlFile << " <img src=\"RBX-HB-1Dplot.png\" />\n";
7554           htmlFile << "<br>\n";
7555 
7556           htmlFile << "<h2> Average Amplitudes of RBX-ETA for HB: </h2>" << std::endl;
7557           htmlFile << " <img src=\"RBX-HB-11Dplot.png\" />\n";
7558           htmlFile << "<br>\n";
7559 
7560           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7561         }
7562         // HE: j = 3,4,5, 6, 7      14,15,16,17,18
7563         if (sub == 2) {
7564           htmlFile << "<h2> 9. Averaged Amplitudes of RBX for HE: </h2>" << std::endl;
7565           htmlFile << "<h3> where </h3>" << std::endl;
7566           htmlFile << "<h3> jeta = 3,4,5, 6, 7 (Negative direction); ............&& ............  jeta = "
7567                       "14,15,16,17,18 (Positive direction);  </h3>"
7568                    << std::endl;
7569           htmlFile << "<h3> jphi =  0, 1,..... 16, 17 </h3>" << std::endl;
7570           //           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;
7571           htmlFile << " <img src=\"RBX-HE-2Dplot.png\" />\n";
7572           htmlFile << "<br>\n";
7573 
7574           htmlFile << "<h2> Average Amplitudes of RBX-PHI for HE: </h2>" << std::endl;
7575           htmlFile << " <img src=\"RBX-HE-1Dplot.png\" />\n";
7576           htmlFile << "<br>\n";
7577 
7578           htmlFile << "<h2> Average Amplitudes of RBX-ETA for HE: </h2>" << std::endl;
7579           htmlFile << " <img src=\"RBX-HE-11Dplot.png\" />\n";
7580           htmlFile << "<br>\n";
7581 
7582           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7583         }
7584         // HO:   j = 7,8,9,10            11,12,13,14
7585         if (sub == 3) {
7586           htmlFile << "<h2> 9. Averaged Amplitudes of RBX for HO: </h2>" << std::endl;
7587           htmlFile << "<h3> where </h3>" << std::endl;
7588           htmlFile << "<h3> jeta = 7,8,9,10 (Negative direction); ............&& ............  jeta = 11,12,13,14 "
7589                       "(Positive direction);  </h3>"
7590                    << std::endl;
7591           htmlFile << "<h3> jphi =  0, 1,..... 16, 17 </h3>" << std::endl;
7592           //           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;
7593           htmlFile << " <img src=\"RBX-HO-2Dplot.png\" />\n";
7594           htmlFile << "<br>\n";
7595 
7596           htmlFile << "<h2> Average Amplitudes of RBX-PHI for HO: </h2>" << std::endl;
7597           htmlFile << " <img src=\"RBX-HO-1Dplot.png\" />\n";
7598           htmlFile << "<br>\n";
7599 
7600           htmlFile << "<h2> Average Amplitudes of RBX-ETA for HO: </h2>" << std::endl;
7601           htmlFile << " <img src=\"RBX-HO-11Dplot.png\" />\n";
7602           htmlFile << "<br>\n";
7603 
7604           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7605         }
7606         //HF:j = 0,1,2, 3            18,19,20,21
7607         if (sub == 4) {
7608           htmlFile << "<h2> 9. Averaged Amplitudes of RBX for HF: </h2>" << std::endl;
7609           htmlFile << "<h3> where </h3>" << std::endl;
7610           htmlFile << "<h3> jeta = 0,1,2, 3 (Negative direction); ............&& ............  jeta = 18,19,20,21 "
7611                       "(Positive direction);  </h3>"
7612                    << std::endl;
7613           htmlFile << "<h3> jphi =  0, 1,..... 16, 17 </h3>" << std::endl;
7614           //           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;
7615           htmlFile << " <img src=\"RBX-HF-2Dplot.png\" />\n";
7616           htmlFile << "<br>\n";
7617 
7618           htmlFile << "<h2> Average Amplitudes of RBX-PHI for HF: </h2>" << std::endl;
7619           htmlFile << " <img src=\"RBX-HF-1Dplot.png\" />\n";
7620           htmlFile << "<br>\n";
7621 
7622           htmlFile << "<h2> Average Amplitudes of RBX-ETA for HF: </h2>" << std::endl;
7623           htmlFile << " <img src=\"RBX-HF-11Dplot.png\" />\n";
7624           htmlFile << "<br>\n";
7625 
7626           htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7627         }
7628         htmlFile << "<br>" << std::endl;
7629 
7630         ///////////////////////////////////////////////////////////////////////////////////////////////////
7631         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    10. RBXPHItable
7632 
7633         htmlFile << "<a name=\"RBXPHItable\"></a>\n";
7634         int cutA_ALL = 0;
7635         //       float cutA_HB = 100.;float cutA_HE = 1000000.;float cutA_HO = 150.;float cutA_HF = 500.;
7636         if (sub == 1) {
7637           htmlFile << "<h2> 10. Average RBX-Amplitude in Phi over LSs for HB: </h2>" << std::endl;
7638           htmlFile
7639               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7640               << cutA_HB << std::endl;
7641           cutA_ALL = cutA_HB;
7642         }
7643         if (sub == 2) {
7644           htmlFile << "<h2> 10. Average RBX-Amplitude in Phi over LSs for HE: </h2>" << std::endl;
7645           htmlFile
7646               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7647               << cutA_HE << std::endl;
7648           cutA_ALL = cutA_HE;
7649         }
7650         if (sub == 3) {
7651           htmlFile << "<h2> 10. Average RBX-Amplitude in Phi over LSs for HO: </h2>" << std::endl;
7652           htmlFile
7653               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7654               << cutA_HO << std::endl;
7655           cutA_ALL = cutA_HO;
7656         }
7657         if (sub == 4) {
7658           htmlFile << "<h2> 10. Average RBX-Amplitude in Phi over LSs for HF: </h2>" << std::endl;
7659           htmlFile
7660               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7661               << cutA_HF << std::endl;
7662           cutA_ALL = cutA_HF;
7663         }
7664 
7665         htmlFile << "<br>" << std::endl;
7666         htmlFile << "<table>" << std::endl;
7667         htmlFile << "<tr>";
7668         htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
7669         //              htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
7670         htmlFile << "<td class=\"s1\" align=\"center\">Number of events</td>" << std::endl;
7671         /////////////////////////////////////////////////////
7672 
7673         // k is jphi
7674         for (int k = 0; k < njphi; k++)
7675           htmlFile << "<td class=\"s1\" align=\"center\"> iPHI " << k << " </td>" << std::endl;
7676         htmlFile << "</tr>" << std::endl;
7677         //////////////
7678 
7679         ind = 0;
7680         // i is LS
7681         for (int i = 1; i <= MaxLum; i++) {
7682           if ((ind % 2) == 1)
7683             raw_class = "<td class=\"s2\" align=\"center\">";
7684           else
7685             raw_class = "<td class=\"s3\" align=\"center\">";
7686           htmlFile << "<tr>" << std::endl;
7687           htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
7688           //                  htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
7689           htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
7690 
7691           // k is jphi
7692           for (int k = 0; k < njphi; k++) {
7693             if (sub == 1) {
7694               if (int(alexhb[k][i - 1]) > cutA_ALL) {
7695                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(alexhb[k][i - 1]) << "</td>" << std::endl;
7696               } else {
7697                 htmlFile << raw_class << int(alexhb[k][i - 1]) << "</td>" << std::endl;
7698               }
7699             }  // HB end
7700             if (sub == 2) {
7701               if (int(alexhe[k][i - 1]) > cutA_ALL) {
7702                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(alexhe[k][i - 1]) << "</td>" << std::endl;
7703               } else {
7704                 htmlFile << raw_class << int(alexhe[k][i - 1]) << "</td>" << std::endl;
7705               }
7706             }  // HE end
7707             if (sub == 3) {
7708               if (int(alexho[k][i - 1]) > cutA_ALL) {
7709                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(alexho[k][i - 1]) << "</td>" << std::endl;
7710               } else {
7711                 htmlFile << raw_class << int(alexho[k][i - 1]) << "</td>" << std::endl;
7712               }
7713             }  // HO end
7714             if (sub == 4) {
7715               if (int(alexhf[k][i - 1]) > cutA_ALL) {
7716                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(alexhf[k][i - 1]) << "</td>" << std::endl;
7717               } else {
7718                 htmlFile << raw_class << int(alexhf[k][i - 1]) << "</td>" << std::endl;
7719               }
7720             }  // HF end
7721                ////////////////////////
7722           }    // k over PHI-RBX
7723           htmlFile << "</tr>" << std::endl;
7724           ind += 1;
7725         }  // i over LSs
7726         htmlFile << "</table>" << std::endl;
7727         htmlFile << "<br>" << std::endl;
7728         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7729         htmlFile << "<br>" << std::endl;
7730         //////////////////////////////////////////////////////////////////////////////////////////    11. RBXETAtable
7731 
7732         htmlFile << "<a name=\"RBXETAtable\"></a>\n";
7733         int cutB_ALL = 0;
7734         //       float cutB_HB = 100.;float cutB_HE = 1000000.;float cutB_HO = 150.;float cutB_HF = 500.;
7735         if (sub == 1) {
7736           htmlFile << "<h2> 11. Average RBX-Amplitude in Eta over LSs for HB: </h2>" << std::endl;
7737           htmlFile
7738               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7739               << cutB_HB << std::endl;
7740           cutB_ALL = cutB_HB;
7741         }
7742         if (sub == 2) {
7743           htmlFile << "<h2> 11. Average RBX-Amplitude in Eta over LSs for HE: </h2>" << std::endl;
7744           htmlFile
7745               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7746               << cutB_HE << std::endl;
7747           cutB_ALL = cutB_HE;
7748         }
7749         if (sub == 3) {
7750           htmlFile << "<h2> 11. Average RBX-Amplitude in Eta over LSs for HO: </h2>" << std::endl;
7751           htmlFile
7752               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7753               << cutB_HO << std::endl;
7754           cutB_ALL = cutB_HO;
7755         }
7756         if (sub == 4) {
7757           htmlFile << "<h2> 11. Average RBX-Amplitude in Eta over LSs for HF: </h2>" << std::endl;
7758           htmlFile
7759               << "<h3> Legends: Red boxes correspond BAD LS selected with cut =  <td class=\"s6\" align=\"center\">"
7760               << cutB_HF << std::endl;
7761           cutB_ALL = cutB_HF;
7762         }
7763 
7764         htmlFile << "<br>" << std::endl;
7765         htmlFile << "<table>" << std::endl;
7766         htmlFile << "<tr>";
7767         htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
7768         //              htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
7769         htmlFile << "<td class=\"s1\" align=\"center\">Number of events</td>" << std::endl;
7770         /////////////////////////////////////////////////////
7771 
7772         // k is jeta
7773         for (int k = 0; k < njeta; k++)
7774           htmlFile << "<td class=\"s1\" align=\"center\"> iETA " << k << " </td>" << std::endl;
7775         htmlFile << "</tr>" << std::endl;
7776         //////////////
7777 
7778         ind = 0;
7779         // i is LS
7780         for (int i = 1; i <= MaxLum; i++) {
7781           if ((ind % 2) == 1)
7782             raw_class = "<td class=\"s2\" align=\"center\">";
7783           else
7784             raw_class = "<td class=\"s3\" align=\"center\">";
7785           htmlFile << "<tr>" << std::endl;
7786           htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
7787           //                  htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
7788           htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
7789 
7790           // k is jeta
7791           for (int k = 0; k < njeta; k++) {
7792             if (sub == 1) {
7793               if (int(blexhb[k][i - 1]) > cutB_ALL) {
7794                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(blexhb[k][i - 1]) << "</td>" << std::endl;
7795               } else {
7796                 htmlFile << raw_class << int(blexhb[k][i - 1]) << "</td>" << std::endl;
7797               }
7798             }  // HB end
7799             if (sub == 2) {
7800               if (int(blexhe[k][i - 1]) > cutB_ALL) {
7801                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(blexhe[k][i - 1]) << "</td>" << std::endl;
7802               } else {
7803                 htmlFile << raw_class << int(blexhe[k][i - 1]) << "</td>" << std::endl;
7804               }
7805             }  // HE end
7806             if (sub == 3) {
7807               if (int(blexho[k][i - 1]) > cutB_ALL) {
7808                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(blexho[k][i - 1]) << "</td>" << std::endl;
7809               } else {
7810                 htmlFile << raw_class << int(blexho[k][i - 1]) << "</td>" << std::endl;
7811               }
7812             }  // HO end
7813             if (sub == 4) {
7814               if (int(blexhf[k][i - 1]) > cutB_ALL) {
7815                 htmlFile << "<td class=\"s6\" align=\"center\">" << int(blexhf[k][i - 1]) << "</td>" << std::endl;
7816               } else {
7817                 htmlFile << raw_class << int(blexhf[k][i - 1]) << "</td>" << std::endl;
7818               }
7819             }  // HF end
7820                ////////////////////////
7821           }    // k over ETA-RBX
7822           htmlFile << "</tr>" << std::endl;
7823           ind += 1;
7824         }  // i over LSs
7825         htmlFile << "</table>" << std::endl;
7826         htmlFile << "<br>" << std::endl;
7827         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7828         htmlFile << "<br>" << std::endl;
7829         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7830 
7831         ///////////////////////////////////////////////////////////////////////////////////////////////////
7832         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    12. RBX3plots
7833         htmlFile << "<a name=\"RBX3plots\"></a>\n";
7834         htmlFile << "<br>\n";
7835         htmlFile << "<h2> 12. (Rij) - RBX-amplitudes normilized on reference LS (~=1st) </h2>" << std::endl;
7836         htmlFile << "<h3> ( Rji . . is ratio of . . . . A_j_i . . to . . A_j_ref . . . . for . . j-RBX . . and . . "
7837                     "i-LS . ) </h3>"
7838                  << std::endl;
7839 
7840         htmlFile << "<br>\n";
7841         htmlFile << "<h2> . . . . . . . . . . . . . . 1) . average Ri vs iLS:. . . . . . . . . . . . . . . . . . . . . "
7842                     ". . 2) . average Rj shown for Rij outside meanValue range either 0.95-1.05 or 3RMS: . . . . . . . "
7843                     ". . . . . . . . . . . . . . . . . . 3) . Rij: </h2>"
7844                  << std::endl;
7845         htmlFile << "<br>\n";
7846         if (sub == 1) {
7847           htmlFile << " <img src=\"RBX-HB-3plots.png\" />\n";
7848         }
7849         if (sub == 2) {
7850           htmlFile << " <img src=\"RBX-HE-3plots.png\" />\n";
7851         }
7852         if (sub == 3) {
7853           htmlFile << " <img src=\"RBX-HO-3plots.png\" />\n";
7854         }
7855         if (sub == 4) {
7856           htmlFile << " <img src=\"RBX-HF-3plots.png\" />\n";
7857         }
7858         htmlFile << "<br>\n";
7859 
7860         htmlFile << "<br>\n";
7861         htmlFile << "<h2> . 4). average Rj shown for Rij outside meanValue range 0.80-1.20: . . . . . . . .5) . "
7862                     "average Rj shown for Rij outside meanValue range 0.70-1.30:   . . . . . . . .6). average Rj shown "
7863                     "for Rij outside meanValue range 0.60-1.40: </h2>"
7864                  << std::endl;
7865         htmlFile << "<br>\n";
7866         if (sub == 1) {
7867           htmlFile << " <img src=\"RBX-HB-3plotsmore.png\" />\n";
7868         }
7869         if (sub == 2) {
7870           htmlFile << " <img src=\"RBX-HE-3plotsmore.png\" />\n";
7871         }
7872         if (sub == 3) {
7873           htmlFile << " <img src=\"RBX-HO-3plotsmore.png\" />\n";
7874         }
7875         if (sub == 4) {
7876           htmlFile << " <img src=\"RBX-HF-3plotsmore.png\" />\n";
7877         }
7878         htmlFile << "<br>\n";
7879 
7880         htmlFile << "<a href=\"#Top\">to top</a><br>\n";
7881 
7882         //=========================================================
7883 
7884       }  // test=1
7885 
7886       //===============================================================================
7887 
7888       htmlFile.close();
7889     }  // sub main loop
7890   }    //test main loop
7891   //===============================================================================
7892   //===============================================================================
7893   //===============================================================================
7894   //===============================================================================
7895   //===============================================================================
7896 
7897   //======================================================================
7898   // Creating tests  html pages:
7899 
7900   for (int test = 0; test <= 5; test++) {  //Test: 0,
7901     if (test == 0)
7902       htmlFile.open("CapID_GL.html");
7903     if (test == 1)
7904       htmlFile.open("ADCampl_GL.html");
7905     if (test == 2)
7906       htmlFile.open("Width_GL.html");
7907     if (test == 3)
7908       htmlFile.open("Ratio_GL.html");
7909     if (test == 4)
7910       htmlFile.open("Tmean_GL.html");
7911     if (test == 5)
7912       htmlFile.open("Tmax_GL.html");
7913 
7914     //  cout<<"Creating tests  html pages:  test=  "<< test <<     endl;
7915 
7916     htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
7917     htmlFile << "<head>" << std::endl;
7918     htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
7919     htmlFile << "<title> Certification Monitoring Tool </title>" << std::endl;
7920     htmlFile << "<style type=\"text/css\">" << std::endl;
7921     htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
7922              << std::endl;
7923     htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
7924     htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
7925                 "text-align: center;}"
7926              << std::endl;
7927     htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
7928     htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
7929     htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
7930     htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: #00FF00; }" << std::endl;
7931     htmlFile << "   td.s6 { font-family: arial, arial ce, helvetica; background-color: #FF0000; }" << std::endl;
7932     htmlFile << "</style>" << std::endl;
7933     htmlFile << "<body>" << std::endl;
7934     if (test == 0)
7935       htmlFile << "<h1> CAP ID ERRORS, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7936     if (test == 1)
7937       htmlFile << "<h1> ADC AMPLITIDE, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7938     if (test == 2)
7939       htmlFile << "<h1> WIDTH, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7940     if (test == 3)
7941       htmlFile << "<h1> RATIO, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7942     if (test == 4)
7943       htmlFile << "<h1> TIMING MEAN, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7944     if (test == 5)
7945       htmlFile << "<h1> TIMING MAX, GLOBAL RUN = " << runnumber << " </h1>" << std::endl;
7946     htmlFile << "<br>" << std::endl;
7947     htmlFile << "<h2> 1.  Map of suspicious channels with this criterion for whole HCAL </h2>" << std::endl;
7948     htmlFile << "<h3> Channel legend: green - good, other colour - suspicious  </h3>" << std::endl;
7949     htmlFile << "<br>" << std::endl;
7950     if (test == 0)
7951       htmlFile << " <img src=\"MapCapIdError.png\" />" << std::endl;
7952     if (test == 1)
7953       htmlFile << " <img src=\"MapADCAmpl.png\" />" << std::endl;
7954     if (test == 2)
7955       htmlFile << " <img src=\"MapWidth.png\" />" << std::endl;
7956     if (test == 3)
7957       htmlFile << " <img src=\"MapRatio.png\" />" << std::endl;
7958     if (test == 4)
7959       htmlFile << " <img src=\"MapTmean.png\" />" << std::endl;
7960     if (test == 5)
7961       htmlFile << " <img src=\"MapTmax.png\" />" << std::endl;
7962     htmlFile << "<br>" << std::endl;
7963     htmlFile << "<h2> 2.  For whole HCAL: </h2>" << std::endl;
7964     htmlFile << "<br>" << std::endl;
7965     if (test == 0)
7966       htmlFile << " <img src=\"HistCapID.png\" />" << std::endl;
7967     if (test == 1)
7968       htmlFile << " <img src=\"HistADCAmpl.png\" />" << std::endl;
7969     if (test == 2)
7970       htmlFile << " <img src=\"HistWidth.png\" />" << std::endl;
7971     if (test == 3)
7972       htmlFile << " <img src=\"HistRatio.png\" />" << std::endl;
7973     if (test == 4)
7974       htmlFile << " <img src=\"HistTmean.png\" />" << std::endl;
7975     if (test == 5)
7976       htmlFile << " <img src=\"HistTmax.png\" />" << std::endl;
7977     htmlFile << "<br>" << std::endl;
7978     htmlFile << "<h2> 3. Status of subdetectors </h2>" << std::endl;
7979     htmlFile << "<table width=\"400\">" << std::endl;
7980     htmlFile << "<tr>" << std::endl;
7981     if (test == 0) {
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_CapID.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_CapID.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_CapID.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_CapID.html\">HF</a></td>" << std::endl;
7998     }
7999     if (test == 1) {
8000       // AZ 07.11.2018
8001       htmlFile << "  <td><a href=\"HB_ADCampl.html\">HB</a></td>" << std::endl;
8002       htmlFile << "  <td><a href=\"HE_ADCampl.html\">HE</a></td>" << std::endl;
8003       htmlFile << "  <td><a href=\"HO_ADCampl.html\">HO</a></td>" << std::endl;
8004       htmlFile << "  <td><a href=\"HF_ADCampl.html\">HF</a></td>" << std::endl;
8005       /*
8006       htmlFile << "  <td><a href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/HcalRemoteMonitoring/CMT/GLOBAL_"<<runnumber<<"/HB_ADCampl.html\">HB</a></td>"<< std::endl;
8007       htmlFile << "  <td><a href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/HcalRemoteMonitoring/CMT/GLOBAL_"<<runnumber<<"/HE_ADCampl.html\">HE</a></td>"<< std::endl;
8008       htmlFile << "  <td><a href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/HcalRemoteMonitoring/CMT/GLOBAL_"<<runnumber<<"/HO_ADCampl.html\">HO</a></td>"<< std::endl;
8009       htmlFile << "  <td><a href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/HcalRemoteMonitoring/CMT/GLOBAL_"<<runnumber<<"/HF_ADCampl.html\">HF</a></td>"<< std::endl;
8010 */
8011     }
8012     if (test == 2) {
8013       htmlFile << "  <td><a "
8014                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8015                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8016                << runnumber << "/HB_Width.html\">HB</a></td>" << std::endl;
8017       htmlFile << "  <td><a "
8018                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8019                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8020                << runnumber << "/HE_Width.html\">HE</a></td>" << std::endl;
8021       htmlFile << "  <td><a "
8022                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8023                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8024                << runnumber << "/HO_Width.html\">HO</a></td>" << std::endl;
8025       htmlFile << "  <td><a "
8026                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8027                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8028                << runnumber << "/HF_Width.html\">HF</a></td>" << std::endl;
8029     }
8030     if (test == 3) {
8031       htmlFile << "  <td><a "
8032                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8033                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8034                << runnumber << "/HB_Ratio.html\">HB</a></td>" << std::endl;
8035       htmlFile << "  <td><a "
8036                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8037                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8038                << runnumber << "/HE_Ratio.html\">HE</a></td>" << std::endl;
8039       htmlFile << "  <td><a "
8040                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8041                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8042                << runnumber << "/HO_Ratio.html\">HO</a></td>" << std::endl;
8043       htmlFile << "  <td><a "
8044                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8045                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8046                << runnumber << "/HF_Ratio.html\">HF</a></td>" << std::endl;
8047     }
8048     if (test == 4) {
8049       htmlFile << "  <td><a "
8050                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8051                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8052                << runnumber << "/HB_Tmean.html\">HB</a></td>" << std::endl;
8053       htmlFile << "  <td><a "
8054                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8055                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8056                << runnumber << "/HE_Tmean.html\">HE</a></td>" << std::endl;
8057       htmlFile << "  <td><a "
8058                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8059                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8060                << runnumber << "/HO_Tmean.html\">HO</a></td>" << std::endl;
8061       htmlFile << "  <td><a "
8062                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8063                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8064                << runnumber << "/HF_Tmean.html\">HF</a></td>" << std::endl;
8065     }
8066     if (test == 5) {
8067       htmlFile << "  <td><a "
8068                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8069                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8070                << runnumber << "/HB_Tmax.html\">HB</a></td>" << std::endl;
8071       htmlFile << "  <td><a "
8072                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8073                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8074                << runnumber << "/HE_Tmax.html\">HE</a></td>" << std::endl;
8075       htmlFile << "  <td><a "
8076                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8077                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8078                << runnumber << "/HO_Tmax.html\">HO</a></td>" << std::endl;
8079       htmlFile << "  <td><a "
8080                   "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8081                   "HcalRemoteMonitoring/CMT/GLOBAL_"
8082                << runnumber << "/HF_Tmax.html\">HF</a></td>" << std::endl;
8083     }
8084 
8085     htmlFile << "</tr>" << std::endl;
8086     htmlFile << "</table>" << std::endl;
8087     htmlFile << "<br>" << std::endl;
8088     //  cout<<"Creating tests  html pages:  111111" <<     endl;
8089 
8090     if (test != 0)
8091       htmlFile << "<h2> 4. Table of estimator-values in sub-detectors for ONLY suspicious LSs </h3>" << std::endl;
8092     if (test == 0)
8093       htmlFile << "<h2> 4. Table of average Nbcs in sub-detectors for ONLY suspicious LSs </h3>" << std::endl;
8094     htmlFile << "<table>" << std::endl;
8095     htmlFile << "<tr>";
8096     htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
8097     //     htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
8098     htmlFile << "<td class=\"s1\" align=\"center\">Number of events</td>" << std::endl;
8099     ////////////////////////////////////////////////////////////////////////////////////////////////////
8100     for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HO, 4-HF
8101 
8102       //    cout<<"Creating each test kind for each subdet html pages:  test=  "<< test << "  sub= "  << sub <<    endl;
8103       int kkkkkkmax = k_max[sub];
8104       if ((sub == 4 || sub == 2 || sub == 1) && test == 1)
8105         kkkkkkmax = k_maxupgrade[sub];
8106       //      if ( (sub==4 || sub==2) && test==1) kkkkkkmax = k_maxupgrade[sub];
8107       //       if (test==1 && sub==4) kkkkkkmax = k_maxupgrade[sub];
8108       if (sub == 1) {
8109         if (test == 0)
8110           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8111             htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > HBdep " << k << " </td>" << std::endl;
8112         if (test == 1)
8113           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8114             htmlFile << "<td class=\"s1\" align=\"center\">< A > HBdepth " << k << " </td>" << std::endl;
8115         if (test == 2)
8116           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8117             htmlFile << "<td class=\"s1\" align=\"center\">< W > HBdepth " << k << " </td>" << std::endl;
8118         if (test == 3)
8119           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8120             htmlFile << "<td class=\"s1\" align=\"center\">< R > HBdepth " << k << " </td>" << std::endl;
8121         if (test == 4)
8122           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8123             htmlFile << "<td class=\"s1\" align=\"center\">< TSn > HBdep " << k << " </td>" << std::endl;
8124         if (test == 5)
8125           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8126             htmlFile << "<td class=\"s1\" align=\"center\">< TSx > HBdep " << k << " </td>" << std::endl;
8127       }  //
8128       if (sub == 2) {
8129         if (test == 0)
8130           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8131             htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > HEdep " << k << " </td>" << std::endl;
8132         if (test == 1)
8133           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8134             htmlFile << "<td class=\"s1\" align=\"center\">< A > HEdepth " << k << " </td>" << std::endl;
8135         if (test == 2)
8136           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8137             htmlFile << "<td class=\"s1\" align=\"center\">< W > HEdepth " << k << " </td>" << std::endl;
8138         if (test == 3)
8139           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8140             htmlFile << "<td class=\"s1\" align=\"center\">< R > HEdepth " << k << " </td>" << std::endl;
8141         if (test == 4)
8142           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8143             htmlFile << "<td class=\"s1\" align=\"center\">< TSn > HEdep " << k << " </td>" << std::endl;
8144         if (test == 5)
8145           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8146             htmlFile << "<td class=\"s1\" align=\"center\">< TSx > HEdep " << k << " </td>" << std::endl;
8147       }  //
8148       if (sub == 3) {
8149         if (test == 0)
8150           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8151             htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > HOdep " << k << " </td>" << std::endl;
8152         if (test == 1)
8153           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8154             htmlFile << "<td class=\"s1\" align=\"center\">< A > HOdepth " << k << " </td>" << std::endl;
8155         if (test == 2)
8156           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8157             htmlFile << "<td class=\"s1\" align=\"center\">< W > HOdepth " << k << " </td>" << std::endl;
8158         if (test == 3)
8159           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8160             htmlFile << "<td class=\"s1\" align=\"center\">< R > HOdepth " << k << " </td>" << std::endl;
8161         if (test == 4)
8162           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8163             htmlFile << "<td class=\"s1\" align=\"center\">< TSn > HOdep " << k << " </td>" << std::endl;
8164         if (test == 5)
8165           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8166             htmlFile << "<td class=\"s1\" align=\"center\">< TSx > HOdep " << k << " </td>" << std::endl;
8167       }  //
8168       if (sub == 4) {
8169         if (test == 0)
8170           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8171             htmlFile << "<td class=\"s1\" align=\"center\">< Nbcs > HFdep " << k << " </td>" << std::endl;
8172         if (test == 1)
8173           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8174             htmlFile << "<td class=\"s1\" align=\"center\">< A > HFdepth " << k << " </td>" << std::endl;
8175         if (test == 2)
8176           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8177             htmlFile << "<td class=\"s1\" align=\"center\">< W > HFdepth " << k << " </td>" << std::endl;
8178         if (test == 3)
8179           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8180             htmlFile << "<td class=\"s1\" align=\"center\">< R > HFdepth " << k << " </td>" << std::endl;
8181         if (test == 4)
8182           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8183             htmlFile << "<td class=\"s1\" align=\"center\">< TSn > HFdep " << k << " </td>" << std::endl;
8184         if (test == 5)
8185           for (int k = k_min[sub]; k <= kkkkkkmax; k++)
8186             htmlFile << "<td class=\"s1\" align=\"center\">< TSx > HFdep " << k << " </td>" << std::endl;
8187       }  //
8188     }    // sub
8189     htmlFile << "</tr>" << std::endl;
8190 
8191     //    htmlFile << "<td class=\"s1\" align=\"center\">HB Depth 1</td>"<< std::endl;
8192     //    htmlFile << "<td class=\"s1\" align=\"center\">HB Depth 2</td>"  << std::endl;
8193     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 1</td>"   << std::endl;
8194     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 2</td>"   << std::endl;
8195     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 3</td>"   << std::endl;
8196     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 4</td>"   << std::endl;
8197     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 5</td>"   << std::endl;
8198     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 6</td>"   << std::endl;
8199     //    htmlFile << "<td class=\"s1\" align=\"center\">HE Depth 7</td>"   << std::endl;
8200     //    htmlFile << "<td class=\"s1\" align=\"center\">HO Depth 4</td>"   << std::endl;
8201     //    htmlFile << "<td class=\"s1\" align=\"center\">HF Depth 1</td>"   << std::endl;
8202     //    htmlFile << "<td class=\"s1\" align=\"center\">HF Depth 2</td>"   << std::endl;
8203     //    htmlFile << "<td class=\"s1\" align=\"center\">HF Depth 3</td>"   << std::endl;
8204     //    htmlFile << "<td class=\"s1\" align=\"center\">HF Depth 4</td>"   << std::endl;
8205     //    htmlFile << "</tr>"   << std::endl;
8206 
8207     ind = 0;
8208     //  cout<<"Creating tests  html pages:  222222" <<     endl;
8209     for (int i = 1; i <= MaxLum; i++) {
8210       // define al least one exceed in any sub-detector
8211       int met = 0;
8212       for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
8213         int kkkkkkmax = k_max[sub];
8214         if ((sub == 4 || sub == 2 || sub == 1) && test == 1)
8215           kkkkkkmax = k_maxupgrade[sub];
8216         //  if ( (sub==4 || sub==2) && test==1) kkkkkkmax = k_maxupgrade[sub];
8217         for (int k = k_min[sub]; k <= kkkkkkmax; k++) {
8218           // 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
8219           if (sub == 2 && k > 3) {
8220           } else {
8221             if (HistNumBadChanDepth[test][sub][k]->GetBinContent(i) > Cut0[test][sub][k])
8222               met = 1;
8223           }
8224         }  //depth
8225       }    //sub
8226       // if exceed then plot the line for all sub-detectors
8227       if (met == 1) {
8228         if ((ind % 2) == 1)
8229           raw_class = "<td class=\"s2\" align=\"center\">";
8230         else
8231           raw_class = "<td class=\"s3\" align=\"center\">";
8232         htmlFile << "<tr>" << std::endl;
8233         htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
8234         //            htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
8235         htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
8236         for (int sub = 1; sub <= 4; sub++) {  //Subdetector: 1-HB, 2-HE, 3-HF, 4-HO
8237           int kkkkkkmax = k_max[sub];
8238           if ((sub == 4 || sub == 2 || sub == 1) && test == 1)
8239             kkkkkkmax = k_maxupgrade[sub];
8240           //      if ( (sub==4 || sub==2) && test==1) kkkkkkmax = k_maxupgrade[sub];
8241           for (int k = k_min[sub]; k <= kkkkkkmax; k++) {
8242             if (HistNumBadChanDepth[test][sub][k]->GetBinContent(i) > Cut0[test][sub][k])
8243               htmlFile << "<td class=\"s6\" align=\"center\">" << HistNumBadChanDepth[test][sub][k]->GetBinContent(i)
8244                        << "</td>" << std::endl;
8245             else
8246               htmlFile << raw_class << HistNumBadChanDepth[test][sub][k]->GetBinContent(i) << "</td>" << std::endl;
8247             //       htmlFile << "</tr>" << std::endl;
8248             /*
8249           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;
8250           else htmlFile <<raw_class<<HistNumBadChanDepth[test][1][1]->GetBinContent(i)<<"</td>"<< std::endl;   
8251           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;
8252           else htmlFile <<raw_class<<HistNumBadChanDepth[test][1][2]->GetBinContent(i)<<"</td>"<< std::endl;        
8253           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;
8254           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][1]->GetBinContent(i)<<"</td>"<< std::endl;        
8255           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;
8256           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][2]->GetBinContent(i)<<"</td>"<< std::endl;        
8257           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;
8258           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][3]->GetBinContent(i)<<"</td>"<< std::endl;        
8259           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;
8260           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][4]->GetBinContent(i)<<"</td>"<< std::endl;        
8261           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;
8262           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][5]->GetBinContent(i)<<"</td>"<< std::endl;        
8263           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;
8264           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][6]->GetBinContent(i)<<"</td>"<< std::endl;        
8265           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;
8266           else htmlFile <<raw_class<<HistNumBadChanDepth[test][2][7]->GetBinContent(i)<<"</td>"<< std::endl;        
8267           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;
8268           else htmlFile <<raw_class<<HistNumBadChanDepth[test][3][4]->GetBinContent(i)<<"</td>"<< std::endl;        
8269           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;
8270           else htmlFile <<raw_class<<HistNumBadChanDepth[test][4][1]->GetBinContent(i)<<"</td>"<< std::endl;      
8271           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;
8272           else htmlFile <<raw_class<<HistNumBadChanDepth[test][4][2]->GetBinContent(i)<<"</td>"<< std::endl;
8273         */
8274           }  //k depthes
8275         }    //sub
8276         htmlFile << "</tr>" << std::endl;
8277         ind += 1;
8278       }  // met=1
8279     }    //i bin lines
8280     //  cout<<"Creating tests  html pages:  333333" <<     endl;
8281     htmlFile << "</table>" << std::endl;
8282     htmlFile << "<br>" << std::endl;
8283     htmlFile << "</body> " << std::endl;
8284     htmlFile << "</html> " << std::endl;
8285     htmlFile.close();
8286   }  //test
8287   //======================================================================
8288   //    cout<<"for summed Amplitudes of each sub-detector" <<     endl;
8289 
8290   // for summed Amplitudes of each sub-detector
8291   htmlFile.open("SummedAmplitudes_GL.html");
8292   htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
8293   htmlFile << "<head>" << std::endl;
8294   htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
8295   htmlFile << "<title> for summed Amplitudes of each sub-detector </title>" << std::endl;
8296   htmlFile << "<style type=\"text/css\">" << std::endl;
8297   htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
8298            << std::endl;
8299   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
8300   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
8301               "text-align: center;}"
8302            << std::endl;
8303   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
8304   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
8305   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
8306   htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: #00FF00; }" << std::endl;
8307   htmlFile << "   td.s6 { font-family: arial, arial ce, helvetica; background-color: #FF0000; }" << std::endl;
8308 
8309   htmlFile << "</style>" << std::endl;
8310   htmlFile << "<body>" << std::endl;
8311   htmlFile << "<h1> Averaged Summed Amplitudes & corresponding occupancy of each sub-detector in Global Run = "
8312            << runnumber << " </h1>" << std::endl;
8313   htmlFile << "<a name=\"Top\"></a>\n";
8314   htmlFile << "<b>Contents:<br>\n";
8315   htmlFile << "1. <a href=\"#SAhigh\">average SA&Occupancy for Signal  </a><br>\n";
8316   htmlFile << "2. <a href=\"#SAlow\">average SA&Occupancy for NoSignal </a><br>\n";
8317   htmlFile << "3. <a href=\"#SAmax\"> maxSA & maxOccupancy; SA & Occupancy; </a><br>\n";
8318   htmlFile << "4. <a href=\"#FullTable\">Table(avA; avSA; avOccupancy; maxSA; maxOccupancy;) </a><br>\n";
8319 
8320   htmlFile << "<h2> Clarifying on averaged Summed Amplitude (avSA) : </h2>" << std::endl;
8321   htmlFile << "<h3> Summed Amplitudes (SA) are averaged over all events of each LS: avSA_LS = SUM (SA_eventsInLS) / "
8322               "N_eventsInLS ,</h3>"
8323            << std::endl;
8324   htmlFile << "<h3> where SA = SUM(A_i) ,and means that Amplitude is summed over all sub-detector channels, </h3>"
8325            << std::endl;
8326   htmlFile << "<h3> where A_i = SUM(A_depth) denotes channel amplitude summed over depths;  </h3>" << std::endl;
8327   //  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;
8328   htmlFile << "  <td><a "
8329               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8330               "HcalRemoteMonitoring/CMT/SAwriteup.html\"> see more details for SummedAmplitudes</a></td>"
8331            << std::endl;
8332   htmlFile << "<h2> Apply cuts on A_i to take into account channels with or/and without a'la Signal: </h2>"
8333            << std::endl;
8334   htmlFile << " <img src=\"ChannelDepthsummedAmplitudes.png\" />" << std::endl;
8335   htmlFile << "<br>" << std::endl;
8336   htmlFile << "<br>" << std::endl;
8337   htmlFile << "<a name=\"SAhigh\"></a>\n";
8338   htmlFile << "<h1> 1.  for channels with signal </h1>" << std::endl;
8339   htmlFile << "<br>" << std::endl;
8340   htmlFile << "<h2> for HB: A_i> 80; </h2>" << std::endl;
8341   htmlFile << " <img src=\"SummedAmplitudesSignal_HB.png\" />" << std::endl;
8342   htmlFile << "<br>" << std::endl;
8343   htmlFile << "<h2> for HE: A_i> 200;</h2>" << std::endl;
8344   htmlFile << " <img src=\"SummedAmplitudesSignal_HE.png\" />" << std::endl;
8345   htmlFile << "<br>" << std::endl;
8346   htmlFile << "<h2> for HO: A_i> 1200;</h2>" << std::endl;
8347   htmlFile << " <img src=\"SummedAmplitudesSignal_HO.png\" />" << std::endl;
8348   htmlFile << "<br>" << std::endl;
8349   htmlFile << "<h2> for HF: A_i> 600;</h2>" << std::endl;
8350   htmlFile << " <img src=\"SummedAmplitudesSignal_HF.png\" />" << std::endl;
8351   htmlFile << "<br>" << std::endl;
8352   htmlFile << "<a href=\"#Top\">to top</a><br>\n";
8353 
8354   htmlFile << "<a name=\"SAlow\"></a>\n";
8355   htmlFile << "<h1> 2.  for channels w/o signal </h1>" << std::endl;
8356   htmlFile << "<br>" << std::endl;
8357   htmlFile << "<h2> for HB: A_i< 80;</h2>" << std::endl;
8358   htmlFile << " <img src=\"NoSignalSummedAmplitudes_HB.png\" />" << std::endl;
8359   htmlFile << "<br>" << std::endl;
8360   htmlFile << "<h2> for HE:  A_i< 200;</h2>" << std::endl;
8361   htmlFile << " <img src=\"NoSignalSummedAmplitudes_HE.png\" />" << std::endl;
8362   htmlFile << "<br>" << std::endl;
8363   htmlFile << "<h2> for HO: A_i< 1200;</h2>" << std::endl;
8364   htmlFile << " <img src=\"NoSignalSummedAmplitudes_HO.png\" />" << std::endl;
8365   htmlFile << "<br>" << std::endl;
8366   htmlFile << "<h2> for HF: A_i< 600;</h2>" << std::endl;
8367   htmlFile << " <img src=\"NoSignalSummedAmplitudes_HF.png\" />" << std::endl;
8368   htmlFile << "<br>" << std::endl;
8369   htmlFile << "<a href=\"#Top\">to top</a><br>\n";
8370 
8371   htmlFile << "<br>" << std::endl;
8372   htmlFile << "<br>" << std::endl;
8373   htmlFile << "<a name=\"SAmax\"></a>\n";
8374   htmlFile << "<h1> 3. four plots: ---1--->  max SA ---2---> max Occupancy ---3--->  SA ---4---> Occupancy over all "
8375               "events of LS </h1>"
8376            << std::endl;
8377   htmlFile << "<br>" << std::endl;
8378 
8379   htmlFile << "<h2> for HB: maxSA vs LS, masOccupancy vs LS, SA, Occupancy </h2>" << std::endl;
8380   htmlFile << " <img src=\"MaxxSummedAmplitudes_HB.png\" />" << std::endl;
8381   htmlFile << "<h2>"
8382               " ......(forCut:SAmax>60000) N= "
8383            << countamplmaxHB << " ...... (forCut:OCCUPmax>2000) N= " << countoccumaxHB << " </h2>" << std::endl;
8384   htmlFile << "<h2>"
8385               " ......(forCut:SA>60000) N= "
8386            << countamplHB << " ...... (forCut:OCCUP>2000) N= " << countoccuHB << " </h2>" << std::endl;
8387   htmlFile << "<br>" << std::endl;
8388   htmlFile << "<h3> ONLY for HB (cross-check): channel Amplitudes for events in the Tail (averaged): </h3>"
8389            << std::endl;
8390   htmlFile << " <img src=\"AtaildepthHB.png\" />" << std::endl;
8391   htmlFile << "<br>" << std::endl;
8392 
8393   htmlFile << "<h2> for HE: maxSA vs LS, masOccupancy vs LS, SA, Occupancy </h2>" << std::endl;
8394   htmlFile << " <img src=\"MaxxSummedAmplitudes_HE.png\" />" << std::endl;
8395   htmlFile << "<h2>"
8396               " ......(forCut:SAmax>60000) N= "
8397            << countamplmaxHE << " ...... (forCut:OCCUPmax>1200) N= " << countoccumaxHE << " </h2>" << std::endl;
8398   htmlFile << "<h2>"
8399               " ......(forCut:SA>60000) N= "
8400            << countamplHE << " ...... (forCut:OCCUP>1200) N= " << countoccuHE << " </h2>" << std::endl;
8401   htmlFile << "<br>" << std::endl;
8402 
8403   htmlFile << "<h2> for HO: maxSA vs LS, masOccupancy vs LS, SA, Occupancy </h2>" << std::endl;
8404   htmlFile << " <img src=\"MaxxSummedAmplitudes_HO.png\" />" << std::endl;
8405   htmlFile << "<h2>"
8406               " ......(forCut:SAmax>150000) N= "
8407            << countamplmaxHO << " ...... (forCut:OCCUPmax>2000) N= " << countoccumaxHO << " </h2>" << std::endl;
8408   htmlFile << "<h2>"
8409               " ......(forCut:SA>150000) N= "
8410            << countamplHO << " ...... (forCut:OCCUP>2000) N= " << countoccuHO << " </h2>" << std::endl;
8411   htmlFile << "<br>" << std::endl;
8412 
8413   htmlFile << "<h2> for HF: maxSA vs LS, masOccupancy vs LS, SA, Occupancy </h2>" << std::endl;
8414   htmlFile << " <img src=\"MaxxSummedAmplitudes_HF.png\" />" << std::endl;
8415   htmlFile << "<h2>"
8416               " ......(forCut:SAmax>22000) N= "
8417            << countamplmaxHF << " ...... (forCut:OCCUPmax>860) N= " << countoccumaxHF << " </h2>" << std::endl;
8418   htmlFile << "<h2>"
8419               " ......(forCut:SA>22000) N= "
8420            << countamplHF << " ...... (forCut:OCCUP>860) N= " << countoccuHF << " </h2>" << std::endl;
8421   htmlFile << "<br>" << std::endl;
8422   htmlFile << "<h2> Occupancy HF (ONLY) vs LS </h2>" << std::endl;
8423   htmlFile << " <img src=\"sumOccupancyHF.png\" />" << std::endl;
8424   htmlFile << "<br>" << std::endl;
8425   htmlFile << "<a href=\"#Top\">to top</a><br>\n";
8426 
8427   htmlFile << "<a name=\"FullTable\"></a>\n";
8428   htmlFile << "<h2> 4.Lumisection Status:  </h2>" << std::endl;
8429   htmlFile << "<h3> Legends: HBdepth1 red boxes correspond LSs selected with cut: <td class=\"s6\" align=\"center\">"
8430            << Cut0[1][1][1] << std::endl;
8431   htmlFile << "<h3> Legends: HEdepth1 red boxes correspond LSs selected with cut: <td class=\"s6\" align=\"center\">"
8432            << Cut0[1][2][1] << std::endl;
8433   htmlFile << "<h3> Legends: HOdepth4 red boxes correspond LSs selected with cut: <td class=\"s6\" align=\"center\">"
8434            << Cut0[1][3][4] << std::endl;
8435   htmlFile << "<h3> Legends: HFdepth1 red boxes correspond LSs selected with cut: <td class=\"s6\" align=\"center\">"
8436            << Cut0[1][4][1] << std::endl;
8437   htmlFile << "<br>" << std::endl;
8438   // SummedAmplitudeHisto[i]   SummedAmplitudeOccupancyHisto[i]      NoSignalSummedAmplitudeHisto[i]      NoSignalSummedAmplitudeOccupancyHisto[i]; i=0-3;(HF:i=3)
8439   htmlFile << "<br>" << std::endl;
8440   htmlFile << "<table>" << std::endl;
8441   htmlFile << "<tr>";
8442   htmlFile << "<td class=\"s4\" align=\"center\">LS</td>" << std::endl;
8443   //              htmlFile << "<td class=\"s1\" align=\"center\">LS</td>"  << std::endl;
8444   htmlFile << "<td class=\"s1\" align=\"center\"> Num.of ev.</td>" << std::endl;
8445 
8446   //       for (int k=k_min[sub];k<=k_max[sub]; k++) htmlFile << "<td class=\"s1\" align=\"center\">< A > Depth "<< k <<" </td>"  << std::endl;
8447   //       for (int sub=1;sub<=4;sub++) htmlFile << "<td class=\"s1\" align=\"center\">< A > Depth1, sub "<< sub <<" </td>"  << std::endl;
8448 
8449   htmlFile << "<td class=\"s1\" align=\"center\">< A >HB Depth1</td>" << std::endl;
8450   htmlFile << "<td class=\"s1\" align=\"center\">< A >HE Depth1</td>" << std::endl;
8451   htmlFile << "<td class=\"s1\" align=\"center\">< A >HO Depth4</td>" << std::endl;
8452   htmlFile << "<td class=\"s1\" align=\"center\">< A >HF Depth1</td>" << std::endl;
8453 
8454   htmlFile << "<td class=\"s1\" align=\"center\">< SA >HB (Signal) </td>" << std::endl;
8455   htmlFile << "<td class=\"s1\" align=\"center\">< Occup. > HB (Signal) </td>" << std::endl;
8456   htmlFile << "<td class=\"s1\" align=\"center\">< SA >HF (Signal) </td>" << std::endl;
8457   htmlFile << "<td class=\"s1\" align=\"center\">< Occup. > HF (Signal) </td>" << std::endl;
8458 
8459   htmlFile << "<td class=\"s1\" align=\"center\">< SA >HB (NoSignal) </td>" << std::endl;
8460   htmlFile << "<td class=\"s1\" align=\"center\">< Occup. > HB (NoSignal) </td>" << std::endl;
8461   htmlFile << "<td class=\"s1\" align=\"center\">< SA >HF (NoSignal) </td>" << std::endl;
8462   htmlFile << "<td class=\"s1\" align=\"center\">< Occup. > HF (NoSignal) </td>" << std::endl;
8463 
8464   htmlFile << "<td class=\"s1\" align=\"center\"> maxSA HB  </td>" << std::endl;
8465   htmlFile << "<td class=\"s1\" align=\"center\"> maxOccup. HB </td>" << std::endl;
8466   htmlFile << "<td class=\"s1\" align=\"center\"> maxSA HF  </td>" << std::endl;
8467   htmlFile << "<td class=\"s1\" align=\"center\"> maxOccup. HF </td>" << std::endl;
8468 
8469   htmlFile << "</tr>" << std::endl;
8470 
8471   ind = 0;
8472   for (int i = 1; i <= MaxLum; i++) {
8473     if ((ind % 2) == 1)
8474       raw_class = "<td class=\"s2\" align=\"center\">";
8475     else
8476       raw_class = "<td class=\"s3\" align=\"center\">";
8477     htmlFile << "<tr>" << std::endl;
8478 
8479     htmlFile << "<td class=\"s4\" align=\"center\">" << i << "</td>" << std::endl;
8480 
8481     //                  htmlFile << raw_class<< LumLum->GetBinContent(i)<<"</td>"<< std::endl;
8482     htmlFile << raw_class << LumiEv->GetBinContent(i) << "</td>" << std::endl;
8483 
8484     // (test==1)  <Amplitude>
8485     int test = 1;
8486     //       for (int k=k_min[sub];k<=k_max[sub]; k++) {
8487     for (int sub = 1; sub <= 4; sub++) {
8488       for (int k = k_min[sub]; k <= k_min[sub]; k++) {
8489         if (HistNumBadChanDepth[test][sub][k]->GetBinContent(i) > Cut0[test][sub][k])
8490           htmlFile << "<td class=\"s6\" align=\"center\">" << HistNumBadChanDepth[test][sub][k]->GetBinContent(i)
8491                    << "</td>" << std::endl;
8492 
8493         else
8494           htmlFile << raw_class << HistNumBadChanDepth[test][sub][k]->GetBinContent(i) << "</td>" << std::endl;
8495       }
8496     }
8497     if (SummedAmplitudeHisto[0]) {
8498       htmlFile << raw_class << SummedAmplitudeHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8499       htmlFile << raw_class << SummedAmplitudeOccupancyHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8500       htmlFile << raw_class << SummedAmplitudeHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8501       htmlFile << raw_class << SummedAmplitudeOccupancyHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8502 
8503       htmlFile << raw_class << NoSignalSummedAmplitudeHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8504       htmlFile << raw_class << NoSignalSummedAmplitudeOccupancyHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8505       htmlFile << raw_class << NoSignalSummedAmplitudeHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8506       htmlFile << raw_class << NoSignalSummedAmplitudeOccupancyHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8507 
8508       htmlFile << raw_class << MaxxSummedAmplitudeHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8509       htmlFile << raw_class << MaxxSummedAmplitudeOccupancyHisto[0]->GetBinContent(i) << "</td>" << std::endl;
8510       htmlFile << raw_class << MaxxSummedAmplitudeHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8511       htmlFile << raw_class << MaxxSummedAmplitudeOccupancyHisto[3]->GetBinContent(i) << "</td>" << std::endl;
8512     }
8513     htmlFile << "</tr>" << std::endl;
8514     ind += 1;
8515   }
8516   htmlFile << "</table>" << std::endl;
8517   htmlFile << "<a href=\"#Top\">to top</a><br>\n";
8518 
8519   htmlFile << "<br>" << std::endl;
8520   htmlFile << "</body> " << std::endl;
8521   htmlFile << "</html> " << std::endl;
8522   htmlFile.close();
8523 
8524   //====================================================================== // Creating description of html-files
8525 
8526   /*    
8527     //======================================================================
8528   // Creating description HELP.html file: 
8529   htmlFile.open("HELP.html");  
8530   htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">"<< std::endl;
8531   htmlFile << "<head>"<< std::endl;
8532   htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>"<< std::endl;
8533   htmlFile << "<title> Certification Monitoring Tool </title>"<< std::endl;
8534   htmlFile << "<style type=\"text/css\">"<< std::endl;
8535   htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"<< std::endl;
8536   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }"<< std::endl;
8537   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; text-align: center;}"<< std::endl;
8538   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }"<< std::endl;
8539   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }"<< std::endl;
8540   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }"<< std::endl;
8541   htmlFile << "</style>"<< std::endl;
8542   htmlFile << "<body>"<< std::endl;
8543   htmlFile << "<h1>  Description of Remote Monitoring Tool criteria for bad channel selection</h1>"<< std::endl;
8544   htmlFile << "<br>"<< std::endl;
8545   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;
8546   htmlFile << "<br>"<< std::endl;
8547   htmlFile << "<h3> - Amplitude is full amplitude collected over all time slices </h3> "<< std::endl;
8548   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;
8549   htmlFile << "<br>"<< std::endl;
8550   htmlFile << "<h3> - Width of shape distribution. Width is defined as square root from dispersion. </h3> "<< std::endl;
8551   htmlFile << "<br>"<< std::endl;
8552   htmlFile << "<h3> - Mean TS time slice position of adc signal. </h3> "<< std::endl;
8553   htmlFile << "<br>"<< std::endl;
8554   htmlFile << "<h3> - TS number of maximum signal </h3> "<< std::endl;
8555   htmlFile << "<br>"<< std::endl; 
8556   htmlFile << "<h3>  For more details see https://twiki.cern.ch/twiki/bin/viewauth/CMS/HcalRemoteCertificationMonitoring </h3> "<< std::endl;   
8557   htmlFile << "</body> " << std::endl;
8558   htmlFile << "</html> " << std::endl; 
8559   htmlFile.close();
8560 */
8561   //======================================================================
8562   // Creating description CMTresults.html file:
8563   htmlFile.open("CMTresults.html");
8564   htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
8565   htmlFile << "<head>" << std::endl;
8566   htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
8567   htmlFile << "<title> Certification Monitoring Tool </title>" << std::endl;
8568   htmlFile << "<style type=\"text/css\">" << std::endl;
8569   htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
8570            << std::endl;
8571   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
8572   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
8573               "text-align: center;}"
8574            << std::endl;
8575   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
8576   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
8577   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
8578   htmlFile << "</style>" << std::endl;
8579   htmlFile << "<body>" << std::endl;
8580   htmlFile << "<h1>  LS-certification (recommendation) from analysis of CMT-dependencies of THIS run </h1>"
8581            << std::endl;
8582   htmlFile << "<br>" << std::endl;
8583   htmlFile << "<br>" << std::endl;
8584   htmlFile << "<h2> - List of suspicious LSs:  </h2> " << std::endl;
8585   htmlFile << "<br>" << std::endl;
8586   htmlFile << "<h3> to be added </h3> " << std::endl;
8587   htmlFile << "<br>" << std::endl;
8588   htmlFile << "<br>" << std::endl;
8589   htmlFile << "<br>" << std::endl;
8590   htmlFile << "<h2> - Comments: </h2> " << std::endl;
8591   htmlFile << "<br>" << std::endl;
8592   htmlFile << "<h3> to be added </h3> " << std::endl;
8593   htmlFile << "<br>" << std::endl;
8594   htmlFile << "<br>" << std::endl;
8595   htmlFile << "<br>" << std::endl;
8596   htmlFile << "</body> " << std::endl;
8597   htmlFile << "</html> " << std::endl;
8598   htmlFile.close();
8599 
8600   //======================================================================
8601   // Creating main html file:
8602 
8603   htmlFile.open("LumiList.html");
8604   htmlFile << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
8605   htmlFile << "<head>" << std::endl;
8606   htmlFile << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>" << std::endl;
8607   htmlFile << "<title> Certification Monitoring Tool </title>" << std::endl;
8608   htmlFile << "<style type=\"text/css\">" << std::endl;
8609   htmlFile << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"
8610            << std::endl;
8611   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; }" << std::endl;
8612   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; "
8613               "text-align: center;}"
8614            << std::endl;
8615   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }" << std::endl;
8616   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }" << std::endl;
8617   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }" << std::endl;
8618   htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: #00FF00; }" << std::endl;
8619   htmlFile << "   td.s6 { font-family: arial, arial ce, helvetica; background-color: #FF0000; }" << std::endl;
8620 
8621   htmlFile << "</style>" << std::endl;
8622   htmlFile << "<body>" << std::endl;
8623 
8624   htmlFile << "<h1> Certification Monitoring Tool, GLOBAL RUN = " << runnumber << ". </h1>" << std::endl;
8625   htmlFile << "<br>" << std::endl;
8626   htmlFile << "  <td><a "
8627               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8628               "HcalRemoteMonitoring/CMT/GLOBAL_"
8629            << runnumber << "/CMTresults.html\">  CMT-analysis RESULTS (for this run) </a></td>" << std::endl;
8630   htmlFile << "<br>" << std::endl;
8631   htmlFile << "<br>" << std::endl;
8632 
8633   //  htmlFile << "<h2> 1. General information </h2>"<< std::endl;
8634   htmlFile << "<h2> 1. General information     (Full number of LS = " << MaxLum << " ). </h2>" << std::endl;
8635   htmlFile << " <img src=\"LumiEvent.png\" />" << std::endl;
8636   htmlFile << "<br>" << std::endl;
8637 
8638   htmlFile << "<h2> 2. HCAL status for different criteria </h2>" << std::endl;
8639   //  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;
8640   htmlFile << "  <td><a "
8641               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8642               "HcalRemoteMonitoring/CMT/HELP.html\"> Description of criteria for bad channel selection</a></td>"
8643            << std::endl;
8644   htmlFile << "<br>" << std::endl;
8645   htmlFile << "<table width=\"600\">" << std::endl;
8646   htmlFile << "<tr>" << std::endl;
8647   htmlFile << "  <td><a "
8648               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8649               "HcalRemoteMonitoring/CMT/GLOBAL_"
8650            << runnumber << "/CapID_GL.html\">Cap ID errors</a></td>" << std::endl;
8651   // AZ 18.03.2018
8652   //    htmlFile << "  <td><a href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/HcalRemoteMonitoring/CMT/GLOBAL_"<<runnumber<<"/ADCampl_GL.html\">Amplitude</a></td>"<< std::endl;
8653   htmlFile << "  <td><a  href=\"ADCampl_GL.html\">Amplitude</a></td>" << std::endl;
8654   htmlFile << "  <td><a "
8655               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8656               "HcalRemoteMonitoring/CMT/GLOBAL_"
8657            << runnumber << "/Width_GL.html\">Width</a></td>" << std::endl;
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 << "/Ratio_GL.html\">Ratio</a></td>" << std::endl;
8662   htmlFile << "  <td><a "
8663               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8664               "HcalRemoteMonitoring/CMT/GLOBAL_"
8665            << runnumber << "/Tmean_GL.html\">TS mean</a></td>" << std::endl;
8666   htmlFile << "  <td><a "
8667               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8668               "HcalRemoteMonitoring/CMT/GLOBAL_"
8669            << runnumber << "/Tmax_GL.html\">TS max</a></td>" << std::endl;
8670 
8671   htmlFile << "  <td><a "
8672               "href=\"https://cms-cpt-software.web.cern.ch/cms-cpt-software/General/Validation/SVSuite/"
8673               "HcalRemoteMonitoring/CMT/GLOBAL_"
8674            << runnumber << "/SummedAmplitudes_GL.html\">SummedAmplitudes</a></td>" << std::endl;
8675 
8676   htmlFile << "</tr>" << std::endl;
8677   htmlFile << "</table>" << std::endl;
8678   htmlFile << "<br>" << std::endl;
8679   htmlFile << "</body> " << std::endl;
8680   htmlFile << "</html> " << std::endl;
8681   htmlFile.close();
8682   //======================================================================
8683 
8684   //======================================================================
8685   // Close and delete all possible things:
8686   hfile->Close();
8687   //  hfile->Delete();
8688   //  Exit Root
8689   gSystem->Exit(0);
8690   //======================================================================
8691 }
8692 
8693 // ------------------------------------------------------------
8694 
8695 int copyContents(TH1F **hDest, TString hname, TString htitle, const TH1F *hSrc, int lastBin) {
8696   if (lastBin > hSrc->GetNbinsX()) {
8697     std::cout << "copyContents from " << hSrc->GetName() << ": histo has " << hSrc->GetNbinsX()
8698               << " bins, when lastBin=" << lastBin << " was requested\n";
8699     return 0;
8700   }
8701 
8702   (*hDest) = new TH1F(hname, htitle, lastBin, 0, lastBin);
8703   (*hDest)->SetDirectory(0);
8704   (*hDest)->SetStats(0);
8705 
8706   for (int ibin = 1; ibin <= lastBin; ibin++) {
8707     (*hDest)->SetBinContent(ibin, hSrc->GetBinContent(ibin));
8708     (*hDest)->SetBinError(ibin, hSrc->GetBinError(ibin));
8709   }
8710   return 1;
8711 }
8712 
8713 // ------------------------------------------------------------