Adding the QA plot for the pid efficiency/contamination vs the number of TPC points...
[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   TH3D *gHistESDInitYPtProtons = (TH3D *)list->At(12);
1712   TH3D *gHistESDIdYPtProtons = (TH3D *)list->At(13);
1713   TH3D *gHistESDRecIdYPtProtons = (TH3D *)list->At(14);
1714   TH3D *gHistESDContamYPtProtons = (TH3D *)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(3,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   TH1D *gYESDIdProtons = (TH1D *)gHistESDIdYPtProtons->Project3D("x");
1726   TH1D *gYESDInitProtons = (TH1D *)gHistESDInitYPtProtons->Project3D("x");
1727   gYESDIdProtons->Divide(gYESDInitProtons);
1728   SetError(gYESDIdProtons,gYESDInitProtons);
1729   gYESDIdProtons->Scale(100.);
1730   gYESDIdProtons->SetMarkerStyle(kFullCircle);
1731
1732   //protons pid contamination
1733   //TH1D *gYESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionX("gYESDContamProtons",0,gHistESDContamYPtProtons->GetXaxis()->GetNbins(),"e");
1734   //TH1D *gYESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionX("gYESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetXaxis()->GetNbins(),"e");
1735   TH1D *gYESDContamProtons = (TH1D *)gHistESDContamYPtProtons->Project3D("x");
1736   TH1D *gYESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->Project3D("x");
1737   gYESDContamProtons->Divide(gYESDRecIdProtons);
1738   SetError(gYESDContamProtons,gYESDRecIdProtons);
1739   gYESDContamProtons->Scale(100.);
1740   gYESDContamProtons->SetMarkerStyle(kOpenCircle);
1741
1742   c16->cd(1)->SetBottomMargin(0.15); 
1743   c16->cd(1)->SetLeftMargin(0.15); 
1744   c16->cd(1)->SetGridx(); c16->cd(1)->SetGridy();
1745   hEmpty->GetXaxis()->SetRangeUser(-1.0.,1.0);
1746   hEmpty->GetXaxis()->SetTitle(gYESDContamProtons->GetXaxis()->GetTitle());
1747   hEmpty->DrawCopy();
1748   gYESDIdProtons->DrawCopy("ESAME");
1749   gYESDContamProtons->DrawCopy("ESAME");
1750
1751   //pT dependence
1752   //protons pid efficiency
1753   //TH1D *gPtESDIdProtons = (TH1D *)gHistESDIdYPtProtons->ProjectionY("gPtESDIdProtons",0,gHistESDIdYPtProtons->GetYaxis()->GetNbins(),"e");
1754   //TH1D *gPtESDInitProtons = (TH1D *)gHistESDInitYPtProtons->ProjectionY("gPtESDInitProtons",0,gHistESDInitYPtProtons->GetYaxis()->GetNbins(),"e");
1755   TH1D *gPtESDIdProtons = (TH1D *)gHistESDIdYPtProtons->Project3D("y");
1756   TH1D *gPtESDInitProtons = (TH1D *)gHistESDInitYPtProtons->Project3D("y");
1757   gPtESDIdProtons->Divide(gPtESDInitProtons);
1758   SetError(gPtESDIdProtons,gPtESDInitProtons);
1759   gPtESDIdProtons->Scale(100.);
1760   gPtESDIdProtons->SetMarkerStyle(kFullCircle);
1761
1762   //protons pid contamination
1763   //TH1D *gPtESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionY("gPtESDContamProtons",0,gHistESDContamYPtProtons->GetYaxis()->GetNbins(),"e");
1764   //TH1D *gPtESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionY("gPtESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetYaxis()->GetNbins(),"e");
1765   TH1D *gPtESDContamProtons = (TH1D *)gHistESDContamYPtProtons->Project3D("y");
1766   TH1D *gPtESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->Project3D("y");
1767   gPtESDContamProtons->Divide(gPtESDRecIdProtons);
1768   SetError(gPtESDContamProtons,gPtESDRecIdProtons);
1769   gPtESDContamProtons->Scale(100.);
1770   gPtESDContamProtons->SetMarkerStyle(kOpenCircle);
1771
1772   c16->cd(2)->SetBottomMargin(0.15); 
1773   c16->cd(2)->SetLeftMargin(0.15); 
1774   c16->cd(2)->SetGridx(); c16->cd(2)->SetGridy();
1775   hEmpty->GetXaxis()->SetRangeUser(0.0,1.2);
1776   hEmpty->GetXaxis()->SetTitle(gPtESDContamProtons->GetXaxis()->GetTitle());
1777   hEmpty->DrawCopy();
1778   gPtESDIdProtons->DrawCopy("ESAME");
1779   gPtESDContamProtons->DrawCopy("ESAME");
1780
1781   //N_points dependence
1782   //protons pid efficiency
1783   TH1D *gNPointsESDIdProtons = (TH1D *)gHistESDIdYPtProtons->Project3D("y");
1784   TH1D *gNPointsESDInitProtons = (TH1D *)gHistESDInitYPtProtons->Project3D("y");
1785   gNPointsESDIdProtons->Divide(gNPointsESDInitProtons);
1786   SetError(gNPointsESDIdProtons,gNPointsESDInitProtons);
1787   gNPointsESDIdProtons->Scale(100.);
1788   gNPointsESDIdProtons->SetMarkerStyle(kFullCircle);
1789
1790   //protons pid contamination
1791   TH1D *gNPointsESDContamProtons = (TH1D *)gHistESDContamYPtProtons->Project3D("z");
1792   TH1D *gNPointsESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->Project3D("z");
1793   gNPointsESDContamProtons->Divide(gNPointsESDRecIdProtons);
1794   SetError(gNPointsESDContamProtons,gNPointsESDRecIdProtons);
1795   gNPointsESDContamProtons->Scale(100.);
1796   gNPointsESDContamProtons->SetMarkerStyle(kOpenCircle);
1797
1798   c16->cd(3)->SetBottomMargin(0.15); 
1799   c16->cd(3)->SetLeftMargin(0.15); 
1800   c16->cd(3)->SetGridx(); c16->cd(2)->SetGridy();
1801   hEmpty->GetXaxis()->SetRangeUser(0.0,1.2);
1802   hEmpty->GetXaxis()->SetTitle(gNPointsESDContamProtons->GetXaxis()->GetTitle());
1803   hEmpty->DrawCopy();
1804   gNPointsESDIdProtons->DrawCopy("ESAME");
1805   gNPointsESDContamProtons->DrawCopy("ESAME");
1806
1807   c16->SaveAs("PIDEfficiency-Protons.gif");
1808
1809   TString outputFileName = "Reconstruction-PID-Efficiency.";
1810   outputFileName += analysisType; outputFileName += ".root";
1811   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
1812   gYPrimariesESDProtons->Write();
1813   gYESDProtonsFromWeak->Write();
1814   gYESDProtonsFromHadronic->Write();
1815   gPtPrimariesESDProtons->Write();
1816   gPtESDProtonsFromWeak->Write();
1817   gPtESDProtonsFromHadronic->Write();
1818   gYPrimariesESDAntiProtons->Write();
1819   gYESDAntiProtonsFromWeak->Write();
1820   gYESDAntiProtonsFromHadronic->Write();
1821   gPtPrimariesESDAntiProtons->Write();
1822   gPtESDAntiProtonsFromWeak->Write();
1823   gPtESDAntiProtonsFromHadronic->Write();
1824   gYESDIdProtons->Write();
1825   gYESDContamProtons->Write();
1826   gPtESDIdProtons->Write();
1827   gPtESDContamProtons->Write();
1828   gNPointsESDIdProtons->Write();
1829   gNPointsESDContamProtons->Write();
1830   fout->Close();
1831 }
1832
1833 //________________________________________________//
1834 void DrawMarker(Double_t x, Double_t y, Int_t style, 
1835                 Double_t size, Int_t color) {
1836   TMarker *m = new TMarker(x,y,style);
1837   m->SetMarkerSize(size);
1838   m->SetMarkerColor(color);
1839   m->Draw();
1840 }
1841
1842 //________________________________________________//
1843 const char * const gMCProcessName[45] = {
1844   "Primary particle emission",
1845   "Multiple scattering",
1846   "Energy loss",
1847   "Bending in magnetic field",
1848   "Decay",
1849   "Lepton pair production",
1850   "Compton scattering",
1851   "Photoelectric effect",
1852   "Bremstrahlung",
1853   "Delta ray",
1854   "Positron annihilation",
1855   "Positron annihilation at rest",
1856   "Positron annihilation in flight",
1857   "Hadronic interaction",
1858   "Nuclear evaporation",
1859   "Nuclear fission",
1860   "Nuclear absorbtion",
1861   "Antiproton annihilation",
1862   "Antineutron annihilation",
1863   "Neutron capture",
1864   "Hadronic elastic",
1865   "Hadronic incoherent elastic",
1866   "Hadronic coherent elastic",
1867   "Hadronic inelastic",
1868   "Photon inelastic",
1869   "Muon nuclear interaction",
1870   "Electron nuclear interaction",
1871   "Positron nuclear interaction",
1872   "Time of flight limit",
1873   "Nuclear photofission",
1874   "Rayleigh effect",
1875   "No active process",
1876   "Energy threshold",
1877   "Light absorption",
1878   "Light detection",
1879   "Light scattering",
1880   "Maximum allowed step",
1881   "Cerenkov production",
1882   "Cerenkov feed back photon",
1883   "Cerenkov photon reflection",
1884   "Cerenkov photon refraction",
1885   "Synchrotron radiation",
1886   "Scintillation",
1887   "Transportation",
1888   "Unknown process"
1889 };
1890
1891 //________________________________________________//
1892 void drawKineQA(const char *filename) {
1893   //Draws the QA plots for the kinematic variables for protons and antiprotons
1894   gStyle->SetPalette(1,0);
1895   gStyle->SetCanvasColor(41);
1896   gStyle->SetFrameFillColor(10);
1897
1898   TFile *f = TFile::Open(filename);
1899   TList *acceptedList = (TList *)f->Get("acceptedCutList");
1900   TH3D *gHistEtaPhiNClustersPrimaryProtonsPass = (TH3D *)acceptedList->At(44);
1901   TH3D *gHistEtaPhiNClustersSecondaryProtonsPass = (TH3D *)acceptedList->At(46);
1902   TH3D *gHistEtaPhiNClustersPrimaryAntiProtonsPass = (TH3D *)acceptedList->At(45);
1903   TH3D *gHistEtaPhiNClustersSecondaryAntiProtonsPass = (TH3D *)acceptedList->At(47);
1904
1905   TList *rejectedList = (TList *)f->Get("rejectedCutList");
1906   TH3D *gHistEtaPhiNClustersPrimaryProtonsReject = (TH3D *)rejectedList->At(0);
1907   gHistEtaPhiNClustersPrimaryProtonsPass->Add(gHistEtaPhiNClustersPrimaryProtonsReject);
1908   TH3D *gHistEtaPhiNClustersSecondaryProtonsReject = (TH3D *)rejectedList->At(2);
1909   gHistEtaPhiNClustersSecondaryProtonsPass->Add(gHistEtaPhiNClustersSecondaryProtonsReject);
1910   TH3D *gHistEtaPhiNClustersPrimaryAntiProtonsReject = (TH3D *)rejectedList->At(1);
1911   gHistEtaPhiNClustersPrimaryAntiProtonsPass->Add(gHistEtaPhiNClustersPrimaryAntiProtonsReject);
1912   TH3D *gHistEtaPhiNClustersSecondaryAntiProtonsReject = (TH3D *)rejectedList->At(3);
1913   gHistEtaPhiNClustersSecondaryAntiProtonsPass->Add(gHistEtaPhiNClustersSecondaryAntiProtonsReject);
1914
1915   //eta-phi
1916   TCanvas *c21 = new TCanvas("c21",
1917                              "#eta-#phi",
1918                              0,0,600,600);
1919   c21->SetHighLightColor(10); c21->Divide(2,2);
1920   c21->cd(1)->SetLeftMargin(0.15); c21->cd(1)->SetBottomMargin(0.15);  
1921   c21->cd(1)->SetRightMargin(0.2);
1922   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1923   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("yx")))->DrawCopy("colz");
1924   c21->cd(2)->SetLeftMargin(0.15); c21->cd(2)->SetBottomMargin(0.15);  
1925   c21->cd(2)->SetRightMargin(0.2);
1926   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1927   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("yx")))->DrawCopy("colz");
1928   c21->cd(3)->SetLeftMargin(0.15); c21->cd(3)->SetBottomMargin(0.15);  
1929   c21->cd(3)->SetRightMargin(0.2);
1930   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1931   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("yx")))->DrawCopy("colz");
1932   c21->cd(4)->SetLeftMargin(0.15); c21->cd(4)->SetBottomMargin(0.15);  
1933   c21->cd(4)->SetRightMargin(0.2);
1934   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("yx")))->SetStats(kFALSE);
1935   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("yx")))->DrawCopy("colz");
1936   c21->SaveAs("EtaPhi.gif");
1937
1938   //eta-Nclusters
1939   TCanvas *c22 = new TCanvas("c22",
1940                              "#eta-N_{clusters}",
1941                              100,100,600,600);
1942   c22->SetHighLightColor(10); c22->Divide(2,2);
1943   c22->cd(1)->SetLeftMargin(0.15); c22->cd(1)->SetBottomMargin(0.15);  
1944   c22->cd(1)->SetRightMargin(0.2);
1945   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1946   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
1947   c22->cd(2)->SetLeftMargin(0.15); c22->cd(2)->SetBottomMargin(0.15);  
1948   c22->cd(2)->SetRightMargin(0.2);
1949   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1950   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zx")))->DrawCopy("colz");
1951   c22->cd(3)->SetLeftMargin(0.15); c22->cd(3)->SetBottomMargin(0.15);  
1952   c22->cd(3)->SetRightMargin(0.2);
1953   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1954   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
1955   c22->cd(4)->SetLeftMargin(0.15); c22->cd(4)->SetBottomMargin(0.15);  
1956   c22->cd(4)->SetRightMargin(0.2);
1957   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zx")))->SetStats(kFALSE);
1958   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zx")))->DrawCopy("colz");
1959   c22->SaveAs("EtaNClusters.gif");
1960
1961   //phi-Nclusters
1962   TCanvas *c23 = new TCanvas("c23",
1963                              "#phi-N_{clusters}",
1964                              200,200,600,600);
1965   c23->SetHighLightColor(10); c23->Divide(2,2);
1966   c23->cd(1)->SetLeftMargin(0.15); c23->cd(1)->SetBottomMargin(0.15);  
1967   c23->cd(1)->SetRightMargin(0.2);
1968   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1969   ((TH2D *)(gHistEtaPhiNClustersPrimaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
1970   c23->cd(2)->SetLeftMargin(0.15); c23->cd(2)->SetBottomMargin(0.15);  
1971   c23->cd(2)->SetRightMargin(0.2);
1972   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1973   ((TH2D *)(gHistEtaPhiNClustersSecondaryProtonsPass->Project3D("zy")))->DrawCopy("colz");
1974   c23->cd(3)->SetLeftMargin(0.15); c23->cd(3)->SetBottomMargin(0.15);  
1975   c23->cd(3)->SetRightMargin(0.2);
1976   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1977   ((TH2D *)(gHistEtaPhiNClustersPrimaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
1978   c23->cd(4)->SetLeftMargin(0.15); c23->cd(4)->SetBottomMargin(0.15);  
1979   c23->cd(4)->SetRightMargin(0.2);
1980   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zy")))->SetStats(kFALSE);
1981   ((TH2D *)(gHistEtaPhiNClustersSecondaryAntiProtonsPass->Project3D("zy")))->DrawCopy("colz");
1982   c23->SaveAs("PhiNClusters.gif");
1983
1984   f->Close();
1985 }
1986
1987 //________________________________________________//
1988 void drawEfficiencies(const char *filename,
1989                       Bool_t gShowPrimaries = kTRUE,
1990                       Bool_t gShowWeak = kFALSE,
1991                       Bool_t gShowHadronic = kFALSE) {
1992   //Macro to display the reconstruction, cut and pid efficiencies
1993   gStyle->SetPalette(1,0);
1994   gStyle->SetCanvasColor(41);
1995   gStyle->SetFrameFillColor(10);
1996
1997   TH2F *hEmpty = new TH2F("hEmpty","",100,-1.5,5.0,100,0,120);
1998   hEmpty->SetStats(kFALSE);
1999   hEmpty->GetXaxis()->SetTitleColor(1);
2000   hEmpty->GetXaxis()->SetNdivisions(15);
2001   hEmpty->GetYaxis()->SetNdivisions(15);
2002   hEmpty->GetYaxis()->SetTitleOffset(1.4);
2003   hEmpty->GetYaxis()->SetTitle("#epsilon");
2004
2005   TLatex *t1 = new TLatex();
2006   t1->SetTextSize(0.04);
2007
2008   TPaveText *tpave = new TPaveText();
2009   tpave->SetFillColor(10);
2010   Double_t bottomY = 0.0;
2011
2012   TFile *f = TFile::Open(filename);
2013   TH1D *gYPrimariesESDProtons = (TH1D *)f->Get("gYPrimariesESDProtons");
2014   TH1D *gYESDProtonsFromWeak = (TH1D *)f->Get("gYESDProtonsFromWeak");
2015   TH1D *gYESDProtonsFromHadronic = (TH1D *)f->Get("gYESDProtonsFromHadronic");
2016   TH1D *gPtPrimariesESDProtons = (TH1D *)f->Get("gPtPrimariesESDProtons");
2017   TH1D *gPtESDProtonsFromWeak = (TH1D *)f->Get("gPtESDProtonsFromWeak");
2018   TH1D *gPtESDProtonsFromHadronic = (TH1D *)f->Get("gPtESDProtonsFromHadronic");
2019   TH1D *gYPrimariesESDAntiProtons = (TH1D *)f->Get("gYPrimariesESDAntiProtons");
2020   TH1D *gYESDAntiProtonsFromWeak = (TH1D *)f->Get("gYESDAntiProtonsFromWeak");
2021   TH1D *gYESDAntiProtonsFromHadronic = (TH1D *)f->Get("gYESDAntiProtonsFromHadronic");  
2022   TH1D *gPtPrimariesESDAntiProtons = (TH1D *)f->Get("gPtPrimariesESDAntiProtons");      
2023   TH1D *gPtESDAntiProtonsFromWeak = (TH1D *)f->Get("gPtESDAntiProtonsFromWeak");        
2024   TH1D *gPtESDAntiProtonsFromHadronic = (TH1D *)f->Get("gPtESDAntiProtonsFromHadronic");        
2025   TH1D *gYESDIdProtons = (TH1D *)f->Get("gYESDIdProtons");
2026   TH1D *gYESDContamProtons = (TH1D *)f->Get("gYESDContamProtons");
2027   TH1D *gPtESDIdProtons = (TH1D *)f->Get("gPtESDIdProtons");
2028   TH1D *gPtESDContamProtons = (TH1D *)f->Get("gPtESDContamProtons");    
2029
2030   //Reconstruction efficiencies - protons
2031   TCanvas *c1 = new TCanvas("c1","Reconstruction efficiencies - Protons",
2032                             0,0,700,400);
2033   c1->SetFillColor(41); c1->SetHighLightColor(41);
2034   c1->Divide(2,1);
2035   c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15);
2036   c1->cd(1)->SetGridx(); c1->cd(1)->SetGridy();
2037   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2038                                    gYPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2039   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDProtons->GetXaxis()->GetTitle());
2040   hEmpty->DrawCopy();
2041   if(gShowPrimaries)
2042     bottomY = 111.0;
2043   if(gShowWeak)
2044     bottomY = 106.0;
2045   if(gShowHadronic)
2046     bottomY = 101.0;
2047   tpave->DrawPave(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.1,119,
2048                   gYPrimariesESDProtons->GetXaxis()->GetXmax()-0.1,bottomY);
2049   if(gShowPrimaries) {
2050     DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 115, 20, 1.2, 1);
2051     t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,113,"Primary p");
2052     gYPrimariesESDProtons->DrawCopy("ESAME");
2053   }
2054   if(gShowWeak) {
2055     DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 110, 21, 1.2, 2);
2056     t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,108,"#Lambda -> p + #pi^{-}");
2057     gYESDProtonsFromWeak->DrawCopy("ESAME");
2058   }
2059   if(gShowHadronic) {
2060     DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 105, 22, 1.2, 3);
2061     t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,103,"X + A -> p + B");
2062     gYESDProtonsFromHadronic->DrawCopy("ESAME");
2063   }
2064
2065   c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15);
2066   c1->cd(2)->SetGridx(); c1->cd(2)->SetGridy();
2067   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2068                                    gPtPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2069   hEmpty->GetXaxis()->SetTitle(gPtPrimariesESDProtons->GetXaxis()->GetTitle());
2070   hEmpty->DrawCopy();
2071   if(gShowPrimaries)
2072     bottomY = 111.0;
2073   if(gShowWeak)
2074     bottomY = 106.0;
2075   if(gShowHadronic)
2076     bottomY = 101.0;
2077   tpave->DrawPave(gPtPrimariesESDProtons->GetXaxis()->GetXmin(),119,
2078                   gPtPrimariesESDProtons->GetXaxis()->GetXmax(),bottomY);
2079   if(gShowPrimaries) {
2080     DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 115, 20, 1.2, 1);
2081     t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,113,"Primary p");
2082     gPtPrimariesESDProtons->DrawCopy("ESAME");
2083   }
2084   if(gShowWeak) {
2085     DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 110, 21, 1.2, 2);
2086     t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,108,"#Lambda -> p + #pi^{-}");
2087     gPtESDProtonsFromWeak->DrawCopy("ESAME");
2088   }
2089   if(gShowHadronic) {
2090     DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 105, 22, 1.2, 3);
2091     t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,103,"X + A -> p + B");
2092     gPtESDProtonsFromHadronic->DrawCopy("ESAME");
2093   }
2094   c1->SaveAs("ReconstructionEfficiency-Protons.gif");
2095
2096   //Reconstruction efficiencies - antiprotons
2097   TCanvas *c2 = new TCanvas("c2","Reconstruction efficiencies - Antirotons",
2098                             100,100,700,400);
2099   c2->SetFillColor(41); c2->SetHighLightColor(41);
2100   c2->Divide(2,1);
2101   c2->cd(1)->SetLeftMargin(0.15); c2->cd(1)->SetBottomMargin(0.15);
2102   c2->cd(1)->SetGridx(); c2->cd(1)->SetGridy();
2103   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.1,
2104                                    gYPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.1);
2105   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDAntiProtons->GetXaxis()->GetTitle());
2106   hEmpty->DrawCopy();
2107   if(gShowPrimaries)
2108     bottomY = 111.0;
2109   if(gShowWeak)
2110     bottomY = 104.0;
2111   if(gShowHadronic)
2112     bottomY = 97.0;
2113   tpave->DrawPave(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.1,119,
2114                   gYPrimariesESDAntiProtons->GetXaxis()->GetXmax()-0.1,bottomY);
2115   if(gShowPrimaries) {
2116     DrawMarker(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.2, 115, 20, 1.2, 1);
2117     t1->DrawLatex(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.3,113,"Primary #bar{p}");
2118     gYPrimariesESDAntiProtons->DrawCopy("ESAME");
2119   }
2120   if(gShowWeak) {
2121     DrawMarker(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.2, 108, 21, 1.2, 2);
2122     t1->DrawLatex(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.3,106,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2123     gYESDAntiProtonsFromWeak->DrawCopy("ESAME");
2124   }
2125   if(gShowHadronic) {
2126     DrawMarker(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.2, 101, 22, 1.2, 3);
2127     t1->DrawLatex(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.3,98,"X + A -> #bar{p} + B");
2128     gYESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2129   }
2130
2131   c2->cd(2)->SetLeftMargin(0.15); c2->cd(2)->SetBottomMargin(0.15);
2132   c2->cd(2)->SetGridx(); c2->cd(2)->SetGridy();
2133   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.1,
2134                                    gPtPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.1);
2135   hEmpty->GetXaxis()->SetTitle(gPtPrimariesESDAntiProtons->GetXaxis()->GetTitle());
2136   hEmpty->DrawCopy();
2137   hEmpty->DrawCopy();
2138   if(gShowPrimaries)
2139     bottomY = 111.0;
2140   if(gShowWeak)
2141     bottomY = 104.0;
2142   if(gShowHadronic)
2143     bottomY = 97.0;
2144   tpave->DrawPave(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin(),119,
2145                   gPtPrimariesESDAntiProtons->GetXaxis()->GetXmax(),bottomY);
2146   if(gShowPrimaries) {
2147     DrawMarker(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.05, 115, 20, 1.2, 1);
2148     t1->DrawLatex(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.15,113,"Primary #bar{p}");
2149     gPtPrimariesESDAntiProtons->DrawCopy("ESAME");
2150   }
2151   if(gShowWeak) {
2152     DrawMarker(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.05, 108, 21, 1.2, 2);
2153     t1->DrawLatex(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.15,106,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2154     gPtESDAntiProtonsFromWeak->DrawCopy("ESAME");
2155   }
2156   if(gShowHadronic) {
2157     DrawMarker(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.05, 101, 22, 1.2, 3);
2158     t1->DrawLatex(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()+0.15,98,"X + A -> #bar{p} + B");
2159     gPtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2160   }
2161   c2->SaveAs("ReconstructionEfficiency-AntiProtons.gif");
2162
2163   //PID efficiencies - (anti)protons
2164   TCanvas *c3 = new TCanvas("c3","PID efficiencies",
2165                             200,200,700,400);
2166   c3->SetFillColor(41); c3->SetHighLightColor(41);
2167   c3->Divide(2,1);
2168   c3->cd(1)->SetLeftMargin(0.15); c3->cd(1)->SetBottomMargin(0.15);
2169   c3->cd(1)->SetGridx(); c3->cd(1)->SetGridy();
2170   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2171                                    gYPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2172   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDProtons->GetXaxis()->GetTitle());
2173   hEmpty->DrawCopy();
2174   tpave->DrawPave(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.1,119,
2175                   gYPrimariesESDProtons->GetXaxis()->GetXmax()-0.1,104);
2176   gYESDIdProtons->DrawCopy("ESAME");
2177   gYESDContamProtons->DrawCopy("ESAME");
2178   DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 115, 20, 1.2, 1);
2179   t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,113,"Efficiency");
2180   DrawMarker(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.2, 108, 24, 1.2, 1);
2181   t1->DrawLatex(gYPrimariesESDProtons->GetXaxis()->GetXmin()+0.3,106,"Contamination");
2182  
2183   c3->cd(2)->SetLeftMargin(0.15); c3->cd(2)->SetBottomMargin(0.15);
2184   c3->cd(2)->SetGridx(); c3->cd(2)->SetGridy();
2185   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDProtons->GetXaxis()->GetXmin()-0.1,
2186                                    gPtPrimariesESDProtons->GetXaxis()->GetXmax()+0.1);
2187   hEmpty->GetXaxis()->SetTitle(gPtPrimariesESDProtons->GetXaxis()->GetTitle());
2188   hEmpty->DrawCopy();
2189   tpave->DrawPave(gPtPrimariesESDProtons->GetXaxis()->GetXmin(),119,
2190                   gPtPrimariesESDProtons->GetXaxis()->GetXmax(),104);
2191   gPtESDIdProtons->DrawCopy("ESAME");
2192   gPtESDContamProtons->DrawCopy("ESAME");
2193   DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 115, 20, 1.2, 1);
2194   t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,113,"Efficiency");
2195   DrawMarker(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.05, 108, 24, 1.2, 1);
2196   t1->DrawLatex(gPtPrimariesESDProtons->GetXaxis()->GetXmin()+0.15,106,"Contamination");
2197   c3->SaveAs("PIDEfficiency-Protons.gif");
2198 }
2199
2200 //________________________________________________//
2201 void compareEfficiencies(const char *filenameTPC,
2202                          const char *filenameHybrid,
2203                          Bool_t gShowPrimaries = kTRUE,
2204                          Bool_t gShowWeak = kFALSE,
2205                          Bool_t gShowHadronic = kFALSE) {
2206   //Function to compare the reconstruction efficiencies between two methods:
2207   //e.g. TPC standalone and global tracking
2208   gStyle->SetPalette(1,0);
2209   gStyle->SetCanvasColor(41);
2210   gStyle->SetFrameFillColor(10);
2211
2212   TH2F *hEmpty = new TH2F("hEmpty","",100,-1.5,2.0,100,0,120);
2213   hEmpty->SetStats(kFALSE);
2214   hEmpty->GetXaxis()->SetTitleColor(1);
2215   hEmpty->GetXaxis()->SetNdivisions(15);
2216   hEmpty->GetYaxis()->SetNdivisions(15);
2217   hEmpty->GetYaxis()->SetTitleOffset(1.4);
2218   hEmpty->GetYaxis()->SetTitle("#epsilon");
2219
2220   TLatex *t1 = new TLatex();
2221   t1->SetTextSize(0.04);
2222
2223   TPaveText *tpave = new TPaveText();
2224   tpave->SetFillColor(10);
2225   Double_t bottomY = 0.0;
2226
2227   //TPC standalone
2228   TFile *f1 = TFile::Open(filenameTPC);
2229   TH1D *g1YPrimariesESDProtons = (TH1D *)f1->Get("gYPrimariesESDProtons");
2230   TH1D *g1YESDProtonsFromWeak = (TH1D *)f1->Get("gYESDProtonsFromWeak");
2231   TH1D *g1YESDProtonsFromHadronic = (TH1D *)f1->Get("gYESDProtonsFromHadronic");
2232   TH1D *g1PtPrimariesESDProtons = (TH1D *)f1->Get("gPtPrimariesESDProtons");
2233   TH1D *g1PtESDProtonsFromWeak = (TH1D *)f1->Get("gPtESDProtonsFromWeak");
2234   TH1D *g1PtESDProtonsFromHadronic = (TH1D *)f1->Get("gPtESDProtonsFromHadronic");
2235   TH1D *g1YPrimariesESDAntiProtons = (TH1D *)f1->Get("gYPrimariesESDAntiProtons");
2236   TH1D *g1YESDAntiProtonsFromWeak = (TH1D *)f1->Get("gYESDAntiProtonsFromWeak");
2237   TH1D *g1YESDAntiProtonsFromHadronic = (TH1D *)f1->Get("gYESDAntiProtonsFromHadronic");        
2238   TH1D *g1PtPrimariesESDAntiProtons = (TH1D *)f1->Get("gPtPrimariesESDAntiProtons");    
2239   TH1D *g1PtESDAntiProtonsFromWeak = (TH1D *)f1->Get("gPtESDAntiProtonsFromWeak");      
2240   TH1D *g1PtESDAntiProtonsFromHadronic = (TH1D *)f1->Get("gPtESDAntiProtonsFromHadronic");      
2241
2242   //Global tracking
2243   TFile *f2 = TFile::Open(filenameHybrid);
2244   TH1D *g2YPrimariesESDProtons = (TH1D *)f2->Get("gYPrimariesESDProtons");
2245   TH1D *g2YESDProtonsFromWeak = (TH1D *)f2->Get("gYESDProtonsFromWeak");
2246   TH1D *g2YESDProtonsFromHadronic = (TH1D *)f2->Get("gYESDProtonsFromHadronic");
2247   TH1D *g2PtPrimariesESDProtons = (TH1D *)f2->Get("gPtPrimariesESDProtons");
2248   TH1D *g2PtESDProtonsFromWeak = (TH1D *)f2->Get("gPtESDProtonsFromWeak");
2249   TH1D *g2PtESDProtonsFromHadronic = (TH1D *)f2->Get("gPtESDProtonsFromHadronic");
2250   TH1D *g2YPrimariesESDAntiProtons = (TH1D *)f2->Get("gYPrimariesESDAntiProtons");
2251   TH1D *g2YESDAntiProtonsFromWeak = (TH1D *)f2->Get("gYESDAntiProtonsFromWeak");
2252   TH1D *g2YESDAntiProtonsFromHadronic = (TH1D *)f2->Get("gYESDAntiProtonsFromHadronic");        
2253   TH1D *g2PtPrimariesESDAntiProtons = (TH1D *)f2->Get("gPtPrimariesESDAntiProtons");    
2254   TH1D *g2PtESDAntiProtonsFromWeak = (TH1D *)f2->Get("gPtESDAntiProtonsFromWeak");      
2255   TH1D *g2PtESDAntiProtonsFromHadronic = (TH1D *)f2->Get("gPtESDAntiProtonsFromHadronic");      
2256
2257   //Reconstruction efficiencies - protons
2258   TCanvas *c1 = new TCanvas("c1","Reconstruction efficiencies - Protons",
2259                             0,0,700,400);
2260   c1->SetFillColor(41); c1->SetHighLightColor(41);
2261   c1->Divide(2,1);
2262   c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15);
2263   c1->cd(1)->SetGridx(); c1->cd(1)->SetGridy();
2264   hEmpty->GetXaxis()->SetRangeUser(-1.1,1.1);
2265   hEmpty->GetXaxis()->SetTitle("#eta");
2266   hEmpty->DrawCopy();
2267   if(gShowPrimaries)
2268     bottomY = 106.0;
2269   if(gShowWeak)
2270     bottomY = 99.0;
2271   if(gShowHadronic)
2272     bottomY = 92.0;
2273   tpave->DrawPave(-0.4,119,1.1,bottomY);
2274   t1->DrawLatex(-0.3,113,"TPC");
2275   t1->DrawLatex(0.0,113,"Global");
2276   if(gShowPrimaries) {
2277     DrawMarker(-0.15, 110, 20, 1.2, 1);
2278     DrawMarker(0.15, 110, 24, 1.2, 1);
2279     t1->DrawLatex(0.35,108,"Primary p");
2280     g1YPrimariesESDProtons->DrawCopy("ESAME");
2281     g2YPrimariesESDProtons->SetMarkerStyle(24);
2282     g2YPrimariesESDProtons->DrawCopy("ESAME");
2283   }
2284   if(gShowWeak) {
2285     DrawMarker(-0.15, 103, 21, 1.2, 2);
2286     DrawMarker(0.15, 103, 25, 1.2, 2);
2287     t1->DrawLatex(0.35,101,"#Lambda -> p + #pi^{-}");
2288     g1YESDProtonsFromWeak->DrawCopy("ESAME");
2289     g2YESDProtonsFromWeak->SetMarkerStyle(25);
2290     g2YESDProtonsFromWeak->DrawCopy("ESAME");
2291   }
2292   if(gShowHadronic) {
2293     DrawMarker(-0.15, 96, 22, 1.2, 3);
2294     DrawMarker(0.15, 96, 26, 1.2, 3);
2295     t1->DrawLatex(0.35,94,"X + A -> p + B");
2296     g1YESDProtonsFromHadronic->DrawCopy("ESAME");
2297     g2YESDProtonsFromHadronic->SetMarkerStyle(26);
2298     g2YESDProtonsFromHadronic->DrawCopy("ESAME");
2299   }
2300
2301   c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15);
2302   c1->cd(2)->SetGridx(); c1->cd(2)->SetGridy();
2303   hEmpty->GetXaxis()->SetRangeUser(0.0,1.7);
2304   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
2305   hEmpty->DrawCopy();
2306   if(gShowPrimaries)
2307     bottomY = 106.0;
2308   if(gShowWeak)
2309     bottomY = 99.0;
2310   if(gShowHadronic)
2311     bottomY = 92.0;
2312   tpave->DrawPave(0.05,119,1.2,bottomY);
2313   t1->DrawLatex(0.1,113,"TPC");
2314   t1->DrawLatex(0.3,113,"Global");
2315   if(gShowPrimaries) {
2316     DrawMarker(0.15, 110, 20, 1.2, 1);
2317     DrawMarker(0.4, 110, 24, 1.2, 1);
2318     t1->DrawLatex(0.6,108,"Primary p");
2319     g1PtPrimariesESDProtons->DrawCopy("ESAME");
2320     g2PtPrimariesESDProtons->SetMarkerStyle(24);
2321     g2PtPrimariesESDProtons->DrawCopy("ESAME");
2322   }
2323   if(gShowWeak) {
2324     DrawMarker(0.15, 103, 21, 1.2, 2);
2325     DrawMarker(0.4, 103, 25, 1.2, 2);
2326     t1->DrawLatex(0.6,101,"#Lambda -> p + #pi^{-}");
2327     g1PtESDProtonsFromWeak->DrawCopy("ESAME");
2328     g2PtESDProtonsFromWeak->SetMarkerStyle(25);
2329     g2PtESDProtonsFromWeak->DrawCopy("ESAME");
2330   }
2331   if(gShowHadronic) {
2332     DrawMarker(0.15, 96, 22, 1.2, 3);
2333     DrawMarker(0.4, 96, 26, 1.2, 3);
2334     t1->DrawLatex(0.6,94,"X + A -> p + B");
2335     g1PtESDProtonsFromHadronic->DrawCopy("ESAME");
2336     g2PtESDProtonsFromHadronic->SetMarkerStyle(26);
2337     g2PtESDProtonsFromHadronic->DrawCopy("ESAME");
2338   }
2339   c1->SaveAs("ReconstructionEfficiency-Protons.gif");
2340
2341   //Reconstruction efficiencies - antiprotons
2342   TCanvas *c2 = new TCanvas("c2","Reconstruction efficiencies - Antirotons",
2343                             100,100,700,400);
2344   c2->SetFillColor(41); c2->SetHighLightColor(41);
2345   c2->Divide(2,1);
2346   c2->cd(1)->SetLeftMargin(0.15); c2->cd(1)->SetBottomMargin(0.15);
2347   c2->cd(1)->SetGridx(); c2->cd(1)->SetGridy();
2348   hEmpty->GetXaxis()->SetRangeUser(-1.1,1.1);
2349   hEmpty->GetXaxis()->SetTitle("#eta");
2350   hEmpty->DrawCopy();
2351   if(gShowPrimaries)
2352     bottomY = 106.0;
2353   if(gShowWeak)
2354     bottomY = 99.0;
2355   if(gShowHadronic)
2356     bottomY = 92.0;
2357   tpave->DrawPave(-0.4,119,1.1,bottomY);
2358   t1->DrawLatex(-0.3,113,"TPC");
2359   t1->DrawLatex(0.0,113,"Global");
2360   if(gShowPrimaries) {
2361     DrawMarker(-0.15, 110, 20, 1.2, 1);
2362     DrawMarker(0.15, 110, 24, 1.2, 1);
2363     t1->DrawLatex(0.35,108,"Primary #bar{p}");
2364     g1YPrimariesESDAntiProtons->DrawCopy("ESAME");
2365     g2YPrimariesESDAntiProtons->SetMarkerStyle(24);
2366     g2YPrimariesESDAntiProtons->DrawCopy("ESAME");
2367   }
2368   if(gShowWeak) {
2369     DrawMarker(-0.15, 103, 21, 1.2, 2);
2370     DrawMarker(0.15, 103, 25, 1.2, 2);
2371     t1->DrawLatex(0.35,101,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2372     g1YESDAntiProtonsFromWeak->DrawCopy("ESAME");
2373     g2YESDAntiProtonsFromWeak->SetMarkerStyle(25);
2374     g2YESDAntiProtonsFromWeak->DrawCopy("ESAME");
2375   }
2376   if(gShowHadronic) {
2377     DrawMarker(-0.15, 96, 22, 1.2, 3);
2378     DrawMarker(0.15, 96, 26, 1.2, 3);
2379     t1->DrawLatex(0.35,94,"X + A -> #bar{p} + B");
2380     g1YESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2381     g2YESDAntiProtonsFromHadronic->SetMarkerStyle(26);
2382     g2YESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2383   }
2384
2385   c2->cd(2)->SetLeftMargin(0.15); c2->cd(2)->SetBottomMargin(0.15);
2386   c2->cd(2)->SetGridx(); c2->cd(2)->SetGridy();
2387   hEmpty->GetXaxis()->SetRangeUser(0.0,1.7);
2388   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
2389   hEmpty->DrawCopy();
2390   if(gShowPrimaries)
2391     bottomY = 106.0;
2392   if(gShowWeak)
2393     bottomY = 99.0;
2394   if(gShowHadronic)
2395     bottomY = 92.0;
2396   tpave->DrawPave(0.05,119,1.2,bottomY);
2397   t1->DrawLatex(0.1,113,"TPC");
2398   t1->DrawLatex(0.3,113,"Global");
2399   if(gShowPrimaries) {
2400     DrawMarker(0.15, 110, 20, 1.2, 1);
2401     DrawMarker(0.4, 110, 24, 1.2, 1);
2402     t1->DrawLatex(0.6,108,"Primary #bar{p}");
2403     g1PtPrimariesESDAntiProtons->DrawCopy("ESAME");
2404     g2PtPrimariesESDAntiProtons->SetMarkerStyle(24);
2405     g2PtPrimariesESDAntiProtons->DrawCopy("ESAME");
2406   }
2407   if(gShowWeak) {
2408     DrawMarker(0.15, 103, 21, 1.2, 2);
2409     DrawMarker(0.4, 103, 25, 1.2, 2);
2410     t1->DrawLatex(0.6,101,"#bar{#Lambda} -> #bar{p} + #pi^{+}");
2411     g1PtESDAntiProtonsFromWeak->DrawCopy("ESAME");
2412     g2PtESDAntiProtonsFromWeak->SetMarkerStyle(25);
2413     g2PtESDAntiProtonsFromWeak->DrawCopy("ESAME");
2414   }
2415   if(gShowHadronic) {
2416     DrawMarker(0.15, 96, 22, 1.2, 3);
2417     DrawMarker(0.4, 96, 26, 1.2, 3);
2418     t1->DrawLatex(0.6,94,"X + A -> #bar{p} + B");
2419     g1PtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2420     g2PtESDAntiProtonsFromHadronic->SetMarkerStyle(26);
2421     g2PtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
2422   }
2423   c2->SaveAs("ReconstructionEfficiency-AntiProtons.gif");
2424
2425 }
2426
2427 //________________________________________________//
2428 void drawCutParametersDistributions(const char* filename = "Protons.QA.Histograms.root") {
2429   //macro that takes as an input the third file 
2430   //created by the proton QA analysis task 
2431   //and draws the DCA distributions of protons 
2432   //and antiprotons (both primary & secondaries)
2433   const Int_t nEvents = 1;
2434
2435   TFile *f = TFile::Open(filename);
2436
2437   //cut list
2438   TH1F *gCutListHistograms[100];
2439   TList *listCut = (TList *)f->Get("acceptedCutList");
2440   Int_t iCounter = 0;
2441   cout<<"Cut list entries: "<<listCut->GetEntries()<<endl;
2442   for(Int_t iEntry = 0; iEntry < listCut->GetEntries(); iEntry++) {
2443     if(iCounter == 4) iCounter = 0;
2444     iCounter += 1;
2445     gCutListHistograms[iEntry] = (TH1F *)listCut->At(iEntry);
2446     gCutListHistograms[iEntry]->Scale(1./nEvents);
2447     if(iCounter < 3) {
2448       gCutListHistograms[iEntry]->SetFillColor(4);
2449       gCutListHistograms[iEntry]->SetMarkerColor(4);
2450       gCutListHistograms[iEntry]->SetMarkerStyle(20);
2451     }
2452     else {
2453       gCutListHistograms[iEntry]->SetFillColor(kOrange+1);
2454       gCutListHistograms[iEntry]->SetMarkerColor(kOrange+1);
2455       gCutListHistograms[iEntry]->SetMarkerStyle(29);
2456     }
2457     /*cout<<"Entry: "<<iEntry<<
2458       " - Counter: "<<iCounter<<
2459       " - Name: "<<gCutListHistograms[iEntry]->GetName()<<endl;*/
2460   }
2461
2462   //DCA list
2463   TH1F *gDCAListHistograms[20];
2464   TList *listDCA = (TList *)f->Get("acceptedDCAList");
2465   iCounter = 0;
2466   cout<<"DCA list entries: "<<listDCA->GetEntries()<<endl;
2467   for(Int_t iEntry = 0; iEntry < listDCA->GetEntries(); iEntry++) {
2468     if(iCounter == 4) iCounter = 0;
2469     iCounter += 1;
2470     gDCAListHistograms[iEntry] = (TH1F *)listDCA->At(iEntry);
2471     gDCAListHistograms[iEntry]->Scale(1./nEvents);
2472     if(iCounter < 3) {
2473       gDCAListHistograms[iEntry]->SetFillColor(4);
2474       gDCAListHistograms[iEntry]->SetMarkerColor(4);
2475       gDCAListHistograms[iEntry]->SetMarkerStyle(20);
2476     }
2477     else {
2478       gDCAListHistograms[iEntry]->SetFillColor(kOrange+1);
2479       gDCAListHistograms[iEntry]->SetMarkerColor(kOrange+1);
2480       gDCAListHistograms[iEntry]->SetMarkerStyle(29);
2481     }
2482     /*cout<<"Entry: "<<iEntry<<
2483       " - Counter: "<<iCounter<<
2484       " - Name: "<<gDCAListHistograms[iEntry]->GetName()<<endl;*/
2485   }
2486
2487   //_________________________________________________________//
2488   TF1 *gDCA = new TF1("gDCA",
2489                       "[0]*TMath::Power(1+TMath::Exp((x-[1])/[2]),-1)",
2490                       0.1,100.0);
2491   gDCA->SetParameter(0,1.74221e+07);
2492   gDCA->SetParameter(1,-1.12221e+01);
2493   gDCA->SetParameter(2,1.02726);
2494   //_________________________________________________________//
2495   TH2F *hEmpty = new TH2F("hEmpty","",300,-100,200,100,1e-01,1e+06);
2496   hEmpty->GetYaxis()->SetTitle("Entries/Event");
2497   hEmpty->GetYaxis()->SetNdivisions(10);
2498   hEmpty->GetXaxis()->SetNdivisions(10);
2499   hEmpty->SetStats(kFALSE);
2500   //_________________________________________________________//
2501
2502   //Cut parameters
2503   TCanvas *c1 = new TCanvas("c1","ITS Cluster map",0,0,650,350);
2504   c1->SetFillColor(10); c1->GetFrame()->SetFillColor(10);
2505   c1->SetHighLightColor(10); c1->Divide(2,1);
2506   c1->cd(1)->SetBottomMargin(0.2); c1->cd(1)->SetLeftMargin(0.2);
2507   c1->cd(1)->SetLogy();
2508   hEmpty->GetXaxis()->SetTitle("ITS layer");
2509   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2510   hEmpty->SetTitle("Protons");
2511   hEmpty->DrawCopy();
2512   gCutListHistograms[0]->Draw("ESAME");
2513   gCutListHistograms[2]->Draw("ESAME");
2514   c1->cd(2)->SetBottomMargin(0.2); c1->cd(2)->SetLeftMargin(0.2);
2515   c1->cd(2)->SetLogy();
2516   hEmpty->GetXaxis()->SetTitle("ITS layer");
2517   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2518   hEmpty->SetTitle("Antiprotons");
2519   hEmpty->DrawCopy();
2520   gCutListHistograms[1]->Draw("ESAME");
2521   gCutListHistograms[3]->Draw("ESAME");
2522   c1->SaveAs("ITSClusterMap.gif");
2523
2524   TCanvas *c2 = new TCanvas("c2","Number of ITS Clusters",50,50,650,350);
2525   c2->SetFillColor(10); c2->GetFrame()->SetFillColor(10);
2526   c2->SetHighLightColor(10); c2->Divide(2,1);
2527   c2->cd(1)->SetBottomMargin(0.2); c2->cd(1)->SetLeftMargin(0.2);
2528   c2->cd(1)->SetLogy();
2529   hEmpty->GetXaxis()->SetTitle("N_{clusters}(ITS)");
2530   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2531   hEmpty->SetTitle("Protons");
2532   hEmpty->DrawCopy();
2533   gCutListHistograms[4]->Draw("ESAME");
2534   gCutListHistograms[6]->Draw("ESAME");
2535   c2->cd(2)->SetBottomMargin(0.2); c2->cd(2)->SetLeftMargin(0.2);
2536   c2->cd(2)->SetLogy();
2537   hEmpty->GetXaxis()->SetTitle("N_{clusters}(ITS)");
2538   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2539   hEmpty->SetTitle("Antiprotons");
2540   hEmpty->DrawCopy();
2541   gCutListHistograms[5]->Draw("ESAME");
2542   gCutListHistograms[7]->Draw("ESAME");
2543   c2->SaveAs("NITSClusters.gif");
2544
2545   TCanvas *c3 = new TCanvas("c3","Chi2 per ITS cluster",100,100,650,350);
2546   c3->SetFillColor(10); c3->GetFrame()->SetFillColor(10);
2547   c3->SetHighLightColor(10); c3->Divide(2,1);
2548   c3->cd(1)->SetBottomMargin(0.2); c3->cd(1)->SetLeftMargin(0.2);
2549   c3->cd(1)->SetLogy();
2550   hEmpty->GetXaxis()->SetTitle("#chi^{2}/N_{clusters}(ITS)");
2551   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2552   hEmpty->SetTitle("Protons");
2553   hEmpty->DrawCopy();
2554   gCutListHistograms[8]->Draw("ESAME");
2555   gCutListHistograms[10]->Draw("ESAME");
2556   c3->cd(2)->SetBottomMargin(0.2); c3->cd(2)->SetLeftMargin(0.2);
2557   c3->cd(2)->SetLogy();
2558   hEmpty->GetXaxis()->SetTitle("#chi^{2}/N_{clusters}(ITS)");
2559   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2560   hEmpty->SetTitle("AntiPpotons");
2561   hEmpty->DrawCopy();
2562   gCutListHistograms[9]->Draw("ESAME");
2563   gCutListHistograms[11]->Draw("ESAME");
2564   c3->SaveAs("Chi2PerITSCluster.gif");
2565
2566   TCanvas *c4 = new TCanvas("c4","Constrain chi2 - vertex",150,150,650,350);
2567   c4->SetFillColor(10); c4->GetFrame()->SetFillColor(10);
2568   c4->SetHighLightColor(10); c4->Divide(2,1);
2569   c4->cd(1)->SetBottomMargin(0.2); c4->cd(1)->SetLeftMargin(0.2);
2570   c4->cd(1)->SetLogy();
2571   hEmpty->GetXaxis()->SetTitle("log_{10}(#chi^{2}) (vertex)");
2572   hEmpty->GetXaxis()->SetRangeUser(-10.0,10.0);
2573   hEmpty->SetTitle("Protons");
2574   hEmpty->DrawCopy();
2575   gCutListHistograms[12]->Draw("ESAME");
2576   gCutListHistograms[14]->Draw("ESAME");
2577   c4->cd(2)->SetBottomMargin(0.2); c4->cd(2)->SetLeftMargin(0.2);
2578   c4->cd(2)->SetLogy();
2579   hEmpty->GetXaxis()->SetTitle("log_{10}(#chi^{2}) (vertex )");
2580   hEmpty->GetXaxis()->SetRangeUser(-10.0,10.0);
2581   hEmpty->SetTitle("Antiprotons");
2582   hEmpty->DrawCopy();
2583   gCutListHistograms[13]->Draw("ESAME");
2584   gCutListHistograms[15]->Draw("ESAME");
2585   c4->SaveAs("ConstrainChi2Vertex.gif");
2586
2587   TCanvas *c5 = new TCanvas("c5","Number of TPC Clusters",200,200,650,350);
2588   c5->SetFillColor(10); c5->GetFrame()->SetFillColor(10);
2589   c5->SetHighLightColor(10); c5->Divide(2,1);
2590   c5->cd(1)->SetBottomMargin(0.2); c5->cd(1)->SetLeftMargin(0.2);
2591   c5->cd(1)->SetLogy();
2592   hEmpty->GetXaxis()->SetTitle("N_{clusters}(TPC");
2593   hEmpty->GetXaxis()->SetRangeUser(0.0,200.0);
2594   hEmpty->SetTitle("Protons");
2595   hEmpty->DrawCopy();
2596   gCutListHistograms[16]->Draw("ESAME");
2597   gCutListHistograms[18]->Draw("ESAME");
2598   c5->cd(2)->SetBottomMargin(0.2); c5->cd(2)->SetLeftMargin(0.2);
2599   c5->cd(2)->SetLogy();
2600   hEmpty->GetXaxis()->SetTitle("N_{clusters}(TPC");
2601   hEmpty->GetXaxis()->SetRangeUser(0.0,200.0);
2602   hEmpty->SetTitle("Antiprotons");
2603   hEmpty->DrawCopy();
2604   gCutListHistograms[17]->Draw("ESAME");
2605   gCutListHistograms[19]->Draw("ESAME");
2606   c5->SaveAs("NTPCClusters.gif");
2607
2608   TCanvas *c6 = new TCanvas("c6","Chi2 per TPC cluster",250,250,650,350);
2609   c6->SetFillColor(10); c6->GetFrame()->SetFillColor(10);
2610   c6->SetHighLightColor(10); c6->Divide(2,1);
2611   c6->cd(1)->SetBottomMargin(0.2); c6->cd(1)->SetLeftMargin(0.2);
2612   c6->cd(1)->SetLogy();
2613   hEmpty->GetXaxis()->SetTitle("#chi^{2}/N_{clusters}(TPC)");
2614   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2615   hEmpty->SetTitle("Protons");
2616   hEmpty->DrawCopy();
2617   gCutListHistograms[20]->Draw("ESAME");
2618   gCutListHistograms[22]->Draw("ESAME");
2619   c6->cd(2)->SetBottomMargin(0.2); c6->cd(2)->SetLeftMargin(0.2);
2620   c6->cd(2)->SetLogy();
2621   hEmpty->GetXaxis()->SetTitle("#chi^{2}/N_{clusters}(TPC)");
2622   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2623   hEmpty->SetTitle("Antiprotons");
2624   hEmpty->DrawCopy();
2625   gCutListHistograms[21]->Draw("ESAME");
2626   gCutListHistograms[23]->Draw("ESAME");
2627   c6->SaveAs("Chi2PerTPCCluster.gif");
2628
2629   TCanvas *c7 = new TCanvas("c7","Covariance matrix 11",300,300,650,350);
2630   c7->SetFillColor(10); c7->GetFrame()->SetFillColor(10);
2631   c7->SetHighLightColor(10); c7->Divide(2,1);
2632   c7->cd(1)->SetBottomMargin(0.2); c7->cd(1)->SetLeftMargin(0.2);
2633   c7->cd(1)->SetLogy();
2634   hEmpty->GetXaxis()->SetTitle("#sigma_{y} [cm]");
2635   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2636   hEmpty->SetTitle("Protons");
2637   hEmpty->DrawCopy();
2638   gCutListHistograms[24]->Draw("ESAME");
2639   gCutListHistograms[26]->Draw("ESAME");
2640   c7->cd(2)->SetBottomMargin(0.2); c7->cd(2)->SetLeftMargin(0.2);
2641   c7->cd(2)->SetLogy();
2642   hEmpty->GetXaxis()->SetTitle("#sigma_{y} [cm]");
2643   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2644   hEmpty->SetTitle("Antiprotons");
2645   hEmpty->DrawCopy();
2646   gCutListHistograms[25]->Draw("ESAME");
2647   gCutListHistograms[27]->Draw("ESAME");
2648   c7->SaveAs("Cov11.gif");
2649
2650   TCanvas *c8 = new TCanvas("c8","Covariance matrix 22",350,350,650,350);
2651   c8->SetFillColor(10); c8->GetFrame()->SetFillColor(10);
2652   c8->SetHighLightColor(10); c8->Divide(2,1);
2653   c8->cd(1)->SetBottomMargin(0.2); c8->cd(1)->SetLeftMargin(0.2);
2654   c8->cd(1)->SetLogy();
2655   hEmpty->GetXaxis()->SetTitle("#sigma_{z} [cm]");
2656   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2657   hEmpty->SetTitle("Protons");
2658   hEmpty->DrawCopy();
2659   gCutListHistograms[28]->Draw("ESAME");
2660   gCutListHistograms[30]->Draw("ESAME");
2661   c8->cd(2)->SetBottomMargin(0.2); c8->cd(2)->SetLeftMargin(0.2);
2662   c8->cd(2)->SetLogy();
2663   hEmpty->GetXaxis()->SetTitle("#sigma_{z} [cm]");
2664   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2665   hEmpty->SetTitle("Antiprotons");
2666   hEmpty->DrawCopy();
2667   gCutListHistograms[29]->Draw("ESAME");
2668   gCutListHistograms[31]->Draw("ESAME");
2669   c8->SaveAs("Cov22.gif");
2670
2671   TCanvas *c9 = new TCanvas("c9","Covariance matrix 33",400,400,650,350);
2672   c9->SetFillColor(10); c9->GetFrame()->SetFillColor(10);
2673   c9->SetHighLightColor(10); c9->Divide(2,1);
2674   c9->cd(1)->SetBottomMargin(0.2); c9->cd(1)->SetLeftMargin(0.2);
2675   c9->cd(1)->SetLogy();
2676   hEmpty->GetXaxis()->SetTitle("#sigma_{sin(#phi)}");
2677   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2678   hEmpty->SetTitle("Protons");
2679   hEmpty->DrawCopy();
2680   gCutListHistograms[32]->Draw("ESAME");
2681   gCutListHistograms[34]->Draw("ESAME");
2682   c9->cd(2)->SetBottomMargin(0.2); c9->cd(2)->SetLeftMargin(0.2);
2683   c9->cd(2)->SetLogy();
2684   hEmpty->GetXaxis()->SetTitle("#sigma_{sin(#phi)}");
2685   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2686   hEmpty->SetTitle("Antiprotons");
2687   hEmpty->DrawCopy();
2688   gCutListHistograms[33]->Draw("ESAME");
2689   gCutListHistograms[35]->Draw("ESAME");
2690   c9->SaveAs("Cov33.gif");
2691
2692   TCanvas *c10 = new TCanvas("c10","Covariance matrix 44",450,450,650,350);
2693   c10->SetFillColor(10); c10->GetFrame()->SetFillColor(10);
2694   c10->SetHighLightColor(10); c10->Divide(2,1);
2695   c10->cd(1)->SetBottomMargin(0.2); c10->cd(1)->SetLeftMargin(0.2);
2696   c10->cd(1)->SetLogy();
2697   hEmpty->GetXaxis()->SetTitle("#sigma_{tan(#lambda)}");
2698   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2699   hEmpty->SetTitle("Protons");
2700   hEmpty->DrawCopy();
2701   gCutListHistograms[36]->Draw("ESAME");
2702   gCutListHistograms[38]->Draw("ESAME");
2703   c10->cd(2)->SetBottomMargin(0.2); c10->cd(2)->SetLeftMargin(0.2);
2704   c10->cd(2)->SetLogy();
2705   hEmpty->GetXaxis()->SetTitle("#sigma_{tan(#lambda)}");
2706   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2707   hEmpty->SetTitle("Antiprotons");
2708   hEmpty->DrawCopy();
2709   gCutListHistograms[37]->Draw("ESAME");
2710   gCutListHistograms[39]->Draw("ESAME");
2711   c10->SaveAs("Cov44.gif");
2712
2713   TCanvas *c11 = new TCanvas("c11","Covariance matrix 55",500,500,650,350);
2714   c11->SetFillColor(10); c11->GetFrame()->SetFillColor(10);
2715   c11->SetHighLightColor(10); c11->Divide(2,1);
2716   c11->cd(1)->SetBottomMargin(0.2); c11->cd(1)->SetLeftMargin(0.2);
2717   c11->cd(1)->SetLogy();
2718   hEmpty->GetXaxis()->SetTitle("#sigma_{1/P_{T}} [GeV/c]^{-1}");
2719   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2720   hEmpty->SetTitle("Protons");
2721   hEmpty->DrawCopy();
2722   gCutListHistograms[40]->Draw("ESAME");
2723   gCutListHistograms[42]->Draw("ESAME");
2724   c11->cd(2)->SetBottomMargin(0.2); c11->cd(2)->SetLeftMargin(0.2);
2725   c11->cd(2)->SetLogy();
2726   hEmpty->GetXaxis()->SetTitle("#sigma_{1/P_{T}} [GeV/c]^{-1}");
2727   hEmpty->GetXaxis()->SetRangeUser(0.0,4.0);
2728   hEmpty->SetTitle("Antiprotons");
2729   hEmpty->DrawCopy();
2730   gCutListHistograms[41]->Draw("ESAME");
2731   gCutListHistograms[43]->Draw("ESAME");
2732   c11->SaveAs("Cov55.gif");
2733
2734   TCanvas *c12 = new TCanvas("c12","Number of TPC points (dE/dx)",550,550,650,350);
2735   c12->SetFillColor(10); c12->GetFrame()->SetFillColor(10);
2736   c12->SetHighLightColor(10); c12->Divide(2,1);
2737   c12->cd(1)->SetBottomMargin(0.2); c12->cd(1)->SetLeftMargin(0.2);
2738   c12->cd(1)->SetLogy();
2739   hEmpty->GetXaxis()->SetTitle("N_{points} (TPC-dE/dx");
2740   hEmpty->GetXaxis()->SetRangeUser(0.0,200.0);
2741   hEmpty->SetTitle("Protons");
2742   hEmpty->DrawCopy();
2743   gCutListHistograms[56]->Draw("ESAME");
2744   gCutListHistograms[58]->Draw("ESAME");
2745   c12->cd(2)->SetBottomMargin(0.2); c12->cd(2)->SetLeftMargin(0.2);
2746   c12->cd(2)->SetLogy();
2747   hEmpty->GetXaxis()->SetTitle("N_{points} (TPC-dE/dx");
2748   hEmpty->GetXaxis()->SetRangeUser(0.0,200.0);
2749   hEmpty->SetTitle("Antiprotons");
2750   hEmpty->DrawCopy();
2751   gCutListHistograms[57]->Draw("ESAME");
2752   gCutListHistograms[59]->Draw("ESAME");
2753   c12->SaveAs("Npoints-TPCdEdx.gif");
2754
2755
2756   //DCA cut parameters  
2757   TCanvas *c13 = new TCanvas("c13","DCA xy",600,600,650,350);
2758   c13->SetFillColor(10); c13->GetFrame()->SetFillColor(10);
2759   c13->SetHighLightColor(10); c13->Divide(2,1);
2760   c13->cd(1)->SetBottomMargin(0.2); c13->cd(1)->SetLeftMargin(0.2);
2761   c13->cd(1)->SetLogy();
2762   hEmpty->GetXaxis()->SetTitle("DCA_{xy} [cm]");
2763   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2764   hEmpty->SetTitle("Protons");
2765   hEmpty->DrawCopy();
2766   gDCAListHistograms[2]->Draw("ESAME");
2767   //gDCAListHistograms[2]->Fit("gDCA","","esame",0.1,12);
2768   gDCAListHistograms[0]->Draw("ESAME");
2769   c13->cd(2)->SetBottomMargin(0.15); c13->cd(2)->SetLeftMargin(0.15);
2770   c13->cd(2)->SetLogy();
2771   hEmpty->GetXaxis()->SetTitle("DCA_{xy} [cm]");
2772   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2773   hEmpty->SetTitle("Antiprotons");
2774   hEmpty->DrawCopy();
2775   gDCAListHistograms[1]->Draw("ESAME");
2776   gDCAListHistograms[3]->Draw("ESAME");
2777   c13->SaveAs("DCAxy.gif");
2778
2779   TCanvas *c14 = new TCanvas("c14","DCA z",650,650,650,350);
2780   c14->SetFillColor(10); c14->GetFrame()->SetFillColor(10);
2781   c14->SetHighLightColor(10); c14->Divide(2,1);
2782   c14->cd(1)->SetBottomMargin(0.2); c14->cd(1)->SetLeftMargin(0.2);
2783   c14->cd(1)->SetLogy();
2784   hEmpty->GetXaxis()->SetTitle("DCA_{z} [cm]");
2785   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2786   hEmpty->SetTitle("Protons");
2787   hEmpty->DrawCopy();
2788   gDCAListHistograms[4]->Draw("ESAME");
2789   gDCAListHistograms[6]->Draw("ESAME");
2790   //gDCAListHistograms[6]->Fit("gDCA","","esame",0.1,12);
2791   c14->cd(2)->SetBottomMargin(0.15); c14->cd(2)->SetLeftMargin(0.15);
2792   c14->cd(2)->SetLogy();
2793   hEmpty->GetXaxis()->SetTitle("DCA_{z} [cm]");
2794   hEmpty->GetXaxis()->SetRangeUser(0.0,20.0);
2795   hEmpty->SetTitle("Antiprotons");
2796   hEmpty->DrawCopy();
2797   gDCAListHistograms[5]->Draw("ESAME");
2798   gDCAListHistograms[7]->Draw("ESAME");
2799   c14->SaveAs("DCAz.gif");
2800
2801   TCanvas *c15 = new TCanvas("c15","Sigma to vertex",700,700,650,350);
2802   c15->SetFillColor(10); c15->GetFrame()->SetFillColor(10);
2803   c15->SetHighLightColor(10); c15->Divide(2,1);
2804   c15->cd(1)->SetBottomMargin(0.2); c15->cd(1)->SetLeftMargin(0.2);
2805   c15->cd(1)->SetLogy();
2806   hEmpty->GetXaxis()->SetTitle("N_{#sigma}(Vertex)");
2807   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2808   hEmpty->SetTitle("Protons");
2809   hEmpty->DrawCopy();
2810   gDCAListHistograms[8]->DrawCopy("ESAME");
2811   gDCAListHistograms[10]->DrawCopy("ESAME");
2812   c15->cd(2)->SetBottomMargin(0.15); c15->cd(2)->SetLeftMargin(0.15);
2813   c15->cd(2)->SetLogy();
2814   hEmpty->GetXaxis()->SetTitle("N_{#sigma}(Vertex)");
2815   hEmpty->GetXaxis()->SetRangeUser(0.0,7.0);
2816   hEmpty->SetTitle("Antiprotons");
2817   hEmpty->DrawCopy();
2818   gDCAListHistograms[9]->DrawCopy("ESAME");
2819   gDCAListHistograms[11]->DrawCopy("ESAME");
2820   c15->SaveAs("NSigmaToVertex.gif");
2821
2822
2823   f->Close();
2824 }