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