]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/STRANGENESS/LambdaK0PbPb/DrawSpectraAndRatios.C
Implementing Physics Forum's suggestions
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / LambdaK0PbPb / DrawSpectraAndRatios.C
CommitLineData
8312043c 1#if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TMath.h>
3 #include <TROOT.h>
4 #include <Riostream.h>
5 #include <TCanvas.h>
6 #include <TColor.h>
7 #include <TLatex.h>
8 #include <TLegend.h>
c42feec6 9 #include <TLegendEntry.h>
8312043c 10
11 #include <TStyle.h>
12 #include <TString.h>
13 #include <TASImage.h>
14
15 #include <TFile.h>
16 #include <TList.h>
17 #include <TH1F.h>
18 #include <TH1D.h>
19 #include <TF2.h>
20 #include <TFitResult.h>
21 #include <TFitResultPtr.h>
22 #include <TH2F.h>
23 #include <TH3F.h>
24#endif
25
26extern TStyle *gStyle;
27
28static Double_t xBins[]={
29 0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,
30 1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,
31 2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,
32 4.5,5.0,5.5,6.5,8.0,10.0,12.0
8312043c 33};
ac30a56c 34const Int_t nBins=sizeof(xBins)/sizeof(Double_t) - 1; //37
8312043c 35
36static Bool_t gFlag=kFALSE;
37
e9829c0a 38//*** The systematic uncertainties for combining
276ae8a8 39// TPC crossed/findable
e9829c0a 40// cos(PA)
41// DCA between V0 daughters
276ae8a8 42// TPC crossed pad rows
ac30a56c 43// DCA daughters <-> PV
44// c*tau
45static
46Double_t sysEffK0s[nBins]={//Efficiency, combined over cuts mentioned above
e9829c0a 47 0.0,
48 0.05,0.05,0.04,0.03, //Dominated by cos(PA)
49 0.04,0.05,0.06,0.07,0.08,0.09, //Dominated by TPC crossed/findable
50 0.10,0.10,0.11,0.12,0.12,0.13,0.13,0.13,0.14,0.14,0.14,
51 0.14,0.13,0.13,0.12,0.11,0.11,0.11,0.10,0.09,0.08,
64e44a1a 52 0.08,0.05,0.04,0.03,0.03
8312043c 53};
3b008149 54/*
ac30a56c 55static Double_t sysSigK0s[nBins]={//Signal extraction
56 0.00728589, 0.00728589, 0.00728539, 0.0073469, 0.00737846, 0.00741705,
57 0.00750887, 0.00753641, 0.00769012, 0.00789154, 0.00796624, 0.00822856,
58 0.00838203, 0.00864603, 0.00906498, 0.00923208, 0.00931179, 0.0100081,
59 0.0100768, 0.0105292, 0.0112067, 0.0122143, 0.0130162, 0.0139799, 0.0155215,
60 0.0158903, 0.0168517, 0.0189316, 0.0188103, 0.020233, 0.0223704, 0.0260327,
61 0.0260327, 0.0260327, 0.0260327, 0.0260327, 0.0260327
62};
3b008149 63*/
64static Double_t sysSigK0s[nBins]={//Signal extraction
65 0.03, 0.03, 0.03, 0.03, 0.03, 0.03,
66 0.03, 0.03, 0.03, 0.03, 0.03, 0.03,
67 0.03, 0.03, 0.03, 0.03, 0.03, 0.03,
68 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03,
69 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03,
70 0.03, 0.03, 0.03, 0.03, 0.03
71};
ac30a56c 72
73static
74Double_t sysEffLam[nBins]={//Efficiency, combined over cuts mentioned above
276ae8a8 75 0.0,0.0,0.0,
be8a43e6 76 0.20,0.12,0.05, //Dominated by cos(PA)+FD
77 0.06,0.06,0.06,0.06,0.06, //Dominated by c*tau
78 0.06,0.06, //Dominated by TPC crossed/findable
276ae8a8 79 0.07,0.09,0.09,0.10,0.10,0.11,0.11,0.11,0.10,0.10,0.09,
80 0.08,0.08,0.07,0.07,0.07,0.06,0.07,0.06,0.07,0.05,
ac30a56c 81 0.06,0.08,0.04
82};
83static Double_t sysSigLam[nBins]={//Signal extraction
84 0.0447214, 0.0447214, 0.0447214, 0.0447214, 0.0447214,
85 0.0447214, 0.0447214, 0.0447214, 0.0447214, 0.0447214,
86 0.0447214, 0.0447214, 0.0447214, 0.0447214, 0.0447214,
87 0.0447214, 0.0447214, 0.0447214, 0.0447214, 0.0447214,
88 0.0447214, 0.0447214, 0.0447214, 0.0447214, 0.0447214,
89 0.0447214, 0.0447214, 0.0447214, 0.0447214, 0.0465862,
90 0.0472600, 0.0488576, 0.0526797, 0.0575355, 0.0651647,
91 0.0721110, 0.072111
276ae8a8 92};
ac30a56c 93
e9829c0a 94const Double_t sysPID=0.02; //PID
e9829c0a 95const Double_t sysArm=0.01; //Armenteros cut
f99cb92a 96const Double_t sysFD=0.05; //Feed down
8312043c 97
3b008149 98const Double_t fdCorr=0.81; //Feed down correction value
99
8312043c 100
101TH1 *MapHisto(const TH1 *h) {
102 const Double_t eps=0.0001;
103 TString name("m");
104 name = name + h->GetName();
105 TH1F *mh=new TH1F(name.Data(),h->GetTitle(),nBins,xBins);
c42feec6 106 mh->GetXaxis()->SetTitle("p_{t} (GeV/c)");
107 mh->GetYaxis()->SetTitle("1/N_{ev}d^{2}N/dp_{t}/dy (GeV/c)^{-1}");
8312043c 108
109 Double_t xh=h->GetBinCenter(1), xmh=0.;
110
111 Int_t n=1;
112 for (; n<=nBins; n++) {
113 xmh=mh->GetBinCenter(n);
114 if (TMath::Abs(xh-xmh)<eps) break;
115 }
116
117 Int_t iii=h->GetNbinsX();
3b008149 118 //if (gFlag) iii--;
8312043c 119 for (Int_t i=1; i<=iii; i++) {
120 Int_t ni1=n+i-1;
121
122 if (ni1 > nBins) {
123 cerr<<"Input number of bins is larger than the output number of bins!\n";
124 delete mh;
125 return 0;
126 }
127
128 xh = h->GetBinCenter(i);
129 xmh=mh->GetBinCenter(ni1);
130 if (TMath::Abs(xh-xmh)>eps) {
131 cerr<<"Wrong binning !\n";
132 delete mh;
133 return 0;
134 }
135
136 Double_t c=h->GetBinContent(i);
137 Double_t e=h->GetBinError(i);
138 mh->SetBinContent(ni1,c);
139 mh->SetBinError(ni1,e);
140 }
141
142 return mh;
143}
144
145Bool_t
146GetHistos(const Char_t *rName[], const Char_t *eName[], TH1 *&raw, TH1 *&eff) {
147
148 /*TFile *fr=*/TFile::Open(rName[0]);
3b008149 149 //TList *lst=(TList*)gFile->Get("c1DataYields");
150 TList *lst=(TList*)gFile->Get("cLK0Spectra");
151
8312043c 152 raw=(TH1F*)lst->FindObject(rName[1]);
153 if (!raw) {
154 cerr<<"No raw yield !"<<eName[0]<<' '<<eName[1]<<endl;
155 return kFALSE;
156 }
3b008149 157
158 ///*TFile *fe=*/TFile::Open(eName[0]);
159 //eff=(TH1F*)gFile->Get(eName[1]);
160 eff=(TH1F*)lst->FindObject(eName[1]);
8312043c 161 if (!eff) {
162 cerr<<"No efficiency ! "<<eName[0]<<' '<<eName[1]<<endl;
163 return kFALSE;
164 }
165 return kTRUE;
166}
167
f99cb92a 168void SetAttributes(TH1 *h,const Char_t *tit,Int_t col,Int_t mar,Float_t siz,
169Float_t max=1000., Float_t min=1e-6, Float_t factor=1, Int_t range=nBins) {
8312043c 170 h->SetTitle(tit);
171 h->SetLineColor(col);
172 h->SetMarkerColor(col);
173 h->SetMarkerStyle(mar);
174 h->SetMarkerSize(siz);
f99cb92a 175 h->Scale(factor);
176 h->SetMaximum(max);
177 h->SetMinimum(min);
178 h->GetXaxis()->SetRange(1,range);
8312043c 179}
180
ac30a56c 181void
182DrawHisto(TH1 *h, const Option_t *option, Double_t *sysEff, Double_t *sysSig) {
8312043c 183 TH1F *hh=new TH1F(*((TH1F*)h));
184 Int_t nb=hh->GetNbinsX();
3b008149 185
8312043c 186 for (Int_t i=1; i<=nb; i++) {
187 Double_t c=hh->GetBinContent(i);
188 Double_t e=hh->GetBinError(i);
64e44a1a 189 Int_t j=i-1;
190 e = sysEff[j]*sysEff[j] + sysSig[j]*sysSig[j];
ac30a56c 191
f99cb92a 192 if (sysEff==sysEffLam) {// for Lambda
193 e += sysFD*sysFD;
194 if (i<13) e += sysPID*sysPID;
195 } else {// for K0s
196 e += sysArm*sysArm;
197 }
198
199 e=c*TMath::Sqrt(e);
ac30a56c 200
8312043c 201 hh->SetBinError(i,e);
202 }
203 hh->SetFillColor(17);
204 TString opt("E5"); opt+=option;
205 //TString opt("E2"); opt+=option;
206 hh->Draw(opt.Data());
207 h->Draw("e x0 same");
208}
209
210void DrawALICELogo(Float_t x1, Float_t y1, Float_t x2, Float_t y2)
211{
212// Correct for aspect ratio of figure plus aspect ratio of pad.
213// Coordinates are NDC!
214
215 x2 = x1 + (y2 - y1)*0.891*gPad->GetCanvas()->GetWindowHeight()*gPad->GetHNDC() / (gPad->GetWNDC() * gPad->GetCanvas()->GetWindowWidth());
216
217 TPad *myPadLogo = new TPad("myPadLogo","Pad for ALICE Logo", x1, y1, x2, y2);
218 myPadLogo->SetLeftMargin(0);
219 myPadLogo->SetTopMargin(0);
220 myPadLogo->SetRightMargin(0);
221 myPadLogo->SetBottomMargin(0);
222 myPadLogo->Draw();
223 myPadLogo->cd();
224 TASImage *myAliceLogo =
225 new TASImage("alice_logo_preliminary.eps");
226 myAliceLogo->Draw("same");
227}
228
3b008149 229void DrawFit(const Char_t *nam[], const Float_t *fac, Int_t n){
230 for (Int_t i=0; i<n; i++) {
231 const Char_t *name=nam[i];
232 Float_t factor=fac[i];
233 TF1 *f=(TF1*)gROOT->FindObject(name);
234 TH1 *h=f->GetHistogram();
235 h->Scale(factor);
236 h->SetLineColor(1);
237 h->SetLineWidth(1);
238 h->SetLineStyle(1);
239 h->Draw("Lsame");
240 }
241}
8312043c 242
243void DrawSpectraAndRatios() {
244
3b008149 245 const Int_t nCent=6;
246 const Int_t nCent1=nCent-1;
8312043c 247
248 const Char_t *title[nCent]={
3b008149 249 "0-10 %",
250 "10-20 %",
251 "20-40 %, x1.2",
252 "40-60 %, x2.0",
253 "60-80 %, x3.0",
8312043c 254 "80-90 %"
255 };
3b008149 256 const Int_t colour[nCent]={2, 635, 419, 4 , 6, 1 };
257 const Int_t marker[nCent]={22, 34, 21, 23, 33, 20 };
258 const Float_t masize[nCent]={1.6, 1.3, 1.3, 1.6,2, 1.3};
259 const Float_t factor[nCent]={1.0, 1.0, 1.2, 2.0,3.0,0.0}; //scale for drawing
8312043c 260
261 const Char_t *rNameL[2*nCent]={ // file name, histo name
3b008149 262 "LK0Spectra_WeightMean_100712.root", "Data_La_0010",
263 "LK0Spectra_WeightMean_100712.root", "Data_La_1020",
264 "LK0Spectra_WeightMean_100712.root", "Data_La_2040",
265 "LK0Spectra_WeightMean_100712.root", "Data_La_4060",
266 "LK0Spectra_WeightMean_100712.root", "Data_La_6080",
267 "LK0Spectra_WeightMean_100712.root", "Data_La_8090"
8312043c 268 };
269 const Char_t *eNameL[2*nCent]={ // file name, histo name
3b008149 270 "LK0Spectra_WeightMean_100712.root", "Efficiency_La_0010",
271 "LK0Spectra_WeightMean_100712.root", "Efficiency_La_1020",
272 "LK0Spectra_WeightMean_100712.root", "Efficiency_La_2040",
273 "LK0Spectra_WeightMean_100712.root", "Efficiency_La_4060",
274 "LK0Spectra_WeightMean_100712.root", "Efficiency_La_6080",
275 "LK0Spectra_WeightMean_100712.root", "Efficiency_La_8090"
8312043c 276 };
3b008149 277
8312043c 278 const Char_t *rNameK[2*nCent]={ // file name, histo name
3b008149 279 "LK0Spectra_WeightMean_100712.root", "Data_K0_0010",
280 "LK0Spectra_WeightMean_100712.root", "Data_K0_1020",
281 "LK0Spectra_WeightMean_100712.root", "Data_K0_2040",
282 "LK0Spectra_WeightMean_100712.root", "Data_K0_4060",
283 "LK0Spectra_WeightMean_100712.root", "Data_K0_6080",
284 "LK0Spectra_WeightMean_100712.root", "Data_K0_8090"
8312043c 285 };
286 const Char_t *eNameK[2*nCent]={ // file name, histo name
3b008149 287 "LK0Spectra_WeightMean_100712.root", "Efficiency_K0_0010",
288 "LK0Spectra_WeightMean_100712.root", "Efficiency_K0_1020",
289 "LK0Spectra_WeightMean_100712.root", "Efficiency_K0_2040",
290 "LK0Spectra_WeightMean_100712.root", "Efficiency_K0_4060",
291 "LK0Spectra_WeightMean_100712.root", "Efficiency_K0_6080",
292 "LK0Spectra_WeightMean_100712.root", "Efficiency_K0_8090"
8312043c 293 };
294
8312043c 295 gStyle->SetOptStat(0);
296 gStyle->SetOptTitle(0);
297 gStyle->SetLegendFillColor(0);
298
299 TH1 *raw=0;
300 TH1 *eff=0;
301 TString option(""), ratio("ratio");
302
303 TCanvas *c1=new TCanvas; c1->SetLogy();
304 c1->SetLeftMargin(0.13); c1->SetBottomMargin(0.13);
f99cb92a 305 TCanvas *c1lin=new TCanvas;
306 c1lin->SetLeftMargin(0.13); c1lin->SetBottomMargin(0.13);
8312043c 307
308 TCanvas *c2=new TCanvas; c2->SetLogy();
309 c2->SetLeftMargin(0.13); c2->SetBottomMargin(0.13);
f99cb92a 310 TCanvas *c2lin=new TCanvas;
311 c2lin->SetLeftMargin(0.13); c2lin->SetBottomMargin(0.13);
8312043c 312
313 TCanvas *c3=new TCanvas;
e9829c0a 314
3b008149 315 for (Int_t cent=0; cent<nCent1; cent++) {
f99cb92a 316 const Char_t *tit=title[cent];
317 Int_t col=colour[cent];
318 Int_t mar=marker[cent];
319 Float_t siz=masize[cent];
320 Float_t fac=factor[cent];
321
8312043c 322 // Lambda
323 if (!GetHistos(rNameL+2*cent, eNameL+2*cent, raw, eff)) return;
324 TH1 *rawHl=MapHisto(raw);
325 TH1 *effHl=MapHisto(eff);
f99cb92a 326
3b008149 327 effHl->Scale(1/fdCorr); //Feed down
f99cb92a 328
8312043c 329 rawHl->Divide(effHl);
f99cb92a 330 SetAttributes(rawHl,tit,col,mar,siz);
8312043c 331 c1->cd();
ac30a56c 332 DrawHisto(rawHl, option.Data(), sysEffLam, sysSigLam);
8312043c 333
f99cb92a 334 TH1 *linHl=(TH1*)rawHl->Clone();
3b008149 335 SetAttributes(linHl,tit,col,mar,siz,25.0*fdCorr,0.,fac,32);
f99cb92a 336 c1lin->cd();
337 DrawHisto(linHl, option.Data(), sysEffLam, sysSigLam);
338
8312043c 339 // K0s
3b008149 340 if (cent==nCent1) gFlag=kTRUE;
8312043c 341 if (!GetHistos(rNameK+2*cent, eNameK+2*cent, raw, eff)) return;
342 TH1 *rawHk=MapHisto(raw);
343 TH1 *effHk=MapHisto(eff);
344 rawHk->Divide(effHk);
f99cb92a 345 SetAttributes(rawHk,tit,col,mar,siz);
8312043c 346 c2->cd();
ac30a56c 347 DrawHisto(rawHk, option.Data(), sysEffK0s, sysSigK0s);
8312043c 348
f99cb92a 349 TH1 *linHk=(TH1*)rawHk->Clone();
350 SetAttributes(linHk,tit,col,mar,siz,120.,0.,fac,32);
351 c2lin->cd();
352 DrawHisto(linHk, option.Data(), sysEffK0s, sysSigK0s);
353
8312043c 354 // Lambda/K0s
355 TH1 *rawHlk=(TH1*)rawHl->Clone();
8312043c 356 TString name=ratio+rawHlk->GetName();
357 rawHlk->SetName(name.Data());
f99cb92a 358 rawHlk->SetMaximum(1.7);
8312043c 359 rawHlk->Divide(rawHk);
360 c3->cd();
361 rawHlk->Draw(option.Data());
362
363 option+="same";
364 }
365
366 Float_t offx=0.15, offy=0.16, sizx=0.22, sizy=0.22;
f99cb92a 367 TLegend *leg=c1->BuildLegend(0.68,0.46,0.88,0.82,"Centrality:");
d1185816 368 leg->SetBorderSize(0);
8312043c 369 leg->SetFillColor(0);
c42feec6 370
371 TLegendEntry *entry=leg->AddEntry("NULL","systematic uncertainty","lpf");
372 Int_t ci = TColor::GetColor("#cccccc");
373 entry->SetLineColor(ci);
374 entry->SetLineStyle(1);
375 entry->SetLineWidth(10);
376 entry->SetMarkerColor(ci);
377
8312043c 378 c1->cd();
d1185816 379 TLatex * tex = new TLatex(5.5,5.0,"#Lambda");
8312043c 380 tex->SetTextFont(42);
381 tex->SetTextSize(0.11);
382 tex->SetLineWidth(2);
383 tex->Draw();
d1185816 384 tex = new TLatex(2.18,200.,"Pb-Pb at #sqrt{s_{NN}}=2.76 TeV, |y|<0.5");
385 tex->SetTextFont(42);
386 tex->SetLineWidth(2);
387 tex->Draw();
8312043c 388 DrawALICELogo(offx,offy,offx+sizx,offy+sizy);
389
f99cb92a 390 leg=c1lin->BuildLegend(0.69,0.43,0.88,0.80,"Centrality:");
391 leg->SetBorderSize(0);
392 leg->SetFillColor(0);
c42feec6 393
394 entry=leg->AddEntry("NULL","systematic uncertainty","lpf");
395 entry->SetLineColor(ci);
396 entry->SetLineStyle(1);
397 entry->SetLineWidth(10);
398 entry->SetMarkerColor(ci);
399 entry=leg->AddEntry("NULL","BGBW fit","l");
400 entry->SetLineColor(1);
401 entry->SetLineStyle(1);
402 entry->SetLineWidth(1);
403 entry->SetMarkerColor(1);
404 entry->SetMarkerStyle(21);
405 entry->SetMarkerSize(1);
406
f99cb92a 407 c1lin->cd();
c42feec6 408 tex=new TLatex(1.04,22.7*fdCorr,"Pb-Pb at #sqrt{s_{NN}}=2.76 TeV, |y|<0.5");
f99cb92a 409 tex->Draw();
3b008149 410 tex = new TLatex(2.38,18.5*fdCorr,"#Lambda");
f99cb92a 411 tex->SetTextSize(0.11);
412 tex->Draw();
3b008149 413 {
414 TFile::Open("LamFitResults20120711.root");
415 const Char_t *name[nCent]={
416 "fitBWLambda010","fitBWLambda1020","fitBWLambda2040",
417 "fitBWLambda4060","fitBWLambda6080","fitBWLambda8090"
418 };
419 Float_t fac[nCent]; for (Int_t i=0; i<nCent; i++) fac[i]=fdCorr*factor[i];
420 DrawFit(name, fac, nCent1);
421 }
f99cb92a 422 Float_t offx1=0.70, offy1=0.18;
423 DrawALICELogo(offx1,offy1,offx1+sizx,offy1+sizy);
424
425
426
427
428 leg=c2->BuildLegend(0.68,0.46,0.88,0.82,"Centrality:");
d1185816 429 leg->SetBorderSize(0);
8312043c 430 leg->SetFillColor(0);
c42feec6 431
432 entry=leg->AddEntry("NULL","systematic uncertainty","lpf");
433 entry->SetLineColor(ci);
434 entry->SetLineStyle(1);
435 entry->SetLineWidth(10);
436 entry->SetMarkerColor(ci);
437
8312043c 438 c2->cd();
d1185816 439 tex = new TLatex(5.5,5.0,"K^{0}_{S}");
8312043c 440 tex->SetTextFont(42);
441 tex->SetTextSize(0.089);
442 tex->SetLineWidth(2);
443 tex->Draw();
d1185816 444 tex = new TLatex(2.18,200.,"Pb-Pb at #sqrt{s_{NN}}=2.76 TeV, |y|<0.5");
445 tex->SetTextFont(42);
446 tex->SetLineWidth(2);
447 tex->Draw();
8312043c 448 DrawALICELogo(offx,offy,offx+sizx,offy+sizy);
449
f99cb92a 450 leg=c2lin->BuildLegend(0.69,0.43,0.88,0.80,"Centrality:");
451 leg->SetBorderSize(0);
452 leg->SetFillColor(0);
c42feec6 453
454 entry=leg->AddEntry("NULL","systematic uncertainty","lpf");
455 entry->SetLineColor(ci);
456 entry->SetLineStyle(1);
457 entry->SetLineWidth(10);
458 entry->SetMarkerColor(ci);
459 entry=leg->AddEntry("NULL","BGBW fit","l");
460 entry->SetLineColor(1);
461 entry->SetLineStyle(1);
462 entry->SetLineWidth(1);
463 entry->SetMarkerColor(1);
464 entry->SetMarkerStyle(21);
465 entry->SetMarkerSize(1);
466
f99cb92a 467 c2lin->cd();
f99cb92a 468 tex = new TLatex(1.04,109.,"Pb-Pb at #sqrt{s_{NN}}=2.76 TeV, |y|<0.5");
469 tex->Draw();
470 tex = new TLatex(2.122705,87.70856,"K^{0}_{S}");
471 tex->SetTextSize(0.089);
472 tex->Draw();
3b008149 473 {
474 TFile::Open("K0FitResults20120711.root");
475 const Char_t *name[nCent]={
476 "fitBWK0s0010","fitBWK0s1020","fitBWK0s2040",
477 "fitBWK0s4060","fitBWK0s6080","fitBWK0s8090"
478 };
479 DrawFit(name, factor, nCent1);
480 }
f99cb92a 481 DrawALICELogo(offx1,offy1,offx1+sizx,offy1+sizy);
482
483
8312043c 484 c3->BuildLegend(0.74,0.62,0.88,0.88);
485
486 return;
487}
488