AliPhysics  aaf9c62 (aaf9c62)
CheckNoisePeakVariationWithTimeCut.C
Go to the documentation of this file.
1 
11 #include <stdio.h>
12 #include <TSystem.h>
13 #include <TString.h>
14 #include <TH1.h>
15 #include "TPostScript.h"
16 #include "TH2.h"
17 #include "TStyle.h"
18 #include "TCanvas.h"
19 #include "TFile.h"
20 #include "TMath.h"
21 #include "TList.h"
22 #include "TAxis.h"
23 #include "TPad.h"
24 #include "TLegend.h"
25 #include "TLatex.h"
26 #include "TF1.h"
27 #include "TList.h"
28 #include "TLine.h"
29 
30 //#include "/Users/vauthier/root/macros/myMacros/MyPaletteColor.c" //------------->Have a nice "colz" plot
31 //#include "/Users/vauthier/root/macros/myMacros/ErrorPropagation.c" //------------->Implemented formula for error propagation
32 //#include "/Users/vauthier/root/macros/myMacros/SettingsUtils.cpp" //------------->Settings for canvas and histos
33 
34 
36 {
37  //Declare needed variables - histos - files
38  const int nTimeCut = 2;
39  TString TimeCut[nTimeCut] = {"LooseTimeCut_NoNegCoeffs","_NoNegCoeffs"};
40  const int nSM = 20;
41  const int nCol = 48;
42  const int nRow = 24;
43 
44  int nColForSM = 48;
45  int nRowForSM = 24;
46 
47  TFile *file[nTimeCut];
48  TList *list[nTimeCut];
49  TH1F *hMgg[nSM][nCol][nRow][nTimeCut];
50 
51 // TFile *rootFileOut = new TFile("output_calibPi0.root","RECREATE");
52  char psfile[100];
53  sprintf(psfile,"NoisePeakVariationNoTimeCut.ps");
54  const int cWidth=500;
55  const int cHeight=(int)(500*(29./21.));
56  TCanvas *c1 = new TCanvas("c1","Noise peaks variation as a function of time cuts",cWidth,cHeight);
57  TPostScript *ps = new TPostScript(psfile,111);
58 
59  Color_t HistoColor[nTimeCut] = {kMagenta,kBlack};
60 
61 
62 
63  for(int iTimeCut = 0; iTimeCut < nTimeCut; iTimeCut++)
64  {
65  printf("--\nOPEN FILE %sTimeCutApplied\n",TimeCut[iTimeCut].Data());
66  file[iTimeCut] = new TFile(Form("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass4/AnalysisResults_LHC15sumijMaskTowersByHand24Nov2016_pass4%s.root",TimeCut[iTimeCut].Data()));
67  list[iTimeCut] = (TList*) file[iTimeCut]->Get("Pi0Calibration_Trig");
68  }//End loop on time cut
69 
70 
71  TFile *fOut = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass4_DCALandEMCALThirds/NoisePeakVariationNoTimeCut.root","RECREATE");
72 
73  for(int iSM = 0; iSM < nSM; iSM++)
74  {
75  printf("\nProcessing SM %i ...\n",iSM);
76  if((iSM == 10) || (iSM == 11) || (iSM == 18) || (iSM == 19)) nRowForSM = 8;
77  else nRowForSM = 24;
78  if((iSM > 11) && ((iSM != 18) && (iSM != 19))) nColForSM = 32;
79  else nColForSM = 48;
80  for(int iCol = 0; iCol < nColForSM; iCol++)
81  {
82  for(int iRow = 0; iRow < nRowForSM; iRow++)
83  {
84  if(iRow%(nRow/2) == 0)
85  {
86  ps->NewPage();
87  c1->Clear();
88  c1->Divide(3,4);
89  }
90  c1->cd(iRow%(nRow/2)+1);
91  for(int iTimeCut = 0; iTimeCut < nTimeCut; iTimeCut++)
92  {
93  hMgg[iSM][iCol][iRow][iTimeCut] = (TH1F*) list[iTimeCut]->FindObject(Form("%i_%i_%i",iSM,iCol,iRow));
94  hMgg[iSM][iCol][iRow][iTimeCut]->SetLineColor(HistoColor[iTimeCut]);
95  hMgg[iSM][iCol][iRow][iTimeCut]->SetMarkerColor(HistoColor[iTimeCut]);
96  hMgg[iSM][iCol][iRow][iTimeCut]->SetXTitle("m_{#gamma#gamma} (MeV/c^{2})");
97 // SetHisto(hMgg[iSM][iCol][iRow][iTimeCut],HistoColor[iTimeCut],20,"","m_{#gamma#gamma} (MeV/c^{2})","");
98  if(iTimeCut == 0)hMgg[iSM][iCol][iRow][iTimeCut]->Draw("");
99  else hMgg[iSM][iCol][iRow][iTimeCut]->Draw("same");
100  hMgg[iSM][iCol][iRow][iTimeCut]->Write(Form("%i_%i_%i_%s",iSM,iCol,iRow,TimeCut[iTimeCut].Data()));
101  }//End loop on time cut
102  c1->Update();
103  }//End loop on row
104  }//End loop on column
105  printf("... SM %i done\n",iSM);
106  }//End loop on SM
107 
108  fOut->Write();
109  fOut->Close();
110  ps->Close();
111 
112  return;
113 }
void CheckNoisePeakVariationWithTimeCut()
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
TObject * FindObject(int bin, const char *nameH, const TList *lst, Bool_t normPerEvent=kTRUE)
TFile * file
TList with histograms for a given trigger.