AliPhysics  608b256 (608b256)
DrawM02PhotonPi0BandLimits.C
Go to the documentation of this file.
1 
10 //---------------------------------------------------------
11 // Set includes and declare methods for compilation
12 
13 #if !defined(__CINT__) || defined(__MAKECINT__)
14 
15 #include <TFile.h>
16 #include <TDirectoryFile.h>
17 #include <TList.h>
18 #include <TString.h>
19 #include <TROOT.h>
20 #include <TStyle.h>
21 #include <TH2F.h>
22 #include <TCanvas.h>
23 #include <TPad.h>
24 #include <TLegend.h>
25 #include <TObject.h>
26 #include <TAxis.h>
27 #include <TGaxis.h>
28 #include <TLine.h>
29 #include <TF1.h>
30 #include <TMath.h>
31 #include <TLatex.h>
32 #include <TPaveText.h>
33 
34 #endif
35 
44 (
45  TString filepath = "data/",
46  TString filename = "LHC11cd_EMC7",
47  TString dirname = "",
48  TString listname = "",
49  TString histoname = "AnaPhoton_hLam0E"
50 )
51 {
52  gStyle->SetOptTitle(0);
53  gStyle->SetTitleOffset(2.0,"Y");
54  gStyle->SetOptStat(0);
55  gStyle->SetOptFit(000000);
56  gStyle->SetPadRightMargin(0.17);
57  gStyle->SetPadLeftMargin(0.08);
58  gStyle->SetPadTopMargin(0.02);
59  //gStyle->SetPadBottomMargin(0.15);
60 
61  //
62  // Open file and get histogram
63  //
64  TFile * file = TFile::Open(Form("%s/%s.root",filepath.Data(),filename.Data()));
65  if ( !file ) { printf("No file %s\n",filename.Data()) ; return ; }
66 
67  TH2F * hM02 = 0;
68 
69  if ( dirname!="" )
70  {
71  TDirectoryFile * dir = (TDirectoryFile *) file->Get(dirname);
72  if ( !dir ) { printf("No directory %s\n", dirname .Data()) ; return ; }
73 
74  TList * list = (TList*) dir->Get(listname);
75  if ( !list ) { printf("No list %s\n" , listname.Data()) ; return ; }
76 
77  hM02 = (TH2F*) list->FindObject(histoname);
78  }
79  else if ( listname!="" )
80  {
81  TList * list = (TList*) file->Get(listname);
82  if ( !list ) { printf("No list %s\n" , listname.Data()) ; return ; }
83 
84  hM02 = (TH2F*) list->FindObject(histoname);
85  }
86  else
87  hM02 = (TH2F*) file->Get(histoname);
88 
89  //
90  // Normalize 2D to bin energy
91  //
92  Int_t nbinsy = hM02->GetNbinsY();
93  for(Int_t j = 1; j <= hM02->GetNbinsX(); j++)
94  {
95  TH1D* temp1 = hM02->ProjectionY(Form("Bin%d",j),j,j);
96 
97  Float_t scale1 = temp1 -> Integral(-1,-1);
98 
99  for(Int_t i = 1; i <= nbinsy; i++)
100  {
101  //printf("NLM2: i %d, j %d; content %f / scale %f = %f\n",i,j,hNLM2->GetBinContent(j,i),scale2,hNLM2->GetBinContent(j,i)/scale2);
102  if(scale1>0)
103  {
104  hM02->SetBinContent(j,i, hM02->GetBinContent(j,i)/scale1);
105  hM02->SetBinError (j,i, hM02->GetBinError (j,i)/scale1);
106  }
107  else
108  {
109  hM02->SetBinContent(j,i, 0);
110  hM02->SetBinError (j,i, 0);
111  }
112  }
113  }
114 
115  //
116  // Selection band min/max lines
117  // Based on AN145: https://alice-notes.web.cern.ch/node/145
118  //
119  TF1 *lM02MinNLM1 = new TF1("M02MinNLM1","exp(2.135-0.245*x)",6,13.6);
120  lM02MinNLM1->SetLineColor(6);
121  lM02MinNLM1->SetLineWidth(3);
122 
123  TF1 *lM02MinNLM2 = new TF1("M02MinNLM2","exp(2.135-0.245*x)",6,13.6);
124  lM02MinNLM2->SetLineColor(6);
125  lM02MinNLM2->SetLineWidth(3);
126 
127  TF1 *lM02MaxNLM1 = new TF1("M02MaxNLM1","exp(0.0662-0.0201*x)-0.0955+0.00186*x[0]+9.91/x[0]",6,100);
128  lM02MaxNLM1->SetLineColor(6);
129  lM02MaxNLM1->SetLineWidth(3);
130 
131  TF1 *lM02MaxNLM2 = new TF1("M02MaxNLM2","exp(0.353-0.0264*x)-0.524+0.00559*x[0]+21.9/x[0]",6,100);
132  lM02MaxNLM2->SetLineColor(6);
133  lM02MaxNLM2->SetLineWidth(3);
134 
135  TLine *l03 = new TLine(13.5,0.3,40,0.3);
136  l03->SetLineColor(6);
137  l03->SetLineWidth(3);
138  l03->SetLineStyle(1);
139 
140  TLine *lGammaMax = new TLine(5,0.27,40,0.27);
141  lGammaMax->SetLineColor(kRed);
142  lGammaMax->SetLineWidth(3);
143  lGammaMax->SetLineStyle(2);
144 
145  TLine *lGammaMin = new TLine(5,0.1,40,0.1);
146  lGammaMin->SetLineColor(kRed);
147  lGammaMin->SetLineWidth(3);
148  lGammaMin->SetLineStyle(2);
149 
150  //
151  // Plot
152  //
153  TCanvas * c = new TCanvas("cM02","M02",500,500);
154 
155  gPad->SetLogz();
156 
157  //hM02->Rebin2D(1,1);
158  hM02->SetAxisRange(5,40,"X");
159  hM02->SetAxisRange(0,2.4,"y");
160  hM02->SetZTitle("#it{E} bin normalized to integral");
161  hM02->SetXTitle("#it{E} (GeV)");
162  hM02->SetYTitle("#sigma^{2}_{long}");
163  hM02->SetTitleOffset(1.5,"Z");
164  hM02->SetTitleOffset(1.05,"Y");
165 
166  hM02->Draw("colz");
167 
168  lM02MinNLM1->Draw("same");
169  //lM02MinNLM2->Draw("same");
170  //lM02MaxNLM1->Draw("same");
171  lM02MaxNLM2->Draw("same");
172  l03->Draw("same");
173  lGammaMin->Draw("same");
174  lGammaMax->Draw("same");
175 
176  TLegend *l2 = new TLegend(0.5,0.65,0.77,0.75);
177  l2->SetTextSize(0.035);
178  l2->AddEntry(lM02MaxNLM1,"#pi^{0} band limits","L");
179  l2->AddEntry(lGammaMin,"#gamma band limits","L");
180  l2->SetLineColor(0);
181 
182  l2->Draw();
183 
184  TPaveText *pt = new TPaveText(0.45,0.77,0.82,0.97,"brNDC");
185  pt->SetTextSize(0.035);
186  pt->AddText("pp, #sqrt{#it{s}} = 7 TeV");
187  pt->AddText("EMCal-L0 trigger");
188  //pt->AddLine(.0,.5,1.,.5);
189 // pt->AddText("ALICE Performance");
190 // pt->AddText("08.09.2016");
191  pt->SetFillColor(kWhite);
192  pt->SetLineColor(1);
193  pt->Draw("same");
194 
195  c->Print("M02_BandLimits.eps");
196  //c->Print(Form("%s/M02_BandLimits_%s.eps",filepath.Data(),filename.Data()));
197 }
const char * filename
Definition: TestFCM.C:1
Definition: External.C:236
Int_t nbinsy
TCanvas * c
Definition: TestFitELoss.C:172
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
Definition: External.C:212
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)
void DrawM02PhotonPi0BandLimits(TString filepath="data/", TString filename="LHC11cd_EMC7", TString dirname="", TString listname="", TString histoname="AnaPhoton_hLam0E")
TFile * file
TList with histograms for a given trigger.
TDirectoryFile * dir