]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/AntiprotonToProton/drawProtonQAResults.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / AntiprotonToProton / drawProtonQAResults.C
1 void drawProtonQAResults(const char *analysisType = "Hybrid",
2                          const char *pidMode = "Ratio") {
3   //Macro to visualize the results of the proton QA task
4   gStyle->SetPalette(1,0);
5   gStyle->SetCanvasColor(41);
6   gStyle->SetFrameFillColor(10);
7   
8   PrintHelpMenu();
9   
10   TString filename1 = "Protons.QA.";
11   filename1 += analysisType; 
12   filename1 += "."; filename1 += pidMode;
13   filename1 += ".root";
14   TString filename2 = "Protons.MC.QA.";
15   filename2 += analysisType; 
16   filename2 += "."; filename2 += pidMode;
17   filename2 += ".root";
18   TString filename3 = "Protons.Efficiency.";
19   filename3 += analysisType; 
20   filename3 += "."; filename3 += pidMode;
21   filename3 += ".root";
22   
23   TFile *fQA = TFile::Open(filename1.Data());
24   TList *listGlobalQA = (TList *)fQA->Get("globalQAList");
25   drawCutStatistics(listGlobalQA,analysisType);
26   fQA->Close();
27  
28   TFile *fMC = TFile::Open(filename2.Data());
29   TList *listPDG = (TList *)fMC->Get("pdgCodeList");  
30   TList *listMCProcesses = (TList *)fMC->Get("mcProcessList");  
31   drawMCQA(listPDG,listMCProcesses);
32   fMC->Close();
33   
34   TFile *fEfficiency = TFile::Open(filename3.Data());
35   TList *listEfficiency = (TList *)fEfficiency->Get("efficiencyList");
36   drawEfficiency(listEfficiency,analysisType);
37   TList *listCutEfficiency = (TList *)fEfficiency->Get("cutEfficiencyList");
38   DrawCutEfficiency(listCutEfficiency,analysisType);
39   fEfficiency->Close();
40
41   TFile *fVertex = TFile::Open("Vertex.QA.root");
42   TList *listVertex = (TList *)fVertex->Get("vertexList");
43   drawVertexQA(listVertex);
44   fVertex->Close();
45 }
46
47 //________________________________________//
48 void PrintHelpMenu() {
49   //Function that prints the different possibilities the user has 
50   //with this macro (what to display, what is the input etc)
51   Printf("==============================HELP MENU===========================");
52   Printf("Function drawCutStatistics: Takes as an argument the list obtained from the Protons.QA.root file and the corresponding analysis type. Displays the following plots:");
53   Printf("\t 1. Influence of the track cuts to the primary and secondary protons. For each bin we show the percentage of particles rejected by the corresponding cut. The first column shows the percentage of tracks excluded from the analysis.");
54   Printf("\t 2. Influence of the track cuts to the primary and secondary antiprotons. For each bin we show the percentage of particles rejected by the corresponding cut. The first column shows the percentage of tracks excluded from the analysis.");
55   Printf("\t 3. The ITS cluster map for primary and secondary (anti)protons.");
56   Printf("\t 4. The (anti)proton purity and contamination as a function of eta or y.");
57   Printf("\t 5. The (anti)proton purity and contamination as a function of Pt.");
58   Printf("\t 6. The (anti)proton cut efficiency as a function of eta or y.");
59   Printf("\t 7. The (anti)proton cut efficiency as a function of Pt.");
60   Printf("\t 8. The composition of accepted secondary (anti)protons as a function of eta or y.");
61   Printf("\t 9. The composition of accepted secondary (anti)protons as a function of Pt.");
62   Printf("\t ***This function calls the DrawContamination function that creates an output root file with the name Contamination.root holding all the purity and contamination plots (eta or y and Pt dependence) and the DrawCutEfficiency function that creates an output root file with the name CutEfficiency.root with the y or eta and Pt dependence of the cut efficiency for protons and antiprotons.***");
63
64   Printf("\nFunction drawMCQA: Takes as an argument the two lists obtained from the Protons.MC.QA.root file holding pure MC information. Displays the following plots:");
65   Printf("\t 1. MC composition of secondary protons as a function of either eta or y.");
66   Printf("\t 2. MC composition of secondary antiprotons as a function of either eta or y.");
67   Printf("\t 3. MC composition of secondary protons as a function of Pt.");
68   Printf("\t 4. MC composition of secondary antiprotons as a function of Pt");
69
70   Printf("\nFunction drawEfficiency: Takes as an argument the list obtained from the Protons.Efficiency.root file along with the analysis type. Displays the following plots:");
71   Printf("\t 1. Reconstruction efficiencies for primary and secondary (anti)protons as a function of either eta or y. The secondaries are categorized by the MC process as originating from a weak decay or from a hadronic interaction.");
72   Printf("\t 2. Reconstruction efficiencies for primary and secondary (anti)protons as a function of Pt. The secondaries are categorized by the MC process as originating from a weak decay or from a hadronic interaction.");
73   Printf("\t 3. Particle identifiction efficiencies for (anti)protons as a function of either eta or y and of Pt.");
74   Printf("\t ***This function produces an output root file with the name Reconstruction-PID-Efficiency.root with all the efficiency and contamination plots.***");
75
76   Printf("\nFunction drawVertexQA: Takes as an argument the list obtained from the Vertex.QA.root file holding pure vertex information. Displays the following plots:");
77   Printf("\t 1. The vertex efficiencies for the TPC, SPD and track ones.");
78   Printf("\t 2. The QA plots for the TPC vertex.");
79   Printf("\t 3. The QA plots for the SPD vertex.");
80   Printf("\t 4. The QA plots for the tracks vertex.");
81
82   Printf("\nFunction drawKineQA: Takes as an argument the file Protons.QA.Histograms.root with all the histograms about kinematic or not variables");
83   Printf("\t 1. The phi vs eta correlation plots for primary and secondary (anti)protons.");
84   Printf("\t 2. The Nclusters TPC vs eta correlation plots for primary and secondary (anti)protons.");
85   Printf("\t 3. The Nclusters TPC vs phi correlation plots for primary and secondary (anti)protons.");
86   Printf("\t 4. The chi^2 per TPC cluster vs eta correlation plots for primary and secondary (anti)protons.");
87   Printf("\t 5. The chi^2 per TPC cluster vs phi correlation plots for primary and secondary (anti)protons.");
88   Printf("\t 6. The Npoints TPC (dE/dx) vs eta correlation plots for primary and secondary (anti)protons.");
89   Printf("\t 7. The Npoints TPC (dE/dx) vs phi correlation plots for primary and secondary (anti)protons.");
90
91  Printf("\nFunction drawEfficiencies: Takes as arguments the filename produced by the drawEfficiency (see before - usually the name is Reconstruction-PID-Efficiency.root) and three booleans indicating whether the points for primaries, secondaries from weak decays and secondaries from hadronic interactions will be shown.It displays:");
92   Printf("\t 1. Reconstruction efficiencies for primary and secondary (anti)protons as a function of either eta or y. The secondaries are categorized by the MC process as originating from a weak decay or from a hadronic interaction.");
93   Printf("\t 2. Reconstruction efficiencies for primary and secondary (anti)protons as a function of Pt. The secondaries are categorized by the MC process as originating from a weak decay or from a hadronic interaction.");
94   Printf("\t 3. Particle identifiction efficiencies for (anti)protons as a function of either eta or y and of Pt.");
95
96  Printf("\nFunction compareEfficiencies: Takes as arguments the filenames produced by the drawEfficiency (see before - usually the name is Reconstruction-PID-Efficiency.root) and three booleans indicating whether the points for primaries, secondaries from weak decays and secondaries from hadronic interactions will be shown. The two files correspond to two different tracking methods (e.g. TPC, Hybrid, Global). It displays:");
97   Printf("\t 1. Reconstruction efficiencies for primary and secondary (anti)protons as a function of either eta or y. The secondaries are categorized by the MC process as originating from a weak decay or from a hadronic interaction.");
98   Printf("\t 2. Reconstruction efficiencies for primary and secondary (anti)protons as a function of Pt. The secondaries are categorized by the MC process as originating from a weak decay or from a hadronic interaction.");
99
100   Printf("\nFunction draw2DEfficiency: Takes as an argument the analysis and the PID mode along with the desired projection of the 3D plots. It draws the PID efficiency as a function of the different parameters.");
101   Printf("\t yx: Efficiency vs pT vs eta");
102   Printf("\t zx: Efficiency vs Npoints TPC for the dE/dx vs eta");
103   Printf("\t zy: Efficiency vs Npoints TPC for the dE/dx vs pT");
104
105   Printf("\nFunction drawCutParametersDistributions: Takes as an argument the third file created by the QA code (usually the name is Protons.QA.Histograms.<AnalysisMode>.root) and displays the distributions of accepted primaries (in blue) and secondaries (in orange) for the different cut parameters.");
106   Printf("==================================================================\n\n\n");
107 }
108
109 //________________________________________//
110 void drawCutStatistics(TList *list,
111                        const char* analysisType) {
112   //Function to display the statistics from the cuts
113   //The histogram shows the influence of each cut on the primary
114   //and secondary (anti)protons
115   const Int_t NQAHISTOSPERLIST = 27;
116
117   Double_t gEntriesQA2DList[12] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
118   Double_t gEntriesQAPrimaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryProtonsRejectedList[NQAHISTOSPERLIST];
119   Double_t gEntriesQASecondaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryProtonsRejectedList[NQAHISTOSPERLIST];
120   Double_t gEntriesQAPrimaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
121   Double_t gEntriesQASecondaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
122
123   for(Int_t i = 0; i < NQAHISTOSPERLIST; i++) {
124     gEntriesQAPrimaryProtonsAcceptedList[i] = 0.0;
125     gEntriesQAPrimaryProtonsRejectedList[i] = 0.0;
126     gEntriesQASecondaryProtonsAcceptedList[i] = 0.0;
127     gEntriesQASecondaryProtonsRejectedList[i] = 0.0;
128     gEntriesQAPrimaryAntiProtonsAcceptedList[i] = 0.0;
129     gEntriesQAPrimaryAntiProtonsRejectedList[i] = 0.0;
130     gEntriesQASecondaryAntiProtonsAcceptedList[i] = 0.0;
131     gEntriesQASecondaryAntiProtonsRejectedList[i] = 0.0;
132   }
133
134   TList *fQA2DList = (TList *)list->At(0);
135   GetQAEntries(fQA2DList,gEntriesQA2DList);
136   TH3F *gHistYPtPDGProtonsPass = (TH3F *)fQA2DList->At(10);
137   TH3F *gHistYPtPDGAntiProtonsPass = (TH3F *)fQA2DList->At(11);
138  
139   TList *fQAPrimaryProtonsAcceptedList = (TList *)list->At(1);
140   GetQAEntries(fQAPrimaryProtonsAcceptedList,gEntriesQAPrimaryProtonsAcceptedList);
141
142   TList *fQAPrimaryProtonsRejectedList = (TList *)list->At(2);
143   GetQAEntries(fQAPrimaryProtonsRejectedList,gEntriesQAPrimaryProtonsRejectedList);
144
145   TList *fQASecondaryProtonsAcceptedList = (TList *)list->At(3);
146   GetQAEntries(fQASecondaryProtonsAcceptedList,gEntriesQASecondaryProtonsAcceptedList);
147
148   TList *fQASecondaryProtonsRejectedList = (TList *)list->At(4);
149   GetQAEntries(fQASecondaryProtonsRejectedList,gEntriesQASecondaryProtonsRejectedList);
150
151   TList *fQAPrimaryAntiProtonsAcceptedList = (TList *)list->At(5);
152   GetQAEntries(fQAPrimaryAntiProtonsAcceptedList,gEntriesQAPrimaryAntiProtonsAcceptedList);
153
154   TList *fQAPrimaryAntiProtonsRejectedList = (TList *)list->At(6);
155   GetQAEntries(fQAPrimaryAntiProtonsRejectedList,gEntriesQAPrimaryAntiProtonsRejectedList);
156
157   TList *fQASecondaryAntiProtonsAcceptedList = (TList *)list->At(7);
158   GetQAEntries(fQASecondaryAntiProtonsAcceptedList,gEntriesQASecondaryAntiProtonsAcceptedList);
159
160   TList *fQASecondaryAntiProtonsRejectedList = (TList *)list->At(8);
161   GetQAEntries(fQASecondaryAntiProtonsRejectedList,gEntriesQASecondaryAntiProtonsRejectedList);
162
163   //_______________________________________________________//
164   //Create the histograms
165   const Int_t nx = 27;
166   char *fCutName[nx] = {"Tracks","",
167                         "ITS Clusters",
168                         "#chi^{2}/N_{ITS-Clusters}",
169                         "TPC Clusters",
170                         "#chi^{2}/N_{TPC-Clusters}",
171                         "ExtCov11",
172                         "ExtCov22",
173                         "ExtCov33",
174                         "ExtCov44",
175                         "ExtCov55",
176                         "#sigma_{Vertex}",
177                         "#sigma_{Vertex-TPC}",
178                         "DCA_{xy}",
179                         "DCA_{xy}(TPC)",
180                         "DCA_{z}",
181                         "DCA_{z}(TPC)",
182                         "#chi^{2}(vertex)",
183                         "ITS refit",
184                         "TPC refit",
185                         "ESD pid",
186                         "TPC pid",
187                         "N_{points} (dE/dx)","",
188                         "N_{Secondaries}/N_{total}","",""};
189   char *fCutITSName[6] = {"SPD_{1}","SPD_{2}",
190                           "SDD_{1}","SDD_{2}",
191                           "SSD_{1}","SSD_{2}"};
192
193   //cut influence
194   TH2F *hEmpty = new TH2F("hEmpty","",nx,0,nx,100,0,100); 
195   hEmpty->SetStats(kFALSE); 
196   hEmpty->SetMarkerStyle(kFullCircle);
197   hEmpty->SetLineColor(2); hEmpty->SetMarkerColor(2);
198   hEmpty->GetYaxis()->SetTitle("Influence of the cuts [%]");
199   for(Int_t i = 1; i <= nx; i++) 
200     hEmpty->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
201   hEmpty->GetXaxis()->SetLabelOffset(0.01); 
202   hEmpty->GetXaxis()->SetLabelSize(0.045);
203
204   //primary protons
205   TH1F *hPrimaryProtons = new TH1F("hPrimaryProtons","",nx,0,nx); 
206   hPrimaryProtons->SetStats(kFALSE); 
207   hPrimaryProtons->SetMarkerStyle(kFullCircle);
208   hPrimaryProtons->SetLineColor(4); hPrimaryProtons->SetLineWidth(2); 
209   hPrimaryProtons->SetMarkerColor(4);
210   hPrimaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
211   for(Int_t i = 1; i <= nx; i++) {
212     hPrimaryProtons->SetBinContent(i,-10.);
213     hPrimaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
214   }
215   hPrimaryProtons->GetXaxis()->SetLabelOffset(0.01); 
216   hPrimaryProtons->GetXaxis()->SetLabelSize(0.045);
217
218   //secondary protons
219   TH1F *hSecondaryProtons = new TH1F("hSecondaryProtons","",nx,0,nx); 
220   hSecondaryProtons->SetStats(kFALSE); 
221   hSecondaryProtons->SetMarkerStyle(22);
222   hSecondaryProtons->SetMarkerSize(1.4);
223   hSecondaryProtons->SetLineColor(2); hSecondaryProtons->SetLineWidth(2); 
224   hSecondaryProtons->SetMarkerColor(2);
225   hSecondaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
226   for(Int_t i = 1; i <= nx; i++) {
227     hSecondaryProtons->SetBinContent(i,-10.);
228     hSecondaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
229   }
230   hSecondaryProtons->GetXaxis()->SetLabelOffset(0.01); 
231   hSecondaryProtons->GetXaxis()->SetLabelSize(0.045);
232
233   //primary antiprotons
234   TH1F *hPrimaryAntiProtons = new TH1F("hPrimaryAntiProtons","",nx,0,nx); 
235   hPrimaryAntiProtons->SetStats(kFALSE); 
236   hPrimaryAntiProtons->SetMarkerStyle(kFullCircle);
237   hPrimaryAntiProtons->SetLineColor(4); hPrimaryAntiProtons->SetLineWidth(2); 
238   hPrimaryAntiProtons->SetMarkerColor(4);
239   hPrimaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
240   for(Int_t i = 1; i <= nx; i++) {
241     hPrimaryAntiProtons->SetBinContent(i,-10.);
242     hPrimaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
243   }
244   hPrimaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
245   hPrimaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
246
247   //secondary antiprotons
248   TH1F *hSecondaryAntiProtons = new TH1F("hSecondaryAntiProtons","",nx,0,nx); 
249   hSecondaryAntiProtons->SetStats(kFALSE); 
250   hSecondaryAntiProtons->SetMarkerStyle(22);
251   hSecondaryAntiProtons->SetMarkerSize(1.4);
252   hSecondaryAntiProtons->SetLineColor(2); hSecondaryAntiProtons->SetLineWidth(2); 
253   hSecondaryAntiProtons->SetMarkerColor(2);
254   hSecondaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
255   for(Int_t i = 1; i <= nx; i++) {
256     hSecondaryAntiProtons->SetBinContent(i,-10.);
257     hSecondaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
258   }
259   hSecondaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
260   hSecondaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
261   //_______________________________________________________//
262
263   //1D for primary protons
264   //cout<<"_____________________________________________________"<<endl;
265   //cout<<"_______________PRIMARY PROTONS_______________________"<<endl;
266   hPrimaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[1]));
267
268   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
269     hPrimaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryProtonsAcceptedList[i-2],
270                                                      gEntriesQAPrimaryProtonsRejectedList[i-2]));
271   
272   //1D for secondary protons
273   //cout<<"_____________________________________________________"<<endl;
274   //cout<<"_______________SECONDARY PROTONS_____________________"<<endl;
275   hSecondaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[2],gEntriesQA2DList[3]));
276   
277   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
278     hSecondaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryProtonsAcceptedList[i-2],
279                                                        gEntriesQASecondaryProtonsRejectedList[i-2]));
280   hSecondaryProtons->SetBinContent(25,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[2]));
281
282   //1D for primary antiprotons
283   //cout<<"_________________________________________________________"<<endl;
284   //cout<<"_______________PRIMARY ANTIPROTONS_______________________"<<endl;
285   hPrimaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[5]));
286   
287   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
288     hPrimaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryAntiProtonsAcceptedList[i-2],
289                                                          gEntriesQAPrimaryAntiProtonsRejectedList[i-2]));
290   
291   //1D for secondary antiprotons
292   //cout<<"_________________________________________________________"<<endl;
293   //cout<<"_______________SECONDARY ANTIPROTONS_____________________"<<endl;
294   hSecondaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[6],gEntriesQA2DList[7]));
295
296   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
297     hSecondaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryAntiProtonsAcceptedList[i-2],
298                                                            gEntriesQASecondaryAntiProtonsRejectedList[i-2]));
299   hSecondaryAntiProtons->SetBinContent(25,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[6]));
300
301   TLatex *t1 = new TLatex();
302   t1->SetTextSize(0.04);
303   //_________________________________________________________//
304   TCanvas *c1 = new TCanvas("c1","Cut Influence - Protons",0,0,700,400);
305   c1->SetHighLightColor(10); c1->SetBottomMargin(0.15);
306   c1->SetGridx(); c1->SetGridy();
307
308   for(Int_t i = 1; i <= nx; i++) {
309     hPrimaryProtons->SetBinError(i,1.0);
310     hSecondaryProtons->SetBinError(i,1.0);
311   }
312   hEmpty->DrawCopy();
313   hPrimaryProtons->DrawCopy("EHISTSAME");
314   hSecondaryProtons->DrawCopy("EHISTSAME");
315   DrawMarker(20.5, 90, 20, 1.2, 4);
316   t1->DrawLatex(21,88,"Primary p");
317   DrawMarker(20.5, 80, 22, 1.2, 2);
318   t1->DrawLatex(21,78,"Secondary p");
319
320   c1->SaveAs("CutInfluence-Protons.gif");
321
322   //_________________________________________________________//
323   TCanvas *c2 = new TCanvas("c2","Cut Influence - AntiProtons",50,50,700,400);
324   c2->SetHighLightColor(10); c2->SetBottomMargin(0.15);
325   c2->SetGridx(); c2->SetGridy();
326
327   for(Int_t i = 1; i <= nx; i++) {
328     hPrimaryAntiProtons->SetBinError(i,1.0);
329     hSecondaryAntiProtons->SetBinError(i,1.0);
330   }
331   hEmpty->DrawCopy();
332   hPrimaryAntiProtons->DrawCopy("EHISTSAME");
333   hSecondaryAntiProtons->DrawCopy("EHISTSAME");
334   DrawMarker(20.5, 90, 20, 1.2, 4);
335   t1->DrawLatex(21,88,"Primary #bar{p}");
336   DrawMarker(20.5, 80, 22, 1.2, 2);
337   t1->DrawLatex(21,78,"Secondary #bar{p}");
338
339   c2->SaveAs("CutInfluence-AntiProtons.gif");
340
341   //_________________________________________________________//
342   //ITS layers influence
343   TH2F *hEmptyITS = new TH2F("hEmptyITS","",10,0,10,100,0,100); 
344   hEmptyITS->SetStats(kFALSE); 
345   hEmptyITS->SetMarkerStyle(kFullCircle);
346   hEmptyITS->SetLineColor(2); hEmptyITS->SetMarkerColor(2);
347   hEmptyITS->GetYaxis()->SetTitle("Influence of the ITS layers [%]");
348   hEmptyITS->GetYaxis()->SetTitleOffset(1.3);
349   for(Int_t i = 1; i <= 6; i++) 
350     hEmptyITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
351   hEmptyITS->GetXaxis()->SetLabelOffset(0.01); 
352   hEmptyITS->GetXaxis()->SetLabelSize(0.045);
353
354   //_________________________________________________________//
355   //primary protons
356   TH1F *hPrimaryProtonsITS = new TH1F("hPrimaryProtonsITS","",7,0,7); 
357   hPrimaryProtonsITS->SetStats(kFALSE); 
358   hPrimaryProtonsITS->SetMarkerStyle(kFullCircle);
359   hPrimaryProtonsITS->SetLineColor(4); hPrimaryProtonsITS->SetLineWidth(2); 
360   hPrimaryProtonsITS->SetMarkerColor(4);
361   hPrimaryProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
362   for(Int_t i = 1; i <= 6; i++) {
363     hPrimaryProtonsITS->SetBinContent(i,-10.);
364     hPrimaryProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
365   }
366   hPrimaryProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
367   hPrimaryProtonsITS->GetXaxis()->SetLabelSize(0.045);
368
369   //secondary protons
370   TH1F *hSecondaryProtonsITS = new TH1F("hSecondaryProtonsITS","",7,0,7); 
371   hSecondaryProtonsITS->SetStats(kFALSE); 
372   hSecondaryProtonsITS->SetMarkerStyle(22);
373   hSecondaryProtonsITS->SetMarkerSize(1.4);
374   hSecondaryProtonsITS->SetLineColor(2); hSecondaryProtonsITS->SetLineWidth(2); 
375   hSecondaryProtonsITS->SetMarkerColor(2);
376   hSecondaryProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
377   for(Int_t i = 1; i <= 6; i++) {
378     hSecondaryProtonsITS->SetBinContent(i,-10.);
379     hSecondaryProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
380   }
381   hSecondaryProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
382   hSecondaryProtonsITS->GetXaxis()->SetLabelSize(0.045);
383
384   //primary antiprotons
385   TH1F *hPrimaryAntiProtonsITS = new TH1F("hPrimaryAntiProtonsITS","",7,0,7); 
386   hPrimaryAntiProtonsITS->SetStats(kFALSE); 
387   hPrimaryAntiProtonsITS->SetMarkerStyle(kFullCircle);
388   hPrimaryAntiProtonsITS->SetLineColor(4); hPrimaryAntiProtonsITS->SetLineWidth(2); 
389   hPrimaryAntiProtonsITS->SetMarkerColor(4);
390   hPrimaryAntiProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
391   for(Int_t i = 1; i <= 6; i++) {
392     hPrimaryAntiProtonsITS->SetBinContent(i,-10.);
393     hPrimaryAntiProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
394   }
395   hPrimaryAntiProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
396   hPrimaryAntiProtonsITS->GetXaxis()->SetLabelSize(0.045);
397
398   //secondary antiprotons
399   TH1F *hSecondaryAntiProtonsITS = new TH1F("hSecondaryAntiProtonsITS","",7,0,7); 
400   hSecondaryAntiProtonsITS->SetStats(kFALSE); 
401   hSecondaryAntiProtonsITS->SetMarkerStyle(22);
402   hSecondaryAntiProtonsITS->SetMarkerSize(1.4);
403   hSecondaryAntiProtonsITS->SetLineColor(2); hSecondaryAntiProtonsITS->SetLineWidth(2); 
404   hSecondaryAntiProtonsITS->SetMarkerColor(2);
405   hSecondaryAntiProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
406   for(Int_t i = 1; i <= 6; i++) {
407     hSecondaryAntiProtonsITS->SetBinContent(i,-10.);
408     hSecondaryAntiProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
409   }
410   hSecondaryAntiProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
411   hSecondaryAntiProtonsITS->GetXaxis()->SetLabelSize(0.045);
412
413   //_______________________________________________________//
414   TCanvas *c9 = new TCanvas("c9","ITS cluster map - (anti)protons",
415                             100,100,700,400);
416   c9->SetHighLightColor(10); c9->Divide(2,1);
417   for(Int_t i = 1; i <= 6; i++) {
418     hPrimaryProtonsITS->SetBinError(i,1.0);
419     hSecondaryProtonsITS->SetBinError(i,1.0);
420     hPrimaryAntiProtonsITS->SetBinError(i,1.0);
421     hSecondaryAntiProtonsITS->SetBinError(i,1.0);
422   }
423   c9->cd(1)->SetBottomMargin(0.15);
424   c9->cd(1)->SetLeftMargin(0.15);
425   c9->cd(1)->SetGridx(); c9->cd(1)->SetGridy();
426   hEmptyITS->SetTitle("Protons");
427   hEmptyITS->DrawCopy();
428
429   for(Int_t i = 1; i < 7; i++) {
430     hPrimaryProtonsITS->SetBinContent(i,GetPercentage(gEntriesQAPrimaryProtonsAcceptedList[20+i],
431                                                       gEntriesQAPrimaryProtonsRejectedList[20+i]));
432     hSecondaryProtonsITS->SetBinContent(i,GetPercentage(gEntriesQASecondaryProtonsAcceptedList[20+i],
433                                                         gEntriesQASecondaryProtonsRejectedList[20+i]));
434   }
435   hPrimaryProtonsITS->DrawCopy("EHISTSAME");
436   hSecondaryProtonsITS->DrawCopy("EHISTSAME");
437   DrawMarker(6.5, 90, 20, 1.2, 4);
438   t1->DrawLatex(7,88,"Primary p");
439   DrawMarker(6.5, 80, 22, 1.2, 2);
440   t1->DrawLatex(7,78,"Secondary p");
441
442   c9->cd(2)->SetBottomMargin(0.15);
443   c9->cd(2)->SetLeftMargin(0.15);
444   c9->cd(2)->SetGridx(); c9->cd(2)->SetGridy();
445   hEmptyITS->SetTitle("Antiprotons");
446   hEmptyITS->DrawCopy();
447   for(Int_t i = 1; i < 7; i++) {
448     hPrimaryAntiProtonsITS->SetBinContent(i,GetPercentage(gEntriesQAPrimaryAntiProtonsAcceptedList[20+i],
449                                                           gEntriesQAPrimaryAntiProtonsRejectedList[20+i]));
450     hSecondaryAntiProtonsITS->SetBinContent(i,GetPercentage(gEntriesQASecondaryAntiProtonsAcceptedList[20+i],
451                                                             gEntriesQASecondaryAntiProtonsRejectedList[20+i]));
452   }
453   hPrimaryAntiProtonsITS->DrawCopy("EHISTSAME");
454   hSecondaryAntiProtonsITS->DrawCopy("EHISTSAME");
455   DrawMarker(6.5, 90, 20, 1.2, 4);
456   t1->DrawLatex(7,88,"Primary #bar{p}");
457   DrawMarker(6.5, 80, 22, 1.2, 2);
458   t1->DrawLatex(7,78,"Secondary #bar{p}");
459
460   c9->SaveAs("CutInfluence-ITS.gif");
461   
462   //Efficiency - Contamination plots
463   DrawContamination(fQA2DList,analysisType);
464   DrawComposition(gHistYPtPDGProtonsPass,gHistYPtPDGAntiProtonsPass);
465 }
466
467 //________________________________________//
468 void DrawComposition(TH3F *gHistYPtPDGProtons,
469                      TH3F *gHistYPtPDGAntiProtons) {
470   //Function to display the composition of secondary (anti)protons
471   //that survive the quality criteria
472   Double_t nParticleCompositionProtonY[200], nParticleCompositionProtonPt[200];
473   Double_t nParticleCompositionProtonYError[200], nParticleCompositionProtonPtError[200];
474   Double_t nParticleCompositionAntiProtonY[200], nParticleCompositionAntiProtonPt[200];
475   Double_t nParticleCompositionAntiProtonYError[200], nParticleCompositionAntiProtonPtError[200];
476   Double_t gY[200], gPt[200];
477   Double_t gYError[200], gPtError[200];
478   for(Int_t iBins = 0; iBins < 200; iBins++) {
479     nParticleCompositionProtonY[iBins] = 0;
480     nParticleCompositionProtonPt[iBins] = 0;
481     nParticleCompositionProtonYError[iBins] = 0;
482     nParticleCompositionProtonPtError[iBins] = 0;
483     nParticleCompositionAntiProtonY[iBins] = 0;
484     nParticleCompositionAntiProtonPt[iBins] = 0;
485     nParticleCompositionAntiProtonYError[iBins] = 0;
486     nParticleCompositionAntiProtonPtError[iBins] = 0;
487     gY[iBins] = 0;
488     gPt[iBins] = 0;
489     gYError[iBins] = 0;
490     gPtError[iBins] = 0;
491   }
492   
493   TGraphErrors *gParticleProtonY[14];
494   TGraphErrors *gParticleProtonPt[14];
495   TGraphErrors *gParticleAntiProtonY[14];
496   TGraphErrors *gParticleAntiProtonPt[14];
497   for(Int_t iParticle = 0; iParticle < 14; iParticle++) {
498     GetComposition(iParticle,
499                    gHistYPtPDGProtons,
500                    nParticleCompositionProtonY,nParticleCompositionProtonYError,gY, gYError,
501                    nParticleCompositionProtonPt, nParticleCompositionProtonPtError, gPt, gPtError);
502     gParticleProtonY[iParticle] = new TGraphErrors(gHistYPtPDGProtons->GetNbinsX(),
503                                                   gY,nParticleCompositionProtonY,gYError,nParticleCompositionProtonYError);
504     gParticleProtonY[iParticle]->SetMarkerStyle(iParticle+20);
505     gParticleProtonY[iParticle]->SetMarkerSize(1.2);
506
507     gParticleProtonPt[iParticle] = new TGraphErrors(gHistYPtPDGProtons->GetNbinsY(),
508                                                    gPt,nParticleCompositionProtonPt,gPtError,nParticleCompositionProtonPtError);
509     gParticleProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
510     gParticleProtonPt[iParticle]->SetMarkerSize(1.2);
511
512     GetComposition(iParticle,
513                    gHistYPtPDGAntiProtons,
514                    nParticleCompositionAntiProtonY,nParticleCompositionAntiProtonYError,gY, gYError, 
515                    nParticleCompositionAntiProtonPt, nParticleCompositionAntiProtonPtError, gPt, gPtError);
516     gParticleAntiProtonY[iParticle] = new TGraphErrors(gHistYPtPDGAntiProtons->GetNbinsX(),
517                                                       gY,nParticleCompositionAntiProtonY,gYError,nParticleCompositionAntiProtonYError);
518     gParticleAntiProtonY[iParticle]->SetMarkerStyle(iParticle+20);
519     gParticleAntiProtonY[iParticle]->SetMarkerSize(1.2);
520
521     gParticleAntiProtonPt[iParticle] = new TGraphErrors(gHistYPtPDGAntiProtons->GetNbinsY(),
522                                                        gPt,nParticleCompositionAntiProtonPt,gPtError,nParticleCompositionAntiProtonPtError);
523     gParticleAntiProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
524     gParticleAntiProtonPt[iParticle]->SetMarkerSize(1.2);
525   }
526
527   //_________________________________________________________//
528   char *fParticleName[14] = {"Primary","K_{L}","#pi","K_{S}","K",
529                              "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
530                              "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
531   TLatex *t1 = new TLatex();
532   t1->SetTextSize(0.04);
533
534   TH2F *hEmptyY = new TH2F("hEmptyY","",100,-1.2,1.2,100,0,120); 
535   hEmptyY->SetStats(kFALSE); 
536   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
537   hEmptyY->GetXaxis()->SetTitle(gHistYPtPDGProtons->GetXaxis()->GetTitle());
538
539   TCanvas *c12 = new TCanvas("c12",
540                              "Composition of accepted secondaries vs y",
541                              350,350,700,400);
542   c12->Divide(2,1);
543   c12->SetHighLightColor(10); c12->cd(1)->SetBottomMargin(0.15);
544   c12->cd(1)->SetGridx(); c12->cd(1)->SetGridy();
545   hEmptyY->SetTitle("Protons");
546   hEmptyY->DrawCopy();
547   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
548     //if((iParticle == 0)||(iParticle == 2)||(iParticle == 5)||(iParticle == 6)||(iParticle == 8))
549     if((iParticle == 2)||(iParticle == 6)||(iParticle == 8)) {
550       gParticleProtonY[iParticle]->Draw("P");
551       //if(iParticle < 5) {
552       //DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
553       //t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
554     }
555     /*else {
556       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
557       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
558       }*/
559   }
560   DrawMarker(0.0, 115, 22, 1.2, 1);
561   t1->DrawLatex(0.1,113,fParticleName[2]);
562   DrawMarker(0.0, 105, 26, 1.2, 1);
563   t1->DrawLatex(0.1,103,fParticleName[6]);
564   DrawMarker(0.0, 95, 28, 1.2, 1);
565   t1->DrawLatex(0.1,93,fParticleName[8]);
566
567   c12->SetHighLightColor(10); c12->cd(2)->SetBottomMargin(0.15);
568   c12->cd(2)->SetGridx(); c12->cd(2)->SetGridy();
569   hEmptyY->SetTitle("Antiprotons");
570   hEmptyY->DrawCopy();
571   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
572     if((iParticle == 6)||(iParticle == 8)||(iParticle == 9))
573       gParticleAntiProtonY[iParticle]->Draw("P");
574     /*if(iParticle < 5) {
575       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
576       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
577     }
578     else {
579       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
580       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
581       }*/
582   }
583   DrawMarker(0.0, 115, 26, 1.2, 1);
584   t1->DrawLatex(0.1,113,fParticleName[6]);
585   DrawMarker(0.0, 105, 28, 1.2, 1);
586   t1->DrawLatex(0.1,103,fParticleName[8]);
587   DrawMarker(0.0, 95, 29, 1.2, 1);
588   t1->DrawLatex(0.1,93,fParticleName[9]);
589   c12->SaveAs("SurvivedSecondaries-Composition-Rapidity.gif");
590
591   TH2F *hEmptyPt = new TH2F("hEmptyPt","",100,0.0,4.0,100,0,120); 
592   hEmptyPt->SetStats(kFALSE); 
593   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
594   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
595
596   TCanvas *c13 = new TCanvas("c13",
597                              "Composition of accepted secondaries vs pT",
598                              400,400,700,400);
599   c13->Divide(2,1);
600   c13->SetHighLightColor(10); c13->cd(1)->SetBottomMargin(0.15);
601   c13->cd(1)->SetGridx(); c13->cd(1)->SetGridy();
602   hEmptyPt->GetXaxis()->SetRangeUser(gParticleProtonPt[0]->GetXaxis()->GetXmin()-0.2,gParticleProtonPt[0]->GetXaxis()->GetXmax()+0.2);
603   hEmptyPt->SetTitle("Protons");
604   hEmptyPt->DrawCopy();
605   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
606     /*if(iParticle < 5) {
607       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.1, 
608                  115-5*iParticle, 20+iParticle, 1.2, 1);
609       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.2,
610                     113-5*iParticle,fParticleName[iParticle]);
611     }
612     else {
613       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5, 
614                  115-5*(iParticle-5), 20+iParticle, 1.2, 1);
615       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5+0.1,
616                     113-5*(iParticle-5),fParticleName[iParticle]);
617                     }*/
618     if((iParticle == 2)||(iParticle == 6)||(iParticle == 8))
619       gParticleProtonPt[iParticle]->Draw("P");
620   }
621   DrawMarker(0.5, 115, 22, 1.2, 1);
622   t1->DrawLatex(0.6,113,fParticleName[2]);
623   DrawMarker(0.5, 105, 26, 1.2, 1);
624   t1->DrawLatex(0.6,103,fParticleName[6]);
625   DrawMarker(0.5, 95, 28, 1.2, 1);
626   t1->DrawLatex(0.6,93,fParticleName[8]);
627
628   c13->SetHighLightColor(10); c13->cd(2)->SetBottomMargin(0.15);
629   c13->cd(2)->SetGridx(); c13->cd(2)->SetGridy();
630   hEmptyPt->SetTitle("Antiprotons");
631   hEmptyPt->DrawCopy();
632   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
633     /*if(iParticle < 5) {
634       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.1, 
635                  115-5*iParticle, 20+iParticle, 1.2, 1);
636       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.2,
637                     113-5*iParticle,fParticleName[iParticle]);
638     }
639     else {
640       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5, 
641                  115-5*(iParticle-5), 20+iParticle, 1.2, 1);
642       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5+0.1,
643                     113-5*(iParticle-5),fParticleName[iParticle]);
644                     }*/
645     if((iParticle == 6)||(iParticle == 8)||(iParticle == 9))
646       gParticleAntiProtonPt[iParticle]->Draw("P");
647   }
648   DrawMarker(0.5, 115, 26, 1.2, 1);
649   t1->DrawLatex(0.6,113,fParticleName[6]);
650   DrawMarker(0.5, 105, 28, 1.2, 1);
651   t1->DrawLatex(0.6,103,fParticleName[8]);
652   DrawMarker(0.5, 95, 29, 1.2, 1);
653   t1->DrawLatex(0.6,93,fParticleName[9]);
654   c13->SaveAs("SurvivedSecondaries-Composition-Pt.gif");
655 }
656
657 //________________________________________________//
658 void DrawContamination(TList *inputList,
659                        const char* analysisType) {
660   //loops over the list entries and
661   //draws the rapidity and pT dependence
662   //of the percentage of primary and secondary
663   //protons and antiprotons after the track cuts
664   cout<<"Extracting the entries for the histograms in the list: "<<
665     inputList->GetName()<<"..."<<endl;
666
667   TLatex *t1 = new TLatex();
668   t1->SetTextSize(0.04);
669
670  TH2D *hPrimaryProtons = (TH2D *)inputList->At(0);
671   hPrimaryProtons->SetStats(kFALSE); hPrimaryProtons->Sumw2();
672   TH2D *hSecondaryProtons = (TH2D *)inputList->At(2);
673   hSecondaryProtons->SetStats(kFALSE); hSecondaryProtons->Sumw2();
674   TH2D *hTotalProtons = hSecondaryProtons->Clone();
675   hTotalProtons->SetStats(kFALSE); hTotalProtons->Add(hPrimaryProtons);
676   hTotalProtons->Sumw2();
677
678   TH2D *hPrimaryAntiProtons = (TH2D *)inputList->At(4);
679   hPrimaryAntiProtons->SetStats(kFALSE); hPrimaryAntiProtons->Sumw2();
680   TH2D *hSecondaryAntiProtons = (TH2D *)inputList->At(6);
681   hSecondaryAntiProtons->SetStats(kFALSE); hSecondaryAntiProtons->Sumw2();
682   TH2D *hTotalAntiProtons = hSecondaryAntiProtons->Clone();
683   hTotalAntiProtons->SetStats(kFALSE); 
684   hTotalAntiProtons->Add(hPrimaryAntiProtons);
685   hTotalAntiProtons->Sumw2();
686
687   //=================================================================//
688   //Purity - protons
689   hPrimaryProtons->Divide(hTotalProtons);
690   hPrimaryProtons->Scale(100.);
691   TH1D *gHistEtaPurityProtons = hPrimaryProtons->ProjectionX("gHistEtaPurityProtons",1,hPrimaryProtons->GetNbinsY());
692   RescaleEtaHistogram(gHistEtaPurityProtons,hPrimaryProtons);
693   gHistEtaPurityProtons->SetStats(kFALSE);
694   gHistEtaPurityProtons->SetMarkerStyle(20);
695   TH1D *gHistPtPurityProtons = hPrimaryProtons->ProjectionY("gHistPtPurityProtons",1,hPrimaryProtons->GetNbinsX());
696   RescalePtHistogram(gHistPtPurityProtons,hPrimaryProtons);
697   gHistPtPurityProtons->SetStats(kFALSE);
698   gHistPtPurityProtons->SetMarkerStyle(20);
699
700   //Contamination - protons
701   hSecondaryProtons->Divide(hTotalProtons);
702   hSecondaryProtons->Scale(100.);
703   TH1D *gHistEtaContaminationProtons = hSecondaryProtons->ProjectionX("gHistEtaContaminationProtons",1,hSecondaryProtons->GetNbinsY());
704   RescaleEtaHistogram(gHistEtaContaminationProtons,hSecondaryProtons);
705   gHistEtaContaminationProtons->SetStats(kFALSE);
706   gHistEtaContaminationProtons->SetMarkerStyle(24);
707   TH1D *gHistPtContaminationProtons = hSecondaryProtons->ProjectionY("gHistPtContaminationProtons",1,hSecondaryProtons->GetNbinsX());
708   RescalePtHistogram(gHistPtContaminationProtons,hSecondaryProtons);
709   gHistPtContaminationProtons->SetStats(kFALSE);
710   gHistPtContaminationProtons->SetMarkerStyle(24);
711
712     //=================================================================//
713   //Purity - antiprotons
714   hPrimaryAntiProtons->Divide(hTotalAntiProtons);
715   hPrimaryAntiProtons->Scale(100.);
716   TH1D *gHistEtaPurityAntiProtons = hPrimaryAntiProtons->ProjectionX("gHistEtaPurityAntiProtons",1,hPrimaryAntiProtons->GetNbinsY());
717   RescaleEtaHistogram(gHistEtaPurityAntiProtons,hPrimaryAntiProtons);
718   gHistEtaPurityAntiProtons->SetStats(kFALSE);
719   gHistEtaPurityAntiProtons->SetMarkerStyle(20);
720   TH1D *gHistPtPurityAntiProtons = hPrimaryAntiProtons->ProjectionY("gHistPtPurityAntiProtons",1,hPrimaryAntiProtons->GetNbinsX());
721   RescalePtHistogram(gHistPtPurityAntiProtons,hPrimaryAntiProtons);
722   gHistPtPurityAntiProtons->SetStats(kFALSE);
723   gHistPtPurityAntiProtons->SetMarkerStyle(20);
724
725   //Contamination - antiprotons
726   hSecondaryAntiProtons->Divide(hTotalAntiProtons);
727   hSecondaryAntiProtons->Scale(100.);
728   TH1D *gHistEtaContaminationAntiProtons = hSecondaryAntiProtons->ProjectionX("gHistEtaContaminationAntiProtons",1,hSecondaryAntiProtons->GetNbinsY());
729   RescaleEtaHistogram(gHistEtaContaminationAntiProtons,hSecondaryAntiProtons);
730   gHistEtaContaminationAntiProtons->SetStats(kFALSE);
731   gHistEtaContaminationAntiProtons->SetMarkerStyle(24);
732   TH1D *gHistPtContaminationAntiProtons = hSecondaryAntiProtons->ProjectionY("gHistPtContaminationAntiProtons",1,hSecondaryAntiProtons->GetNbinsX());
733   RescalePtHistogram(gHistPtContaminationAntiProtons,hSecondaryAntiProtons);
734   gHistPtContaminationAntiProtons->SetStats(kFALSE);
735   gHistPtContaminationAntiProtons->SetMarkerStyle(24);
736   
737   TH2F *hEmptyY = new TH2F("hEmptyCompositionY","",
738                            100,-1.2,1.2,100,-10.0,130); 
739   hEmptyY->SetStats(kFALSE); 
740   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
741   hEmptyY->GetYaxis()->SetTitleOffset(1.3);
742   hEmptyY->GetXaxis()->SetTitle(hPrimaryProtons->GetXaxis()->GetTitle());
743
744   TCanvas *c7 = new TCanvas("c7","(Anti)Proton contamination vs y",
745                             150,150,700,400);
746   c7->SetHighLightColor(10); c7->Divide(2,1);
747
748   c7->cd(1)->SetBottomMargin(0.15); 
749   c7->cd(1)->SetLeftMargin(0.15); 
750   c7->cd(1)->SetGridx(); c7->cd(1)->SetGridy();
751   hEmptyY->SetTitle("Protons");
752   hEmptyY->DrawCopy();
753   gHistEtaPurityProtons->DrawCopy("ESAME");
754   gHistEtaContaminationProtons->DrawCopy("ESAME");
755
756   DrawMarker(0, 55, kFullCircle, 1.2, 1);
757   t1->DrawLatex(0.1,53,"Primaries");
758   DrawMarker(0, 45, kOpenCircle, 1.2, 1);
759   t1->DrawLatex(0.1,43,"Secondaries");
760
761   c7->cd(2)->SetBottomMargin(0.15); 
762   c7->cd(2)->SetLeftMargin(0.15); 
763   c7->cd(2)->SetGridx(); c7->cd(2)->SetGridy();
764   hEmptyY->SetTitle("Antiprotons");
765   hEmptyY->DrawCopy();
766   gHistEtaPurityAntiProtons->DrawCopy("ESAME");
767   gHistEtaContaminationAntiProtons->DrawCopy("ESAME");
768
769   DrawMarker(0, 55, kFullCircle, 1.2, 1);
770   t1->DrawLatex(0.1,53,"Primaries");
771   DrawMarker(0, 45, kOpenCircle, 1.2, 1);
772   t1->DrawLatex(0.1,41,"Secondaries");
773
774   c7->SaveAs("Contamination-Protons-Rapidity.gif");
775   
776   TH2F *hEmptyPt = new TH2F("hEmptyCompositionPt","",
777                            100,0.0,4.0,100,-10.0,130); 
778   hEmptyPt->SetStats(kFALSE); 
779   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
780   hEmptyPt->GetYaxis()->SetTitleOffset(1.3);
781   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
782
783   TCanvas *c8 = new TCanvas("c8","(Anti)Proton comtamination vs pT",
784                             200,200,700,400);
785   c8->SetHighLightColor(10); c8->Divide(2,1);
786
787   c8->cd(1)->SetBottomMargin(0.15); 
788   c8->cd(1)->SetLeftMargin(0.15); 
789   c8->cd(1)->SetGridx(); c8->cd(1)->SetGridy();
790   hEmptyPt->SetTitle("Protons");
791   hEmptyPt->GetXaxis()->SetRangeUser(gHistPtPurityProtons->GetXaxis()->GetXmin()-0.1,gHistPtPurityProtons->GetXaxis()->GetXmax()+0.1);
792   hEmptyPt->DrawCopy();
793   gHistPtPurityProtons->DrawCopy("ESAME");
794   gHistPtContaminationProtons->DrawCopy("ESAME");
795
796   DrawMarker(0.5, 55, kFullCircle, 1.2, 1);
797   t1->DrawLatex(0.6,53,"Primaries");
798   DrawMarker(0.5, 45, kOpenCircle, 1.2, 1);
799   t1->DrawLatex(0.6,41,"Secondaries");
800
801   c8->cd(2)->SetBottomMargin(0.15); 
802   c8->cd(2)->SetLeftMargin(0.15); 
803   c8->cd(2)->SetGridx(); c8->cd(2)->SetGridy();
804   hEmptyPt->SetTitle("Antirotons");
805   hEmptyPt->DrawCopy();
806   gHistPtPurityAntiProtons->DrawCopy("ESAME");
807   gHistPtContaminationAntiProtons->DrawCopy("ESAME");
808
809   DrawMarker(2.0, 55, kFullCircle, 1.2, 1);
810   t1->DrawLatex(2.1,53,"Primaries");
811   DrawMarker(2.0, 45, kOpenCircle, 1.2, 1);
812   t1->DrawLatex(2.1,43,"Secondaries");
813
814   c8->SaveAs("Contamination-Protons-Pt.gif");
815
816   TString outputFileName = "Contamination."; 
817   outputFileName += analysisType; outputFileName += ".root";
818   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
819   gHistEtaPurityProtons->Write();
820   gHistEtaContaminationProtons->Write();
821   gHistEtaPurityAntiProtons->Write();
822   gHistEtaContaminationAntiProtons->Write();
823   gHistPtPurityProtons->Write();
824   gHistPtContaminationProtons->Write();
825   gHistPtPurityAntiProtons->Write();
826   gHistPtContaminationAntiProtons->Write();
827   fout->Close();
828 }
829
830 //________________________________________________//
831 void DrawCutEfficiency(TList *inputList,
832                        const char* analysisType) {
833   //loops over the list entries and
834   //draws the rapidity and pT dependence
835   //of the percentage of primary and secondary
836   //protons and antiprotons after the track cuts
837   cout<<"Extracting the entries for the histograms in the list: "<<
838     inputList->GetName()<<"..."<<endl;
839
840   TLatex *t1 = new TLatex();
841   t1->SetTextSize(0.04);
842
843   TH2D *hPrimaryESDProtons = (TH2D *)inputList->At(0);
844   hPrimaryESDProtons->SetStats(kFALSE); hPrimaryESDProtons->Sumw2();
845   TH2D *hPrimaryESDAntiProtons = (TH2D *)inputList->At(1);
846   hPrimaryESDAntiProtons->SetStats(kFALSE); hPrimaryESDAntiProtons->Sumw2();
847   TH2D *hPrimaryESDProtonsSurvived = (TH2D *)inputList->At(2);
848   hPrimaryESDProtonsSurvived->SetStats(kFALSE); hPrimaryESDProtonsSurvived->Sumw2();
849   hPrimaryESDProtonsSurvived->Divide(hPrimaryESDProtons);
850   hPrimaryESDProtonsSurvived->Scale(100.);
851   TH2D *hPrimaryESDAntiProtonsSurvived = (TH2D *)inputList->At(3);
852   hPrimaryESDAntiProtonsSurvived->SetStats(kFALSE); hPrimaryESDAntiProtonsSurvived->Sumw2();
853   hPrimaryESDAntiProtonsSurvived->Divide(hPrimaryESDAntiProtons);
854   hPrimaryESDAntiProtonsSurvived->Scale(100.);
855
856   //rapidity dependence
857   //Protons
858   TH1D *gHistEtaProtons = hPrimaryESDProtonsSurvived->ProjectionX("gHistEtaProtons",1,hPrimaryESDProtonsSurvived->GetNbinsY());
859   //gHistEtaProtons->Scale(1./hPrimaryESDProtonsSurvived->GetNbinsY());
860   RescaleEtaHistogram(gHistEtaProtons,hPrimaryESDProtonsSurvived);
861   gHistEtaProtons->SetStats(kFALSE);
862   gHistEtaProtons->SetMarkerStyle(20);
863   
864   //Antiprotons
865   TH1D *gHistEtaAntiProtons = hPrimaryESDAntiProtonsSurvived->ProjectionX("gHistEtaAntiProtons",1,hPrimaryESDAntiProtonsSurvived->GetNbinsY());
866   //gHistEtaAntiProtons->Scale(1./hPrimaryESDAntiProtonsSurvived->GetNbinsY());
867   RescaleEtaHistogram(gHistEtaAntiProtons,hPrimaryESDAntiProtonsSurvived);
868   gHistEtaAntiProtons->SetStats(kFALSE);
869   gHistEtaAntiProtons->SetMarkerStyle(20);
870   
871   TH2F *hEmptyY = new TH2F("hEmptyEfficiencyY","",
872                            100,-1.2,1.2,100,-10.0,130); 
873   hEmptyY->SetStats(kFALSE); 
874   hEmptyY->GetYaxis()->SetTitle("#epsilon [%]");
875   hEmptyY->GetYaxis()->SetTitleOffset(1.3);
876   hEmptyY->GetXaxis()->SetTitle(hPrimaryESDProtonsSurvived->GetXaxis()->GetTitle());
877
878   TCanvas *c10 = new TCanvas("c10","(Anti)Proton cut efficiency vs y",
879                             250,250,700,400);
880   c10->SetHighLightColor(10); c10->Divide(2,1);
881
882   c10->cd(1)->SetBottomMargin(0.15); 
883   c10->cd(1)->SetLeftMargin(0.15); 
884   c10->cd(1)->SetGridx(); c10->cd(1)->SetGridy();
885   hEmptyY->SetTitle("Protons");
886   hEmptyY->GetXaxis()->SetRangeUser(gHistEtaProtons->GetXaxis()->GetXmin()-0.2,gHistEtaProtons->GetXaxis()->GetXmax()+0.2);
887   hEmptyY->DrawCopy();
888   gHistEtaProtons->DrawCopy("ESAME");
889
890   c10->cd(2)->SetBottomMargin(0.15); 
891   c10->cd(2)->SetLeftMargin(0.15); 
892   c10->cd(2)->SetGridx(); c10->cd(2)->SetGridy();
893   hEmptyY->SetTitle("Antiprotons");
894   hEmptyY->DrawCopy();
895   gHistEtaAntiProtons->DrawCopy("ESAME");
896
897   c10->SaveAs("CutEfficiency-Protons-Rapidity.gif");
898
899   //pT dependence
900   //Protons
901   TH1D *gHistPtProtons = hPrimaryESDProtonsSurvived->ProjectionY("gHistPtProtons",1,hPrimaryESDProtonsSurvived->GetNbinsX());
902   //gHistPtProtons->Scale(1./hPrimaryESDProtonsSurvived->GetNbinsX());
903   RescalePtHistogram(gHistPtProtons,hPrimaryESDProtonsSurvived);  
904   gHistPtProtons->SetStats(kFALSE);
905   gHistPtProtons->SetMarkerStyle(20);
906   //SetError(gPtPrimaryESDProtonsSurvived,gPtPrimaryESDProtons);
907
908   //Antiprotons
909   TH1D *gHistPtAntiProtons = hPrimaryESDAntiProtonsSurvived->ProjectionY("gHistPtAntiProtons",1,hPrimaryESDAntiProtonsSurvived->GetNbinsX());
910   //gHistPtAntiProtons->Scale(1./hPrimaryESDAntiProtonsSurvived->GetNbinsX());
911   RescalePtHistogram(gHistPtAntiProtons,hPrimaryESDAntiProtonsSurvived);
912   gHistPtAntiProtons->SetStats(kFALSE);
913   gHistPtAntiProtons->SetMarkerStyle(20);
914   //SetError(gPtPrimaryESDAntiProtonsSurvived,gPtPrimaryESDAntiProtons);
915
916   TH2F *hEmptyPt = new TH2F("hEmptyEfficiencyPt","",
917                            100,0.0,4.0,100,-10.0,130); 
918   hEmptyPt->SetStats(kFALSE); 
919   hEmptyPt->GetYaxis()->SetTitle("#epsilon [%]");
920   hEmptyPt->GetYaxis()->SetTitleOffset(1.3);
921   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
922
923   TCanvas *c11 = new TCanvas("c11","(Anti)Proton cut efficiency vs pT",
924                              300,300,700,400);
925   c11->SetHighLightColor(10); c11->Divide(2,1);
926
927   c11->cd(1)->SetBottomMargin(0.15); 
928   c11->cd(1)->SetLeftMargin(0.15); 
929   c11->cd(1)->SetGridx(); c11->cd(1)->SetGridy();
930   hEmptyPt->SetTitle("Protons");
931   hEmptyPt->GetXaxis()->SetRangeUser(gHistPtProtons->GetXaxis()->GetXmin()-0.1,gHistPtProtons->GetXaxis()->GetXmax()+0.1);
932   hEmptyPt->DrawCopy();
933   gHistPtProtons->DrawCopy("ESAME");
934
935   c11->cd(2)->SetBottomMargin(0.15); 
936   c11->cd(2)->SetLeftMargin(0.15); 
937   c11->cd(2)->SetGridx(); c11->cd(2)->SetGridy();
938   hEmptyPt->SetTitle("Antirotons");
939   hEmptyPt->DrawCopy();
940   gHistPtAntiProtons->DrawCopy("ESAME");
941
942   c11->SaveAs("CutEfficiency-Protons-Pt.gif");
943
944   TString outputFileName = "CutEfficiency.";
945   outputFileName += analysisType; outputFileName += ".root";
946   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
947   gHistEtaProtons->Write();
948   gHistEtaAntiProtons->Write();
949   gHistPtProtons->Write();
950   gHistPtAntiProtons->Write();
951   fout->Close();
952 }
953
954 //________________________________________________//
955 void GetQAEntries(TList *inputList, Double_t *entries) {
956   //loops over the list entries
957   //extracts the entries for each histogram
958   //cout<<"Extracting the entries for the histograms in the list: "<<
959   //inputList->GetName()<<"..."<<endl;
960
961   for(Int_t i = 0; i < inputList->GetEntries(); i++) {
962     TH1F *gHist = (TH1F *)inputList->At(i);
963     entries[i] = gHist->GetEntries();
964     cout<<"Position: "<<i+1<<" - Histogram: "<<gHist->GetName()<<
965       " - Entries: "<<entries[i]<<endl;
966     gHist = 0;
967   }
968 }
969
970 //________________________________________________//
971 Double_t GetPercentage(Double_t nPassEntries,
972                        Double_t nRejectEntries) {
973   //returns the percentage of tracks that were rejected by a cut
974   Int_t nTotalEntries = nPassEntries + nRejectEntries;
975
976   if(nTotalEntries == 0)
977     return -1;
978
979   return 100.*nRejectEntries/nTotalEntries;
980 }
981
982 //________________________________________//
983 void drawMCQA(TList *listPDG, TList *listMCProcesses) {
984   //Function to display the composition of secondary (anti)protons
985   //The histogram shows the percentage of secondary (anti)protons
986   //originating from each particle species.
987   //The box summarizes the MC process that gave these secondary (anti)protons
988   TDatabasePDG *db = TDatabasePDG::Instance();
989   TParticlePDG *p = 0x0;
990   
991   TH3F *gHistYPtPDGProtons = (TH3F *)listPDG->At(0);
992   TH3F *gHistYPtPDGAntiProtons = (TH3F *)listPDG->At(1);
993   readProcesses(listMCProcesses);
994   Double_t nParticleCompositionProtonY[200], nParticleCompositionProtonPt[200];
995   Double_t nParticleCompositionProtonYError[200], nParticleCompositionProtonPtError[200];
996   Double_t nParticleCompositionAntiProtonY[200], nParticleCompositionAntiProtonPt[200];
997   Double_t nParticleCompositionAntiProtonYError[200], nParticleCompositionAntiProtonPtError[200];
998   Double_t gY[200], gPt[200];
999   Double_t gYError[200], gPtError[200];
1000   for(Int_t iBins = 0; iBins < 200; iBins++) {
1001     nParticleCompositionProtonY[iBins] = 0;
1002     nParticleCompositionProtonPt[iBins] = 0;
1003     nParticleCompositionProtonYError[iBins] = 0;
1004     nParticleCompositionProtonPtError[iBins] = 0;
1005     nParticleCompositionAntiProtonY[iBins] = 0;
1006     nParticleCompositionAntiProtonPt[iBins] = 0;
1007     nParticleCompositionAntiProtonYError[iBins] = 0;
1008     nParticleCompositionAntiProtonPtError[iBins] = 0;
1009     gY[iBins] = 0;
1010     gPt[iBins] = 0;
1011     gYError[iBins] = 0;
1012     gPtError[iBins] = 0;
1013   }
1014   
1015   TGraphErrors *gParticleProtonY[14];
1016   TGraphErrors *gParticleProtonPt[14];
1017   TGraphErrors *gParticleAntiProtonY[14];
1018   TGraphErrors *gParticleAntiProtonPt[14];
1019   for(Int_t iParticle = 0; iParticle < 14; iParticle++) {
1020     GetComposition(iParticle,
1021                    gHistYPtPDGProtons,
1022                    nParticleCompositionProtonY,
1023                    nParticleCompositionProtonYError, gY, gYError, 
1024                    nParticleCompositionProtonPt, 
1025                    nParticleCompositionProtonPtError, gPt, gPtError);
1026     gParticleProtonY[iParticle] = new TGraphErrors(gHistYPtPDGProtons->GetNbinsX(),
1027                                                    gY,nParticleCompositionProtonY,
1028                                                    gYError,nParticleCompositionProtonYError);
1029     gParticleProtonY[iParticle]->SetMarkerStyle(iParticle+20);
1030     gParticleProtonY[iParticle]->SetMarkerSize(1.2);
1031
1032     gParticleProtonPt[iParticle] = new TGraphErrors(gHistYPtPDGProtons->GetNbinsY(),
1033                                                     gPt,nParticleCompositionProtonPt,
1034                                                     gPtError,nParticleCompositionProtonPtError);
1035     gParticleProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
1036     gParticleProtonPt[iParticle]->SetMarkerSize(1.2);
1037
1038     GetComposition(iParticle,
1039                    gHistYPtPDGAntiProtons,
1040                    nParticleCompositionAntiProtonY,
1041                    nParticleCompositionAntiProtonYError, gY, gYError, 
1042                    nParticleCompositionAntiProtonPt, 
1043                    nParticleCompositionAntiProtonPtError, gPt, gPtError);
1044     gParticleAntiProtonY[iParticle] = new TGraphErrors(gHistYPtPDGAntiProtons->GetNbinsX(),
1045                                                        gY,nParticleCompositionAntiProtonY,
1046                                                        gYError,nParticleCompositionAntiProtonYError);
1047     gParticleAntiProtonY[iParticle]->SetMarkerStyle(iParticle+20);
1048     gParticleAntiProtonY[iParticle]->SetMarkerSize(1.2);
1049
1050     gParticleAntiProtonPt[iParticle] = new TGraphErrors(gHistYPtPDGAntiProtons->GetNbinsY(),
1051                                                         gPt,nParticleCompositionAntiProtonPt,
1052                                                         gPtError,nParticleCompositionAntiProtonPtError);
1053     gParticleAntiProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
1054     gParticleAntiProtonPt[iParticle]->SetMarkerSize(1.2);
1055   }
1056
1057   //_________________________________________________________//
1058   char *fParticleName[14] = {"Primary","K_{L}","#pi","K_{S}","K",
1059                              "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
1060                              "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
1061   TLatex *t1 = new TLatex();
1062   t1->SetTextSize(0.04);
1063
1064   TH2F *hEmptyY = new TH2F("hEmptyY","",100,-1.2,1.2,100,0,120); 
1065   hEmptyY->SetStats(kFALSE); 
1066   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
1067   hEmptyY->GetXaxis()->SetTitle(gHistYPtPDGProtons->GetXaxis()->GetTitle());
1068
1069   TCanvas *c3 = new TCanvas("c3","MC secondary composition vs y - Protons",
1070                             450,450,700,400);
1071   c3->SetHighLightColor(10); c3->SetBottomMargin(0.15);
1072   c3->SetGridx(); c3->SetGridy();
1073   hEmptyY->GetXaxis()->SetRangeUser(gParticleProtonY[0]->GetXaxis()->GetXmin()-0.2,gParticleProtonY[0]->GetXaxis()->GetXmax()+0.2);
1074   hEmptyY->DrawCopy();
1075   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1076     //if((iParticle == 0)||(iParticle == 2)||(iParticle == 5)||(iParticle == 6)||(iParticle == 8))
1077     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
1078       gParticleProtonY[iParticle]->Draw("P");
1079     /*if(iParticle < 5) {
1080       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
1081       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
1082     }
1083     else {
1084       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1085       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
1086       }*/
1087   }
1088   DrawMarker(0.0, 115, 20, 1.2, 1);
1089   t1->DrawLatex(0.1,113,fParticleName[0]);
1090   DrawMarker(0.0, 108, 22, 1.2, 1);
1091   t1->DrawLatex(0.1,106,fParticleName[2]);
1092   DrawMarker(0.0, 101, 26, 1.2, 1);
1093   t1->DrawLatex(0.1,99,fParticleName[6]);
1094   DrawMarker(0.0, 94, 28, 1.2, 1);
1095   t1->DrawLatex(0.1,92,fParticleName[8]);
1096
1097   TCanvas *c5 = new TCanvas("c5","MC secondary composition vs y - antiProtons",
1098                             500,500,700,400);
1099   c5->SetHighLightColor(10); c5->SetBottomMargin(0.15);
1100   c5->SetGridx(); c5->SetGridy();
1101   hEmptyY->DrawCopy();
1102   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1103     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
1104       gParticleAntiProtonY[iParticle]->Draw("P");
1105     /*if(iParticle < 5) {
1106       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
1107       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
1108     }
1109     else {
1110       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1111       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
1112       }*/
1113   }
1114   DrawMarker(0.0, 115, 20, 1.2, 1);
1115   t1->DrawLatex(0.1,113,fParticleName[0]);
1116   DrawMarker(0.0, 108, 26, 1.2, 1);
1117   t1->DrawLatex(0.1,106,fParticleName[6]);
1118   DrawMarker(0.0, 101, 28, 1.2, 1);
1119   t1->DrawLatex(0.1,99,fParticleName[8]);
1120
1121   TH2F *hEmptyPt = new TH2F("hEmptyPt","",100,0.0,4.0,100,0,120); 
1122   hEmptyPt->SetStats(kFALSE); 
1123   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
1124   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1125
1126   TCanvas *c4 = new TCanvas("c4","MC secondary composition vs pT - Protons",
1127                             550,550,700,400);
1128   c4->SetHighLightColor(10); c4->SetBottomMargin(0.15);
1129   c4->SetGridx(); c4->SetGridy();
1130   hEmptyPt->GetXaxis()->SetRangeUser(gParticleProtonPt[0]->GetXaxis()->GetXmin()-0.2,gParticleProtonPt[0]->GetXaxis()->GetXmax()+0.2);
1131   hEmptyPt->DrawCopy();
1132   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1133     /*if(iParticle < 5) {
1134       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
1135       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
1136     }
1137     else {
1138       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1139       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
1140       }*/
1141     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
1142       gParticleProtonPt[iParticle]->Draw("P");
1143   }
1144   DrawMarker(0.5, 115, 20, 1.2, 1);
1145   t1->DrawLatex(0.6,113,fParticleName[0]);
1146   DrawMarker(0.5, 108, 22, 1.2, 1);
1147   t1->DrawLatex(0.6,106,fParticleName[2]);
1148   DrawMarker(0.5, 101, 26, 1.2, 1);
1149   t1->DrawLatex(0.6,99,fParticleName[6]);
1150   DrawMarker(0.5, 94, 28, 1.2, 1);
1151   t1->DrawLatex(0.6,92,fParticleName[8]);
1152
1153   TCanvas *c6 = new TCanvas("c6",
1154                             "MC secondary composition vs pT - AntiProtons",
1155                             600,600,700,400);
1156   c6->SetHighLightColor(10); c6->SetBottomMargin(0.15);
1157   c6->SetGridx(); c6->SetGridy();
1158   hEmptyPt->DrawCopy();
1159   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1160     /*if(iParticle < 5) {
1161       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
1162       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
1163     }
1164     else {
1165       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1166       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
1167       }*/
1168     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
1169       gParticleAntiProtonPt[iParticle]->Draw("P");
1170   }
1171   DrawMarker(0.5, 115, 20, 1.2, 1);
1172   t1->DrawLatex(0.6,113,fParticleName[0]);
1173   DrawMarker(0.5, 108, 26, 1.2, 1);
1174   t1->DrawLatex(0.6,106,fParticleName[6]);
1175   DrawMarker(0.5, 101, 28, 1.2, 1);
1176   t1->DrawLatex(0.6,99,fParticleName[8]);
1177 }
1178
1179 //________________________________________//
1180 void GetComposition(Int_t iSpecies,
1181                     TH3F *gHist, 
1182                     Double_t *nParticleCompositionY,
1183                     Double_t *nParticleCompositionYError,
1184                     Double_t *gY, Double_t *gYError,
1185                     Double_t *nParticleCompositionPt,
1186                     Double_t *nParticleCompositionPtError,
1187                     Double_t *gPt, Double_t *gPtError) {
1188   //Returns the pT and y dependence of the MC composition
1189   Double_t ymin = gHist->GetXaxis()->GetXmin();
1190   Double_t ymax = gHist->GetXaxis()->GetXmax();
1191   Double_t nybins = gHist->GetNbinsX();
1192   Double_t ptmin = gHist->GetYaxis()->GetXmin();
1193   Double_t ptmax = gHist->GetYaxis()->GetXmax();
1194   Double_t nptbins = gHist->GetNbinsY();
1195   Double_t nTotalY[200], nTotalPt[200];
1196   for(Int_t iBins = 0; iBins < 200; iBins++) {
1197     nParticleCompositionY[iBins] = 0;
1198     nParticleCompositionPt[iBins] = 0;
1199     nParticleCompositionYError[iBins] = 0;
1200     nParticleCompositionPtError[iBins] = 0;
1201     nTotalY[iBins] = 0.0;
1202     nTotalPt[iBins] = 0.0;
1203   }
1204
1205   //rapidity dependence
1206   //cout<<"Ymin: "<<ymin<<" - Ymax: "<<ymax<<" - Ybins: "<<nybins<<endl;
1207   for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1208     for(Int_t iZbins = 1; iZbins <= gHist->GetNbinsZ(); iZbins++) {
1209       for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1210         nTotalY[iXbins-1] += gHist->GetBinContent(iXbins,iYbins,iZbins);
1211       }
1212     }
1213   }
1214
1215   for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1216     for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1217       if(nTotalY[iXbins-1] > 0)
1218         nParticleCompositionY[iXbins-1] += 100.*gHist->GetBinContent(iXbins,iYbins,iSpecies+1)/nTotalY[iXbins-1];
1219       //nCompositionY[iXbins-1] += gHist->GetBinContent(iXbins,iYbins,iSpecies+1);
1220       //if(nParticleCompositionY[iXbins-1] == 0) 
1221       //nParticleCompositionY[iXbins-1] = -10.0;
1222     }//pt loop
1223     if((nParticleCompositionY[iXbins-1] <= 100.)&&(nTotalY[iXbins-1] != 0))
1224       nParticleCompositionYError[iXbins-1] = TMath::Sqrt(nParticleCompositionY[iXbins-1]*(100. - nParticleCompositionY[iXbins-1])/nTotalY[iXbins-1]);
1225     gY[iXbins-1] = ymin + (iXbins-1)*(ymax - ymin)/nybins + 0.5*(ymax - ymin)/nybins;
1226     gYError[iXbins-1] = 0.5*(ymax - ymin)/nybins;
1227     //cout<<"y: "<<gY[iXbins-1]<<
1228     //" - test: "<<ymin + (iXbins-1)*(ymax - ymin)/nybins + 0.5*(ymax - ymin)/nybins<<
1229     //" - Number of protons: "<<nY[iXbins-1]<<
1230     //" - Total: "<<nTotalY[iXbins-1]<<
1231     //" - Percentage: "<<nParticleCompositionY[iXbins-1]<<endl;
1232   }//y loop
1233
1234   //pt dependence
1235   //cout<<"Ptmin: "<<ptmin<<" - Ptmax: "<<ptmax<<" - Ptbins: "<<nptbins<<endl;
1236   for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1237     for(Int_t iZbins = 1; iZbins <= gHist->GetNbinsZ(); iZbins++) {
1238       for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1239         nTotalPt[iYbins-1] += gHist->GetBinContent(iXbins,iYbins,iZbins);
1240       }
1241     }
1242   }
1243
1244   for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1245     for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1246       if(nTotalPt[iYbins-1] > 0)
1247         nParticleCompositionPt[iYbins-1] += 100.*gHist->GetBinContent(iXbins,iYbins,iSpecies+1)/nTotalPt[iYbins-1];
1248       //if(nParticleCompositionPt[iYbins-1] == 0) 
1249       //nParticleCompositionPt[iYbins-1] = -10.0;
1250     }//pt loop
1251     if((nParticleCompositionPt[iYbins-1] <= 100.)&&(nTotalPt[iYbins-1] != 0))
1252       nParticleCompositionPtError[iYbins-1] = TMath::Sqrt(nParticleCompositionPt[iYbins-1]*(100. - nParticleCompositionPt[iYbins-1])/nTotalPt[iYbins-1]);
1253     gPt[iYbins-1] = ptmin + (iYbins-1)*(ptmax - ptmin)/nptbins + 0.5*(ptmax - ptmin)/nptbins;
1254     gPtError[iYbins-1] = 0.5*(ptmax - ptmin)/nptbins;
1255     //cout<<"Pt: "<<gPt[iYbins-1]<<
1256     //" - test: "<<ptmin + (iYbins-1)*(ptmax - ptmin)/nptbins + 0.5*(ptmax - ptmin)/nptbins<<
1257     //" - Number of protons: "<<nY[iXbins-1]<<
1258     //" - Total: "<<nTotalPt[iYbins-1]<<
1259     //" - Percentage: "<<nParticleCompositionPt[iYbins-1]<<endl;
1260   }//pt loop
1261 }
1262
1263 //________________________________________//
1264 void readProcesses(TList *list) {
1265   char *fParticleProtonName[12] = {"K_{L}","#pi","K_{S}","K",
1266                                    "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
1267                                    "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
1268   char *fParticleAntiProtonName[8] = {"K_{L}","#pi","K_{S}","K",
1269                                       "n","p","#Lambda","#Sigma^{+}"};
1270   Int_t iProtonCounter = 0, iAntiProtonCounter = 0;
1271   TH1F *gMCProcesses;
1272   for(Int_t iEntry = 0; iEntry < list->GetEntries(); iEntry++) {
1273     gMCProcesses = (TH1F *)list->At(iEntry);
1274     TString histName = gMCProcesses->GetName();
1275     if(histName.Contains("gHistProtons")) {
1276       cout<<"Protons coming from "<<fParticleProtonName[iProtonCounter]<<endl;
1277
1278       iProtonCounter += 1;
1279     }
1280     if(histName.Contains("gHistAntiProtons")) {
1281       cout<<"Antiprotons coming from "<<fParticleAntiProtonName[iAntiProtonCounter]<<endl;
1282
1283       iAntiProtonCounter += 1;
1284     }
1285     for(Int_t iBin = 1; iBin < gMCProcesses->GetNbinsX(); iBin++) {
1286       Double_t binContent = gMCProcesses->GetBinContent(iBin);
1287       if(binContent > 0) {
1288         Int_t processId = gMCProcesses->GetBinCenter(iBin);
1289         cout<<"\t Process ID: "<<processId<<" - "<<
1290           gMCProcessName[processId]<<" - "<<
1291           100.*binContent/gMCProcesses->GetEntries()<<"%"<<endl;
1292       }
1293     }
1294   }
1295 }
1296
1297 //________________________________________________//
1298 void SetError(TH1 *hEff, TH1 *hGen) {
1299   for(Int_t iBin = 1; iBin <= hEff->GetNbinsX(); iBin++) {
1300     Double_t error = 0.0;
1301     if((hEff->GetBinContent(iBin) <= 1  .)&&(hGen->GetBinContent(iBin) != 0))
1302       error = TMath::Sqrt(hEff->GetBinContent(iBin)*(1  . - hEff->GetBinContent(iBin))/hGen->GetBinContent(iBin));
1303     hEff->SetBinError(iBin,error);
1304   }
1305 }
1306
1307 //________________________________________//
1308 void drawVertexQA(TList *list) {
1309   //Function to display the vertex QA plots
1310   TH1I *gHistMCPrimaryMultiplicity = (TH1I *)list->At(0);
1311   //TPC
1312   TH1I *gHistMCPrimaryMultiplicityTPC = (TH1I *)list->At(1);
1313   TH2F *gHistTPCESDVx = (TH2F *)list->At(2);
1314   TH2F *gHistTPCESDVy = (TH2F *)list->At(3);
1315   TH2F *gHistTPCESDVz = (TH2F *)list->At(4);
1316   TH1F *gHistTPCDiffVx = (TH1F *)list->At(5);
1317   TH1F *gHistTPCDiffVy = (TH1F *)list->At(6);
1318   TH1F *gHistTPCDiffVz = (TH1F *)list->At(7);
1319   TH1F *gHistTPCResolutionVx = (TH1F *)list->At(8);
1320   TH1F *gHistTPCResolutionVy = (TH1F *)list->At(9);
1321   TH1F *gHistTPCResolutionVz = (TH1F *)list->At(10);
1322   //SPD
1323   TH1I *gHistMCPrimaryMultiplicitySPD = (TH1I *)list->At(11);
1324   TH2F *gHistSPDESDVx = (TH2F *)list->At(12);
1325   TH2F *gHistSPDESDVy = (TH2F *)list->At(13);
1326   TH2F *gHistSPDESDVz = (TH2F *)list->At(14);
1327   TH1F *gHistSPDDiffVx = (TH1F *)list->At(15);
1328   TH1F *gHistSPDDiffVy = (TH1F *)list->At(16);
1329   TH1F *gHistSPDDiffVz = (TH1F *)list->At(17);
1330   TH1F *gHistSPDResolutionVx = (TH1F *)list->At(18);
1331   TH1F *gHistSPDResolutionVy = (TH1F *)list->At(19);
1332   TH1F *gHistSPDResolutionVz = (TH1F *)list->At(20);
1333   //Tracks
1334   TH1I *gHistMCPrimaryMultiplicityTracks = (TH1I *)list->At(21);
1335   TH2F *gHistTracksESDVx = (TH2F *)list->At(22);
1336   TH2F *gHistTracksESDVy = (TH2F *)list->At(23);
1337   TH2F *gHistTracksESDVz = (TH2F *)list->At(24);
1338   TH1F *gHistTracksDiffVx = (TH1F *)list->At(25);
1339   TH1F *gHistTracksDiffVy = (TH1F *)list->At(26);
1340   TH1F *gHistTracksDiffVz = (TH1F *)list->At(27);
1341   TH1F *gHistTracksResolutionVx = (TH1F *)list->At(28);
1342   TH1F *gHistTracksResolutionVy = (TH1F *)list->At(29);
1343   TH1F *gHistTracksResolutionVz = (TH1F *)list->At(30);
1344
1345   TCanvas *c17 = new TCanvas("c17",
1346                              "Vertex efficiency",
1347                              300,0,900,400);
1348   c17->SetHighLightColor(10); c17->Divide(3,1);
1349   c17->cd(1)->SetLeftMargin(0.15); c17->cd(1)->SetBottomMargin(0.15);  
1350   c17->cd(1)->SetRightMargin(0.2);
1351   c17->cd(1)->SetGridx(); c17->cd(1)->SetGridy();
1352   gHistMCPrimaryMultiplicityTPC->SetTitle("TPC vertex");
1353   gHistMCPrimaryMultiplicityTPC->Divide(gHistMCPrimaryMultiplicity);
1354   SetError(gHistMCPrimaryMultiplicityTPC,gHistMCPrimaryMultiplicity);
1355   gHistMCPrimaryMultiplicityTPC->SetMaximum(110.);
1356   gHistMCPrimaryMultiplicityTPC->Scale(100.);
1357   gHistMCPrimaryMultiplicityTPC->SetMarkerStyle(20);
1358   gHistMCPrimaryMultiplicityTPC->SetMarkerColor(1);
1359   gHistMCPrimaryMultiplicityTPC->GetYaxis()->SetTitle("#epsilon [%]");
1360   gHistMCPrimaryMultiplicityTPC->SetStats(kFALSE);
1361   gHistMCPrimaryMultiplicityTPC->Draw("E");
1362   c17->cd(2)->SetLeftMargin(0.15); c17->cd(2)->SetBottomMargin(0.15);  
1363   c17->cd(2)->SetRightMargin(0.2);
1364   c17->cd(2)->SetGridx(); c17->cd(2)->SetGridy();
1365   gHistMCPrimaryMultiplicitySPD->SetTitle("SPD vertex");
1366   gHistMCPrimaryMultiplicitySPD->Divide(gHistMCPrimaryMultiplicity);
1367   SetError(gHistMCPrimaryMultiplicitySPD,gHistMCPrimaryMultiplicity);
1368   gHistMCPrimaryMultiplicitySPD->SetMaximum(110.);
1369   gHistMCPrimaryMultiplicitySPD->Scale(100.);
1370   gHistMCPrimaryMultiplicitySPD->SetMarkerStyle(20);
1371   gHistMCPrimaryMultiplicitySPD->SetMarkerColor(1);
1372   gHistMCPrimaryMultiplicitySPD->GetYaxis()->SetTitle("#epsilon [%]");
1373   gHistMCPrimaryMultiplicitySPD->SetStats(kFALSE);
1374   gHistMCPrimaryMultiplicitySPD->Draw("E");
1375   c17->cd(3)->SetLeftMargin(0.15); c17->cd(3)->SetBottomMargin(0.15);  
1376   c17->cd(3)->SetRightMargin(0.2);
1377   c17->cd(3)->SetGridx(); c17->cd(3)->SetGridy();
1378   gHistMCPrimaryMultiplicityTracks->SetTitle("Vertex from tracks");
1379   gHistMCPrimaryMultiplicityTracks->Divide(gHistMCPrimaryMultiplicity);
1380   SetError(gHistMCPrimaryMultiplicityTracks,gHistMCPrimaryMultiplicity);
1381   gHistMCPrimaryMultiplicityTracks->SetMaximum(110.);
1382   gHistMCPrimaryMultiplicityTracks->Scale(100.);
1383   gHistMCPrimaryMultiplicityTracks->SetMarkerStyle(20);
1384   gHistMCPrimaryMultiplicityTracks->SetMarkerColor(1);
1385   gHistMCPrimaryMultiplicityTracks->GetYaxis()->SetTitle("#epsilon [%]");
1386   gHistMCPrimaryMultiplicityTracks->SetStats(kFALSE);
1387   gHistMCPrimaryMultiplicityTracks->Draw("E");
1388   c17->SaveAs("VertexEfficiency.gif");
1389
1390   //TPC vertex
1391   TCanvas *c18 = new TCanvas("c18",
1392                              "TPC vertex",
1393                              350,50,700,700);
1394   c18->SetHighLightColor(10); c18->Divide(3,3);
1395   c18->cd(1)->SetLeftMargin(0.15); c18->cd(1)->SetBottomMargin(0.15);  
1396   c18->cd(1)->SetRightMargin(0.2); c18->cd(1)->SetLogy();
1397   gHistTPCESDVx->Draw("col");
1398   c18->cd(2)->SetLeftMargin(0.15); c18->cd(2)->SetBottomMargin(0.15);  
1399   c18->cd(2)->SetRightMargin(0.2); c18->cd(2)->SetLogy();
1400   gHistTPCESDVy->Draw("col");
1401   c18->cd(3)->SetLeftMargin(0.15); c18->cd(3)->SetBottomMargin(0.15);  
1402   c18->cd(3)->SetRightMargin(0.2); c18->cd(3)->SetLogy();
1403   gHistTPCESDVz->Draw("col");
1404   c18->cd(4)->SetLeftMargin(0.15); c18->cd(4)->SetBottomMargin(0.15);  
1405   c18->cd(4)->SetRightMargin(0.2); c18->cd(4)->SetLogy();
1406   gHistTPCDiffVx->Draw();
1407   c18->cd(5)->SetLeftMargin(0.15); c18->cd(5)->SetBottomMargin(0.15);  
1408   c18->cd(5)->SetRightMargin(0.2); c18->cd(5)->SetLogy();
1409   gHistTPCDiffVy->Draw();
1410   c18->cd(6)->SetLeftMargin(0.15); c18->cd(6)->SetBottomMargin(0.15);  
1411   c18->cd(6)->SetRightMargin(0.2); c18->cd(6)->SetLogy();
1412   gHistTPCDiffVz->Draw();
1413   c18->cd(7)->SetLeftMargin(0.15); c18->cd(7)->SetBottomMargin(0.15);  
1414   c18->cd(7)->SetRightMargin(0.2); c18->cd(7)->SetLogy();
1415   gHistTPCResolutionVx->Draw();
1416   c18->cd(8)->SetLeftMargin(0.15); c18->cd(8)->SetBottomMargin(0.15);  
1417   c18->cd(8)->SetRightMargin(0.2); c18->cd(8)->SetLogy();
1418   gHistTPCResolutionVy->Draw();
1419   c18->cd(9)->SetLeftMargin(0.15); c18->cd(9)->SetBottomMargin(0.15);  
1420   c18->cd(9)->SetRightMargin(0.2); c18->cd(9)->SetLogy();
1421   gHistTPCResolutionVz->Draw();
1422   c18->SaveAs("VertexTPC.gif");
1423
1424   //SPD vertex
1425   TCanvas *c19 = new TCanvas("c19",
1426                              "SPD vertex",
1427                              400,100,700,700);
1428   c19->SetHighLightColor(10); c19->Divide(3,3);
1429   c19->cd(1)->SetLeftMargin(0.15); c19->cd(1)->SetBottomMargin(0.15);  
1430   c19->cd(1)->SetRightMargin(0.2); c19->cd(1)->SetLogy();
1431   gHistSPDESDVx->Draw("col");
1432   c19->cd(2)->SetLeftMargin(0.15); c19->cd(2)->SetBottomMargin(0.15);  
1433   c19->cd(2)->SetRightMargin(0.2); c19->cd(2)->SetLogy();
1434   gHistSPDESDVy->Draw("col");
1435   c19->cd(3)->SetLeftMargin(0.15); c19->cd(3)->SetBottomMargin(0.15);  
1436   c19->cd(3)->SetRightMargin(0.2); c19->cd(3)->SetLogy();
1437   gHistSPDESDVz->Draw("col");
1438   c19->cd(4)->SetLeftMargin(0.15); c19->cd(4)->SetBottomMargin(0.15);  
1439   c19->cd(4)->SetRightMargin(0.2); c19->cd(4)->SetLogy();
1440   gHistSPDDiffVx->Draw();
1441   c19->cd(5)->SetLeftMargin(0.15); c19->cd(5)->SetBottomMargin(0.15);  
1442   c19->cd(5)->SetRightMargin(0.2); c19->cd(5)->SetLogy();
1443   gHistSPDDiffVy->Draw();
1444   c19->cd(6)->SetLeftMargin(0.15); c19->cd(6)->SetBottomMargin(0.15);  
1445   c19->cd(6)->SetRightMargin(0.2); c19->cd(6)->SetLogy();
1446   gHistSPDDiffVz->Draw();
1447   c19->cd(7)->SetLeftMargin(0.15); c19->cd(7)->SetBottomMargin(0.15);  
1448   c19->cd(7)->SetRightMargin(0.2); c19->cd(7)->SetLogy();
1449   gHistSPDResolutionVx->Draw();
1450   c19->cd(8)->SetLeftMargin(0.15); c19->cd(8)->SetBottomMargin(0.15);  
1451   c19->cd(8)->SetRightMargin(0.2); c19->cd(8)->SetLogy();
1452   gHistSPDResolutionVy->Draw();
1453   c19->cd(9)->SetLeftMargin(0.15); c19->cd(9)->SetBottomMargin(0.15);  
1454   c19->cd(9)->SetRightMargin(0.2); c19->cd(9)->SetLogy();
1455   gHistSPDResolutionVz->Draw();
1456   c19->SaveAs("VertexSPD.gif");
1457
1458   //Tracks vertex
1459   TCanvas *c20 = new TCanvas("c20",
1460                              "Tracks vertex",
1461                              450,150,700,700);
1462   c20->SetHighLightColor(10); c20->Divide(3,3);
1463   c20->cd(1)->SetLeftMargin(0.15); c20->cd(1)->SetBottomMargin(0.15);  
1464   c20->cd(1)->SetRightMargin(0.2); c20->cd(1)->SetLogy();
1465   gHistTracksESDVx->Draw("col");
1466   c20->cd(2)->SetLeftMargin(0.15); c20->cd(2)->SetBottomMargin(0.15);  
1467   c20->cd(2)->SetRightMargin(0.2); c20->cd(2)->SetLogy();
1468   gHistTracksESDVy->Draw("col");
1469   c20->cd(3)->SetLeftMargin(0.15); c20->cd(3)->SetBottomMargin(0.15);  
1470   c20->cd(3)->SetRightMargin(0.2); c20->cd(3)->SetLogy();
1471   gHistTracksESDVz->Draw("col");
1472   c20->cd(4)->SetLeftMargin(0.15); c20->cd(4)->SetBottomMargin(0.15);  
1473   c20->cd(4)->SetRightMargin(0.2); c20->cd(4)->SetLogy();
1474   gHistTracksDiffVx->Draw();
1475   c20->cd(5)->SetLeftMargin(0.15); c20->cd(5)->SetBottomMargin(0.15);  
1476   c20->cd(5)->SetRightMargin(0.2); c20->cd(5)->SetLogy();
1477   gHistTracksDiffVy->Draw();
1478   c20->cd(6)->SetLeftMargin(0.15); c20->cd(6)->SetBottomMargin(0.15);  
1479   c20->cd(6)->SetRightMargin(0.2); c20->cd(6)->SetLogy();
1480   gHistTracksDiffVz->Draw();
1481   c20->cd(7)->SetLeftMargin(0.15); c20->cd(7)->SetBottomMargin(0.15);  
1482   c20->cd(7)->SetRightMargin(0.2); c20->cd(7)->SetLogy();
1483   gHistTracksResolutionVx->Draw();
1484   c20->cd(8)->SetLeftMargin(0.15); c20->cd(8)->SetBottomMargin(0.15);  
1485   c20->cd(8)->SetRightMargin(0.2); c20->cd(8)->SetLogy();
1486   gHistTracksResolutionVy->Draw();
1487   c20->cd(9)->SetLeftMargin(0.15); c20->cd(9)->SetBottomMargin(0.15);  
1488   c20->cd(9)->SetRightMargin(0.2); c20->cd(9)->SetLogy();
1489   gHistTracksResolutionVz->Draw();
1490   c20->SaveAs("VertexTracks.gif");
1491 }
1492
1493 //________________________________________//
1494 void drawEfficiency(TList *list,
1495                     const char* analysisType) {
1496   //Function to display the reconstruction and PID efficiencies
1497   //for protons and antiprotons vs y and pT
1498
1499   TH2F *hEmpty = new TH2F("hEmptyReconstructionEfficiency","",
1500                            1000,-1.2,210.,100,-10.0,130); 
1501   hEmpty->SetStats(kFALSE); 
1502   hEmpty->GetYaxis()->SetTitle("#epsilon [%]");
1503   hEmpty->GetYaxis()->SetTitleOffset(1.3);
1504
1505   //Reconstruction efficiency
1506   TH2D *gHistPrimariesMCYPtProtons = (TH2D *)list->At(0);
1507   TH2D *gHistPrimariesMCYPtAntiProtons = (TH2D *)list->At(1);
1508   TH2D *gHistMCYPtProtonsFromWeak = (TH2D *)list->At(2);
1509   TH2D *gHistMCYPtAntiProtonsFromWeak = (TH2D *)list->At(3);
1510   TH2D *gHistMCYPtProtonsFromHadronic = (TH2D *)list->At(4);
1511   TH2D *gHistMCYPtAntiProtonsFromHadronic = (TH2D *)list->At(5);
1512   TH2D *gHistPrimariesESDYPtProtons = (TH2D *)list->At(6);
1513   TH2D *gHistPrimariesESDYPtAntiProtons = (TH2D *)list->At(7);
1514   TH2D *gHistESDYPtProtonsFromWeak = (TH2D *)list->At(8);
1515   TH2D *gHistESDYPtAntiProtonsFromWeak = (TH2D *)list->At(9);
1516   TH2D *gHistESDYPtProtonsFromHadronic = (TH2D *)list->At(10);
1517   TH2D *gHistESDYPtAntiProtonsFromHadronic = (TH2D *)list->At(11);
1518
1519   //rapidity dependence
1520   TCanvas *c14 = new TCanvas("c14",
1521                              "(Anti)Proton reconstruction efficiency vs y",
1522                              650,650,700,400);
1523   c14->SetHighLightColor(10); c14->Divide(2,1);
1524
1525   //Primary Protons
1526   TH1D *gYPrimariesESDProtons = (TH1D *)gHistPrimariesESDYPtProtons->ProjectionX("gYPrimariesESDProtons",0,gHistPrimariesESDYPtProtons->GetXaxis()->GetNbins(),"e");
1527   TH1D *gYPrimariesMCProtons = (TH1D *)gHistPrimariesMCYPtProtons->ProjectionX("gYPrimariesMCProtons",0,gHistPrimariesMCYPtProtons->GetXaxis()->GetNbins(),"e");
1528   gYPrimariesESDProtons->Divide(gYPrimariesMCProtons);
1529   SetError(gYPrimariesESDProtons,gYPrimariesMCProtons);
1530   gYPrimariesESDProtons->Scale(100.);
1531   gYPrimariesESDProtons->SetMarkerStyle(kFullCircle);
1532
1533   //Primary AntiProtons
1534   TH1D *gYPrimariesESDAntiProtons = (TH1D *)gHistPrimariesESDYPtAntiProtons->ProjectionX("gYPrimariesESDAntiProtons",0,gHistPrimariesESDYPtAntiProtons->GetXaxis()->GetNbins(),"e");
1535   TH1D *gYPrimariesMCAntiProtons = (TH1D *)gHistPrimariesMCYPtAntiProtons->ProjectionX("gYPrimariesMCAntiProtons",0,gHistPrimariesMCYPtProtons->GetXaxis()->GetNbins(),"e");
1536   gYPrimariesESDAntiProtons->Divide(gYPrimariesMCAntiProtons);
1537   SetError(gYPrimariesESDAntiProtons,gYPrimariesMCAntiProtons);
1538   gYPrimariesESDAntiProtons->Scale(100.);
1539   gYPrimariesESDAntiProtons->SetMarkerStyle(kFullCircle);
1540
1541   //Protons from weak decays
1542   TH1D *gYESDProtonsFromWeak = (TH1D *)gHistESDYPtProtonsFromWeak->ProjectionX("gYESDProtonsFromWeak",0,gHistESDYPtProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1543   TH1D *gYMCProtonsFromWeak = (TH1D *)gHistMCYPtProtonsFromWeak->ProjectionX("gYMCProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1544   gYESDProtonsFromWeak->Divide(gYMCProtonsFromWeak);
1545   SetError(gYESDProtonsFromWeak,gYMCProtonsFromWeak);
1546   gYESDProtonsFromWeak->Scale(100.);
1547   gYESDProtonsFromWeak->SetMarkerStyle(21);
1548   gYESDProtonsFromWeak->SetMarkerColor(2);
1549
1550   //AntiProtons from weak decays
1551   TH1D *gYESDAntiProtonsFromWeak = (TH1D *)gHistESDYPtAntiProtonsFromWeak->ProjectionX("gYESDAntiProtonsFromWeak",0,gHistESDYPtAntiProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1552   TH1D *gYMCAntiProtonsFromWeak = (TH1D *)gHistMCYPtAntiProtonsFromWeak->ProjectionX("gYMCAntiProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1553   gYESDAntiProtonsFromWeak->Divide(gYMCAntiProtonsFromWeak);
1554   SetError(gYESDAntiProtonsFromWeak,gYMCAntiProtonsFromWeak);
1555   gYESDAntiProtonsFromWeak->Scale(100.);
1556   gYESDAntiProtonsFromWeak->SetMarkerStyle(21);
1557   gYESDAntiProtonsFromWeak->SetMarkerColor(2);
1558
1559   //Protons from hadronic interactions
1560   TH1D *gYESDProtonsFromHadronic = (TH1D *)gHistESDYPtProtonsFromHadronic->ProjectionX("gYESDProtonsFromHadronic",0,gHistESDYPtProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1561   TH1D *gYMCProtonsFromHadronic = (TH1D *)gHistMCYPtProtonsFromHadronic->ProjectionX("gYMCProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1562   gYESDProtonsFromHadronic->Divide(gYMCProtonsFromHadronic);
1563   SetError(gYESDProtonsFromHadronic,gYMCProtonsFromHadronic);
1564   gYESDProtonsFromHadronic->Scale(100.);
1565   gYESDProtonsFromHadronic->SetMarkerStyle(22);
1566   gYESDProtonsFromHadronic->SetMarkerColor(3);
1567
1568   //AntiProtons from hadronic interactions
1569   TH1D *gYESDAntiProtonsFromHadronic = (TH1D *)gHistESDYPtAntiProtonsFromHadronic->ProjectionX("gYESDAntiProtonsFromHadronic",0,gHistESDYPtAntiProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1570   TH1D *gYMCAntiProtonsFromHadronic = (TH1D *)gHistMCYPtAntiProtonsFromHadronic->ProjectionX("gYMCAntiProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1571   gYESDAntiProtonsFromHadronic->Divide(gYMCAntiProtonsFromHadronic);
1572   SetError(gYESDAntiProtonsFromHadronic,gYMCAntiProtonsFromHadronic);
1573   gYESDAntiProtonsFromHadronic->Scale(100.);
1574   gYESDAntiProtonsFromHadronic->SetMarkerStyle(22);
1575   gYESDAntiProtonsFromHadronic->SetMarkerColor(3);
1576
1577   c14->cd(1)->SetBottomMargin(0.15); 
1578   c14->cd(1)->SetLeftMargin(0.15); 
1579   c14->cd(1)->SetGridx(); c14->cd(1)->SetGridy();
1580   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.2,
1581                                    gYPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.2);
1582   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDAntiProtons->GetXaxis()->GetTitle());
1583   hEmpty->SetTitle("Protons");
1584   hEmpty->DrawCopy();
1585   gYPrimariesESDProtons->DrawCopy("ESAME");
1586   gYESDProtonsFromWeak->DrawCopy("ESAME");
1587   gYESDProtonsFromHadronic->DrawCopy("ESAME");
1588
1589   c14->cd(2)->SetBottomMargin(0.15); 
1590   c14->cd(2)->SetLeftMargin(0.15); 
1591   c14->cd(2)->SetGridx(); c14->cd(2)->SetGridy();
1592   hEmpty->SetTitle("Antiprotons");
1593   hEmpty->DrawCopy();
1594   gYPrimariesESDAntiProtons->DrawCopy("ESAME");
1595   gYESDAntiProtonsFromWeak->DrawCopy("ESAME");
1596   gYESDAntiProtonsFromHadronic->DrawCopy("ESAME");
1597   c14->SaveAs("ReconstructionEfficiency-Protons-Rapidity.gif");
1598
1599   //pT dependence
1600   TCanvas *c15 = new TCanvas("c15",
1601                              "(Anti)Proton reconstruction efficiency vs pT",
1602                              700,700,700,400);
1603   c15->SetHighLightColor(10); c15->Divide(2,1);
1604
1605   //Primary Protons
1606   TH1D *gPtPrimariesESDProtons = (TH1D *)gHistPrimariesESDYPtProtons->ProjectionY("gPtPrimariesESDProtons",0,gHistPrimariesESDYPtProtons->GetYaxis()->GetNbins(),"e");
1607   TH1D *gPtPrimariesMCProtons = (TH1D *)gHistPrimariesMCYPtProtons->ProjectionY("gPtPrimariesMCProtons",0,gHistPrimariesMCYPtProtons->GetYaxis()->GetNbins(),"e");
1608   gPtPrimariesESDProtons->Divide(gPtPrimariesMCProtons);
1609   SetError(gPtPrimariesESDProtons,gPtPrimariesMCProtons);
1610   gPtPrimariesESDProtons->Scale(100.);
1611   gPtPrimariesESDProtons->SetMarkerStyle(kFullCircle);
1612
1613   //Primary AntiProtons
1614   TH1D *gPtPrimariesESDAntiProtons = (TH1D *)gHistPrimariesESDYPtAntiProtons->ProjectionY("gPtPrimariesESDAntiProtons",0,gHistPrimariesESDYPtAntiProtons->GetYaxis()->GetNbins(),"e");
1615   TH1D *gPtPrimariesMCAntiProtons = (TH1D *)gHistPrimariesMCYPtAntiProtons->ProjectionY("gPtPrimariesMCAntiProtons",0,gHistPrimariesMCYPtProtons->GetYaxis()->GetNbins(),"e");
1616   gPtPrimariesESDAntiProtons->Divide(gPtPrimariesMCAntiProtons);
1617   SetError(gPtPrimariesESDAntiProtons,gPtPrimariesMCAntiProtons);
1618   gPtPrimariesESDAntiProtons->Scale(100.);
1619   gPtPrimariesESDAntiProtons->SetMarkerStyle(kFullCircle);
1620
1621   //Protons from weak decays
1622   TH1D *gPtESDProtonsFromWeak = (TH1D *)gHistESDYPtProtonsFromWeak->ProjectionY("gPtESDProtonsFromWeak",0,gHistESDYPtProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1623   TH1D *gPtMCProtonsFromWeak = (TH1D *)gHistMCYPtProtonsFromWeak->ProjectionY("gPtMCProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1624   gPtESDProtonsFromWeak->Divide(gPtMCProtonsFromWeak);
1625   SetError(gPtESDProtonsFromWeak,gPtMCProtonsFromWeak);
1626   gPtESDProtonsFromWeak->Scale(100.);
1627   gPtESDProtonsFromWeak->SetMarkerStyle(21);
1628   gPtESDProtonsFromWeak->SetMarkerColor(2);
1629
1630   //AntiProtons from weak decays
1631   TH1D *gPtESDAntiProtonsFromWeak = (TH1D *)gHistESDYPtAntiProtonsFromWeak->ProjectionY("gPtESDAntiProtonsFromWeak",0,gHistESDYPtAntiProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1632   TH1D *gPtMCAntiProtonsFromWeak = (TH1D *)gHistMCYPtAntiProtonsFromWeak->ProjectionY("gPtMCAntiProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1633   gPtESDAntiProtonsFromWeak->Divide(gPtMCAntiProtonsFromWeak);
1634   SetError(gPtESDAntiProtonsFromWeak,gPtMCAntiProtonsFromWeak);
1635   gPtESDAntiProtonsFromWeak->Scale(100.);
1636   gPtESDAntiProtonsFromWeak->SetMarkerStyle(21);
1637   gPtESDAntiProtonsFromWeak->SetMarkerColor(2);
1638
1639   //Protons from hadronic interactions
1640   TH1D *gPtESDProtonsFromHadronic = (TH1D *)gHistESDYPtProtonsFromHadronic->ProjectionY("gPtESDProtonsFromHadronic",0,gHistESDYPtProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1641   TH1D *gPtMCProtonsFromHadronic = (TH1D *)gHistMCYPtProtonsFromHadronic->ProjectionY("gPtMCProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1642   gPtESDProtonsFromHadronic->Divide(gPtMCProtonsFromHadronic);
1643   SetError(gPtESDProtonsFromHadronic,gPtMCProtonsFromHadronic);
1644   gPtESDProtonsFromHadronic->Scale(100.);
1645   gPtESDProtonsFromHadronic->SetMarkerStyle(22);
1646   gPtESDProtonsFromHadronic->SetMarkerColor(3);
1647
1648   //AntiProtons from hadronic interactions
1649   TH1D *gPtESDAntiProtonsFromHadronic = (TH1D *)gHistESDYPtAntiProtonsFromHadronic->ProjectionY("gPtESDAntiProtonsFromHadronic",0,gHistESDYPtAntiProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1650   TH1D *gPtMCAntiProtonsFromHadronic = (TH1D *)gHistMCYPtAntiProtonsFromHadronic->ProjectionY("gPtMCAntiProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1651   gPtESDAntiProtonsFromHadronic->Divide(gPtMCAntiProtonsFromHadronic);
1652   SetError(gPtESDAntiProtonsFromHadronic,gPtMCAntiProtonsFromHadronic);
1653   gPtESDAntiProtonsFromHadronic->Scale(100.);
1654   gPtESDAntiProtonsFromHadronic->SetMarkerStyle(22);
1655   gPtESDAntiProtonsFromHadronic->SetMarkerColor(3);
1656
1657
1658   c15->cd(1)->SetBottomMargin(0.15); 
1659   c15->cd(1)->SetLeftMargin(0.15); 
1660   c15->cd(1)->SetGridx(); c15->cd(1)->SetGridy();
1661   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.2,
1662                                    gPtPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.2);
1663   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1664   hEmpty->SetTitle("Protons");
1665   hEmpty->DrawCopy();
1666   gPtPrimariesESDProtons->DrawCopy("ESAME");
1667   gPtESDProtonsFromWeak->DrawCopy("ESAME");
1668   gPtESDProtonsFromHadronic->DrawCopy("ESAME");
1669
1670   c15->cd(2)->SetBottomMargin(0.15); 
1671   c15->cd(2)->SetLeftMargin(0.15); 
1672   c15->cd(2)->SetGridx(); c15->cd(2)->SetGridy();
1673   hEmpty->SetTitle("Antiprotons");
1674   hEmpty->DrawCopy();
1675   gPtPrimariesESDAntiProtons->DrawCopy("ESAME");
1676   gPtESDAntiProtonsFromWeak->DrawCopy("ESAME");
1677   gPtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
1678   c15->SaveAs("ReconstructionEfficiency-Protons-Pt.gif");
1679
1680   //______________//
1681   //PID efficiency//
1682   //______________//
1683   TH3D *gHistESDInitYPtProtons = (TH3D *)list->At(12);
1684   TH3D *gHistESDIdYPtProtons = (TH3D *)list->At(13);
1685   TH3D *gHistESDRecIdYPtProtons = (TH3D *)list->At(14);
1686   TH3D *gHistESDContamYPtProtons = (TH3D *)list->At(15);
1687
1688   TCanvas *c16 = new TCanvas("c16",
1689                              "(Anti)Proton PID efficiency vs y and pT",
1690                              750,750,700,400);
1691   c16->SetHighLightColor(10); c16->Divide(3,1);
1692
1693   //rapidity dependence
1694   //protons pid efficiency
1695   //TH1D *gYESDIdProtons = (TH1D *)gHistESDIdYPtProtons->ProjectionX("gYESDIdProtons",0,gHistESDIdYPtProtons->GetXaxis()->GetNbins(),"e");
1696   //TH1D *gYESDInitProtons = (TH1D *)gHistESDInitYPtProtons->ProjectionX("gYESDInitProtons",0,gHistESDInitYPtProtons->GetXaxis()->GetNbins(),"e");
1697   TH1D *gYESDIdProtons = (TH1D *)gHistESDIdYPtProtons->Project3D("x");
1698   TH1D *gYESDInitProtons = (TH1D *)gHistESDInitYPtProtons->Project3D("x");
1699   gYESDIdProtons->Divide(gYESDInitProtons);
1700   SetError(gYESDIdProtons,gYESDInitProtons);
1701   gYESDIdProtons->Scale(100.);
1702   gYESDIdProtons->SetMarkerStyle(kFullCircle);
1703
1704   //protons pid contamination
1705   //TH1D *gYESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionX("gYESDContamProtons",0,gHistESDContamYPtProtons->GetXaxis()->GetNbins(),"e");
1706   //TH1D *gYESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionX("gYESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetXaxis()->GetNbins(),"e");
1707   TH1D *gYESDContamProtons = (TH1D *)gHistESDContamYPtProtons->Project3D("x");
1708   TH1D *gYESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->Project3D("x");
1709   gYESDContamProtons->Divide(gYESDRecIdProtons);
1710   SetError(gYESDContamProtons,gYESDRecIdProtons);
1711   gYESDContamProtons->Scale(100.);
1712   gYESDContamProtons->SetMarkerStyle(kOpenCircle);
1713
1714   c16->cd(1)->SetBottomMargin(0.15); 
1715   c16->cd(1)->SetLeftMargin(0.15); 
1716   c16->cd(1)->SetGridx(); c16->cd(1)->SetGridy();
1717   hEmpty->GetXaxis()->SetRangeUser(gYESDIdProtons->GetXaxis()->GetXmin()-0.2,
1718                                    gYESDIdProtons->GetXaxis()->GetXmax()+0.2);
1719   hEmpty->GetXaxis()->SetTitle(gYESDContamProtons->GetXaxis()->GetTitle());
1720   hEmpty->DrawCopy();
1721   gYESDIdProtons->DrawCopy("ESAME");
1722   gYESDContamProtons->DrawCopy("ESAME");
1723
1724   //pT dependence
1725   //protons pid efficiency
1726   //TH1D *gPtESDIdProtons = (TH1D *)gHistESDIdYPtProtons->ProjectionY("gPtESDIdProtons",0,gHistESDIdYPtProtons->GetYaxis()->GetNbins(),"e");
1727   //TH1D *gPtESDInitProtons = (TH1D *)gHistESDInitYPtProtons->ProjectionY("gPtESDInitProtons",0,gHistESDInitYPtProtons->GetYaxis()->GetNbins(),"e");
1728   TH1D *gPtESDIdProtons = (TH1D *)gHistESDIdYPtProtons->Project3D("y");
1729   TH1D *gPtESDInitProtons = (TH1D *)gHistESDInitYPtProtons->Project3D("y");
1730   gPtESDIdProtons->Divide(gPtESDInitProtons);
1731   SetError(gPtESDIdProtons,gPtESDInitProtons);
1732   gPtESDIdProtons->Scale(100.);
1733   gPtESDIdProtons->SetMarkerStyle(kFullCircle);
1734
1735   //protons pid contamination
1736   //TH1D *gPtESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionY("gPtESDContamProtons",0,gHistESDContamYPtProtons->GetYaxis()->GetNbins(),"e");
1737   //TH1D *gPtESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionY("gPtESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetYaxis()->GetNbins(),"e");
1738   TH1D *gPtESDContamProtons = (TH1D *)gHistESDContamYPtProtons->Project3D("y");
1739   TH1D *gPtESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->Project3D("y");
1740   gPtESDContamProtons->Divide(gPtESDRecIdProtons);
1741   SetError(gPtESDContamProtons,gPtESDRecIdProtons);
1742   gPtESDContamProtons->Scale(100.);
1743   gPtESDContamProtons->SetMarkerStyle(kOpenCircle);
1744
1745   c16->cd(2)->SetBottomMargin(0.15); 
1746   c16->cd(2)->SetLeftMargin(0.15); 
1747   c16->cd(2)->SetGridx(); c16->cd(2)->SetGridy();
1748   hEmpty->GetXaxis()->SetRangeUser(gPtESDIdProtons->GetXaxis()->GetXmin()-0.2,
1749                                    gPtESDIdProtons->GetXaxis()->GetXmax()+0.2);
1750   hEmpty->GetXaxis()->SetTitle(gPtESDContamProtons->GetXaxis()->GetTitle());
1751   hEmpty->DrawCopy();
1752   gPtESDIdProtons->DrawCopy("ESAME");
1753   gPtESDContamProtons->DrawCopy("ESAME");
1754
1755   //N_points dependence
1756   //protons pid efficiency
1757   TH1D *gNPointsESDIdProtons = (TH1D *)gHistESDIdYPtProtons->Project3D("z");
1758   TH1D *gNPointsESDInitProtons = (TH1D *)gHistESDInitYPtProtons->Project3D("z");
1759   gNPointsESDIdProtons->Divide(gNPointsESDInitProtons);
1760   SetError(gNPointsESDIdProtons,gNPointsESDInitProtons);
1761   gNPointsESDIdProtons->Scale(100.);
1762   gNPointsESDIdProtons->SetMarkerStyle(kFullCircle);
1763
1764   //protons pid contamination
1765   TH1D *gNPointsESDContamProtons = (TH1D *)gHistESDContamYPtProtons->Project3D("z");
1766   TH1D *gNPointsESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->Project3D("z");
1767   gNPointsESDContamProtons->Divide(gNPointsESDRecIdProtons);
1768   SetError(gNPointsESDContamProtons,gNPointsESDRecIdProtons);
1769   gNPointsESDContamProtons->Scale(100.);
1770   gNPointsESDContamProtons->SetMarkerStyle(kOpenCircle);
1771
1772   c16->cd(3)->SetBottomMargin(0.15); 
1773   c16->cd(3)->SetLeftMargin(0.15); 
1774   c16->cd(3)->SetGridx(); c16->cd(3)->SetGridy();
1775   hEmpty->GetXaxis()->SetRangeUser(gNPointsESDIdProtons->GetXaxis()->GetXmin(),
1776                                    gNPointsESDIdProtons->GetXaxis()->GetXmax()+10);
1777   hEmpty->GetXaxis()->SetTitle(gNPointsESDContamProtons->GetXaxis()->GetTitle());
1778   hEmpty->DrawCopy();
1779   gNPointsESDIdProtons->DrawCopy("ESAME");
1780   gNPointsESDContamProtons->DrawCopy("ESAME");
1781
1782   c16->SaveAs("PIDEfficiency-Protons.gif");
1783
1784   TString outputFileName = "Reconstruction-PID-Efficiency.";
1785   outputFileName += analysisType; outputFileName += ".root";
1786   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
1787   gYPrimariesESDProtons->Write();
1788   gYESDProtonsFromWeak->Write();
1789   gYESDProtonsFromHadronic->Write();
1790   gPtPrimariesESDProtons->Write();
1791   gPtESDProtonsFromWeak->Write();
1792   gPtESDProtonsFromHadronic->Write();
1793   gYPrimariesESDAntiProtons->Write();
1794   gYESDAntiProtonsFromWeak->Write();
1795   gYESDAntiProtonsFromHadronic->Write();
1796   gPtPrimariesESDAntiProtons->Write();
1797   gPtESDAntiProtonsFromWeak->Write();
1798   gPtESDAntiProtonsFromHadronic->Write();
1799   gYESDIdProtons->Write();
1800   gYESDContamProtons->Write();
1801   gPtESDIdProtons->Write();
1802   gPtESDContamProtons->Write();
1803   gNPointsESDIdProtons->Write();
1804   gNPointsESDContamProtons->Write();
1805   fout->Close();
1806 }
1807
1808 //________________________________________________//
1809 void DrawMarker(Double_t x, Double_t y, Int_t style, 
1810                 Double_t size, Int_t color) {
1811   TMarker *m = new TMarker(x,y,style);
1812   m->SetMarkerSize(size);
1813   m->SetMarkerColor(color);
1814   m->Draw();
1815 }
1816
1817 //________________________________________________//
1818 const char * const gMCProcessName[45] = {
1819   "Primary particle emission",
1820   "Multiple scattering",
1821   "Energy loss",
1822   "Bending in magnetic field",
1823   "Decay",
1824   "Lepton pair production",
1825   "Compton scattering",
1826   "Photoelectric effect",
1827   "Bremstrahlung",
1828   "Delta ray",
1829   "Positron annihilation",
1830   "Positron annihilation at rest",
1831   "Positron annihilation in flight",
1832   "Hadronic interaction",
1833   "Nuclear evaporation",
1834   "Nuclear fission",
1835   "Nuclear absorbtion",
1836   "Antiproton annihilation",
1837   "Antineutron annihilation",
1838   "Neutron capture",
1839   "Hadronic elastic",
1840   "Hadronic incoherent elastic",
1841   "Hadronic coherent elastic",
1842   "Hadronic inelastic",
1843   "Photon inelastic",
1844   "Muon nuclear interaction",
1845   "Electron nuclear interaction",
1846   "Positron nuclear interaction",
1847   "Time of flight limit",
1848   "Nuclear photofission",
1849   "Rayleigh effect",
1850   "No active process",
1851   "Energy threshold",
1852   "Light absorption",
1853   "Light detection",
1854   "Light scattering",
1855   "Maximum allowed step",
1856   "Cerenkov production",
1857   "Cerenkov feed back photon",
1858   "Cerenkov photon reflection",
1859   "Cerenkov photon refraction",
1860   "Synchrotron radiation",
1861   "Scintillation",
1862   "Transportation",
1863   "Unknown process"
1864 };
1865
1866 //________________________________________________//
1867 void drawKineQA(const char *filename) {
1868   //Draws the QA plots for the kinematic variables for protons and antiprotons
1869   gStyle->SetPalette(1,0);
1870   gStyle->SetCanvasColor(41);
1871   gStyle->SetFrameFillColor(10);
1872
1873   TFile *f = TFile::Open(filename);
1874   TList *acceptedList = (TList *)f->Get("acceptedCutList");
1875   TH3D *gHistEtaPhiNClustersPrimaryProtonsPass = (TH3D *)acceptedList->At(44);
1876   gHistEtaPhiNClustersPrimaryProtonsPass->SetTitle("Primary protons");
1877   TH3D *gHistEtaPhiNClustersSecondaryProtonsPass = (TH3D *)acceptedList->At(46);
1878   gHistEtaPhiNClustersSecondaryProtonsPass->SetTitle("Secondary protons");
1879   TH3D *gHistEtaPhiNClustersPrimaryAntiProtonsPass = (TH3D *)acceptedList->At(45);
1880   gHistEtaPhiNClustersPrimaryAntiProtonsPass->SetTitle("Primary antiprotons");
1881   TH3D *gHistEtaPhiNClustersSecondaryAntiProtonsPass = (TH3D *)acceptedList->At(47);
1882   gHistEtaPhiNClustersSecondaryAntiProtonsPass->SetTitle("Secondary antiprotons");
1883   TH3D *gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass = (TH3D *)acceptedList->At(48);
1884   gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass->SetTitle("Primary protons");
1885   TH3D *gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass = (TH3D *)acceptedList->At(50);
1886   gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass->SetTitle("Secondary protons");
1887   TH3D *gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass = (TH3D *)acceptedList->At(49);
1888   gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass->SetTitle("Primary antiprotons");
1889   TH3D *gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass = (TH3D *)acceptedList->At(51);
1890   gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass->SetTitle("Secondary antiprotons");
1891   TH3D *gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass = (TH3D *)acceptedList->At(52);
1892   gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass->SetTitle("Primary protons");
1893   TH3D *gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass = (TH3D *)acceptedList->At(54);
1894   gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass->SetTitle("Secondary protons");
1895   TH3D *gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass = (TH3D *)acceptedList->At(53);
1896   gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass->SetTitle("Primary antiprotons");
1897   TH3D *gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass = (TH3D *)acceptedList->At(55);
1898   gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass->SetTitle("Secondary antiprotons");
1899   
1900   TList *rejectedList = (TList *)f->Get("rejectedCutList");
1901   TH3D *gHistEtaPhiNClustersPrimaryProtonsReject = (TH3D *)rejectedList->At(0);
1902   gHistEtaPhiNClustersPrimaryProtonsPass->Add(gHistEtaPhiNClustersPrimaryProtonsReject);
1903   TH3D *gHistEtaPhiNClustersSecondaryProtonsReject = (TH3D *)rejectedList->At(2);
1904   gHistEtaPhiNClustersSecondaryProtonsPass->Add(gHistEtaPhiNClustersSecondaryProtonsReject);
1905   TH3D *gHistEtaPhiNClustersPrimaryAntiProtonsReject = (TH3D *)rejectedList->At(1);
1906   gHistEtaPhiNClustersPrimaryAntiProtonsPass->Add(gHistEtaPhiNClustersPrimaryAntiProtonsReject);
1907   TH3D *gHistEtaPhiNClustersSecondaryAntiProtonsReject = (TH3D *)rejectedList->At(3);
1908   gHistEtaPhiNClustersSecondaryAntiProtonsPass->Add(gHistEtaPhiNClustersSecondaryAntiProtonsReject);
1909   TH3D *gHistEtaPhiChi2PerTPCClusterPrimaryProtonsReject = (TH3D *)rejectedList->At(4);
1910   gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass->Add(gHistEtaPhiChi2PerTPCClusterPrimaryProtonsReject);
1911   TH3D *gHistEtaPhiChi2PerTPCClusterSecondaryProtonsReject = (TH3D *)rejectedList->At(6);
1912   gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass->Add(gHistEtaPhiChi2PerTPCClusterSecondaryProtonsReject);
1913   TH3D *gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsReject = (TH3D *)rejectedList->At(5);
1914   gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass->Add(gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsReject);
1915   TH3D *gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsReject = (TH3D *)rejectedList->At(7);
1916   gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass->Add(gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsReject);
1917   TH3D *gHistEtaPhiTPCdEdxNPointsPrimaryProtonsReject = (TH3D *)rejectedList->At(8);
1918   gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass->Add(gHistEtaPhiTPCdEdxNPointsPrimaryProtonsReject);
1919   TH3D *gHistEtaPhiTPCdEdxNPointsSecondaryProtonsReject = (TH3D *)rejectedList->At(10);
1920   gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass->Add(gHistEtaPhiTPCdEdxNPointsSecondaryProtonsReject);
1921   TH3D *gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsReject = (TH3D *)rejectedList->At(9);
1922   gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass->Add(gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsReject);
1923   TH3D *gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsReject = (TH3D *)rejectedList->At(11);
1924   gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass->Add(gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsReject);
1925
1926   //eta-phi
1927   TCanvas *c21 = new TCanvas("c21",
1928                              "#eta-#phi",
1929                              0,0,600,600);
1930   c21->SetHighLightColor(10); c21->Divide(2,2);
1931   c21->cd(1)->SetLeftMargin(0.15); c21->cd(1)->SetBottomMargin(0.15);  
1932   c21->cd(1)->SetRightMargin(0.2);
1933   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1934   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("yx")))->DrawCopy("colz");
1935   c21->cd(2)->SetLeftMargin(0.15); c21->cd(2)->SetBottomMargin(0.15);  
1936   c21->cd(2)->SetRightMargin(0.2);
1937   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1938   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("yx")))->DrawCopy("colz");
1939   c21->cd(3)->SetLeftMargin(0.15); c21->cd(3)->SetBottomMargin(0.15);  
1940   c21->cd(3)->SetRightMargin(0.2);
1941   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1942   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("yx")))->DrawCopy("colz");
1943   c21->cd(4)->SetLeftMargin(0.15); c21->cd(4)->SetBottomMargin(0.15);  
1944   c21->cd(4)->SetRightMargin(0.2);
1945   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1946   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("yx")))->DrawCopy("colz");
1947   c21->SaveAs("EtaPhi.gif");
1948
1949   //eta-Nclusters
1950   TCanvas *c22 = new TCanvas("c22",
1951                              "#eta-N_{clusters}",
1952                              100,100,600,600);
1953   c22->SetHighLightColor(10); c22->Divide(2,2);
1954   c22->cd(1)->SetLeftMargin(0.15); c22->cd(1)->SetBottomMargin(0.15);  
1955   c22->cd(1)->SetRightMargin(0.2);
1956   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1957   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
1958   c22->cd(2)->SetLeftMargin(0.15); c22->cd(2)->SetBottomMargin(0.15);  
1959   c22->cd(2)->SetRightMargin(0.2);
1960   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1961   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
1962   c22->cd(3)->SetLeftMargin(0.15); c22->cd(3)->SetBottomMargin(0.15);  
1963   c22->cd(3)->SetRightMargin(0.2);
1964   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1965   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
1966   c22->cd(4)->SetLeftMargin(0.15); c22->cd(4)->SetBottomMargin(0.15);  
1967   c22->cd(4)->SetRightMargin(0.2);
1968   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1969   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
1970   c22->SaveAs("EtaNClusters.gif");
1971
1972   //phi-Nclusters
1973   TCanvas *c23 = new TCanvas("c23",
1974                              "#phi-N_{clusters}",
1975                              200,200,600,600);
1976   c23->SetHighLightColor(10); c23->Divide(2,2);
1977   c23->cd(1)->SetLeftMargin(0.15); c23->cd(1)->SetBottomMargin(0.15);  
1978   c23->cd(1)->SetRightMargin(0.2);
1979   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1980   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
1981   c23->cd(2)->SetLeftMargin(0.15); c23->cd(2)->SetBottomMargin(0.15);  
1982   c23->cd(2)->SetRightMargin(0.2);
1983   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1984   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
1985   c23->cd(3)->SetLeftMargin(0.15); c23->cd(3)->SetBottomMargin(0.15);  
1986   c23->cd(3)->SetRightMargin(0.2);
1987   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1988   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
1989   c23->cd(4)->SetLeftMargin(0.15); c23->cd(4)->SetBottomMargin(0.15);  
1990   c23->cd(4)->SetRightMargin(0.2);
1991   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1992   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
1993   c23->SaveAs("PhiNClusters.gif");
1994
1995   //eta-chi^2 per TPC cluster
1996   TCanvas *c24 = new TCanvas("c24",
1997                              "#eta-#chi^{2}/N_{clusters}(TPC)",
1998                              300,300,600,600);
1999   c24->SetHighLightColor(10); c24->Divide(2,2);
2000   c24->cd(1)->SetLeftMargin(0.15); c24->cd(1)->SetBottomMargin(0.15);  
2001   c24->cd(1)->SetRightMargin(0.2);
2002   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
2003   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
2004   c24->cd(2)->SetLeftMargin(0.15); c24->cd(2)->SetBottomMargin(0.15);  
2005   c24->cd(2)->SetRightMargin(0.2);
2006   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
2007   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
2008   c24->cd(3)->SetLeftMargin(0.15); c24->cd(3)->SetBottomMargin(0.15);  
2009   c24->cd(3)->SetRightMargin(0.2);
2010   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
2011   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
2012   c24->cd(4)->SetLeftMargin(0.15); c24->cd(4)->SetBottomMargin(0.15);  
2013   c24->cd(4)->SetRightMargin(0.2);
2014   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
2015   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
2016   c24->SaveAs("EtaChi2PerTPCCluster.gif");
2017
2018   //phi-chi^2 per TPC cluster
2019   TCanvas *c25 = new TCanvas("c25",
2020                              "#phi-#chi^{2}/N_{clusters}(TPC)",
2021                              400,400,600,600);
2022   c25->SetHighLightColor(10); c25->Divide(2,2);
2023   c25->cd(1)->SetLeftMargin(0.15); c25->cd(1)->SetBottomMargin(0.15);  
2024   c25->cd(1)->SetRightMargin(0.2);
2025   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
2026   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
2027   c25->cd(2)->SetLeftMargin(0.15); c25->cd(2)->SetBottomMargin(0.15);  
2028   c25->cd(2)->SetRightMargin(0.2);
2029   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
2030   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
2031   c25->cd(3)->SetLeftMargin(0.15); c25->cd(3)->SetBottomMargin(0.15);  
2032   c25->cd(3)->SetRightMargin(0.2);
2033   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
2034   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
2035   c25->cd(4)->SetLeftMargin(0.15); c25->cd(4)->SetBottomMargin(0.15);  
2036   c25->cd(4)->SetRightMargin(0.2);
2037   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
2038   ((TH2D *)(gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
2039   c25->SaveAs("PhiChi2PerTPCCluster.gif");
2040
2041    //eta-dE/dx Npoints (TPC)
2042   TCanvas *c26 = new TCanvas("c26",
2043                              "#eta-dEdx N_{points}(TPC)",
2044                              500,500,600,600);
2045   c26->SetHighLightColor(10); c26->Divide(2,2);
2046   c26->cd(1)->SetLeftMargin(0.15); c26->cd(1)->SetBottomMargin(0.15);  
2047   c26->cd(1)->SetRightMargin(0.2);
2048   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
2049   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
2050   c26->cd(2)->SetLeftMargin(0.15); c26->cd(2)->SetBottomMargin(0.15);  
2051   c26->cd(2)->SetRightMargin(0.2);
2052   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
2053   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
2054   c26->cd(3)->SetLeftMargin(0.15); c26->cd(3)->SetBottomMargin(0.15);  
2055   c26->cd(3)->SetRightMargin(0.2);
2056   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
2057   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
2058   c26->cd(4)->SetLeftMargin(0.15); c26->cd(4)->SetBottomMargin(0.15);  
2059   c26->cd(4)->SetRightMargin(0.2);
2060   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
2061   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
2062   c26->SaveAs("EtadEdxNPointsTPC.gif");
2063
2064   //phi-dE/dx Npoints (TPC)
2065   TCanvas *c27 = new TCanvas("c27",
2066                              "#phi-dEdx N_{points}(TPC)",
2067                              600,600,600,600);
2068   c27->SetHighLightColor(10); c27->Divide(2,2);
2069   c27->cd(1)->SetLeftMargin(0.15); c27->cd(1)->SetBottomMargin(0.15);  
2070   c27->cd(1)->SetRightMargin(0.2);
2071   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
2072   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
2073   c27->cd(2)->SetLeftMargin(0.15); c27->cd(2)->SetBottomMargin(0.15);  
2074   c27->cd(2)->SetRightMargin(0.2);
2075   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
2076   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
2077   c27->cd(3)->SetLeftMargin(0.15); c27->cd(3)->SetBottomMargin(0.15);  
2078   c27->cd(3)->SetRightMargin(0.2);
2079   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
2080   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
2081   c27->cd(4)->SetLeftMargin(0.15); c27->cd(4)->SetBottomMargin(0.15);  
2082   c27->cd(4)->SetRightMargin(0.2);
2083   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
2084   ((TH2D *)(gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
2085   c27->SaveAs("PhidEdxNPointsTPC.gif");
2086   
2087   f->Close();
2088 }
2089
2090 //________________________________________________//
2091 void drawEfficiencies(const char *filename,
2092                       Bool_t gShowPrimaries = kTRUE,
2093                       Bool_t gShowWeak = kFALSE,
2094                       Bool_t gShowHadronic = kFALSE) {
2095   //Macro to display the reconstruction, cut and pid efficiencies
2096   gStyle->SetPalette(1,0);
2097   gStyle->SetCanvasColor(41);
2098   gStyle->SetFrameFillColor(10);
2099
2100   TH2F *hEmpty = new TH2F("hEmpty","",100,-1.5,5.0,100,0,120);
2101   hEmpty->SetStats(kFALSE);
2102   hEmpty->GetXaxis()->SetTitleColor(1);
2103   hEmpty->GetXaxis()->SetNdivisions(15);
2104   hEmpty->GetYaxis()->SetNdivisions(15);
2105   hEmpty->GetYaxis()->SetTitleOffset(1.4);
2106   hEmpty->GetYaxis()->SetTitle("#epsilon");
2107
2108   TLatex *t1 = new TLatex();
2109   t1->SetTextSize(0.04);
2110
2111   TPaveText *tpave = new TPaveText();
2112   tpave->SetFillColor(10);
2113   Double_t bottomY = 0.0;
2114
2115   TFile *f = TFile::Open(filename);
2116   TH1D *gYPrimariesESDProtons = (TH1D *)f->Get("gYPrimariesESDProtons");
2117   TH1D *gYESDProtonsFromWeak = (TH1D *)f->Get("gYESDProtonsFromWeak");
2118   TH1D *gYESDProtonsFromHadronic = (TH1D *)f->Get("gYESDProtonsFromHadronic");
2119   TH1D *gPtPrimariesESDProtons = (TH1D *)f->Get("gPtPrimariesESDProtons");
2120   TH1D *gPtESDProtonsFromWeak = (TH1D *)f->Get("gPtESDProtonsFromWeak");
2121   TH1D *gPtESDProtonsFromHadronic = (TH1D *)f->Get("gPtESDProtonsFromHadronic");
2122   TH1D *gYPrimariesESDAntiProtons = (TH1D *)f->Get("gYPrimariesESDAntiProtons");
2123   TH1D *gYESDAntiProtonsFromWeak = (TH1D *)f->Get("gYESDAntiProtonsFromWeak");
2124   TH1D *gYESDAntiProtonsFromHadronic = (TH1D *)f->Get("gYESDAntiProtonsFromHadronic");  
2125   TH1D *gPtPrimariesESDAntiProtons = (TH1D *)f->Get("gPtPrimariesESDAntiProtons");      
2126   TH1D *gPtESDAntiProtonsFromWeak = (TH1D *)f->Get("gPtESDAntiProtonsFromWeak");        
2127   TH1D *gPtESDAntiProtonsFromHadronic = (TH1D *)f->Get("gPtESDAntiProtonsFromHadronic");        
2128   TH1D *gYESDIdProtons = (TH1D *)f->Get("gHistESDIdYPtProtons_x");
2129   TH1D *gYESDContamProtons = (TH1D *)f->Get("gHistESDContamYPtProtons_x");
2130   TH1D *gPtESDIdProtons = (TH1D *)f->Get("gHistESDIdYPtProtons_y");
2131   TH1D *gPtESDContamProtons = (TH1D *)f->Get("gHistESDContamYPtProtons_y");     
2132
2133   //Reconstruction efficiencies - protons
2134   TCanvas *c1 = new TCanvas("c1","Reconstruction efficiencies - Protons",
2135                             0,0,700,400);
2136   c1->SetFillColor(41); c1->SetHighLightColor(41);
2137   c1->Divide(2,1);
2138   c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15);
2139   c1->cd(1)->SetGridx(); c1->cd(1)->SetGridy();
2140   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2141                                    gYPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2142   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDProtons->GetXaxis()->GetTitle());
2143   hEmpty->DrawCopy();
2144   if(gShowPrimaries)
2145     bottomY = 111.0;
2146   if(gShowWeak)
2147     bottomY = 106.0;
2148   if(gShowHadronic)
2149     bottomY = 101.0;
2150   tpave->DrawPave(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.1,119,
2151                   gYPrimariesESDProtons->GetXaxis()->GetXmax()-0.1,bottomY);
2152   if(gShowPrimaries) {
2153     DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 115, 20, 1.2, 1);
2154     t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,113,"Primary p");
2155     gYPrimariesESDProtons->DrawCopy("ESAME");
2156   }
2157   if(gShowWeak) {
2158     DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 110, 21, 1.2, 2);
2159     t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,108,"#Lambda -> p + #pi^{-}");
2160     gYESDProtonsFromWeak->DrawCopy("ESAME");
2161   }
2162   if(gShowHadronic) {
2163     DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 105, 22, 1.2, 3);
2164     t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,103,"X + A -> p + B");
2165     gYESDProtonsFromHadronic->DrawCopy("ESAME");
2166   }
2167
2168   c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15);
2169   c1->cd(2)->SetGridx(); c1->cd(2)->SetGridy();
2170   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2171                                    gPtPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2172   hEmpty->GetXaxis()->SetTitle(gPtPrimariesESDProtons->GetXaxis()->GetTitle());
2173   hEmpty->DrawCopy();
2174   if(gShowPrimaries)
2175     bottomY = 111.0;
2176   if(gShowWeak)
2177     bottomY = 106.0;
2178   if(gShowHadronic)
2179     bottomY = 101.0;
2180   tpave->DrawPave(gPtPrimariesESDProtons->GetXaxis()->GetXmin(),119,
2181                   gPtPrimariesESDProtons->GetXaxis()->GetXmax(),bottomY);
2182   if(gShowPrimaries) {
2183     DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 115, 20, 1.2, 1);
2184     t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,113,"Primary p");
2185     gPtPrimariesESDProtons->DrawCopy("ESAME");
2186   }
2187   if(gShowWeak) {
2188     DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 110, 21, 1.2, 2);
2189     t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,108,"#Lambda -> p + #pi^{-}");
2190     gPtESDProtonsFromWeak->DrawCopy("ESAME");
2191   }
2192   if(gShowHadronic) {
2193     DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 105, 22, 1.2, 3);
2194     t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,103,"X + A -> p + B");
2195     gPtESDProtonsFromHadronic->DrawCopy("ESAME");
2196   }
2197   c1->SaveAs("ReconstructionEfficiency-Protons.gif");
2198
2199   //Reconstruction efficiencies - antiprotons
2200   TCanvas *c2 = new TCanvas("c2","Reconstruction efficiencies - Antirotons",
2201                             100,100,700,400);
2202   c2->SetFillColor(41); c2->SetHighLightColor(41);
2203   c2->Divide(2,1);
2204   c2->cd(1)->SetLeftMargin(0.15); c2->cd(1)->SetBottomMargin(0.15);
2205   c2->cd(1)->SetGridx(); c2->cd(1)->SetGridy();
2206   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.1,
2207                                    gYPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.1);
2208   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDAntiProtons->GetXaxis()->GetTitle());
2209   hEmpty->DrawCopy();
2210   if(gShowPrimaries)
2211     bottomY = 111.0;
2212   if(gShowWeak)
2213     bottomY = 104.0;
2214   if(gShowHadronic)
2215     bottomY = 97.0;
2216   tpave->DrawPave(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.1,119,
2217                   gYPrimariesESDAntiProtons->GetXaxis()->GetXmax()-0.1,bottomY);
2218   if(gShowPrimaries) {
2219     DrawMarker(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.2, 115, 20, 1.2, 1);
2220     t1->DrawLatex(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.3,113,"Primary #bar{p}");
2221     gYPrimariesESDAntiProtons->DrawCopy("ESAME");
2222   }
2223   if(gShowWeak) {
2224     DrawMarker(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.2, 108, 21, 1.2, 2);
2225     t1->DrawLatex(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.3,106,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2226     gYESDAntiProtonsFromWeak->DrawCopy("ESAME");
2227   }
2228   if(gShowHadronic) {
2229     DrawMarker(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.2, 101, 22, 1.2, 3);
2230     t1->DrawLatex(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.3,98,"X + A -> #bar{p} + B");
2231     gYESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2232   }
2233
2234   c2->cd(2)->SetLeftMargin(0.15); c2->cd(2)->SetBottomMargin(0.15);
2235   c2->cd(2)->SetGridx(); c2->cd(2)->SetGridy();
2236   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.1,
2237                                    gPtPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.1);
2238   hEmpty->GetXaxis()->SetTitle(gPtPrimariesESDAntiProtons->GetXaxis()->GetTitle());
2239   hEmpty->DrawCopy();
2240   hEmpty->DrawCopy();
2241   if(gShowPrimaries)
2242     bottomY = 111.0;
2243   if(gShowWeak)
2244     bottomY = 104.0;
2245   if(gShowHadronic)
2246     bottomY = 97.0;
2247   tpave->DrawPave(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin(),119,
2248                   gPtPrimariesESDAntiProtons->GetXaxis()->GetXmax(),bottomY);
2249   if(gShowPrimaries) {
2250     DrawMarker(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.05, 115, 20, 1.2, 1);
2251     t1->DrawLatex(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.15,113,"Primary #bar{p}");
2252     gPtPrimariesESDAntiProtons->DrawCopy("ESAME");
2253   }
2254   if(gShowWeak) {
2255     DrawMarker(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.05, 108, 21, 1.2, 2);
2256     t1->DrawLatex(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.15,106,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2257     gPtESDAntiProtonsFromWeak->DrawCopy("ESAME");
2258   }
2259   if(gShowHadronic) {
2260     DrawMarker(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.05, 101, 22, 1.2, 3);
2261     t1->DrawLatex(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.15,98,"X + A -> #bar{p} + B");
2262     gPtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2263   }
2264   c2->SaveAs("ReconstructionEfficiency-AntiProtons.gif");
2265
2266   //PID efficiencies - (anti)protons
2267   TCanvas *c3 = new TCanvas("c3","PID efficiencies",
2268                             200,200,700,400);
2269   c3->SetFillColor(41); c3->SetHighLightColor(41);
2270   c3->Divide(2,1);
2271   c3->cd(1)->SetLeftMargin(0.15); c3->cd(1)->SetBottomMargin(0.15);
2272   c3->cd(1)->SetGridx(); c3->cd(1)->SetGridy();
2273   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2274                                    gYPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2275   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDProtons->GetXaxis()->GetTitle());
2276   hEmpty->DrawCopy();
2277   tpave->DrawPave(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.1,119,
2278                   gYPrimariesESDProtons->GetXaxis()->GetXmax()-0.1,104);
2279   gYESDIdProtons->DrawCopy("ESAME");
2280   gYESDContamProtons->DrawCopy("ESAME");
2281   DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 115, 20, 1.2, 1);
2282   t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,113,"Efficiency");
2283   DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 108, 24, 1.2, 1);
2284   t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,106,"Contamination");
2285  
2286   c3->cd(2)->SetLeftMargin(0.15); c3->cd(2)->SetBottomMargin(0.15);
2287   c3->cd(2)->SetGridx(); c3->cd(2)->SetGridy();
2288   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2289                                    gPtPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2290   hEmpty->GetXaxis()->SetTitle(gPtPrimariesESDProtons->GetXaxis()->GetTitle());
2291   hEmpty->DrawCopy();
2292   tpave->DrawPave(gPtPrimariesESDProtons->GetXaxis()->GetXmin(),119,
2293                   gPtPrimariesESDProtons->GetXaxis()->GetXmax(),104);
2294   gPtESDIdProtons->DrawCopy("ESAME");
2295   gPtESDContamProtons->DrawCopy("ESAME");
2296   DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 115, 20, 1.2, 1);
2297   t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,113,"Efficiency");
2298   DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 108, 24, 1.2, 1);
2299   t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,106,"Contamination");
2300   c3->SaveAs("PIDEfficiency-Protons.gif");
2301 }
2302
2303 //________________________________________________//
2304 void compareEfficiencies(const char *filenameTPC,
2305                          const char *filenameHybrid,
2306                          Bool_t gShowPrimaries = kTRUE,
2307                          Bool_t gShowWeak = kFALSE,
2308                          Bool_t gShowHadronic = kFALSE) {
2309   //Function to compare the reconstruction efficiencies between two methods:
2310   //e.g. TPC standalone and global tracking
2311   gStyle->SetPalette(1,0);
2312   gStyle->SetCanvasColor(41);
2313   gStyle->SetFrameFillColor(10);
2314
2315   TH2F *hEmpty = new TH2F("hEmpty","",100,-1.5,2.0,100,0,120);
2316   hEmpty->SetStats(kFALSE);
2317   hEmpty->GetXaxis()->SetTitleColor(1);
2318   hEmpty->GetXaxis()->SetNdivisions(15);
2319   hEmpty->GetYaxis()->SetNdivisions(15);
2320   hEmpty->GetYaxis()->SetTitleOffset(1.4);
2321   hEmpty->GetYaxis()->SetTitle("#epsilon");
2322
2323   TLatex *t1 = new TLatex();
2324   t1->SetTextSize(0.04);
2325
2326   TPaveText *tpave = new TPaveText();
2327   tpave->SetFillColor(10);
2328   Double_t bottomY = 0.0;
2329
2330   //TPC standalone
2331   TFile *f1 = TFile::Open(filenameTPC);
2332   TH1D *g1YPrimariesESDProtons = (TH1D *)f1->Get("gYPrimariesESDProtons");
2333   TH1D *g1YESDProtonsFromWeak = (TH1D *)f1->Get("gYESDProtonsFromWeak");
2334   TH1D *g1YESDProtonsFromHadronic = (TH1D *)f1->Get("gYESDProtonsFromHadronic");
2335   TH1D *g1PtPrimariesESDProtons = (TH1D *)f1->Get("gPtPrimariesESDProtons");
2336   TH1D *g1PtESDProtonsFromWeak = (TH1D *)f1->Get("gPtESDProtonsFromWeak");
2337   TH1D *g1PtESDProtonsFromHadronic = (TH1D *)f1->Get("gPtESDProtonsFromHadronic");
2338   TH1D *g1YPrimariesESDAntiProtons = (TH1D *)f1->Get("gYPrimariesESDAntiProtons");
2339   TH1D *g1YESDAntiProtonsFromWeak = (TH1D *)f1->Get("gYESDAntiProtonsFromWeak");
2340   TH1D *g1YESDAntiProtonsFromHadronic = (TH1D *)f1->Get("gYESDAntiProtonsFromHadronic");        
2341   TH1D *g1PtPrimariesESDAntiProtons = (TH1D *)f1->Get("gPtPrimariesESDAntiProtons");    
2342   TH1D *g1PtESDAntiProtonsFromWeak = (TH1D *)f1->Get("gPtESDAntiProtonsFromWeak");      
2343   TH1D *g1PtESDAntiProtonsFromHadronic = (TH1D *)f1->Get("gPtESDAntiProtonsFromHadronic");      
2344
2345   //Global tracking
2346   TFile *f2 = TFile::Open(filenameHybrid);
2347   TH1D *g2YPrimariesESDProtons = (TH1D *)f2->Get("gYPrimariesESDProtons");
2348   TH1D *g2YESDProtonsFromWeak = (TH1D *)f2->Get("gYESDProtonsFromWeak");
2349   TH1D *g2YESDProtonsFromHadronic = (TH1D *)f2->Get("gYESDProtonsFromHadronic");
2350   TH1D *g2PtPrimariesESDProtons = (TH1D *)f2->Get("gPtPrimariesESDProtons");
2351   TH1D *g2PtESDProtonsFromWeak = (TH1D *)f2->Get("gPtESDProtonsFromWeak");
2352   TH1D *g2PtESDProtonsFromHadronic = (TH1D *)f2->Get("gPtESDProtonsFromHadronic");
2353   TH1D *g2YPrimariesESDAntiProtons = (TH1D *)f2->Get("gYPrimariesESDAntiProtons");
2354   TH1D *g2YESDAntiProtonsFromWeak = (TH1D *)f2->Get("gYESDAntiProtonsFromWeak");
2355   TH1D *g2YESDAntiProtonsFromHadronic = (TH1D *)f2->Get("gYESDAntiProtonsFromHadronic");        
2356   TH1D *g2PtPrimariesESDAntiProtons = (TH1D *)f2->Get("gPtPrimariesESDAntiProtons");    
2357   TH1D *g2PtESDAntiProtonsFromWeak = (TH1D *)f2->Get("gPtESDAntiProtonsFromWeak");      
2358   TH1D *g2PtESDAntiProtonsFromHadronic = (TH1D *)f2->Get("gPtESDAntiProtonsFromHadronic");      
2359
2360   //Reconstruction efficiencies - protons
2361   TCanvas *c1 = new TCanvas("c1","Reconstruction efficiencies - Protons",
2362                             0,0,700,400);
2363   c1->SetFillColor(41); c1->SetHighLightColor(41);
2364   c1->Divide(2,1);
2365   c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15);
2366   c1->cd(1)->SetGridx(); c1->cd(1)->SetGridy();
2367   hEmpty->GetXaxis()->SetRangeUser(-1.1,1.1);
2368   hEmpty->GetXaxis()->SetTitle("#eta");
2369   hEmpty->DrawCopy();
2370   if(gShowPrimaries)
2371     bottomY = 106.0;
2372   if(gShowWeak)
2373     bottomY = 99.0;
2374   if(gShowHadronic)
2375     bottomY = 92.0;
2376   tpave->DrawPave(-0.4,119,1.1,bottomY);
2377   t1->DrawLatex(-0.3,113,"TPC");
2378   t1->DrawLatex(0.0,113,"Global");
2379   if(gShowPrimaries) {
2380     DrawMarker(-0.15, 110, 20, 1.2, 1);
2381     DrawMarker(0.15, 110, 24, 1.2, 1);
2382     t1->DrawLatex(0.35,108,"Primary p");
2383     g1YPrimariesESDProtons->DrawCopy("ESAME");
2384     g2YPrimariesESDProtons->SetMarkerStyle(24);
2385     g2YPrimariesESDProtons->DrawCopy("ESAME");
2386   }
2387   if(gShowWeak) {
2388     DrawMarker(-0.15, 103, 21, 1.2, 2);
2389     DrawMarker(0.15, 103, 25, 1.2, 2);
2390     t1->DrawLatex(0.35,101,"#Lambda -> p + #pi^{-}");
2391     g1YESDProtonsFromWeak->DrawCopy("ESAME");
2392     g2YESDProtonsFromWeak->SetMarkerStyle(25);
2393     g2YESDProtonsFromWeak->DrawCopy("ESAME");
2394   }
2395   if(gShowHadronic) {
2396     DrawMarker(-0.15, 96, 22, 1.2, 3);
2397     DrawMarker(0.15, 96, 26, 1.2, 3);
2398     t1->DrawLatex(0.35,94,"X + A -> p + B");
2399     g1YESDProtonsFromHadronic->DrawCopy("ESAME");
2400     g2YESDProtonsFromHadronic->SetMarkerStyle(26);
2401     g2YESDProtonsFromHadronic->DrawCopy("ESAME");
2402   }
2403
2404   c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15);
2405   c1->cd(2)->SetGridx(); c1->cd(2)->SetGridy();
2406   hEmpty->GetXaxis()->SetRangeUser(0.0,1.7);
2407   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
2408   hEmpty->DrawCopy();
2409   if(gShowPrimaries)
2410     bottomY = 106.0;
2411   if(gShowWeak)
2412     bottomY = 99.0;
2413   if(gShowHadronic)
2414     bottomY = 92.0;
2415   tpave->DrawPave(0.05,119,1.2,bottomY);
2416   t1->DrawLatex(0.1,113,"TPC");
2417   t1->DrawLatex(0.3,113,"Global");
2418   if(gShowPrimaries) {
2419     DrawMarker(0.15, 110, 20, 1.2, 1);
2420     DrawMarker(0.4, 110, 24, 1.2, 1);
2421     t1->DrawLatex(0.6,108,"Primary p");
2422     g1PtPrimariesESDProtons->DrawCopy("ESAME");
2423     g2PtPrimariesESDProtons->SetMarkerStyle(24);
2424     g2PtPrimariesESDProtons->DrawCopy("ESAME");
2425   }
2426   if(gShowWeak) {
2427     DrawMarker(0.15, 103, 21, 1.2, 2);
2428     DrawMarker(0.4, 103, 25, 1.2, 2);
2429     t1->DrawLatex(0.6,101,"#Lambda -> p + #pi^{-}");
2430     g1PtESDProtonsFromWeak->DrawCopy("ESAME");
2431     g2PtESDProtonsFromWeak->SetMarkerStyle(25);
2432     g2PtESDProtonsFromWeak->DrawCopy("ESAME");
2433   }
2434   if(gShowHadronic) {
2435     DrawMarker(0.15, 96, 22, 1.2, 3);
2436     DrawMarker(0.4, 96, 26, 1.2, 3);
2437     t1->DrawLatex(0.6,94,"X + A -> p + B");
2438     g1PtESDProtonsFromHadronic->DrawCopy("ESAME");
2439     g2PtESDProtonsFromHadronic->SetMarkerStyle(26);
2440     g2PtESDProtonsFromHadronic->DrawCopy("ESAME");
2441   }
2442   c1->SaveAs("ReconstructionEfficiency-Protons.gif");
2443
2444   //Reconstruction efficiencies - antiprotons
2445   TCanvas *c2 = new TCanvas("c2","Reconstruction efficiencies - Antirotons",
2446                             100,100,700,400);
2447   c2->SetFillColor(41); c2->SetHighLightColor(41);
2448   c2->Divide(2,1);
2449   c2->cd(1)->SetLeftMargin(0.15); c2->cd(1)->SetBottomMargin(0.15);
2450   c2->cd(1)->SetGridx(); c2->cd(1)->SetGridy();
2451   hEmpty->GetXaxis()->SetRangeUser(-1.1,1.1);
2452   hEmpty->GetXaxis()->SetTitle("#eta");
2453   hEmpty->DrawCopy();
2454   if(gShowPrimaries)
2455     bottomY = 106.0;
2456   if(gShowWeak)
2457     bottomY = 99.0;
2458   if(gShowHadronic)
2459     bottomY = 92.0;
2460   tpave->DrawPave(-0.4,119,1.1,bottomY);
2461   t1->DrawLatex(-0.3,113,"TPC");
2462   t1->DrawLatex(0.0,113,"Global");
2463   if(gShowPrimaries) {
2464     DrawMarker(-0.15, 110, 20, 1.2, 1);
2465     DrawMarker(0.15, 110, 24, 1.2, 1);
2466     t1->DrawLatex(0.35,108,"Primary #bar{p}");
2467     g1YPrimariesESDAntiProtons->DrawCopy("ESAME");
2468     g2YPrimariesESDAntiProtons->SetMarkerStyle(24);
2469     g2YPrimariesESDAntiProtons->DrawCopy("ESAME");
2470   }
2471   if(gShowWeak) {
2472     DrawMarker(-0.15, 103, 21, 1.2, 2);
2473     DrawMarker(0.15, 103, 25, 1.2, 2);
2474     t1->DrawLatex(0.35,101,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2475     g1YESDAntiProtonsFromWeak->DrawCopy("ESAME");
2476     g2YESDAntiProtonsFromWeak->SetMarkerStyle(25);
2477     g2YESDAntiProtonsFromWeak->DrawCopy("ESAME");
2478   }
2479   if(gShowHadronic) {
2480     DrawMarker(-0.15, 96, 22, 1.2, 3);
2481     DrawMarker(0.15, 96, 26, 1.2, 3);
2482     t1->DrawLatex(0.35,94,"X + A -> #bar{p} + B");
2483     g1YESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2484     g2YESDAntiProtonsFromHadronic->SetMarkerStyle(26);
2485     g2YESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2486   }
2487
2488   c2->cd(2)->SetLeftMargin(0.15); c2->cd(2)->SetBottomMargin(0.15);
2489   c2->cd(2)->SetGridx(); c2->cd(2)->SetGridy();
2490   hEmpty->GetXaxis()->SetRangeUser(0.0,1.7);
2491   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
2492   hEmpty->DrawCopy();
2493   if(gShowPrimaries)
2494     bottomY = 106.0;
2495   if(gShowWeak)
2496     bottomY = 99.0;
2497   if(gShowHadronic)
2498     bottomY = 92.0;
2499   tpave->DrawPave(0.05,119,1.2,bottomY);
2500   t1->DrawLatex(0.1,113,"TPC");
2501   t1->DrawLatex(0.3,113,"Global");
2502   if(gShowPrimaries) {
2503     DrawMarker(0.15, 110, 20, 1.2, 1);
2504     DrawMarker(0.4, 110, 24, 1.2, 1);
2505     t1->DrawLatex(0.6,108,"Primary #bar{p}");
2506     g1PtPrimariesESDAntiProtons->DrawCopy("ESAME");
2507     g2PtPrimariesESDAntiProtons->SetMarkerStyle(24);
2508     g2PtPrimariesESDAntiProtons->DrawCopy("ESAME");
2509   }
2510   if(gShowWeak) {
2511     DrawMarker(0.15, 103, 21, 1.2, 2);
2512     DrawMarker(0.4, 103, 25, 1.2, 2);
2513     t1->DrawLatex(0.6,101,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2514     g1PtESDAntiProtonsFromWeak->DrawCopy("ESAME");
2515     g2PtESDAntiProtonsFromWeak->SetMarkerStyle(25);
2516     g2PtESDAntiProtonsFromWeak->DrawCopy("ESAME");
2517   }
2518   if(gShowHadronic) {
2519     DrawMarker(0.15, 96, 22, 1.2, 3);
2520     DrawMarker(0.4, 96, 26, 1.2, 3);
2521     t1->DrawLatex(0.6,94,"X + A -> #bar{p} + B");
2522     g1PtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2523     g2PtESDAntiProtonsFromHadronic->SetMarkerStyle(26);
2524     g2PtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2525   }
2526   c2->SaveAs("ReconstructionEfficiency-AntiProtons.gif");
2527
2528 }
2529
2530 //________________________________________________//
2531 void drawCutParametersDistributions(const char* filename = "Protons.QA.Histograms.root") {
2532   //macro that takes as an input the third file 
2533   //created by the proton QA analysis task 
2534   //and draws the DCA distributions of protons 
2535   //and antiprotons (both primary & secondaries)
2536   const Int_t nEvents = 1;
2537   gStyle->SetPalette(1,0);
2538
2539   TFile *f = TFile::Open(filename);
2540
2541   //cut list
2542   TH1F *gCutListHistograms[100];
2543   TList *listCut = (TList *)f->Get("acceptedCutList");
2544   Int_t iCounter = 0;
2545   cout<<"Cut list entries: "<<listCut->GetEntries()<<endl;
2546   for(Int_t iEntry = 0; iEntry < listCut->GetEntries(); iEntry++) {
2547     if(iCounter == 4) iCounter = 0;
2548     iCounter += 1;
2549     gCutListHistograms[iEntry] = (TH1F *)listCut->At(iEntry);
2550     gCutListHistograms[iEntry]->Scale(1./nEvents);
2551     if(iCounter < 3) {
2552       gCutListHistograms[iEntry]->SetFillColor(4);
2553       gCutListHistograms[iEntry]->SetMarkerColor(4);
2554       gCutListHistograms[iEntry]->SetMarkerStyle(20);
2555     }
2556     else {
2557       gCutListHistograms[iEntry]->SetFillColor(kOrange+1);
2558       gCutListHistograms[iEntry]->SetMarkerColor(kOrange+1);
2559       gCutListHistograms[iEntry]->SetMarkerStyle(29);
2560     }
2561     /*cout<<"Entry: "<<iEntry<<
2562       " - Counter: "<<iCounter<<
2563       " - Name: "<<gCutListHistograms[iEntry]->GetName()<<endl;*/
2564   }
2565
2566   //DCA list
2567   TH1F *gDCAListHistograms[20];
2568   TList *listDCA = (TList *)f->Get("acceptedDCAList");
2569   iCounter = 0;
2570   Int_t nDCAHistos1D = 12;
2571   cout<<"DCA list entries: "<<listDCA->GetEntries()<<endl;
2572   for(Int_t iEntry = 0; iEntry < nDCAHistos1D; iEntry++) {
2573     if(iCounter == 4) iCounter = 0;
2574     iCounter += 1;
2575     gDCAListHistograms[iEntry] = (TH1F *)listDCA->At(iEntry);
2576     gDCAListHistograms[iEntry]->Scale(1./nEvents);
2577     if(iCounter < 3) {
2578       gDCAListHistograms[iEntry]->SetFillColor(4);
2579       gDCAListHistograms[iEntry]->SetMarkerColor(4);
2580       gDCAListHistograms[iEntry]->SetMarkerStyle(20);
2581     }
2582     else {
2583       gDCAListHistograms[iEntry]->SetFillColor(kOrange+1);
2584       gDCAListHistograms[iEntry]->SetMarkerColor(kOrange+1);
2585       gDCAListHistograms[iEntry]->SetMarkerStyle(29);
2586     }
2587     /*cout<<"Entry: "<<iEntry<<
2588       " - Counter: "<<iCounter<<
2589       " - Name: "<<gDCAListHistograms[iEntry]->GetName()<<endl;*/
2590   }
2591
2592   TH3F *gDCAListHistograms3D[20];
2593   TList *listDCA3D = new TList();
2594   Int_t nDCAHistos2D = 12;
2595   for(Int_t iEntry = nDCAHistos1D; iEntry < 2*nDCAHistos2D; iEntry++) {
2596     gDCAListHistograms3D[iEntry-nDCAHistos1D] = dynamic_cast<TH3F *>(listDCA->At(iEntry));
2597     listDCA3D->Add(gDCAListHistograms3D[iEntry-nDCAHistos1D]);
2598   }
2599   
2600   //_________________________________________________________//
2601   TF1 *gDCA = new TF1("gDCA",
2602                       "[0]*TMath::Power(1+TMath::Exp((x-[1])/[2]),-1)",
2603                       0.1,100.0);
2604   gDCA->SetParameter(0,1.74221e+07);
2605   gDCA->SetParameter(1,-1.12221e+01);
2606   gDCA->SetParameter(2,1.02726);
2607   //_________________________________________________________//
2608   TH2F *hEmpty = new TH2F("hEmpty","",300,-100,200,100,1e-01,1e+06);
2609   hEmpty->GetYaxis()->SetTitle("Entries/Event");
2610   hEmpty->GetYaxis()->SetNdivisions(10);
2611   hEmpty->GetXaxis()->SetNdivisions(10);
2612   hEmpty->SetStats(kFALSE);
2613   //_________________________________________________________//
2614
2615   //Cut parameters
2616   TCanvas *c1 = new TCanvas("c1","ITS Cluster map",0,0,650,350);
2617   c1->SetFillColor(10); c1->GetFrame()->SetFillColor(10);
2618   c1->SetHighLightColor(10); c1->Divide(2,1);
2619   c1->cd(1)->SetBottomMargin(0.2); c1->cd(1)->SetLeftMargin(0.2);
2620   c1->cd(1)->SetLogy();
2621   hEmpty->GetXaxis()->SetTitle("ITS layer");
2622   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2623   hEmpty->SetTitle("Protons");
2624   hEmpty->DrawCopy();
2625   gCutListHistograms[0]->Draw("ESAME");
2626   gCutListHistograms[2]->Draw("ESAME");
2627   c1->cd(2)->SetBottomMargin(0.2); c1->cd(2)->SetLeftMargin(0.2);
2628   c1->cd(2)->SetLogy();
2629   hEmpty->GetXaxis()->SetTitle("ITS layer");
2630   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2631   hEmpty->SetTitle("Antiprotons");
2632   hEmpty->DrawCopy();
2633   gCutListHistograms[1]->Draw("ESAME");
2634   gCutListHistograms[3]->Draw("ESAME");
2635   c1->SaveAs("ITSClusterMap.gif");
2636
2637   TCanvas *c2 = new TCanvas("c2","Number of ITS Clusters",50,50,650,350);
2638   c2->SetFillColor(10); c2->GetFrame()->SetFillColor(10);
2639   c2->SetHighLightColor(10); c2->Divide(2,1);
2640   c2->cd(1)->SetBottomMargin(0.2); c2->cd(1)->SetLeftMargin(0.2);
2641   c2->cd(1)->SetLogy();
2642   hEmpty->GetXaxis()->SetTitle("N_{clusters}(ITS)");
2643   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2644   hEmpty->SetTitle("Protons");
2645   hEmpty->DrawCopy();
2646   gCutListHistograms[4]->Draw("ESAME");
2647   gCutListHistograms[6]->Draw("ESAME");
2648   c2->cd(2)->SetBottomMargin(0.2); c2->cd(2)->SetLeftMargin(0.2);
2649   c2->cd(2)->SetLogy();
2650   hEmpty->GetXaxis()->SetTitle("N_{clusters}(ITS)");
2651   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2652   hEmpty->SetTitle("Antiprotons");
2653   hEmpty->DrawCopy();
2654   gCutListHistograms[5]->Draw("ESAME");
2655   gCutListHistograms[7]->Draw("ESAME");
2656   c2->SaveAs("NITSClusters.gif");
2657
2658   TCanvas *c3 = new TCanvas("c3","Chi2 per ITS cluster",100,100,650,350);
2659   c3->SetFillColor(10); c3->GetFrame()->SetFillColor(10);
2660   c3->SetHighLightColor(10); c3->Divide(2,1);
2661   c3->cd(1)->SetBottomMargin(0.2); c3->cd(1)->SetLeftMargin(0.2);
2662   c3->cd(1)->SetLogy();
2663   hEmpty->GetXaxis()->SetTitle("#chi^{2}/N_{clusters}(ITS)");
2664   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2665   hEmpty->SetTitle("Protons");
2666   hEmpty->DrawCopy();
2667   gCutListHistograms[8]->Draw("ESAME");
2668   gCutListHistograms[10]->Draw("ESAME");
2669   c3->cd(2)->SetBottomMargin(0.2); c3->cd(2)->SetLeftMargin(0.2);
2670   c3->cd(2)->SetLogy();
2671   hEmpty->GetXaxis()->SetTitle("#chi^{2}/N_{clusters}(ITS)");
2672   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2673   hEmpty->SetTitle("AntiPpotons");
2674   hEmpty->DrawCopy();
2675   gCutListHistograms[9]->Draw("ESAME");
2676   gCutListHistograms[11]->Draw("ESAME");
2677   c3->SaveAs("Chi2PerITSCluster.gif");
2678
2679   TCanvas *c4 = new TCanvas("c4","Constrain chi2 - vertex",150,150,650,350);
2680   c4->SetFillColor(10); c4->GetFrame()->SetFillColor(10);
2681   c4->SetHighLightColor(10); c4->Divide(2,1);
2682   c4->cd(1)->SetBottomMargin(0.2); c4->cd(1)->SetLeftMargin(0.2);
2683   c4->cd(1)->SetLogy();
2684   hEmpty->GetXaxis()->SetTitle("log_{10}(#chi^{2}) (vertex)");
2685   hEmpty->GetXaxis()->SetRangeUser(-10.0,10.0);
2686   hEmpty->SetTitle("Protons");
2687   hEmpty->DrawCopy();
2688   gCutListHistograms[12]->Draw("ESAME");
2689   gCutListHistograms[14]->Draw("ESAME");
2690   c4->cd(2)->SetBottomMargin(0.2); c4->cd(2)->SetLeftMargin(0.2);
2691   c4->cd(2)->SetLogy();
2692   hEmpty->GetXaxis()->SetTitle("log_{10}(#chi^{2}) (vertex )");
2693   hEmpty->GetXaxis()->SetRangeUser(-10.0,10.0);
2694   hEmpty->SetTitle("Antiprotons");
2695   hEmpty->DrawCopy();
2696   gCutListHistograms[13]->Draw("ESAME");
2697   gCutListHistograms[15]->Draw("ESAME");
2698   c4->SaveAs("ConstrainChi2Vertex.gif");
2699
2700   TCanvas *c5 = new TCanvas("c5","Number of TPC Clusters",200,200,650,350);
2701   c5->SetFillColor(10); c5->GetFrame()->SetFillColor(10);
2702   c5->SetHighLightColor(10); c5->Divide(2,1);
2703   c5->cd(1)->SetBottomMargin(0.2); c5->cd(1)->SetLeftMargin(0.2);
2704   c5->cd(1)->SetLogy();
2705   hEmpty->GetXaxis()->SetTitle("N_{clusters}(TPC");
2706   hEmpty->GetXaxis()->SetRangeUser(0.0,200.0);
2707   hEmpty->SetTitle("Protons");
2708   hEmpty->DrawCopy();
2709   gCutListHistograms[16]->Draw("ESAME");
2710   gCutListHistograms[18]->Draw("ESAME");
2711   c5->cd(2)->SetBottomMargin(0.2); c5->cd(2)->SetLeftMargin(0.2);
2712   c5->cd(2)->SetLogy();
2713   hEmpty->GetXaxis()->SetTitle("N_{clusters}(TPC");
2714   hEmpty->GetXaxis()->SetRangeUser(0.0,200.0);
2715   hEmpty->SetTitle("Antiprotons");
2716   hEmpty->DrawCopy();
2717   gCutListHistograms[17]->Draw("ESAME");
2718   gCutListHistograms[19]->Draw("ESAME");
2719   c5->SaveAs("NTPCClusters.gif");
2720
2721   TCanvas *c6 = new TCanvas("c6","Chi2 per TPC cluster",250,250,650,350);
2722   c6->SetFillColor(10); c6->GetFrame()->SetFillColor(10);
2723   c6->SetHighLightColor(10); c6->Divide(2,1);
2724   c6->cd(1)->SetBottomMargin(0.2); c6->cd(1)->SetLeftMargin(0.2);
2725   c6->cd(1)->SetLogy();
2726   hEmpty->GetXaxis()->SetTitle("#chi^{2}/N_{clusters}(TPC)");
2727   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2728   hEmpty->SetTitle("Protons");
2729   hEmpty->DrawCopy();
2730   gCutListHistograms[20]->Draw("ESAME");
2731   gCutListHistograms[22]->Draw("ESAME");
2732   c6->cd(2)->SetBottomMargin(0.2); c6->cd(2)->SetLeftMargin(0.2);
2733   c6->cd(2)->SetLogy();
2734   hEmpty->GetXaxis()->SetTitle("#chi^{2}/N_{clusters}(TPC)");
2735   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2736   hEmpty->SetTitle("Antiprotons");
2737   hEmpty->DrawCopy();
2738   gCutListHistograms[21]->Draw("ESAME");
2739   gCutListHistograms[23]->Draw("ESAME");
2740   c6->SaveAs("Chi2PerTPCCluster.gif");
2741
2742   TCanvas *c7 = new TCanvas("c7","Covariance matrix 11",300,300,650,350);
2743   c7->SetFillColor(10); c7->GetFrame()->SetFillColor(10);
2744   c7->SetHighLightColor(10); c7->Divide(2,1);
2745   c7->cd(1)->SetBottomMargin(0.2); c7->cd(1)->SetLeftMargin(0.2);
2746   c7->cd(1)->SetLogy();
2747   hEmpty->GetXaxis()->SetTitle("#sigma_{y} [cm]");
2748   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2749   hEmpty->SetTitle("Protons");
2750   hEmpty->DrawCopy();
2751   gCutListHistograms[24]->Draw("ESAME");
2752   gCutListHistograms[26]->Draw("ESAME");
2753   c7->cd(2)->SetBottomMargin(0.2); c7->cd(2)->SetLeftMargin(0.2);
2754   c7->cd(2)->SetLogy();
2755   hEmpty->GetXaxis()->SetTitle("#sigma_{y} [cm]");
2756   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2757   hEmpty->SetTitle("Antiprotons");
2758   hEmpty->DrawCopy();
2759   gCutListHistograms[25]->Draw("ESAME");
2760   gCutListHistograms[27]->Draw("ESAME");
2761   c7->SaveAs("Cov11.gif");
2762
2763   TCanvas *c8 = new TCanvas("c8","Covariance matrix 22",350,350,650,350);
2764   c8->SetFillColor(10); c8->GetFrame()->SetFillColor(10);
2765   c8->SetHighLightColor(10); c8->Divide(2,1);
2766   c8->cd(1)->SetBottomMargin(0.2); c8->cd(1)->SetLeftMargin(0.2);
2767   c8->cd(1)->SetLogy();
2768   hEmpty->GetXaxis()->SetTitle("#sigma_{z} [cm]");
2769   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2770   hEmpty->SetTitle("Protons");
2771   hEmpty->DrawCopy();
2772   gCutListHistograms[28]->Draw("ESAME");
2773   gCutListHistograms[30]->Draw("ESAME");
2774   c8->cd(2)->SetBottomMargin(0.2); c8->cd(2)->SetLeftMargin(0.2);
2775   c8->cd(2)->SetLogy();
2776   hEmpty->GetXaxis()->SetTitle("#sigma_{z} [cm]");
2777   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2778   hEmpty->SetTitle("Antiprotons");
2779   hEmpty->DrawCopy();
2780   gCutListHistograms[29]->Draw("ESAME");
2781   gCutListHistograms[31]->Draw("ESAME");
2782   c8->SaveAs("Cov22.gif");
2783
2784   TCanvas *c9 = new TCanvas("c9","Covariance matrix 33",400,400,650,350);
2785   c9->SetFillColor(10); c9->GetFrame()->SetFillColor(10);
2786   c9->SetHighLightColor(10); c9->Divide(2,1);
2787   c9->cd(1)->SetBottomMargin(0.2); c9->cd(1)->SetLeftMargin(0.2);
2788   c9->cd(1)->SetLogy();
2789   hEmpty->GetXaxis()->SetTitle("#sigma_{sin(#phi)}");
2790   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2791   hEmpty->SetTitle("Protons");
2792   hEmpty->DrawCopy();
2793   gCutListHistograms[32]->Draw("ESAME");
2794   gCutListHistograms[34]->Draw("ESAME");
2795   c9->cd(2)->SetBottomMargin(0.2); c9->cd(2)->SetLeftMargin(0.2);
2796   c9->cd(2)->SetLogy();
2797   hEmpty->GetXaxis()->SetTitle("#sigma_{sin(#phi)}");
2798   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2799   hEmpty->SetTitle("Antiprotons");
2800   hEmpty->DrawCopy();
2801   gCutListHistograms[33]->Draw("ESAME");
2802   gCutListHistograms[35]->Draw("ESAME");
2803   c9->SaveAs("Cov33.gif");
2804
2805   TCanvas *c10 = new TCanvas("c10","Covariance matrix 44",450,450,650,350);
2806   c10->SetFillColor(10); c10->GetFrame()->SetFillColor(10);
2807   c10->SetHighLightColor(10); c10->Divide(2,1);
2808   c10->cd(1)->SetBottomMargin(0.2); c10->cd(1)->SetLeftMargin(0.2);
2809   c10->cd(1)->SetLogy();
2810   hEmpty->GetXaxis()->SetTitle("#sigma_{tan(#lambda)}");
2811   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2812   hEmpty->SetTitle("Protons");
2813   hEmpty->DrawCopy();
2814   gCutListHistograms[36]->Draw("ESAME");
2815   gCutListHistograms[38]->Draw("ESAME");
2816   c10->cd(2)->SetBottomMargin(0.2); c10->cd(2)->SetLeftMargin(0.2);
2817   c10->cd(2)->SetLogy();
2818   hEmpty->GetXaxis()->SetTitle("#sigma_{tan(#lambda)}");
2819   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2820   hEmpty->SetTitle("Antiprotons");
2821   hEmpty->DrawCopy();
2822   gCutListHistograms[37]->Draw("ESAME");
2823   gCutListHistograms[39]->Draw("ESAME");
2824   c10->SaveAs("Cov44.gif");
2825
2826   TCanvas *c11 = new TCanvas("c11","Covariance matrix 55",500,500,650,350);
2827   c11->SetFillColor(10); c11->GetFrame()->SetFillColor(10);
2828   c11->SetHighLightColor(10); c11->Divide(2,1);
2829   c11->cd(1)->SetBottomMargin(0.2); c11->cd(1)->SetLeftMargin(0.2);
2830   c11->cd(1)->SetLogy();
2831   hEmpty->GetXaxis()->SetTitle("#sigma_{1/P_{T}} [GeV/c]^{-1}");
2832   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2833   hEmpty->SetTitle("Protons");
2834   hEmpty->DrawCopy();
2835   gCutListHistograms[40]->Draw("ESAME");
2836   gCutListHistograms[42]->Draw("ESAME");
2837   c11->cd(2)->SetBottomMargin(0.2); c11->cd(2)->SetLeftMargin(0.2);
2838   c11->cd(2)->SetLogy();
2839   hEmpty->GetXaxis()->SetTitle("#sigma_{1/P_{T}} [GeV/c]^{-1}");
2840   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2841   hEmpty->SetTitle("Antiprotons");
2842   hEmpty->DrawCopy();
2843   gCutListHistograms[41]->Draw("ESAME");
2844   gCutListHistograms[43]->Draw("ESAME");
2845   c11->SaveAs("Cov55.gif");
2846
2847   TCanvas *c12 = new TCanvas("c12","Number of TPC points (dE/dx)",550,550,650,350);
2848   c12->SetFillColor(10); c12->GetFrame()->SetFillColor(10);
2849   c12->SetHighLightColor(10); c12->Divide(2,1);
2850   c12->cd(1)->SetBottomMargin(0.2); c12->cd(1)->SetLeftMargin(0.2);
2851   c12->cd(1)->SetLogy();
2852   hEmpty->GetXaxis()->SetTitle("N_{points} (TPC-dE/dx");
2853   hEmpty->GetXaxis()->SetRangeUser(0.0,200.0);
2854   hEmpty->SetTitle("Protons");
2855   hEmpty->DrawCopy();
2856   gCutListHistograms[56]->Draw("ESAME");
2857   gCutListHistograms[58]->Draw("ESAME");
2858   c12->cd(2)->SetBottomMargin(0.2); c12->cd(2)->SetLeftMargin(0.2);
2859   c12->cd(2)->SetLogy();
2860   hEmpty->GetXaxis()->SetTitle("N_{points} (TPC-dE/dx");
2861   hEmpty->GetXaxis()->SetRangeUser(0.0,200.0);
2862   hEmpty->SetTitle("Antiprotons");
2863   hEmpty->DrawCopy();
2864   gCutListHistograms[57]->Draw("ESAME");
2865   gCutListHistograms[59]->Draw("ESAME");
2866   c12->SaveAs("Npoints-TPCdEdx.gif");
2867
2868
2869   //DCA cut parameters  
2870   TCanvas *c13 = new TCanvas("c13","DCA xy",600,600,650,350);
2871   c13->SetFillColor(10); c13->GetFrame()->SetFillColor(10);
2872   c13->SetHighLightColor(10); c13->Divide(2,1);
2873   c13->cd(1)->SetBottomMargin(0.2); c13->cd(1)->SetLeftMargin(0.2);
2874   c13->cd(1)->SetLogy();
2875   hEmpty->GetXaxis()->SetTitle("DCA_{xy} [cm]");
2876   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2877   hEmpty->SetTitle("Protons");
2878   hEmpty->DrawCopy();
2879   gDCAListHistograms[2]->Draw("ESAME");
2880   //gDCAListHistograms[2]->Fit("gDCA","","esame",0.1,12);
2881   gDCAListHistograms[0]->Draw("ESAME");
2882   c13->cd(2)->SetBottomMargin(0.15); c13->cd(2)->SetLeftMargin(0.15);
2883   c13->cd(2)->SetLogy();
2884   hEmpty->GetXaxis()->SetTitle("DCA_{xy} [cm]");
2885   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2886   hEmpty->SetTitle("Antiprotons");
2887   hEmpty->DrawCopy();
2888   gDCAListHistograms[1]->Draw("ESAME");
2889   gDCAListHistograms[3]->Draw("ESAME");
2890   c13->SaveAs("DCAxy.gif");
2891
2892   TCanvas *c14 = new TCanvas("c14","DCA z",650,650,650,350);
2893   c14->SetFillColor(10); c14->GetFrame()->SetFillColor(10);
2894   c14->SetHighLightColor(10); c14->Divide(2,1);
2895   c14->cd(1)->SetBottomMargin(0.2); c14->cd(1)->SetLeftMargin(0.2);
2896   c14->cd(1)->SetLogy();
2897   hEmpty->GetXaxis()->SetTitle("DCA_{z} [cm]");
2898   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2899   hEmpty->SetTitle("Protons");
2900   hEmpty->DrawCopy();
2901   gDCAListHistograms[4]->Draw("ESAME");
2902   gDCAListHistograms[6]->Draw("ESAME");
2903   //gDCAListHistograms[6]->Fit("gDCA","","esame",0.1,12);
2904   c14->cd(2)->SetBottomMargin(0.15); c14->cd(2)->SetLeftMargin(0.15);
2905   c14->cd(2)->SetLogy();
2906   hEmpty->GetXaxis()->SetTitle("DCA_{z} [cm]");
2907   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2908   hEmpty->SetTitle("Antiprotons");
2909   hEmpty->DrawCopy();
2910   gDCAListHistograms[5]->Draw("ESAME");
2911   gDCAListHistograms[7]->Draw("ESAME");
2912   c14->SaveAs("DCAz.gif");
2913
2914   TCanvas *c15 = new TCanvas("c15","Sigma to vertex",700,700,650,350);
2915   c15->SetFillColor(10); c15->GetFrame()->SetFillColor(10);
2916   c15->SetHighLightColor(10); c15->Divide(2,1);
2917   c15->cd(1)->SetBottomMargin(0.2); c15->cd(1)->SetLeftMargin(0.2);
2918   c15->cd(1)->SetLogy();
2919   hEmpty->GetXaxis()->SetTitle("N_{#sigma}(Vertex)");
2920   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2921   hEmpty->SetTitle("Protons");
2922   hEmpty->DrawCopy();
2923   gDCAListHistograms[8]->DrawCopy("ESAME");
2924   gDCAListHistograms[10]->DrawCopy("ESAME");
2925   c15->cd(2)->SetBottomMargin(0.15); c15->cd(2)->SetLeftMargin(0.15);
2926   c15->cd(2)->SetLogy();
2927   hEmpty->GetXaxis()->SetTitle("N_{#sigma}(Vertex)");
2928   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2929   hEmpty->SetTitle("Antiprotons");
2930   hEmpty->DrawCopy();
2931   gDCAListHistograms[9]->DrawCopy("ESAME");
2932   gDCAListHistograms[11]->DrawCopy("ESAME");
2933   c15->SaveAs("NSigmaToVertex.gif");
2934
2935   TCanvas *c16 = new TCanvas("c16","dca(xy) vs Pt",0,0,900,650);
2936   c16->SetFillColor(10); c16->GetFrame()->SetFillColor(10);
2937   c16->SetHighLightColor(10); c16->Divide(3,2);
2938   c16->cd(1)->SetBottomMargin(0.2); c16->cd(1)->SetLeftMargin(0.2);
2939   gDCAListHistograms3D[0]->SetTitle("Accepted primary protons");
2940   gDCAListHistograms3D[0]->Draw("");
2941   c16->cd(2)->SetBottomMargin(0.2); c16->cd(2)->SetLeftMargin(0.2);
2942   gDCAListHistograms3D[2]->SetTitle("Accepted secondary protons (weak decay)");
2943   gDCAListHistograms3D[2]->Draw("");
2944   c16->cd(3)->SetBottomMargin(0.2); c16->cd(3)->SetLeftMargin(0.2);
2945   gDCAListHistograms3D[4]->SetTitle("Accepted secondary protons (material)");
2946   gDCAListHistograms3D[4]->Draw("");
2947   c16->cd(4)->SetBottomMargin(0.2); c16->cd(4)->SetLeftMargin(0.2);
2948   gDCAListHistograms3D[1]->SetTitle("Accepted primary antiprotons");
2949   gDCAListHistograms3D[1]->Draw("");
2950   c16->cd(5)->SetBottomMargin(0.2); c16->cd(5)->SetLeftMargin(0.2);
2951   gDCAListHistograms3D[3]->SetTitle("Accepted secondary antiprotons (weak decay)");
2952   gDCAListHistograms3D[3]->Draw("");
2953   c16->cd(6)->SetBottomMargin(0.2); c16->cd(6)->SetLeftMargin(0.2);
2954   gDCAListHistograms3D[5]->SetTitle("Accepted secondary antiprotons (material)");
2955   gDCAListHistograms3D[5]->Draw("");
2956
2957   TCanvas *c17 = new TCanvas("c17","dca(z) vs Pt",100,100,900,650);
2958   c17->SetFillColor(10); c17->GetFrame()->SetFillColor(10);
2959   c17->SetHighLightColor(10); c17->Divide(3,2);
2960   c17->cd(1)->SetBottomMargin(0.2); c17->cd(1)->SetLeftMargin(0.2);
2961   gDCAListHistograms3D[6]->SetTitle("Accepted primary protons");
2962   gDCAListHistograms3D[6]->Draw("");
2963   c17->cd(2)->SetBottomMargin(0.2); c17->cd(2)->SetLeftMargin(0.2);
2964   gDCAListHistograms3D[8]->SetTitle("Accepted secondary protons (weak decay)");
2965   gDCAListHistograms3D[8]->Draw("");
2966   c17->cd(3)->SetBottomMargin(0.2); c17->cd(3)->SetLeftMargin(0.2);
2967   gDCAListHistograms3D[10]->SetTitle("Accepted secondary protons (material)");
2968   gDCAListHistograms3D[10]->Draw("");
2969   c17->cd(4)->SetBottomMargin(0.2); c17->cd(4)->SetLeftMargin(0.2);
2970   gDCAListHistograms3D[7]->SetTitle("Accepted primary antiprotons");
2971   gDCAListHistograms3D[7]->Draw("");
2972   c17->cd(5)->SetBottomMargin(0.2); c17->cd(5)->SetLeftMargin(0.2);
2973   gDCAListHistograms3D[9]->SetTitle("Accepted secondary antiprotons (weak decay)");
2974   gDCAListHistograms3D[9]->Draw("");
2975   c17->cd(6)->SetBottomMargin(0.2); c17->cd(6)->SetLeftMargin(0.2);
2976   gDCAListHistograms3D[11]->SetTitle("Accepted secondary antiprotons (material)");
2977   gDCAListHistograms3D[11]->Draw("");
2978
2979   drawDCAPlots(listDCA3D);
2980   f->Close();
2981 }
2982
2983 //________________________________________________//
2984 void drawDCAPlots(TList *listDCA3D) {
2985   //Draws the dca distributions for primaries and secondaries for each 
2986   //eta-pT bin
2987     TH3F *gDCAListHistograms3D[20];
2988   listDCA3D->ls();
2989   for(Int_t i = 0; i < listDCA3D->GetEntries(); i++) {
2990     gDCAListHistograms3D[i] = dynamic_cast<TH3F *>(listDCA3D->At(i));
2991     Printf("Name 3D: %s - Entries: %d",gDCAListHistograms3D[i]->GetName(),gDCAListHistograms3D[i]->GetEntries());
2992   }
2993   TCanvas *cDCAxy = new TCanvas("cDCAxy","",0,0,500,500);
2994   gDCAListHistograms3D[0]->ProjectionZ()->Draw();
2995   
2996 }
2997
2998 //________________________________________________//
2999 void draw2DEfficiency(const char *analysisMode = "TPC",
3000                       const char *pidMode = "Bayesian",
3001                       const char* projection = "yx") {
3002   gStyle->SetPalette(1,0);
3003   gStyle->SetCanvasColor(41);
3004   gStyle->SetFrameFillColor(10);
3005
3006   TString filename = "Protons.Efficiency.";filename += analysisMode; 
3007   filename += "."; filename += pidMode; filename += ".root";
3008   TFile *f = TFile::Open(filename.Data());
3009   TList *list = (TList *)f->Get("efficiencyList");
3010
3011   TH3D *gHistESDInitYPtProtons = (TH3D *)list->At(12);
3012   TH2D *gInit = (TH2D *)gHistESDInitYPtProtons->Project3D(projection);
3013   TH3D *gHistESDIdYPtProtons = (TH3D *)list->At(13);
3014   TH2D *gId = (TH2D *)gHistESDIdYPtProtons->Project3D(projection);
3015   gId->Divide(gInit);
3016   gId->Scale(100.);
3017   gId->GetZaxis()->SetTitle("#epsilon [%]");
3018
3019   TH2F *h = new TH2F("h","",100,-1,1,10000,0,210);
3020   h->SetStats(kFALSE);
3021
3022   switch(projection) {
3023     case "yx":
3024       gId->GetZaxis()->SetRangeUser(90,100);
3025       h->GetXaxis()->SetRangeUser(gHistESDInitYPtProtons->GetXaxis()->GetXmin(),
3026                                   gHistESDInitYPtProtons->GetXaxis()->GetXmax());
3027       h->GetYaxis()->SetRangeUser(gHistESDInitYPtProtons->GetYaxis()->GetXmin(),
3028                                   gHistESDInitYPtProtons->GetYaxis()->GetXmax());
3029       h->GetXaxis()->SetTitle(gId->GetXaxis()->GetTitle());
3030       h->GetYaxis()->SetTitle(gId->GetYaxis()->GetTitle());
3031       break;
3032     case "zx":
3033       gId->GetZaxis()->SetRangeUser(0,100);
3034       h->GetXaxis()->SetRangeUser(gHistESDInitYPtProtons->GetXaxis()->GetXmin(),
3035                                   gHistESDInitYPtProtons->GetXaxis()->GetXmax());
3036       h->GetYaxis()->SetRangeUser(gHistESDInitYPtProtons->GetZaxis()->GetXmin(),
3037                                   gHistESDInitYPtProtons->GetZaxis()->GetXmax());
3038       h->GetXaxis()->SetTitle(gId->GetXaxis()->GetTitle());
3039       h->GetYaxis()->SetTitle(gId->GetYaxis()->GetTitle());
3040       break;
3041     case "zy":
3042       gId->GetZaxis()->SetRangeUser(0,100);
3043       h->GetXaxis()->SetRangeUser(gHistESDInitYPtProtons->GetYaxis()->GetXmin(),
3044                                   gHistESDInitYPtProtons->GetYaxis()->GetXmax());
3045       h->GetYaxis()->SetRangeUser(gHistESDInitYPtProtons->GetZaxis()->GetXmin(),
3046                                   gHistESDInitYPtProtons->GetZaxis()->GetXmax());
3047       h->GetXaxis()->SetTitle(gId->GetXaxis()->GetTitle());
3048       h->GetYaxis()->SetTitle(gId->GetYaxis()->GetTitle());
3049       break;
3050   default:
3051     break;
3052   }
3053
3054   TCanvas *c = new TCanvas();
3055   c->SetRightMargin(0.15);
3056   h->DrawCopy();
3057   gId->DrawCopy("colzsame");
3058 }
3059
3060 //________________________________________________//
3061 void RescaleEtaHistogram(TH1 *h1, TH2 *h2) {
3062   //Rescales the histogram in eta or y 
3063   Int_t iBinCounter = 0;
3064   for(Int_t iBinX = 1; iBinX <= h2->GetNbinsX(); iBinX++) {
3065     iBinCounter = 0;
3066     for(Int_t iBinY = 1; iBinY <= h2->GetNbinsY(); iBinY++) {
3067       if(h2->GetBinContent(iBinX,iBinY) > 0) {
3068         iBinCounter += 1;
3069       }
3070     }
3071     h1->SetBinContent(iBinX,h1->GetBinContent(iBinX)/iBinCounter);
3072     h1->SetBinError(iBinX,h1->GetBinError(iBinX)/iBinCounter);
3073     //Printf("Bin: %d - e: %lf - error: %lf",iBinX,sum/iBinCounter,TMath::Sqrt(sumError)/iBinCounter);
3074   }
3075 }
3076
3077 //________________________________________________//
3078 void RescalePtHistogram(TH1 *h1, TH2 *h2) {
3079   //Rescales the histogram in pT
3080   Int_t iBinCounter = 0;
3081   for(Int_t iBinY = 1; iBinY <= h2->GetNbinsY(); iBinY++) {
3082     iBinCounter = 0;
3083     for(Int_t iBinX = 1; iBinX <= h2->GetNbinsX(); iBinX++) {
3084       if(h2->GetBinContent(iBinX,iBinY) > 0) {
3085         iBinCounter += 1;
3086       }
3087     }
3088     h1->SetBinContent(iBinY,h1->GetBinContent(iBinY)/iBinCounter);
3089     h1->SetBinError(iBinY,h1->GetBinError(iBinY)/iBinCounter);
3090     //Printf("Bin: %d - e: %lf - error: %lf",iBinX,sum/iBinCounter,TMath::Sqrt(sumError)/iBinCounter);
3091   }
3092 }
3093