]>
Commit | Line | Data |
---|---|---|
4bd4fc13 | 1 | |
2 | /************************************************************************** | |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | // | |
17 | // Class for spectrum correction | |
18 | // Subtraction of hadronic background, Unfolding of the data and | |
19 | // Renormalization done here | |
20 | // The following containers have to be set: | |
21 | // - Correction framework container for real data | |
22 | // - Correction framework container for MC (Efficiency Map) | |
23 | // - Correction framework container for background coming from data | |
24 | // - Correction framework container for background coming from MC | |
25 | // | |
26 | // Author: | |
27 | // Raphaelle Bailhache <R.Bailhache@gsi.de> | |
28 | // | |
29 | ||
30 | #include <TArrayD.h> | |
31 | #include <TH1.h> | |
32 | #include <TList.h> | |
33 | #include <TObjArray.h> | |
34 | #include <TObject.h> | |
35 | #include <TROOT.h> | |
36 | #include <TCanvas.h> | |
37 | #include <TLegend.h> | |
38 | #include <TStyle.h> | |
39 | #include <TMath.h> | |
40 | #include <TAxis.h> | |
41 | #include <TGraphErrors.h> | |
42 | #include <TFile.h> | |
43 | #include <TPad.h> | |
44 | #include <TH2D.h> | |
45 | #include <TF1.h> | |
46 | ||
47 | #include "AliPID.h" | |
48 | #include "AliCFContainer.h" | |
49 | #include "AliCFDataGrid.h" | |
50 | #include "AliCFEffGrid.h" | |
51 | #include "AliCFGridSparse.h" | |
52 | #include "AliCFUnfolding.h" | |
53 | #include "AliLog.h" | |
54 | ||
55 | #include "AliHFEBeautySpectrumQA.h" | |
56 | #include "AliHFECorrectSpectrumBase.h" | |
57 | #include "AliHFEcuts.h" | |
58 | #include "AliHFEcontainer.h" | |
59 | #include "AliHFEtools.h" | |
60 | ||
61 | ClassImp(AliHFEBeautySpectrumQA) | |
62 | ||
63 | const Char_t *AliHFEBeautySpectrumQA::fgkNameCanvas[AliHFEBeautySpectrumQA::kNTypeEfficiency] = { | |
64 | "MCEfficiency", | |
65 | "ParametrizedEfficiency" | |
66 | }; | |
67 | ||
68 | //____________________________________________________________ | |
69 | AliHFEBeautySpectrumQA::AliHFEBeautySpectrumQA(): | |
70 | TNamed(), | |
71 | fPtMax(8.0), | |
72 | fListOfResult(), | |
73 | fWriteToFile(kTRUE) | |
74 | { | |
75 | // | |
76 | // Default constructor | |
77 | // | |
78 | ||
79 | fListOfResult = new TObjArray(kNResults); | |
80 | fListOfResult->SetName("ListOfResults"); | |
81 | ||
82 | ||
83 | } | |
84 | //____________________________________________________________ | |
85 | AliHFEBeautySpectrumQA::AliHFEBeautySpectrumQA(const char *name): | |
86 | TNamed(name, ""), | |
87 | fPtMax(8.0), | |
88 | fListOfResult(), | |
89 | fWriteToFile(kTRUE) | |
90 | { | |
91 | // | |
92 | // Default constructor | |
93 | // | |
94 | ||
95 | fListOfResult = new TObjArray(kNResults); | |
96 | fListOfResult->SetName("ListOfResults"); | |
97 | ||
98 | ||
99 | } | |
100 | ||
101 | //____________________________________________________________ | |
102 | AliHFEBeautySpectrumQA::~AliHFEBeautySpectrumQA(){ | |
103 | // | |
104 | // Destructor | |
105 | // | |
106 | if(fListOfResult) delete fListOfResult; | |
107 | ||
108 | } | |
109 | //____________________________________________________________ | |
110 | void AliHFEBeautySpectrumQA::AddResultAt(TObject *obj,Int_t index) | |
111 | { | |
112 | // | |
113 | // Init what we need for the correction: | |
114 | // | |
115 | ||
116 | if(fListOfResult) fListOfResult->AddAt(obj,index); | |
117 | ||
118 | } | |
119 | //____________________________________________________________ | |
120 | TObject *AliHFEBeautySpectrumQA::GetResult(Int_t index) | |
121 | { | |
122 | // | |
123 | // Get result | |
124 | // | |
125 | ||
126 | if(fListOfResult) return fListOfResult->UncheckedAt(index); | |
127 | else return 0x0; | |
128 | ||
129 | } | |
130 | //____________________________________________________________ | |
131 | void AliHFEBeautySpectrumQA::DrawProjections() const | |
132 | { | |
133 | // | |
134 | // get spectrum for beauty 2nd method | |
135 | // | |
136 | // | |
137 | AliCFContainer *data = (AliCFContainer *) fListOfResult->UncheckedAt(kDataProjection); | |
138 | THnSparseF *correlation = (THnSparseF *) fListOfResult->UncheckedAt(kCMProjection); | |
139 | if(!data || !correlation) return; | |
140 | ||
141 | Int_t ndimcont = data->GetNVar(); | |
142 | Int_t ndimcor = correlation->GetNdimensions(); | |
143 | Int_t charge = 3; | |
144 | Int_t centrality = 5; | |
145 | Int_t eta = 1; | |
146 | ||
147 | TCanvas * canvas = new TCanvas("Projections","Projections",1000,700); | |
148 | Int_t n = 0; | |
149 | if(charge < ndimcont) n++; | |
150 | if(centrality < ndimcont) n++; | |
151 | if(eta < ndimcont) n++; | |
152 | canvas->Divide(2,n); | |
153 | Int_t counter = 1; | |
154 | ||
155 | if(charge < ndimcont) { | |
156 | ||
157 | canvas->cd(counter); | |
158 | TH1 *checkcharge = (TH1 *) data->Project(data->GetNStep()-1,charge); | |
159 | checkcharge->Draw(); | |
160 | counter++; | |
161 | canvas->cd(counter); | |
162 | TH2F* projectioncharge = (TH2F *) correlation->Projection(charge,charge+((Int_t)(ndimcor/2.))); | |
163 | projectioncharge->Draw("colz"); | |
164 | counter++; | |
165 | ||
166 | } | |
167 | ||
168 | if(centrality < ndimcont) { | |
169 | canvas->cd(counter); | |
170 | TH1 *checkcentrality = (TH1 *) data->Project(data->GetNStep()-1,centrality); | |
171 | checkcentrality->Draw(); | |
172 | counter++; | |
173 | canvas->cd(counter); | |
174 | TH2F *projectioncentrality = (TH2F *) correlation->Projection(centrality,centrality+((Int_t)(ndimcor/2.))); | |
175 | projectioncentrality->Draw("colz"); | |
176 | counter++; | |
177 | } | |
178 | ||
179 | if(eta < ndimcont) { | |
180 | canvas->cd(counter); | |
181 | TH1 *checketa = (TH1 *) data->Project(data->GetNStep()-1,eta); | |
182 | checketa->Draw(); | |
183 | counter++; | |
184 | canvas->cd(counter); | |
185 | TH2D* projectioneta = (TH2D *) correlation->Projection(eta,eta+((Int_t)(ndimcor/2.))); | |
186 | projectioneta->Draw("colz"); | |
187 | } | |
188 | ||
189 | ||
190 | } | |
191 | //____________________________________________________________ | |
192 | void AliHFEBeautySpectrumQA::DrawSubtractContamination() const | |
193 | { | |
194 | // | |
195 | // get spectrum for beauty 2nd method | |
196 | // | |
197 | // | |
198 | TH1D *measuredTH1Daftersubstraction = (TH1D *) fListOfResult->UncheckedAt(kAfterSC); | |
199 | TH1D *measuredTH1Dbeforesubstraction = (TH1D *) fListOfResult->UncheckedAt(kBeforeSC); | |
200 | TH1D *measuredTH1background = (TH1D *) fListOfResult->UncheckedAt(kMeasBG); | |
201 | if(!measuredTH1Daftersubstraction || !measuredTH1Dbeforesubstraction) return; | |
202 | ||
203 | SetStyle(); | |
204 | ||
205 | TCanvas * cbackgroundsubtraction = new TCanvas("backgroundsubtraction","backgroundsubtraction",1000,700); | |
206 | cbackgroundsubtraction->Divide(3,1); | |
207 | cbackgroundsubtraction->cd(1); | |
208 | gPad->SetLogy(); | |
209 | gPad->SetTicks(); | |
210 | measuredTH1Daftersubstraction->SetStats(0); | |
211 | measuredTH1Daftersubstraction->SetTitle(""); | |
212 | measuredTH1Daftersubstraction->GetYaxis()->SetTitleOffset(1.5); | |
213 | measuredTH1Daftersubstraction->GetYaxis()->SetTitle("dN/dp_{T} [(GeV/c)^{-1}]"); | |
214 | measuredTH1Daftersubstraction->GetXaxis()->SetTitle("p^{rec}_{T} [GeV/c]"); | |
215 | //measuredTH1Daftersubstraction->GetXaxis()->SetRangeUser(0.0,fPtMax); | |
216 | //measuredTH1Daftersubstraction->SetMarkerStyle(25); | |
217 | //measuredTH1Daftersubstraction->SetMarkerColor(kBlack); | |
218 | //measuredTH1Daftersubstraction->SetLineColor(kBlack); | |
219 | measuredTH1Dbeforesubstraction->SetStats(0); | |
220 | measuredTH1Dbeforesubstraction->SetTitle(""); | |
221 | measuredTH1Dbeforesubstraction->GetYaxis()->SetTitle("dN/dp_{T} [(GeV/c)^{-1}]"); | |
222 | measuredTH1Dbeforesubstraction->GetXaxis()->SetTitle("p^{rec}_{T} [GeV/c]"); | |
223 | //measuredTH1Dbeforesubstraction->GetXaxis()->SetRangeUser(0.0,fPtMax); | |
224 | //measuredTH1Dbeforesubstraction->SetMarkerStyle(24); | |
225 | //measuredTH1Dbeforesubstraction->SetMarkerColor(kBlue); | |
226 | //measuredTH1Dbeforesubstraction->SetLineColor(kBlue); | |
227 | measuredTH1Daftersubstraction->Draw(); | |
228 | measuredTH1Dbeforesubstraction->Draw("same"); | |
229 | TLegend *legsubstraction = new TLegend(0.4,0.6,0.89,0.89); | |
230 | legsubstraction->AddEntry(measuredTH1Dbeforesubstraction,"With hadron contamination","p"); | |
231 | legsubstraction->AddEntry(measuredTH1Daftersubstraction,"Without hadron contamination ","p"); | |
232 | legsubstraction->SetFillStyle(0); | |
233 | legsubstraction->SetLineStyle(0); | |
234 | legsubstraction->SetLineColor(0); | |
235 | legsubstraction->Draw("same"); | |
236 | cbackgroundsubtraction->cd(2); | |
237 | gPad->SetLogy(); | |
238 | gPad->SetTicks(); | |
239 | TH1D* ratiomeasuredcontamination = (TH1D*)measuredTH1Dbeforesubstraction->Clone(); | |
240 | ratiomeasuredcontamination->SetName("ratiomeasuredcontamination"); | |
241 | ratiomeasuredcontamination->SetTitle(""); | |
242 | ratiomeasuredcontamination->GetYaxis()->SetTitleOffset(1.5); | |
243 | ratiomeasuredcontamination->GetYaxis()->SetTitle("(with contamination - without contamination) / with contamination"); | |
244 | ratiomeasuredcontamination->GetXaxis()->SetTitle("p^{rec}_{T} [GeV/c]"); | |
245 | ratiomeasuredcontamination->GetYaxis()->SetRangeUser(0.8,1.2); | |
246 | ratiomeasuredcontamination->GetXaxis()->SetRangeUser(0.0,fPtMax); | |
247 | ratiomeasuredcontamination->Sumw2(); | |
248 | ratiomeasuredcontamination->Add(measuredTH1Daftersubstraction,-1.0); | |
249 | ratiomeasuredcontamination->Divide(measuredTH1Dbeforesubstraction); | |
250 | ratiomeasuredcontamination->SetStats(0); | |
251 | ratiomeasuredcontamination->SetMarkerStyle(26); | |
252 | ratiomeasuredcontamination->SetMarkerColor(kBlack); | |
253 | ratiomeasuredcontamination->SetLineColor(kBlack); | |
254 | for(Int_t k=0; k < ratiomeasuredcontamination->GetNbinsX(); k++){ | |
255 | ratiomeasuredcontamination->SetBinError(k+1,0.0); | |
256 | } | |
257 | ratiomeasuredcontamination->Draw("P"); | |
258 | cbackgroundsubtraction->cd(3); | |
259 | measuredTH1background->SetStats(0); | |
260 | measuredTH1background->SetTitle(""); | |
261 | measuredTH1background->GetYaxis()->SetTitle("dN/dp_{T} [(GeV/c)^{-1}]"); | |
262 | measuredTH1background->GetXaxis()->SetTitle("p_{T} [GeV/c]"); | |
263 | measuredTH1background->SetMarkerStyle(26); | |
264 | measuredTH1background->SetMarkerColor(kBlack); | |
265 | measuredTH1background->SetLineColor(kBlack); | |
266 | measuredTH1background->Draw(); | |
267 | if(fWriteToFile) cbackgroundsubtraction->SaveAs("BackgroundSubtracted.png"); | |
268 | ||
269 | } | |
270 | ||
271 | ||
272 | //____________________________________________________________ | |
273 | void AliHFEBeautySpectrumQA::DrawCorrectWithEfficiency(Int_t typeeff) const | |
274 | { | |
275 | // | |
276 | // Correct the spectrum for efficiency and unfolding | |
277 | // with both method and compare | |
278 | // | |
279 | ||
280 | TH1D *afterE = 0x0; | |
281 | TH1D *beforeE = 0x0; | |
282 | TH1D *efficiencyDproj = 0x0; | |
283 | TF1 *efficiencyparametrized = 0x0; | |
284 | ||
285 | if(typeeff== kMC) { | |
286 | afterE = (TH1D *) fListOfResult->UncheckedAt(kAfterMCE); | |
287 | beforeE = (TH1D *) fListOfResult->UncheckedAt(kBeforeMCE); | |
288 | efficiencyDproj = (TH1D *) fListOfResult->UncheckedAt(kMCEfficiency); | |
289 | } | |
290 | if(typeeff== kParametrized) { | |
291 | afterE = (TH1D *) fListOfResult->UncheckedAt(kAfterPE); | |
292 | beforeE = (TH1D *) fListOfResult->UncheckedAt(kBeforePE); | |
293 | efficiencyparametrized = (TF1 *) fListOfResult->UncheckedAt(kPEfficiency); | |
294 | } | |
295 | ||
32c709ed | 296 | if(!afterE || !beforeE) return; |
297 | ||
298 | if(typeeff==kMC && !efficiencyDproj) return; | |
299 | if(typeeff==kParametrized && !efficiencyparametrized) return; | |
4bd4fc13 | 300 | |
301 | SetStyle(); | |
302 | ||
303 | TCanvas * cEfficiency = new TCanvas(AliHFEBeautySpectrumQA::fgkNameCanvas[typeeff],AliHFEBeautySpectrumQA::fgkNameCanvas[typeeff],1000,700); | |
304 | cEfficiency->Divide(2,1); | |
305 | cEfficiency->cd(1); | |
306 | gPad->SetLogy(); | |
307 | gPad->SetTicks(); | |
308 | afterE->SetStats(0); | |
309 | afterE->SetTitle(""); | |
310 | afterE->GetYaxis()->SetTitleOffset(1.5); | |
311 | afterE->GetYaxis()->SetTitle("dN/dp_{T} [(GeV/c)^{-1}]"); | |
312 | afterE->GetXaxis()->SetTitle("p^{rec}_{T} [GeV/c]"); | |
313 | afterE->GetXaxis()->SetRangeUser(0.0,fPtMax); | |
314 | afterE->SetMarkerStyle(25); | |
315 | afterE->SetMarkerColor(kBlack); | |
316 | afterE->SetLineColor(kBlack); | |
317 | beforeE->SetStats(0); | |
318 | beforeE->SetTitle(""); | |
319 | beforeE->GetYaxis()->SetTitle("dN/dp_{T} [(GeV/c)^{-1}]"); | |
320 | beforeE->GetXaxis()->SetTitle("p_{T} [GeV/c]"); | |
321 | beforeE->GetXaxis()->SetRangeUser(0.0,fPtMax); | |
322 | beforeE->SetMarkerStyle(24); | |
323 | beforeE->SetMarkerColor(kBlue); | |
324 | beforeE->SetLineColor(kBlue); | |
325 | afterE->Draw(); | |
326 | beforeE->Draw("same"); | |
327 | TLegend *legefficiency = new TLegend(0.4,0.6,0.89,0.89); | |
328 | legefficiency->AddEntry(beforeE,"Before Efficiency correction","p"); | |
329 | legefficiency->AddEntry(afterE,"After Efficiency correction","p"); | |
330 | legefficiency->SetFillStyle(0); | |
331 | legefficiency->SetLineStyle(0); | |
332 | legefficiency->SetLineColor(0); | |
333 | legefficiency->Draw("same"); | |
334 | cEfficiency->cd(2); | |
335 | gPad->SetTicks(); | |
336 | if(typeeff==kMC) { | |
337 | if(efficiencyDproj) { | |
338 | efficiencyDproj->SetTitle(""); | |
339 | efficiencyDproj->SetStats(0); | |
340 | efficiencyDproj->GetYaxis()->SetTitleOffset(1.5); | |
341 | efficiencyDproj->GetYaxis()->SetRangeUser(0.0,1.0); | |
342 | efficiencyDproj->GetYaxis()->SetTitle("Efficiency"); | |
343 | efficiencyDproj->GetXaxis()->SetTitle("p^{rec}_{T} [GeV/c]"); | |
344 | efficiencyDproj->GetXaxis()->SetRangeUser(0.0,fPtMax); | |
345 | efficiencyDproj->SetMarkerStyle(25); | |
346 | efficiencyDproj->Draw(); | |
347 | } | |
348 | } | |
349 | if(typeeff==kParametrized) { | |
350 | if(efficiencyparametrized) efficiencyparametrized->Draw(); | |
351 | } | |
352 | ||
353 | if(fWriteToFile) { | |
354 | if(typeeff==kMC) cEfficiency->SaveAs("EfficiencyMC.png"); | |
355 | if(typeeff==kParametrized) cEfficiency->SaveAs("EfficiencyParametrized.png"); | |
356 | } | |
357 | ||
358 | } | |
359 | ||
360 | //____________________________________________________________ | |
361 | void AliHFEBeautySpectrumQA::DrawUnfolding() const | |
362 | { | |
363 | // | |
364 | // Draw unfolding | |
365 | // | |
366 | TH1D *measuredspectrumD = (TH1D *) fListOfResult->UncheckedAt(kBeforeU); | |
367 | TH1D *residualspectrumD = (TH1D *) fListOfResult->UncheckedAt(kResidualU); | |
368 | TH1D *efficiencyDproj = (TH1D *) fListOfResult->UncheckedAt(kUEfficiency); | |
369 | THnSparseF *correlation = (THnSparseF *) fListOfResult->UncheckedAt(kCMProjection); | |
370 | ||
371 | if(!measuredspectrumD || !residualspectrumD || !efficiencyDproj || !correlation) return; | |
372 | ||
373 | Int_t ndimcor = (Int_t) correlation->GetNdimensions()/2.; | |
374 | ||
375 | SetStyle(); | |
376 | ||
377 | TCanvas * cunfolding = new TCanvas("unfolding","unfolding",1000,700); | |
378 | cunfolding->Divide(2,2); | |
379 | cunfolding->cd(1); | |
380 | gPad->SetLogy(); | |
381 | gPad->SetTicks(); | |
382 | residualspectrumD->GetYaxis()->SetTitle("dN/dp_{T} [(GeV/c)^{-1}]"); | |
383 | residualspectrumD->GetXaxis()->SetTitle("p^{rec}_{T} [GeV/c]"); | |
384 | residualspectrumD->GetXaxis()->SetRangeUser(0.0,fPtMax); | |
385 | residualspectrumD->SetStats(0); | |
386 | residualspectrumD->SetTitle(""); | |
387 | residualspectrumD->GetYaxis()->SetTitleOffset(1.5); | |
388 | residualspectrumD->SetMarkerStyle(26); | |
389 | residualspectrumD->SetMarkerColor(kBlue); | |
390 | residualspectrumD->SetLineColor(kBlue); | |
391 | residualspectrumD->Sumw2(); | |
392 | residualspectrumD->Draw("P"); | |
393 | measuredspectrumD->SetStats(0); | |
394 | measuredspectrumD->SetTitle(""); | |
395 | measuredspectrumD->GetYaxis()->SetTitleOffset(1.5); | |
396 | measuredspectrumD->SetMarkerStyle(25); | |
397 | measuredspectrumD->SetMarkerColor(kBlack); | |
398 | measuredspectrumD->SetLineColor(kBlack); | |
399 | measuredspectrumD->Draw("same"); | |
400 | TLegend *legres = new TLegend(0.4,0.6,0.89,0.89); | |
401 | legres->AddEntry(residualspectrumD,"Residual","p"); | |
402 | legres->AddEntry(measuredspectrumD,"Measured","p"); | |
403 | legres->SetFillStyle(0); | |
404 | legres->SetLineStyle(0); | |
405 | legres->SetLineColor(0); | |
406 | legres->Draw("same"); | |
407 | cunfolding->cd(2); | |
408 | gPad->SetTicks(); | |
409 | TH1D* ratioresidual = (TH1D*)residualspectrumD->Clone(); | |
410 | ratioresidual->SetName("ratioresidual"); | |
411 | ratioresidual->SetTitle(""); | |
412 | ratioresidual->GetYaxis()->SetRangeUser(0.6,1.4); | |
413 | ratioresidual->GetYaxis()->SetTitle("Folded/Measured"); | |
414 | ratioresidual->GetXaxis()->SetTitle("p_{T} [GeV/c]"); | |
415 | ratioresidual->Divide(measuredspectrumD); | |
416 | ratioresidual->SetStats(0); | |
417 | ratioresidual->Draw(); | |
418 | cunfolding->cd(3); | |
419 | gPad->SetTicks(); | |
420 | efficiencyDproj->GetYaxis()->SetTitle("Efficiency"); | |
421 | efficiencyDproj->GetXaxis()->SetTitle("p^{MC}_{T} [GeV/c]"); | |
422 | efficiencyDproj->GetXaxis()->SetRangeUser(0.0,fPtMax); | |
423 | efficiencyDproj->GetYaxis()->SetRangeUser(0.0,1.0); | |
424 | efficiencyDproj->SetStats(0); | |
425 | efficiencyDproj->SetTitle(""); | |
426 | efficiencyDproj->GetYaxis()->SetTitleOffset(1.5); | |
427 | efficiencyDproj->SetMarkerStyle(26); | |
428 | efficiencyDproj->SetMarkerColor(kBlue); | |
429 | efficiencyDproj->SetLineColor(kBlue); | |
430 | efficiencyDproj->Sumw2(); | |
431 | efficiencyDproj->Draw("P"); | |
432 | cunfolding->cd(4); | |
433 | TH2F *projectioncorr = (TH2F *) correlation->Projection(0,ndimcor); | |
434 | projectioncorr->GetYaxis()->SetTitle("p^{ESD}_{T} [GeV/c]"); | |
435 | projectioncorr->GetXaxis()->SetTitle("p^{MC}_{T} [GeV/c]"); | |
436 | projectioncorr->GetXaxis()->SetRangeUser(0.0,fPtMax); | |
437 | projectioncorr->GetYaxis()->SetRangeUser(0.0,fPtMax); | |
438 | projectioncorr->SetStats(0); | |
439 | projectioncorr->SetTitle(""); | |
440 | projectioncorr->Draw("colz"); | |
441 | ||
442 | if(fWriteToFile){ | |
443 | cunfolding->SaveAs("Unfolding.png"); | |
444 | } | |
445 | ||
446 | } | |
447 | //____________________________________________________________ | |
448 | void AliHFEBeautySpectrumQA::DrawResult() | |
449 | { | |
450 | // | |
451 | // Draw Results | |
452 | // | |
453 | TGraphErrors* correctedspectrumD = (TGraphErrors *) fListOfResult->UncheckedAt(kFinalResultUnfolded); | |
454 | TGraphErrors* alltogetherspectrumD = (TGraphErrors *) fListOfResult->UncheckedAt(kFinalResultDirectEfficiency); | |
455 | THnSparse* correctedspectrum = (THnSparse *) fListOfResult->UncheckedAt(kFinalResultUnfSparse); | |
456 | AliCFDataGrid* alltogetherCorrection = (AliCFDataGrid *) fListOfResult->UncheckedAt( kFinalResultDirectEffSparse); | |
457 | if(!correctedspectrumD || !alltogetherspectrumD) return; | |
458 | ||
459 | SetStyle(); | |
460 | ||
461 | TCanvas * ccorrected = new TCanvas("corrected","corrected",1000,700); | |
462 | ccorrected->Divide(2,1); | |
463 | ccorrected->cd(1); | |
464 | gPad->SetLogy(); | |
465 | correctedspectrumD->SetTitle(""); | |
466 | correctedspectrumD->GetYaxis()->SetTitleOffset(1.5); | |
467 | correctedspectrumD->GetYaxis()->SetRangeUser(0.000000001,1.0); | |
468 | correctedspectrumD->SetMarkerStyle(26); | |
469 | correctedspectrumD->SetMarkerColor(kBlue); | |
470 | correctedspectrumD->SetLineColor(kBlue); | |
471 | correctedspectrumD->Draw("AP"); | |
472 | alltogetherspectrumD->SetTitle(""); | |
473 | alltogetherspectrumD->GetYaxis()->SetTitleOffset(1.5); | |
474 | alltogetherspectrumD->GetYaxis()->SetRangeUser(0.000000001,1.0); | |
475 | alltogetherspectrumD->SetMarkerStyle(25); | |
476 | alltogetherspectrumD->SetMarkerColor(kBlack); | |
477 | alltogetherspectrumD->SetLineColor(kBlack); | |
478 | alltogetherspectrumD->Draw("P"); | |
479 | TLegend *legcorrected = new TLegend(0.4,0.6,0.89,0.89); | |
480 | legcorrected->AddEntry(correctedspectrumD,"Corrected","p"); | |
481 | legcorrected->AddEntry(alltogetherspectrumD,"Alltogether","p"); | |
482 | legcorrected->Draw("same"); | |
483 | ccorrected->cd(2); | |
484 | TH1D *correctedTH1D = correctedspectrum->Projection(0); | |
485 | TH1D *alltogetherTH1D = (TH1D *) alltogetherCorrection->Project(0); | |
486 | TH1D* ratiocorrected = (TH1D*)correctedTH1D->Clone(); | |
487 | ratiocorrected->SetName("ratiocorrected"); | |
488 | ratiocorrected->SetTitle(""); | |
489 | ratiocorrected->GetYaxis()->SetTitle("Unfolded/DirectCorrected"); | |
490 | ratiocorrected->GetXaxis()->SetTitle("p_{T} [GeV/c]"); | |
491 | ratiocorrected->Divide(correctedTH1D,alltogetherTH1D,1,1); | |
492 | ratiocorrected->SetStats(0); | |
493 | ratiocorrected->Draw(); | |
494 | if(fWriteToFile){ | |
495 | ccorrected->SaveAs("CorrectedBeauty.eps"); | |
496 | TFile *out; | |
497 | out = new TFile("finalSpectrum.root","recreate"); | |
498 | out->cd(); | |
499 | // | |
500 | correctedspectrumD->SetName("UnfoldingCorrectedSpectrum"); | |
501 | correctedspectrumD->Write(); | |
502 | alltogetherspectrumD->SetName("AlltogetherSpectrum"); | |
503 | alltogetherspectrumD->Write(); | |
504 | ratiocorrected->SetName("RatioUnfoldingAlltogetherSpectrum"); | |
505 | ratiocorrected->Write(); | |
506 | // | |
507 | ||
508 | out->Close(); | |
509 | delete out; | |
510 | } | |
511 | } | |
512 | //____________________________________________________________ | |
513 | TH1D *AliHFEBeautySpectrumQA::DivideSpectra(TGraphErrors *ga, TGraphErrors *gb) | |
514 | { | |
515 | // | |
516 | // Divide Spectra | |
517 | // | |
518 | ||
519 | TH1D *afterE = (TH1D *) fListOfResult->UncheckedAt(kAfterMCE); | |
520 | if(!afterE) return 0x0; | |
521 | ||
522 | TH1D *histoB = (TH1D*) afterE->Clone(); | |
523 | histoB->Sumw2(); | |
524 | histoB->SetName("ratio"); | |
525 | TH1D *histoa = (TH1D*) afterE->Clone(); | |
526 | histoa->Sumw2(); | |
527 | histoa->SetName("a"); | |
528 | TH1D *histob = (TH1D*) afterE->Clone(); | |
529 | histob->Sumw2(); | |
530 | histob->SetName("b"); | |
531 | ||
532 | double xa,ya,xb,yb,eya,eyb; | |
533 | Int_t npointsa = ga->GetN(); | |
534 | Int_t npointsb = gb->GetN(); | |
535 | if(npointsa != npointsb) { | |
536 | printf("Problem the two spectra have not the same number of points\n"); | |
537 | return 0x0; | |
538 | } | |
539 | for(Int_t k = 0; k < npointsa; k++){ | |
540 | ga->GetPoint(k,xa,ya); | |
541 | gb->GetPoint(k,xb,yb); | |
542 | // | |
543 | Double_t centerhisto = histoa->GetBinCenter(k+1); | |
544 | // | |
545 | if((TMath::Abs(xa-xb) > 0.0001) || (TMath::Abs(xa-centerhisto) > 0.0001)) { | |
546 | printf("Problem not the same x axis\n"); | |
547 | return 0x0; | |
548 | } | |
549 | histoa->SetBinContent(k+1,ya); | |
550 | histob->SetBinContent(k+1,yb); | |
551 | // | |
552 | eya = ga->GetErrorY(k); | |
553 | eyb = gb->GetErrorY(k); | |
554 | // | |
555 | histoa->SetBinError(k+1,eya); | |
556 | histob->SetBinError(k+1,eyb); | |
557 | ||
558 | } | |
559 | ||
560 | histoB->Sumw2(); | |
561 | histoB->Divide(histoa,histob,1.0,1.0,"B"); | |
562 | ||
563 | return histoB; | |
564 | ||
565 | } | |
566 | //__________________________________________ | |
567 | void AliHFEBeautySpectrumQA::SetStyle() const | |
568 | { | |
569 | // | |
570 | // Set style | |
571 | // | |
572 | ||
573 | gStyle->SetPalette(1); | |
574 | gStyle->SetOptStat(1111); | |
575 | gStyle->SetPadBorderMode(0); | |
576 | gStyle->SetCanvasColor(10); | |
577 | gStyle->SetPadLeftMargin(0.13); | |
578 | gStyle->SetPadRightMargin(0.13); | |
579 | ||
580 | } |