]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/drawProtonQAResults.C
Warning fixed
[u/mrichter/AliRoot.git] / PWG2 / drawProtonQAResults.C
1 void drawProtonQAResults(const char* filename1 = "Protons.QA.root",
2                          const char* filename2 = "Protons.MC.QA.root",
3                          const char* filename3 = "Protons.Efficiency.root") {
4   //Macro to visualize the results of the proton QA task
5   //TCanvas objects: 15
6   gStyle->SetPalette(1,0);
7  
8   TFile *fQA = TFile::Open(filename1);
9   TList *listGlobalQA = (TList *)fQA->Get("globalQAList");
10   drawCutStatistics(listGlobalQA);
11  
12   TFile *fMC = TFile::Open(filename2);
13   TList *listPDG = (TList *)fMC->Get("pdgCodeList");  
14   TList *listMCProcesses = (TList *)fMC->Get("mcProcessList");  
15   drawMCQA(listPDG,listMCProcesses);
16   
17   TFile *fEfficiency = TFile::Open(filename3);
18   TList *listEfficiency = (TList *)fEfficiency->Get("efficiencyList");
19   drawEfficiency(listEfficiency);
20
21   fQA->Close();
22   fMC->Close();
23   fEfficiency->Close();
24 }
25
26 //________________________________________//
27 void drawCutStatistics(TList *list) {
28   //Function to display the statistics from the cuts
29   //The histogram shows the influence of each cut on the primary
30   //and secondary (anti)protons
31   const Int_t NQAHISTOSPERLIST = 26;
32   
33   Double_t gEntriesQA2DList[12] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
34   Double_t gEntriesQAPrimaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryProtonsRejectedList[NQAHISTOSPERLIST];
35   Double_t gEntriesQASecondaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryProtonsRejectedList[NQAHISTOSPERLIST];
36   Double_t gEntriesQAPrimaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
37   Double_t gEntriesQASecondaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
38
39   for(Int_t i = 0; i < NQAHISTOSPERLIST; i++) {
40     gEntriesQAPrimaryProtonsAcceptedList[i] = 0.0;
41     gEntriesQAPrimaryProtonsRejectedList[i] = 0.0;
42     gEntriesQASecondaryProtonsAcceptedList[i] = 0.0;
43     gEntriesQASecondaryProtonsRejectedList[i] = 0.0;
44     gEntriesQAPrimaryAntiProtonsAcceptedList[i] = 0.0;
45     gEntriesQAPrimaryAntiProtonsRejectedList[i] = 0.0;
46     gEntriesQASecondaryAntiProtonsAcceptedList[i] = 0.0;
47     gEntriesQASecondaryAntiProtonsRejectedList[i] = 0.0;
48   }
49
50   TList *fQA2DList = (TList *)list->At(0);
51   GetQAEntries(fQA2DList,gEntriesQA2DList);
52   TH3F *gHistYPtPDGProtonsPass = (TH3F *)fQA2DList->At(10);
53   TH3F *gHistYPtPDGAntiProtonsPass = (TH3F *)fQA2DList->At(11);
54
55   TList *fQAPrimaryProtonsAcceptedList = (TList *)list->At(1);
56   GetQAEntries(fQAPrimaryProtonsAcceptedList,gEntriesQAPrimaryProtonsAcceptedList);
57
58   TList *fQAPrimaryProtonsRejectedList = (TList *)list->At(2);
59   GetQAEntries(fQAPrimaryProtonsRejectedList,gEntriesQAPrimaryProtonsRejectedList);
60
61   TList *fQASecondaryProtonsAcceptedList = (TList *)list->At(3);
62   GetQAEntries(fQASecondaryProtonsAcceptedList,gEntriesQASecondaryProtonsAcceptedList);
63
64   TList *fQASecondaryProtonsRejectedList = (TList *)list->At(4);
65   GetQAEntries(fQASecondaryProtonsRejectedList,gEntriesQASecondaryProtonsRejectedList);
66
67   TList *fQAPrimaryAntiProtonsAcceptedList = (TList *)list->At(5);
68   GetQAEntries(fQAPrimaryAntiProtonsAcceptedList,gEntriesQAPrimaryAntiProtonsAcceptedList);
69
70   TList *fQAPrimaryAntiProtonsRejectedList = (TList *)list->At(6);
71   GetQAEntries(fQAPrimaryAntiProtonsRejectedList,gEntriesQAPrimaryAntiProtonsRejectedList);
72
73   TList *fQASecondaryAntiProtonsAcceptedList = (TList *)list->At(7);
74   GetQAEntries(fQASecondaryAntiProtonsAcceptedList,gEntriesQASecondaryAntiProtonsAcceptedList);
75
76   TList *fQASecondaryAntiProtonsRejectedList = (TList *)list->At(8);
77   GetQAEntries(fQASecondaryAntiProtonsRejectedList,gEntriesQASecondaryAntiProtonsRejectedList);
78
79   //_______________________________________________________//
80   //Create the histograms
81   const Int_t nx = 26;
82   char *fCutName[nx] = {"Tracks","",
83                         "ITS Clusters",
84                         "#chi^{2}/N_{ITS-Clusters}",
85                         "TPC Clusters",
86                         "#chi^{2}/N_{TPC-Clusters}",
87                         "ExtCov11",
88                         "ExtCov22",
89                         "ExtCov33",
90                         "ExtCov44",
91                         "ExtCov55",
92                         "#sigma_{Vertex}",
93                         "#sigma_{Vertex-TPC}",
94                         "DCA_{xy}",
95                         "DCA_{xy}(TPC)",
96                         "DCA_{z}",
97                         "DCA_{z}(TPC)",
98                         "#chi^{2}(vertex)",
99                         "ITS refit",
100                         "TPC refit",
101                         "ESD pid",
102                         "TPC pid","",
103                         "N_{Secondaries}/N_{total}","",""};
104   char *fCutITSName[6] = {"SPD_{1}","SPD_{2}",
105                           "SDD_{1}","SDD_{2}",
106                           "SSD_{1}","SSD_{2}"};
107
108   //cut influence
109   TH2F *hEmpty = new TH2F("hEmpty","",nx,0,nx,100,0,100); 
110   hEmpty->SetStats(kFALSE); 
111   hEmpty->SetMarkerStyle(kFullCircle);
112   hEmpty->SetLineColor(2); hEmpty->SetMarkerColor(2);
113   hEmpty->GetYaxis()->SetTitle("Influence of the cuts [%]");
114   for(Int_t i = 1; i <= nx; i++) 
115     hEmpty->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
116   hEmpty->GetXaxis()->SetLabelOffset(0.01); 
117   hEmpty->GetXaxis()->SetLabelSize(0.045);
118
119   //primary protons
120   TH1F *hPrimaryProtons = new TH1F("hPrimaryProtons","",nx,0,nx); 
121   hPrimaryProtons->SetStats(kFALSE); 
122   hPrimaryProtons->SetMarkerStyle(kFullCircle);
123   hPrimaryProtons->SetLineColor(4); hPrimaryProtons->SetLineWidth(2); 
124   hPrimaryProtons->SetMarkerColor(4);
125   hPrimaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
126   for(Int_t i = 1; i <= nx; i++) {
127     hPrimaryProtons->SetBinContent(i,-10.);
128     hPrimaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
129   }
130   hPrimaryProtons->GetXaxis()->SetLabelOffset(0.01); 
131   hPrimaryProtons->GetXaxis()->SetLabelSize(0.045);
132
133   //secondary protons
134   TH1F *hSecondaryProtons = new TH1F("hSecondaryProtons","",nx,0,nx); 
135   hSecondaryProtons->SetStats(kFALSE); 
136   hSecondaryProtons->SetMarkerStyle(22);
137   hSecondaryProtons->SetMarkerSize(1.4);
138   hSecondaryProtons->SetLineColor(2); hSecondaryProtons->SetLineWidth(2); 
139   hSecondaryProtons->SetMarkerColor(2);
140   hSecondaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
141   for(Int_t i = 1; i <= nx; i++) {
142     hSecondaryProtons->SetBinContent(i,-10.);
143     hSecondaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
144   }
145   hSecondaryProtons->GetXaxis()->SetLabelOffset(0.01); 
146   hSecondaryProtons->GetXaxis()->SetLabelSize(0.045);
147
148   //primary antiprotons
149   TH1F *hPrimaryAntiProtons = new TH1F("hPrimaryAntiProtons","",nx,0,nx); 
150   hPrimaryAntiProtons->SetStats(kFALSE); 
151   hPrimaryAntiProtons->SetMarkerStyle(kFullCircle);
152   hPrimaryAntiProtons->SetLineColor(4); hPrimaryAntiProtons->SetLineWidth(2); 
153   hPrimaryAntiProtons->SetMarkerColor(4);
154   hPrimaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
155   for(Int_t i = 1; i <= nx; i++) {
156     hPrimaryAntiProtons->SetBinContent(i,-10.);
157     hPrimaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
158   }
159   hPrimaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
160   hPrimaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
161
162   //secondary antiprotons
163   TH1F *hSecondaryAntiProtons = new TH1F("hSecondaryAntiProtons","",nx,0,nx); 
164   hSecondaryAntiProtons->SetStats(kFALSE); 
165   hSecondaryAntiProtons->SetMarkerStyle(22);
166   hSecondaryAntiProtons->SetMarkerSize(1.4);
167   hSecondaryAntiProtons->SetLineColor(2); hSecondaryAntiProtons->SetLineWidth(2); 
168   hSecondaryAntiProtons->SetMarkerColor(2);
169   hSecondaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
170   for(Int_t i = 1; i <= nx; i++) {
171     hSecondaryAntiProtons->SetBinContent(i,-10.);
172     hSecondaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
173   }
174   hSecondaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
175   hSecondaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
176   //_______________________________________________________//
177
178   //1D for primary protons
179   //cout<<"_____________________________________________________"<<endl;
180   //cout<<"_______________PRIMARY PROTONS_______________________"<<endl;
181   hPrimaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[1]));
182
183   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
184     hPrimaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryProtonsAcceptedList[i-2],
185                                                      gEntriesQAPrimaryProtonsRejectedList[i-2]));
186   
187   //1D for secondary protons
188   //cout<<"_____________________________________________________"<<endl;
189   //cout<<"_______________SECONDARY PROTONS_____________________"<<endl;
190   hSecondaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[2],gEntriesQA2DList[3]));
191   
192   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
193     hSecondaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryProtonsAcceptedList[i-2],
194                                                        gEntriesQASecondaryProtonsRejectedList[i-2]));
195   hSecondaryProtons->SetBinContent(24,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[2]));
196
197   //1D for primary antiprotons
198   //cout<<"_________________________________________________________"<<endl;
199   //cout<<"_______________PRIMARY ANTIPROTONS_______________________"<<endl;
200   hPrimaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[5]));
201   
202   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
203     hPrimaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryAntiProtonsAcceptedList[i-2],
204                                                          gEntriesQAPrimaryAntiProtonsRejectedList[i-2]));
205   
206   //1D for secondary antiprotons
207   //cout<<"_________________________________________________________"<<endl;
208   //cout<<"_______________SECONDARY ANTIPROTONS_____________________"<<endl;
209   hSecondaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[6],gEntriesQA2DList[7]));
210
211   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
212     hSecondaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryAntiProtonsAcceptedList[i-2],
213                                                            gEntriesQASecondaryAntiProtonsRejectedList[i-2]));
214   hSecondaryAntiProtons->SetBinContent(24,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[6]));
215
216   TLatex *t1 = new TLatex();
217   t1->SetTextSize(0.04);
218   //_________________________________________________________//
219   TCanvas *c1 = new TCanvas("c1","Cut Influence - Protons",0,0,700,400);
220   c1->SetFillColor(10); c1->GetFrame()->SetFillColor(10);
221   c1->SetHighLightColor(10); c1->SetBottomMargin(0.15);
222   c1->SetGridx(); c1->SetGridy();
223
224   for(Int_t i = 1; i <= nx; i++) {
225     hPrimaryProtons->SetBinError(i,1.0);
226     hSecondaryProtons->SetBinError(i,1.0);
227   }
228   hEmpty->DrawCopy();
229   hPrimaryProtons->DrawCopy("EHISTSAME");
230   hSecondaryProtons->DrawCopy("EHISTSAME");
231   DrawMarker(20.5, 90, 20, 1.2, 4);
232   t1->DrawLatex(21,88,"Primary p");
233   DrawMarker(20.5, 80, 22, 1.2, 2);
234   t1->DrawLatex(21,78,"Secondary p");
235
236   c1->SaveAs("CutInfluence-Protons.gif");
237
238   //_________________________________________________________//
239   TCanvas *c2 = new TCanvas("c2","Cut Influence - AntiProtons",50,50,700,400);
240   c2->SetFillColor(10); c2->GetFrame()->SetFillColor(10);
241   c2->SetHighLightColor(10); c2->SetBottomMargin(0.15);
242   c2->SetGridx(); c2->SetGridy();
243
244   for(Int_t i = 1; i <= nx; i++) {
245     hPrimaryAntiProtons->SetBinError(i,1.0);
246     hSecondaryAntiProtons->SetBinError(i,1.0);
247   }
248   hEmpty->DrawCopy();
249   hPrimaryAntiProtons->DrawCopy("EHISTSAME");
250   hSecondaryAntiProtons->DrawCopy("EHISTSAME");
251   DrawMarker(20.5, 90, 20, 1.2, 4);
252   t1->DrawLatex(21,88,"Primary #bar{p}");
253   DrawMarker(20.5, 80, 22, 1.2, 2);
254   t1->DrawLatex(21,78,"Secondary #bar{p}");
255
256   c2->SaveAs("CutInfluence-AntiProtons.gif");
257
258   //_________________________________________________________//
259   //ITS layers influence
260   TH2F *hEmptyITS = new TH2F("hEmptyITS","",10,0,10,100,0,100); 
261   hEmptyITS->SetStats(kFALSE); 
262   hEmptyITS->SetMarkerStyle(kFullCircle);
263   hEmptyITS->SetLineColor(2); hEmptyITS->SetMarkerColor(2);
264   hEmptyITS->GetYaxis()->SetTitle("Influence of the ITS layers [%]");
265   hEmptyITS->GetYaxis()->SetTitleOffset(1.3);
266   for(Int_t i = 1; i <= 6; i++) 
267     hEmptyITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
268   hEmptyITS->GetXaxis()->SetLabelOffset(0.01); 
269   hEmptyITS->GetXaxis()->SetLabelSize(0.045);
270
271   //_________________________________________________________//
272   //primary protons
273   TH1F *hPrimaryProtonsITS = new TH1F("hPrimaryProtonsITS","",7,0,7); 
274   hPrimaryProtonsITS->SetStats(kFALSE); 
275   hPrimaryProtonsITS->SetMarkerStyle(kFullCircle);
276   hPrimaryProtonsITS->SetLineColor(4); hPrimaryProtonsITS->SetLineWidth(2); 
277   hPrimaryProtonsITS->SetMarkerColor(4);
278   hPrimaryProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
279   for(Int_t i = 1; i <= 6; i++) {
280     hPrimaryProtonsITS->SetBinContent(i,-10.);
281     hPrimaryProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
282   }
283   hPrimaryProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
284   hPrimaryProtonsITS->GetXaxis()->SetLabelSize(0.045);
285
286   //secondary protons
287   TH1F *hSecondaryProtonsITS = new TH1F("hSecondaryProtonsITS","",7,0,7); 
288   hSecondaryProtonsITS->SetStats(kFALSE); 
289   hSecondaryProtonsITS->SetMarkerStyle(22);
290   hSecondaryProtonsITS->SetMarkerSize(1.4);
291   hSecondaryProtonsITS->SetLineColor(2); hSecondaryProtonsITS->SetLineWidth(2); 
292   hSecondaryProtonsITS->SetMarkerColor(2);
293   hSecondaryProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
294   for(Int_t i = 1; i <= 6; i++) {
295     hSecondaryProtonsITS->SetBinContent(i,-10.);
296     hSecondaryProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
297   }
298   hSecondaryProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
299   hSecondaryProtonsITS->GetXaxis()->SetLabelSize(0.045);
300
301   //primary antiprotons
302   TH1F *hPrimaryAntiProtonsITS = new TH1F("hPrimaryAntiProtonsITS","",7,0,7); 
303   hPrimaryAntiProtonsITS->SetStats(kFALSE); 
304   hPrimaryAntiProtonsITS->SetMarkerStyle(kFullCircle);
305   hPrimaryAntiProtonsITS->SetLineColor(4); hPrimaryAntiProtonsITS->SetLineWidth(2); 
306   hPrimaryAntiProtonsITS->SetMarkerColor(4);
307   hPrimaryAntiProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
308   for(Int_t i = 1; i <= 6; i++) {
309     hPrimaryAntiProtonsITS->SetBinContent(i,-10.);
310     hPrimaryAntiProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
311   }
312   hPrimaryAntiProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
313   hPrimaryAntiProtonsITS->GetXaxis()->SetLabelSize(0.045);
314
315   //secondary antiprotons
316   TH1F *hSecondaryAntiProtonsITS = new TH1F("hSecondaryAntiProtonsITS","",7,0,7); 
317   hSecondaryAntiProtonsITS->SetStats(kFALSE); 
318   hSecondaryAntiProtonsITS->SetMarkerStyle(22);
319   hSecondaryAntiProtonsITS->SetMarkerSize(1.4);
320   hSecondaryAntiProtonsITS->SetLineColor(2); hSecondaryAntiProtonsITS->SetLineWidth(2); 
321   hSecondaryAntiProtonsITS->SetMarkerColor(2);
322   hSecondaryAntiProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
323   for(Int_t i = 1; i <= 6; i++) {
324     hSecondaryAntiProtonsITS->SetBinContent(i,-10.);
325     hSecondaryAntiProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
326   }
327   hSecondaryAntiProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
328   hSecondaryAntiProtonsITS->GetXaxis()->SetLabelSize(0.045);
329
330   //_______________________________________________________//
331   TCanvas *c9 = new TCanvas("c9","ITS cluster map - (anti)protons",
332                             100,100,700,400);
333   c9->SetFillColor(10); c9->GetFrame()->SetFillColor(10);
334   c9->SetHighLightColor(10); c9->Divide(2,1);
335   for(Int_t i = 1; i <= 6; i++) {
336     hPrimaryProtonsITS->SetBinError(i,1.0);
337     hSecondaryProtonsITS->SetBinError(i,1.0);
338     hPrimaryAntiProtonsITS->SetBinError(i,1.0);
339     hSecondaryAntiProtonsITS->SetBinError(i,1.0);
340   }
341   c9->cd(1)->SetBottomMargin(0.15);
342   c9->cd(1)->SetLeftMargin(0.15);
343   c9->cd(1)->SetGridx(); c9->cd(1)->SetGridy();
344   hEmptyITS->SetTitle("Protons");
345   hEmptyITS->DrawCopy();
346
347   for(Int_t i = 1; i < 7; i++) {
348     hPrimaryProtonsITS->SetBinContent(i,GetPercentage(gEntriesQAPrimaryProtonsAcceptedList[19+i],
349                                                       gEntriesQAPrimaryProtonsRejectedList[19+i]));
350     hSecondaryProtonsITS->SetBinContent(i,GetPercentage(gEntriesQASecondaryProtonsAcceptedList[19+i],
351                                                         gEntriesQASecondaryProtonsRejectedList[19+i]));
352   }
353   hPrimaryProtonsITS->DrawCopy("EHISTSAME");
354   hSecondaryProtonsITS->DrawCopy("EHISTSAME");
355   DrawMarker(6.5, 90, 20, 1.2, 4);
356   t1->DrawLatex(7,88,"Primary p");
357   DrawMarker(6.5, 80, 22, 1.2, 2);
358   t1->DrawLatex(7,78,"Secondary p");
359
360   c9->cd(2)->SetBottomMargin(0.15);
361   c9->cd(2)->SetLeftMargin(0.15);
362   c9->cd(2)->SetGridx(); c9->cd(2)->SetGridy();
363   hEmptyITS->SetTitle("Antiprotons");
364   hEmptyITS->DrawCopy();
365   for(Int_t i = 1; i < 7; i++) {
366     hPrimaryAntiProtonsITS->SetBinContent(i,GetPercentage(gEntriesQAPrimaryAntiProtonsAcceptedList[19+i],
367                                                           gEntriesQAPrimaryAntiProtonsRejectedList[19+i]));
368     hSecondaryAntiProtonsITS->SetBinContent(i,GetPercentage(gEntriesQASecondaryAntiProtonsAcceptedList[19+i],
369                                                             gEntriesQASecondaryAntiProtonsRejectedList[19+i]));
370   }
371   hPrimaryAntiProtonsITS->DrawCopy("EHISTSAME");
372   hSecondaryAntiProtonsITS->DrawCopy("EHISTSAME");
373   DrawMarker(6.5, 90, 20, 1.2, 4);
374   t1->DrawLatex(7,88,"Primary #bar{p}");
375   DrawMarker(6.5, 80, 22, 1.2, 2);
376   t1->DrawLatex(7,78,"Secondary #bar{p}");
377
378   c9->SaveAs("CutInfluence-ITS.gif");
379   
380   //Efficiency - Contamination plots
381   DrawContamination(fQA2DList);
382   DrawCutEfficiency(fQA2DList);
383   DrawComposition(gHistYPtPDGProtonsPass,gHistYPtPDGAntiProtonsPass);
384 }
385
386 //________________________________________//
387 void DrawComposition(TH3F *gHistYPtPDGProtons,
388                      TH3F *gHistYPtPDGAntiProtons) {
389   //Function to display the composition of secondary (anti)protons
390   //that survive the quality criteria
391   Double_t nParticleCompositionProtonY[100], nParticleCompositionProtonPt[100];
392   Double_t nParticleCompositionAntiProtonY[100], nParticleCompositionAntiProtonPt[100];
393   Double_t gY[100], gPt[100];
394   for(Int_t iBins = 0; iBins < 100; iBins++) {
395     nParticleCompositionProtonY[iBins] = 0;
396     nParticleCompositionProtonPt[iBins] = 0;
397     nParticleCompositionAntiProtonY[iBins] = 0;
398     nParticleCompositionAntiProtonPt[iBins] = 0;
399     gY[iBins] = 0;
400     gPt[iBins] = 0;
401   }
402   
403   TGraph *gParticleProtonY[14];
404   TGraph *gParticleProtonPt[14];
405   TGraph *gParticleAntiProtonY[14];
406   TGraph *gParticleAntiProtonPt[14];
407   for(Int_t iParticle = 0; iParticle < 14; iParticle++) {
408     GetComposition(iParticle,
409                    gHistYPtPDGProtons,
410                    nParticleCompositionProtonY,
411                    gY, nParticleCompositionProtonPt, gPt);
412     gParticleProtonY[iParticle] = new TGraph(gHistYPtPDGProtons->GetNbinsX(),
413                                        gY,nParticleCompositionProtonY);
414     gParticleProtonY[iParticle]->SetMarkerStyle(iParticle+20);
415     gParticleProtonY[iParticle]->SetMarkerSize(1.2);
416
417     gParticleProtonPt[iParticle] = new TGraph(gHistYPtPDGProtons->GetNbinsY(),
418                                         gPt,nParticleCompositionProtonPt);
419     gParticleProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
420     gParticleProtonPt[iParticle]->SetMarkerSize(1.2);
421
422     GetComposition(iParticle,
423                    gHistYPtPDGAntiProtons,
424                    nParticleCompositionAntiProtonY,
425                    gY, nParticleCompositionAntiProtonPt, gPt);
426     gParticleAntiProtonY[iParticle] = new TGraph(gHistYPtPDGAntiProtons->GetNbinsX(),
427                                        gY,nParticleCompositionAntiProtonY);
428     gParticleAntiProtonY[iParticle]->SetMarkerStyle(iParticle+20);
429     gParticleAntiProtonY[iParticle]->SetMarkerSize(1.2);
430
431     gParticleAntiProtonPt[iParticle] = new TGraph(gHistYPtPDGAntiProtons->GetNbinsY(),
432                                         gPt,nParticleCompositionAntiProtonPt);
433     gParticleAntiProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
434     gParticleAntiProtonPt[iParticle]->SetMarkerSize(1.2);
435   }
436
437   //_________________________________________________________//
438   char *fParticleName[14] = {"Primary","K_{L}","#pi","K_{S}","K",
439                              "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
440                              "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
441   TLatex *t1 = new TLatex();
442   t1->SetTextSize(0.04);
443
444   TH2F *hEmptyY = new TH2F("hEmptyY","",100,-1.2,1.2,100,0,120); 
445   hEmptyY->SetStats(kFALSE); 
446   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
447   hEmptyY->GetXaxis()->SetTitle("y");
448
449   TCanvas *c12 = new TCanvas("c12",
450                              "Composition of accepted secondaries vs y",
451                             550,550,700,400);
452   c12->SetFillColor(10); c12->GetFrame()->SetFillColor(10); c12->Divide(2,1);
453   c12->SetHighLightColor(10); c12->cd(1)->SetBottomMargin(0.15);
454   c12->cd(1)->SetGridx(); c12->cd(1)->SetGridy();
455   hEmptyY->DrawCopy();
456   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
457     //if((iParticle == 0)||(iParticle == 2)||(iParticle == 5)||(iParticle == 6)||(iParticle == 8))
458     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
459       gParticleProtonY[iParticle]->Draw("P");
460     if(iParticle < 5) {
461       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
462       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
463     }
464     else {
465       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
466       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
467     }
468   }
469
470   c12->SetHighLightColor(10); c12->cd(2)->SetBottomMargin(0.15);
471   c12->cd(2)->SetGridx(); c12->cd(2)->SetGridy();
472   hEmptyY->DrawCopy();
473   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
474     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
475       gParticleAntiProtonY[iParticle]->Draw("P");
476     if(iParticle < 5) {
477       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
478       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
479     }
480     else {
481       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
482       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
483     }
484   }
485
486   TH2F *hEmptyPt = new TH2F("hEmptyPt","",100,0.0,4.0,100,0,120); 
487   hEmptyPt->SetStats(kFALSE); 
488   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
489   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
490
491   TCanvas *c13 = new TCanvas("c13",
492                             "Composition of accepted secondaries vs pT",
493                             600,600,700,400);
494   c13->SetFillColor(10); c13->GetFrame()->SetFillColor(10); c13->Divide(2,1);
495   c13->SetHighLightColor(10); c13->cd(1)->SetBottomMargin(0.15);
496   c13->cd(1)->SetGridx(); c13->cd(1)->SetGridy();
497   hEmptyPt->DrawCopy();
498   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
499     if(iParticle < 5) {
500       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
501       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
502     }
503     else {
504       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
505       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
506     }
507     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
508       gParticleProtonPt[iParticle]->Draw("P");
509   }
510
511   c13->SetHighLightColor(10); c13->cd(2)->SetBottomMargin(0.15);
512   c13->cd(2)->SetGridx(); c13->cd(2)->SetGridy();
513   hEmptyPt->DrawCopy();
514   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
515     if(iParticle < 5) {
516       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
517       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
518     }
519     else {
520       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
521       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
522     }
523     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
524       gParticleAntiProtonPt[iParticle]->Draw("P");
525   }
526 }
527
528 //________________________________________________//
529 void DrawContamination(TList *inputList) {
530   //loops over the list entries and
531   //draws the rapidity and pT dependence
532   //of the percentage of primary and secondary
533   //protons and antiprotons after the track cuts
534   cout<<"Extracting the entries for the histograms in the list: "<<
535     inputList->GetName()<<"..."<<endl;
536
537   TLatex *t1 = new TLatex();
538   t1->SetTextSize(0.04);
539
540   TH2F *hPrimaryProtons = (TH2F *)inputList->At(0);
541   TH2F *hSecondaryProtons = (TH2F *)inputList->At(2);
542   TH2F *hPrimaryAntiProtons = (TH2F *)inputList->At(4);
543   TH2F *hSecondaryAntiProtons = (TH2F *)inputList->At(6);
544
545   //rapidity dependence
546   //Protons
547   TH1D *gYPrimaryProtons = (TH1D *)hPrimaryProtons->ProjectionX("gYPrimaryProtons",0,hPrimaryProtons->GetXaxis()->GetNbins(),"e");
548   TH1D *gYSecondaryProtons = (TH1D *)hSecondaryProtons->ProjectionX("gYSecondaryProtons",0,hSecondaryProtons->GetXaxis()->GetNbins(),"e");
549   TH1D *gYTotalProtons = (TH1D *)hPrimaryProtons->ProjectionX("gYTotalProtons",0,hPrimaryProtons->GetXaxis()->GetNbins(),"e");
550   gYTotalProtons->Add(gYSecondaryProtons);
551
552   TH1D *gYPrimaryProtonsPercentage = new TH1D("gYPrimaryProtonsPercentage",
553                                               "",
554                                               hPrimaryProtons->GetXaxis()->GetNbins(),
555                                               hPrimaryProtons->GetXaxis()->GetXmin(),
556                                               hPrimaryProtons->GetXaxis()->GetXmax());                                        
557   gYPrimaryProtonsPercentage->Divide(gYPrimaryProtons,
558                                      gYTotalProtons,1.,1.0);
559   SetError(gYPrimaryProtonsPercentage,gYTotalProtons);
560   gYPrimaryProtonsPercentage->Scale(100.);
561   gYPrimaryProtonsPercentage->SetMarkerStyle(kFullCircle);
562
563   TH1D *gYSecondaryProtonsPercentage = new TH1D("gYSecondaryProtonsPercentage",
564                                                 "",
565                                                 hSecondaryProtons->GetXaxis()->GetNbins(),
566                                                 hSecondaryProtons->GetXaxis()->GetXmin(),
567                                                 hSecondaryProtons->GetXaxis()->GetXmax());                                            
568   gYSecondaryProtonsPercentage->Divide(gYSecondaryProtons,
569                                        gYTotalProtons,1.,1.0);
570   SetError(gYSecondaryProtonsPercentage,gYTotalProtons);
571   gYSecondaryProtonsPercentage->Scale(100.);
572   gYSecondaryProtonsPercentage->SetMarkerStyle(kOpenCircle);
573
574   //Antiprotons
575   TH1D *gYPrimaryAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionX("gYPrimaryAntiProtons",0,hPrimaryAntiProtons->GetXaxis()->GetNbins(),"e");
576   TH1D *gYSecondaryAntiProtons = (TH1D *)hSecondaryAntiProtons->ProjectionX("gYSecondaryAntiProtons",0,hSecondaryAntiProtons->GetXaxis()->GetNbins(),"e");
577   TH1D *gYTotalAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionX("gYTotalAntiProtons",0,hPrimaryAntiProtons->GetXaxis()->GetNbins(),"e");
578   gYTotalAntiProtons->Add(gYSecondaryAntiProtons);
579   
580   TH1D *gYPrimaryAntiProtonsPercentage = new TH1D("gYPrimaryAntiProtonsPercentage",
581                                                   "",
582                                                   hPrimaryAntiProtons->GetXaxis()->GetNbins(),
583                                                   hPrimaryAntiProtons->GetXaxis()->GetXmin(),
584                                                   hPrimaryAntiProtons->GetXaxis()->GetXmax());                                        
585   gYPrimaryAntiProtonsPercentage->Divide(gYPrimaryAntiProtons,
586                                          gYTotalAntiProtons,1.,1.0);
587   SetError(gYPrimaryAntiProtonsPercentage,gYTotalAntiProtons);
588   gYPrimaryAntiProtonsPercentage->Scale(100.);
589   gYPrimaryAntiProtonsPercentage->SetMarkerStyle(kFullCircle);
590   
591   TH1D *gYSecondaryAntiProtonsPercentage = new TH1D("gYSecondaryAntiProtonsPercentage",
592                                                     "",
593                                                     hSecondaryAntiProtons->GetXaxis()->GetNbins(),
594                                                     hSecondaryAntiProtons->GetXaxis()->GetXmin(),
595                                                     hSecondaryAntiProtons->GetXaxis()->GetXmax());                                            
596   gYSecondaryAntiProtonsPercentage->Divide(gYSecondaryAntiProtons,
597                                            gYTotalAntiProtons,1.,1.0);
598   SetError(gYSecondaryAntiProtonsPercentage,gYTotalAntiProtons);
599   gYSecondaryAntiProtonsPercentage->Scale(100.);
600   gYSecondaryAntiProtonsPercentage->SetMarkerStyle(kOpenCircle);
601   
602   
603   TH2F *hEmptyY = new TH2F("hEmptyCompositionY","",
604                            100,-1.2,1.2,100,-10.0,130); 
605   hEmptyY->SetStats(kFALSE); 
606   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
607   hEmptyY->GetYaxis()->SetTitleOffset(1.3);
608   hEmptyY->GetXaxis()->SetTitle("y");
609
610   TCanvas *c7 = new TCanvas("c7","(Anti)Proton contamination vs y",
611                             150,150,700,400);
612   c7->SetFillColor(10); c7->GetFrame()->SetFillColor(10); 
613   c7->SetHighLightColor(10); c7->Divide(2,1);
614
615   c7->cd(1)->SetBottomMargin(0.15); 
616   c7->cd(1)->SetLeftMargin(0.15); 
617   c7->cd(1)->SetGridx(); c7->cd(1)->SetGridy();
618   hEmptyY->SetTitle("Protons");
619   hEmptyY->DrawCopy();
620   gYPrimaryProtonsPercentage->DrawCopy("ESAME");
621   gYSecondaryProtonsPercentage->DrawCopy("ESAME");
622
623   DrawMarker(0, 55, kFullCircle, 1.2, 1);
624   t1->DrawLatex(0.1,53,"Primaries");
625   DrawMarker(0, 45, kOpenCircle, 1.2, 1);
626   t1->DrawLatex(0.1,43,"Secondaries");
627
628   c7->cd(2)->SetBottomMargin(0.15); 
629   c7->cd(2)->SetLeftMargin(0.15); 
630   c7->cd(2)->SetGridx(); c7->cd(2)->SetGridy();
631   hEmptyY->SetTitle("Antiprotons");
632   hEmptyY->DrawCopy();
633   gYPrimaryAntiProtonsPercentage->DrawCopy("ESAME");
634   gYSecondaryAntiProtonsPercentage->DrawCopy("ESAME");
635
636   DrawMarker(0, 55, kFullCircle, 1.2, 1);
637   t1->DrawLatex(0.1,53,"Primaries");
638   DrawMarker(0, 45, kOpenCircle, 1.2, 1);
639   t1->DrawLatex(0.1,43,"Secondaries");
640
641   c7->SaveAs("Contamination-Protons-Rapidity.gif");
642
643   //pT dependence
644   //Protons
645   TH1D *gPtPrimaryProtons = (TH1D *)hPrimaryProtons->ProjectionY("gPtPrimaryProtons",0,hPrimaryProtons->GetYaxis()->GetNbins(),"e");
646   TH1D *gPtSecondaryProtons = (TH1D *)hSecondaryProtons->ProjectionY("gPtSecondaryProtons",0,hSecondaryProtons->GetYaxis()->GetNbins(),"e");
647   TH1D *gPtTotalProtons = (TH1D *)hPrimaryProtons->ProjectionY("gPtTotalProtons",0,hPrimaryProtons->GetYaxis()->GetNbins(),"e");
648   gPtTotalProtons->Add(gPtSecondaryProtons);
649
650   TH1D *gPtPrimaryProtonsPercentage = new TH1D("gPtPrimaryProtonsPercentage",
651                                                "",
652                                                hPrimaryProtons->GetYaxis()->GetNbins(),
653                                                hPrimaryProtons->GetYaxis()->GetXmin(),
654                                                hPrimaryProtons->GetYaxis()->GetXmax());                                       
655   gPtPrimaryProtonsPercentage->Divide(gPtPrimaryProtons,
656                                       gPtTotalProtons,1.,1.0);
657   SetError(gPtPrimaryProtonsPercentage,gPtTotalProtons);
658   gPtPrimaryProtonsPercentage->Scale(100.);
659   gPtPrimaryProtonsPercentage->SetMarkerStyle(kFullCircle);
660   
661   TH1D *gPtSecondaryProtonsPercentage = new TH1D("gPtSecondaryProtonsPercentage",
662                                                  "",
663                                                  hSecondaryProtons->GetYaxis()->GetNbins(),
664                                                  hSecondaryProtons->GetYaxis()->GetXmin(),
665                                                  hSecondaryProtons->GetYaxis()->GetXmax());                                           
666   gPtSecondaryProtonsPercentage->Divide(gPtSecondaryProtons,
667                                         gPtTotalProtons,1.,1.0);
668   SetError(gPtSecondaryProtonsPercentage,gPtTotalProtons);
669   gPtSecondaryProtonsPercentage->Scale(100.);
670   gPtSecondaryProtonsPercentage->SetMarkerStyle(kOpenCircle);
671
672
673   //Antiprotons
674   TH1D *gPtPrimaryAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionY("gPtPrimaryAntiProtons",0,hPrimaryAntiProtons->GetYaxis()->GetNbins(),"e");
675   TH1D *gPtSecondaryAntiProtons = (TH1D *)hSecondaryAntiProtons->ProjectionY("gPtSecondaryAntiProtons",0,hSecondaryAntiProtons->GetYaxis()->GetNbins(),"e");
676   TH1D *gPtTotalAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionY("gPtTotalAntiProtons",0,hPrimaryAntiProtons->GetYaxis()->GetNbins(),"e");
677   gPtTotalAntiProtons->Add(gPtSecondaryAntiProtons);
678   
679   TH1D *gPtPrimaryAntiProtonsPercentage = new TH1D("gPtPrimaryAntiProtonsPercentage",
680                                                    "",
681                                                    hPrimaryAntiProtons->GetYaxis()->GetNbins(),
682                                                    hPrimaryAntiProtons->GetYaxis()->GetXmin(),
683                                                    hPrimaryAntiProtons->GetYaxis()->GetXmax());                                       
684   gPtPrimaryAntiProtonsPercentage->Divide(gPtPrimaryAntiProtons,
685                                           gPtTotalAntiProtons,1.,1.0);
686   SetError(gPtPrimaryAntiProtonsPercentage,gPtTotalAntiProtons);
687   gPtPrimaryAntiProtonsPercentage->Scale(100.);
688   gPtPrimaryAntiProtonsPercentage->SetMarkerStyle(kFullCircle);
689   
690   TH1D *gPtSecondaryAntiProtonsPercentage = new TH1D("gPtSecondaryAntiProtonsPercentage",
691                                                      "",
692                                                      hSecondaryAntiProtons->GetYaxis()->GetNbins(),
693                                                      hSecondaryAntiProtons->GetYaxis()->GetXmin(),
694                                                      hSecondaryAntiProtons->GetYaxis()->GetXmax());                                           
695   gPtSecondaryAntiProtonsPercentage->Divide(gPtSecondaryAntiProtons,
696                                             gPtTotalAntiProtons,1.,1.0);
697   SetError(gPtSecondaryAntiProtonsPercentage,gPtTotalAntiProtons);
698   gPtSecondaryAntiProtonsPercentage->Scale(100.);
699   gPtSecondaryAntiProtonsPercentage->SetMarkerStyle(kOpenCircle);
700   
701   TH2F *hEmptyPt = new TH2F("hEmptyCompositionPt","",
702                            100,0.0,4.0,100,-10.0,130); 
703   hEmptyPt->SetStats(kFALSE); 
704   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
705   hEmptyPt->GetYaxis()->SetTitleOffset(1.3);
706   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
707
708   TCanvas *c8 = new TCanvas("c8","(Anti)Proton comtamination vs pT",
709                             200,200,700,400);
710   c8->SetFillColor(10); c8->GetFrame()->SetFillColor(10); 
711   c8->SetHighLightColor(10); c8->Divide(2,1);
712
713   c8->cd(1)->SetBottomMargin(0.15); 
714   c8->cd(1)->SetLeftMargin(0.15); 
715   c8->cd(1)->SetGridx(); c8->cd(1)->SetGridy();
716   hEmptyPt->SetTitle("Protons");
717   hEmptyPt->DrawCopy();
718   gPtPrimaryProtonsPercentage->DrawCopy("ESAME");
719   gPtSecondaryProtonsPercentage->DrawCopy("ESAME");
720
721   DrawMarker(2.0, 55, kFullCircle, 1.2, 1);
722   t1->DrawLatex(2.1,53,"Primaries");
723   DrawMarker(2.0, 45, kOpenCircle, 1.2, 1);
724   t1->DrawLatex(2.1,43,"Secondaries");
725
726   c8->cd(2)->SetBottomMargin(0.15); 
727   c8->cd(2)->SetLeftMargin(0.15); 
728   c8->cd(2)->SetGridx(); c8->cd(2)->SetGridy();
729   hEmptyPt->SetTitle("Antirotons");
730   hEmptyPt->DrawCopy();
731   gPtPrimaryAntiProtonsPercentage->DrawCopy("ESAME");
732   gPtSecondaryAntiProtonsPercentage->DrawCopy("ESAME");
733
734   DrawMarker(2.0, 55, kFullCircle, 1.2, 1);
735   t1->DrawLatex(2.1,53,"Primaries");
736   DrawMarker(2.0, 45, kOpenCircle, 1.2, 1);
737   t1->DrawLatex(2.1,43,"Secondaries");
738
739   c8->SaveAs("Contamination-Protons-Pt.gif");
740
741   TFile *fout = TFile::Open("Contamination.root","recreate");
742   gYPrimaryProtonsPercentage->Write();
743   gYSecondaryProtonsPercentage->Write();
744   gPtPrimaryProtonsPercentage->Write();
745   gPtSecondaryProtonsPercentage->Write();
746   gYPrimaryAntiProtonsPercentage->Write();
747   gYSecondaryAntiProtonsPercentage->Write();
748   gPtPrimaryAntiProtonsPercentage->Write();
749   gPtSecondaryAntiProtonsPercentage->Write();
750   fout->Close();
751 }
752
753 //________________________________________________//
754 void DrawCutEfficiency(TList *inputList) {
755   //loops over the list entries and
756   //draws the rapidity and pT dependence
757   //of the percentage of primary and secondary
758   //protons and antiprotons after the track cuts
759   cout<<"Extracting the entries for the histograms in the list: "<<
760     inputList->GetName()<<"..."<<endl;
761
762   TLatex *t1 = new TLatex();
763   t1->SetTextSize(0.04);
764
765   TH2F *hPrimaryESDProtons = (TH2F *)inputList->At(0);
766   TH2F *hPrimaryESDAntiProtons = (TH2F *)inputList->At(4);
767   TH2F *hPrimaryMCProtons = (TH2F *)inputList->At(8);
768   TH2F *hPrimaryMCAntiProtons = (TH2F *)inputList->At(9);
769
770   //rapidity dependence
771   //Protons
772   TH1D *gYPrimaryESDProtons = (TH1D *)hPrimaryESDProtons->ProjectionX("gYPrimaryESDProtons",0,hPrimaryESDProtons->GetXaxis()->GetNbins(),"e");
773   TH1D *gYPrimaryMCProtons = (TH1D *)hPrimaryMCProtons->ProjectionX("gYPrimaryMCProtons",0,hPrimaryMCProtons->GetXaxis()->GetNbins(),"e");
774   gYPrimaryESDProtons->Divide(gYPrimaryMCProtons);
775   SetError(gYPrimaryESDProtons,gYPrimaryMCProtons);
776   gYPrimaryESDProtons->Scale(100.);
777   gYPrimaryESDProtons->SetMarkerStyle(kFullCircle);
778
779   //Antiprotons
780   TH1D *gYPrimaryESDAntiProtons = (TH1D *)hPrimaryESDAntiProtons->ProjectionX("gYPrimaryESDAntiProtons",0,hPrimaryESDAntiProtons->GetXaxis()->GetNbins(),"e");
781   TH1D *gYPrimaryMCAntiProtons = (TH1D *)hPrimaryMCAntiProtons->ProjectionX("gYPrimaryMCAntiProtons",0,hPrimaryMCAntiProtons->GetXaxis()->GetNbins(),"e");
782   gYPrimaryESDAntiProtons->Divide(gYPrimaryMCAntiProtons);
783   SetError(gYPrimaryESDAntiProtons,gYPrimaryMCAntiProtons);
784   gYPrimaryESDAntiProtons->Scale(100.);
785   gYPrimaryESDAntiProtons->SetMarkerStyle(kFullCircle);
786   
787   TH2F *hEmptyY = new TH2F("hEmptyEfficiencyY","",
788                            100,-1.2,1.2,100,-10.0,130); 
789   hEmptyY->SetStats(kFALSE); 
790   hEmptyY->GetYaxis()->SetTitle("#epsilon [%]");
791   hEmptyY->GetYaxis()->SetTitleOffset(1.3);
792   hEmptyY->GetXaxis()->SetTitle("y");
793
794   TCanvas *c10 = new TCanvas("c10","(Anti)Proton efficiency vs y",
795                             250,250,700,400);
796   c10->SetFillColor(10); c10->GetFrame()->SetFillColor(10); 
797   c10->SetHighLightColor(10); c10->Divide(2,1);
798
799   c10->cd(1)->SetBottomMargin(0.15); 
800   c10->cd(1)->SetLeftMargin(0.15); 
801   c10->cd(1)->SetGridx(); c10->cd(1)->SetGridy();
802   hEmptyY->SetTitle("Protons");
803   hEmptyY->DrawCopy();
804   gYPrimaryESDProtons->DrawCopy("ESAME");
805
806   c10->cd(2)->SetBottomMargin(0.15); 
807   c10->cd(2)->SetLeftMargin(0.15); 
808   c10->cd(2)->SetGridx(); c10->cd(2)->SetGridy();
809   hEmptyY->SetTitle("Antiprotons");
810   hEmptyY->DrawCopy();
811   gYPrimaryESDAntiProtons->DrawCopy("ESAME");
812
813   c10->SaveAs("Efficiency-Protons-Rapidity.gif");
814
815   //pT dependence
816   //Protons
817   TH1D *gPtPrimaryESDProtons = (TH1D *)hPrimaryESDProtons->ProjectionY("gPtPrimaryESDProtons",0,hPrimaryESDProtons->GetYaxis()->GetNbins(),"e");
818   TH1D *gPtPrimaryMCProtons = (TH1D *)hPrimaryMCProtons->ProjectionY("gPtPrimaryMCProtons",0,hPrimaryMCProtons->GetYaxis()->GetNbins(),"e");
819   gPtPrimaryESDProtons->Divide(gPtPrimaryMCProtons);
820   SetError(gPtPrimaryESDProtons,gPtPrimaryMCProtons);
821   gPtPrimaryESDProtons->Scale(100.);
822   gPtPrimaryESDProtons->SetMarkerStyle(kFullCircle);
823
824   //Antiprotons
825   TH1D *gPtPrimaryESDAntiProtons = (TH1D *)hPrimaryESDAntiProtons->ProjectionY("gPtPrimaryESDAntiProtons",0,hPrimaryESDAntiProtons->GetYaxis()->GetNbins(),"e");
826   TH1D *gPtPrimaryMCAntiProtons = (TH1D *)hPrimaryMCAntiProtons->ProjectionY("gPtPrimaryMCAntiProtons",0,hPrimaryMCAntiProtons->GetYaxis()->GetNbins(),"e");
827   gPtPrimaryESDAntiProtons->Divide(gPtPrimaryMCAntiProtons);
828   SetError(gPtPrimaryESDAntiProtons,gPtPrimaryMCAntiProtons);
829   gPtPrimaryESDAntiProtons->Scale(100.);
830   gPtPrimaryESDAntiProtons->SetMarkerStyle(kFullCircle);
831
832   TH2F *hEmptyPt = new TH2F("hEmptyEfficiencyPt","",
833                            100,0.0,4.0,100,-10.0,130); 
834   hEmptyPt->SetStats(kFALSE); 
835   hEmptyPt->GetYaxis()->SetTitle("#epsilon [%]");
836   hEmptyPt->GetYaxis()->SetTitleOffset(1.3);
837   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
838
839   TCanvas *c11 = new TCanvas("c11","(Anti)Proton efficiency vs pT",
840                             300,300,700,400);
841   c11->SetFillColor(10); c11->GetFrame()->SetFillColor(10); 
842   c11->SetHighLightColor(10); c11->Divide(2,1);
843
844   c11->cd(1)->SetBottomMargin(0.15); 
845   c11->cd(1)->SetLeftMargin(0.15); 
846   c11->cd(1)->SetGridx(); c11->cd(1)->SetGridy();
847   hEmptyPt->SetTitle("Protons");
848   hEmptyPt->DrawCopy();
849   gPtPrimaryESDProtons->DrawCopy("ESAME");
850
851   c11->cd(2)->SetBottomMargin(0.15); 
852   c11->cd(2)->SetLeftMargin(0.15); 
853   c11->cd(2)->SetGridx(); c11->cd(2)->SetGridy();
854   hEmptyPt->SetTitle("Antirotons");
855   hEmptyPt->DrawCopy();
856   gPtPrimaryESDAntiProtons->DrawCopy("ESAME");
857
858   c11->SaveAs("Efficiency-Protons-Pt.gif");
859
860   TFile *fout = TFile::Open("Efficiency.root","recreate");
861   gYPrimaryESDProtons->Write();
862   gYPrimaryESDAntiProtons->Write();
863   gPtPrimaryESDProtons->Write();
864   gPtPrimaryESDAntiProtons->Write();
865   fout->Close();
866 }
867
868 //________________________________________________//
869 void GetQAEntries(TList *inputList, Double_t *entries) {
870   //loops over the list entries
871   //extracts the entries for each histogram
872   //cout<<"Extracting the entries for the histograms in the list: "<<
873   //inputList->GetName()<<"..."<<endl;
874
875   for(Int_t i = 0; i < inputList->GetEntries(); i++) {
876     TH1F *gHist = (TH1F *)inputList->At(i);
877     entries[i] = gHist->GetEntries();
878     cout<<"Histogram: "<<gHist->GetName()<<
879       " - Entries: "<<entries[i]<<endl;
880     gHist = 0;
881   }
882 }
883
884 //________________________________________________//
885 Double_t GetPercentage(Double_t nPassEntries,
886                        Double_t nRejectEntries) {
887   //returns the percentage of tracks that were rejected by a cut
888   Int_t nTotalEntries = nPassEntries + nRejectEntries;
889
890   if(nTotalEntries == 0)
891     return -1;
892
893   return 100.*nRejectEntries/nTotalEntries;
894 }
895
896 //________________________________________//
897 void drawMCQA(TList *listPDG, TList *listMCProcesses) {
898   //Function to display the composition of secondary (anti)protons
899   //The histogram shows the percentage of secondary (anti)protons
900   //originating from each particle species.
901   //The box summarizes the MC process that gave these secondary (anti)protons
902   TDatabasePDG *db = TDatabasePDG::Instance();
903   TParticlePDG *p = 0x0;
904   
905   TH3F *gHistYPtPDGProtons = (TH3F *)listPDG->At(0);
906   TH3F *gHistYPtPDGAntiProtons = (TH3F *)listPDG->At(1);
907   readProcesses(listMCProcesses);
908   Double_t nParticleCompositionProtonY[100], nParticleCompositionProtonPt[100];
909   Double_t nParticleCompositionAntiProtonY[100], nParticleCompositionAntiProtonPt[100];
910   Double_t gY[100], gPt[100];
911   for(Int_t iBins = 0; iBins < 100; iBins++) {
912     nParticleCompositionProtonY[iBins] = 0;
913     nParticleCompositionProtonPt[iBins] = 0;
914     nParticleCompositionAntiProtonY[iBins] = 0;
915     nParticleCompositionAntiProtonPt[iBins] = 0;
916     gY[iBins] = 0;
917     gPt[iBins] = 0;
918   }
919   
920   TGraph *gParticleProtonY[14];
921   TGraph *gParticleProtonPt[14];
922   TGraph *gParticleAntiProtonY[14];
923   TGraph *gParticleAntiProtonPt[14];
924   for(Int_t iParticle = 0; iParticle < 14; iParticle++) {
925     GetComposition(iParticle,
926                    gHistYPtPDGProtons,
927                    nParticleCompositionProtonY,
928                    gY, nParticleCompositionProtonPt, gPt);
929     gParticleProtonY[iParticle] = new TGraph(gHistYPtPDGProtons->GetNbinsX(),
930                                        gY,nParticleCompositionProtonY);
931     gParticleProtonY[iParticle]->SetMarkerStyle(iParticle+20);
932     gParticleProtonY[iParticle]->SetMarkerSize(1.2);
933
934     gParticleProtonPt[iParticle] = new TGraph(gHistYPtPDGProtons->GetNbinsY(),
935                                         gPt,nParticleCompositionProtonPt);
936     gParticleProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
937     gParticleProtonPt[iParticle]->SetMarkerSize(1.2);
938
939     GetComposition(iParticle,
940                    gHistYPtPDGAntiProtons,
941                    nParticleCompositionAntiProtonY,
942                    gY, nParticleCompositionAntiProtonPt, gPt);
943     gParticleAntiProtonY[iParticle] = new TGraph(gHistYPtPDGAntiProtons->GetNbinsX(),
944                                        gY,nParticleCompositionAntiProtonY);
945     gParticleAntiProtonY[iParticle]->SetMarkerStyle(iParticle+20);
946     gParticleAntiProtonY[iParticle]->SetMarkerSize(1.2);
947
948     gParticleAntiProtonPt[iParticle] = new TGraph(gHistYPtPDGAntiProtons->GetNbinsY(),
949                                         gPt,nParticleCompositionAntiProtonPt);
950     gParticleAntiProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
951     gParticleAntiProtonPt[iParticle]->SetMarkerSize(1.2);
952   }
953
954   //_________________________________________________________//
955   char *fParticleName[14] = {"Primary","K_{L}","#pi","K_{S}","K",
956                              "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
957                              "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
958   TLatex *t1 = new TLatex();
959   t1->SetTextSize(0.04);
960
961   TH2F *hEmptyY = new TH2F("hEmptyY","",100,-1.2,1.2,100,0,120); 
962   hEmptyY->SetStats(kFALSE); 
963   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
964   hEmptyY->GetXaxis()->SetTitle("y");
965
966   TCanvas *c3 = new TCanvas("c3","MC secondary composition vs y - Protons",
967                             350,350,700,400);
968   c3->SetFillColor(10); c3->GetFrame()->SetFillColor(10);
969   c3->SetHighLightColor(10); c3->SetBottomMargin(0.15);
970   c3->SetGridx(); c3->SetGridy();
971   hEmptyY->DrawCopy();
972   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
973     //if((iParticle == 0)||(iParticle == 2)||(iParticle == 5)||(iParticle == 6)||(iParticle == 8))
974     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
975       gParticleProtonY[iParticle]->Draw("P");
976     if(iParticle < 5) {
977       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
978       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
979     }
980     else {
981       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
982       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
983     }
984   }
985
986   TCanvas *c5 = new TCanvas("c5","MC secondary composition vs y - antiProtons",
987                             400,400,700,400);
988   c5->SetFillColor(10); c5->GetFrame()->SetFillColor(10);
989   c5->SetHighLightColor(10); c5->SetBottomMargin(0.15);
990   c5->SetGridx(); c5->SetGridy();
991   hEmptyY->DrawCopy();
992   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
993     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
994       gParticleAntiProtonY[iParticle]->Draw("P");
995     if(iParticle < 5) {
996       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
997       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
998     }
999     else {
1000       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1001       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
1002     }
1003   }
1004
1005   TH2F *hEmptyPt = new TH2F("hEmptyPt","",100,0.0,4.0,100,0,120); 
1006   hEmptyPt->SetStats(kFALSE); 
1007   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
1008   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1009
1010   TCanvas *c4 = new TCanvas("c4","MC secondary composition vs pT - Protons",
1011                             450,450,700,400);
1012   c4->SetFillColor(10); c4->GetFrame()->SetFillColor(10);
1013   c4->SetHighLightColor(10); c4->SetBottomMargin(0.15);
1014   c4->SetGridx(); c4->SetGridy();
1015   hEmptyPt->DrawCopy();
1016   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1017     if(iParticle < 5) {
1018       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
1019       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
1020     }
1021     else {
1022       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1023       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
1024     }
1025     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
1026       gParticleProtonPt[iParticle]->Draw("P");
1027   }
1028
1029   TCanvas *c6 = new TCanvas("c6",
1030                             "MC secondary composition vs pT - AntiProtons",
1031                             500,500,700,400);
1032   c6->SetFillColor(10); c6->GetFrame()->SetFillColor(10);
1033   c6->SetHighLightColor(10); c6->SetBottomMargin(0.15);
1034   c6->SetGridx(); c6->SetGridy();
1035   hEmptyPt->DrawCopy();
1036   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1037     if(iParticle < 5) {
1038       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
1039       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
1040     }
1041     else {
1042       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1043       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
1044     }
1045     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
1046       gParticleAntiProtonPt[iParticle]->Draw("P");
1047   }
1048 }
1049
1050 //________________________________________//
1051 void GetComposition(Int_t iSpecies,
1052                     TH3F *gHist, 
1053                     Double_t *nParticleCompositionY,
1054                     Double_t *gY,
1055                     Double_t *nParticleCompositionPt,
1056                     Double_t *gPt) {
1057   //Returns the pT and y dependence of the MC composition
1058   Double_t ymin = gHist->GetXaxis()->GetXmin();
1059   Double_t ymax = gHist->GetXaxis()->GetXmax();
1060   Double_t nybins = gHist->GetNbinsX();
1061   Double_t ptmin = gHist->GetYaxis()->GetXmin();
1062   Double_t ptmax = gHist->GetYaxis()->GetXmax();
1063   Double_t nptbins = gHist->GetNbinsY();
1064   Double_t nTotalY[100], nTotalPt[100];
1065   for(Int_t iBins = 0; iBins < 100; iBins++) {
1066     nParticleCompositionY[iBins] = 0;
1067     nParticleCompositionPt[iBins] = 0;
1068     nTotalY[iBins] = 0.0;
1069     nTotalPt[iBins] = 0.0;
1070   }
1071
1072   //rapidity dependence
1073   //cout<<"Ymin: "<<ymin<<" - Ymax: "<<ymax<<" - Ybins: "<<nybins<<endl;
1074   for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1075     for(Int_t iZbins = 1; iZbins <= gHist->GetNbinsZ(); iZbins++) {
1076       for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1077         nTotalY[iXbins-1] += gHist->GetBinContent(iXbins,iYbins,iZbins);
1078       }
1079     }
1080   }
1081
1082   for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1083     for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1084       if(nTotalY[iXbins-1] > 0)
1085         nParticleCompositionY[iXbins-1] += 100.*gHist->GetBinContent(iXbins,iYbins,iSpecies+1)/nTotalY[iXbins-1];
1086       //if(nParticleCompositionY[iXbins-1] == 0) 
1087       //nParticleCompositionY[iXbins-1] = -10.0;
1088     }//pt loop
1089     gY[iXbins-1] = ymin + (iXbins-1)*(ymax - ymin)/nybins + 0.5*(ymax - ymin)/nybins;
1090     //cout<<"y: "<<gY[iXbins-1]<<
1091     //" - test: "<<ymin + (iXbins-1)*(ymax - ymin)/nybins + 0.5*(ymax - ymin)/nybins<<
1092     //" - Number of protons: "<<nY[iXbins-1]<<
1093     //" - Total: "<<nTotalY[iXbins-1]<<
1094     //" - Percentage: "<<nParticleCompositionY[iXbins-1]<<endl;
1095   }//y loop
1096
1097   //pt dependence
1098   //cout<<"Ptmin: "<<ptmin<<" - Ptmax: "<<ptmax<<" - Ptbins: "<<nptbins<<endl;
1099   for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1100     for(Int_t iZbins = 1; iZbins <= gHist->GetNbinsZ(); iZbins++) {
1101       for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1102         nTotalPt[iYbins-1] += gHist->GetBinContent(iXbins,iYbins,iZbins);
1103       }
1104     }
1105   }
1106
1107   for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1108     for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1109       if(nTotalPt[iYbins-1] > 0)
1110         nParticleCompositionPt[iYbins-1] += 100.*gHist->GetBinContent(iXbins,iYbins,iSpecies+1)/nTotalPt[iYbins-1];
1111       //if(nParticleCompositionPt[iYbins-1] == 0) 
1112       //nParticleCompositionPt[iYbins-1] = -10.0;
1113     }//pt loop
1114     gPt[iYbins-1] = ptmin + (iYbins-1)*(ptmax - ptmin)/nptbins + 0.5*(ptmax - ptmin)/nptbins;
1115     //cout<<"Pt: "<<gPt[iYbins-1]<<
1116     //" - test: "<<ptmin + (iYbins-1)*(ptmax - ptmin)/nptbins + 0.5*(ptmax - ptmin)/nptbins<<
1117     //" - Number of protons: "<<nY[iXbins-1]<<
1118     //" - Total: "<<nTotalPt[iYbins-1]<<
1119     //" - Percentage: "<<nParticleCompositionPt[iYbins-1]<<endl;
1120   }//pt loop
1121 }
1122
1123 //________________________________________//
1124 void readProcesses(TList *list) {
1125   char *fParticleProtonName[12] = {"K_{L}","#pi","K_{S}","K",
1126                                    "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
1127                                    "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
1128   char *fParticleAntiProtonName[8] = {"K_{L}","#pi","K_{S}","K",
1129                                       "n","p","#Lambda","#Sigma^{+}"};
1130   Int_t iProtonCounter = 0, iAntiProtonCounter = 0;
1131   TH1F *gMCProcesses;
1132   for(Int_t iEntry = 0; iEntry < list->GetEntries(); iEntry++) {
1133     gMCProcesses = (TH1F *)list->At(iEntry);
1134     TString histName = gMCProcesses->GetName();
1135     if(histName.Contains("gHistProtons")) {
1136       cout<<"Protons coming from "<<fParticleProtonName[iProtonCounter]<<endl;
1137
1138       iProtonCounter += 1;
1139     }
1140     if(histName.Contains("gHistAntiProtons")) {
1141       cout<<"Antiprotons coming from "<<fParticleAntiProtonName[iAntiProtonCounter]<<endl;
1142
1143       iAntiProtonCounter += 1;
1144     }
1145     for(Int_t iBin = 1; iBin < gMCProcesses->GetNbinsX(); iBin++) {
1146       Double_t binContent = gMCProcesses->GetBinContent(iBin);
1147       if(binContent > 0) {
1148         Int_t processId = gMCProcesses->GetBinCenter(iBin);
1149         cout<<"\t Process ID: "<<processId<<" - "<<
1150           gMCProcessName[processId]<<" - "<<
1151           100.*binContent/gMCProcesses->GetEntries()<<"%"<<endl;
1152       }
1153     }
1154   }
1155 }
1156
1157 //________________________________________________//
1158 void SetError(TH1D *hEff, TH1D *hGen) {
1159   for(Int_t iBin = 1; iBin <= hEff->GetNbinsX(); iBin++) {
1160     Double_t error = 0.0;
1161     if(hEff->GetBinContent(iBin) <= 1  .) 
1162       error = TMath::Sqrt(hEff->GetBinContent(iBin)*(1  . - hEff->GetBinContent(iBin))/hGen->GetBinContent(iBin));
1163     hEff->SetBinError(iBin,error);
1164   }
1165 }
1166
1167 //________________________________________//
1168 void drawEfficiency(TList *list) {
1169   //Function to display the reconstruction and PID efficiencies
1170   //for protons and antiprotons vs y and pT
1171
1172   TH2F *hEmpty = new TH2F("hEmptyReconstructionEfficiency","",
1173                            100,-1.2,3.5,100,-10.0,130); 
1174   hEmpty->SetStats(kFALSE); 
1175   hEmpty->GetYaxis()->SetTitle("#epsilon [%]");
1176   hEmpty->GetYaxis()->SetTitleOffset(1.3);
1177
1178   //Reconstruction efficiency
1179   TH2D *gHistMCYPtProtons = (TH2D *)list->At(0);
1180   TH2D *gHistMCYPtAntiProtons = (TH2D *)list->At(1);
1181   TH2D *gHistESDYPtProtons = (TH2D *)list->At(2);
1182   TH2D *gHistESDYPtAntiProtons = (TH2D *)list->At(3);
1183
1184   //rapidity dependence
1185   TCanvas *c14 = new TCanvas("c14",
1186                              "(Anti)Proton reconstruction efficiency vs y",
1187                              600,600,700,400);
1188   c14->SetFillColor(10); c14->GetFrame()->SetFillColor(10); 
1189   c14->SetHighLightColor(10); c14->Divide(2,1);
1190
1191   //Protons
1192   TH1D *gYESDProtons = (TH1D *)gHistESDYPtProtons->ProjectionX("gYESDProtons",0,gHistESDYPtProtons->GetXaxis()->GetNbins(),"e");
1193   TH1D *gYMCProtons = (TH1D *)gHistMCYPtProtons->ProjectionX("gYMCProtons",0,gHistMCYPtProtons->GetXaxis()->GetNbins(),"e");
1194   gYESDProtons->Divide(gYMCProtons);
1195   SetError(gYESDProtons,gYMCProtons);
1196   gYESDProtons->Scale(100.);
1197   gYESDProtons->SetMarkerStyle(kFullCircle);
1198
1199   //AntiProtons
1200   TH1D *gYESDAntiProtons = (TH1D *)gHistESDYPtAntiProtons->ProjectionX("gYESDAntiProtons",0,gHistESDYPtAntiProtons->GetXaxis()->GetNbins(),"e");
1201   TH1D *gYMCAntiProtons = (TH1D *)gHistMCYPtAntiProtons->ProjectionX("gYMCAntiProtons",0,gHistMCYPtProtons->GetXaxis()->GetNbins(),"e");
1202   gYESDAntiProtons->Divide(gYMCAntiProtons);
1203   SetError(gYESDAntiProtons,gYMCAntiProtons);
1204   gYESDAntiProtons->Scale(100.);
1205   gYESDAntiProtons->SetMarkerStyle(kFullCircle);
1206
1207   c14->cd(1)->SetBottomMargin(0.15); 
1208   c14->cd(1)->SetLeftMargin(0.15); 
1209   c14->cd(1)->SetGridx(); c14->cd(1)->SetGridy();
1210   hEmpty->GetXaxis()->SetRangeUser(-1.0,1.0);
1211   hEmpty->GetXaxis()->SetTitle("y");
1212   hEmpty->SetTitle("Protons");
1213   hEmpty->DrawCopy();
1214   gYESDProtons->DrawCopy("ESAME");
1215
1216   c14->cd(2)->SetBottomMargin(0.15); 
1217   c14->cd(2)->SetLeftMargin(0.15); 
1218   c14->cd(2)->SetGridx(); c14->cd(2)->SetGridy();
1219   hEmpty->SetTitle("Antiprotons");
1220   hEmpty->DrawCopy();
1221   gYESDAntiProtons->DrawCopy("ESAME");
1222   c14->SaveAs("ReconstructionEfficiency-Protons-Rapidity.gif");
1223
1224   //pT dependence
1225   TCanvas *c15 = new TCanvas("c15",
1226                              "(Anti)Proton reconstruction efficiency vs pT",
1227                              650,650,700,400);
1228   c15->SetFillColor(10); c15->GetFrame()->SetFillColor(10); 
1229   c15->SetHighLightColor(10); c15->Divide(2,1);
1230
1231   //Protons
1232   TH1D *gPtESDProtons = (TH1D *)gHistESDYPtProtons->ProjectionY("gPtESDProtons",0,gHistESDYPtProtons->GetYaxis()->GetNbins(),"e");
1233   TH1D *gPtMCProtons = (TH1D *)gHistMCYPtProtons->ProjectionY("gPtMCProtons",0,gHistMCYPtProtons->GetYaxis()->GetNbins(),"e");
1234   gPtESDProtons->Divide(gPtMCProtons);
1235   SetError(gPtESDProtons,gPtMCProtons);
1236   gPtESDProtons->Scale(100.);
1237   gPtESDProtons->SetMarkerStyle(kFullCircle);
1238
1239   //AntiProtons
1240   TH1D *gPtESDAntiProtons = (TH1D *)gHistESDYPtAntiProtons->ProjectionY("gPtESDAntiProtons",0,gHistESDYPtAntiProtons->GetYaxis()->GetNbins(),"e");
1241   TH1D *gPtMCAntiProtons = (TH1D *)gHistMCYPtAntiProtons->ProjectionY("gPtMCAntiProtons",0,gHistMCYPtProtons->GetYaxis()->GetNbins(),"e");
1242   gPtESDAntiProtons->Divide(gPtMCAntiProtons);
1243   SetError(gPtESDAntiProtons,gPtMCAntiProtons);
1244   gPtESDAntiProtons->Scale(100.);
1245   gPtESDAntiProtons->SetMarkerStyle(kFullCircle);
1246
1247
1248   c15->cd(1)->SetBottomMargin(0.15); 
1249   c15->cd(1)->SetLeftMargin(0.15); 
1250   c15->cd(1)->SetGridx(); c15->cd(1)->SetGridy();
1251   hEmpty->GetXaxis()->SetRangeUser(0.,1.2);
1252   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1253   hEmpty->SetTitle("Protons");
1254   hEmpty->DrawCopy();
1255   gPtESDProtons->DrawCopy("ESAME");
1256
1257   c15->cd(2)->SetBottomMargin(0.15); 
1258   c15->cd(2)->SetLeftMargin(0.15); 
1259   c15->cd(2)->SetGridx(); c15->cd(2)->SetGridy();
1260   hEmpty->SetTitle("Antiprotons");
1261   hEmpty->DrawCopy();
1262   gPtESDAntiProtons->DrawCopy("ESAME");
1263   c15->SaveAs("ReconstructionEfficiency-Protons-Pt.gif");
1264
1265   //PID efficiency
1266   TH2D *gHistESDInitYPtProtons = (TH2D *)list->At(4);
1267   TH2D *gHistESDIdYPtProtons = (TH2D *)list->At(5);
1268   TH2D *gHistESDRecIdYPtProtons = (TH2D *)list->At(6);
1269   TH2D *gHistESDContamYPtProtons = (TH2D *)list->At(7);
1270
1271   TCanvas *c16 = new TCanvas("c16",
1272                              "(Anti)Proton PID efficiency vs y and pT",
1273                              700,700,700,400);
1274   c16->SetFillColor(10); c16->GetFrame()->SetFillColor(10); 
1275   c16->SetHighLightColor(10); c16->Divide(2,1);
1276
1277   //rapidity dependence
1278   //protons pid efficiency
1279   TH1D *gYESDIdProtons = (TH1D *)gHistESDIdYPtProtons->ProjectionX("gYESDIdProtons",0,gHistESDIdYPtProtons->GetXaxis()->GetNbins(),"e");
1280   TH1D *gYESDInitProtons = (TH1D *)gHistESDInitYPtProtons->ProjectionX("gYESDInitProtons",0,gHistESDInitYPtProtons->GetXaxis()->GetNbins(),"e");
1281   gYESDIdProtons->Divide(gYESDInitProtons);
1282   SetError(gYESDIdProtons,gYESDInitProtons);
1283   gYESDIdProtons->Scale(100.);
1284   gYESDIdProtons->SetMarkerStyle(kFullCircle);
1285
1286   //protons pid contamination
1287   TH1D *gYESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionX("gYESDContamProtons",0,gHistESDContamYPtProtons->GetXaxis()->GetNbins(),"e");
1288   TH1D *gYESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionX("gYESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetXaxis()->GetNbins(),"e");
1289   gYESDContamProtons->Divide(gYESDRecIdProtons);
1290   SetError(gYESDContamProtons,gYESDRecIdProtons);
1291   gYESDContamProtons->Scale(100.);
1292   gYESDContamProtons->SetMarkerStyle(kOpenCircle);
1293
1294   c16->cd(1)->SetBottomMargin(0.15); 
1295   c16->cd(1)->SetLeftMargin(0.15); 
1296   c16->cd(1)->SetGridx(); c16->cd(1)->SetGridy();
1297   hEmpty->GetXaxis()->SetRangeUser(-1.0.,1.0);
1298   hEmpty->GetXaxis()->SetTitle("y");
1299   hEmpty->DrawCopy();
1300   gYESDIdProtons->DrawCopy("ESAME");
1301   gYESDContamProtons->DrawCopy("ESAME");
1302
1303   //pT dependence
1304   //protons pid efficiency
1305   TH1D *gPtESDIdProtons = (TH1D *)gHistESDIdYPtProtons->ProjectionY("gPtESDIdProtons",0,gHistESDIdYPtProtons->GetYaxis()->GetNbins(),"e");
1306   TH1D *gPtESDInitProtons = (TH1D *)gHistESDInitYPtProtons->ProjectionY("gPtESDInitProtons",0,gHistESDInitYPtProtons->GetYaxis()->GetNbins(),"e");
1307   gPtESDIdProtons->Divide(gPtESDInitProtons);
1308   SetError(gPtESDIdProtons,gPtESDInitProtons);
1309   gPtESDIdProtons->Scale(100.);
1310   gPtESDIdProtons->SetMarkerStyle(kFullCircle);
1311
1312   //protons pid contamination
1313   TH1D *gPtESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionY("gPtESDContamProtons",0,gHistESDContamYPtProtons->GetYaxis()->GetNbins(),"e");
1314   TH1D *gPtESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionY("gPtESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetYaxis()->GetNbins(),"e");
1315   gPtESDContamProtons->Divide(gPtESDRecIdProtons);
1316   SetError(gPtESDContamProtons,gPtESDRecIdProtons);
1317   gPtESDContamProtons->Scale(100.);
1318   gPtESDContamProtons->SetMarkerStyle(kOpenCircle);
1319
1320   c16->cd(2)->SetBottomMargin(0.15); 
1321   c16->cd(2)->SetLeftMargin(0.15); 
1322   c16->cd(2)->SetGridx(); c16->cd(2)->SetGridy();
1323   hEmpty->GetXaxis()->SetRangeUser(0.0,1.2);
1324   hEmpty->GetXaxis()->SetTitle("y");
1325   hEmpty->DrawCopy();
1326   gPtESDIdProtons->DrawCopy("ESAME");
1327   gPtESDContamProtons->DrawCopy("ESAME");
1328 }
1329
1330 //________________________________________________//
1331 void DrawMarker(Double_t x, Double_t y, Int_t style, 
1332                 Double_t size, Int_t color) {
1333   TMarker *m = new TMarker(x,y,style);
1334   m->SetMarkerSize(size);
1335   m->SetMarkerColor(color);
1336   m->Draw();
1337 }
1338
1339 //________________________________________________//
1340 const char * const gMCProcessName[45] = {
1341   "Primary particle emission",
1342   "Multiple scattering",
1343   "Energy loss",
1344   "Bending in magnetic field",
1345   "Decay",
1346   "Lepton pair production",
1347   "Compton scattering",
1348   "Photoelectric effect",
1349   "Bremstrahlung",
1350   "Delta ray",
1351   "Positron annihilation",
1352   "Positron annihilation at rest",
1353   "Positron annihilation in flight",
1354   "Hadronic interaction",
1355   "Nuclear evaporation",
1356   "Nuclear fission",
1357   "Nuclear absorbtion",
1358   "Antiproton annihilation",
1359   "Antineutron annihilation",
1360   "Neutron capture",
1361   "Hadronic elastic",
1362   "Hadronic incoherent elastic",
1363   "Hadronic coherent elastic",
1364   "Hadronic inelastic",
1365   "Photon inelastic",
1366   "Muon nuclear interaction",
1367   "Electron nuclear interaction",
1368   "Positron nuclear interaction",
1369   "Time of flight limit",
1370   "Nuclear photofission",
1371   "Rayleigh effect",
1372   "No active process",
1373   "Energy threshold",
1374   "Light absorption",
1375   "Light detection",
1376   "Light scattering",
1377   "Maximum allowed step",
1378   "Cerenkov production",
1379   "Cerenkov feed back photon",
1380   "Cerenkov photon reflection",
1381   "Cerenkov photon refraction",
1382   "Synchrotron radiation",
1383   "Scintillation",
1384   "Transportation",
1385   "Unknown process"
1386 };