]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/drawProtonQAResults.C
fix coding violations
[u/mrichter/AliRoot.git] / PWG2 / drawProtonQAResults.C
1 void drawProtonQAResults(const char *analysisType = "TPC") {
2   //Macro to visualize the results of the proton QA task
3   //TCanvas objects: 20
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; filename1 += ".root";
12   TString filename2 = "Protons.MC.QA.";
13   filename2 += analysisType; filename2 += ".root";
14   TString filename3 = "Protons.Efficiency.";
15   filename3 += analysisType; filename3 += ".root";
16   
17   TFile *fQA = TFile::Open(filename1.Data());
18   TList *listGlobalQA = (TList *)fQA->Get("globalQAList");
19   drawCutStatistics(listGlobalQA,analysisType);
20   fQA->Close();
21  
22   TFile *fMC = TFile::Open(filename2.Data());
23   TList *listPDG = (TList *)fMC->Get("pdgCodeList");  
24   TList *listMCProcesses = (TList *)fMC->Get("mcProcessList");  
25   drawMCQA(listPDG,listMCProcesses);
26   fMC->Close();
27   
28   TFile *fEfficiency = TFile::Open(filename3.Data());
29   TList *listEfficiency = (TList *)fEfficiency->Get("efficiencyList");
30   drawEfficiency(listEfficiency,analysisType);
31   fEfficiency->Close();
32
33   TFile *fVertex = TFile::Open("Vertex.QA.root");
34   TList *listVertex = (TList *)fVertex->Get("vertexList");
35   drawVertexQA(listVertex);
36   fVertex->Close();
37 }
38
39 //________________________________________//
40 void PrintHelpMenu() {
41   //Function that prints the different possibilities the user has 
42   //with this macro (what to display, what is the input etc)
43   Printf("==============================HELP MENU===========================");
44   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:");
45   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.");
46   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.");
47   Printf("\t 3. The ITS cluster map for primary and secondary (anti)protons.");
48   Printf("\t 4. The (anti)proton purity and contamination as a function of eta or y.");
49   Printf("\t 5. The (anti)proton purity and contamination as a function of Pt.");
50   Printf("\t 6. The (anti)proton cut efficiency as a function of eta or y.");
51   Printf("\t 7. The (anti)proton cut efficiency as a function of Pt.");
52   Printf("\t 8. The composition of accepted secondary (anti)protons as a function of eta or y.");
53   Printf("\t 9. The composition of accepted secondary (anti)protons as a function of Pt.");
54   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.***");
55
56   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:");
57   Printf("\t 1. MC composition of secondary protons as a function of either eta or y.");
58   Printf("\t 2. MC composition of secondary antiprotons as a function of either eta or y.");
59   Printf("\t 3. MC composition of secondary protons as a function of Pt.");
60   Printf("\t 4. MC composition of secondary antiprotons as a function of Pt");
61
62   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:");
63   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.");
64   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.");
65   Printf("\t 3. Particle identifiction efficiencies for (anti)protons as a function of either eta or y and of Pt.");
66   Printf("\t ***This function produces an output root file with the name Reconstruction-PID-Efficiency.root with all the efficiency and contamination plots.***");
67
68   Printf("\nFunction drawVertexQA: Takes as an argument the list obtained from the Vertex.QA.root file holding pure vertex information. Displays the following plots:");
69   Printf("\t 1. The vertex efficiencies for the TPC, SPD and track ones.");
70   Printf("\t 2. The QA plots for the TPC vertex.");
71   Printf("\t 3. The QA plots for the SPD vertex.");
72   Printf("\t 4. The QA plots for the tracks vertex.");
73
74   Printf("\nFunction drawKineQA: Takes as an argument the file Protons.QA.Histograms.root with all the histograms about kinematic or not variables");
75   Printf("\t 1. The phi vs eta correlation plots for primary and secondary (anti)protons.");
76   Printf("\t 2. The Nclusters TPC vs eta correlation plots for primary and secondary (anti)protons.");
77   Printf("\t 3. The Nclusters TPC vs phi correlation plots for primary and secondary (anti)protons.");
78
79  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:");
80   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.");
81   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.");
82   Printf("\t 3. Particle identifiction efficiencies for (anti)protons as a function of either eta or y and of Pt.");
83
84  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:");
85   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.");
86   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.");
87   Printf("==================================================================\n\n\n");
88 }
89
90 //________________________________________//
91 void drawCutStatistics(TList *list,
92                        const char* analysisType) {
93   //Function to display the statistics from the cuts
94   //The histogram shows the influence of each cut on the primary
95   //and secondary (anti)protons
96   const Int_t NQAHISTOSPERLIST = 26;
97
98   Double_t gEntriesQA2DList[12] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
99   Double_t gEntriesQAPrimaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryProtonsRejectedList[NQAHISTOSPERLIST];
100   Double_t gEntriesQASecondaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryProtonsRejectedList[NQAHISTOSPERLIST];
101   Double_t gEntriesQAPrimaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
102   Double_t gEntriesQASecondaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
103
104   for(Int_t i = 0; i < NQAHISTOSPERLIST; i++) {
105     gEntriesQAPrimaryProtonsAcceptedList[i] = 0.0;
106     gEntriesQAPrimaryProtonsRejectedList[i] = 0.0;
107     gEntriesQASecondaryProtonsAcceptedList[i] = 0.0;
108     gEntriesQASecondaryProtonsRejectedList[i] = 0.0;
109     gEntriesQAPrimaryAntiProtonsAcceptedList[i] = 0.0;
110     gEntriesQAPrimaryAntiProtonsRejectedList[i] = 0.0;
111     gEntriesQASecondaryAntiProtonsAcceptedList[i] = 0.0;
112     gEntriesQASecondaryAntiProtonsRejectedList[i] = 0.0;
113   }
114
115   TList *fQA2DList = (TList *)list->At(0);
116   GetQAEntries(fQA2DList,gEntriesQA2DList);
117   TH3F *gHistYPtPDGProtonsPass = (TH3F *)fQA2DList->At(10);
118   TH3F *gHistYPtPDGAntiProtonsPass = (TH3F *)fQA2DList->At(11);
119  
120   TList *fQAPrimaryProtonsAcceptedList = (TList *)list->At(1);
121   GetQAEntries(fQAPrimaryProtonsAcceptedList,gEntriesQAPrimaryProtonsAcceptedList);
122
123   TList *fQAPrimaryProtonsRejectedList = (TList *)list->At(2);
124   GetQAEntries(fQAPrimaryProtonsRejectedList,gEntriesQAPrimaryProtonsRejectedList);
125
126   TList *fQASecondaryProtonsAcceptedList = (TList *)list->At(3);
127   GetQAEntries(fQASecondaryProtonsAcceptedList,gEntriesQASecondaryProtonsAcceptedList);
128
129   TList *fQASecondaryProtonsRejectedList = (TList *)list->At(4);
130   GetQAEntries(fQASecondaryProtonsRejectedList,gEntriesQASecondaryProtonsRejectedList);
131
132   TList *fQAPrimaryAntiProtonsAcceptedList = (TList *)list->At(5);
133   GetQAEntries(fQAPrimaryAntiProtonsAcceptedList,gEntriesQAPrimaryAntiProtonsAcceptedList);
134
135   TList *fQAPrimaryAntiProtonsRejectedList = (TList *)list->At(6);
136   GetQAEntries(fQAPrimaryAntiProtonsRejectedList,gEntriesQAPrimaryAntiProtonsRejectedList);
137
138   TList *fQASecondaryAntiProtonsAcceptedList = (TList *)list->At(7);
139   GetQAEntries(fQASecondaryAntiProtonsAcceptedList,gEntriesQASecondaryAntiProtonsAcceptedList);
140
141   TList *fQASecondaryAntiProtonsRejectedList = (TList *)list->At(8);
142   GetQAEntries(fQASecondaryAntiProtonsRejectedList,gEntriesQASecondaryAntiProtonsRejectedList);
143
144   //_______________________________________________________//
145   //Create the histograms
146   const Int_t nx = 26;
147   char *fCutName[nx] = {"Tracks","",
148                         "ITS Clusters",
149                         "#chi^{2}/N_{ITS-Clusters}",
150                         "TPC Clusters",
151                         "#chi^{2}/N_{TPC-Clusters}",
152                         "ExtCov11",
153                         "ExtCov22",
154                         "ExtCov33",
155                         "ExtCov44",
156                         "ExtCov55",
157                         "#sigma_{Vertex}",
158                         "#sigma_{Vertex-TPC}",
159                         "DCA_{xy}",
160                         "DCA_{xy}(TPC)",
161                         "DCA_{z}",
162                         "DCA_{z}(TPC)",
163                         "#chi^{2}(vertex)",
164                         "ITS refit",
165                         "TPC refit",
166                         "ESD pid",
167                         "TPC pid","",
168                         "N_{Secondaries}/N_{total}","",""};
169   char *fCutITSName[6] = {"SPD_{1}","SPD_{2}",
170                           "SDD_{1}","SDD_{2}",
171                           "SSD_{1}","SSD_{2}"};
172
173   //cut influence
174   TH2F *hEmpty = new TH2F("hEmpty","",nx,0,nx,100,0,100); 
175   hEmpty->SetStats(kFALSE); 
176   hEmpty->SetMarkerStyle(kFullCircle);
177   hEmpty->SetLineColor(2); hEmpty->SetMarkerColor(2);
178   hEmpty->GetYaxis()->SetTitle("Influence of the cuts [%]");
179   for(Int_t i = 1; i <= nx; i++) 
180     hEmpty->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
181   hEmpty->GetXaxis()->SetLabelOffset(0.01); 
182   hEmpty->GetXaxis()->SetLabelSize(0.045);
183
184   //primary protons
185   TH1F *hPrimaryProtons = new TH1F("hPrimaryProtons","",nx,0,nx); 
186   hPrimaryProtons->SetStats(kFALSE); 
187   hPrimaryProtons->SetMarkerStyle(kFullCircle);
188   hPrimaryProtons->SetLineColor(4); hPrimaryProtons->SetLineWidth(2); 
189   hPrimaryProtons->SetMarkerColor(4);
190   hPrimaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
191   for(Int_t i = 1; i <= nx; i++) {
192     hPrimaryProtons->SetBinContent(i,-10.);
193     hPrimaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
194   }
195   hPrimaryProtons->GetXaxis()->SetLabelOffset(0.01); 
196   hPrimaryProtons->GetXaxis()->SetLabelSize(0.045);
197
198   //secondary protons
199   TH1F *hSecondaryProtons = new TH1F("hSecondaryProtons","",nx,0,nx); 
200   hSecondaryProtons->SetStats(kFALSE); 
201   hSecondaryProtons->SetMarkerStyle(22);
202   hSecondaryProtons->SetMarkerSize(1.4);
203   hSecondaryProtons->SetLineColor(2); hSecondaryProtons->SetLineWidth(2); 
204   hSecondaryProtons->SetMarkerColor(2);
205   hSecondaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
206   for(Int_t i = 1; i <= nx; i++) {
207     hSecondaryProtons->SetBinContent(i,-10.);
208     hSecondaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
209   }
210   hSecondaryProtons->GetXaxis()->SetLabelOffset(0.01); 
211   hSecondaryProtons->GetXaxis()->SetLabelSize(0.045);
212
213   //primary antiprotons
214   TH1F *hPrimaryAntiProtons = new TH1F("hPrimaryAntiProtons","",nx,0,nx); 
215   hPrimaryAntiProtons->SetStats(kFALSE); 
216   hPrimaryAntiProtons->SetMarkerStyle(kFullCircle);
217   hPrimaryAntiProtons->SetLineColor(4); hPrimaryAntiProtons->SetLineWidth(2); 
218   hPrimaryAntiProtons->SetMarkerColor(4);
219   hPrimaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
220   for(Int_t i = 1; i <= nx; i++) {
221     hPrimaryAntiProtons->SetBinContent(i,-10.);
222     hPrimaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
223   }
224   hPrimaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
225   hPrimaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
226
227   //secondary antiprotons
228   TH1F *hSecondaryAntiProtons = new TH1F("hSecondaryAntiProtons","",nx,0,nx); 
229   hSecondaryAntiProtons->SetStats(kFALSE); 
230   hSecondaryAntiProtons->SetMarkerStyle(22);
231   hSecondaryAntiProtons->SetMarkerSize(1.4);
232   hSecondaryAntiProtons->SetLineColor(2); hSecondaryAntiProtons->SetLineWidth(2); 
233   hSecondaryAntiProtons->SetMarkerColor(2);
234   hSecondaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
235   for(Int_t i = 1; i <= nx; i++) {
236     hSecondaryAntiProtons->SetBinContent(i,-10.);
237     hSecondaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
238   }
239   hSecondaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
240   hSecondaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
241   //_______________________________________________________//
242
243   //1D for primary protons
244   //cout<<"_____________________________________________________"<<endl;
245   //cout<<"_______________PRIMARY PROTONS_______________________"<<endl;
246   hPrimaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[1]));
247
248   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
249     hPrimaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryProtonsAcceptedList[i-2],
250                                                      gEntriesQAPrimaryProtonsRejectedList[i-2]));
251   
252   //1D for secondary protons
253   //cout<<"_____________________________________________________"<<endl;
254   //cout<<"_______________SECONDARY PROTONS_____________________"<<endl;
255   hSecondaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[2],gEntriesQA2DList[3]));
256   
257   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
258     hSecondaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryProtonsAcceptedList[i-2],
259                                                        gEntriesQASecondaryProtonsRejectedList[i-2]));
260   hSecondaryProtons->SetBinContent(24,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[2]));
261
262   //1D for primary antiprotons
263   //cout<<"_________________________________________________________"<<endl;
264   //cout<<"_______________PRIMARY ANTIPROTONS_______________________"<<endl;
265   hPrimaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[5]));
266   
267   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
268     hPrimaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryAntiProtonsAcceptedList[i-2],
269                                                          gEntriesQAPrimaryAntiProtonsRejectedList[i-2]));
270   
271   //1D for secondary antiprotons
272   //cout<<"_________________________________________________________"<<endl;
273   //cout<<"_______________SECONDARY ANTIPROTONS_____________________"<<endl;
274   hSecondaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[6],gEntriesQA2DList[7]));
275
276   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
277     hSecondaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryAntiProtonsAcceptedList[i-2],
278                                                            gEntriesQASecondaryAntiProtonsRejectedList[i-2]));
279   hSecondaryAntiProtons->SetBinContent(24,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[6]));
280
281   TLatex *t1 = new TLatex();
282   t1->SetTextSize(0.04);
283   //_________________________________________________________//
284   TCanvas *c1 = new TCanvas("c1","Cut Influence - Protons",0,0,700,400);
285   c1->SetHighLightColor(10); c1->SetBottomMargin(0.15);
286   c1->SetGridx(); c1->SetGridy();
287
288   for(Int_t i = 1; i <= nx; i++) {
289     hPrimaryProtons->SetBinError(i,1.0);
290     hSecondaryProtons->SetBinError(i,1.0);
291   }
292   hEmpty->DrawCopy();
293   hPrimaryProtons->DrawCopy("EHISTSAME");
294   hSecondaryProtons->DrawCopy("EHISTSAME");
295   DrawMarker(20.5, 90, 20, 1.2, 4);
296   t1->DrawLatex(21,88,"Primary p");
297   DrawMarker(20.5, 80, 22, 1.2, 2);
298   t1->DrawLatex(21,78,"Secondary p");
299
300   c1->SaveAs("CutInfluence-Protons.gif");
301
302   //_________________________________________________________//
303   TCanvas *c2 = new TCanvas("c2","Cut Influence - AntiProtons",50,50,700,400);
304   c2->SetHighLightColor(10); c2->SetBottomMargin(0.15);
305   c2->SetGridx(); c2->SetGridy();
306
307   for(Int_t i = 1; i <= nx; i++) {
308     hPrimaryAntiProtons->SetBinError(i,1.0);
309     hSecondaryAntiProtons->SetBinError(i,1.0);
310   }
311   hEmpty->DrawCopy();
312   hPrimaryAntiProtons->DrawCopy("EHISTSAME");
313   hSecondaryAntiProtons->DrawCopy("EHISTSAME");
314   DrawMarker(20.5, 90, 20, 1.2, 4);
315   t1->DrawLatex(21,88,"Primary #bar{p}");
316   DrawMarker(20.5, 80, 22, 1.2, 2);
317   t1->DrawLatex(21,78,"Secondary #bar{p}");
318
319   c2->SaveAs("CutInfluence-AntiProtons.gif");
320
321   //_________________________________________________________//
322   //ITS layers influence
323   TH2F *hEmptyITS = new TH2F("hEmptyITS","",10,0,10,100,0,100); 
324   hEmptyITS->SetStats(kFALSE); 
325   hEmptyITS->SetMarkerStyle(kFullCircle);
326   hEmptyITS->SetLineColor(2); hEmptyITS->SetMarkerColor(2);
327   hEmptyITS->GetYaxis()->SetTitle("Influence of the ITS layers [%]");
328   hEmptyITS->GetYaxis()->SetTitleOffset(1.3);
329   for(Int_t i = 1; i <= 6; i++) 
330     hEmptyITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
331   hEmptyITS->GetXaxis()->SetLabelOffset(0.01); 
332   hEmptyITS->GetXaxis()->SetLabelSize(0.045);
333
334   //_________________________________________________________//
335   //primary protons
336   TH1F *hPrimaryProtonsITS = new TH1F("hPrimaryProtonsITS","",7,0,7); 
337   hPrimaryProtonsITS->SetStats(kFALSE); 
338   hPrimaryProtonsITS->SetMarkerStyle(kFullCircle);
339   hPrimaryProtonsITS->SetLineColor(4); hPrimaryProtonsITS->SetLineWidth(2); 
340   hPrimaryProtonsITS->SetMarkerColor(4);
341   hPrimaryProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
342   for(Int_t i = 1; i <= 6; i++) {
343     hPrimaryProtonsITS->SetBinContent(i,-10.);
344     hPrimaryProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
345   }
346   hPrimaryProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
347   hPrimaryProtonsITS->GetXaxis()->SetLabelSize(0.045);
348
349   //secondary protons
350   TH1F *hSecondaryProtonsITS = new TH1F("hSecondaryProtonsITS","",7,0,7); 
351   hSecondaryProtonsITS->SetStats(kFALSE); 
352   hSecondaryProtonsITS->SetMarkerStyle(22);
353   hSecondaryProtonsITS->SetMarkerSize(1.4);
354   hSecondaryProtonsITS->SetLineColor(2); hSecondaryProtonsITS->SetLineWidth(2); 
355   hSecondaryProtonsITS->SetMarkerColor(2);
356   hSecondaryProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
357   for(Int_t i = 1; i <= 6; i++) {
358     hSecondaryProtonsITS->SetBinContent(i,-10.);
359     hSecondaryProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
360   }
361   hSecondaryProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
362   hSecondaryProtonsITS->GetXaxis()->SetLabelSize(0.045);
363
364   //primary antiprotons
365   TH1F *hPrimaryAntiProtonsITS = new TH1F("hPrimaryAntiProtonsITS","",7,0,7); 
366   hPrimaryAntiProtonsITS->SetStats(kFALSE); 
367   hPrimaryAntiProtonsITS->SetMarkerStyle(kFullCircle);
368   hPrimaryAntiProtonsITS->SetLineColor(4); hPrimaryAntiProtonsITS->SetLineWidth(2); 
369   hPrimaryAntiProtonsITS->SetMarkerColor(4);
370   hPrimaryAntiProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
371   for(Int_t i = 1; i <= 6; i++) {
372     hPrimaryAntiProtonsITS->SetBinContent(i,-10.);
373     hPrimaryAntiProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
374   }
375   hPrimaryAntiProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
376   hPrimaryAntiProtonsITS->GetXaxis()->SetLabelSize(0.045);
377
378   //secondary antiprotons
379   TH1F *hSecondaryAntiProtonsITS = new TH1F("hSecondaryAntiProtonsITS","",7,0,7); 
380   hSecondaryAntiProtonsITS->SetStats(kFALSE); 
381   hSecondaryAntiProtonsITS->SetMarkerStyle(22);
382   hSecondaryAntiProtonsITS->SetMarkerSize(1.4);
383   hSecondaryAntiProtonsITS->SetLineColor(2); hSecondaryAntiProtonsITS->SetLineWidth(2); 
384   hSecondaryAntiProtonsITS->SetMarkerColor(2);
385   hSecondaryAntiProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
386   for(Int_t i = 1; i <= 6; i++) {
387     hSecondaryAntiProtonsITS->SetBinContent(i,-10.);
388     hSecondaryAntiProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
389   }
390   hSecondaryAntiProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
391   hSecondaryAntiProtonsITS->GetXaxis()->SetLabelSize(0.045);
392
393   //_______________________________________________________//
394   TCanvas *c9 = new TCanvas("c9","ITS cluster map - (anti)protons",
395                             100,100,700,400);
396   c9->SetHighLightColor(10); c9->Divide(2,1);
397   for(Int_t i = 1; i <= 6; i++) {
398     hPrimaryProtonsITS->SetBinError(i,1.0);
399     hSecondaryProtonsITS->SetBinError(i,1.0);
400     hPrimaryAntiProtonsITS->SetBinError(i,1.0);
401     hSecondaryAntiProtonsITS->SetBinError(i,1.0);
402   }
403   c9->cd(1)->SetBottomMargin(0.15);
404   c9->cd(1)->SetLeftMargin(0.15);
405   c9->cd(1)->SetGridx(); c9->cd(1)->SetGridy();
406   hEmptyITS->SetTitle("Protons");
407   hEmptyITS->DrawCopy();
408
409   for(Int_t i = 1; i < 7; i++) {
410     hPrimaryProtonsITS->SetBinContent(i,GetPercentage(gEntriesQAPrimaryProtonsAcceptedList[19+i],
411                                                       gEntriesQAPrimaryProtonsRejectedList[19+i]));
412     hSecondaryProtonsITS->SetBinContent(i,GetPercentage(gEntriesQASecondaryProtonsAcceptedList[19+i],
413                                                         gEntriesQASecondaryProtonsRejectedList[19+i]));
414   }
415   hPrimaryProtonsITS->DrawCopy("EHISTSAME");
416   hSecondaryProtonsITS->DrawCopy("EHISTSAME");
417   DrawMarker(6.5, 90, 20, 1.2, 4);
418   t1->DrawLatex(7,88,"Primary p");
419   DrawMarker(6.5, 80, 22, 1.2, 2);
420   t1->DrawLatex(7,78,"Secondary p");
421
422   c9->cd(2)->SetBottomMargin(0.15);
423   c9->cd(2)->SetLeftMargin(0.15);
424   c9->cd(2)->SetGridx(); c9->cd(2)->SetGridy();
425   hEmptyITS->SetTitle("Antiprotons");
426   hEmptyITS->DrawCopy();
427   for(Int_t i = 1; i < 7; i++) {
428     hPrimaryAntiProtonsITS->SetBinContent(i,GetPercentage(gEntriesQAPrimaryAntiProtonsAcceptedList[19+i],
429                                                           gEntriesQAPrimaryAntiProtonsRejectedList[19+i]));
430     hSecondaryAntiProtonsITS->SetBinContent(i,GetPercentage(gEntriesQASecondaryAntiProtonsAcceptedList[19+i],
431                                                             gEntriesQASecondaryAntiProtonsRejectedList[19+i]));
432   }
433   hPrimaryAntiProtonsITS->DrawCopy("EHISTSAME");
434   hSecondaryAntiProtonsITS->DrawCopy("EHISTSAME");
435   DrawMarker(6.5, 90, 20, 1.2, 4);
436   t1->DrawLatex(7,88,"Primary #bar{p}");
437   DrawMarker(6.5, 80, 22, 1.2, 2);
438   t1->DrawLatex(7,78,"Secondary #bar{p}");
439
440   c9->SaveAs("CutInfluence-ITS.gif");
441   
442   //Efficiency - Contamination plots
443   DrawContamination(fQA2DList,analysisType);
444   DrawCutEfficiency(fQA2DList,analysisType);
445   DrawComposition(gHistYPtPDGProtonsPass,gHistYPtPDGAntiProtonsPass);
446 }
447
448 //________________________________________//
449 void DrawComposition(TH3F *gHistYPtPDGProtons,
450                      TH3F *gHistYPtPDGAntiProtons) {
451   //Function to display the composition of secondary (anti)protons
452   //that survive the quality criteria
453   Double_t nParticleCompositionProtonY[200], nParticleCompositionProtonPt[200];
454   Double_t nParticleCompositionProtonYError[200], nParticleCompositionProtonPtError[200];
455   Double_t nParticleCompositionAntiProtonY[200], nParticleCompositionAntiProtonPt[200];
456   Double_t nParticleCompositionAntiProtonYError[200], nParticleCompositionAntiProtonPtError[200];
457   Double_t gY[200], gPt[200];
458   Double_t gYError[200], gPtError[200];
459   for(Int_t iBins = 0; iBins < 200; iBins++) {
460     nParticleCompositionProtonY[iBins] = 0;
461     nParticleCompositionProtonPt[iBins] = 0;
462     nParticleCompositionProtonYError[iBins] = 0;
463     nParticleCompositionProtonPtError[iBins] = 0;
464     nParticleCompositionAntiProtonY[iBins] = 0;
465     nParticleCompositionAntiProtonPt[iBins] = 0;
466     nParticleCompositionAntiProtonYError[iBins] = 0;
467     nParticleCompositionAntiProtonPtError[iBins] = 0;
468     gY[iBins] = 0;
469     gPt[iBins] = 0;
470     gYError[iBins] = 0;
471     gPtError[iBins] = 0;
472   }
473   
474   TGraphErrors *gParticleProtonY[14];
475   TGraphErrors *gParticleProtonPt[14];
476   TGraphErrors *gParticleAntiProtonY[14];
477   TGraphErrors *gParticleAntiProtonPt[14];
478   for(Int_t iParticle = 0; iParticle < 14; iParticle++) {
479     GetComposition(iParticle,
480                    gHistYPtPDGProtons,
481                    nParticleCompositionProtonY,nParticleCompositionProtonYError,gY, gYError,
482                    nParticleCompositionProtonPt, nParticleCompositionProtonPtError, gPt, gPtError);
483     gParticleProtonY[iParticle] = new TGraphErrors(gHistYPtPDGProtons->GetNbinsX(),
484                                                   gY,nParticleCompositionProtonY,gYError,nParticleCompositionProtonYError);
485     gParticleProtonY[iParticle]->SetMarkerStyle(iParticle+20);
486     gParticleProtonY[iParticle]->SetMarkerSize(1.2);
487
488     gParticleProtonPt[iParticle] = new TGraphErrors(gHistYPtPDGProtons->GetNbinsY(),
489                                                    gPt,nParticleCompositionProtonPt,gPtError,nParticleCompositionProtonPtError);
490     gParticleProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
491     gParticleProtonPt[iParticle]->SetMarkerSize(1.2);
492
493     GetComposition(iParticle,
494                    gHistYPtPDGAntiProtons,
495                    nParticleCompositionAntiProtonY,nParticleCompositionAntiProtonYError,gY, gYError, 
496                    nParticleCompositionAntiProtonPt, nParticleCompositionAntiProtonPtError, gPt, gPtError);
497     gParticleAntiProtonY[iParticle] = new TGraphErrors(gHistYPtPDGAntiProtons->GetNbinsX(),
498                                                       gY,nParticleCompositionAntiProtonY,gYError,nParticleCompositionAntiProtonYError);
499     gParticleAntiProtonY[iParticle]->SetMarkerStyle(iParticle+20);
500     gParticleAntiProtonY[iParticle]->SetMarkerSize(1.2);
501
502     gParticleAntiProtonPt[iParticle] = new TGraphErrors(gHistYPtPDGAntiProtons->GetNbinsY(),
503                                                        gPt,nParticleCompositionAntiProtonPt,gPtError,nParticleCompositionAntiProtonPtError);
504     gParticleAntiProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
505     gParticleAntiProtonPt[iParticle]->SetMarkerSize(1.2);
506   }
507
508   //_________________________________________________________//
509   char *fParticleName[14] = {"Primary","K_{L}","#pi","K_{S}","K",
510                              "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
511                              "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
512   TLatex *t1 = new TLatex();
513   t1->SetTextSize(0.04);
514
515   TH2F *hEmptyY = new TH2F("hEmptyY","",100,-1.2,1.2,100,0,120); 
516   hEmptyY->SetStats(kFALSE); 
517   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
518   hEmptyY->GetXaxis()->SetTitle(gHistYPtPDGProtons->GetXaxis()->GetTitle());
519
520   TCanvas *c12 = new TCanvas("c12",
521                              "Composition of accepted secondaries vs y",
522                              350,350,700,400);
523   c12->Divide(2,1);
524   c12->SetHighLightColor(10); c12->cd(1)->SetBottomMargin(0.15);
525   c12->cd(1)->SetGridx(); c12->cd(1)->SetGridy();
526   hEmptyY->SetTitle("Protons");
527   hEmptyY->DrawCopy();
528   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
529     //if((iParticle == 0)||(iParticle == 2)||(iParticle == 5)||(iParticle == 6)||(iParticle == 8))
530     if((iParticle == 2)||(iParticle == 6)||(iParticle == 8)) {
531       gParticleProtonY[iParticle]->Draw("P");
532       //if(iParticle < 5) {
533       //DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
534       //t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
535     }
536     /*else {
537       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
538       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
539       }*/
540   }
541   DrawMarker(0.0, 115, 22, 1.2, 1);
542   t1->DrawLatex(0.1,113,fParticleName[2]);
543   DrawMarker(0.0, 105, 26, 1.2, 1);
544   t1->DrawLatex(0.1,103,fParticleName[6]);
545   DrawMarker(0.0, 95, 28, 1.2, 1);
546   t1->DrawLatex(0.1,93,fParticleName[8]);
547
548   c12->SetHighLightColor(10); c12->cd(2)->SetBottomMargin(0.15);
549   c12->cd(2)->SetGridx(); c12->cd(2)->SetGridy();
550   hEmptyY->SetTitle("Antiprotons");
551   hEmptyY->DrawCopy();
552   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
553     if((iParticle == 6)||(iParticle == 8))
554       gParticleAntiProtonY[iParticle]->Draw("P");
555     /*if(iParticle < 5) {
556       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
557       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
558     }
559     else {
560       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
561       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
562       }*/
563   }
564   DrawMarker(0.0, 115, 26, 1.2, 1);
565   t1->DrawLatex(0.1,113,fParticleName[6]);
566   DrawMarker(0.0, 105, 28, 1.2, 1);
567   t1->DrawLatex(0.1,103,fParticleName[8]);
568   c12->SaveAs("SurvivedSecondaries-Composition-Rapidity.gif");
569
570   TH2F *hEmptyPt = new TH2F("hEmptyPt","",100,0.0,4.0,100,0,120); 
571   hEmptyPt->SetStats(kFALSE); 
572   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
573   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
574
575   TCanvas *c13 = new TCanvas("c13",
576                              "Composition of accepted secondaries vs pT",
577                              400,400,700,400);
578   c13->Divide(2,1);
579   c13->SetHighLightColor(10); c13->cd(1)->SetBottomMargin(0.15);
580   c13->cd(1)->SetGridx(); c13->cd(1)->SetGridy();
581   hEmptyPt->GetXaxis()->SetRangeUser(gParticleProtonPt[0]->GetXaxis()->GetXmin()-0.2,gParticleProtonPt[0]->GetXaxis()->GetXmax()+0.2);
582   hEmptyPt->SetTitle("Protons");
583   hEmptyPt->DrawCopy();
584   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
585     /*if(iParticle < 5) {
586       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.1, 
587                  115-5*iParticle, 20+iParticle, 1.2, 1);
588       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.2,
589                     113-5*iParticle,fParticleName[iParticle]);
590     }
591     else {
592       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5, 
593                  115-5*(iParticle-5), 20+iParticle, 1.2, 1);
594       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5+0.1,
595                     113-5*(iParticle-5),fParticleName[iParticle]);
596                     }*/
597     if((iParticle == 2)||(iParticle == 6)||(iParticle == 8))
598       gParticleProtonPt[iParticle]->Draw("P");
599   }
600   DrawMarker(0.5, 115, 22, 1.2, 1);
601   t1->DrawLatex(0.6,113,fParticleName[2]);
602   DrawMarker(0.5, 105, 26, 1.2, 1);
603   t1->DrawLatex(0.6,103,fParticleName[6]);
604   DrawMarker(0.5, 95, 28, 1.2, 1);
605   t1->DrawLatex(0.6,93,fParticleName[8]);
606
607   c13->SetHighLightColor(10); c13->cd(2)->SetBottomMargin(0.15);
608   c13->cd(2)->SetGridx(); c13->cd(2)->SetGridy();
609   hEmptyPt->SetTitle("Antiprotons");
610   hEmptyPt->DrawCopy();
611   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
612     /*if(iParticle < 5) {
613       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.1, 
614                  115-5*iParticle, 20+iParticle, 1.2, 1);
615       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.2,
616                     113-5*iParticle,fParticleName[iParticle]);
617     }
618     else {
619       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5, 
620                  115-5*(iParticle-5), 20+iParticle, 1.2, 1);
621       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5+0.1,
622                     113-5*(iParticle-5),fParticleName[iParticle]);
623                     }*/
624     if((iParticle == 6)||(iParticle == 8))
625       gParticleAntiProtonPt[iParticle]->Draw("P");
626   }
627   DrawMarker(0.5, 115, 26, 1.2, 1);
628   t1->DrawLatex(0.6,113,fParticleName[6]);
629   DrawMarker(0.5, 105, 28, 1.2, 1);
630   t1->DrawLatex(0.6,103,fParticleName[8]);
631   c13->SaveAs("SurvivedSecondaries-Composition-Pt.gif");
632 }
633
634 //________________________________________________//
635 void DrawContamination(TList *inputList,
636                        const char* analysisType) {
637   //loops over the list entries and
638   //draws the rapidity and pT dependence
639   //of the percentage of primary and secondary
640   //protons and antiprotons after the track cuts
641   cout<<"Extracting the entries for the histograms in the list: "<<
642     inputList->GetName()<<"..."<<endl;
643
644   TLatex *t1 = new TLatex();
645   t1->SetTextSize(0.04);
646
647   TH2F *hPrimaryProtons = (TH2F *)inputList->At(0);
648   TH2F *hSecondaryProtons = (TH2F *)inputList->At(2);
649   TH2F *hPrimaryAntiProtons = (TH2F *)inputList->At(4);
650   TH2F *hSecondaryAntiProtons = (TH2F *)inputList->At(6);
651
652   //rapidity dependence
653   //Protons
654   TH1D *gYPrimaryProtons = (TH1D *)hPrimaryProtons->ProjectionX("gYPrimaryProtons",0,hPrimaryProtons->GetXaxis()->GetNbins(),"e");
655   TH1D *gYSecondaryProtons = (TH1D *)hSecondaryProtons->ProjectionX("gYSecondaryProtons",0,hSecondaryProtons->GetXaxis()->GetNbins(),"e");
656   TH1D *gYTotalProtons = (TH1D *)hPrimaryProtons->ProjectionX("gYTotalProtons",0,hPrimaryProtons->GetXaxis()->GetNbins(),"e");
657   gYTotalProtons->Add(gYSecondaryProtons);
658
659   TH1D *gYPrimaryProtonsPercentage = new TH1D("gYPrimaryProtonsPercentage",
660                                               "",
661                                               hPrimaryProtons->GetXaxis()->GetNbins(),
662                                               hPrimaryProtons->GetXaxis()->GetXmin(),
663                                               hPrimaryProtons->GetXaxis()->GetXmax());                                        
664   gYPrimaryProtonsPercentage->Divide(gYPrimaryProtons,
665                                      gYTotalProtons,1.,1.0);
666   SetError(gYPrimaryProtonsPercentage,gYTotalProtons);
667   gYPrimaryProtonsPercentage->Scale(100.);
668   gYPrimaryProtonsPercentage->SetMarkerStyle(kFullCircle);
669
670   TH1D *gYSecondaryProtonsPercentage = new TH1D("gYSecondaryProtonsPercentage",
671                                                 "",
672                                                 hSecondaryProtons->GetXaxis()->GetNbins(),
673                                                 hSecondaryProtons->GetXaxis()->GetXmin(),
674                                                 hSecondaryProtons->GetXaxis()->GetXmax());                                            
675   gYSecondaryProtonsPercentage->Divide(gYSecondaryProtons,
676                                        gYTotalProtons,1.,1.0);
677   SetError(gYSecondaryProtonsPercentage,gYTotalProtons);
678   gYSecondaryProtonsPercentage->Scale(100.);
679   gYSecondaryProtonsPercentage->SetMarkerStyle(kOpenCircle);
680
681   //Antiprotons
682   TH1D *gYPrimaryAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionX("gYPrimaryAntiProtons",0,hPrimaryAntiProtons->GetXaxis()->GetNbins(),"e");
683   TH1D *gYSecondaryAntiProtons = (TH1D *)hSecondaryAntiProtons->ProjectionX("gYSecondaryAntiProtons",0,hSecondaryAntiProtons->GetXaxis()->GetNbins(),"e");
684   TH1D *gYTotalAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionX("gYTotalAntiProtons",0,hPrimaryAntiProtons->GetXaxis()->GetNbins(),"e");
685   gYTotalAntiProtons->Add(gYSecondaryAntiProtons);
686   
687   TH1D *gYPrimaryAntiProtonsPercentage = new TH1D("gYPrimaryAntiProtonsPercentage",
688                                                   "",
689                                                   hPrimaryAntiProtons->GetXaxis()->GetNbins(),
690                                                   hPrimaryAntiProtons->GetXaxis()->GetXmin(),
691                                                   hPrimaryAntiProtons->GetXaxis()->GetXmax());                                        
692   gYPrimaryAntiProtonsPercentage->Divide(gYPrimaryAntiProtons,
693                                          gYTotalAntiProtons,1.,1.0);
694   SetError(gYPrimaryAntiProtonsPercentage,gYTotalAntiProtons);
695   gYPrimaryAntiProtonsPercentage->Scale(100.);
696   gYPrimaryAntiProtonsPercentage->SetMarkerStyle(kFullCircle);
697   
698   TH1D *gYSecondaryAntiProtonsPercentage = new TH1D("gYSecondaryAntiProtonsPercentage",
699                                                     "",
700                                                     hSecondaryAntiProtons->GetXaxis()->GetNbins(),
701                                                     hSecondaryAntiProtons->GetXaxis()->GetXmin(),
702                                                     hSecondaryAntiProtons->GetXaxis()->GetXmax());                                            
703   gYSecondaryAntiProtonsPercentage->Divide(gYSecondaryAntiProtons,
704                                            gYTotalAntiProtons,1.,1.0);
705   SetError(gYSecondaryAntiProtonsPercentage,gYTotalAntiProtons);
706   gYSecondaryAntiProtonsPercentage->Scale(100.);
707   gYSecondaryAntiProtonsPercentage->SetMarkerStyle(kOpenCircle);
708   
709   
710   TH2F *hEmptyY = new TH2F("hEmptyCompositionY","",
711                            100,-1.2,1.2,100,-10.0,130); 
712   hEmptyY->SetStats(kFALSE); 
713   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
714   hEmptyY->GetYaxis()->SetTitleOffset(1.3);
715   hEmptyY->GetXaxis()->SetTitle(hPrimaryProtons->GetXaxis()->GetTitle());
716
717   TCanvas *c7 = new TCanvas("c7","(Anti)Proton contamination vs y",
718                             150,150,700,400);
719   c7->SetHighLightColor(10); c7->Divide(2,1);
720
721   c7->cd(1)->SetBottomMargin(0.15); 
722   c7->cd(1)->SetLeftMargin(0.15); 
723   c7->cd(1)->SetGridx(); c7->cd(1)->SetGridy();
724   hEmptyY->SetTitle("Protons");
725   hEmptyY->DrawCopy();
726   gYPrimaryProtonsPercentage->DrawCopy("ESAME");
727   gYSecondaryProtonsPercentage->DrawCopy("ESAME");
728
729   DrawMarker(0, 55, kFullCircle, 1.2, 1);
730   t1->DrawLatex(0.1,53,"Primaries");
731   DrawMarker(0, 45, kOpenCircle, 1.2, 1);
732   t1->DrawLatex(0.1,43,"Secondaries");
733
734   c7->cd(2)->SetBottomMargin(0.15); 
735   c7->cd(2)->SetLeftMargin(0.15); 
736   c7->cd(2)->SetGridx(); c7->cd(2)->SetGridy();
737   hEmptyY->SetTitle("Antiprotons");
738   hEmptyY->DrawCopy();
739   gYPrimaryAntiProtonsPercentage->DrawCopy("ESAME");
740   gYSecondaryAntiProtonsPercentage->DrawCopy("ESAME");
741
742   DrawMarker(0, 55, kFullCircle, 1.2, 1);
743   t1->DrawLatex(0.1,53,"Primaries");
744   DrawMarker(0, 45, kOpenCircle, 1.2, 1);
745   t1->DrawLatex(0.1,41,"Secondaries");
746
747   c7->SaveAs("Contamination-Protons-Rapidity.gif");
748
749   //pT dependence
750   //Protons
751   TH1D *gPtPrimaryProtons = (TH1D *)hPrimaryProtons->ProjectionY("gPtPrimaryProtons",0,hPrimaryProtons->GetYaxis()->GetNbins(),"e");
752   TH1D *gPtSecondaryProtons = (TH1D *)hSecondaryProtons->ProjectionY("gPtSecondaryProtons",0,hSecondaryProtons->GetYaxis()->GetNbins(),"e");
753   TH1D *gPtTotalProtons = (TH1D *)hPrimaryProtons->ProjectionY("gPtTotalProtons",0,hPrimaryProtons->GetYaxis()->GetNbins(),"e");
754   gPtTotalProtons->Add(gPtSecondaryProtons);
755
756   TH1D *gPtPrimaryProtonsPercentage = new TH1D("gPtPrimaryProtonsPercentage",
757                                                "",
758                                                hPrimaryProtons->GetYaxis()->GetNbins(),
759                                                hPrimaryProtons->GetYaxis()->GetXmin(),
760                                                hPrimaryProtons->GetYaxis()->GetXmax());                                       
761   gPtPrimaryProtonsPercentage->Divide(gPtPrimaryProtons,
762                                       gPtTotalProtons,1.,1.0);
763   SetError(gPtPrimaryProtonsPercentage,gPtTotalProtons);
764   gPtPrimaryProtonsPercentage->Scale(100.);
765   gPtPrimaryProtonsPercentage->SetMarkerStyle(kFullCircle);
766   
767   TH1D *gPtSecondaryProtonsPercentage = new TH1D("gPtSecondaryProtonsPercentage",
768                                                  "",
769                                                  hSecondaryProtons->GetYaxis()->GetNbins(),
770                                                  hSecondaryProtons->GetYaxis()->GetXmin(),
771                                                  hSecondaryProtons->GetYaxis()->GetXmax());                                           
772   gPtSecondaryProtonsPercentage->Divide(gPtSecondaryProtons,
773                                         gPtTotalProtons,1.,1.0);
774   SetError(gPtSecondaryProtonsPercentage,gPtTotalProtons);
775   gPtSecondaryProtonsPercentage->Scale(100.);
776   gPtSecondaryProtonsPercentage->SetMarkerStyle(kOpenCircle);
777
778
779   //Antiprotons
780   TH1D *gPtPrimaryAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionY("gPtPrimaryAntiProtons",0,hPrimaryAntiProtons->GetYaxis()->GetNbins(),"e");
781   TH1D *gPtSecondaryAntiProtons = (TH1D *)hSecondaryAntiProtons->ProjectionY("gPtSecondaryAntiProtons",0,hSecondaryAntiProtons->GetYaxis()->GetNbins(),"e");
782   TH1D *gPtTotalAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionY("gPtTotalAntiProtons",0,hPrimaryAntiProtons->GetYaxis()->GetNbins(),"e");
783   gPtTotalAntiProtons->Add(gPtSecondaryAntiProtons);
784   
785   TH1D *gPtPrimaryAntiProtonsPercentage = new TH1D("gPtPrimaryAntiProtonsPercentage",
786                                                    "",
787                                                    hPrimaryAntiProtons->GetYaxis()->GetNbins(),
788                                                    hPrimaryAntiProtons->GetYaxis()->GetXmin(),
789                                                    hPrimaryAntiProtons->GetYaxis()->GetXmax());                                       
790   gPtPrimaryAntiProtonsPercentage->Divide(gPtPrimaryAntiProtons,
791                                           gPtTotalAntiProtons,1.,1.0);
792   SetError(gPtPrimaryAntiProtonsPercentage,gPtTotalAntiProtons);
793   gPtPrimaryAntiProtonsPercentage->Scale(100.);
794   gPtPrimaryAntiProtonsPercentage->SetMarkerStyle(kFullCircle);
795   
796   TH1D *gPtSecondaryAntiProtonsPercentage = new TH1D("gPtSecondaryAntiProtonsPercentage",
797                                                      "",
798                                                      hSecondaryAntiProtons->GetYaxis()->GetNbins(),
799                                                      hSecondaryAntiProtons->GetYaxis()->GetXmin(),
800                                                      hSecondaryAntiProtons->GetYaxis()->GetXmax());                                           
801   gPtSecondaryAntiProtonsPercentage->Divide(gPtSecondaryAntiProtons,
802                                             gPtTotalAntiProtons,1.,1.0);
803   SetError(gPtSecondaryAntiProtonsPercentage,gPtTotalAntiProtons);
804   gPtSecondaryAntiProtonsPercentage->Scale(100.);
805   gPtSecondaryAntiProtonsPercentage->SetMarkerStyle(kOpenCircle);
806   
807   TH2F *hEmptyPt = new TH2F("hEmptyCompositionPt","",
808                            100,0.0,4.0,100,-10.0,130); 
809   hEmptyPt->SetStats(kFALSE); 
810   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
811   hEmptyPt->GetYaxis()->SetTitleOffset(1.3);
812   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
813
814   TCanvas *c8 = new TCanvas("c8","(Anti)Proton comtamination vs pT",
815                             200,200,700,400);
816   c8->SetHighLightColor(10); c8->Divide(2,1);
817
818   c8->cd(1)->SetBottomMargin(0.15); 
819   c8->cd(1)->SetLeftMargin(0.15); 
820   c8->cd(1)->SetGridx(); c8->cd(1)->SetGridy();
821   hEmptyPt->SetTitle("Protons");
822   hEmptyPt->GetXaxis()->SetRangeUser(gPtPrimaryProtonsPercentage->GetXaxis()->GetXmin()-0.2,gPtPrimaryProtonsPercentage->GetXaxis()->GetXmax()+0.2);
823   hEmptyPt->DrawCopy();
824   gPtPrimaryProtonsPercentage->DrawCopy("ESAME");
825   gPtSecondaryProtonsPercentage->DrawCopy("ESAME");
826
827   DrawMarker(0.5, 55, kFullCircle, 1.2, 1);
828   t1->DrawLatex(0.6,53,"Primaries");
829   DrawMarker(0.5, 45, kOpenCircle, 1.2, 1);
830   t1->DrawLatex(0.6,41,"Secondaries");
831
832   c8->cd(2)->SetBottomMargin(0.15); 
833   c8->cd(2)->SetLeftMargin(0.15); 
834   c8->cd(2)->SetGridx(); c8->cd(2)->SetGridy();
835   hEmptyPt->SetTitle("Antirotons");
836   hEmptyPt->DrawCopy();
837   gPtPrimaryAntiProtonsPercentage->DrawCopy("ESAME");
838   gPtSecondaryAntiProtonsPercentage->DrawCopy("ESAME");
839
840   DrawMarker(2.0, 55, kFullCircle, 1.2, 1);
841   t1->DrawLatex(2.1,53,"Primaries");
842   DrawMarker(2.0, 45, kOpenCircle, 1.2, 1);
843   t1->DrawLatex(2.1,43,"Secondaries");
844
845   c8->SaveAs("Contamination-Protons-Pt.gif");
846
847   TString outputFileName = "Contamination."; 
848   outputFileName += analysisType; outputFileName += ".root";
849   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
850   gYPrimaryProtonsPercentage->Write();
851   gYSecondaryProtonsPercentage->Write();
852   gPtPrimaryProtonsPercentage->Write();
853   gPtSecondaryProtonsPercentage->Write();
854   gYPrimaryAntiProtonsPercentage->Write();
855   gYSecondaryAntiProtonsPercentage->Write();
856   gPtPrimaryAntiProtonsPercentage->Write();
857   gPtSecondaryAntiProtonsPercentage->Write();
858   fout->Close();
859 }
860
861 //________________________________________________//
862 void DrawCutEfficiency(TList *inputList,
863                        const char* analysisType) {
864   //loops over the list entries and
865   //draws the rapidity and pT dependence
866   //of the percentage of primary and secondary
867   //protons and antiprotons after the track cuts
868   cout<<"Extracting the entries for the histograms in the list: "<<
869     inputList->GetName()<<"..."<<endl;
870
871   TLatex *t1 = new TLatex();
872   t1->SetTextSize(0.04);
873
874   TH2F *hPrimaryESDProtons = (TH2F *)inputList->At(0);
875   TH2F *hPrimaryESDAntiProtons = (TH2F *)inputList->At(4);
876   TH2F *hPrimaryMCProtons = (TH2F *)inputList->At(8);
877   TH2F *hPrimaryMCAntiProtons = (TH2F *)inputList->At(9);
878
879   //rapidity dependence
880   //Protons
881   TH1D *gYPrimaryESDProtons = (TH1D *)hPrimaryESDProtons->ProjectionX("gYPrimaryESDProtons",0,hPrimaryESDProtons->GetXaxis()->GetNbins(),"e");
882   TH1D *gYPrimaryMCProtons = (TH1D *)hPrimaryMCProtons->ProjectionX("gYPrimaryMCProtons",0,hPrimaryMCProtons->GetXaxis()->GetNbins(),"e");
883   gYPrimaryESDProtons->Divide(gYPrimaryMCProtons);
884   SetError(gYPrimaryESDProtons,gYPrimaryMCProtons);
885   gYPrimaryESDProtons->Scale(100.);
886   gYPrimaryESDProtons->SetMarkerStyle(kFullCircle);
887
888   //Antiprotons
889   TH1D *gYPrimaryESDAntiProtons = (TH1D *)hPrimaryESDAntiProtons->ProjectionX("gYPrimaryESDAntiProtons",0,hPrimaryESDAntiProtons->GetXaxis()->GetNbins(),"e");
890   TH1D *gYPrimaryMCAntiProtons = (TH1D *)hPrimaryMCAntiProtons->ProjectionX("gYPrimaryMCAntiProtons",0,hPrimaryMCAntiProtons->GetXaxis()->GetNbins(),"e");
891   gYPrimaryESDAntiProtons->Divide(gYPrimaryMCAntiProtons);
892   SetError(gYPrimaryESDAntiProtons,gYPrimaryMCAntiProtons);
893   gYPrimaryESDAntiProtons->Scale(100.);
894   gYPrimaryESDAntiProtons->SetMarkerStyle(kFullCircle);
895   
896   TH2F *hEmptyY = new TH2F("hEmptyEfficiencyY","",
897                            100,-1.2,1.2,100,-10.0,130); 
898   hEmptyY->SetStats(kFALSE); 
899   hEmptyY->GetYaxis()->SetTitle("#epsilon [%]");
900   hEmptyY->GetYaxis()->SetTitleOffset(1.3);
901   hEmptyY->GetXaxis()->SetTitle(hPrimaryESDProtons->GetXaxis()->GetTitle());
902
903   TCanvas *c10 = new TCanvas("c10","(Anti)Proton cut efficiency vs y",
904                             250,250,700,400);
905   c10->SetHighLightColor(10); c10->Divide(2,1);
906
907   c10->cd(1)->SetBottomMargin(0.15); 
908   c10->cd(1)->SetLeftMargin(0.15); 
909   c10->cd(1)->SetGridx(); c10->cd(1)->SetGridy();
910   hEmptyY->SetTitle("Protons");
911   hEmptyY->GetXaxis()->SetRangeUser(gYPrimaryESDAntiProtons->GetXaxis()->GetXmin()-0.2,gYPrimaryESDAntiProtons->GetXaxis()->GetXmax()+0.2);
912   hEmptyY->DrawCopy();
913   gYPrimaryESDProtons->DrawCopy("ESAME");
914
915   c10->cd(2)->SetBottomMargin(0.15); 
916   c10->cd(2)->SetLeftMargin(0.15); 
917   c10->cd(2)->SetGridx(); c10->cd(2)->SetGridy();
918   hEmptyY->SetTitle("Antiprotons");
919   hEmptyY->DrawCopy();
920   gYPrimaryESDAntiProtons->DrawCopy("ESAME");
921
922   c10->SaveAs("CutEfficiency-Protons-Rapidity.gif");
923
924   //pT dependence
925   //Protons
926   TH1D *gPtPrimaryESDProtons = (TH1D *)hPrimaryESDProtons->ProjectionY("gPtPrimaryESDProtons",0,hPrimaryESDProtons->GetYaxis()->GetNbins(),"e");
927   TH1D *gPtPrimaryMCProtons = (TH1D *)hPrimaryMCProtons->ProjectionY("gPtPrimaryMCProtons",0,hPrimaryMCProtons->GetYaxis()->GetNbins(),"e");
928   gPtPrimaryESDProtons->Divide(gPtPrimaryMCProtons);
929   SetError(gPtPrimaryESDProtons,gPtPrimaryMCProtons);
930   gPtPrimaryESDProtons->Scale(100.);
931   gPtPrimaryESDProtons->SetMarkerStyle(kFullCircle);
932
933   //Antiprotons
934   TH1D *gPtPrimaryESDAntiProtons = (TH1D *)hPrimaryESDAntiProtons->ProjectionY("gPtPrimaryESDAntiProtons",0,hPrimaryESDAntiProtons->GetYaxis()->GetNbins(),"e");
935   TH1D *gPtPrimaryMCAntiProtons = (TH1D *)hPrimaryMCAntiProtons->ProjectionY("gPtPrimaryMCAntiProtons",0,hPrimaryMCAntiProtons->GetYaxis()->GetNbins(),"e");
936   gPtPrimaryESDAntiProtons->Divide(gPtPrimaryMCAntiProtons);
937   SetError(gPtPrimaryESDAntiProtons,gPtPrimaryMCAntiProtons);
938   gPtPrimaryESDAntiProtons->Scale(100.);
939   gPtPrimaryESDAntiProtons->SetMarkerStyle(kFullCircle);
940
941   TH2F *hEmptyPt = new TH2F("hEmptyEfficiencyPt","",
942                            100,0.0,4.0,100,-10.0,130); 
943   hEmptyPt->SetStats(kFALSE); 
944   hEmptyPt->GetYaxis()->SetTitle("#epsilon [%]");
945   hEmptyPt->GetYaxis()->SetTitleOffset(1.3);
946   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
947
948   TCanvas *c11 = new TCanvas("c11","(Anti)Proton cut efficiency vs pT",
949                             300,300,700,400);
950   c11->SetHighLightColor(10); c11->Divide(2,1);
951
952   c11->cd(1)->SetBottomMargin(0.15); 
953   c11->cd(1)->SetLeftMargin(0.15); 
954   c11->cd(1)->SetGridx(); c11->cd(1)->SetGridy();
955   hEmptyPt->SetTitle("Protons");
956   hEmptyPt->GetXaxis()->SetRangeUser(gPtPrimaryESDAntiProtons->GetXaxis()->GetXmin()-0.2,gPtPrimaryESDAntiProtons->GetXaxis()->GetXmax()+0.2);
957   hEmptyPt->DrawCopy();
958   gPtPrimaryESDProtons->DrawCopy("ESAME");
959
960   c11->cd(2)->SetBottomMargin(0.15); 
961   c11->cd(2)->SetLeftMargin(0.15); 
962   c11->cd(2)->SetGridx(); c11->cd(2)->SetGridy();
963   hEmptyPt->SetTitle("Antirotons");
964   hEmptyPt->DrawCopy();
965   gPtPrimaryESDAntiProtons->DrawCopy("ESAME");
966
967   c11->SaveAs("CutEfficiency-Protons-Pt.gif");
968
969   TString outputFileName = "CutEfficiency.";
970   outputFileName += analysisType; outputFileName += ".root";
971   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
972   gYPrimaryESDProtons->Write();
973   gYPrimaryESDAntiProtons->Write();
974   gPtPrimaryESDProtons->Write();
975   gPtPrimaryESDAntiProtons->Write();
976   fout->Close();
977 }
978
979 //________________________________________________//
980 void GetQAEntries(TList *inputList, Double_t *entries) {
981   //loops over the list entries
982   //extracts the entries for each histogram
983   //cout<<"Extracting the entries for the histograms in the list: "<<
984   //inputList->GetName()<<"..."<<endl;
985
986   for(Int_t i = 0; i < inputList->GetEntries(); i++) {
987     TH1F *gHist = (TH1F *)inputList->At(i);
988     entries[i] = gHist->GetEntries();
989     //cout<<"Histogram: "<<gHist->GetName()<<
990     //" - Entries: "<<entries[i]<<endl;
991     gHist = 0;
992   }
993 }
994
995 //________________________________________________//
996 Double_t GetPercentage(Double_t nPassEntries,
997                        Double_t nRejectEntries) {
998   //returns the percentage of tracks that were rejected by a cut
999   Int_t nTotalEntries = nPassEntries + nRejectEntries;
1000
1001   if(nTotalEntries == 0)
1002     return -1;
1003
1004   return 100.*nRejectEntries/nTotalEntries;
1005 }
1006
1007 //________________________________________//
1008 void drawMCQA(TList *listPDG, TList *listMCProcesses) {
1009   //Function to display the composition of secondary (anti)protons
1010   //The histogram shows the percentage of secondary (anti)protons
1011   //originating from each particle species.
1012   //The box summarizes the MC process that gave these secondary (anti)protons
1013   TDatabasePDG *db = TDatabasePDG::Instance();
1014   TParticlePDG *p = 0x0;
1015   
1016   TH3F *gHistYPtPDGProtons = (TH3F *)listPDG->At(0);
1017   TH3F *gHistYPtPDGAntiProtons = (TH3F *)listPDG->At(1);
1018   readProcesses(listMCProcesses);
1019   Double_t nParticleCompositionProtonY[200], nParticleCompositionProtonPt[200];
1020   Double_t nParticleCompositionProtonYError[200], nParticleCompositionProtonPtError[200];
1021   Double_t nParticleCompositionAntiProtonY[200], nParticleCompositionAntiProtonPt[200];
1022   Double_t nParticleCompositionAntiProtonYError[200], nParticleCompositionAntiProtonPtError[200];
1023   Double_t gY[200], gPt[200];
1024   Double_t gYError[200], gPtError[200];
1025   for(Int_t iBins = 0; iBins < 200; iBins++) {
1026     nParticleCompositionProtonY[iBins] = 0;
1027     nParticleCompositionProtonPt[iBins] = 0;
1028     nParticleCompositionProtonYError[iBins] = 0;
1029     nParticleCompositionProtonPtError[iBins] = 0;
1030     nParticleCompositionAntiProtonY[iBins] = 0;
1031     nParticleCompositionAntiProtonPt[iBins] = 0;
1032     nParticleCompositionAntiProtonYError[iBins] = 0;
1033     nParticleCompositionAntiProtonPtError[iBins] = 0;
1034     gY[iBins] = 0;
1035     gPt[iBins] = 0;
1036     gYError[iBins] = 0;
1037     gPtError[iBins] = 0;
1038   }
1039   
1040   TGraphErrors *gParticleProtonY[14];
1041   TGraphErrors *gParticleProtonPt[14];
1042   TGraphErrors *gParticleAntiProtonY[14];
1043   TGraphErrors *gParticleAntiProtonPt[14];
1044   for(Int_t iParticle = 0; iParticle < 14; iParticle++) {
1045     GetComposition(iParticle,
1046                    gHistYPtPDGProtons,
1047                    nParticleCompositionProtonY,
1048                    nParticleCompositionProtonYError, gY, gYError, 
1049                    nParticleCompositionProtonPt, 
1050                    nParticleCompositionProtonPtError, gPt, gPtError);
1051     gParticleProtonY[iParticle] = new TGraphErrors(gHistYPtPDGProtons->GetNbinsX(),
1052                                                    gY,nParticleCompositionProtonY,
1053                                                    gYError,nParticleCompositionProtonYError);
1054     gParticleProtonY[iParticle]->SetMarkerStyle(iParticle+20);
1055     gParticleProtonY[iParticle]->SetMarkerSize(1.2);
1056
1057     gParticleProtonPt[iParticle] = new TGraphErrors(gHistYPtPDGProtons->GetNbinsY(),
1058                                                     gPt,nParticleCompositionProtonPt,
1059                                                     gPtError,nParticleCompositionProtonPtError);
1060     gParticleProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
1061     gParticleProtonPt[iParticle]->SetMarkerSize(1.2);
1062
1063     GetComposition(iParticle,
1064                    gHistYPtPDGAntiProtons,
1065                    nParticleCompositionAntiProtonY,
1066                    nParticleCompositionAntiProtonYError, gY, gYError, 
1067                    nParticleCompositionAntiProtonPt, 
1068                    nParticleCompositionAntiProtonPtError, gPt, gPtError);
1069     gParticleAntiProtonY[iParticle] = new TGraphErrors(gHistYPtPDGAntiProtons->GetNbinsX(),
1070                                                        gY,nParticleCompositionAntiProtonY,
1071                                                        gYError,nParticleCompositionAntiProtonYError);
1072     gParticleAntiProtonY[iParticle]->SetMarkerStyle(iParticle+20);
1073     gParticleAntiProtonY[iParticle]->SetMarkerSize(1.2);
1074
1075     gParticleAntiProtonPt[iParticle] = new TGraphErrors(gHistYPtPDGAntiProtons->GetNbinsY(),
1076                                                         gPt,nParticleCompositionAntiProtonPt,
1077                                                         gPtError,nParticleCompositionAntiProtonPtError);
1078     gParticleAntiProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
1079     gParticleAntiProtonPt[iParticle]->SetMarkerSize(1.2);
1080   }
1081
1082   //_________________________________________________________//
1083   char *fParticleName[14] = {"Primary","K_{L}","#pi","K_{S}","K",
1084                              "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
1085                              "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
1086   TLatex *t1 = new TLatex();
1087   t1->SetTextSize(0.04);
1088
1089   TH2F *hEmptyY = new TH2F("hEmptyY","",100,-1.2,1.2,100,0,120); 
1090   hEmptyY->SetStats(kFALSE); 
1091   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
1092   hEmptyY->GetXaxis()->SetTitle(gHistYPtPDGProtons->GetXaxis()->GetTitle());
1093
1094   TCanvas *c3 = new TCanvas("c3","MC secondary composition vs y - Protons",
1095                             450,450,700,400);
1096   c3->SetHighLightColor(10); c3->SetBottomMargin(0.15);
1097   c3->SetGridx(); c3->SetGridy();
1098   hEmptyY->GetXaxis()->SetRangeUser(gParticleProtonY[0]->GetXaxis()->GetXmin()-0.2,gParticleProtonY[0]->GetXaxis()->GetXmax()+0.2);
1099   hEmptyY->DrawCopy();
1100   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1101     //if((iParticle == 0)||(iParticle == 2)||(iParticle == 5)||(iParticle == 6)||(iParticle == 8))
1102     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
1103       gParticleProtonY[iParticle]->Draw("P");
1104     /*if(iParticle < 5) {
1105       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
1106       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
1107     }
1108     else {
1109       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1110       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
1111       }*/
1112   }
1113   DrawMarker(0.0, 115, 20, 1.2, 1);
1114   t1->DrawLatex(0.1,113,fParticleName[0]);
1115   DrawMarker(0.0, 108, 22, 1.2, 1);
1116   t1->DrawLatex(0.1,106,fParticleName[2]);
1117   DrawMarker(0.0, 101, 26, 1.2, 1);
1118   t1->DrawLatex(0.1,99,fParticleName[6]);
1119   DrawMarker(0.0, 94, 28, 1.2, 1);
1120   t1->DrawLatex(0.1,92,fParticleName[8]);
1121
1122   TCanvas *c5 = new TCanvas("c5","MC secondary composition vs y - antiProtons",
1123                             500,500,700,400);
1124   c5->SetHighLightColor(10); c5->SetBottomMargin(0.15);
1125   c5->SetGridx(); c5->SetGridy();
1126   hEmptyY->DrawCopy();
1127   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1128     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
1129       gParticleAntiProtonY[iParticle]->Draw("P");
1130     /*if(iParticle < 5) {
1131       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
1132       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
1133     }
1134     else {
1135       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1136       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
1137       }*/
1138   }
1139   DrawMarker(0.0, 115, 20, 1.2, 1);
1140   t1->DrawLatex(0.1,113,fParticleName[0]);
1141   DrawMarker(0.0, 108, 26, 1.2, 1);
1142   t1->DrawLatex(0.1,106,fParticleName[6]);
1143   DrawMarker(0.0, 101, 28, 1.2, 1);
1144   t1->DrawLatex(0.1,99,fParticleName[8]);
1145
1146   TH2F *hEmptyPt = new TH2F("hEmptyPt","",100,0.0,4.0,100,0,120); 
1147   hEmptyPt->SetStats(kFALSE); 
1148   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
1149   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1150
1151   TCanvas *c4 = new TCanvas("c4","MC secondary composition vs pT - Protons",
1152                             550,550,700,400);
1153   c4->SetHighLightColor(10); c4->SetBottomMargin(0.15);
1154   c4->SetGridx(); c4->SetGridy();
1155   hEmptyPt->GetXaxis()->SetRangeUser(gParticleProtonPt[0]->GetXaxis()->GetXmin()-0.2,gParticleProtonPt[0]->GetXaxis()->GetXmax()+0.2);
1156   hEmptyPt->DrawCopy();
1157   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1158     /*if(iParticle < 5) {
1159       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
1160       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
1161     }
1162     else {
1163       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1164       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
1165       }*/
1166     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
1167       gParticleProtonPt[iParticle]->Draw("P");
1168   }
1169   DrawMarker(0.5, 115, 20, 1.2, 1);
1170   t1->DrawLatex(0.6,113,fParticleName[0]);
1171   DrawMarker(0.5, 108, 22, 1.2, 1);
1172   t1->DrawLatex(0.6,106,fParticleName[2]);
1173   DrawMarker(0.5, 101, 26, 1.2, 1);
1174   t1->DrawLatex(0.6,99,fParticleName[6]);
1175   DrawMarker(0.5, 94, 28, 1.2, 1);
1176   t1->DrawLatex(0.6,92,fParticleName[8]);
1177
1178   TCanvas *c6 = new TCanvas("c6",
1179                             "MC secondary composition vs pT - AntiProtons",
1180                             600,600,700,400);
1181   c6->SetHighLightColor(10); c6->SetBottomMargin(0.15);
1182   c6->SetGridx(); c6->SetGridy();
1183   hEmptyPt->DrawCopy();
1184   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1185     /*if(iParticle < 5) {
1186       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
1187       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
1188     }
1189     else {
1190       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1191       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
1192       }*/
1193     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
1194       gParticleAntiProtonPt[iParticle]->Draw("P");
1195   }
1196   DrawMarker(0.5, 115, 20, 1.2, 1);
1197   t1->DrawLatex(0.6,113,fParticleName[0]);
1198   DrawMarker(0.5, 108, 26, 1.2, 1);
1199   t1->DrawLatex(0.6,106,fParticleName[6]);
1200   DrawMarker(0.5, 101, 28, 1.2, 1);
1201   t1->DrawLatex(0.6,99,fParticleName[8]);
1202 }
1203
1204 //________________________________________//
1205 void GetComposition(Int_t iSpecies,
1206                     TH3F *gHist, 
1207                     Double_t *nParticleCompositionY,
1208                     Double_t *nParticleCompositionYError,
1209                     Double_t *gY, Double_t *gYError,
1210                     Double_t *nParticleCompositionPt,
1211                     Double_t *nParticleCompositionPtError,
1212                     Double_t *gPt, Double_t *gPtError) {
1213   //Returns the pT and y dependence of the MC composition
1214   Double_t ymin = gHist->GetXaxis()->GetXmin();
1215   Double_t ymax = gHist->GetXaxis()->GetXmax();
1216   Double_t nybins = gHist->GetNbinsX();
1217   Double_t ptmin = gHist->GetYaxis()->GetXmin();
1218   Double_t ptmax = gHist->GetYaxis()->GetXmax();
1219   Double_t nptbins = gHist->GetNbinsY();
1220   Double_t nTotalY[200], nTotalPt[200];
1221   for(Int_t iBins = 0; iBins < 200; iBins++) {
1222     nParticleCompositionY[iBins] = 0;
1223     nParticleCompositionPt[iBins] = 0;
1224     nParticleCompositionYError[iBins] = 0;
1225     nParticleCompositionPtError[iBins] = 0;
1226     nTotalY[iBins] = 0.0;
1227     nTotalPt[iBins] = 0.0;
1228   }
1229
1230   //rapidity dependence
1231   //cout<<"Ymin: "<<ymin<<" - Ymax: "<<ymax<<" - Ybins: "<<nybins<<endl;
1232   for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1233     for(Int_t iZbins = 1; iZbins <= gHist->GetNbinsZ(); iZbins++) {
1234       for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1235         nTotalY[iXbins-1] += gHist->GetBinContent(iXbins,iYbins,iZbins);
1236       }
1237     }
1238   }
1239
1240   for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1241     for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1242       if(nTotalY[iXbins-1] > 0)
1243         nParticleCompositionY[iXbins-1] += 100.*gHist->GetBinContent(iXbins,iYbins,iSpecies+1)/nTotalY[iXbins-1];
1244       //nCompositionY[iXbins-1] += gHist->GetBinContent(iXbins,iYbins,iSpecies+1);
1245       //if(nParticleCompositionY[iXbins-1] == 0) 
1246       //nParticleCompositionY[iXbins-1] = -10.0;
1247     }//pt loop
1248     if((nParticleCompositionY[iXbins-1] <= 100.)&&(nTotalY[iXbins-1] != 0))
1249       nParticleCompositionYError[iXbins-1] = TMath::Sqrt(nParticleCompositionY[iXbins-1]*(100. - nParticleCompositionY[iXbins-1])/nTotalY[iXbins-1]);
1250     gY[iXbins-1] = ymin + (iXbins-1)*(ymax - ymin)/nybins + 0.5*(ymax - ymin)/nybins;
1251     gYError[iXbins-1] = 0.5*(ymax - ymin)/nybins;
1252     //cout<<"y: "<<gY[iXbins-1]<<
1253     //" - test: "<<ymin + (iXbins-1)*(ymax - ymin)/nybins + 0.5*(ymax - ymin)/nybins<<
1254     //" - Number of protons: "<<nY[iXbins-1]<<
1255     //" - Total: "<<nTotalY[iXbins-1]<<
1256     //" - Percentage: "<<nParticleCompositionY[iXbins-1]<<endl;
1257   }//y loop
1258
1259   //pt dependence
1260   //cout<<"Ptmin: "<<ptmin<<" - Ptmax: "<<ptmax<<" - Ptbins: "<<nptbins<<endl;
1261   for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1262     for(Int_t iZbins = 1; iZbins <= gHist->GetNbinsZ(); iZbins++) {
1263       for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1264         nTotalPt[iYbins-1] += gHist->GetBinContent(iXbins,iYbins,iZbins);
1265       }
1266     }
1267   }
1268
1269   for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1270     for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1271       if(nTotalPt[iYbins-1] > 0)
1272         nParticleCompositionPt[iYbins-1] += 100.*gHist->GetBinContent(iXbins,iYbins,iSpecies+1)/nTotalPt[iYbins-1];
1273       //if(nParticleCompositionPt[iYbins-1] == 0) 
1274       //nParticleCompositionPt[iYbins-1] = -10.0;
1275     }//pt loop
1276     if((nParticleCompositionPt[iYbins-1] <= 100.)&&(nTotalPt[iYbins-1] != 0))
1277       nParticleCompositionPtError[iYbins-1] = TMath::Sqrt(nParticleCompositionPt[iYbins-1]*(100. - nParticleCompositionPt[iYbins-1])/nTotalPt[iYbins-1]);
1278     gPt[iYbins-1] = ptmin + (iYbins-1)*(ptmax - ptmin)/nptbins + 0.5*(ptmax - ptmin)/nptbins;
1279     gPtError[iYbins-1] = 0.5*(ptmax - ptmin)/nptbins;
1280     //cout<<"Pt: "<<gPt[iYbins-1]<<
1281     //" - test: "<<ptmin + (iYbins-1)*(ptmax - ptmin)/nptbins + 0.5*(ptmax - ptmin)/nptbins<<
1282     //" - Number of protons: "<<nY[iXbins-1]<<
1283     //" - Total: "<<nTotalPt[iYbins-1]<<
1284     //" - Percentage: "<<nParticleCompositionPt[iYbins-1]<<endl;
1285   }//pt loop
1286 }
1287
1288 //________________________________________//
1289 void readProcesses(TList *list) {
1290   char *fParticleProtonName[12] = {"K_{L}","#pi","K_{S}","K",
1291                                    "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
1292                                    "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
1293   char *fParticleAntiProtonName[8] = {"K_{L}","#pi","K_{S}","K",
1294                                       "n","p","#Lambda","#Sigma^{+}"};
1295   Int_t iProtonCounter = 0, iAntiProtonCounter = 0;
1296   TH1F *gMCProcesses;
1297   for(Int_t iEntry = 0; iEntry < list->GetEntries(); iEntry++) {
1298     gMCProcesses = (TH1F *)list->At(iEntry);
1299     TString histName = gMCProcesses->GetName();
1300     if(histName.Contains("gHistProtons")) {
1301       cout<<"Protons coming from "<<fParticleProtonName[iProtonCounter]<<endl;
1302
1303       iProtonCounter += 1;
1304     }
1305     if(histName.Contains("gHistAntiProtons")) {
1306       cout<<"Antiprotons coming from "<<fParticleAntiProtonName[iAntiProtonCounter]<<endl;
1307
1308       iAntiProtonCounter += 1;
1309     }
1310     for(Int_t iBin = 1; iBin < gMCProcesses->GetNbinsX(); iBin++) {
1311       Double_t binContent = gMCProcesses->GetBinContent(iBin);
1312       if(binContent > 0) {
1313         Int_t processId = gMCProcesses->GetBinCenter(iBin);
1314         cout<<"\t Process ID: "<<processId<<" - "<<
1315           gMCProcessName[processId]<<" - "<<
1316           100.*binContent/gMCProcesses->GetEntries()<<"%"<<endl;
1317       }
1318     }
1319   }
1320 }
1321
1322 //________________________________________________//
1323 void SetError(TH1 *hEff, TH1 *hGen) {
1324   for(Int_t iBin = 1; iBin <= hEff->GetNbinsX(); iBin++) {
1325     Double_t error = 0.0;
1326     if((hEff->GetBinContent(iBin) <= 1  .)&&(hGen->GetBinContent(iBin) != 0))
1327       error = TMath::Sqrt(hEff->GetBinContent(iBin)*(1  . - hEff->GetBinContent(iBin))/hGen->GetBinContent(iBin));
1328     hEff->SetBinError(iBin,error);
1329   }
1330 }
1331
1332 //________________________________________//
1333 void drawVertexQA(TList *list) {
1334   //Function to display the vertex QA plots
1335   TH1I *gHistMCPrimaryMultiplicity = (TH1I *)list->At(0);
1336   //TPC
1337   TH1I *gHistMCPrimaryMultiplicityTPC = (TH1I *)list->At(1);
1338   TH2F *gHistTPCESDVx = (TH2F *)list->At(2);
1339   TH2F *gHistTPCESDVy = (TH2F *)list->At(3);
1340   TH2F *gHistTPCESDVz = (TH2F *)list->At(4);
1341   TH1F *gHistTPCDiffVx = (TH1F *)list->At(5);
1342   TH1F *gHistTPCDiffVy = (TH1F *)list->At(6);
1343   TH1F *gHistTPCDiffVz = (TH1F *)list->At(7);
1344   TH1F *gHistTPCResolutionVx = (TH1F *)list->At(8);
1345   TH1F *gHistTPCResolutionVy = (TH1F *)list->At(9);
1346   TH1F *gHistTPCResolutionVz = (TH1F *)list->At(10);
1347   //SPD
1348   TH1I *gHistMCPrimaryMultiplicitySPD = (TH1I *)list->At(11);
1349   TH2F *gHistSPDESDVx = (TH2F *)list->At(12);
1350   TH2F *gHistSPDESDVy = (TH2F *)list->At(13);
1351   TH2F *gHistSPDESDVz = (TH2F *)list->At(14);
1352   TH1F *gHistSPDDiffVx = (TH1F *)list->At(15);
1353   TH1F *gHistSPDDiffVy = (TH1F *)list->At(16);
1354   TH1F *gHistSPDDiffVz = (TH1F *)list->At(17);
1355   TH1F *gHistSPDResolutionVx = (TH1F *)list->At(18);
1356   TH1F *gHistSPDResolutionVy = (TH1F *)list->At(19);
1357   TH1F *gHistSPDResolutionVz = (TH1F *)list->At(20);
1358   //Tracks
1359   TH1I *gHistMCPrimaryMultiplicityTracks = (TH1I *)list->At(21);
1360   TH2F *gHistTracksESDVx = (TH2F *)list->At(22);
1361   TH2F *gHistTracksESDVy = (TH2F *)list->At(23);
1362   TH2F *gHistTracksESDVz = (TH2F *)list->At(24);
1363   TH1F *gHistTracksDiffVx = (TH1F *)list->At(25);
1364   TH1F *gHistTracksDiffVy = (TH1F *)list->At(26);
1365   TH1F *gHistTracksDiffVz = (TH1F *)list->At(27);
1366   TH1F *gHistTracksResolutionVx = (TH1F *)list->At(28);
1367   TH1F *gHistTracksResolutionVy = (TH1F *)list->At(29);
1368   TH1F *gHistTracksResolutionVz = (TH1F *)list->At(30);
1369
1370   TCanvas *c17 = new TCanvas("c17",
1371                              "Vertex efficiency",
1372                              300,0,900,400);
1373   c17->SetHighLightColor(10); c17->Divide(3,1);
1374   c17->cd(1)->SetLeftMargin(0.15); c17->cd(1)->SetBottomMargin(0.15);  
1375   c17->cd(1)->SetRightMargin(0.2);
1376   gHistMCPrimaryMultiplicityTPC->Divide(gHistMCPrimaryMultiplicity);
1377   SetError(gHistMCPrimaryMultiplicityTPC,gHistMCPrimaryMultiplicity);
1378   gHistMCPrimaryMultiplicityTPC->Scale(100.);
1379   gHistMCPrimaryMultiplicityTPC->SetMarkerStyle(20);
1380   gHistMCPrimaryMultiplicityTPC->SetMarkerColor(1);
1381   gHistMCPrimaryMultiplicityTPC->GetYaxis()->SetTitle("#epsilon [%]");
1382   gHistMCPrimaryMultiplicityTPC->SetStats(kFALSE);
1383   gHistMCPrimaryMultiplicityTPC->Draw("E");
1384   c17->cd(2)->SetLeftMargin(0.15); c17->cd(2)->SetBottomMargin(0.15);  
1385   c17->cd(2)->SetRightMargin(0.2);
1386   gHistMCPrimaryMultiplicitySPD->Divide(gHistMCPrimaryMultiplicity);
1387   SetError(gHistMCPrimaryMultiplicitySPD,gHistMCPrimaryMultiplicity);
1388   gHistMCPrimaryMultiplicitySPD->Scale(100.);
1389   gHistMCPrimaryMultiplicitySPD->SetMarkerStyle(20);
1390   gHistMCPrimaryMultiplicitySPD->SetMarkerColor(1);
1391   gHistMCPrimaryMultiplicitySPD->GetYaxis()->SetTitle("#epsilon [%]");
1392   gHistMCPrimaryMultiplicitySPD->SetStats(kFALSE);
1393   gHistMCPrimaryMultiplicitySPD->Draw("E");
1394   c17->cd(3)->SetLeftMargin(0.15); c17->cd(3)->SetBottomMargin(0.15);  
1395   c17->cd(3)->SetRightMargin(0.2);
1396   gHistMCPrimaryMultiplicityTracks->Divide(gHistMCPrimaryMultiplicity);
1397   SetError(gHistMCPrimaryMultiplicityTracks,gHistMCPrimaryMultiplicity);
1398   gHistMCPrimaryMultiplicityTracks->Scale(100.);
1399   gHistMCPrimaryMultiplicityTracks->SetMarkerStyle(20);
1400   gHistMCPrimaryMultiplicityTracks->SetMarkerColor(1);
1401   gHistMCPrimaryMultiplicityTracks->GetYaxis()->SetTitle("#epsilon [%]");
1402   gHistMCPrimaryMultiplicityTracks->SetStats(kFALSE);
1403   gHistMCPrimaryMultiplicityTracks->Draw("E");
1404   c17->SaveAs("VertexEfficiency.gif");
1405
1406   //TPC vertex
1407   TCanvas *c18 = new TCanvas("c18",
1408                              "TPC vertex",
1409                              350,50,700,700);
1410   c18->SetHighLightColor(10); c18->Divide(3,3);
1411   c18->cd(1)->SetLeftMargin(0.15); c18->cd(1)->SetBottomMargin(0.15);  
1412   c18->cd(1)->SetRightMargin(0.2); c18->cd(1)->SetLogy();
1413   gHistTPCESDVx->Draw("col");
1414   c18->cd(2)->SetLeftMargin(0.15); c18->cd(2)->SetBottomMargin(0.15);  
1415   c18->cd(2)->SetRightMargin(0.2); c18->cd(2)->SetLogy();
1416   gHistTPCESDVy->Draw("col");
1417   c18->cd(3)->SetLeftMargin(0.15); c18->cd(3)->SetBottomMargin(0.15);  
1418   c18->cd(3)->SetRightMargin(0.2); c18->cd(3)->SetLogy();
1419   gHistTPCESDVz->Draw("col");
1420   c18->cd(4)->SetLeftMargin(0.15); c18->cd(4)->SetBottomMargin(0.15);  
1421   c18->cd(4)->SetRightMargin(0.2); c18->cd(4)->SetLogy();
1422   gHistTPCDiffVx->Draw();
1423   c18->cd(5)->SetLeftMargin(0.15); c18->cd(5)->SetBottomMargin(0.15);  
1424   c18->cd(5)->SetRightMargin(0.2); c18->cd(5)->SetLogy();
1425   gHistTPCDiffVy->Draw();
1426   c18->cd(6)->SetLeftMargin(0.15); c18->cd(6)->SetBottomMargin(0.15);  
1427   c18->cd(6)->SetRightMargin(0.2); c18->cd(6)->SetLogy();
1428   gHistTPCDiffVz->Draw();
1429   c18->cd(7)->SetLeftMargin(0.15); c18->cd(7)->SetBottomMargin(0.15);  
1430   c18->cd(7)->SetRightMargin(0.2); c18->cd(7)->SetLogy();
1431   gHistTPCResolutionVx->Draw();
1432   c18->cd(8)->SetLeftMargin(0.15); c18->cd(8)->SetBottomMargin(0.15);  
1433   c18->cd(8)->SetRightMargin(0.2); c18->cd(8)->SetLogy();
1434   gHistTPCResolutionVy->Draw();
1435   c18->cd(9)->SetLeftMargin(0.15); c18->cd(9)->SetBottomMargin(0.15);  
1436   c18->cd(9)->SetRightMargin(0.2); c18->cd(9)->SetLogy();
1437   gHistTPCResolutionVz->Draw();
1438   c18->SaveAs("VertexTPC.gif");
1439
1440   //SPD vertex
1441   TCanvas *c19 = new TCanvas("c19",
1442                              "SPD vertex",
1443                              400,100,700,700);
1444   c19->SetHighLightColor(10); c19->Divide(3,3);
1445   c19->cd(1)->SetLeftMargin(0.15); c19->cd(1)->SetBottomMargin(0.15);  
1446   c19->cd(1)->SetRightMargin(0.2); c19->cd(1)->SetLogy();
1447   gHistSPDESDVx->Draw("col");
1448   c19->cd(2)->SetLeftMargin(0.15); c19->cd(2)->SetBottomMargin(0.15);  
1449   c19->cd(2)->SetRightMargin(0.2); c19->cd(2)->SetLogy();
1450   gHistSPDESDVy->Draw("col");
1451   c19->cd(3)->SetLeftMargin(0.15); c19->cd(3)->SetBottomMargin(0.15);  
1452   c19->cd(3)->SetRightMargin(0.2); c19->cd(3)->SetLogy();
1453   gHistSPDESDVz->Draw("col");
1454   c19->cd(4)->SetLeftMargin(0.15); c19->cd(4)->SetBottomMargin(0.15);  
1455   c19->cd(4)->SetRightMargin(0.2); c19->cd(4)->SetLogy();
1456   gHistSPDDiffVx->Draw();
1457   c19->cd(5)->SetLeftMargin(0.15); c19->cd(5)->SetBottomMargin(0.15);  
1458   c19->cd(5)->SetRightMargin(0.2); c19->cd(5)->SetLogy();
1459   gHistSPDDiffVy->Draw();
1460   c19->cd(6)->SetLeftMargin(0.15); c19->cd(6)->SetBottomMargin(0.15);  
1461   c19->cd(6)->SetRightMargin(0.2); c19->cd(6)->SetLogy();
1462   gHistSPDDiffVz->Draw();
1463   c19->cd(7)->SetLeftMargin(0.15); c19->cd(7)->SetBottomMargin(0.15);  
1464   c19->cd(7)->SetRightMargin(0.2); c19->cd(7)->SetLogy();
1465   gHistSPDResolutionVx->Draw();
1466   c19->cd(8)->SetLeftMargin(0.15); c19->cd(8)->SetBottomMargin(0.15);  
1467   c19->cd(8)->SetRightMargin(0.2); c19->cd(8)->SetLogy();
1468   gHistSPDResolutionVy->Draw();
1469   c19->cd(9)->SetLeftMargin(0.15); c19->cd(9)->SetBottomMargin(0.15);  
1470   c19->cd(9)->SetRightMargin(0.2); c19->cd(9)->SetLogy();
1471   gHistSPDResolutionVz->Draw();
1472   c19->SaveAs("VertexSPD.gif");
1473
1474   //Tracks vertex
1475   TCanvas *c20 = new TCanvas("c20",
1476                              "Tracks vertex",
1477                              450,150,700,700);
1478   c20->SetHighLightColor(10); c20->Divide(3,3);
1479   c20->cd(1)->SetLeftMargin(0.15); c20->cd(1)->SetBottomMargin(0.15);  
1480   c20->cd(1)->SetRightMargin(0.2); c20->cd(1)->SetLogy();
1481   gHistTracksESDVx->Draw("col");
1482   c20->cd(2)->SetLeftMargin(0.15); c20->cd(2)->SetBottomMargin(0.15);  
1483   c20->cd(2)->SetRightMargin(0.2); c20->cd(2)->SetLogy();
1484   gHistTracksESDVy->Draw("col");
1485   c20->cd(3)->SetLeftMargin(0.15); c20->cd(3)->SetBottomMargin(0.15);  
1486   c20->cd(3)->SetRightMargin(0.2); c20->cd(3)->SetLogy();
1487   gHistTracksESDVz->Draw("col");
1488   c20->cd(4)->SetLeftMargin(0.15); c20->cd(4)->SetBottomMargin(0.15);  
1489   c20->cd(4)->SetRightMargin(0.2); c20->cd(4)->SetLogy();
1490   gHistTracksDiffVx->Draw();
1491   c20->cd(5)->SetLeftMargin(0.15); c20->cd(5)->SetBottomMargin(0.15);  
1492   c20->cd(5)->SetRightMargin(0.2); c20->cd(5)->SetLogy();
1493   gHistTracksDiffVy->Draw();
1494   c20->cd(6)->SetLeftMargin(0.15); c20->cd(6)->SetBottomMargin(0.15);  
1495   c20->cd(6)->SetRightMargin(0.2); c20->cd(6)->SetLogy();
1496   gHistTracksDiffVz->Draw();
1497   c20->cd(7)->SetLeftMargin(0.15); c20->cd(7)->SetBottomMargin(0.15);  
1498   c20->cd(7)->SetRightMargin(0.2); c20->cd(7)->SetLogy();
1499   gHistTracksResolutionVx->Draw();
1500   c20->cd(8)->SetLeftMargin(0.15); c20->cd(8)->SetBottomMargin(0.15);  
1501   c20->cd(8)->SetRightMargin(0.2); c20->cd(8)->SetLogy();
1502   gHistTracksResolutionVy->Draw();
1503   c20->cd(9)->SetLeftMargin(0.15); c20->cd(9)->SetBottomMargin(0.15);  
1504   c20->cd(9)->SetRightMargin(0.2); c20->cd(9)->SetLogy();
1505   gHistTracksResolutionVz->Draw();
1506   c20->SaveAs("VertexTracks.gif");
1507 }
1508
1509 //________________________________________//
1510 void drawEfficiency(TList *list,
1511                     const char* analysisType) {
1512   //Function to display the reconstruction and PID efficiencies
1513   //for protons and antiprotons vs y and pT
1514
1515   TH2F *hEmpty = new TH2F("hEmptyReconstructionEfficiency","",
1516                            100,-1.2,3.5,100,-10.0,130); 
1517   hEmpty->SetStats(kFALSE); 
1518   hEmpty->GetYaxis()->SetTitle("#epsilon [%]");
1519   hEmpty->GetYaxis()->SetTitleOffset(1.3);
1520
1521   //Reconstruction efficiency
1522   TH2D *gHistPrimariesMCYPtProtons = (TH2D *)list->At(0);
1523   TH2D *gHistPrimariesMCYPtAntiProtons = (TH2D *)list->At(1);
1524   TH2D *gHistMCYPtProtonsFromWeak = (TH2D *)list->At(2);
1525   TH2D *gHistMCYPtAntiProtonsFromWeak = (TH2D *)list->At(3);
1526   TH2D *gHistMCYPtProtonsFromHadronic = (TH2D *)list->At(4);
1527   TH2D *gHistMCYPtAntiProtonsFromHadronic = (TH2D *)list->At(5);
1528   TH2D *gHistPrimariesESDYPtProtons = (TH2D *)list->At(6);
1529   TH2D *gHistPrimariesESDYPtAntiProtons = (TH2D *)list->At(7);
1530   TH2D *gHistESDYPtProtonsFromWeak = (TH2D *)list->At(8);
1531   TH2D *gHistESDYPtAntiProtonsFromWeak = (TH2D *)list->At(9);
1532   TH2D *gHistESDYPtProtonsFromHadronic = (TH2D *)list->At(10);
1533   TH2D *gHistESDYPtAntiProtonsFromHadronic = (TH2D *)list->At(11);
1534
1535   //rapidity dependence
1536   TCanvas *c14 = new TCanvas("c14",
1537                              "(Anti)Proton reconstruction efficiency vs y",
1538                              650,650,700,400);
1539   c14->SetHighLightColor(10); c14->Divide(2,1);
1540
1541   //Primary Protons
1542   TH1D *gYPrimariesESDProtons = (TH1D *)gHistPrimariesESDYPtProtons->ProjectionX("gYPrimariesESDProtons",0,gHistPrimariesESDYPtProtons->GetXaxis()->GetNbins(),"e");
1543   TH1D *gYPrimariesMCProtons = (TH1D *)gHistPrimariesMCYPtProtons->ProjectionX("gYPrimariesMCProtons",0,gHistPrimariesMCYPtProtons->GetXaxis()->GetNbins(),"e");
1544   gYPrimariesESDProtons->Divide(gYPrimariesMCProtons);
1545   SetError(gYPrimariesESDProtons,gYPrimariesMCProtons);
1546   gYPrimariesESDProtons->Scale(100.);
1547   gYPrimariesESDProtons->SetMarkerStyle(kFullCircle);
1548
1549   //Primary AntiProtons
1550   TH1D *gYPrimariesESDAntiProtons = (TH1D *)gHistPrimariesESDYPtAntiProtons->ProjectionX("gYPrimariesESDAntiProtons",0,gHistPrimariesESDYPtAntiProtons->GetXaxis()->GetNbins(),"e");
1551   TH1D *gYPrimariesMCAntiProtons = (TH1D *)gHistPrimariesMCYPtAntiProtons->ProjectionX("gYPrimariesMCAntiProtons",0,gHistPrimariesMCYPtProtons->GetXaxis()->GetNbins(),"e");
1552   gYPrimariesESDAntiProtons->Divide(gYPrimariesMCAntiProtons);
1553   SetError(gYPrimariesESDAntiProtons,gYPrimariesMCAntiProtons);
1554   gYPrimariesESDAntiProtons->Scale(100.);
1555   gYPrimariesESDAntiProtons->SetMarkerStyle(kFullCircle);
1556
1557   //Protons from weak decays
1558   TH1D *gYESDProtonsFromWeak = (TH1D *)gHistESDYPtProtonsFromWeak->ProjectionX("gYESDProtonsFromWeak",0,gHistESDYPtProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1559   TH1D *gYMCProtonsFromWeak = (TH1D *)gHistMCYPtProtonsFromWeak->ProjectionX("gYMCProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1560   gYESDProtonsFromWeak->Divide(gYMCProtonsFromWeak);
1561   SetError(gYESDProtonsFromWeak,gYMCProtonsFromWeak);
1562   gYESDProtonsFromWeak->Scale(100.);
1563   gYESDProtonsFromWeak->SetMarkerStyle(21);
1564   gYESDProtonsFromWeak->SetMarkerColor(2);
1565
1566   //AntiProtons from weak decays
1567   TH1D *gYESDAntiProtonsFromWeak = (TH1D *)gHistESDYPtAntiProtonsFromWeak->ProjectionX("gYESDAntiProtonsFromWeak",0,gHistESDYPtAntiProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1568   TH1D *gYMCAntiProtonsFromWeak = (TH1D *)gHistMCYPtAntiProtonsFromWeak->ProjectionX("gYMCAntiProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1569   gYESDAntiProtonsFromWeak->Divide(gYMCAntiProtonsFromWeak);
1570   SetError(gYESDAntiProtonsFromWeak,gYMCAntiProtonsFromWeak);
1571   gYESDAntiProtonsFromWeak->Scale(100.);
1572   gYESDAntiProtonsFromWeak->SetMarkerStyle(21);
1573   gYESDAntiProtonsFromWeak->SetMarkerColor(2);
1574
1575   //Protons from hadronic interactions
1576   TH1D *gYESDProtonsFromHadronic = (TH1D *)gHistESDYPtProtonsFromHadronic->ProjectionX("gYESDProtonsFromHadronic",0,gHistESDYPtProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1577   TH1D *gYMCProtonsFromHadronic = (TH1D *)gHistMCYPtProtonsFromHadronic->ProjectionX("gYMCProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1578   gYESDProtonsFromHadronic->Divide(gYMCProtonsFromHadronic);
1579   SetError(gYESDProtonsFromHadronic,gYMCProtonsFromHadronic);
1580   gYESDProtonsFromHadronic->Scale(100.);
1581   gYESDProtonsFromHadronic->SetMarkerStyle(22);
1582   gYESDProtonsFromHadronic->SetMarkerColor(3);
1583
1584   //AntiProtons from hadronic interactions
1585   TH1D *gYESDAntiProtonsFromHadronic = (TH1D *)gHistESDYPtAntiProtonsFromHadronic->ProjectionX("gYESDAntiProtonsFromHadronic",0,gHistESDYPtAntiProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1586   TH1D *gYMCAntiProtonsFromHadronic = (TH1D *)gHistMCYPtAntiProtonsFromHadronic->ProjectionX("gYMCAntiProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1587   gYESDAntiProtonsFromHadronic->Divide(gYMCAntiProtonsFromHadronic);
1588   SetError(gYESDAntiProtonsFromHadronic,gYMCAntiProtonsFromHadronic);
1589   gYESDAntiProtonsFromHadronic->Scale(100.);
1590   gYESDAntiProtonsFromHadronic->SetMarkerStyle(22);
1591   gYESDAntiProtonsFromHadronic->SetMarkerColor(3);
1592
1593   c14->cd(1)->SetBottomMargin(0.15); 
1594   c14->cd(1)->SetLeftMargin(0.15); 
1595   c14->cd(1)->SetGridx(); c14->cd(1)->SetGridy();
1596   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.2,
1597                                    gYPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.2);
1598   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDAntiProtons->GetXaxis()->GetTitle());
1599   hEmpty->SetTitle("Protons");
1600   hEmpty->DrawCopy();
1601   gYPrimariesESDProtons->DrawCopy("ESAME");
1602   gYESDProtonsFromWeak->DrawCopy("ESAME");
1603   gYESDProtonsFromHadronic->DrawCopy("ESAME");
1604
1605   c14->cd(2)->SetBottomMargin(0.15); 
1606   c14->cd(2)->SetLeftMargin(0.15); 
1607   c14->cd(2)->SetGridx(); c14->cd(2)->SetGridy();
1608   hEmpty->SetTitle("Antiprotons");
1609   hEmpty->DrawCopy();
1610   gYPrimariesESDAntiProtons->DrawCopy("ESAME");
1611   gYESDAntiProtonsFromWeak->DrawCopy("ESAME");
1612   gYESDAntiProtonsFromHadronic->DrawCopy("ESAME");
1613   c14->SaveAs("ReconstructionEfficiency-Protons-Rapidity.gif");
1614
1615   //pT dependence
1616   TCanvas *c15 = new TCanvas("c15",
1617                              "(Anti)Proton reconstruction efficiency vs pT",
1618                              700,700,700,400);
1619   c15->SetHighLightColor(10); c15->Divide(2,1);
1620
1621   //Primary Protons
1622   TH1D *gPtPrimariesESDProtons = (TH1D *)gHistPrimariesESDYPtProtons->ProjectionY("gPtPrimariesESDProtons",0,gHistPrimariesESDYPtProtons->GetYaxis()->GetNbins(),"e");
1623   TH1D *gPtPrimariesMCProtons = (TH1D *)gHistPrimariesMCYPtProtons->ProjectionY("gPtPrimariesMCProtons",0,gHistPrimariesMCYPtProtons->GetYaxis()->GetNbins(),"e");
1624   gPtPrimariesESDProtons->Divide(gPtPrimariesMCProtons);
1625   SetError(gPtPrimariesESDProtons,gPtPrimariesMCProtons);
1626   gPtPrimariesESDProtons->Scale(100.);
1627   gPtPrimariesESDProtons->SetMarkerStyle(kFullCircle);
1628
1629   //Primary AntiProtons
1630   TH1D *gPtPrimariesESDAntiProtons = (TH1D *)gHistPrimariesESDYPtAntiProtons->ProjectionY("gPtPrimariesESDAntiProtons",0,gHistPrimariesESDYPtAntiProtons->GetYaxis()->GetNbins(),"e");
1631   TH1D *gPtPrimariesMCAntiProtons = (TH1D *)gHistPrimariesMCYPtAntiProtons->ProjectionY("gPtPrimariesMCAntiProtons",0,gHistPrimariesMCYPtProtons->GetYaxis()->GetNbins(),"e");
1632   gPtPrimariesESDAntiProtons->Divide(gPtPrimariesMCAntiProtons);
1633   SetError(gPtPrimariesESDAntiProtons,gPtPrimariesMCAntiProtons);
1634   gPtPrimariesESDAntiProtons->Scale(100.);
1635   gPtPrimariesESDAntiProtons->SetMarkerStyle(kFullCircle);
1636
1637   //Protons from weak decays
1638   TH1D *gPtESDProtonsFromWeak = (TH1D *)gHistESDYPtProtonsFromWeak->ProjectionY("gPtESDProtonsFromWeak",0,gHistESDYPtProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1639   TH1D *gPtMCProtonsFromWeak = (TH1D *)gHistMCYPtProtonsFromWeak->ProjectionY("gPtMCProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1640   gPtESDProtonsFromWeak->Divide(gPtMCProtonsFromWeak);
1641   SetError(gPtESDProtonsFromWeak,gPtMCProtonsFromWeak);
1642   gPtESDProtonsFromWeak->Scale(100.);
1643   gPtESDProtonsFromWeak->SetMarkerStyle(21);
1644   gPtESDProtonsFromWeak->SetMarkerColor(2);
1645
1646   //AntiProtons from weak decays
1647   TH1D *gPtESDAntiProtonsFromWeak = (TH1D *)gHistESDYPtAntiProtonsFromWeak->ProjectionY("gPtESDAntiProtonsFromWeak",0,gHistESDYPtAntiProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1648   TH1D *gPtMCAntiProtonsFromWeak = (TH1D *)gHistMCYPtAntiProtonsFromWeak->ProjectionY("gPtMCAntiProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1649   gPtESDAntiProtonsFromWeak->Divide(gPtMCAntiProtonsFromWeak);
1650   SetError(gPtESDAntiProtonsFromWeak,gPtMCAntiProtonsFromWeak);
1651   gPtESDAntiProtonsFromWeak->Scale(100.);
1652   gPtESDAntiProtonsFromWeak->SetMarkerStyle(21);
1653   gPtESDAntiProtonsFromWeak->SetMarkerColor(2);
1654
1655   //Protons from hadronic interactions
1656   TH1D *gPtESDProtonsFromHadronic = (TH1D *)gHistESDYPtProtonsFromHadronic->ProjectionY("gPtESDProtonsFromHadronic",0,gHistESDYPtProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1657   TH1D *gPtMCProtonsFromHadronic = (TH1D *)gHistMCYPtProtonsFromHadronic->ProjectionY("gPtMCProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1658   gPtESDProtonsFromHadronic->Divide(gPtMCProtonsFromHadronic);
1659   SetError(gPtESDProtonsFromHadronic,gPtMCProtonsFromHadronic);
1660   gPtESDProtonsFromHadronic->Scale(100.);
1661   gPtESDProtonsFromHadronic->SetMarkerStyle(22);
1662   gPtESDProtonsFromHadronic->SetMarkerColor(3);
1663
1664   //AntiProtons from hadronic interactions
1665   TH1D *gPtESDAntiProtonsFromHadronic = (TH1D *)gHistESDYPtAntiProtonsFromHadronic->ProjectionY("gPtESDAntiProtonsFromHadronic",0,gHistESDYPtAntiProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1666   TH1D *gPtMCAntiProtonsFromHadronic = (TH1D *)gHistMCYPtAntiProtonsFromHadronic->ProjectionY("gPtMCAntiProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1667   gPtESDAntiProtonsFromHadronic->Divide(gPtMCAntiProtonsFromHadronic);
1668   SetError(gPtESDAntiProtonsFromHadronic,gPtMCAntiProtonsFromHadronic);
1669   gPtESDAntiProtonsFromHadronic->Scale(100.);
1670   gPtESDAntiProtonsFromHadronic->SetMarkerStyle(22);
1671   gPtESDAntiProtonsFromHadronic->SetMarkerColor(3);
1672
1673
1674   c15->cd(1)->SetBottomMargin(0.15); 
1675   c15->cd(1)->SetLeftMargin(0.15); 
1676   c15->cd(1)->SetGridx(); c15->cd(1)->SetGridy();
1677   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.2,
1678                                    gPtPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.2);
1679   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1680   hEmpty->SetTitle("Protons");
1681   hEmpty->DrawCopy();
1682   gPtPrimariesESDProtons->DrawCopy("ESAME");
1683   gPtESDProtonsFromWeak->DrawCopy("ESAME");
1684   gPtESDProtonsFromHadronic->DrawCopy("ESAME");
1685
1686   c15->cd(2)->SetBottomMargin(0.15); 
1687   c15->cd(2)->SetLeftMargin(0.15); 
1688   c15->cd(2)->SetGridx(); c15->cd(2)->SetGridy();
1689   hEmpty->SetTitle("Antiprotons");
1690   hEmpty->DrawCopy();
1691   gPtPrimariesESDAntiProtons->DrawCopy("ESAME");
1692   gPtESDAntiProtonsFromWeak->DrawCopy("ESAME");
1693   gPtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
1694   c15->SaveAs("ReconstructionEfficiency-Protons-Pt.gif");
1695
1696   //______________//
1697   //PID efficiency//
1698   //______________//
1699   TH2D *gHistESDInitYPtProtons = (TH2D *)list->At(12);
1700   TH2D *gHistESDIdYPtProtons = (TH2D *)list->At(13);
1701   TH2D *gHistESDRecIdYPtProtons = (TH2D *)list->At(14);
1702   TH2D *gHistESDContamYPtProtons = (TH2D *)list->At(15);
1703
1704   TCanvas *c16 = new TCanvas("c16",
1705                              "(Anti)Proton PID efficiency vs y and pT",
1706                              750,750,700,400);
1707   c16->SetHighLightColor(10); c16->Divide(2,1);
1708
1709   //rapidity dependence
1710   //protons pid efficiency
1711   TH1D *gYESDIdProtons = (TH1D *)gHistESDIdYPtProtons->ProjectionX("gYESDIdProtons",0,gHistESDIdYPtProtons->GetXaxis()->GetNbins(),"e");
1712   TH1D *gYESDInitProtons = (TH1D *)gHistESDInitYPtProtons->ProjectionX("gYESDInitProtons",0,gHistESDInitYPtProtons->GetXaxis()->GetNbins(),"e");
1713   gYESDIdProtons->Divide(gYESDInitProtons);
1714   SetError(gYESDIdProtons,gYESDInitProtons);
1715   gYESDIdProtons->Scale(100.);
1716   gYESDIdProtons->SetMarkerStyle(kFullCircle);
1717
1718   //protons pid contamination
1719   TH1D *gYESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionX("gYESDContamProtons",0,gHistESDContamYPtProtons->GetXaxis()->GetNbins(),"e");
1720   TH1D *gYESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionX("gYESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetXaxis()->GetNbins(),"e");
1721   gYESDContamProtons->Divide(gYESDRecIdProtons);
1722   SetError(gYESDContamProtons,gYESDRecIdProtons);
1723   gYESDContamProtons->Scale(100.);
1724   gYESDContamProtons->SetMarkerStyle(kOpenCircle);
1725
1726   c16->cd(1)->SetBottomMargin(0.15); 
1727   c16->cd(1)->SetLeftMargin(0.15); 
1728   c16->cd(1)->SetGridx(); c16->cd(1)->SetGridy();
1729   hEmpty->GetXaxis()->SetRangeUser(-1.0.,1.0);
1730   hEmpty->GetXaxis()->SetTitle(gYESDContamProtons->GetXaxis()->GetTitle());
1731   hEmpty->DrawCopy();
1732   gYESDIdProtons->DrawCopy("ESAME");
1733   gYESDContamProtons->DrawCopy("ESAME");
1734
1735   //pT dependence
1736   //protons pid efficiency
1737   TH1D *gPtESDIdProtons = (TH1D *)gHistESDIdYPtProtons->ProjectionY("gPtESDIdProtons",0,gHistESDIdYPtProtons->GetYaxis()->GetNbins(),"e");
1738   TH1D *gPtESDInitProtons = (TH1D *)gHistESDInitYPtProtons->ProjectionY("gPtESDInitProtons",0,gHistESDInitYPtProtons->GetYaxis()->GetNbins(),"e");
1739   gPtESDIdProtons->Divide(gPtESDInitProtons);
1740   SetError(gPtESDIdProtons,gPtESDInitProtons);
1741   gPtESDIdProtons->Scale(100.);
1742   gPtESDIdProtons->SetMarkerStyle(kFullCircle);
1743
1744   //protons pid contamination
1745   TH1D *gPtESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionY("gPtESDContamProtons",0,gHistESDContamYPtProtons->GetYaxis()->GetNbins(),"e");
1746   TH1D *gPtESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionY("gPtESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetYaxis()->GetNbins(),"e");
1747   gPtESDContamProtons->Divide(gPtESDRecIdProtons);
1748   SetError(gPtESDContamProtons,gPtESDRecIdProtons);
1749   gPtESDContamProtons->Scale(100.);
1750   gPtESDContamProtons->SetMarkerStyle(kOpenCircle);
1751
1752   c16->cd(2)->SetBottomMargin(0.15); 
1753   c16->cd(2)->SetLeftMargin(0.15); 
1754   c16->cd(2)->SetGridx(); c16->cd(2)->SetGridy();
1755   hEmpty->GetXaxis()->SetRangeUser(0.0,1.2);
1756   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1757   hEmpty->DrawCopy();
1758   gPtESDIdProtons->DrawCopy("ESAME");
1759   gPtESDContamProtons->DrawCopy("ESAME");
1760
1761   c16->SaveAs("PIDEfficiency-Protons.gif");
1762
1763   TString outputFileName = "Reconstruction-PID-Efficiency.";
1764   outputFileName += analysisType; outputFileName += ".root";
1765   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
1766   gYPrimariesESDProtons->Write();
1767   gYESDProtonsFromWeak->Write();
1768   gYESDProtonsFromHadronic->Write();
1769   gPtPrimariesESDProtons->Write();
1770   gPtESDProtonsFromWeak->Write();
1771   gPtESDProtonsFromHadronic->Write();
1772   gYPrimariesESDAntiProtons->Write();
1773   gYESDAntiProtonsFromWeak->Write();
1774   gYESDAntiProtonsFromHadronic->Write();
1775   gPtPrimariesESDAntiProtons->Write();
1776   gPtESDAntiProtonsFromWeak->Write();
1777   gPtESDAntiProtonsFromHadronic->Write();
1778   gYESDIdProtons->Write();
1779   gYESDContamProtons->Write();
1780   gPtESDIdProtons->Write();
1781   gPtESDContamProtons->Write();
1782   fout->Close();
1783 }
1784
1785 //________________________________________________//
1786 void DrawMarker(Double_t x, Double_t y, Int_t style, 
1787                 Double_t size, Int_t color) {
1788   TMarker *m = new TMarker(x,y,style);
1789   m->SetMarkerSize(size);
1790   m->SetMarkerColor(color);
1791   m->Draw();
1792 }
1793
1794 //________________________________________________//
1795 const char * const gMCProcessName[45] = {
1796   "Primary particle emission",
1797   "Multiple scattering",
1798   "Energy loss",
1799   "Bending in magnetic field",
1800   "Decay",
1801   "Lepton pair production",
1802   "Compton scattering",
1803   "Photoelectric effect",
1804   "Bremstrahlung",
1805   "Delta ray",
1806   "Positron annihilation",
1807   "Positron annihilation at rest",
1808   "Positron annihilation in flight",
1809   "Hadronic interaction",
1810   "Nuclear evaporation",
1811   "Nuclear fission",
1812   "Nuclear absorbtion",
1813   "Antiproton annihilation",
1814   "Antineutron annihilation",
1815   "Neutron capture",
1816   "Hadronic elastic",
1817   "Hadronic incoherent elastic",
1818   "Hadronic coherent elastic",
1819   "Hadronic inelastic",
1820   "Photon inelastic",
1821   "Muon nuclear interaction",
1822   "Electron nuclear interaction",
1823   "Positron nuclear interaction",
1824   "Time of flight limit",
1825   "Nuclear photofission",
1826   "Rayleigh effect",
1827   "No active process",
1828   "Energy threshold",
1829   "Light absorption",
1830   "Light detection",
1831   "Light scattering",
1832   "Maximum allowed step",
1833   "Cerenkov production",
1834   "Cerenkov feed back photon",
1835   "Cerenkov photon reflection",
1836   "Cerenkov photon refraction",
1837   "Synchrotron radiation",
1838   "Scintillation",
1839   "Transportation",
1840   "Unknown process"
1841 };
1842
1843 //________________________________________________//
1844 void drawKineQA(const char *filename) {
1845   //Draws the QA plots for the kinematic variables for protons and antiprotons
1846   gStyle->SetPalette(1,0);
1847   gStyle->SetCanvasColor(41);
1848   gStyle->SetFrameFillColor(10);
1849
1850   TFile *f = TFile::Open(filename);
1851   TList *acceptedList = (TList *)f->Get("acceptedCutList");
1852   TH3D *gHistEtaPhiNClustersPrimaryProtonsPass = (TH3D *)acceptedList->At(44);
1853   TH3D *gHistEtaPhiNClustersSecondaryProtonsPass = (TH3D *)acceptedList->At(46);
1854   TH3D *gHistEtaPhiNClustersPrimaryAntiProtonsPass = (TH3D *)acceptedList->At(45);
1855   TH3D *gHistEtaPhiNClustersSecondaryAntiProtonsPass = (TH3D *)acceptedList->At(47);
1856
1857   TList *rejectedList = (TList *)f->Get("rejectedCutList");
1858   TH3D *gHistEtaPhiNClustersPrimaryProtonsReject = (TH3D *)rejectedList->At(0);
1859   gHistEtaPhiNClustersPrimaryProtonsPass->Add(gHistEtaPhiNClustersPrimaryProtonsReject);
1860   TH3D *gHistEtaPhiNClustersSecondaryProtonsReject = (TH3D *)rejectedList->At(2);
1861   gHistEtaPhiNClustersSecondaryProtonsPass->Add(gHistEtaPhiNClustersSecondaryProtonsReject);
1862   TH3D *gHistEtaPhiNClustersPrimaryAntiProtonsReject = (TH3D *)rejectedList->At(1);
1863   gHistEtaPhiNClustersPrimaryAntiProtonsPass->Add(gHistEtaPhiNClustersPrimaryAntiProtonsReject);
1864   TH3D *gHistEtaPhiNClustersSecondaryAntiProtonsReject = (TH3D *)rejectedList->At(3);
1865   gHistEtaPhiNClustersSecondaryAntiProtonsPass->Add(gHistEtaPhiNClustersSecondaryAntiProtonsReject);
1866
1867   //eta-phi
1868   TCanvas *c21 = new TCanvas("c21",
1869                              "#eta-#phi",
1870                              0,0,600,600);
1871   c21->SetHighLightColor(10); c21->Divide(2,2);
1872   c21->cd(1)->SetLeftMargin(0.15); c21->cd(1)->SetBottomMargin(0.15);  
1873   c21->cd(1)->SetRightMargin(0.2);
1874   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1875   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("yx")))->DrawCopy("colz");
1876   c21->cd(2)->SetLeftMargin(0.15); c21->cd(2)->SetBottomMargin(0.15);  
1877   c21->cd(2)->SetRightMargin(0.2);
1878   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1879   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("yx")))->DrawCopy("colz");
1880   c21->cd(3)->SetLeftMargin(0.15); c21->cd(3)->SetBottomMargin(0.15);  
1881   c21->cd(3)->SetRightMargin(0.2);
1882   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1883   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("yx")))->DrawCopy("colz");
1884   c21->cd(4)->SetLeftMargin(0.15); c21->cd(4)->SetBottomMargin(0.15);  
1885   c21->cd(4)->SetRightMargin(0.2);
1886   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1887   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("yx")))->DrawCopy("colz");
1888   c21->SaveAs("EtaPhi.gif");
1889
1890   //eta-Nclusters
1891   TCanvas *c22 = new TCanvas("c22",
1892                              "#eta-N_{clusters}",
1893                              100,100,600,600);
1894   c22->SetHighLightColor(10); c22->Divide(2,2);
1895   c22->cd(1)->SetLeftMargin(0.15); c22->cd(1)->SetBottomMargin(0.15);  
1896   c22->cd(1)->SetRightMargin(0.2);
1897   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1898   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
1899   c22->cd(2)->SetLeftMargin(0.15); c22->cd(2)->SetBottomMargin(0.15);  
1900   c22->cd(2)->SetRightMargin(0.2);
1901   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1902   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
1903   c22->cd(3)->SetLeftMargin(0.15); c22->cd(3)->SetBottomMargin(0.15);  
1904   c22->cd(3)->SetRightMargin(0.2);
1905   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1906   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
1907   c22->cd(4)->SetLeftMargin(0.15); c22->cd(4)->SetBottomMargin(0.15);  
1908   c22->cd(4)->SetRightMargin(0.2);
1909   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1910   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
1911   c22->SaveAs("EtaNClusters.gif");
1912
1913   //phi-Nclusters
1914   TCanvas *c23 = new TCanvas("c23",
1915                              "#phi-N_{clusters}",
1916                              200,200,600,600);
1917   c23->SetHighLightColor(10); c23->Divide(2,2);
1918   c23->cd(1)->SetLeftMargin(0.15); c23->cd(1)->SetBottomMargin(0.15);  
1919   c23->cd(1)->SetRightMargin(0.2);
1920   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1921   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
1922   c23->cd(2)->SetLeftMargin(0.15); c23->cd(2)->SetBottomMargin(0.15);  
1923   c23->cd(2)->SetRightMargin(0.2);
1924   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1925   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
1926   c23->cd(3)->SetLeftMargin(0.15); c23->cd(3)->SetBottomMargin(0.15);  
1927   c23->cd(3)->SetRightMargin(0.2);
1928   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1929   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
1930   c23->cd(4)->SetLeftMargin(0.15); c23->cd(4)->SetBottomMargin(0.15);  
1931   c23->cd(4)->SetRightMargin(0.2);
1932   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1933   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
1934   c23->SaveAs("PhiNClusters.gif");
1935
1936   f->Close();
1937 }
1938
1939 //________________________________________________//
1940 void drawEfficiencies(const char *filename,
1941                       Bool_t gShowPrimaries = kTRUE,
1942                       Bool_t gShowWeak = kFALSE,
1943                       Bool_t gShowHadronic = kFALSE) {
1944   //Macro to display the reconstruction, cut and pid efficiencies
1945   gStyle->SetPalette(1,0);
1946   gStyle->SetCanvasColor(41);
1947   gStyle->SetFrameFillColor(10);
1948
1949   TH2F *hEmpty = new TH2F("hEmpty","",100,-1.5,5.0,100,0,120);
1950   hEmpty->SetStats(kFALSE);
1951   hEmpty->GetXaxis()->SetTitleColor(1);
1952   hEmpty->GetXaxis()->SetNdivisions(15);
1953   hEmpty->GetYaxis()->SetNdivisions(15);
1954   hEmpty->GetYaxis()->SetTitleOffset(1.4);
1955   hEmpty->GetYaxis()->SetTitle("#epsilon");
1956
1957   TLatex *t1 = new TLatex();
1958   t1->SetTextSize(0.04);
1959
1960   TPaveText *tpave = new TPaveText();
1961   tpave->SetFillColor(10);
1962   Double_t bottomY = 0.0;
1963
1964   TFile *f = TFile::Open(filename);
1965   TH1D *gYPrimariesESDProtons = (TH1D *)f->Get("gYPrimariesESDProtons");
1966   TH1D *gYESDProtonsFromWeak = (TH1D *)f->Get("gYESDProtonsFromWeak");
1967   TH1D *gYESDProtonsFromHadronic = (TH1D *)f->Get("gYESDProtonsFromHadronic");
1968   TH1D *gPtPrimariesESDProtons = (TH1D *)f->Get("gPtPrimariesESDProtons");
1969   TH1D *gPtESDProtonsFromWeak = (TH1D *)f->Get("gPtESDProtonsFromWeak");
1970   TH1D *gPtESDProtonsFromHadronic = (TH1D *)f->Get("gPtESDProtonsFromHadronic");
1971   TH1D *gYPrimariesESDAntiProtons = (TH1D *)f->Get("gYPrimariesESDAntiProtons");
1972   TH1D *gYESDAntiProtonsFromWeak = (TH1D *)f->Get("gYESDAntiProtonsFromWeak");
1973   TH1D *gYESDAntiProtonsFromHadronic = (TH1D *)f->Get("gYESDAntiProtonsFromHadronic");  
1974   TH1D *gPtPrimariesESDAntiProtons = (TH1D *)f->Get("gPtPrimariesESDAntiProtons");      
1975   TH1D *gPtESDAntiProtonsFromWeak = (TH1D *)f->Get("gPtESDAntiProtonsFromWeak");        
1976   TH1D *gPtESDAntiProtonsFromHadronic = (TH1D *)f->Get("gPtESDAntiProtonsFromHadronic");        
1977   TH1D *gYESDIdProtons = (TH1D *)f->Get("gYESDIdProtons");
1978   TH1D *gYESDContamProtons = (TH1D *)f->Get("gYESDContamProtons");
1979   TH1D *gPtESDIdProtons = (TH1D *)f->Get("gPtESDIdProtons");
1980   TH1D *gPtESDContamProtons = (TH1D *)f->Get("gPtESDContamProtons");    
1981
1982   //Reconstruction efficiencies - protons
1983   TCanvas *c1 = new TCanvas("c1","Reconstruction efficiencies - Protons",
1984                             0,0,700,400);
1985   c1->SetFillColor(41); c1->SetHighLightColor(41);
1986   c1->Divide(2,1);
1987   c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15);
1988   c1->cd(1)->SetGridx(); c1->cd(1)->SetGridy();
1989   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
1990                                    gYPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
1991   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDProtons->GetXaxis()->GetTitle());
1992   hEmpty->DrawCopy();
1993   if(gShowPrimaries)
1994     bottomY = 111.0;
1995   if(gShowWeak)
1996     bottomY = 106.0;
1997   if(gShowHadronic)
1998     bottomY = 101.0;
1999   tpave->DrawPave(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.1,119,
2000                   gYPrimariesESDProtons->GetXaxis()->GetXmax()-0.1,bottomY);
2001   if(gShowPrimaries) {
2002     DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 115, 20, 1.2, 1);
2003     t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,113,"Primary p");
2004     gYPrimariesESDProtons->DrawCopy("ESAME");
2005   }
2006   if(gShowWeak) {
2007     DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 110, 21, 1.2, 2);
2008     t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,108,"#Lambda -> p + #pi^{-}");
2009     gYESDProtonsFromWeak->DrawCopy("ESAME");
2010   }
2011   if(gShowHadronic) {
2012     DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 105, 22, 1.2, 3);
2013     t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,103,"X + A -> p + B");
2014     gYESDProtonsFromHadronic->DrawCopy("ESAME");
2015   }
2016
2017   c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15);
2018   c1->cd(2)->SetGridx(); c1->cd(2)->SetGridy();
2019   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2020                                    gPtPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2021   hEmpty->GetXaxis()->SetTitle(gPtPrimariesESDProtons->GetXaxis()->GetTitle());
2022   hEmpty->DrawCopy();
2023   if(gShowPrimaries)
2024     bottomY = 111.0;
2025   if(gShowWeak)
2026     bottomY = 106.0;
2027   if(gShowHadronic)
2028     bottomY = 101.0;
2029   tpave->DrawPave(gPtPrimariesESDProtons->GetXaxis()->GetXmin(),119,
2030                   gPtPrimariesESDProtons->GetXaxis()->GetXmax(),bottomY);
2031   if(gShowPrimaries) {
2032     DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 115, 20, 1.2, 1);
2033     t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,113,"Primary p");
2034     gPtPrimariesESDProtons->DrawCopy("ESAME");
2035   }
2036   if(gShowWeak) {
2037     DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 110, 21, 1.2, 2);
2038     t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,108,"#Lambda -> p + #pi^{-}");
2039     gPtESDProtonsFromWeak->DrawCopy("ESAME");
2040   }
2041   if(gShowHadronic) {
2042     DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 105, 22, 1.2, 3);
2043     t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,103,"X + A -> p + B");
2044     gPtESDProtonsFromHadronic->DrawCopy("ESAME");
2045   }
2046   c1->SaveAs("ReconstructionEfficiency-Protons.gif");
2047
2048   //Reconstruction efficiencies - antiprotons
2049   TCanvas *c2 = new TCanvas("c2","Reconstruction efficiencies - Antirotons",
2050                             100,100,700,400);
2051   c2->SetFillColor(41); c2->SetHighLightColor(41);
2052   c2->Divide(2,1);
2053   c2->cd(1)->SetLeftMargin(0.15); c2->cd(1)->SetBottomMargin(0.15);
2054   c2->cd(1)->SetGridx(); c2->cd(1)->SetGridy();
2055   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.1,
2056                                    gYPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.1);
2057   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDAntiProtons->GetXaxis()->GetTitle());
2058   hEmpty->DrawCopy();
2059   if(gShowPrimaries)
2060     bottomY = 111.0;
2061   if(gShowWeak)
2062     bottomY = 104.0;
2063   if(gShowHadronic)
2064     bottomY = 97.0;
2065   tpave->DrawPave(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.1,119,
2066                   gYPrimariesESDAntiProtons->GetXaxis()->GetXmax()-0.1,bottomY);
2067   if(gShowPrimaries) {
2068     DrawMarker(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.2, 115, 20, 1.2, 1);
2069     t1->DrawLatex(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.3,113,"Primary #bar{p}");
2070     gYPrimariesESDAntiProtons->DrawCopy("ESAME");
2071   }
2072   if(gShowWeak) {
2073     DrawMarker(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.2, 108, 21, 1.2, 2);
2074     t1->DrawLatex(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.3,106,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2075     gYESDAntiProtonsFromWeak->DrawCopy("ESAME");
2076   }
2077   if(gShowHadronic) {
2078     DrawMarker(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.2, 101, 22, 1.2, 3);
2079     t1->DrawLatex(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.3,98,"X + A -> #bar{p} + B");
2080     gYESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2081   }
2082
2083   c2->cd(2)->SetLeftMargin(0.15); c2->cd(2)->SetBottomMargin(0.15);
2084   c2->cd(2)->SetGridx(); c2->cd(2)->SetGridy();
2085   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.1,
2086                                    gPtPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.1);
2087   hEmpty->GetXaxis()->SetTitle(gPtPrimariesESDAntiProtons->GetXaxis()->GetTitle());
2088   hEmpty->DrawCopy();
2089   hEmpty->DrawCopy();
2090   if(gShowPrimaries)
2091     bottomY = 111.0;
2092   if(gShowWeak)
2093     bottomY = 104.0;
2094   if(gShowHadronic)
2095     bottomY = 97.0;
2096   tpave->DrawPave(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin(),119,
2097                   gPtPrimariesESDAntiProtons->GetXaxis()->GetXmax(),bottomY);
2098   if(gShowPrimaries) {
2099     DrawMarker(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.05, 115, 20, 1.2, 1);
2100     t1->DrawLatex(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.15,113,"Primary #bar{p}");
2101     gPtPrimariesESDAntiProtons->DrawCopy("ESAME");
2102   }
2103   if(gShowWeak) {
2104     DrawMarker(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.05, 108, 21, 1.2, 2);
2105     t1->DrawLatex(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.15,106,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2106     gPtESDAntiProtonsFromWeak->DrawCopy("ESAME");
2107   }
2108   if(gShowHadronic) {
2109     DrawMarker(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.05, 101, 22, 1.2, 3);
2110     t1->DrawLatex(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.15,98,"X + A -> #bar{p} + B");
2111     gPtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2112   }
2113   c2->SaveAs("ReconstructionEfficiency-AntiProtons.gif");
2114
2115   //PID efficiencies - (anti)protons
2116   TCanvas *c3 = new TCanvas("c3","PID efficiencies",
2117                             200,200,700,400);
2118   c3->SetFillColor(41); c3->SetHighLightColor(41);
2119   c3->Divide(2,1);
2120   c3->cd(1)->SetLeftMargin(0.15); c3->cd(1)->SetBottomMargin(0.15);
2121   c3->cd(1)->SetGridx(); c3->cd(1)->SetGridy();
2122   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2123                                    gYPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2124   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDProtons->GetXaxis()->GetTitle());
2125   hEmpty->DrawCopy();
2126   tpave->DrawPave(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.1,119,
2127                   gYPrimariesESDProtons->GetXaxis()->GetXmax()-0.1,104);
2128   gYESDIdProtons->DrawCopy("ESAME");
2129   gYESDContamProtons->DrawCopy("ESAME");
2130   DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 115, 20, 1.2, 1);
2131   t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,113,"Efficiency");
2132   DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 108, 24, 1.2, 1);
2133   t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,106,"Contamination");
2134  
2135   c3->cd(2)->SetLeftMargin(0.15); c3->cd(2)->SetBottomMargin(0.15);
2136   c3->cd(2)->SetGridx(); c3->cd(2)->SetGridy();
2137   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2138                                    gPtPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2139   hEmpty->GetXaxis()->SetTitle(gPtPrimariesESDProtons->GetXaxis()->GetTitle());
2140   hEmpty->DrawCopy();
2141   tpave->DrawPave(gPtPrimariesESDProtons->GetXaxis()->GetXmin(),119,
2142                   gPtPrimariesESDProtons->GetXaxis()->GetXmax(),104);
2143   gPtESDIdProtons->DrawCopy("ESAME");
2144   gPtESDContamProtons->DrawCopy("ESAME");
2145   DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 115, 20, 1.2, 1);
2146   t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,113,"Efficiency");
2147   DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 108, 24, 1.2, 1);
2148   t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,106,"Contamination");
2149   c3->SaveAs("PIDEfficiency-Protons.gif");
2150 }
2151
2152 //________________________________________________//
2153 void compareEfficiencies(const char *filenameTPC,
2154                          const char *filenameHybrid,
2155                          Bool_t gShowPrimaries = kTRUE,
2156                          Bool_t gShowWeak = kFALSE,
2157                          Bool_t gShowHadronic = kFALSE) {
2158   //Function to compare the reconstruction efficiencies between two methods:
2159   //e.g. TPC standalone and global tracking
2160   gStyle->SetPalette(1,0);
2161   gStyle->SetCanvasColor(41);
2162   gStyle->SetFrameFillColor(10);
2163
2164   TH2F *hEmpty = new TH2F("hEmpty","",100,-1.5,2.0,100,0,120);
2165   hEmpty->SetStats(kFALSE);
2166   hEmpty->GetXaxis()->SetTitleColor(1);
2167   hEmpty->GetXaxis()->SetNdivisions(15);
2168   hEmpty->GetYaxis()->SetNdivisions(15);
2169   hEmpty->GetYaxis()->SetTitleOffset(1.4);
2170   hEmpty->GetYaxis()->SetTitle("#epsilon");
2171
2172   TLatex *t1 = new TLatex();
2173   t1->SetTextSize(0.04);
2174
2175   TPaveText *tpave = new TPaveText();
2176   tpave->SetFillColor(10);
2177   Double_t bottomY = 0.0;
2178
2179   //TPC standalone
2180   TFile *f1 = TFile::Open(filenameTPC);
2181   TH1D *g1YPrimariesESDProtons = (TH1D *)f1->Get("gYPrimariesESDProtons");
2182   TH1D *g1YESDProtonsFromWeak = (TH1D *)f1->Get("gYESDProtonsFromWeak");
2183   TH1D *g1YESDProtonsFromHadronic = (TH1D *)f1->Get("gYESDProtonsFromHadronic");
2184   TH1D *g1PtPrimariesESDProtons = (TH1D *)f1->Get("gPtPrimariesESDProtons");
2185   TH1D *g1PtESDProtonsFromWeak = (TH1D *)f1->Get("gPtESDProtonsFromWeak");
2186   TH1D *g1PtESDProtonsFromHadronic = (TH1D *)f1->Get("gPtESDProtonsFromHadronic");
2187   TH1D *g1YPrimariesESDAntiProtons = (TH1D *)f1->Get("gYPrimariesESDAntiProtons");
2188   TH1D *g1YESDAntiProtonsFromWeak = (TH1D *)f1->Get("gYESDAntiProtonsFromWeak");
2189   TH1D *g1YESDAntiProtonsFromHadronic = (TH1D *)f1->Get("gYESDAntiProtonsFromHadronic");        
2190   TH1D *g1PtPrimariesESDAntiProtons = (TH1D *)f1->Get("gPtPrimariesESDAntiProtons");    
2191   TH1D *g1PtESDAntiProtonsFromWeak = (TH1D *)f1->Get("gPtESDAntiProtonsFromWeak");      
2192   TH1D *g1PtESDAntiProtonsFromHadronic = (TH1D *)f1->Get("gPtESDAntiProtonsFromHadronic");      
2193
2194   //Global tracking
2195   TFile *f2 = TFile::Open(filenameHybrid);
2196   TH1D *g2YPrimariesESDProtons = (TH1D *)f2->Get("gYPrimariesESDProtons");
2197   TH1D *g2YESDProtonsFromWeak = (TH1D *)f2->Get("gYESDProtonsFromWeak");
2198   TH1D *g2YESDProtonsFromHadronic = (TH1D *)f2->Get("gYESDProtonsFromHadronic");
2199   TH1D *g2PtPrimariesESDProtons = (TH1D *)f2->Get("gPtPrimariesESDProtons");
2200   TH1D *g2PtESDProtonsFromWeak = (TH1D *)f2->Get("gPtESDProtonsFromWeak");
2201   TH1D *g2PtESDProtonsFromHadronic = (TH1D *)f2->Get("gPtESDProtonsFromHadronic");
2202   TH1D *g2YPrimariesESDAntiProtons = (TH1D *)f2->Get("gYPrimariesESDAntiProtons");
2203   TH1D *g2YESDAntiProtonsFromWeak = (TH1D *)f2->Get("gYESDAntiProtonsFromWeak");
2204   TH1D *g2YESDAntiProtonsFromHadronic = (TH1D *)f2->Get("gYESDAntiProtonsFromHadronic");        
2205   TH1D *g2PtPrimariesESDAntiProtons = (TH1D *)f2->Get("gPtPrimariesESDAntiProtons");    
2206   TH1D *g2PtESDAntiProtonsFromWeak = (TH1D *)f2->Get("gPtESDAntiProtonsFromWeak");      
2207   TH1D *g2PtESDAntiProtonsFromHadronic = (TH1D *)f2->Get("gPtESDAntiProtonsFromHadronic");      
2208
2209   //Reconstruction efficiencies - protons
2210   TCanvas *c1 = new TCanvas("c1","Reconstruction efficiencies - Protons",
2211                             0,0,700,400);
2212   c1->SetFillColor(41); c1->SetHighLightColor(41);
2213   c1->Divide(2,1);
2214   c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15);
2215   c1->cd(1)->SetGridx(); c1->cd(1)->SetGridy();
2216   hEmpty->GetXaxis()->SetRangeUser(-1.1,1.1);
2217   hEmpty->GetXaxis()->SetTitle("#eta");
2218   hEmpty->DrawCopy();
2219   if(gShowPrimaries)
2220     bottomY = 106.0;
2221   if(gShowWeak)
2222     bottomY = 99.0;
2223   if(gShowHadronic)
2224     bottomY = 92.0;
2225   tpave->DrawPave(-0.4,119,1.1,bottomY);
2226   t1->DrawLatex(-0.3,113,"TPC");
2227   t1->DrawLatex(0.0,113,"Global");
2228   if(gShowPrimaries) {
2229     DrawMarker(-0.15, 110, 20, 1.2, 1);
2230     DrawMarker(0.15, 110, 24, 1.2, 1);
2231     t1->DrawLatex(0.35,108,"Primary p");
2232     g1YPrimariesESDProtons->DrawCopy("ESAME");
2233     g2YPrimariesESDProtons->SetMarkerStyle(24);
2234     g2YPrimariesESDProtons->DrawCopy("ESAME");
2235   }
2236   if(gShowWeak) {
2237     DrawMarker(-0.15, 103, 21, 1.2, 2);
2238     DrawMarker(0.15, 103, 25, 1.2, 2);
2239     t1->DrawLatex(0.35,101,"#Lambda -> p + #pi^{-}");
2240     g1YESDProtonsFromWeak->DrawCopy("ESAME");
2241     g2YESDProtonsFromWeak->SetMarkerStyle(25);
2242     g2YESDProtonsFromWeak->DrawCopy("ESAME");
2243   }
2244   if(gShowHadronic) {
2245     DrawMarker(-0.15, 96, 22, 1.2, 3);
2246     DrawMarker(0.15, 96, 26, 1.2, 3);
2247     t1->DrawLatex(0.35,94,"X + A -> p + B");
2248     g1YESDProtonsFromHadronic->DrawCopy("ESAME");
2249     g2YESDProtonsFromHadronic->SetMarkerStyle(26);
2250     g2YESDProtonsFromHadronic->DrawCopy("ESAME");
2251   }
2252
2253   c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15);
2254   c1->cd(2)->SetGridx(); c1->cd(2)->SetGridy();
2255   hEmpty->GetXaxis()->SetRangeUser(0.0,1.7);
2256   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
2257   hEmpty->DrawCopy();
2258   if(gShowPrimaries)
2259     bottomY = 106.0;
2260   if(gShowWeak)
2261     bottomY = 99.0;
2262   if(gShowHadronic)
2263     bottomY = 92.0;
2264   tpave->DrawPave(0.05,119,1.2,bottomY);
2265   t1->DrawLatex(0.1,113,"TPC");
2266   t1->DrawLatex(0.3,113,"Global");
2267   if(gShowPrimaries) {
2268     DrawMarker(0.15, 110, 20, 1.2, 1);
2269     DrawMarker(0.4, 110, 24, 1.2, 1);
2270     t1->DrawLatex(0.6,108,"Primary p");
2271     g1PtPrimariesESDProtons->DrawCopy("ESAME");
2272     g2PtPrimariesESDProtons->SetMarkerStyle(24);
2273     g2PtPrimariesESDProtons->DrawCopy("ESAME");
2274   }
2275   if(gShowWeak) {
2276     DrawMarker(0.15, 103, 21, 1.2, 2);
2277     DrawMarker(0.4, 103, 25, 1.2, 2);
2278     t1->DrawLatex(0.6,101,"#Lambda -> p + #pi^{-}");
2279     g1PtESDProtonsFromWeak->DrawCopy("ESAME");
2280     g2PtESDProtonsFromWeak->SetMarkerStyle(25);
2281     g2PtESDProtonsFromWeak->DrawCopy("ESAME");
2282   }
2283   if(gShowHadronic) {
2284     DrawMarker(0.15, 96, 22, 1.2, 3);
2285     DrawMarker(0.4, 96, 26, 1.2, 3);
2286     t1->DrawLatex(0.6,94,"X + A -> p + B");
2287     g1PtESDProtonsFromHadronic->DrawCopy("ESAME");
2288     g2PtESDProtonsFromHadronic->SetMarkerStyle(26);
2289     g2PtESDProtonsFromHadronic->DrawCopy("ESAME");
2290   }
2291   c1->SaveAs("ReconstructionEfficiency-Protons.gif");
2292
2293   //Reconstruction efficiencies - antiprotons
2294   TCanvas *c2 = new TCanvas("c2","Reconstruction efficiencies - Antirotons",
2295                             100,100,700,400);
2296   c2->SetFillColor(41); c2->SetHighLightColor(41);
2297   c2->Divide(2,1);
2298   c2->cd(1)->SetLeftMargin(0.15); c2->cd(1)->SetBottomMargin(0.15);
2299   c2->cd(1)->SetGridx(); c2->cd(1)->SetGridy();
2300   hEmpty->GetXaxis()->SetRangeUser(-1.1,1.1);
2301   hEmpty->GetXaxis()->SetTitle("#eta");
2302   hEmpty->DrawCopy();
2303   if(gShowPrimaries)
2304     bottomY = 106.0;
2305   if(gShowWeak)
2306     bottomY = 99.0;
2307   if(gShowHadronic)
2308     bottomY = 92.0;
2309   tpave->DrawPave(-0.4,119,1.1,bottomY);
2310   t1->DrawLatex(-0.3,113,"TPC");
2311   t1->DrawLatex(0.0,113,"Global");
2312   if(gShowPrimaries) {
2313     DrawMarker(-0.15, 110, 20, 1.2, 1);
2314     DrawMarker(0.15, 110, 24, 1.2, 1);
2315     t1->DrawLatex(0.35,108,"Primary #bar{p}");
2316     g1YPrimariesESDAntiProtons->DrawCopy("ESAME");
2317     g2YPrimariesESDAntiProtons->SetMarkerStyle(24);
2318     g2YPrimariesESDAntiProtons->DrawCopy("ESAME");
2319   }
2320   if(gShowWeak) {
2321     DrawMarker(-0.15, 103, 21, 1.2, 2);
2322     DrawMarker(0.15, 103, 25, 1.2, 2);
2323     t1->DrawLatex(0.35,101,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2324     g1YESDAntiProtonsFromWeak->DrawCopy("ESAME");
2325     g2YESDAntiProtonsFromWeak->SetMarkerStyle(25);
2326     g2YESDAntiProtonsFromWeak->DrawCopy("ESAME");
2327   }
2328   if(gShowHadronic) {
2329     DrawMarker(-0.15, 96, 22, 1.2, 3);
2330     DrawMarker(0.15, 96, 26, 1.2, 3);
2331     t1->DrawLatex(0.35,94,"X + A -> #bar{p} + B");
2332     g1YESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2333     g2YESDAntiProtonsFromHadronic->SetMarkerStyle(26);
2334     g2YESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2335   }
2336
2337   c2->cd(2)->SetLeftMargin(0.15); c2->cd(2)->SetBottomMargin(0.15);
2338   c2->cd(2)->SetGridx(); c2->cd(2)->SetGridy();
2339   hEmpty->GetXaxis()->SetRangeUser(0.0,1.7);
2340   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
2341   hEmpty->DrawCopy();
2342   if(gShowPrimaries)
2343     bottomY = 106.0;
2344   if(gShowWeak)
2345     bottomY = 99.0;
2346   if(gShowHadronic)
2347     bottomY = 92.0;
2348   tpave->DrawPave(0.05,119,1.2,bottomY);
2349   t1->DrawLatex(0.1,113,"TPC");
2350   t1->DrawLatex(0.3,113,"Global");
2351   if(gShowPrimaries) {
2352     DrawMarker(0.15, 110, 20, 1.2, 1);
2353     DrawMarker(0.4, 110, 24, 1.2, 1);
2354     t1->DrawLatex(0.6,108,"Primary #bar{p}");
2355     g1PtPrimariesESDAntiProtons->DrawCopy("ESAME");
2356     g2PtPrimariesESDAntiProtons->SetMarkerStyle(24);
2357     g2PtPrimariesESDAntiProtons->DrawCopy("ESAME");
2358   }
2359   if(gShowWeak) {
2360     DrawMarker(0.15, 103, 21, 1.2, 2);
2361     DrawMarker(0.4, 103, 25, 1.2, 2);
2362     t1->DrawLatex(0.6,101,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2363     g1PtESDAntiProtonsFromWeak->DrawCopy("ESAME");
2364     g2PtESDAntiProtonsFromWeak->SetMarkerStyle(25);
2365     g2PtESDAntiProtonsFromWeak->DrawCopy("ESAME");
2366   }
2367   if(gShowHadronic) {
2368     DrawMarker(0.15, 96, 22, 1.2, 3);
2369     DrawMarker(0.4, 96, 26, 1.2, 3);
2370     t1->DrawLatex(0.6,94,"X + A -> #bar{p} + B");
2371     g1PtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2372     g2PtESDAntiProtonsFromHadronic->SetMarkerStyle(26);
2373     g2PtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2374   }
2375   c2->SaveAs("ReconstructionEfficiency-AntiProtons.gif");
2376
2377 }