10 #include <TClonesArray.h>
13 #include <AliXRDPROOFtoolkit.h>
15 #include "DebugClasses.C"
27 * I did not recheck this code. For now I would just use the efficiency values I have.
28 * The code could be made nicer. Esepcially some plots could be put in folders.
30 Use AliRoot because of AliXRDPROOFtoolkit:
31 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC")
32 gSystem->AddIncludePath("-I../lib")
33 gSystem->AddIncludePath("-I../grid")
34 gSystem->AddIncludePath("-I../macros")
35 gROOT->SetMacroPath(".:../macros:../grid:../lib/")
38 .L createEfficiency.C+
40 Examples of visualization:
41 DrawEfficiency("lhc10d_eff_pythia.root", "eff.root")
43 // This is the correction I did for the low pT guys
44 DrawCorrection("lhc10d_eff_pythia.root", "lhc10d_eff_phojet.root")
48 CreateEff("lhc10d_mc_all.dat", 0, "lhc10d_eff_all.root")
53 void DrawEfficiency(const Char_t* fileName, const Char_t* effFileName);
54 void DrawCorrection(const Char_t* fileNamePYTHIA, const Char_t* fileNamePHOJET);
55 TH1D* HistInvert(TH1D* hist);
58 void CreateEff(const Char_t* mcFileName, Int_t maxEvents, const Char_t* mcOutFileName,
59 Float_t centLow=-20, Float_t centHigh=-5)
61 gStyle->SetOptStat(0);
65 TFile* outFile = new TFile(mcOutFileName, "RECREATE");
68 TH1D* hMcIn[nPid] = {0, 0, 0, 0, 0, 0, 0 };
69 TH1D* hMcOut[nPid] = {0, 0, 0, 0, 0, 0, 0 };
70 TH1D* hMcSec[nPid] = {0, 0, 0, 0, 0, 0, 0 };
71 TH1D* hMcEff[nPid] = {0, 0, 0, 0, 0, 0, 0 };
72 TH1D* hMcInNeg[nPid] = {0, 0, 0, 0, 0, 0, 0 };
73 TH1D* hMcOutNeg[nPid] = {0, 0, 0, 0, 0, 0, 0 };
74 TH1D* hMcSecNeg[nPid] = {0, 0, 0, 0, 0, 0, 0 };
75 TH1D* hMcEffNeg[nPid] = {0, 0, 0, 0, 0, 0, 0 };
76 TH1D* hMcInPos[nPid] = {0, 0, 0, 0, 0, 0, 0 };
77 TH1D* hMcOutPos[nPid] = {0, 0, 0, 0, 0, 0, 0 };
78 TH1D* hMcSecPos[nPid] = {0, 0, 0, 0, 0, 0, 0 };
79 TH1D* hMcEffPos[nPid] = {0, 0, 0, 0, 0, 0, 0 };
81 Int_t color[nPid] = {1, 2, 3, 4, 5, 1, 1};
83 const Int_t nPtBins = 68;
84 Double_t xBins[nPtBins+1] = {0. , 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45,
85 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95,
86 1.0, 1.1 , 1.2, 1.3 , 1.4, 1.5 , 1.6, 1.7 , 1.8, 1.9 ,
87 2.0, 2.2 , 2.4, 2.6 , 2.8, 3.0 , 3.2, 3.4 , 3.6, 3.8 ,
88 4.0, 4.5 , 5.0, 5.5 , 6.0, 6.5 , 7.0, 8.0 , 9.0, 10.0,
89 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 20.0, 22.0, 24.0,
90 26.0, 28.0, 30.0, 32.0, 34.0, 36.0, 40.0, 45.0, 50.0 };
92 for(Int_t pid = 0; pid < nPid; pid++) {
94 hMcIn[pid] = new TH1D(Form("hIn%d", pid), Form("Efficiency (pid %d)", pid),
96 hMcInNeg[pid] = new TH1D(Form("hInNeg%d", pid), Form("Efficiency (pid %d, q < 0)", pid),
98 hMcInPos[pid] = new TH1D(Form("hInPos%d", pid), Form("Efficiency (pid %d, q < 0)", pid),
102 hMcIn[pid]->SetMarkerStyle(29);
103 hMcIn[pid]->SetMarkerColor(color[pid]);
104 hMcInNeg[pid]->Sumw2();
105 hMcInNeg[pid]->SetMarkerStyle(24);
106 hMcInNeg[pid]->SetMarkerColor(color[pid]);
107 hMcInPos[pid]->Sumw2();
108 hMcInPos[pid]->SetMarkerStyle(20);
109 hMcInPos[pid]->SetMarkerColor(color[pid]);
111 hMcOut[pid] = new TH1D(Form("hMcOut%d", pid), Form("MC out (pid %d)", pid),
113 hMcOutNeg[pid] = new TH1D(Form("hMcOutNeg%d", pid), Form("MC out (pid %d, q < 0)", pid),
115 hMcOutPos[pid] = new TH1D(Form("hMcOutPos%d", pid), Form("MC out (pid %d, q < 0)", pid),
118 hMcOut[pid]->Sumw2();
119 hMcOut[pid]->SetMarkerStyle(29);
120 hMcOut[pid]->SetMarkerColor(color[pid]);
121 hMcOutNeg[pid]->Sumw2();
122 hMcOutNeg[pid]->SetMarkerStyle(24);
123 hMcOutNeg[pid]->SetMarkerColor(color[pid]);
124 hMcOutPos[pid]->Sumw2();
125 hMcOutPos[pid]->SetMarkerStyle(20);
126 hMcOutPos[pid]->SetMarkerColor(color[pid]);
128 hMcSec[pid] = new TH1D(Form("hSec%d", pid), Form("Secondaries (pid %d)", pid),
130 hMcSecNeg[pid] = new TH1D(Form("hSecNeg%d", pid), Form("Secondaries (pid %d, q < 0)", pid),
132 hMcSecPos[pid] = new TH1D(Form("hSecPos%d", pid), Form("Secondaries (pid %d, q < 0)", pid),
135 hMcSec[pid]->Sumw2();
136 hMcSec[pid]->SetMarkerStyle(29);
137 hMcSec[pid]->SetMarkerColor(color[pid]);
138 hMcSecNeg[pid]->Sumw2();
139 hMcSecNeg[pid]->SetMarkerStyle(24);
140 hMcSecNeg[pid]->SetMarkerColor(color[pid]);
141 hMcSecPos[pid]->Sumw2();
142 hMcSecPos[pid]->SetMarkerStyle(20);
143 hMcSecPos[pid]->SetMarkerColor(color[pid]);
145 hMcEff[pid] = new TH1D(Form("hEff%d", pid), Form("Efficiency (pid %d)", pid),
147 hMcEffNeg[pid] = new TH1D(Form("hEffNeg%d", pid), Form("Efficiency (pid %d, q < 0)", pid),
149 hMcEffPos[pid] = new TH1D(Form("hEffPos%d", pid), Form("Efficiency (pid %d, q < 0)", pid),
152 hMcEff[pid]->Sumw2();
153 hMcEff[pid]->SetMarkerStyle(29);
154 hMcEff[pid]->SetMarkerColor(color[pid]);
155 hMcEffNeg[pid]->Sumw2();
156 hMcEffNeg[pid]->SetMarkerStyle(24);
157 hMcEffNeg[pid]->SetMarkerColor(color[pid]);
158 hMcEffPos[pid]->Sumw2();
159 hMcEffPos[pid]->SetMarkerStyle(20);
160 hMcEffPos[pid]->SetMarkerColor(color[pid]);
164 if(strstr(mcFileName, ".dat")) {
166 AliXRDPROOFtoolkit tool;
167 TChain* chain = tool.MakeChain(mcFileName,"tree", 0, 1000);
171 TFile* mcFile = FindFileFresh(mcFileName);
175 Tree = (TTree*)mcFile->Get("tree");
181 DeDxEvent* event = 0;
182 TClonesArray* trackArray = 0;
183 TClonesArray* mcTrackArray = 0;
184 Tree->SetBranchAddress("event", &event);
185 Tree->SetBranchAddress("track" , &trackArray);
186 Tree->SetBranchAddress("trackMC" , &mcTrackArray);
187 Int_t nEvents = Tree->GetEntries();
188 cout << "Number of events: " << nEvents << endl;
190 if(maxEvents>0 && maxEvents < nEvents) {
193 cout << "N events was reduced to: " << maxEvents << endl;
196 Int_t currentRun = 0;
198 for(Int_t n = 0; n < nEvents; n++) {
203 cout << "Event: " << n+1 << "/" << nEvents << endl;
205 if(event->run != currentRun) {
207 cout << "New run: " << event->run << endl;
208 currentRun = event->run;
211 if(event->cent < centLow || event->cent > centHigh)
214 const Int_t nMcTracks = mcTrackArray->GetEntries();
216 for(Int_t i = 0; i < nMcTracks; i++) {
218 DeDxTrackMC* trackMC = (DeDxTrackMC*)mcTrackArray->At(i);
220 // if(TMath::Abs(trackMC->pdgMC)==3312 || TMath::Abs(trackMC->pdgMC)==3334)
223 hMcIn[0]->Fill(trackMC->ptMC);
224 hMcIn[trackMC->pidMC]->Fill(trackMC->ptMC);
226 if(trackMC->qMC < 0) {
228 hMcInNeg[0]->Fill(trackMC->ptMC);
229 hMcInNeg[trackMC->pidMC]->Fill(trackMC->ptMC);
232 hMcInPos[0]->Fill(trackMC->ptMC);
233 hMcInPos[trackMC->pidMC]->Fill(trackMC->ptMC);
237 const Int_t nTracks = trackArray->GetEntries();
239 for(Int_t i = 0; i < nTracks; i++) {
241 DeDxTrack* track = (DeDxTrack*)trackArray->At(i);
243 if(!(track->filter&1))
246 // if(TMath::Abs(track->mother)==3312 || TMath::Abs(track->mother)==3334)
247 // continue; // Xi+- or Omega+-!
249 hMcOut[0]->Fill(track->pt);
250 hMcOut[track->pid]->Fill(track->pt);
254 hMcOutNeg[0]->Fill(track->pt);
255 hMcOutNeg[track->pid]->Fill(track->pt);
258 hMcOutPos[0]->Fill(track->pt);
259 hMcOutPos[track->pid]->Fill(track->pt);
262 if(track->primary==0) {
263 hMcSec[0]->Fill(track->pt);
264 hMcSec[track->pid]->Fill(track->pt);
268 hMcSecNeg[0]->Fill(track->pt);
269 hMcSecNeg[track->pid]->Fill(track->pt);
272 hMcSecPos[0]->Fill(track->pt);
273 hMcSecPos[track->pid]->Fill(track->pt);
279 TH1D* hMcInPiKP = (TH1D*)hMcIn[1]->Clone("hMcInPiKP");
280 hMcInPiKP->Add(hMcIn[2]);
281 hMcInPiKP->Add(hMcIn[3]);
282 hMcInPiKP->Divide(hMcIn[0]);
284 for(Int_t pid = 0; pid < nPid; pid++) {
286 hMcSec[pid]->Divide(hMcSec[pid], hMcOut[pid]);
287 hMcSecNeg[pid]->Divide(hMcSecNeg[pid], hMcOutNeg[pid]);
288 hMcSecPos[pid]->Divide(hMcSecPos[pid], hMcOutPos[pid]);
290 hMcEff[pid] ->Divide(hMcOut[pid], hMcIn[pid]);
291 hMcEffNeg[pid]->Divide(hMcOutNeg[pid], hMcInNeg[pid]);
292 hMcEffPos[pid]->Divide(hMcOutPos[pid], hMcInPos[pid]);
299 //_______________________________________________________________________
300 void DrawEfficiency(const Char_t* fileName, const Char_t* effFileName)
302 TFile* file = FindFileFresh(fileName);
306 gStyle->SetOptStat(0);
308 const Double_t ptmin = 3.01;
309 const Double_t ptmax = 19.999;
310 // const Double_t ptmax = 49.999;
312 const Double_t effmin = 0.6;
313 const Double_t effmax = 0.9;
315 // const Double_t effmin = 0.0;
316 // const Double_t effmax = 1.5;
318 const Double_t secmin = 0.0;
319 const Double_t secmax = 0.1;
321 const Int_t nPid = 7;
323 TH1D* hEff[nPid] = {0, 0, 0, 0, 0, 0, 0 };
324 TH1D* hEffNeg[nPid] = {0, 0, 0, 0, 0, 0, 0 };
325 TH1D* hEffPos[nPid] = {0, 0, 0, 0, 0, 0, 0 };
326 TH1D* hSec[nPid] = {0, 0, 0, 0, 0, 0, 0 };
327 TH1D* hSecNeg[nPid] = {0, 0, 0, 0, 0, 0, 0 };
328 TH1D* hSecPos[nPid] = {0, 0, 0, 0, 0, 0, 0 };
329 TH1D* hOut[nPid] = {0, 0, 0, 0, 0, 0, 0 };
331 for(Int_t pid = 0; pid < nPid; pid++) {
333 hEff[pid] = (TH1D*)file->Get(Form("hEff%d", pid));
335 hEffNeg[pid] = (TH1D*)file->Get(Form("hEffNeg%d", pid));
337 hEffPos[pid] = (TH1D*)file->Get(Form("hEffPos%d", pid));
339 hSec[pid] = (TH1D*)file->Get(Form("hSec%d", pid));
341 hSecNeg[pid] = (TH1D*)file->Get(Form("hSecNeg%d", pid));
343 hSecPos[pid] = (TH1D*)file->Get(Form("hSecPos%d", pid));
345 hOut[pid] = (TH1D*)file->Get(Form("hMcOut%d", pid));
347 // hEff[pid]->Rebin(4);
348 // hEffNeg[pid]->Rebin(4);
349 // hEffPos[pid]->Rebin(4);
351 // hSec[pid]->Rebin(4);
352 // hSecNeg[pid]->Rebin(4);
353 // hSecPos[pid]->Rebin(4);
355 // hOut[pid]->Rebin(4);
357 // hEff[pid]->Scale(0.25);
358 // hEffNeg[pid]->Scale(0.25);
359 // hEffPos[pid]->Scale(0.25);
361 // hSec[pid]->Scale(0.25);
362 // hSecNeg[pid]->Scale(0.25);
363 // hSecPos[pid]->Scale(0.25);
365 // hOut[pid]->Scale(0.25);
367 hEff[pid]->GetXaxis()->SetRangeUser(ptmin, ptmax);
368 hEff[pid]->GetYaxis()->SetRangeUser(effmin, effmax);
369 hEffNeg[pid]->GetXaxis()->SetRangeUser(ptmin, ptmax);
370 hEffNeg[pid]->GetYaxis()->SetRangeUser(effmin, effmax);
371 hEffPos[pid]->GetXaxis()->SetRangeUser(ptmin, ptmax);
372 hEffPos[pid]->GetYaxis()->SetRangeUser(effmin, effmax);
373 hSec[pid]->GetXaxis()->SetRangeUser(ptmin, ptmax);
374 hSec[pid]->GetYaxis()->SetRangeUser(secmin, secmax);
375 hSecNeg[pid]->GetXaxis()->SetRangeUser(ptmin, ptmax);
376 hSecNeg[pid]->GetYaxis()->SetRangeUser(secmin, secmax);
377 hSecPos[pid]->GetXaxis()->SetRangeUser(ptmin, ptmax);
378 hSecPos[pid]->GetYaxis()->SetRangeUser(secmin, secmax);
379 hOut[pid]->GetXaxis()->SetRangeUser(ptmin, ptmax);
382 TCanvas* cChEff = new TCanvas("cChEff", "All efficiency", 800, 300);
384 cChEff->Divide(2, 1);
386 // TF1* pionEff = new TF1("pionEff", "pol0", 0.0, 50.0);
387 TF1* chEff = new TF1("chEff", "[0]*(1-[1]/x)", 0.0, 50.0);
388 chEff->SetLineColor(1);
389 chEff->SetParameters(0.7, 0.5);
390 hEff[0]->Fit(chEff, "", "", ptmin, ptmax);
394 hEffNeg[0]->Draw("SAME");
395 chEff->DrawCopy("SAME");
396 cChEff->SaveAs("eff_charged.gif");
398 TCanvas* cPionEff = new TCanvas("cPionEff", "Pion efficiency", 800, 300);
400 cPionEff->Divide(2, 1);
402 // TF1* pionEff = new TF1("pionEff", "pol0", 0.0, 50.0);
403 TF1* pionEff = new TF1("pionEff", "[0]*(1-[1]/x)", 0.0, 50.0);
404 pionEff->SetLineColor(2);
405 pionEff->SetParameters(0.7, 0.5);
406 hEff[1]->Fit(pionEff, "", "", ptmin, ptmax);
410 hEffNeg[1]->Draw("SAME");
411 pionEff->DrawCopy("SAME");
412 cPionEff->SaveAs("eff_pion.gif");
414 TCanvas* cKaonEff = new TCanvas("cKaonEff", "Kaon efficiency", 800, 300);
416 cKaonEff->Divide(2, 1);
418 // TF1* kaonEff = new TF1("kaonEff", "pol0", 0.0, 50.0);
419 TF1* kaonEff = new TF1("kaonEff", "[0]*(1-[1]/x)", 0.0, 50.0);
420 kaonEff->SetLineColor(3);
421 kaonEff->SetParameters(0.7, 0.5);
422 hEff[2]->Fit(kaonEff, "", "", ptmin, ptmax);
426 hEffNeg[2]->Draw("SAME");
427 kaonEff->DrawCopy("SAME");
428 cKaonEff->SaveAs("eff_kaon.gif");
430 TCanvas* cProtonEff = new TCanvas("cProtonEff", "Proton efficiency", 800, 300);
432 cProtonEff->Divide(2, 1);
434 // TF1* protonEff = new TF1("protonEff", "pol0", 0.0, 50.0);
435 TF1* protonEff = new TF1("protonEff", "[0]*(1-[1]/x)", 0.0, 50.0);
436 protonEff->SetLineColor(4);
437 protonEff->SetParameters(0.7, 0.5);
438 hEff[3]->Fit(protonEff, "", "", ptmin, ptmax);
442 hEffNeg[3]->Draw("SAME");
443 protonEff->DrawCopy("SAME");
444 cProtonEff->SaveAs("eff_proton.gif");
446 TCanvas* cAllEff = new TCanvas("cAllEff", "All efficiency", 400, 300);
449 TH1D* hDummy = (TH1D*)hEff[1]->Clone("hDummy");
451 hDummy->SetTitle("Efficiency vs p_{T}; p_{T} [GeV/c]; Efficiency");
454 chEff->DrawCopy("SAME");
455 pionEff->DrawCopy("SAME");
456 kaonEff->DrawCopy("SAME");
457 protonEff->DrawCopy("SAME");
458 cAllEff->SaveAs("eff_all.gif");
460 // TCanvas* cPionSec = new TCanvas("cPionSec", "Pion sec", 800, 300);
461 // cPionSec->Clear();
462 // cPionSec->Divide(2, 1);
464 // TF1* pionSec = new TF1("pionSec", "pol0", 0.0, 50.0);
465 // hSec[1]->Fit(pionSec, "", "", ptmin, ptmax);
468 // hSecPos[1]->Draw();
469 // hSecNeg[1]->Draw("SAME");
470 // pionSec->Draw("SAME");
471 // cPionSec->SaveAs("sec_pion.gif");
473 // TCanvas* cKaonSec = new TCanvas("cKaonSec", "Kaon sec", 800, 300);
474 // cKaonSec->Clear();
475 // cKaonSec->Divide(2, 1);
477 // TF1* kaonSec = new TF1("kaonSec", "pol0", 0.0, 50.0);
478 // hSec[2]->Fit(kaonSec, "", "", ptmin, ptmax);
481 // hSecPos[2]->Draw();
482 // hSecNeg[2]->Draw("SAME");
483 // kaonSec->Draw("SAME");
484 // cKaonSec->SaveAs("sec_kaon.gif");
486 // TCanvas* cProtonSec = new TCanvas("cProtonSec", "Proton sec", 800, 300);
487 // cProtonSec->Clear();
488 // cProtonSec->Divide(2, 1);
489 // cProtonSec->cd(1);
490 // TF1* protonSec = new TF1("protonSec", "pol0", 0.0, 50.0);
491 // hSec[3]->Fit(protonSec, "", "", ptmin, ptmax);
493 // cProtonSec->cd(2);
494 // hSecPos[3]->Draw();
495 // hSecNeg[3]->Draw("SAME");
496 // protonSec->Draw("SAME");
497 // cProtonSec->SaveAs("sec_proton.gif");
500 TCanvas* cEffRatioPi = new TCanvas("cEffRatioPi", "eff pi / eff all", 400, 300);
501 cEffRatioPi->Clear();
502 // TF1* pionEff = new TF1("pionEff", "pol0", 0.0, 50.0);
503 TF1* effRatioPi = new TF1("effRatioPi", "pol0", 0.0, 50.0);
504 effRatioPi->SetLineColor(6);
505 effRatioPi->SetParameters(0.7, 0.5);
506 TH1D* hEffRatioPi = (TH1D*)hEff[1]->Clone("hEffRatioPi");
507 hEffRatioPi->SetTitle("; p_{T} [GeV/c]; #epsilon_{ch}/#epsilon_{pi}");
508 hEffRatioPi->Divide(hEff[0], hEff[1], 1, 1, "B");
509 // hEffRatioPi->Divide(hEff[1], hEff[0]);
510 hEffRatioPi->GetXaxis()->SetRangeUser(0.0, 19.99);
511 hEffRatioPi->GetYaxis()->SetRangeUser(0.8, 1.1);
512 hEffRatioPi->SetStats(kTRUE);
513 hEffRatioPi->Fit(effRatioPi, "", "", ptmin, ptmax);
514 cEffRatioPi->SaveAs("eff_ratio_pi.gif");
515 cEffRatioPi->SaveAs("eff_ratio_pi.pdf");
517 TCanvas* cEffRatioK = new TCanvas("cEffRatioK", "eff K / eff all", 400, 300);
519 TF1* effRatioK = new TF1("effRatioK", "exp(-[1]*x)+[0]", 0.0, 50.0);
520 effRatioK->SetParameters(1.0, 1.0);
521 effRatioK->SetLineColor(6);
522 TH1D* hEffChargedRebinned = (TH1D*)hEff[0]->Clone("hEffChargedRebinned");
523 hEffChargedRebinned->Rebin(2);
524 TH1D* hEffRatioK = (TH1D*)hEff[2]->Clone("hEffRatioK");
525 hEffRatioK->Rebin(2);
526 hEffRatioK->SetTitle("; p_{T} [GeV/c]; #epsilon_{ch}/#epsilon_{K}");
527 hEffRatioK->Divide(hEffChargedRebinned, hEffRatioK, 1, 1, "B");
528 // hEffRatioK->Divide(hEff[1], hEff[0]);
529 hEffRatioK->GetXaxis()->SetRangeUser(0.0, 19.99);
530 hEffRatioK->GetYaxis()->SetRangeUser(0.8, 1.1);
531 hEffRatioK->SetStats(kTRUE);
532 hEffRatioK->Fit(effRatioK, "", "", ptmin, ptmax);
533 cEffRatioK->SaveAs("eff_ratio_K.gif");
534 cEffRatioK->SaveAs("eff_ratio_K.pdf");
536 TCanvas* cEffRatioP = new TCanvas("cEffRatioP", "eff p / eff all", 400, 300);
538 TF1* effRatioP = new TF1("effRatioP", "pol0", 0.0, 50.0);
539 effRatioP->SetLineColor(6);
540 effRatioP->SetParameters(0.7, 0.5);
541 // TH1D* hEffChargedRebinned = (TH1D*)hEff[0]->Clone("hEffChargedRebinned");
542 // hEffChargedRebinned->Rebin(2);
543 TH1D* hEffRatioP = (TH1D*)hEff[3]->Clone("hEffRatioP");
544 hEffRatioP->Rebin(2);
545 hEffRatioP->SetTitle("; p_{T} [GeV/c]; #epsilon_{ch}/#epsilon_{p}");
546 hEffRatioP->Divide(hEffChargedRebinned, hEffRatioP, 1, 1, "B");
547 // hEffRatioP->Divide(hEff[1], hEff[0]);
548 hEffRatioP->GetXaxis()->SetRangeUser(0.0, 19.99);
549 hEffRatioP->GetYaxis()->SetRangeUser(0.8, 1.1);
550 hEffRatioP->SetStats(kTRUE);
551 hEffRatioP->Fit(effRatioP, "", "", ptmin, ptmax);
552 cEffRatioP->SaveAs("eff_ratio_p.gif");
553 cEffRatioP->SaveAs("eff_ratio_p.pdf");
556 // TCanvas* cMuonRatio = new TCanvas("cMuonRatio", "muon / all", 400, 300);
557 // cMuonRatio->Clear();
558 // // TF1* pionMuon = new TF1("pionMuon", "pol0", 0.0, 50.0);
559 // TF1* muonRatio = new TF1("muonRatio", "pol0", 0.0, 50.0);
560 // muonRatio->SetLineColor(1);
561 // muonRatio->SetParameter(0, 0.01);
562 // TH1D* hMuonRatio = (TH1D*)hOut[5]->Clone("hMuonRatio");
563 // hMuonRatio->SetTitle("; p_{T} [GeV/c]; muon/all");
564 // hMuonRatio->Divide(hOut[5], hOut[0], 1, 1, "B");
565 // hMuonRatio->GetYaxis()->SetRangeUser(0.0, 0.05);
566 // hMuonRatio->SetStats(kTRUE);
567 // hMuonRatio->Fit(muonRatio, "", "", ptmin, ptmax);
568 // cMuonRatio->SaveAs("muon_ratio.gif");
569 // cMuonRatio->SaveAs("muon_ratio.pdf");
571 // TCanvas* cElectronRatio = new TCanvas("cElectronRatio", "electron / all", 400, 300);
572 // cElectronRatio->Clear();
573 // // TF1* pionElectron = new TF1("pionElectron", "pol0", 0.0, 50.0);
574 // TF1* electronRatio = new TF1("electronRatio", "pol0", 0.0, 50.0);
575 // electronRatio->SetLineColor(1);
576 // electronRatio->SetParameter(0, 0.01);
577 // TH1D* hElectronRatio = (TH1D*)hOut[4]->Clone("hElectronRatio");
578 // hElectronRatio->SetTitle("; p_{T} [GeV/c]; electron/all");
579 // hElectronRatio->Divide(hOut[4], hOut[0], 1, 1, "B");
580 // hElectronRatio->GetYaxis()->SetRangeUser(0.0, 0.05);
581 // hElectronRatio->SetStats(kTRUE);
582 // hElectronRatio->SetMarkerColor(6);
583 // hElectronRatio->Fit(electronRatio, "", "", ptmin, ptmax);
584 // cElectronRatio->SaveAs("electron_ratio.gif");
585 // cElectronRatio->SaveAs("electron_ratio.pdf");
588 TFile* effFile = new TFile(effFileName, "RECREATE");
597 //_______________________________________________________________________
598 void DrawCorrection(const Char_t* fileNamePYTHIA, const Char_t* fileNamePHOJET)
600 TFile* filePYTHIA = FindFileFresh(fileNamePYTHIA);
604 TFile* filePHOJET = FindFileFresh(fileNamePHOJET);
608 gStyle->SetOptStat(0);
610 const Double_t ptmin = 0.0;
611 const Double_t ptmax = 4.999;
612 // const Double_t ptmax = 49.999;
614 const Double_t effmin = 0.95;
615 const Double_t effmax = 1.12;
617 const Int_t nPid = 7;
619 TH1D* hInPYTHIA[nPid] = {0, 0, 0, 0, 0, 0, 0 };
620 TH1D* hInPHOJET[nPid] = {0, 0, 0, 0, 0, 0, 0 };
622 for(Int_t pid = 0; pid < nPid; pid++) {
624 hInPYTHIA[pid] = (TH1D*)filePYTHIA->Get(Form("hIn%d", pid));
625 hInPYTHIA[pid]->GetXaxis()->SetRangeUser(ptmin, ptmax);
626 hInPYTHIA[pid]->GetYaxis()->SetRangeUser(effmin, effmax);
628 hInPHOJET[pid] = (TH1D*)filePHOJET->Get(Form("hIn%d", pid));
629 hInPHOJET[pid]->GetXaxis()->SetRangeUser(ptmin, ptmax);
630 hInPHOJET[pid]->GetYaxis()->SetRangeUser(effmin, effmax);
633 hInPYTHIA[1]->Add(hInPYTHIA[2]);
634 hInPYTHIA[1]->Add(hInPYTHIA[3]);
635 hInPYTHIA[0]->Divide(hInPYTHIA[1], hInPYTHIA[0], 1, 1, "B");
637 TH1D* histPYTHIA = HistInvert(hInPYTHIA[0]);
638 histPYTHIA->SetLineColor(2);
639 histPYTHIA->SetMarkerColor(2);
641 hInPHOJET[1]->Add(hInPHOJET[2]);
642 hInPHOJET[1]->Add(hInPHOJET[3]);
643 hInPHOJET[0]->Divide(hInPHOJET[1], hInPHOJET[0], 1, 1, "B");
645 TH1D* histPHOJET = HistInvert(hInPHOJET[0]);
646 histPHOJET->SetLineColor(4);
647 histPHOJET->SetMarkerColor(4);
649 TCanvas* cChCorrection = new TCanvas("cChCorrection", "All efficiency", 400, 300);
650 cChCorrection->Clear();
652 cChCorrection->SetGridy();
654 histPYTHIA->GetYaxis()->SetRangeUser(effmin, effmax);
655 histPYTHIA->SetTitle("N_{ch}/(#pi + K + p) for primaries at generator level; p_{T} [GeV/c]; Ratio");
658 histPHOJET->Draw("SAME");
660 TLegend* legend = new TLegend(0.55, 0.22, 0.79, 0.42);
661 legend->SetBorderSize(0);
662 legend->SetFillColor(0);
663 legend->AddEntry(histPYTHIA, "PYTHIA", "P");
664 legend->AddEntry(histPHOJET, "PHOJET", "P");
667 cChCorrection->SaveAs("charged_over_piKp.gif");
669 TFile* file = new TFile("correction.root", "RECREATE");
670 histPYTHIA->SetName("histPYTHIA");
671 histPHOJET->SetName("histPHOJET");
677 //_______________________________________________________________________
678 TH1D* HistInvert(TH1D* hist)
680 TH1D* histNew = new TH1D(*hist);
682 histNew->SetName(Form("%s_inv", hist->GetName()));
683 histNew->SetTitle(Form("%s (inverted)", hist->GetTitle()));
685 const Int_t nBins = hist->GetNbinsX();
687 for(Int_t i = 1; i <= nBins; i++) {
689 if(hist->GetBinContent(i) == 0)
692 histNew->SetBinContent(i, 1.0/hist->GetBinContent(i));
693 histNew->SetBinError(i, hist->GetBinError(i)/hist->GetBinContent(i)/hist->GetBinContent(i));