Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <TChain.h>
0002 #include <TH1D.h>
0003 #include <TH2D.h>
0004 #include <TProfile.h>
0005 #include <TFitResult.h>
0006 #include <TFitResultPtr.h>
0007 #include <TPaveStats.h>
0008 #include <vector>
0009 #include <string>
0010 #include <iomanip>
0011 //#####
0012 #include <iostream>
0013 #include <fstream>
0014 #include "TH1.h"
0015 #include "TH2.h"
0016 #include "TCanvas.h"
0017 #include "TROOT.h"
0018 #include <TMath.h>
0019 #include "TStyle.h"
0020 #include "TSystem.h"
0021 #include "TLegend.h"
0022 #include "TText.h"
0023 #include "TAxis.h"
0024 #include "TFile.h"
0025 #include "TLine.h"
0026 #include "TGraph.h"
0027 #include <TPaveText.h>
0028 #include <TPostScript.h>
0029 #include <TClass.h>
0030 
0031 //
0032 using namespace std;
0033 //
0034 //
0035 
0036 //inline void HERE(const char *msg) { std::cout << msg << std::endl; }
0037 
0038 int main(int argc, char *argv[]) {
0039   std::string dirnm = "Analyzer";
0040   //======================================================================
0041   printf("reco: gROOT Reset \n");
0042   gROOT->Reset();
0043   gROOT->SetStyle("Plain");
0044   //======================================================================
0045   //            gStyle->SetOptStat(0);   //  no statistics _or_
0046   //                  gStyle->SetOptStat(11111111);
0047   //gStyle->SetOptStat(1101);// name mean and rms
0048   //    gStyle->SetOptStat(0101);// name and entries
0049   //       gStyle->SetOptStat(1100);// mean and rms only !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0050   //    gStyle->SetOptStat(1110000);// und over, integral !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0051   gStyle->SetOptStat(101110);  // entries, mean, rms, overflow !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0052                                //   gStyle->SetOptStat(100000);//  over !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0053   //
0054   //gStyle->SetOptFit(00010);// constant, mean and sigma only !!
0055   //    gStyle->SetOptFit(00001);// hi2/nu, constant, mean and sigma only !!
0056   gStyle->SetOptFit(0010);  // constant, mean and sigma only !!
0057   //    gStyle->SetOptFit(00011);// constant, mean and sigma only !!
0058   // gStyle->SetOptFit(1101);
0059   //       gStyle->SetOptFit(1011);
0060   //
0061   //gStyle->SetStatX(0.98);
0062   //gStyle->SetStatY(0.99);
0063   //gStyle->SetStatW(0.30);
0064   //gStyle->SetStatH(0.25);
0065   gStyle->SetStatX(0.91);
0066   gStyle->SetStatY(0.75);
0067   gStyle->SetStatW(0.20);
0068   gStyle->SetStatH(0.10);
0069   // gStyle->SetStatH(0.35);
0070   //
0071 
0072   //        Float_t LeftOffset = 0.12;
0073   //Float_t TopOffset = 0.12;
0074   Float_t LeftOffset = 0.12;
0075   Float_t TopOffset = 0.22;
0076 
0077   gStyle->SetLineWidth(1);
0078   gStyle->SetErrorX(0);
0079 
0080   //---=[ Titles,Labels ]=-----------
0081   gStyle->SetOptTitle(0);  // title on/off
0082   //      gStyle->SetTitleColor(0);           // title color
0083   gStyle->SetTitleColor(1);  // title color
0084   //      gStyle->SetTitleX(0.35);            // title x-position
0085   gStyle->SetTitleX(0.15);  // title x-position
0086   gStyle->SetTitleH(0.15);  // title height
0087   //      gStyle->SetTitleW(0.53);            // title width
0088   gStyle->SetTitleW(0.60);         // title width
0089   gStyle->SetTitleFont(42);        // title font
0090   gStyle->SetTitleFontSize(0.07);  // title font size
0091 
0092   gStyle->SetPalette(1);
0093   //---=[ Histogram style ]=----------
0094   //        gStyle->SetHistFillColor(38);
0095   //            gStyle->SetFrameFillColor(41);// jelto-kori4nev-svetl
0096   //    gStyle->SetFrameFillColor(5);// jeltyi
0097   //    gStyle->SetFrameFillColor(17);// seryi
0098   //    gStyle->SetFrameFillColor(18);// svetlo seryi
0099   //    gStyle->SetFrameFillColor(20);// svetlo kori4nev
0100   //        gStyle->SetFrameFillColor(33);// sine-seryi
0101   //    gStyle->SetFrameFillColor(40);// fiolet-seryi
0102   //    gStyle->SetFrameFillColor(23);// sv.kor
0103 
0104   //---=[ Pad style ]=----------------
0105   gStyle->SetPadTopMargin(TopOffset);
0106   gStyle->SetPadBottomMargin(LeftOffset);
0107   gStyle->SetPadRightMargin(TopOffset);
0108   gStyle->SetPadLeftMargin(LeftOffset);
0109   //---=[ SetCanvasDef           ]=----------------
0110   //======================================================================
0111   //
0112   // Connect the input file and get the 2-d histogram in memory
0113   //======================================================================
0114   //  TBrowser *b = new TBrowser
0115 
0116   //    TFile *hfile1= new TFile("test.root", "READ");
0117   //
0118 
0119   //    TFile *hfile1= new TFile("testNZS.root", "READ");
0120   //    TFile *hfile1= new TFile("test.root", "READ");
0121 
0122   //    TFile *hfile1= new TFile("newruns/Global_234034.root", "READ");
0123   //
0124 
0125   //    TFile *hfile1= new TFile("/afs/cern.ch/cms/CAF/CMSALCA/ALCA_HCALCALIB/HCALMONITORING/CMTweb/histos/Global_234556.root", "READ");
0126   //    TFile *hfile1= new TFile("Global_234034.root", "READ");
0127   //    TFile *hfile1= new TFile("test211006.root", "READ");
0128   //    TFile *hfile1= new TFile("test234457.root", "READ");
0129 
0130   //    TFile *hfile1= new TFile("Global_51.root", "READ");
0131   //    TFile *hfile1= new TFile("Global_235698.root", "READ");
0132 
0133   //    TFile *hfile1= new TFile("Global_39.root", "READ");
0134   //    TFile *hfile1= new TFile("test237165.root", "READ");
0135   //
0136   //    TFile *hfile1= new TFile("Laser_238187.root", "READ");
0137   //    TFile *hfile1= new TFile("Laser_238183.root", "READ");
0138 
0139   //    TFile *hfile1= new TFile("Global_255031.root", "READ");
0140 
0141   //    TFile *hfile1= new TFile("Global_256001.root", "READ");
0142   //    TFile *hfile1= new TFile("Global_256167.root", "READ");
0143   //    TFile *hfile1= new TFile("Global_256348.root", "READ");
0144   //    TFile *hfile1= new TFile("Global_256630.root", "READ");
0145 
0146   //    TFile *hfile1= new TFile("../PYTHON_runlist_test/Global_283884_1.root", "READ");
0147   //        TFile *hfile1= new TFile("Global_test.root", "READ");
0148 
0149   //    TFile *hfile1= new TFile("LED_280702.root", "READ");
0150   //    TFile *hfile2= new TFile("LED_287824.root", "READ");
0151 
0152   //    TFile *hfile1= new TFile("LED_284352.root", "READ");
0153   //    TFile *hfile1= new TFile("LEDtest.root", "READ");
0154   //  TFile *hfile1 = new TFile("Global_346445.root", "READ");
0155 
0156   TFile *hfile1 = new TFile("Global_362365.root", "READ");
0157   //          TH1D *hist1(nullptr);
0158   //            hist1 = (TH1D *)dir->FindObjectAny("h_mapDepth1_HE");
0159 
0160   //    TFile *hfile2= new TFile("LED_284902.root", "READ");
0161   //    TFile *hfile2= new TFile("LED_284499.root", "READ");
0162   //    TFile *hfile2= new TFile("LED_284352.root", "READ");
0163 
0164   //    TFile *hfile2= new TFile("LED_286590.root", "READ");
0165 
0166   //    getchar();
0167   //
0168   TPostScript psfile("zlumiadcampltest.ps", 111);
0169 
0170   //
0171 
0172   TCanvas *c1 = new TCanvas("c1", "Hcal4test", 200, 10, 700, 900);
0173   //  TCanvas *c1 = new TCanvas("c1", "Hcal4test", 1000, 500);
0174 
0175   hfile1->ls();
0176   TDirectory *dir = (TDirectory *)hfile1->FindObjectAny(dirnm.c_str());
0177 
0178   //========================================================================================== 1
0179   //======================================================================
0180   //======================================================================
0181   //================
0182   //======================================================================
0183   //+++++++++++++++++++++++++++++
0184   // Lumi iLumi and number of events
0185   //+++++++++++++++++++++++++++++
0186   // with TfileService implementation, change everywhere below:     hfile->Get     to     dir->FindObjectAny
0187   c1->Clear();
0188   c1->Divide(2, 1);
0189   c1->cd(1);
0190   TH1F *LumLum = (TH1F *)dir->FindObjectAny("h_lsnumber_per_eachLS");
0191   int MaxLumDanila = LumLum->GetBinContent(LumLum->GetMaximumBin());  // old variant of Danila
0192   cout << " MaxLumDanila=     " << MaxLumDanila << endl;
0193   //  gPad->SetGridy();
0194   //  gPad->SetGridx();
0195   LumLum->SetMarkerStyle(21);
0196   LumLum->SetMarkerSize(0.8);
0197   LumLum->GetYaxis()->SetLabelSize(0.04);
0198   LumLum->SetTitle("Cont. number per LS  \b");
0199   LumLum->SetXTitle("Cont.number \b");
0200   LumLum->SetYTitle("Ls \b");
0201   LumLum->SetMarkerColor(4);
0202   LumLum->SetLineColor(0);
0203   LumLum->SetMinimum(0.8);
0204   LumLum->GetXaxis()->SetRangeUser(0, MaxLumDanila + 5.);
0205   LumLum->Draw("Error");
0206 
0207   c1->cd(2);
0208   TH1F *LumiEv = (TH1F *)dir->FindObjectAny("h_nevents_per_eachRealLS");
0209   int MaxLum0 = LumiEv->GetBinContent(LumiEv->GetMaximumBin());
0210   int MaxLum = 0;
0211   for (int i = 1; i <= LumiEv->GetXaxis()->GetNbins(); i++) {
0212     if (LumiEv->GetBinContent(i)) {
0213       MaxLum = i;
0214     }
0215   }
0216   cout << " Nev in bin of MaxLum =     " << MaxLum0 << " MaxLum=     " << MaxLum << endl;
0217 
0218   //  gPad->SetGridy();
0219   //  gPad->SetGridx();
0220   gPad->SetLogy();
0221   //            gPad->SetLogx();
0222   LumiEv->GetYaxis()->SetLabelSize(0.04);
0223   LumiEv->SetTitle("Number of events per LS");
0224   LumiEv->SetXTitle("LS");
0225   LumiEv->SetYTitle("Number of events ");
0226   LumiEv->SetMarkerStyle(21);
0227   LumiEv->SetMarkerSize(0.8);
0228   LumiEv->SetMarkerColor(4);
0229   LumiEv->SetLineColor(0);
0230   LumiEv->SetMinimum(0.8);
0231   LumiEv->GetXaxis()->SetRangeUser(0, MaxLum + 5.);
0232   LumiEv->Draw("Error");
0233 
0234   c1->Update();
0235   //  cHB->Print("LumiEvent.png");
0236   //  cHB->Clear();
0237 
0238   //========================================================================================== 2
0239   //======================================================================
0240   //======================================================================
0241   //================
0242   //======================================================================
0243 
0244   //      h_lsnumber_per_eachLS->Fill(float(lscounter), float(lumi));
0245   //        h_nevents_per_eachLS->Fill(float(lscounter), float(nevcounter));  //
0246   //        h_nls_per_run->Fill(float(lscounterrun));
0247   //        h_nevents_per_eachRealLS->Fill(float(lscounterM1), float(nevcounter));  //
0248   //      h_nevents_per_LS->Fill(float(nevcounter));
0249   //      h_nevents_per_LSzoom->Fill(float(nevcounter));
0250   //        h_nls_per_run10->Fill(float(lscounterrun10));
0251 
0252   c1->Clear();
0253   c1->Divide(2, 4);
0254 
0255   c1->cd(1);
0256   TH1F *MilMil = (TH1F *)dir->FindObjectAny("h_lsnumber_per_eachLS");
0257   int MaxMilDanila = MilMil->GetBinContent(MilMil->GetMaximumBin());  // old variant of Danila
0258   cout << " MaxMilDanila=     " << MaxMilDanila << endl;
0259   //    gPad->SetGridy();
0260   //    gPad->SetGridx();
0261   MilMil->GetYaxis()->SetLabelSize(0.04);
0262   MilMil->SetTitle("Cont. number per LS  \b");
0263   MilMil->SetXTitle("Cont.number \b");
0264   MilMil->SetYTitle("Ls \b");
0265   MilMil->SetMarkerStyle(20);
0266   MilMil->SetMarkerSize(0.2);
0267   MilMil->SetMarkerColor(4);
0268   MilMil->SetLineColor(0);
0269   MilMil->SetMinimum(0.8);
0270   MilMil->GetXaxis()->SetRangeUser(0, MaxMilDanila);
0271   MilMil->Draw("Error");
0272 
0273   c1->cd(2);
0274   TH1F *MiliEv = (TH1F *)dir->FindObjectAny("h_nevents_per_eachLS");
0275   int MaxMil0 = MiliEv->GetBinContent(MiliEv->GetMaximumBin());
0276   int MaxMil = 0;
0277   for (int i = 1; i <= MiliEv->GetXaxis()->GetNbins(); i++) {
0278     if (MiliEv->GetBinContent(i)) {
0279       MaxMil = i;
0280     }
0281   }
0282   cout << " MaxMil0=     " << MaxMil0 << " MaxMil=     " << MaxMil << endl;
0283 
0284   //    gPad->SetGridy();
0285   //    gPad->SetGridx();
0286   gPad->SetLogy();
0287   //            gPad->SetLogx();
0288   MiliEv->GetYaxis()->SetLabelSize(0.04);
0289   MiliEv->SetTitle("Number of events per LS");
0290   MiliEv->SetXTitle("LS");
0291   MiliEv->SetYTitle("Number of events ");
0292   MiliEv->SetMarkerStyle(20);
0293   MiliEv->SetMarkerSize(0.2);
0294   MiliEv->SetMarkerColor(4);
0295   MiliEv->SetLineColor(0);
0296   //      MiliEv->SetMinimum(0.8);
0297   MiliEv->GetXaxis()->SetRangeUser(0, MaxMil);
0298   MiliEv->Draw("Error");
0299 
0300   c1->cd(3);
0301   TH1F *GiriEv = (TH1F *)dir->FindObjectAny("h_nls_per_run");
0302   int MaxGir0 = GiriEv->GetBinContent(GiriEv->GetMaximumBin());
0303   int MaxGir = 0;
0304   for (int i = 1; i <= GiriEv->GetXaxis()->GetNbins(); i++) {
0305     if (GiriEv->GetBinContent(i)) {
0306       MaxGir = i;
0307     }
0308   }
0309   cout << "nls_per_run =     " << MaxGir0 << " Maxnls_per_run=     " << MaxGir << endl;
0310 
0311   //    gPad->SetGridy();
0312   //    gPad->SetGridx();
0313   //  gPad->SetLogy();
0314   //            gPad->SetLogx();
0315   GiriEv->GetYaxis()->SetLabelSize(0.04);
0316   GiriEv->SetTitle("Number of LS per run");
0317   GiriEv->SetXTitle("irun");
0318   GiriEv->SetYTitle("Number of LS ");
0319   GiriEv->SetMarkerStyle(20);
0320   GiriEv->SetMarkerSize(0.8);
0321   GiriEv->SetMarkerColor(4);
0322   GiriEv->SetLineColor(0);
0323   //      GiriEv->SetMinimum(0.8);
0324   GiriEv->GetXaxis()->SetRangeUser(0, MaxGir);
0325   GiriEv->Draw("Error");
0326 
0327   c1->cd(4);
0328   TH1F *SumiEv = (TH1F *)dir->FindObjectAny("h_nevents_per_eachRealLS");
0329   int MaxSum0 = SumiEv->GetBinContent(SumiEv->GetMaximumBin());
0330   int MaxSum = 0;
0331   for (int i = 1; i <= SumiEv->GetXaxis()->GetNbins(); i++) {
0332     if (SumiEv->GetBinContent(i)) {
0333       MaxSum = i;
0334     }
0335   }
0336   cout << " MaxSum0=     " << MaxSum0 << " MaxSum=     " << MaxSum << endl;
0337 
0338   gPad->SetGridy();
0339   gPad->SetGridx();
0340   gPad->SetLogy();
0341   //            gPad->SetLogx();
0342   SumiEv->GetYaxis()->SetLabelSize(0.04);
0343   SumiEv->SetTitle("Number of events per RealLS");
0344   SumiEv->SetXTitle("LS");
0345   SumiEv->SetYTitle("Number of events ");
0346   SumiEv->SetMarkerStyle(20);
0347   SumiEv->SetMarkerSize(0.2);
0348   SumiEv->SetMarkerColor(4);
0349   SumiEv->SetLineColor(0);
0350   //      SumiEv->SetMinimum(0.8);
0351   SumiEv->GetXaxis()->SetRangeUser(0, MaxSum);
0352   SumiEv->Draw("Error");
0353 
0354   c1->cd(5);
0355   TH1F *TiriEv = (TH1F *)dir->FindObjectAny("h_nevents_per_LS");
0356   int MaxTir0 = TiriEv->GetBinContent(TiriEv->GetMaximumBin());
0357   int MaxTir = 0;
0358   for (int i = 1; i <= TiriEv->GetXaxis()->GetNbins(); i++) {
0359     if (TiriEv->GetBinContent(i)) {
0360       MaxTir = i;
0361     }
0362   }
0363   cout << " MaxTir0=     " << MaxTir0 << " MaxTir=     " << MaxTir << endl;
0364 
0365   TiriEv->GetYaxis()->SetLabelSize(0.04);
0366   TiriEv->SetTitle("Number of events per LS");
0367   TiriEv->SetXTitle("LS");
0368   TiriEv->SetYTitle("Number of events ");
0369   TiriEv->SetMarkerStyle(20);
0370   TiriEv->SetMarkerSize(0.8);
0371   TiriEv->SetMarkerColor(4);
0372   TiriEv->SetLineColor(0);
0373   //      TiriEv->SetMinimum(0.8);
0374   TiriEv->GetXaxis()->SetRangeUser(0, MaxTir);
0375   TiriEv->Draw("Error");
0376 
0377   c1->cd(6);
0378   TH1F *MasiEv = (TH1F *)dir->FindObjectAny("h_nevents_per_LSzoom");
0379   int MaxMas0 = MasiEv->GetBinContent(MasiEv->GetMaximumBin());
0380   int MaxMas = 0;
0381   for (int i = 1; i <= MasiEv->GetXaxis()->GetNbins(); i++) {
0382     if (MasiEv->GetBinContent(i)) {
0383       MaxMas = i;
0384     }
0385   }
0386   cout << " MaxMas0=     " << MaxMas0 << " MaxMas=     " << MaxMas << endl;
0387 
0388   MasiEv->GetYaxis()->SetLabelSize(0.04);
0389   MasiEv->SetTitle("Number of events per LS");
0390   MasiEv->SetXTitle("LS");
0391   MasiEv->SetYTitle("Number of events ");
0392   MasiEv->SetMarkerStyle(20);
0393   MasiEv->SetMarkerSize(0.8);
0394   MasiEv->SetMarkerColor(4);
0395   MasiEv->SetLineColor(0);
0396   //      MasiEv->SetMinimum(0.8);
0397   MasiEv->GetXaxis()->SetRangeUser(0, MaxMas);
0398   MasiEv->Draw("Error");
0399 
0400   c1->cd(7);
0401   TH1F *LediEv = (TH1F *)dir->FindObjectAny("h_nls_per_run10");
0402   int MaxLed0 = LediEv->GetBinContent(LediEv->GetMaximumBin());
0403   int MaxLed = 0;
0404   for (int i = 1; i <= LediEv->GetXaxis()->GetNbins(); i++) {
0405     if (LediEv->GetBinContent(i)) {
0406       MaxLed = i;
0407     }
0408   }
0409   cout << " NlsPERrun=     " << MaxLed0 << " MaxbinHisto=     " << MaxLed << endl;
0410 
0411   LediEv->GetYaxis()->SetLabelSize(0.04);
0412   LediEv->SetTitle("Number of ls(ev>10) per run");
0413   LediEv->SetXTitle("run");
0414   LediEv->SetYTitle("Number of ls ");
0415   LediEv->SetMarkerStyle(20);
0416   LediEv->SetMarkerSize(0.8);
0417   LediEv->SetMarkerColor(4);
0418   LediEv->SetLineColor(0);
0419   //      LediEv->SetMinimum(0.8);
0420   LediEv->GetXaxis()->SetRangeUser(0, MaxLed);
0421   LediEv->Draw("Error");
0422 
0423   c1->Update();
0424 
0425   //======================================================================
0426   //==================================================================================================== end
0427   //======================================================================
0428   //======================================================================
0429   // close and delete all possible things:
0430 
0431   //   psfile->Close();
0432   psfile.Close();
0433 
0434   hfile1->Close();
0435   //    hfile1->Delete();
0436   hfile1->Close();
0437   //    hfile1->Delete();
0438 
0439   //  Exit Root
0440   gSystem->Exit(0);
0441   //======================================================================
0442 }