]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/macros/electrons/plotPIDCompare.C
Reader: Add option to remove or not event with primary vertex not reconstructed
[u/mrichter/AliRoot.git] / PWG4 / macros / electrons / plotPIDCompare.C
CommitLineData
112a7da3 1/////////////////////////////////////////////////\r
2//\r
3// Macro for plotting rates of identified Non-photonic electrons\r
4// for the EMCAL PPR\r
5//\r
6// J.L. Klay (Cal Poly)\r
7//\r
8/////////////////////////////////////////////////\r
9\r
b3858198 10void plotPIDCompare(char* which = "EMC") {\r
112a7da3 11\r
12 gROOT->LoadMacro("makeCombinedData.C");\r
b3858198 13 makeData("data/scaled25Oct09/TOTALhistosscaled-LHC09b2-0.root",\r
112a7da3 14 "data/scaled25Oct09/histosscaledLHC09b4AODc.root",\r
15 "data/scaled25Oct09/histosWboson.root");\r
16\r
17 //define common legend\r
18 TLegend* leg = new TLegend(0.5,0.6,0.9,0.9);\r
4257ed73 19 leg->SetFillColor(0);\r
112a7da3 20 leg->SetTextSize(leg->GetTextSize()*1.2);\r
b3858198 21 leg->AddEntry(alltte,"All N-P e candidates","l");\r
22 //leg->AddEntry(sumtte,"All N-P electrons","l");\r
112a7da3 23 leg->AddEntry(btte,"Bottom e","l");\r
24 leg->AddEntry(ctte,"Charm e","l");\r
25 leg->AddEntry(cbtte,"B-->C e","l");\r
26 leg->AddEntry(daltte,"Dalitz e","l");\r
27 leg->AddEntry(convtte,"Conversion e","l");\r
28 leg->AddEntry(wztte,"W Boson e","l");\r
29 //leg->AddEntry(htte,"Mis-identified hadrons","l");\r
30\r
31 gStyle->SetOptStat(0);\r
32 \r
33 TCanvas* crates = new TCanvas("crates","",0,0,1600,600);\r
4257ed73 34 crates->SetFillColor(0);\r
35 crates->SetBorderMode(0);\r
36 crates->SetBorderSize(2);\r
37 crates->SetFrameBorderMode(0);\r
38 crates->SetFrameBorderMode(0);\r
112a7da3 39 crates->Divide(2,1);\r
40 crates->cd(1);\r
41 gPad->SetLogy();\r
42 alltrk->SetXTitle("p_{T} (GeV/c)");\r
43 alltrk->SetYTitle("Annual yield in EMCAL dN/dp_{T} (GeV/c)^{-1}");\r
44 alltrk->SetTitle("PID comparison: Tracking only vs. EMCAL only");\r
b3858198 45 alltrk->Rebin(5); alltrk->Scale(0.2);\r
112a7da3 46 alltrk->GetYaxis()->SetRangeUser(10.,alltrk->GetMaximum()*2.);\r
47 alltrk->GetXaxis()->SetRangeUser(10.,49.);\r
48 alltrk->Draw();\r
b3858198 49 htrk->Rebin(5); htrk->Scale(0.2);\r
112a7da3 50 htrk->Draw("same");\r
51 TH1F* tempallemc = (TH1F*)allemc->Clone();\r
52 tempallemc->SetNameTitle("tempallemc","tempallemc");\r
53 tempallemc->SetLineColor(kBlue);\r
b3858198 54 tempallemc->Rebin(5); tempallemc->Scale(0.2);\r
112a7da3 55 tempallemc->Draw("same");\r
56 \r
57 TH1F* temphemc = (TH1F*)hemc->Clone();\r
58 temphemc->SetNameTitle("temphemc","temphemc");\r
59 temphemc->SetLineColor(kOrange-3);\r
b3858198 60 temphemc->Rebin(5); temphemc->Scale(0.2);\r
112a7da3 61 temphemc->Draw("same");\r
62\r
63 TLegend* leg2 = new TLegend(0.35,0.6,0.9,0.9);\r
4257ed73 64 leg2->SetFillColor(0);\r
112a7da3 65 leg2->SetTextSize(leg->GetTextSize()*1.2);\r
66 leg2->AddEntry(alltrk,"Electron Candidates (Tracking PID only)","l");\r
67 leg2->AddEntry(htrk,"Hadron Contamination (Tracking PID only)","l");\r
68 leg2->AddEntry(tempallemc,"Electron Candidates (EMCAL PID)","l");\r
69 leg2->AddEntry(temphemc,"Hadron Contamination (EMCAL PID)","l");\r
70 leg2->Draw();\r
71\r
72 crates->cd(2);\r
73 gPad->SetLogy();\r
74 TH1F* subtrk = (TH1F*)alltrk->Clone();\r
75 for(Int_t i = 1; i <= alltrk->GetNbinsX(); i++) {\r
76 Double_t diff = alltrk->GetBinContent(i) - htrk->GetBinContent(i);\r
77 Double_t unc = 0.;\r
78 if(diff < 0) diff = 0.;\r
79 if(diff > 0) \r
80 unc = diff/TMath::Sqrt(diff+2.*htrk->GetBinContent(i));\r
81 printf("<%d> Cand %d, Contam %d, diff %d, unc %d\n",i,alltrk->GetBinContent(i),htrk->GetBinContent(i), diff, unc);\r
82 subtrk->SetBinContent(i,diff);\r
83 subtrk->SetBinError(i,unc);\r
84 }\r
85 subtrk->SetYTitle("Annual yield in EMCAL dN/dp_{T} (GeV/c)^{-1}");\r
86 subtrk->SetLineColor(kRed);\r
4257ed73 87 subtrk->SetMarkerStyle(20); subtrk->SetMarkerColor(kRed);\r
112a7da3 88 subtrk->Draw();\r
112a7da3 89\r
90 TH1F* subemc = (TH1F*)tempallemc->Clone();\r
91 for(Int_t i = 1; i <= tempallemc->GetNbinsX(); i++) {\r
92 Double_t diff = tempallemc->GetBinContent(i) - temphemc->GetBinContent(i);\r
93 Double_t unc = 0.;\r
4257ed73 94 if(diff < 0.) diff = subemc->GetBinContent(i-1);\r
112a7da3 95 if(diff > 0)\r
96 unc = diff/TMath::Sqrt(diff+2.*temphemc->GetBinContent(i));\r
97 // printf("Cand %d, Contam %d, diff %d, unc %d\n",tempallemc->GetBinContent(i),temphemc->GetBinContent(i), diff, unc);\r
98 subemc->SetBinContent(i,diff);\r
99 subemc->SetBinError(i,unc);\r
100 }\r
112a7da3 101\r
4257ed73 102 TFile* effic = new TFile("elec_eff.root");\r
103 TH1F* heff = (TH1F*)effic->Get("h111");\r
b3858198 104 heff->Rebin(5); heff->Scale(0.2);\r
4257ed73 105 TH1F* hcorr = (TH1F*)subemc->Clone();\r
106 hcorr->SetName("hcorr");\r
107 for(Int_t i = 1; i < heff->GetNbinsX(); i++) {\r
108 Double_t pt = heff->GetBinCenter(i);\r
109 Double_t eff = heff->GetBinContent(i);\r
110 Double_t corr = 0.;\r
111 if(eff > 0.) corr = hcorr->GetBinContent(i)/eff;\r
112 hcorr->SetBinContent(i,corr);\r
113 }\r
114\r
5cc733da 115 Double_t efinal = 0.4;\r
4257ed73 116 TGraphErrors* eerr = new TGraphErrors();\r
117 eerr->SetName("emcErr");\r
63e2bb97 118 int count=0;\r
4257ed73 119 for(Int_t i = 1; i <= hcorr->GetNbinsX(); i++) {\r
63e2bb97 120 if (hcorr->GetBinCenter(i) <10.0) continue;\r
121 if (hcorr->GetBinCenter(i) >50.0) break;\r
122 cout <<"bin:"<< i << ", bin-center:"<< hcorr->GetBinCenter(i)<< endl;\r
123 eerr->SetPoint(count,hcorr->GetBinCenter(i),hcorr->GetBinContent(i));\r
124 eerr->SetPointError(count,0.,efinal*hcorr->GetBinContent(i));\r
5cc733da 125 // if(hcorr->GetBinCenter(i) <20.0) eerr->SetPointError(count,0.,1.5*efinal*hcorr->GetBinContent(i));\r
63e2bb97 126 count++;\r
4257ed73 127 }\r
128 eerr->SetFillColor(kRed-8);\r
129 eerr->Draw("3same");\r
130 subtrk->Draw("same");\r
131 hcorr->SetMarkerStyle(20); hcorr->SetMarkerColor(kBlue);\r
132 hcorr->SetLineColor(kBlue);\r
133 hcorr->Draw("same");\r
134 \r
b3858198 135 allMC->Draw("same");\r
112a7da3 136 mchad->Draw("same");\r
137\r
138 TLegend *legx = new TLegend(0.3,0.7,0.9,0.9);\r
4257ed73 139 legx->SetFillColor(0);\r
140 legx->AddEntry(subtrk,"Signal (candidates - contam) (Tracking PID only)","pl");\r
141 legx->AddEntry(hcorr,"Eff. corrected signal (EMCAL PID)","pl");\r
142 legx->AddEntry(eerr,"Systematic uncertainty","f");\r
b3858198 143 legx->AddEntry(allMC,"MC Electrons","l");\r
112a7da3 144 legx->AddEntry(mchad,"MC Hadrons","l");\r
145 legx->Draw();\r
146\r
147 \r
148 TLatex* latex = new TLatex(0.5,0.6,"Unc = #frac{S}{#sqrt{S+2B}}");\r
149 latex->SetNDC();\r
b3858198 150 // latex->Draw();\r
112a7da3 151\r
152 crates->Print("NPERates_PIDCompare_all.pdf");\r
63e2bb97 153\r
154 TCanvas* ccomp = new TCanvas("ccomp","",0,0,600,800);\r
155 ccomp->SetFillColor(0);\r
156 ccomp->SetBorderMode(0);\r
157 ccomp->SetBorderSize(2);\r
158 ccomp->SetFrameBorderMode(0);\r
159 ccomp->SetFrameBorderMode(0);\r
160 TPad* upperPad = new TPad("upperPad", "upperPad", \r
161 .005, .2525, .995, .995);\r
162 upperPad->SetFillColor(0);\r
163 upperPad->SetBorderMode(0);\r
164 upperPad->SetBorderSize(2);\r
165 upperPad->SetFrameBorderMode(0);\r
166 upperPad->SetFrameBorderMode(0);\r
167 TPad* lowerPad = new TPad("lowerPad", "lowerPad", \r
168 .005, .005, .995, .2525);\r
169 lowerPad->SetFillColor(0);\r
170 lowerPad->SetFillColor(0);\r
171 lowerPad->SetBorderMode(0);\r
172 lowerPad->SetBorderSize(2);\r
173 lowerPad->SetFrameBorderMode(0);\r
174 lowerPad->SetFrameBorderMode(0);\r
175 upperPad->Draw(); \r
176 lowerPad->Draw(); \r
177 upperPad->cd();\r
178 gPad->SetLogy();\r
179 hcorr->SetTitle("Efficiency corrected non-photonic electrons");\r
180 hcorr->SetYTitle("Annual yield in EMCAL dN/dp_{T} (GeV/c)^{-1}");\r
181 hcorr->SetXTitle("p_{T} (GeV/c)");\r
182 hcorr->GetXaxis()->SetRangeUser(10.,49.);\r
183 hcorr->GetYaxis()->SetTitleOffset(1.2);\r
184 hcorr->Draw();\r
185 eerr->Draw("3same");\r
186 hcorr->Draw("same");\r
187 allMC->Draw("same");\r
188 TLegend *myleg = new TLegend(0.3,0.7,0.9,0.9);\r
189 myleg->SetFillColor(0);\r
190 myleg->AddEntry(allMC,"MC Electrons","l");\r
191 myleg->AddEntry(hcorr,"Eff. corrected EMCAL N-P electrons","pl");\r
192 myleg->AddEntry(eerr,"Systematic uncertainty","f");\r
193 myleg->Draw();\r
194 lowerPad->cd();\r
195 TH1F* hmc = (TH1F*)allMC->Clone(); hmc->SetName("hmc");\r
196 hmc->Rebin(5); hmc->Scale(0.2);\r
197 TH1F* hmcratio = (TH1F*)hcorr->Clone(); hmcratio->SetName("hmcratio");\r
198 hmcratio->Divide(hmc);\r
199 hmcratio->SetTitle();\r
200 hmcratio->SetYTitle("MC/Data");\r
201 hmcratio->GetYaxis()->SetRangeUser(0.,2.);\r
202 hmcratio->GetYaxis()->SetNdivisions(505);\r
203 hmcratio->GetYaxis()->SetLabelSize(2.*hmcratio->GetYaxis()->GetLabelSize());\r
204 hmcratio->GetYaxis()->SetTitleSize(3.*hmcratio->GetYaxis()->GetTitleSize());\r
205 hmcratio->GetYaxis()->SetTitleOffset(0.3);\r
206 hmcratio->SetXTitle("");\r
207 hmcratio->GetXaxis()->SetLabelSize(2.*hmcratio->GetXaxis()->GetLabelSize());\r
208 hmcratio->Draw();\r
209 TGraphErrors* rerr = new TGraphErrors();\r
210 rerr->SetName("ratioErr");\r
211 count=0;\r
212 for(Int_t i = 1; i <= hmcratio->GetNbinsX(); i++) {\r
213 if (hmcratio->GetBinCenter(i) <10.0) continue;\r
214 if (hmcratio->GetBinCenter(i) >50.0) break;\r
215 rerr->SetPoint(count,hmcratio->GetBinCenter(i),hmcratio->GetBinContent(i));\r
216 rerr->SetPointError(count,0.,efinal*hmcratio->GetBinContent(i));\r
5cc733da 217 //if(hmcratio->GetBinCenter(i) <20.0) rerr->SetPointError(count,0.,1.5*efinal*hmcratio->GetBinContent(i));\r
63e2bb97 218 count++;\r
219 }\r
220 rerr->SetFillColor(kRed-8);\r
221 rerr->Draw("3same");\r
222 hmcratio->Draw("same");\r
223 TLine* line = new TLine(10.,1.,50.,1.);\r
224 line->SetLineStyle(2);\r
225 line->Draw();\r
226 ccomp->Print("EMCAL_NPE.pdf");\r
227 crates->cd();\r
112a7da3 228}\r
229\r