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