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