Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <iostream>
0002 #include <fstream>
0003 #include "TH1.h"
0004 #include "TH2.h"
0005 #include "TH1F.h"
0006 #include "TH2F.h"
0007 #include "TCanvas.h"
0008 #include "TROOT.h"
0009 #include <TMath.h>
0010 #include "TStyle.h"
0011 #include "TSystem.h"
0012 #include "TLegend.h"
0013 #include "TText.h"
0014 #include "TAxis.h"
0015 #include "TFile.h"
0016 #include "TLine.h"
0017 #include "TGraph.h"
0018 #include <TPaveText.h>
0019 #include <TPostScript.h>
0020 #include <TClass.h>
0021 #include <TLatex.h>
0022 #include <TFrame.h>
0023 #include <TPad.h>
0024 #include <TGaxis.h>
0025 
0026 #include "TGraphErrors.h"
0027 #include "TF1.h"
0028 #include "TArrow.h"
0029 
0030 //
0031 using namespace std;
0032 //
0033 //
0034 int main(int argc, char* argv[]) {
0035   cout << "********************************************************************* START job " << endl;
0036   //______________________________________________________________________________________________________________________________
0037   //TCanvas *c1;
0038   TGraph* gr1;
0039   TGraph* gr2;
0040   TGraph* gr3;
0041   TGraph* gr4;
0042   TGraph* gr5;
0043   TGraph* gr6;
0044   TGraph* gr7;
0045   TGraph* gr8;
0046   TGraph* gr9;
0047   TGraphErrors* ge1;
0048   TGraphErrors* ge2;
0049   TGraphErrors* ge3;
0050   TGraphErrors* ge4;
0051   TGraphErrors* ge5;
0052   TGraphErrors* ge6;
0053   TGraphErrors* ge7;
0054   TGraphErrors* ge8;
0055   TGraphErrors* ge9;
0056 
0057   //
0058   const Int_t NMethods = 14;       // total number of Methods (all-together 37 methods)
0059   const Int_t NMethodsStart = 0;   // since which method to start ( min=  0)
0060   const Int_t NMethodsToUse = 13;  // choose Number of methods to use ( max= 36)
0061                                    //
0062   TString MethodName[NMethods] = {"PLOT0",
0063                                   "PLOT1",
0064                                   "PLOT2",
0065                                   "PLOT3",
0066                                   "PLOT4",
0067                                   "PLOT5",
0068                                   "PLOT6",
0069                                   "PLOT7",
0070                                   "PLOT8",
0071                                   "PLOT9",
0072                                   "PLOT10",
0073                                   "PLOT11",
0074                                   "PLOT12",
0075                                   "PLOT13"};
0076   //______________________________________________________________________________________________________________________________
0077   const Int_t NMAXM = 70;  //
0078 
0079   cout << "********************************************************************* NMAXM =  " << NMAXM << endl;
0080 
0081   TString LEDrunsM[NMAXM] = {// reference first run 315812 has Local run key: LED - 2000 events, masks: HCAL_Laser
0082                              "315812", "315984", "316826", "317116", "317193", "317268", "317271", "317273", "317363",
0083                              "317444", "317606", "317607", "317609", "317610", "317611", "317612", "317613", "317617",
0084                              "317785", "318758", "319198", "319401", "319517", "319519", "319520", "319564", "319612",
0085                              "319734", "319771", "319774", "319857", "319969", "320117", "320158", "320203", "320205",
0086                              "320348", "320579", "320873", "320892", "320952", "321019", "321036", "321187", "321339",
0087                              "321359", "321371", "321447", "321514", "322781", "322782", "323314", "323502", "323579",
0088                              "323613", "323742", "324030", "324032", "324138", "324225", "324296", "324919", "325141",
0089                              "325787", "326234", "326875", "327288", "327438", "327552", "327579"
0090 
0091   };
0092   cout << "********************************************************************* first massives defined " << endl;
0093   Float_t X0M[NMAXM] = {
0094 
0095       0.,   2.,   17.,  22.,  23.,  24.,  24.,  24.,  27.,  29.,  32.,  32.,  32.,  32.,  32.,  32.,  32.,  32.,
0096       38.,  51.,  58.,  63.,  65.,  65.,  65.,  66.,  68.,  70.,  71.,  71.,  72.,  74.,  77.,  78.,  79.,  79.,
0097       80.,  85.,  90.,  91.,  92.,  93.,  93.,  98.,  101., 101., 101., 104., 106., 129., 129., 138., 141., 142.,
0098       143., 146., 150., 150., 151., 153., 155., 165., 169., 179., 183., 195., 203., 205., 208., 209.,
0099   };  // days of year    time points (abscissa) !!!
0100   cout << "********************************************************************* both massives are defined " << endl;
0101   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0102   //define yearcase:
0103   //         ____________________________________________________________________________      THIS line below is MAIN to make a yearcase selection !!!!!!!!!!!!!!!!!!!!!!!!!!
0104   const Int_t yearcase = 0;
0105   //
0106   cout << "************************************** yearcase = " << yearcase << endl;
0107   // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0108   // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0109   // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0110   // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0111   //    Int_t verbosity = 2;//
0112   //    Int_t verbosity = 3;//
0113   //    Int_t verbosity = 4;//   to clarify # channels in HOP17
0114   Int_t verbosity = 0;  //
0115   // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0116 
0117   //  const Int_t flagHOP17selection = 2;// -> ALL channels w/o bad
0118   //  const Int_t flagHOP17selection = 1;// ==1 HOP17;
0119   const Int_t flagHOP17selection = 0;  //  -> ALL channels
0120 
0121   cout << "************************************** flagHOP17selection = " << flagHOP17selection << endl;
0122   // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0123   //______________________________________________________________________________
0124 
0125   //______________________________________________________________________________
0126   //______________________________________________________________________________
0127   //
0128   //---=[ SetCanvasDef           ]=----------------
0129   // Create a new canvas.
0130   //TCanvas  *c1 = new TCanvas("c1","GSM",10,10,900,700);
0131 
0132   //TCanvas  *c1 = new TCanvas("c1","GSM",20,50,920,850);
0133   TCanvas* c1 = new TCanvas("c1", "GSM", 10, 10, 1010, 1010);
0134 
0135   //TCanvas  *c1 = new TCanvas("c1","GSM",200,10,700,900);
0136   //TCanvas  *c1 = new TCanvas("c1","Hcal4test",200,10,700,900);
0137 
0138   c1->Range(0, 0, 25, 18);
0139   //c1->SetFillColor(40);
0140   c1->SetFillColor(0);
0141   c1->Clear();
0142 
0143   TLatex* t = new TLatex();
0144   t->SetTextFont(32);
0145   //t->SetTextColor(4);
0146   t->SetTextSize(0.03);
0147   t->SetTextAlign(12);
0148   //______________________________________________________________________________
0149   t->DrawLatex(
0150       0.9, 15.5, "Time dependence of full Amplitude averaged over events of each LED run for some random HO channels");
0151 
0152   //-----------------------------------------------------------------------------------------------------
0153   //
0154   //              x1   y1     x2     y2
0155   //    pad1->DrawFrame(1,   0.8,  370,   1.2);// all
0156 
0157   //
0158   //      Float_t x1=0.00; Float_t x2=170.00;
0159   //       Float_t x1=0.00; Float_t x2=850.00;
0160 
0161   //          Float_t x1=0.00; Float_t x2=45.00;
0162   Float_t x1 = 0.00;
0163   Float_t x2 = 215.0;
0164 
0165   // y(ordinate) for All Days
0166   //  Float_t y1=0.985; Float_t y2=  1.015;
0167   Float_t y1 = 0.9;
0168   Float_t y2 = 1.1;
0169 
0170   //
0171   // x(abscissa) for Days
0172   Float_t RrangeMIN = y1;
0173   Float_t RrangeMAX = y2;
0174 
0175   //
0176   Float_t xx1 = 0.35;
0177   Float_t xx2 = 0.55;
0178   Float_t yy1 = 0.76;
0179   Float_t yy2 = 0.88;
0180   //
0181   cout << "************************************** RrangeMIN = " << RrangeMIN << "  RrangeMAX = " << RrangeMAX << endl;
0182 
0183   //-----------------------------------------------------------------------------------------------------
0184   //-----------------------------------------------------------------------------------------------------
0185   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0186   const Int_t NDEP = 5;
0187   const Int_t NETA0 = 83;
0188   const Int_t NPHI0 = 73;
0189   //  const Int_t NDEP =5;const Int_t NETA0=83;const Int_t NPHI0=73;
0190   //
0191   Double_t mapRATIO[NDEP][NETA0][NPHI0];
0192   Double_t mapRATIOD2[NETA0][NPHI0];
0193   Int_t mapRATIOD20[NETA0][NPHI0];
0194 
0195   //Double_t normalization[NDEP][NETA0][NPHI0];
0196   Double_t normalization[NETA0][NPHI0];
0197   cout << "************************************** NDEP = " << NDEP << "  NETA0 = " << NETA0 << "  NPHI0 = " << NPHI0
0198        << endl;
0199 
0200   // define max size of massives (to be just NMAXSIZE ):
0201   Int_t NMAXSIZE = NMAXM;
0202   Float_t X0[NMAXSIZE];
0203   TString LEDruns[NMAXSIZE];
0204   Double_t XX[NMAXSIZE];
0205   Double_t XXE[NMAXSIZE];
0206   Double_t XXX[NMAXSIZE];
0207   Double_t XXXE[NMAXSIZE];
0208   Int_t indWAS[NMAXSIZE];
0209 
0210   Double_t YY[NMAXSIZE];
0211   Double_t YYE[NMAXSIZE];
0212   cout << "************************************** NMAXSIZE = " << NMAXSIZE << " NMAXM  = " << NMAXM << endl;
0213   //----------------------------------------------------------------------
0214 
0215   Double_t GSMRATIOD2[NMAXSIZE][NETA0][NPHI0];
0216 
0217   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0218   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0219   //////////////////////////////////////////////////////
0220   // define where to run inside massives above:
0221   //                                                                            yearcase=0
0222   Int_t NMINmM = 0;
0223   Int_t NMAXmM = NMAXSIZE - 1;
0224   Int_t NMAXaM = NMAXSIZE;
0225   if (yearcase == 1) {
0226     //                                           2016 only:                     yearcase=1
0227     NMINmM = 0;
0228     NMAXmM = 46;
0229     NMAXaM = 47;  // M
0230   } else if (yearcase == 2) {
0231     //                                           2017 only::                    yearcase=2
0232     NMINmM = 53;
0233     NMAXmM = 93;
0234     NMAXaM = 41;  // M
0235   } else if (yearcase == 3) {
0236     //                                           20167 only::                   yearcase=3
0237     NMINmM = 0;
0238     NMAXmM = 93;
0239     NMAXaM = 94;  // M
0240   } else if (yearcase == 4) {
0241     //                                           2018 only::                    yearcase=4
0242     NMINmM = 94;
0243     NMAXmM = -1;
0244     NMAXaM = -1;  // M
0245   } else if (yearcase == 5) {
0246     //                                           20168 only::                   yearcase=5
0247     NMINmM = 0;
0248     NMAXmM = -1;
0249     NMAXaM = -1;  // M
0250   }
0251 
0252   cout << "************************************** NMINmM = " << NMINmM << " NMAXmM  = " << NMAXmM
0253        << " NMAXaM  = " << NMAXaM << endl;
0254   if (NMINmM == -1 || NMAXmM == -1 || NMAXaM == -1)
0255     cout << " STOP  !!!!!!     NMINmM == -1 || NMAXmM == -1 || NMAXaM == -1 " << endl;
0256   ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0257   Int_t NMAX = 0;
0258   NMAX = NMAXaM;
0259   //      cout << "NMAX= " << NMAX << "NMINmM= " << NMINmM << "NMAXmM= " << NMAXmM <<endl;
0260   for (int jjj = NMINmM; jjj <= NMAXmM; jjj++) {
0261     LEDruns[jjj - NMINmM] = LEDrunsM[jjj];
0262     X0[jjj - NMINmM] = X0M[jjj];
0263     //  cout << "jjj= " << jjj << "     jjj-NMINmM= " << jjj-NMINmM << "     LEDrunsM[jjj]= " << LEDrunsM[jjj] << "     X0M[jjj]= " << X0M[jjj] <<endl;
0264   }
0265   //////////////////////////////////////////////////////
0266   //========================================================================================================================
0267   //---------------------------------------------------------------------------------------------------------------------
0268   //---------------------------------------------------------------------------------------------------------------------
0269   //      Int_t NP = 22; // for loop over time points(LED runs) NMAX is number of LED runs(time abscissa)
0270   Int_t NP = NMAX;  // for loop over time points(LED runs) NMAX is number of LED runs(time abscissa)
0271   cout << "******************* NP = " << NP << endl;
0272   //
0273   //---------------------------------------------------------------------------------------------------------------------  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0274   // take into account for future treatment only channels with <Aijk>_runevents within cutMinA to cutMaxA:
0275   //    Double_t cutMinA =400.; Double_t cutMaxA = 1200.;  // HPD HO only
0276 
0277   //      Double_t cutMinA =0.; Double_t cutMaxA = 999999999999.;
0278   //    Double_t cutMinA =50000.; Double_t cutMaxA = 150000.;
0279   Double_t cutMinA = 100.;
0280   Double_t cutMaxA = 5000.;
0281 
0282   //    Double_t cutMinA =9000.; Double_t cutMaxA = 40000.;
0283   //
0284   // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0285   //---------------------------------------------------------------------------------------------------------------------
0286   //------------------------------------ define DELTA (days) of current point wrt first point
0287   for (int kk1 = 0; kk1 < NP; kk1++) {
0288     XX[kk1] = X0[kk1];
0289     int k10 = 0;
0290     int z1 = X0[k10];
0291     XX[kk1] -= z1;
0292     if (verbosity == 2) {
0293       cout << "ORDINATE points:    kk1 =  " << kk1 << "  XX[kk1]= " << XX[kk1] << endl;
0294     }
0295 
0296     XXE[kk1] = 0.001 * XX[kk1];
0297   }  //XXE - errors at fit
0298   //-----------------------------------------------------------------------------------------------------
0299 
0300   //----------------------------------------------------------------------------------------------------
0301   //----------------------------------------------------------------------------------------------------
0302   ///////////////////////////////////////////////////////////////////////// initial nulling:
0303   for (int jjj = 0; jjj <= 82; jjj++) {
0304     for (int kkk = 0; kkk <= 72; kkk++) {
0305       mapRATIOD2[jjj][kkk] = 0.;
0306       mapRATIOD20[jjj][kkk] = 0.;
0307       normalization[jjj][kkk] = 0.;
0308 
0309       for (int k1 = 0; k1 < NP; k1++) {
0310         GSMRATIOD2[k1][jjj][kkk] = mapRATIOD2[jjj][kkk];
0311       }
0312 
0313       for (int iii = 0; iii < NDEP; iii++) {
0314         mapRATIO[iii][jjj][kkk] = 0.;
0315         //  normalization[iii][jjj][kkk] = 0.;
0316       }
0317 
0318     }  // for
0319   }    // for
0320 
0321   /////////////////////////////////////////////////////////////////////////
0322 
0323   //______________________________________________________________________________
0324   //     ls -latr /afs/cern.ch/cms/CAF/CMSALCA/ALCA_HCALCALIB/HCALMONITORING/RDMweb/histos/LED_* | less
0325 
0326   TString fname = "/afs/cern.ch/cms/CAF/CMSALCA/ALCA_HCALCALIB/HCALMONITORING/RDMweb/histos/LED_";
0327   //  TString fname = "/afs/cern.ch/cms/CAF/CMSALCA/ALCA_HCALCALIB/HCALMONITORING/RDMweb/histos/LASER_";
0328 
0329   // booking:
0330   TH1F* Seff1D = new TH1F("Seff1D", "", 1000, 10., 1010.);
0331   TH1F* Ceff1D = new TH1F("Ceff1D", "", 1500, 10., 8010.);
0332 
0333   TH2F* mapBADchannels = new TH2F("mapBADchannels", " ", 82, -41., 41., 72, 0., 72.);
0334   TH2F* mapBADchannels0 = new TH2F("mapBADchannels0", " ", 82, -41., 41., 72, 0., 72.);
0335 
0336   //TH2F* mapchannelsdepth1= new TH2F("mapchannelsdepth1"," ", 82, -41., 41., 72, 0., 72.);
0337   //TH2F* mapchannelsdepth2= new TH2F("mapchannelsdepth2"," ", 82, -41., 41., 72, 0., 72.);
0338   //  TH2F* mapchannelsdepth3= new TH2F("mapchannelsdepth3"," ", 82, -41., 41., 72, 0., 72.);
0339   TH2F* mapchannelsdepth4 = new TH2F("mapchannelsdepth4", " ", 82, -41., 41., 72, 0., 72.);
0340 
0341   TH1F* gainkoeff = new TH1F("gainkoeff", "", 100, y1, y2);
0342   TH1F* gainkoeff0 = new TH1F("gainkoeff0", "", 100, 0.9, 1.1);
0343   TH1F* gainkoeff9 = new TH1F("gainkoeff9", "", 100, 0.1, 1.9);
0344   TH1F* GOODruns = new TH1F("GOODruns", "", NP, 0., float(NP));
0345   TH1F* BADruns = new TH1F("BADruns", "", NP, 0., float(NP));
0346   TH1F* NotEmptyDepthes = new TH1F("NotEmptyDepthes", "", 56, 0., 56.);
0347 
0348   //////////////////////////////////////////////////////////////////////  initial variables
0349   Int_t kmm = 0;
0350   Int_t firstrun = 0;
0351   //
0352   cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! firstrun =  " << firstrun << " run = " << LEDruns[firstrun] << endl;
0353 
0354   //////////////////////////////////////////////////////////////////////////////////////////////  LOOP    ratio current
0355   //////////////////////////////////////////////////////////////////////////  LOOP    ratio current
0356   //////////////////////////////////////////////////////////////////////////  LOOP    ratio current
0357 
0358   /////////////////////////////////////////////////////////////////////////////////////////
0359   cout << "!!!!!!!!!!!!!!!!!!!!!! use root files from official RMT dir. " << endl;
0360   //  cout << "!!!!!!!!!!!!!!!!!!!!!! use root files from my  dir. " <<endl;
0361   /////////////////////////////////////////////////////////////////////////////////////////      START LOOP       START LOOP     START LOOP   START LOOP
0362 
0363   TH1F* Aeff1D = new TH1F("Aeff1D", "", 250, 0., 500000.);
0364   //  TH1F* Aeff1D = new TH1F("Aeff1D","", 200, 0.,2000000.);
0365   int ck1count = 0;
0366   for (int k1 = firstrun; k1 < NP; k1++) {
0367     //  for(int k1 = 0; k1<NP; k1++) {
0368     ck1count++;
0369     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0370     // my dir.
0371     //    TString epsName = "root/LEDtest" + LEDruns[k1] + ".root";
0372     //           TString epsName = "rootshunt1/LEDtest" + LEDruns[k1] + ".root";
0373 
0374     // RMT:
0375     TString epsName = fname + LEDruns[k1] + ".root";
0376 
0377     /////////////////////////////////////////////////////////////////////////////////////////
0378     //              cout << "!!!! read LED run with k1= " << k1   <<"  run:  " << LEDruns[k1] <<endl;
0379 
0380     TFile* hfile = new TFile(epsName, "READ");
0381     //            cout << "!!!! read LED run with k1= " << k1   <<"  run:  " << LEDruns[k1] <<endl;
0382     TH1F* Aeff1 = (TH1F*)hfile->Get("h_ADCAmpl_HO");
0383 
0384     int kx = Aeff1->GetXaxis()->GetNbins();
0385     //      cout  <<" run = " << LEDruns[k1]  <<" Nbins=kx= " << kx <<" k1= " << k1 <<endl;
0386     //      cout  <<"BEGINNING k1= " << k1 <<" kx= " << kx <<endl;
0387     int maxvalueA = -1;
0388     for (int jjj = 0; jjj < kx; jjj++) {
0389       if (double(Aeff1->GetBinContent(jjj)) > 0. && maxvalueA < jjj)
0390         maxvalueA = jjj;
0391       //    cout  <<" k1= " << k1 <<" jjj= " << jjj <<" content= " << Aeff1->GetBinContent(jjj) <<endl;
0392       Aeff1D->Fill(float(jjj), double(Aeff1->GetBinContent(jjj)));
0393     }  // for
0394     cout << " run = " << LEDruns[k1] << " k1= " << k1 << " max bin value= " << maxvalueA << " ck1count= " << ck1count
0395          << endl;
0396 
0397     //
0398     //
0399     // display last-run existing histoes:
0400     if (k1 == NP - 1) {
0401       c1->Clear();
0402       c1->Divide(1, 1);
0403       c1->cd(1);
0404       gPad->SetGridy();
0405       gPad->SetGridx();
0406       gPad->SetLogy();
0407       gStyle->SetOptStat(101110);
0408       Aeff1->SetMarkerStyle(20);
0409       Aeff1->SetMarkerSize(0.4);
0410       Aeff1->GetYaxis()->SetLabelSize(0.04);
0411       Aeff1->SetTitle("Last run & events & channels");
0412       Aeff1->SetXTitle("Aijk");
0413       Aeff1->SetYTitle("N");
0414       Aeff1->SetMarkerColor(4);
0415       Aeff1->SetLineColor(4);
0416       Aeff1->SetMinimum(0.8);
0417       Aeff1->Draw("PL");
0418       c1->Update();
0419       TString fdir = "testamt5gsmHO2018/";
0420       //    TString plotName = fdir + "Aijk.png";
0421       TString plotName = fdir + "Aijk-Run" + LEDruns[k1] + ".png";
0422       c1->SaveAs(plotName);
0423       cout << "****PLOT  AijkLastRun.png is drawn **** " << endl;
0424     }
0425     // display first runt existing histoes:
0426     //      if(k1== 0 ) {
0427     if (k1 == firstrun) {
0428       c1->Clear();
0429       c1->Divide(1, 1);
0430       c1->cd(1);
0431       gPad->SetGridy();
0432       gPad->SetGridx();
0433       //    gPad->SetLogy();
0434       gStyle->SetOptStat(101110);
0435       Aeff1->SetMarkerStyle(20);
0436       Aeff1->SetMarkerSize(0.4);
0437       Aeff1->GetYaxis()->SetLabelSize(0.04);
0438       Aeff1->SetTitle("First run & events & channels");
0439       Aeff1->SetXTitle("Aijk");
0440       Aeff1->SetYTitle("N");
0441       Aeff1->SetMarkerColor(4);
0442       Aeff1->SetLineColor(4);
0443       Aeff1->SetMinimum(0.8);
0444       Aeff1->Draw("PL");
0445       c1->Update();
0446       TString fdir = "testamt5gsmHO2018/";
0447       TString plotName = fdir + "AijkFirstRun.png";
0448       c1->SaveAs(plotName);
0449       cout << "****PLOT  AijkFirstRun.png is drawn **** " << endl;
0450     }
0451     // 000000000000000000000000000000000000000000000000000000000000000000000000
0452     //      TH2F *twod1= (TH2F*)hfile->Get("h_mapDepth1ADCAmpl");
0453     //      TH2F *twod2= (TH2F*)hfile->Get("h_mapDepth2ADCAmpl");
0454     //      TH2F *twod3= (TH2F*)hfile->Get("h_mapDepth3ADCAmpl");
0455     // 111111111111111111111111111111111111111111111111111111111111111111111111
0456     // h_mapDepth1ADCAmpl12 means ADCcounts(massive) within -1 max +1 +2
0457 
0458     /*
0459     TH2F *twod1= (TH2F*)hfile->Get("h_mapDepth1ADCAmpl12_HO");
0460     TH2F *twod2= (TH2F*)hfile->Get("h_mapDepth2ADCAmpl12_HO");
0461     TH2F *twod3= (TH2F*)hfile->Get("h_mapDepth3ADCAmpl12_HO");
0462 */
0463     // HOP17 of 2017:
0464     //      TH2F *twod1= (TH2F*)hfile->Get("h_mapDepth1ADCAmpl12SiPM_HO");
0465     //      TH2F *twod2= (TH2F*)hfile->Get("h_mapDepth2ADCAmpl12SiPM_HO");
0466     //      TH2F *twod3= (TH2F*)hfile->Get("h_mapDepth3ADCAmpl12SiPM_HO");
0467     // all:
0468 
0469     //    TH2F *twod1= (TH2F*)hfile->Get("h_mapDepth1ADCAmpl12_HO");
0470     //    TH2F *twod2= (TH2F*)hfile->Get("h_mapDepth2ADCAmpl12_HO");
0471     //      TH2F *twod3= (TH2F*)hfile->Get("h_mapDepth3ADCAmpl12_HO");
0472 
0473     TH2F* twod4 = (TH2F*)hfile->Get("h_mapDepth4ADCAmpl12_HO");
0474 
0475     // all TS bins:
0476     //      TH2F *twod1= (TH2F*)hfile->Get("h_mapDepth1ADCAmpl_HO");
0477     //      TH2F *twod2= (TH2F*)hfile->Get("h_mapDepth2ADCAmpl_HO");
0478     //      TH2F *twod3= (TH2F*)hfile->Get("h_mapDepth3ADCAmpl_HO");
0479 
0480     //      TH2F *twod4= (TH2F*)hfile->Get("h_mapDepth4ADCAmpl_HO");
0481 
0482     int nx = twod4->GetXaxis()->GetNbins();
0483     int ny = twod4->GetYaxis()->GetNbins();
0484     //      cout  <<"BEGINNING k1= " << k1 <<" nx= " << nx <<" ny= " << ny   <<endl;
0485 
0486     //    TH2F *t0010= (TH2F*)hfile->Get("h_mapDepth1_HO");
0487     //    TH2F *t0020= (TH2F*)hfile->Get("h_mapDepth2_HO");
0488     //      TH2F *t0030= (TH2F*)hfile->Get("h_mapDepth3_HO");
0489     TH2F* t0040 = (TH2F*)hfile->Get("h_mapDepth4_HO");
0490 
0491     //    TH2F* Ceff1= (TH2F*)twod1->Clone("Ceff1");
0492     //    TH2F* Ceff2= (TH2F*)twod2->Clone("Ceff2");
0493     //      TH2F* Ceff3= (TH2F*)twod3->Clone("Ceff3");
0494     TH2F* Ceff4 = (TH2F*)twod4->Clone("Ceff4");
0495 
0496     // <Aijk>_runevents:
0497     //  Ceff1->Divide(twod1,t0010, 1, 1, "B");
0498     //  Ceff2->Divide(twod2,t0020, 1, 1, "B");
0499     //    Ceff3->Divide(twod3,t0030, 1, 1, "B");
0500     Ceff4->Divide(twod4, t0040, 1, 1, "B");
0501     //      Ceff1->Sumw2();Ceff2->Sumw2();Ceff3->Sumw2();
0502     ///////////////////////////////////////////////////////////////////////////////////////////
0503     for (int jjj = 0; jjj < nx; jjj++) {
0504       for (int kkk = 0; kkk < ny; kkk++) {
0505         // HOP17 selection:
0506         if (flagHOP17selection == 0 ||
0507             (flagHOP17selection == 1 && (((jjj > 56 && jjj < 62) && (kkk > 63 && kkk < 68)) ||
0508                                          ((jjj > 61 && jjj < 71) && (kkk == 64 || kkk == 66)))) ||
0509             (flagHOP17selection == 2 && !(((jjj > 14 && jjj < 25) && (kkk > 55 && kkk < 64))))) {
0510           //      if(Ceff1->GetBinContent(jjj,kkk) !=0.)  cout  <<" k1=111111 " << k1 <<" eta= " << jjj <<" phi= " << kkk   <<" Ceff1= " << Ceff1->GetBinContent(jjj,kkk)   <<endl;
0511           //      if(Ceff7->GetBinContent(jjj,kkk) !=0.)  cout  <<" k1=77777777777 " << k1 <<" eta= " << jjj <<" phi= " << kkk   <<" Ceff7= " << Ceff7->GetBinContent(jjj,kkk)   <<endl;
0512           //      if(Ceff1->GetBinContent(jjj,kkk) >0. ) mapchannelsdepth1->Fill(    double(jjj)-41., double(kkk), Ceff1->GetBinContent(jjj,kkk)      );
0513           //      if(Ceff2->GetBinContent(jjj,kkk) >0. ) mapchannelsdepth2->Fill(    double(jjj)-41., double(kkk), Ceff2->GetBinContent(jjj,kkk)      );
0514           //      if(Ceff3->GetBinContent(jjj,kkk) >0. ) mapchannelsdepth3->Fill(    double(jjj)-41., double(kkk), Ceff3->GetBinContent(jjj,kkk)      );
0515           if (Ceff4->GetBinContent(jjj, kkk) > 0.)
0516             mapchannelsdepth4->Fill(double(jjj) - 41., double(kkk), Ceff4->GetBinContent(jjj, kkk));
0517         }  // if HOP17 selection
0518       }    // for
0519     }      // for
0520     ///////////////////////////////////////////////////////////////////////////////////////////
0521     //  }
0522 
0523     //
0524     //
0525     // fill:
0526     // fill massive <Aijk>_runevents ,  where iii=depth, jjj=eta, kkk=phi
0527     for (int jjj = 0; jjj < nx; jjj++) {
0528       for (int kkk = 0; kkk < ny; kkk++) {
0529         //
0530         // HOP17 selection:
0531         if (flagHOP17selection == 0 ||
0532             (flagHOP17selection == 1 && (((jjj > 56 && jjj < 62) && (kkk > 63 && kkk < 68)) ||
0533                                          ((jjj > 61 && jjj < 71) && (kkk == 64 || kkk == 66)))) ||
0534             (flagHOP17selection == 2 && !(((jjj > 14 && jjj < 25) && (kkk > 55 && kkk < 64))))) {
0535           // FILL NEW PLOTS:
0536           // Aijk: Ceff1D & Seff1D plots
0537           //      if(Ceff1->GetBinContent(jjj,kkk)!= 0.) {Ceff1D->Fill(Ceff1->GetBinContent(jjj,kkk));Seff1D->Fill(Ceff1->GetBinContent(jjj,kkk));}
0538           //      if(Ceff2->GetBinContent(jjj,kkk)!= 0.) {Ceff1D->Fill(Ceff2->GetBinContent(jjj,kkk));Seff1D->Fill(Ceff2->GetBinContent(jjj,kkk));}
0539           //      if(Ceff3->GetBinContent(jjj,kkk)!= 0.) {Ceff1D->Fill(Ceff3->GetBinContent(jjj,kkk));Seff1D->Fill(Ceff3->GetBinContent(jjj,kkk));}
0540           if (Ceff4->GetBinContent(jjj, kkk) != 0.) {
0541             Ceff1D->Fill(Ceff4->GetBinContent(jjj, kkk));
0542             Seff1D->Fill(Ceff4->GetBinContent(jjj, kkk));
0543           }
0544         }  //if
0545       }
0546     }
0547 
0548     //--------------------------------------
0549     // take into account for future treatment only HOP17 channels and cuts on <Aijk>_runevents within cutMinA to cutMaxA:
0550     // apply cut on <Aijk>_runevents
0551     //             -41                                +41
0552     //                            82 bins
0553     for (int jjj = 0; jjj < nx; jjj++) {
0554       for (int kkk = 0; kkk < ny; kkk++) {
0555         // HOP17 selection:
0556         if (flagHOP17selection == 0 ||
0557             (flagHOP17selection == 1 && (((jjj > 56 && jjj < 62) && (kkk > 63 && kkk < 68)) ||
0558                                          ((jjj > 61 && jjj < 71) && (kkk == 64 || kkk == 66)))) ||
0559             (flagHOP17selection == 2 && !(((jjj > 14 && jjj < 25) && (kkk > 55 && kkk < 64))))) {
0560           //      if(Ceff1->GetBinContent(jjj,kkk)> cutMinA && Ceff1->GetBinContent(jjj,kkk)< cutMaxA) mapRATIO[1][jjj][kkk] =  Ceff1->GetBinContent(jjj,kkk);
0561           //      if(Ceff2->GetBinContent(jjj,kkk)> cutMinA && Ceff2->GetBinContent(jjj,kkk)< cutMaxA) mapRATIO[2][jjj][kkk] =  Ceff2->GetBinContent(jjj,kkk);
0562           //      if(Ceff3->GetBinContent(jjj,kkk)> cutMinA && Ceff3->GetBinContent(jjj,kkk)< cutMaxA) mapRATIO[3][jjj][kkk] =  Ceff3->GetBinContent(jjj,kkk);
0563           if (Ceff4->GetBinContent(jjj, kkk) > cutMinA && Ceff4->GetBinContent(jjj, kkk) < cutMaxA)
0564             mapRATIO[4][jjj][kkk] = Ceff4->GetBinContent(jjj, kkk);
0565         }  //if
0566       }    // for
0567     }      // for
0568     //////////////////---------------------------------------
0569     /*
0570     //         define A for refRun :  k1=[0]
0571     //////////////////---------------------------------------
0572     if(k1==firstrun && kmm==0 ) {
0573       kmm=1; //Int_t mcount=0;
0574       cout<<"* to be printed once only  CHOCK IT please  ************ kmm = " << kmm <<endl;
0575       for(int iii = 1; iii<4; iii++) {
0576 //  for (int jjj=1;jjj<=82;jjj++) {
0577 //    for (int kkk=1;kkk<=72;kkk++) {
0578       for (int jjj=0;jjj<nx;jjj++) {
0579     for (int kkk=0;kkk<ny;kkk++) {
0580         normalization[iii][jjj][kkk] = mapRATIO[iii][jjj][kkk];
0581       }//for 
0582     }//for 
0583       }//for 
0584     }// if(k1=firstrun
0585 */
0586     //--------------------------------------
0587     //                                               then, averaging over depthes, but first sum over depthes before!!! any dividing.  Use mapRATIOD2[jjj][kkk] and mapRATIOD20[jjj][kkk]
0588     //////////////////---------------------------------------
0589     int totalhep17count = 0;
0590     int totalhep17count1 = 0;
0591     int totalhep17count2 = 0;
0592     int totalhep17count3 = 0;
0593     int totalhep17count4 = 0;
0594     int totalhep17count5 = 0;
0595     int totalhep17count6 = 0;
0596     int totalhep17count7 = 0;
0597     for (int iii = 1; iii < NDEP; iii++) {
0598       for (int jjj = 0; jjj < nx; jjj++) {
0599         for (int kkk = 0; kkk < ny; kkk++) {
0600           //    for (int jjj=1;jjj<=82;jjj++) {
0601           //    for (int kkk=1;kkk<=72;kkk++) {
0602           if (mapRATIO[iii][jjj][kkk] > 0) {
0603             // calculate # channels in HOP17 for each depth:
0604             totalhep17count++;
0605             if (verbosity == 4 && k1 == 0) {
0606               cout << " k1= " << k1 << " depth= " << iii << " eta= " << jjj << " phi= " << kkk
0607                    << " mapRATIO= " << mapRATIO[iii][jjj][kkk] << endl;
0608             }
0609             if (iii == 1)
0610               totalhep17count1++;
0611             if (iii == 2)
0612               totalhep17count2++;
0613             if (iii == 3)
0614               totalhep17count3++;
0615             if (iii == 4)
0616               totalhep17count4++;
0617             if (iii == 5)
0618               totalhep17count5++;
0619             if (iii == 6)
0620               totalhep17count6++;
0621             if (iii == 7)
0622               totalhep17count7++;
0623             // ----------------------------------------   sum over depthes before!!! any dividing:
0624             mapRATIOD2[jjj][kkk] += mapRATIO[iii][jjj][kkk];
0625             // count entries with digis only:
0626             mapRATIOD20[jjj][kkk]++;
0627             if (verbosity == 3 && iii == 3)
0628               cout << "   depth = " << iii << " k1 = " << k1 << " eta = " << jjj
0629                    << " mapRATIOD2[jjj][kkk] = " << mapRATIOD2[jjj][kkk] << " #entries = " << mapRATIOD20[jjj][kkk]
0630                    << " mapRATIO[iii][jjj][kkk] = " << mapRATIO[iii][jjj][kkk] << endl;
0631           }  // if mapRATIO[iii][jjj][kkk] != 0
0632         }    //for
0633       }      //for
0634     }        //for
0635 
0636     // ERROR printout !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0637     //    if(totalhep17count != 184 ) {cout  <<"!!!!!! ERROR:NOT ALL CHANNELS HOP17 INVOLEVED FOR RUN WITH  k1= " << k1 <<" totalhep17count= " << totalhep17count <<endl;}
0638 
0639     if (verbosity == 4 && k1 == 0) {
0640       cout << " k1= " << k1 << " totalhep17count= " << totalhep17count << endl;
0641       cout << " k1= " << k1 << " totalhep17count1= " << totalhep17count1 << endl;
0642       cout << " k1= " << k1 << " totalhep17count2= " << totalhep17count2 << endl;
0643       cout << " k1= " << k1 << " totalhep17count3= " << totalhep17count3 << endl;
0644       cout << " k1= " << k1 << " totalhep17count4= " << totalhep17count4 << endl;
0645       cout << " k1= " << k1 << " totalhep17count5= " << totalhep17count5 << endl;
0646       cout << " k1= " << k1 << " totalhep17count6= " << totalhep17count6 << endl;
0647       cout << " k1= " << k1 << " totalhep17count7= " << totalhep17count7 << endl;
0648     }
0649 
0650     //////////////------------------------------          and now averaging over depthes     and   get final mapRATIOD2[jjj][kkk]
0651     //////////////////---------------------------------------
0652     Int_t depthAVERAGEcount = 0;
0653     for (int jjj = 0; jjj < nx; jjj++) {
0654       for (int kkk = 0; kkk < ny; kkk++) {
0655         //  for (int jjj=1;jjj<=82;jjj++) {
0656         //for(int kkk=1;kkk<=72;kkk++) {
0657         depthAVERAGEcount = 4 * (jjj - 57) + (kkk - 64);
0658         if (mapRATIOD20[jjj][kkk] != 0) {
0659           NotEmptyDepthes->Fill(float(depthAVERAGEcount));
0660           if (verbosity == 1)
0661             cout << "****aver per depthes********* phi = " << kkk << " RunIndex = " << k1 << " eta = " << jjj
0662                  << " #entries  = " << mapRATIOD20[jjj][kkk] << endl;
0663           mapRATIOD2[jjj][kkk] /= mapRATIOD20[jjj][kkk];
0664           if (verbosity == 3 && kkk == 3)
0665             cout << "****aver per depthes********* phi = " << jjj << " RunIndex = " << k1 << " eta = " << jjj
0666                  << " Nphi = " << mapRATIOD20[jjj][kkk] << endl;
0667         }  // if(mapRATIOD20 != 0
0668       }    //for kkk
0669     }      //for jjj
0670     //////////////////---------------------------------------
0671     //                                                 define A for refRun :  k1=[0]
0672     //////////////////---------------------------------------
0673     if (k1 == firstrun && kmm == 0) {
0674       kmm = 1;  //Int_t mcount=0;
0675       cout << "* to be printed once only  CHOCK IT please  ************ kmm = " << kmm << endl;
0676       //      for (int jjj=1;jjj<=82;jjj++) {
0677       //    for (int kkk=1;kkk<=72;kkk++) {
0678       for (int jjj = 0; jjj < nx; jjj++) {
0679         for (int kkk = 0; kkk < ny; kkk++) {
0680           normalization[jjj][kkk] = mapRATIOD2[jjj][kkk];
0681         }  //for
0682       }    //for
0683     }      // if(k1=firstrun
0684     //--------------------------------------
0685     //              cout << "!!!! 111111 " <<endl;
0686     //////////////------------------------------          get normalized ratio   GSMRATIOD2[k1][jjj][kkk]
0687     //////////////////---------------------------------------
0688     //   int etaphicount = 0;
0689     //    for (int jjj=1;jjj<=82;jjj++) {
0690     //      for (int kkk=1;kkk<=72;kkk++) {
0691     for (int jjj = 0; jjj < nx; jjj++) {
0692       for (int kkk = 0; kkk < ny; kkk++) {
0693         if (normalization[jjj][kkk] != 0) {
0694           GSMRATIOD2[k1][jjj][kkk] = mapRATIOD2[jjj][kkk] / normalization[jjj][kkk];
0695           // plotting:
0696           if (GSMRATIOD2[k1][jjj][kkk] < RrangeMAX && GSMRATIOD2[k1][jjj][kkk] > RrangeMIN) {
0697             gainkoeff->Fill(GSMRATIOD2[k1][jjj][kkk]);
0698             gainkoeff0->Fill(GSMRATIOD2[k1][jjj][kkk]);
0699             gainkoeff9->Fill(GSMRATIOD2[k1][jjj][kkk]);
0700             // printout
0701             //    etaphicount++;
0702             //  if(etaphicount > 30 ) cout  <<"etaphicount =   " << etaphicount   << "for  k1= " << k1 <<endl;
0703             //          if(etaphicount == 30 ) cout  <<"etaphicount == 30 for  k1= " << k1 <<endl;
0704             //      cout  <<" k1= " << k1 <<" eta= " << jjj <<" phi= " << kkk   <<endl;
0705             GOODruns->Fill(float(k1));  // fill #channels w/ R inside unit
0706           } else {
0707             if (GSMRATIOD2[k1][jjj][kkk] > 0.)
0708               BADruns->Fill(float(k1));
0709           }  // fill #channels outside  R  unit
0710           //      else{if(GSMRATIOD2[k1][jjj][kkk]>0.) BADruns->Fill(float(k1));}
0711 
0712         }  // if(normalization[jjj][kkk] != 0
0713       }    //for kkk
0714     }      //for jjj
0715     //              cout << "!!!! 222222 " <<endl;
0716 
0717     //
0718     //////////////////---------------------------------------
0719     //////////////////---------------------------------------
0720     //////////////////---------------------------------------
0721     /////////////////////////////////////////////////////////////////////////////////////////////// nulling :
0722     ///////////////////////////////////////////////////////////////// nulling :
0723     for (int jjj = 0; jjj <= 82; jjj++) {
0724       for (int kkk = 0; kkk <= 72; kkk++) {
0725         mapRATIOD2[jjj][kkk] = 0.;
0726         mapRATIOD20[jjj][kkk] = 0.;
0727         for (int iii = 0; iii < NDEP; iii++) {
0728           mapRATIO[iii][jjj][kkk] = 0.;
0729         }
0730       }  // for
0731     }    // for
0732     //              cout << "!!!! 333333 " <<endl;
0733 
0734     ///////////////////// hfile->Close();
0735     hfile->Close();
0736     /////////////////////
0737 
0738     //              cout << "!!!! 444444 " <<endl;
0739 
0740     //  }//if(k1==0 || (k1>37
0741     //////////////////////////////////////////////////////////////////////////////////////////////////  END OF LOOP OVER LED RUNS
0742   }  //for k1 loop over time points(LED runs)
0743   cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                   DONE: last LED run READ " << endl;
0744 
0745   //    c1->Clear();
0746 
0747   // ////////////////////////////////////////////////////////////////////////////////////////////////// END OF LOOP OVER LED RUNS
0748   ////////////////////////////////////////////////////////////////////////////////////////////////////  END OF LOOP OVER LED RUNS
0749   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0750   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0751 
0752   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   DRAWING   DRAWING   DRAWING   DRAWING   DRAWING
0753   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   DRAWING   DRAWING   DRAWING   DRAWING   DRAWING
0754   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   DRAWING   DRAWING   DRAWING   DRAWING   DRAWING
0755   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   DRAWING   DRAWING   DRAWING   DRAWING   DRAWING
0756   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   DRAWING   DRAWING   DRAWING   DRAWING   DRAWING
0757   cout << "****  ****  ****  ****  ****     Draw Dependencies: *** " << endl;
0758 
0759   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0760   Int_t Method = NMethodsStart;
0761   while (Method < NMethodsToUse + 1) {
0762     if (Method != 9999992) {
0763       cout << " ****  START   Method " << Method << endl;
0764       //======================================================================================================= PLOT0:  <Aijk>  for each event and all LED runs
0765       if (Method == 0) {
0766         cout << "****Draw 0 Dependencies: <Aijk>  for each event and all LED runs  *** " << endl;
0767         gPad->SetGridy();
0768         gPad->SetGridx();
0769         gPad->SetLogy();
0770         gStyle->SetOptStat(101110);
0771         Ceff1D->SetMarkerStyle(20);
0772         Ceff1D->SetMarkerSize(0.4);
0773         Ceff1D->GetYaxis()->SetLabelSize(0.04);
0774         Ceff1D->SetTitle("all runs & channels");
0775         Ceff1D->SetXTitle("<Aijk>");
0776         Ceff1D->SetYTitle("N");
0777         Ceff1D->SetMarkerColor(4);
0778         Ceff1D->SetLineColor(4);
0779         //    Ceff1D->Draw("Error");
0780         Ceff1D->Draw("PL");
0781       }  //Method = 0
0782       //======================================================================================================= PLOT1: <Aijk>  for each event and all LED runs ZOOM
0783       if (Method == 1) {
0784         cout << "****Draw 1 Dependencies: <Aijk>  for each event and all LED runs ZOOM  *** " << endl;
0785         gPad->SetGridy();
0786         gPad->SetGridx();
0787         gPad->SetLogy();
0788         gStyle->SetOptStat(101110);
0789         //    Seff1D->SetTitle("any Error, HO Depth1 \n");
0790         Seff1D->SetMarkerStyle(20);
0791         Seff1D->SetMarkerSize(0.4);
0792         Seff1D->GetYaxis()->SetLabelSize(0.04);
0793         Seff1D->SetTitle("ZOOM all runs & channels");
0794         Seff1D->SetXTitle("<Aijk> ZOOM  ");
0795         Seff1D->SetYTitle("N");
0796         Seff1D->SetMarkerColor(4);
0797         Seff1D->SetLineColor(4);
0798         //    Seff1D->Draw("Error");
0799         Seff1D->Draw("PL");
0800       }  //Method = 1
0801       //  //////////////////////////////////////////////////////////////////////////
0802       //======================================================================================================= PLOT2  GSM ratio vs days
0803       if (Method == 2) {
0804         cout << "****Draw 2 Dependencies: GSM ratio vs days  *** " << endl;
0805         for (int k1 = 0; k1 < NP; k1++) {
0806           YY[k1] = 0.;
0807         }
0808         //      c1->Range(0,0,25,18);
0809         //      c1->SetFillColor(0);
0810         //      c1->Clear();
0811         TPad* pad1 = new TPad("pad1", "This is pad1", 0.02, 0.02, 0.99, 0.99, 0);
0812         pad1->Draw();
0813         pad1->cd();
0814         pad1->Range(-0.255174, -19.25, 2.29657, -6.75);
0815         //              x1   y1     x2     y2
0816         pad1->DrawFrame(x1, y1, x2, y2);  // 1-A,
0817         //  pad1->DrawFrame(1,   0.,  370,   2.0);  // 1-A,
0818         pad1->GetFrame()->SetFillColor(0);
0819         pad1->Draw();
0820         gPad->SetGridy();
0821         gPad->SetGridx();
0822         //                -   -       -        -   -  -                                                            -   -   -       -           -    -
0823         Int_t colorlines = 0;
0824         Int_t generalcount = 0;
0825         //      for (int jjj=1;jjj<=82;jjj++) {
0826         //  for (int kkk=1;kkk<=72;kkk++) {
0827         for (int jjj = 0; jjj < 82; jjj++) {
0828           for (int kkk = 0; kkk < 72; kkk++) {
0829             Int_t sscount = -1;
0830             for (int k1 = 0; k1 < NP; k1++) {
0831               if (GSMRATIOD2[k1][jjj][kkk] != 0) {
0832                 //        if(GSMRATIOD2[k1][jjj][kkk]< 1.033 && GSMRATIOD2[k1][jjj][kkk] > 0.91  ) {
0833                 //   if(GSMRATIOD2[k1][jjj][kkk]< 9. && GSMRATIOD2[k1][jjj][kkk] > 0.  ) {
0834                 if (GSMRATIOD2[k1][jjj][kkk] < RrangeMAX && GSMRATIOD2[k1][jjj][kkk] > RrangeMIN) {
0835                   //              if(GSMRATIOD2[k1][jjj][kkk]< 1.05 && GSMRATIOD2[k1][jjj][kkk] > 0.91  ) {
0836                   //   if(GSMRATIOD2[k1][jjj][kkk]< 1.15 && GSMRATIOD2[k1][jjj][kkk] > 0.85  ) {
0837                   sscount++;
0838                   YY[sscount] = GSMRATIOD2[k1][jjj][kkk];  //
0839                   XXX[sscount] = XX[k1];
0840                   indWAS[sscount] = k1;
0841                   mapBADchannels->Fill(double(jjj) - 42., double(kkk) - 1., GSMRATIOD2[k1][jjj][kkk]);
0842                   mapBADchannels0->Fill(double(jjj) - 42., double(kkk) - 1., 1.);
0843                 }  // GSMRATIOD2[k1][jjj][kkk] < 1.05
0844                 else {
0845                   //        mapBADchannels->Fill(double(jjj)-42., double(kkk)-1., GSMRATIOD2[k1][jjj][kkk]);
0846                 }
0847               }  // GSMRATIOD2[k1][jjj][kkk] != 0
0848             }    //for k1
0849             Int_t MMcount = sscount + 1;
0850             if (MMcount > 0) {
0851               generalcount++;
0852               if (generalcount == 1 && verbosity == 2)
0853                 for (int k1 = 0; k1 < MMcount; k1++) {
0854                   cout << "**** All GOOD runs: indWAS[k1](1,..) =  " << indWAS[k1] + 1 << " XXX[k1]+1 = " << XXX[k1] + 1
0855                        << endl;
0856                 }
0857               gr1 = new TGraph(MMcount, XXX, YY);
0858               colorlines = generalcount / 5. + 2;
0859               gr1->SetLineColor(colorlines);
0860               gr1->SetMarkerColor(colorlines);
0861               gr1->SetMarkerStyle(20);
0862               gr1->SetMarkerSize(1.2);
0863               gr1->SetFillStyle(0);
0864               gr1->GetXaxis()->SetTitle("days");
0865               gr1->GetYaxis()->SetTitle("R");
0866               gr1->Draw("PL");
0867             }  // if
0868             //    else {cout<<"****ERROR for  PLOT2:  MMcount is lower 1,  MMcount =   *** " << MMcount  <<   endl;}
0869           }  //for kkk
0870         }    //for jjj
0871 
0872         //      TLegend leg(.6,.67,.78,.88, " HOP Depth1");
0873         //   TLegend leg(xx1,yy1,xx2,yy2, "HOP17: R vs t");
0874         TLegend leg(xx1, yy1, xx2, yy2, "HO: R vs t(days)");
0875         //      leg.AddEntry(gr1);
0876         leg.SetMargin(0.3);
0877         leg.SetBorderSize(1);
0878         leg.DrawClone("Same");
0879         /*      
0880       // Draw labels on the y axis
0881       TText *t7 = new TText();
0882       t7->SetTextAlign(32);
0883       t7->SetTextSize(0.035);
0884       t7->SetTextFont(72);
0885       char *labels[NP+1] = {"31","1","7","7","8","9","12","13","19","22","22","24","24","24","24","24","24","Feb."};
0886       float X7[NP];
0887       for(int k1 = 0; k1<NP; k1++) {
0888     //  cout<<"**** XXX[k1] =  " << XXX[k1] <<"     YY[k1] =  " << YY[k1] <<   endl;
0889         t7->DrawText(0.2+XXX[k1],0.890,labels[k1]);
0890       }
0891             t7->DrawText(0.2+XXX[NP-1]+75.,0.890,labels[NP]);
0892 */
0893 
0894       }  ////Method = 2
0895       //
0896 
0897       //======================================================================================================= PLOT3: 2D channels
0898       if (Method == 3) {
0899         cout << "****Draw 3 Dependencies: 2D  channels  *** " << endl;
0900         TH2F* Cdepth2hbff = (TH2F*)mapBADchannels->Clone("Cdepth2hbff");
0901         Cdepth2hbff->Divide(mapBADchannels, mapBADchannels0, 1, 1, "B");
0902         Cdepth2hbff->Sumw2();
0903         gPad->SetGridy();
0904         gPad->SetGridx();
0905         gStyle->SetOptStat(0000000);
0906         Cdepth2hbff->SetMarkerStyle(20);
0907         Cdepth2hbff->SetMarkerSize(0.4);
0908         Cdepth2hbff->GetYaxis()->SetLabelSize(0.04);
0909         Cdepth2hbff->SetTitle("within R & Weighted by R");
0910         Cdepth2hbff->SetXTitle("#eta \b");
0911         Cdepth2hbff->SetYTitle("#phi \b");
0912         Cdepth2hbff->SetMarkerColor(4);
0913         Cdepth2hbff->SetLineColor(4);
0914         Cdepth2hbff->Draw("COLZ");
0915       }  //Method = 3
0916       //======================================================================================================= PLOT4:gains LED runs
0917       if (Method == 4) {
0918         cout << "****Draw 4 Dependencies: gains LED runs   *** " << endl;
0919         gPad->SetGridy();
0920         gPad->SetGridx();
0921         //    gPad->SetLogy();
0922         //gStyle->SetOptStat(1110000);
0923         gStyle->SetOptStat(1100);  // only mean & rms
0924         //gStyle->SetOptStat(1111111);// only mean & rms
0925         gainkoeff->SetMarkerStyle(20);
0926         gainkoeff->SetMarkerSize(0.4);
0927         gainkoeff->GetYaxis()->SetLabelSize(0.04);
0928         gainkoeff->SetXTitle("gains");
0929         gainkoeff->SetYTitle("N");
0930         gainkoeff->SetMarkerColor(4);
0931         gainkoeff->SetLineColor(4);
0932         //    gainkoeff->Draw("Error");
0933         gainkoeff->Draw("PL");
0934       }  //Method = 4
0935       //======================================================================================================= PLOT5:gains LED runs
0936       if (Method == 5) {
0937         cout << "****Draw 5 Dependencies: gains LED runs   *** " << endl;
0938         gPad->SetGridy();
0939         gPad->SetGridx();
0940         gPad->SetLogy();
0941         //gStyle->SetOptStat(1110000);
0942         gStyle->SetOptStat(1100);  // only mean & rms
0943         //gStyle->SetOptStat(1111111);// only mean & rms
0944         gainkoeff9->SetMarkerStyle(20);
0945         gainkoeff9->SetMarkerSize(0.4);
0946         gainkoeff9->GetYaxis()->SetLabelSize(0.04);
0947         gainkoeff9->SetXTitle("gains");
0948         gainkoeff9->SetYTitle("N");
0949         gainkoeff9->SetMarkerColor(4);
0950         gainkoeff9->SetLineColor(4);
0951         //    gainkoeff9->Draw("Error");
0952         gainkoeff9->Draw("PL");
0953       }  //Method = 5
0954       //======================================================================================================= PLOT6:gains LED runs
0955       if (Method == 6) {
0956         cout << "****Draw 6 Dependencies: gains LED runs   *** " << endl;
0957         gPad->SetGridy();
0958         gPad->SetGridx();
0959         gPad->SetLogy();
0960         //gStyle->SetOptStat(1110000);
0961         gStyle->SetOptStat(1100);  // only mean & rms
0962         //gStyle->SetOptStat(1111111);// only mean & rms
0963         gainkoeff0->SetMarkerStyle(20);
0964         gainkoeff0->SetMarkerSize(0.4);
0965         gainkoeff0->GetYaxis()->SetLabelSize(0.04);
0966         gainkoeff0->SetXTitle("gains");
0967         gainkoeff0->SetYTitle("N");
0968         gainkoeff0->SetMarkerColor(4);
0969         gainkoeff0->SetLineColor(4);
0970         //    gainkoeff0->Draw("Error");
0971         gainkoeff0->Draw("PL");
0972       }  //Method = 6
0973       //======================================================================================================= PLOT7: BADruns
0974       if (Method == 7) {
0975         cout << "****Draw 7 Dependencies: BADruns  *** " << endl;
0976         gPad->Update();
0977         gPad->SetGridy();
0978         gPad->SetGridx();
0979         gPad->SetLogy(kFALSE);
0980         gStyle->SetOptStat(101110);
0981         BADruns->SetMarkerStyle(20);
0982         BADruns->SetMarkerSize(0.4);
0983         BADruns->GetYaxis()->SetLabelSize(0.04);
0984         BADruns->SetTitle("#channels outside Rrange VS iRun");
0985         BADruns->SetXTitle("iRun");
0986         BADruns->SetYTitle("#channels");
0987         BADruns->SetMarkerColor(4);
0988         BADruns->SetLineColor(4);
0989         //    BADruns->Draw("Error");
0990         BADruns->Draw("PL");
0991         //  PRINTOUT ONLY:
0992         //      if(verbosity == 4 ){
0993         int cx = BADruns->GetXaxis()->GetNbins();
0994         cout << "*****    *************     Number of runs w/ R outside unit-range = " << cx << endl;
0995         int nbadruns = 0;
0996         for (int jjj = 1; jjj <= cx; jjj++) {
0997           if (BADruns->GetBinContent(jjj) > 200.) {
0998             cout << "BADruns w/ content>60:   jjj= " << jjj << " run= " << LEDruns[jjj - 1]
0999                  << "  R ouside unit-range for # channels= " << BADruns->GetBinContent(jjj) << endl;
1000             ++nbadruns;
1001           }
1002           //    if( BADruns->GetBinContent(jjj) >8.) {cout<<"BADruns w/ content>60:   jjj= " << jjj  <<" run= " <<   LEDruns[jjj-1]    <<"  R ouside unit-range for # channels= " << BADruns->GetBinContent(jjj) <<endl;++nbadruns;}
1003         }  //jjj
1004         cout << "BADruns w/ content>60   nbadruns= " << nbadruns << endl;
1005         //      }// if(verbosity == 2 )
1006       }  //Method = 7
1007 
1008       //======================================================================================================= PLOT8: Goodruns
1009       if (Method == 8) {
1010         cout << "****Draw 8 Dependencies: Goodruns  *** " << endl;
1011         gPad->SetGridy();
1012         gPad->SetGridx();
1013         //      gPad->SetLogy();
1014         gStyle->SetOptStat(101110);
1015         GOODruns->SetMarkerStyle(20);
1016         GOODruns->SetMarkerSize(0.4);
1017         GOODruns->GetYaxis()->SetLabelSize(0.04);
1018         GOODruns->SetTitle("#channels inside Rrange VS iRun");
1019         GOODruns->SetXTitle("iRun");
1020         GOODruns->SetYTitle("#channels");
1021         GOODruns->SetMarkerColor(4);
1022         GOODruns->SetLineColor(4);
1023         //    GOODruns->Draw("Error");
1024         GOODruns->Draw("PL");
1025         //  PRINTOUT ONLY:
1026         //      if(verbosity == 4 ){
1027         int cx = GOODruns->GetXaxis()->GetNbins();
1028         cout << "************* cx = " << cx << endl;
1029         for (int jjj = 0; jjj <= cx; jjj++) {
1030           //      if( GOODruns->GetBinContent(jjj) >100.) cout<<"GOODruns:   k1= " <<      jjj      <<endl;
1031           //      if( GOODruns->GetBinContent(jjj) >5.) cout<<"GOODruns:   k1= " <<      jjj      <<endl;
1032           if (GOODruns->GetBinContent(jjj) > 1400.)
1033             cout << "GOODruns:   k1(0,...)= " << jjj
1034                  << "  GOODruns->GetBinContent(jjj)= " << GOODruns->GetBinContent(jjj) << endl;
1035         }  //jjj
1036            //      }// if(verbosity == 2 )
1037       }    //Method = 8
1038 
1039       //======================================================================================================= PLOT9:depthes with zero A
1040       if (Method == 9) {
1041         cout << "****Draw 9 Dependencies: depthes with zero A   *** " << endl;
1042         gPad->SetGridy();
1043         gPad->SetGridx();
1044         gPad->SetLogy(kFALSE);
1045         gStyle->SetOptStat(1110000);
1046         NotEmptyDepthes->SetMarkerStyle(20);
1047         NotEmptyDepthes->SetMarkerSize(0.4);
1048         NotEmptyDepthes->GetYaxis()->SetLabelSize(0.04);
1049         NotEmptyDepthes->SetTitle("# Not Empty Channels in etq-phi projection");
1050         NotEmptyDepthes->SetXTitle("4*(eta-57)+(phi-64)");
1051         NotEmptyDepthes->SetYTitle("N");
1052         NotEmptyDepthes->SetMarkerColor(4);
1053         NotEmptyDepthes->SetLineColor(4);
1054         //    NotEmptyDepthes->Draw("Error");
1055         NotEmptyDepthes->Draw("PL");
1056       }  //Method = 9
1057       //======================================================================================================= PLOT10:  Aijk  for each event and all LED runs
1058       if (Method == 10) {
1059         cout << "****Draw 10 Dependencies: Aijk  for each event and all LED runs  *** " << endl;
1060 
1061         c1->Clear();
1062         c1->Divide(1, 1);
1063 
1064         c1->cd(1);
1065         //        TString epsName = fname + LEDruns[0] +".root";
1066         //        TFile *hfile= new TFile(epsName, "READ");
1067         //        TH1F * Aeff1D= (TH1F*)hfile->Get("h_ADCAmpl_HO");
1068 
1069         gPad->SetGridy();
1070         gPad->SetGridx();
1071         gPad->SetLogy();
1072         gStyle->SetOptStat(101110);
1073         //      Aeff1D->SetStats(0);
1074         Aeff1D->SetMarkerStyle(20);
1075         Aeff1D->SetMarkerSize(0.4);
1076         Aeff1D->GetYaxis()->SetLabelSize(0.04);
1077         Aeff1D->SetTitle("all runs & events& channels");
1078         Aeff1D->SetXTitle("Aijk");
1079         Aeff1D->SetYTitle("N");
1080         Aeff1D->SetMarkerColor(4);
1081         Aeff1D->SetLineColor(4);
1082         //    Aeff1D->Draw("Error");
1083         //    Aeff1D->Draw("PL");
1084         Aeff1D->SetMinimum(0.8);
1085         Aeff1D->Draw("");
1086 
1087         c1->Update();
1088 
1089       }  //Method = 10
1090       //======================================================================================================= PLOT11: 2D SiPM channels Depthes1,2,(3.4 for 20202)
1091       if (Method == 11) {
1092         cout << "****Draw 11 <A>: 2D Depthes1,2,3,4  *** " << endl;
1093         //      gPad->SetGridy();
1094         //      gPad->SetGridx();
1095         //      gStyle->SetOptStat(0000000);
1096         c1->Clear();
1097         c1->Divide(1, 1);
1098 
1099         c1->cd(1);
1100         /*
1101       mapchannelsdepth1->SetStats(0);
1102       mapchannelsdepth1->SetTitle("<A> Depth1");
1103       mapchannelsdepth1->SetXTitle("#eta \b");
1104       mapchannelsdepth1->SetYTitle("#phi \b");
1105       mapchannelsdepth1->Draw("COLZ");
1106       c1->cd(2);
1107       mapchannelsdepth2->SetStats(0);
1108       mapchannelsdepth2->SetTitle("<A> Depth2");
1109       mapchannelsdepth2->SetXTitle("#eta \b");
1110       mapchannelsdepth2->SetYTitle("#phi \b");
1111       mapchannelsdepth2->Draw("COLZ");
1112       c1->cd(3);
1113       mapchannelsdepth3->SetStats(0);
1114       mapchannelsdepth3->SetTitle("<A> Depth3");
1115       mapchannelsdepth3->SetXTitle("#eta \b");
1116       mapchannelsdepth3->SetYTitle("#phi \b");
1117       mapchannelsdepth3->Draw("COLZ");
1118       c1->cd(4);
1119 */
1120         mapchannelsdepth4->SetStats(0);
1121         mapchannelsdepth4->SetTitle("<A> Depth4");
1122         mapchannelsdepth4->SetXTitle("#eta \b");
1123         mapchannelsdepth4->SetYTitle("#phi \b");
1124         mapchannelsdepth4->Draw("COLZ");
1125         c1->Update();
1126 
1127       }  //Method = 11
1128       //======================================================================================================= PLOT12:
1129       if (Method == 12) {
1130         cout << "****Draw 12 not used yet  *** " << endl;
1131         //      gPad->SetGridy();
1132         //      gPad->SetGridx();
1133         //      gStyle->SetOptStat(0000000);
1134         c1->Clear();
1135         c1->Divide(2, 2);
1136 
1137         c1->cd(1);
1138         c1->cd(2);
1139         c1->cd(3);
1140 
1141         c1->Update();
1142 
1143       }  //Method = 12
1144 
1145       //======================================================================================================= PLOT13: 2D
1146       if (Method == 13) {
1147         cout << "****Draw 13 function, fC *** " << endl;
1148         c1->Clear();
1149         c1->Divide(1, 1);
1150 
1151         c1->cd(1);
1152         {
1153           double c0 = 1.000000;
1154           double b1 = 2.71238e-05;
1155           double a2 = 1.32877e-10;
1156           Int_t n = 50;
1157           Double_t x[n], y[n];
1158           for (Int_t i = 0; i < n; i++) {
1159             x[i] = (i + 1) * 20000.;
1160             y[i] = a2 * x[i] * x[i] / 40. / 40. + b1 * x[i] / 40. + c0;
1161           }
1162 
1163           // create graph
1164           TGraph* gr = new TGraph(n, x, y);
1165 
1166           // draw the graph with axis, continuous line, and put
1167           // a * at each point
1168           gPad->SetGridy();
1169           gPad->SetGridx();
1170           //    gPad->SetLogy();
1171           gr->Draw("AC*");
1172           /*
1173       gr1 = new TGraph(MMcount,XXX,YY); 
1174       colorlines = generalcount/5.+2;
1175       gr1->SetLineColor(colorlines);  gr1->SetMarkerColor(colorlines); 
1176       gr1->SetMarkerStyle(20); gr1->SetMarkerSize(1.2); gr1->SetFillStyle(0); gr1->Draw("PL");
1177     */
1178         }
1179 
1180         c1->Update();
1181 
1182       }  //Method = 13
1183 
1184       //  //////////////////////////////////////////////////////////////////////////
1185 
1186       //=======================================================================================================
1187       //======================================================================================================= finish loop over Methods
1188       //=======================================================================================================
1189       TString fdir = "testamt5gsmHO2018/";
1190       //
1191       TString plotName = fdir + MethodName[Method] + ".png";
1192       c1->SaveAs(plotName);
1193       cout << "****PLOT " << Method << " drawn **** " << endl;
1194 
1195     }  //if( Method != 9
1196     ++Method;
1197   }  //while loop over Methods
1198   //=======================================================================================================
1199   //=======================================================================================================
1200   //=======================================================================================================
1201   //=======================================================================================================
1202   //=======================================================================================================
1203   //=======================================================================================================
1204   //=======================================================================================================
1205   //=======================================================================================================
1206   //=======================================================================================================
1207   //______________________________________________________________________________
1208   //______________________________________________________________________________
1209   //
1210   //______________________________________________________________________________
1211   //______________________________________________________________________________
1212   //
1213   gSystem->Exit(0);
1214   //______________________________________________________________________________
1215 }
1216 //______________________________________________________________________________