]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/drawProtonQAResults.C
Extra histograms GFC cumulants + rule checker corrections
[u/mrichter/AliRoot.git] / PWG2 / drawProtonQAResults.C
1 void drawProtonQAResults(const char *analysisType = "TPC") {
2   //Macro to visualize the results of the proton QA task
3   //TCanvas objects: 16
4   gStyle->SetPalette(1,0);
5   TString filename1 = "Protons.QA.";
6   filename1 += analysisType; filename1 += ".root";
7   TString filename2 = "Protons.MC.QA.";
8   filename2 += analysisType; filename2 += ".root";
9   TString filename3 = "Protons.Efficiency.";
10   filename3 += analysisType; filename3 += ".root",
11  
12   TFile *fQA = TFile::Open(filename1.Data());
13   TList *listGlobalQA = (TList *)fQA->Get("globalQAList");
14   drawCutStatistics(listGlobalQA,analysisType);
15  
16   TFile *fMC = TFile::Open(filename2.Data());
17   TList *listPDG = (TList *)fMC->Get("pdgCodeList");  
18   TList *listMCProcesses = (TList *)fMC->Get("mcProcessList");  
19   drawMCQA(listPDG,listMCProcesses);
20   
21   TFile *fEfficiency = TFile::Open(filename3.Data());
22   TList *listEfficiency = (TList *)fEfficiency->Get("efficiencyList");
23   drawEfficiency(listEfficiency,analysisType);
24
25   fQA->Close();
26   fMC->Close();
27   fEfficiency->Close();
28 }
29
30 //________________________________________//
31 void drawCutStatistics(TList *list,
32                        const char* analysisType) {
33   //Function to display the statistics from the cuts
34   //The histogram shows the influence of each cut on the primary
35   //and secondary (anti)protons
36   const Int_t NQAHISTOSPERLIST = 26;
37   
38   Double_t gEntriesQA2DList[12] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
39   Double_t gEntriesQAPrimaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryProtonsRejectedList[NQAHISTOSPERLIST];
40   Double_t gEntriesQASecondaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryProtonsRejectedList[NQAHISTOSPERLIST];
41   Double_t gEntriesQAPrimaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
42   Double_t gEntriesQASecondaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
43
44   for(Int_t i = 0; i < NQAHISTOSPERLIST; i++) {
45     gEntriesQAPrimaryProtonsAcceptedList[i] = 0.0;
46     gEntriesQAPrimaryProtonsRejectedList[i] = 0.0;
47     gEntriesQASecondaryProtonsAcceptedList[i] = 0.0;
48     gEntriesQASecondaryProtonsRejectedList[i] = 0.0;
49     gEntriesQAPrimaryAntiProtonsAcceptedList[i] = 0.0;
50     gEntriesQAPrimaryAntiProtonsRejectedList[i] = 0.0;
51     gEntriesQASecondaryAntiProtonsAcceptedList[i] = 0.0;
52     gEntriesQASecondaryAntiProtonsRejectedList[i] = 0.0;
53   }
54
55   TList *fQA2DList = (TList *)list->At(0);
56   GetQAEntries(fQA2DList,gEntriesQA2DList);
57   TH3F *gHistYPtPDGProtonsPass = (TH3F *)fQA2DList->At(10);
58   TH3F *gHistYPtPDGAntiProtonsPass = (TH3F *)fQA2DList->At(11);
59
60   TList *fQAPrimaryProtonsAcceptedList = (TList *)list->At(1);
61   GetQAEntries(fQAPrimaryProtonsAcceptedList,gEntriesQAPrimaryProtonsAcceptedList);
62
63   TList *fQAPrimaryProtonsRejectedList = (TList *)list->At(2);
64   GetQAEntries(fQAPrimaryProtonsRejectedList,gEntriesQAPrimaryProtonsRejectedList);
65
66   TList *fQASecondaryProtonsAcceptedList = (TList *)list->At(3);
67   GetQAEntries(fQASecondaryProtonsAcceptedList,gEntriesQASecondaryProtonsAcceptedList);
68
69   TList *fQASecondaryProtonsRejectedList = (TList *)list->At(4);
70   GetQAEntries(fQASecondaryProtonsRejectedList,gEntriesQASecondaryProtonsRejectedList);
71
72   TList *fQAPrimaryAntiProtonsAcceptedList = (TList *)list->At(5);
73   GetQAEntries(fQAPrimaryAntiProtonsAcceptedList,gEntriesQAPrimaryAntiProtonsAcceptedList);
74
75   TList *fQAPrimaryAntiProtonsRejectedList = (TList *)list->At(6);
76   GetQAEntries(fQAPrimaryAntiProtonsRejectedList,gEntriesQAPrimaryAntiProtonsRejectedList);
77
78   TList *fQASecondaryAntiProtonsAcceptedList = (TList *)list->At(7);
79   GetQAEntries(fQASecondaryAntiProtonsAcceptedList,gEntriesQASecondaryAntiProtonsAcceptedList);
80
81   TList *fQASecondaryAntiProtonsRejectedList = (TList *)list->At(8);
82   GetQAEntries(fQASecondaryAntiProtonsRejectedList,gEntriesQASecondaryAntiProtonsRejectedList);
83
84   //_______________________________________________________//
85   //Create the histograms
86   const Int_t nx = 26;
87   char *fCutName[nx] = {"Tracks","",
88                         "ITS Clusters",
89                         "#chi^{2}/N_{ITS-Clusters}",
90                         "TPC Clusters",
91                         "#chi^{2}/N_{TPC-Clusters}",
92                         "ExtCov11",
93                         "ExtCov22",
94                         "ExtCov33",
95                         "ExtCov44",
96                         "ExtCov55",
97                         "#sigma_{Vertex}",
98                         "#sigma_{Vertex-TPC}",
99                         "DCA_{xy}",
100                         "DCA_{xy}(TPC)",
101                         "DCA_{z}",
102                         "DCA_{z}(TPC)",
103                         "#chi^{2}(vertex)",
104                         "ITS refit",
105                         "TPC refit",
106                         "ESD pid",
107                         "TPC pid","",
108                         "N_{Secondaries}/N_{total}","",""};
109   char *fCutITSName[6] = {"SPD_{1}","SPD_{2}",
110                           "SDD_{1}","SDD_{2}",
111                           "SSD_{1}","SSD_{2}"};
112
113   //cut influence
114   TH2F *hEmpty = new TH2F("hEmpty","",nx,0,nx,100,0,100); 
115   hEmpty->SetStats(kFALSE); 
116   hEmpty->SetMarkerStyle(kFullCircle);
117   hEmpty->SetLineColor(2); hEmpty->SetMarkerColor(2);
118   hEmpty->GetYaxis()->SetTitle("Influence of the cuts [%]");
119   for(Int_t i = 1; i <= nx; i++) 
120     hEmpty->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
121   hEmpty->GetXaxis()->SetLabelOffset(0.01); 
122   hEmpty->GetXaxis()->SetLabelSize(0.045);
123
124   //primary protons
125   TH1F *hPrimaryProtons = new TH1F("hPrimaryProtons","",nx,0,nx); 
126   hPrimaryProtons->SetStats(kFALSE); 
127   hPrimaryProtons->SetMarkerStyle(kFullCircle);
128   hPrimaryProtons->SetLineColor(4); hPrimaryProtons->SetLineWidth(2); 
129   hPrimaryProtons->SetMarkerColor(4);
130   hPrimaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
131   for(Int_t i = 1; i <= nx; i++) {
132     hPrimaryProtons->SetBinContent(i,-10.);
133     hPrimaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
134   }
135   hPrimaryProtons->GetXaxis()->SetLabelOffset(0.01); 
136   hPrimaryProtons->GetXaxis()->SetLabelSize(0.045);
137
138   //secondary protons
139   TH1F *hSecondaryProtons = new TH1F("hSecondaryProtons","",nx,0,nx); 
140   hSecondaryProtons->SetStats(kFALSE); 
141   hSecondaryProtons->SetMarkerStyle(22);
142   hSecondaryProtons->SetMarkerSize(1.4);
143   hSecondaryProtons->SetLineColor(2); hSecondaryProtons->SetLineWidth(2); 
144   hSecondaryProtons->SetMarkerColor(2);
145   hSecondaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
146   for(Int_t i = 1; i <= nx; i++) {
147     hSecondaryProtons->SetBinContent(i,-10.);
148     hSecondaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
149   }
150   hSecondaryProtons->GetXaxis()->SetLabelOffset(0.01); 
151   hSecondaryProtons->GetXaxis()->SetLabelSize(0.045);
152
153   //primary antiprotons
154   TH1F *hPrimaryAntiProtons = new TH1F("hPrimaryAntiProtons","",nx,0,nx); 
155   hPrimaryAntiProtons->SetStats(kFALSE); 
156   hPrimaryAntiProtons->SetMarkerStyle(kFullCircle);
157   hPrimaryAntiProtons->SetLineColor(4); hPrimaryAntiProtons->SetLineWidth(2); 
158   hPrimaryAntiProtons->SetMarkerColor(4);
159   hPrimaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
160   for(Int_t i = 1; i <= nx; i++) {
161     hPrimaryAntiProtons->SetBinContent(i,-10.);
162     hPrimaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
163   }
164   hPrimaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
165   hPrimaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
166
167   //secondary antiprotons
168   TH1F *hSecondaryAntiProtons = new TH1F("hSecondaryAntiProtons","",nx,0,nx); 
169   hSecondaryAntiProtons->SetStats(kFALSE); 
170   hSecondaryAntiProtons->SetMarkerStyle(22);
171   hSecondaryAntiProtons->SetMarkerSize(1.4);
172   hSecondaryAntiProtons->SetLineColor(2); hSecondaryAntiProtons->SetLineWidth(2); 
173   hSecondaryAntiProtons->SetMarkerColor(2);
174   hSecondaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
175   for(Int_t i = 1; i <= nx; i++) {
176     hSecondaryAntiProtons->SetBinContent(i,-10.);
177     hSecondaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
178   }
179   hSecondaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
180   hSecondaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
181   //_______________________________________________________//
182
183   //1D for primary protons
184   //cout<<"_____________________________________________________"<<endl;
185   //cout<<"_______________PRIMARY PROTONS_______________________"<<endl;
186   hPrimaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[1]));
187
188   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
189     hPrimaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryProtonsAcceptedList[i-2],
190                                                      gEntriesQAPrimaryProtonsRejectedList[i-2]));
191   
192   //1D for secondary protons
193   //cout<<"_____________________________________________________"<<endl;
194   //cout<<"_______________SECONDARY PROTONS_____________________"<<endl;
195   hSecondaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[2],gEntriesQA2DList[3]));
196   
197   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
198     hSecondaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryProtonsAcceptedList[i-2],
199                                                        gEntriesQASecondaryProtonsRejectedList[i-2]));
200   hSecondaryProtons->SetBinContent(24,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[2]));
201
202   //1D for primary antiprotons
203   //cout<<"_________________________________________________________"<<endl;
204   //cout<<"_______________PRIMARY ANTIPROTONS_______________________"<<endl;
205   hPrimaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[5]));
206   
207   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
208     hPrimaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryAntiProtonsAcceptedList[i-2],
209                                                          gEntriesQAPrimaryAntiProtonsRejectedList[i-2]));
210   
211   //1D for secondary antiprotons
212   //cout<<"_________________________________________________________"<<endl;
213   //cout<<"_______________SECONDARY ANTIPROTONS_____________________"<<endl;
214   hSecondaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[6],gEntriesQA2DList[7]));
215
216   for(Int_t i = 2; i < NQAHISTOSPERLIST-4; i++) 
217     hSecondaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryAntiProtonsAcceptedList[i-2],
218                                                            gEntriesQASecondaryAntiProtonsRejectedList[i-2]));
219   hSecondaryAntiProtons->SetBinContent(24,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[6]));
220
221   TLatex *t1 = new TLatex();
222   t1->SetTextSize(0.04);
223   //_________________________________________________________//
224   TCanvas *c1 = new TCanvas("c1","Cut Influence - Protons",0,0,700,400);
225   c1->SetFillColor(10); c1->GetFrame()->SetFillColor(10);
226   c1->SetHighLightColor(10); c1->SetBottomMargin(0.15);
227   c1->SetGridx(); c1->SetGridy();
228
229   for(Int_t i = 1; i <= nx; i++) {
230     hPrimaryProtons->SetBinError(i,1.0);
231     hSecondaryProtons->SetBinError(i,1.0);
232   }
233   hEmpty->DrawCopy();
234   hPrimaryProtons->DrawCopy("EHISTSAME");
235   hSecondaryProtons->DrawCopy("EHISTSAME");
236   DrawMarker(20.5, 90, 20, 1.2, 4);
237   t1->DrawLatex(21,88,"Primary p");
238   DrawMarker(20.5, 80, 22, 1.2, 2);
239   t1->DrawLatex(21,78,"Secondary p");
240
241   c1->SaveAs("CutInfluence-Protons.gif");
242
243   //_________________________________________________________//
244   TCanvas *c2 = new TCanvas("c2","Cut Influence - AntiProtons",50,50,700,400);
245   c2->SetFillColor(10); c2->GetFrame()->SetFillColor(10);
246   c2->SetHighLightColor(10); c2->SetBottomMargin(0.15);
247   c2->SetGridx(); c2->SetGridy();
248
249   for(Int_t i = 1; i <= nx; i++) {
250     hPrimaryAntiProtons->SetBinError(i,1.0);
251     hSecondaryAntiProtons->SetBinError(i,1.0);
252   }
253   hEmpty->DrawCopy();
254   hPrimaryAntiProtons->DrawCopy("EHISTSAME");
255   hSecondaryAntiProtons->DrawCopy("EHISTSAME");
256   DrawMarker(20.5, 90, 20, 1.2, 4);
257   t1->DrawLatex(21,88,"Primary #bar{p}");
258   DrawMarker(20.5, 80, 22, 1.2, 2);
259   t1->DrawLatex(21,78,"Secondary #bar{p}");
260
261   c2->SaveAs("CutInfluence-AntiProtons.gif");
262
263   //_________________________________________________________//
264   //ITS layers influence
265   TH2F *hEmptyITS = new TH2F("hEmptyITS","",10,0,10,100,0,100); 
266   hEmptyITS->SetStats(kFALSE); 
267   hEmptyITS->SetMarkerStyle(kFullCircle);
268   hEmptyITS->SetLineColor(2); hEmptyITS->SetMarkerColor(2);
269   hEmptyITS->GetYaxis()->SetTitle("Influence of the ITS layers [%]");
270   hEmptyITS->GetYaxis()->SetTitleOffset(1.3);
271   for(Int_t i = 1; i <= 6; i++) 
272     hEmptyITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
273   hEmptyITS->GetXaxis()->SetLabelOffset(0.01); 
274   hEmptyITS->GetXaxis()->SetLabelSize(0.045);
275
276   //_________________________________________________________//
277   //primary protons
278   TH1F *hPrimaryProtonsITS = new TH1F("hPrimaryProtonsITS","",7,0,7); 
279   hPrimaryProtonsITS->SetStats(kFALSE); 
280   hPrimaryProtonsITS->SetMarkerStyle(kFullCircle);
281   hPrimaryProtonsITS->SetLineColor(4); hPrimaryProtonsITS->SetLineWidth(2); 
282   hPrimaryProtonsITS->SetMarkerColor(4);
283   hPrimaryProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
284   for(Int_t i = 1; i <= 6; i++) {
285     hPrimaryProtonsITS->SetBinContent(i,-10.);
286     hPrimaryProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
287   }
288   hPrimaryProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
289   hPrimaryProtonsITS->GetXaxis()->SetLabelSize(0.045);
290
291   //secondary protons
292   TH1F *hSecondaryProtonsITS = new TH1F("hSecondaryProtonsITS","",7,0,7); 
293   hSecondaryProtonsITS->SetStats(kFALSE); 
294   hSecondaryProtonsITS->SetMarkerStyle(22);
295   hSecondaryProtonsITS->SetMarkerSize(1.4);
296   hSecondaryProtonsITS->SetLineColor(2); hSecondaryProtonsITS->SetLineWidth(2); 
297   hSecondaryProtonsITS->SetMarkerColor(2);
298   hSecondaryProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
299   for(Int_t i = 1; i <= 6; i++) {
300     hSecondaryProtonsITS->SetBinContent(i,-10.);
301     hSecondaryProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
302   }
303   hSecondaryProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
304   hSecondaryProtonsITS->GetXaxis()->SetLabelSize(0.045);
305
306   //primary antiprotons
307   TH1F *hPrimaryAntiProtonsITS = new TH1F("hPrimaryAntiProtonsITS","",7,0,7); 
308   hPrimaryAntiProtonsITS->SetStats(kFALSE); 
309   hPrimaryAntiProtonsITS->SetMarkerStyle(kFullCircle);
310   hPrimaryAntiProtonsITS->SetLineColor(4); hPrimaryAntiProtonsITS->SetLineWidth(2); 
311   hPrimaryAntiProtonsITS->SetMarkerColor(4);
312   hPrimaryAntiProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
313   for(Int_t i = 1; i <= 6; i++) {
314     hPrimaryAntiProtonsITS->SetBinContent(i,-10.);
315     hPrimaryAntiProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
316   }
317   hPrimaryAntiProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
318   hPrimaryAntiProtonsITS->GetXaxis()->SetLabelSize(0.045);
319
320   //secondary antiprotons
321   TH1F *hSecondaryAntiProtonsITS = new TH1F("hSecondaryAntiProtonsITS","",7,0,7); 
322   hSecondaryAntiProtonsITS->SetStats(kFALSE); 
323   hSecondaryAntiProtonsITS->SetMarkerStyle(22);
324   hSecondaryAntiProtonsITS->SetMarkerSize(1.4);
325   hSecondaryAntiProtonsITS->SetLineColor(2); hSecondaryAntiProtonsITS->SetLineWidth(2); 
326   hSecondaryAntiProtonsITS->SetMarkerColor(2);
327   hSecondaryAntiProtonsITS->GetYaxis()->SetTitle("Influence of the cuts [%]");
328   for(Int_t i = 1; i <= 6; i++) {
329     hSecondaryAntiProtonsITS->SetBinContent(i,-10.);
330     hSecondaryAntiProtonsITS->GetXaxis()->SetBinLabel(i,fCutITSName[i-1]);
331   }
332   hSecondaryAntiProtonsITS->GetXaxis()->SetLabelOffset(0.01); 
333   hSecondaryAntiProtonsITS->GetXaxis()->SetLabelSize(0.045);
334
335   //_______________________________________________________//
336   TCanvas *c9 = new TCanvas("c9","ITS cluster map - (anti)protons",
337                             100,100,700,400);
338   c9->SetFillColor(10); c9->GetFrame()->SetFillColor(10);
339   c9->SetHighLightColor(10); c9->Divide(2,1);
340   for(Int_t i = 1; i <= 6; i++) {
341     hPrimaryProtonsITS->SetBinError(i,1.0);
342     hSecondaryProtonsITS->SetBinError(i,1.0);
343     hPrimaryAntiProtonsITS->SetBinError(i,1.0);
344     hSecondaryAntiProtonsITS->SetBinError(i,1.0);
345   }
346   c9->cd(1)->SetBottomMargin(0.15);
347   c9->cd(1)->SetLeftMargin(0.15);
348   c9->cd(1)->SetGridx(); c9->cd(1)->SetGridy();
349   hEmptyITS->SetTitle("Protons");
350   hEmptyITS->DrawCopy();
351
352   for(Int_t i = 1; i < 7; i++) {
353     hPrimaryProtonsITS->SetBinContent(i,GetPercentage(gEntriesQAPrimaryProtonsAcceptedList[19+i],
354                                                       gEntriesQAPrimaryProtonsRejectedList[19+i]));
355     hSecondaryProtonsITS->SetBinContent(i,GetPercentage(gEntriesQASecondaryProtonsAcceptedList[19+i],
356                                                         gEntriesQASecondaryProtonsRejectedList[19+i]));
357   }
358   hPrimaryProtonsITS->DrawCopy("EHISTSAME");
359   hSecondaryProtonsITS->DrawCopy("EHISTSAME");
360   DrawMarker(6.5, 90, 20, 1.2, 4);
361   t1->DrawLatex(7,88,"Primary p");
362   DrawMarker(6.5, 80, 22, 1.2, 2);
363   t1->DrawLatex(7,78,"Secondary p");
364
365   c9->cd(2)->SetBottomMargin(0.15);
366   c9->cd(2)->SetLeftMargin(0.15);
367   c9->cd(2)->SetGridx(); c9->cd(2)->SetGridy();
368   hEmptyITS->SetTitle("Antiprotons");
369   hEmptyITS->DrawCopy();
370   for(Int_t i = 1; i < 7; i++) {
371     hPrimaryAntiProtonsITS->SetBinContent(i,GetPercentage(gEntriesQAPrimaryAntiProtonsAcceptedList[19+i],
372                                                           gEntriesQAPrimaryAntiProtonsRejectedList[19+i]));
373     hSecondaryAntiProtonsITS->SetBinContent(i,GetPercentage(gEntriesQASecondaryAntiProtonsAcceptedList[19+i],
374                                                             gEntriesQASecondaryAntiProtonsRejectedList[19+i]));
375   }
376   hPrimaryAntiProtonsITS->DrawCopy("EHISTSAME");
377   hSecondaryAntiProtonsITS->DrawCopy("EHISTSAME");
378   DrawMarker(6.5, 90, 20, 1.2, 4);
379   t1->DrawLatex(7,88,"Primary #bar{p}");
380   DrawMarker(6.5, 80, 22, 1.2, 2);
381   t1->DrawLatex(7,78,"Secondary #bar{p}");
382
383   c9->SaveAs("CutInfluence-ITS.gif");
384   
385   //Efficiency - Contamination plots
386   DrawContamination(fQA2DList,analysisType);
387   DrawCutEfficiency(fQA2DList,analysisType);
388   DrawComposition(gHistYPtPDGProtonsPass,gHistYPtPDGAntiProtonsPass);
389 }
390
391 //________________________________________//
392 void DrawComposition(TH3F *gHistYPtPDGProtons,
393                      TH3F *gHistYPtPDGAntiProtons) {
394   //Function to display the composition of secondary (anti)protons
395   //that survive the quality criteria
396   Double_t nParticleCompositionProtonY[100], nParticleCompositionProtonPt[100];
397   Double_t nParticleCompositionAntiProtonY[100], nParticleCompositionAntiProtonPt[100];
398   Double_t gY[100], gPt[100];
399   for(Int_t iBins = 0; iBins < 100; iBins++) {
400     nParticleCompositionProtonY[iBins] = 0;
401     nParticleCompositionProtonPt[iBins] = 0;
402     nParticleCompositionAntiProtonY[iBins] = 0;
403     nParticleCompositionAntiProtonPt[iBins] = 0;
404     gY[iBins] = 0;
405     gPt[iBins] = 0;
406   }
407   
408   TGraph *gParticleProtonY[14];
409   TGraph *gParticleProtonPt[14];
410   TGraph *gParticleAntiProtonY[14];
411   TGraph *gParticleAntiProtonPt[14];
412   for(Int_t iParticle = 0; iParticle < 14; iParticle++) {
413     GetComposition(iParticle,
414                    gHistYPtPDGProtons,
415                    nParticleCompositionProtonY,
416                    gY, nParticleCompositionProtonPt, gPt);
417     gParticleProtonY[iParticle] = new TGraph(gHistYPtPDGProtons->GetNbinsX(),
418                                        gY,nParticleCompositionProtonY);
419     gParticleProtonY[iParticle]->SetMarkerStyle(iParticle+20);
420     gParticleProtonY[iParticle]->SetMarkerSize(1.2);
421
422     gParticleProtonPt[iParticle] = new TGraph(gHistYPtPDGProtons->GetNbinsY(),
423                                         gPt,nParticleCompositionProtonPt);
424     gParticleProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
425     gParticleProtonPt[iParticle]->SetMarkerSize(1.2);
426
427     GetComposition(iParticle,
428                    gHistYPtPDGAntiProtons,
429                    nParticleCompositionAntiProtonY,
430                    gY, nParticleCompositionAntiProtonPt, gPt);
431     gParticleAntiProtonY[iParticle] = new TGraph(gHistYPtPDGAntiProtons->GetNbinsX(),
432                                        gY,nParticleCompositionAntiProtonY);
433     gParticleAntiProtonY[iParticle]->SetMarkerStyle(iParticle+20);
434     gParticleAntiProtonY[iParticle]->SetMarkerSize(1.2);
435
436     gParticleAntiProtonPt[iParticle] = new TGraph(gHistYPtPDGAntiProtons->GetNbinsY(),
437                                         gPt,nParticleCompositionAntiProtonPt);
438     gParticleAntiProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
439     gParticleAntiProtonPt[iParticle]->SetMarkerSize(1.2);
440   }
441
442   //_________________________________________________________//
443   char *fParticleName[14] = {"Primary","K_{L}","#pi","K_{S}","K",
444                              "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
445                              "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
446   TLatex *t1 = new TLatex();
447   t1->SetTextSize(0.04);
448
449   TH2F *hEmptyY = new TH2F("hEmptyY","",100,-1.2,1.2,100,0,120); 
450   hEmptyY->SetStats(kFALSE); 
451   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
452   hEmptyY->GetXaxis()->SetTitle("y");
453
454   TCanvas *c12 = new TCanvas("c12",
455                              "Composition of accepted secondaries vs y",
456                              350,350,700,400);
457   c12->SetFillColor(10); c12->GetFrame()->SetFillColor(10); c12->Divide(2,1);
458   c12->SetHighLightColor(10); c12->cd(1)->SetBottomMargin(0.15);
459   c12->cd(1)->SetGridx(); c12->cd(1)->SetGridy();
460   hEmptyY->SetTitle("Protons");
461   hEmptyY->DrawCopy();
462   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
463     //if((iParticle == 0)||(iParticle == 2)||(iParticle == 5)||(iParticle == 6)||(iParticle == 8))
464     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
465       gParticleProtonY[iParticle]->Draw("P");
466     if(iParticle < 5) {
467       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
468       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
469     }
470     else {
471       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
472       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
473     }
474   }
475
476   c12->SetHighLightColor(10); c12->cd(2)->SetBottomMargin(0.15);
477   c12->cd(2)->SetGridx(); c12->cd(2)->SetGridy();
478   hEmptyY->SetTitle("Antiprotons");
479   hEmptyY->DrawCopy();
480   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
481     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
482       gParticleAntiProtonY[iParticle]->Draw("P");
483     if(iParticle < 5) {
484       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
485       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
486     }
487     else {
488       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
489       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
490     }
491   }
492   c12->SaveAs("SurvivedSecondaries-Composition-Rapidity.gif");
493
494   TH2F *hEmptyPt = new TH2F("hEmptyPt","",100,0.0,4.0,100,0,120); 
495   hEmptyPt->SetStats(kFALSE); 
496   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
497   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
498
499   TCanvas *c13 = new TCanvas("c13",
500                              "Composition of accepted secondaries vs pT",
501                              400,400,700,400);
502   c13->SetFillColor(10); c13->GetFrame()->SetFillColor(10); c13->Divide(2,1);
503   c13->SetHighLightColor(10); c13->cd(1)->SetBottomMargin(0.15);
504   c13->cd(1)->SetGridx(); c13->cd(1)->SetGridy();
505   hEmptyPt->GetXaxis()->SetRangeUser(gParticleProtonPt[0]->GetXaxis()->GetXmin()-0.2,gParticleProtonPt[0]->GetXaxis()->GetXmax()+0.2);
506   hEmptyPt->SetTitle("Protons");
507   hEmptyPt->DrawCopy();
508   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
509     if(iParticle < 5) {
510       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.1, 
511                  115-5*iParticle, 20+iParticle, 1.2, 1);
512       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.2,
513                     113-5*iParticle,fParticleName[iParticle]);
514     }
515     else {
516       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5, 
517                  115-5*(iParticle-5), 20+iParticle, 1.2, 1);
518       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5+0.1,
519                     113-5*(iParticle-5),fParticleName[iParticle]);
520     }
521     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
522       gParticleProtonPt[iParticle]->Draw("P");
523   }
524
525   c13->SetHighLightColor(10); c13->cd(2)->SetBottomMargin(0.15);
526   c13->cd(2)->SetGridx(); c13->cd(2)->SetGridy();
527   hEmptyPt->SetTitle("Antiprotons");
528   hEmptyPt->DrawCopy();
529   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
530     if(iParticle < 5) {
531       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.1, 
532                  115-5*iParticle, 20+iParticle, 1.2, 1);
533       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmin()+0.2,
534                     113-5*iParticle,fParticleName[iParticle]);
535     }
536     else {
537       DrawMarker(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5, 
538                  115-5*(iParticle-5), 20+iParticle, 1.2, 1);
539       t1->DrawLatex(gParticleProtonPt[0]->GetXaxis()->GetXmax()*0.5+0.1,
540                     113-5*(iParticle-5),fParticleName[iParticle]);
541     }
542     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
543       gParticleAntiProtonPt[iParticle]->Draw("P");
544   }
545   c13->SaveAs("SurvivedSecondaries-Composition-Pt.gif");
546 }
547
548 //________________________________________________//
549 void DrawContamination(TList *inputList,
550                        const char* analysisType) {
551   //loops over the list entries and
552   //draws the rapidity and pT dependence
553   //of the percentage of primary and secondary
554   //protons and antiprotons after the track cuts
555   cout<<"Extracting the entries for the histograms in the list: "<<
556     inputList->GetName()<<"..."<<endl;
557
558   TLatex *t1 = new TLatex();
559   t1->SetTextSize(0.04);
560
561   TH2F *hPrimaryProtons = (TH2F *)inputList->At(0);
562   TH2F *hSecondaryProtons = (TH2F *)inputList->At(2);
563   TH2F *hPrimaryAntiProtons = (TH2F *)inputList->At(4);
564   TH2F *hSecondaryAntiProtons = (TH2F *)inputList->At(6);
565
566   //rapidity dependence
567   //Protons
568   TH1D *gYPrimaryProtons = (TH1D *)hPrimaryProtons->ProjectionX("gYPrimaryProtons",0,hPrimaryProtons->GetXaxis()->GetNbins(),"e");
569   TH1D *gYSecondaryProtons = (TH1D *)hSecondaryProtons->ProjectionX("gYSecondaryProtons",0,hSecondaryProtons->GetXaxis()->GetNbins(),"e");
570   TH1D *gYTotalProtons = (TH1D *)hPrimaryProtons->ProjectionX("gYTotalProtons",0,hPrimaryProtons->GetXaxis()->GetNbins(),"e");
571   gYTotalProtons->Add(gYSecondaryProtons);
572
573   TH1D *gYPrimaryProtonsPercentage = new TH1D("gYPrimaryProtonsPercentage",
574                                               "",
575                                               hPrimaryProtons->GetXaxis()->GetNbins(),
576                                               hPrimaryProtons->GetXaxis()->GetXmin(),
577                                               hPrimaryProtons->GetXaxis()->GetXmax());                                        
578   gYPrimaryProtonsPercentage->Divide(gYPrimaryProtons,
579                                      gYTotalProtons,1.,1.0);
580   SetError(gYPrimaryProtonsPercentage,gYTotalProtons);
581   gYPrimaryProtonsPercentage->Scale(100.);
582   gYPrimaryProtonsPercentage->SetMarkerStyle(kFullCircle);
583
584   TH1D *gYSecondaryProtonsPercentage = new TH1D("gYSecondaryProtonsPercentage",
585                                                 "",
586                                                 hSecondaryProtons->GetXaxis()->GetNbins(),
587                                                 hSecondaryProtons->GetXaxis()->GetXmin(),
588                                                 hSecondaryProtons->GetXaxis()->GetXmax());                                            
589   gYSecondaryProtonsPercentage->Divide(gYSecondaryProtons,
590                                        gYTotalProtons,1.,1.0);
591   SetError(gYSecondaryProtonsPercentage,gYTotalProtons);
592   gYSecondaryProtonsPercentage->Scale(100.);
593   gYSecondaryProtonsPercentage->SetMarkerStyle(kOpenCircle);
594
595   //Antiprotons
596   TH1D *gYPrimaryAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionX("gYPrimaryAntiProtons",0,hPrimaryAntiProtons->GetXaxis()->GetNbins(),"e");
597   TH1D *gYSecondaryAntiProtons = (TH1D *)hSecondaryAntiProtons->ProjectionX("gYSecondaryAntiProtons",0,hSecondaryAntiProtons->GetXaxis()->GetNbins(),"e");
598   TH1D *gYTotalAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionX("gYTotalAntiProtons",0,hPrimaryAntiProtons->GetXaxis()->GetNbins(),"e");
599   gYTotalAntiProtons->Add(gYSecondaryAntiProtons);
600   
601   TH1D *gYPrimaryAntiProtonsPercentage = new TH1D("gYPrimaryAntiProtonsPercentage",
602                                                   "",
603                                                   hPrimaryAntiProtons->GetXaxis()->GetNbins(),
604                                                   hPrimaryAntiProtons->GetXaxis()->GetXmin(),
605                                                   hPrimaryAntiProtons->GetXaxis()->GetXmax());                                        
606   gYPrimaryAntiProtonsPercentage->Divide(gYPrimaryAntiProtons,
607                                          gYTotalAntiProtons,1.,1.0);
608   SetError(gYPrimaryAntiProtonsPercentage,gYTotalAntiProtons);
609   gYPrimaryAntiProtonsPercentage->Scale(100.);
610   gYPrimaryAntiProtonsPercentage->SetMarkerStyle(kFullCircle);
611   
612   TH1D *gYSecondaryAntiProtonsPercentage = new TH1D("gYSecondaryAntiProtonsPercentage",
613                                                     "",
614                                                     hSecondaryAntiProtons->GetXaxis()->GetNbins(),
615                                                     hSecondaryAntiProtons->GetXaxis()->GetXmin(),
616                                                     hSecondaryAntiProtons->GetXaxis()->GetXmax());                                            
617   gYSecondaryAntiProtonsPercentage->Divide(gYSecondaryAntiProtons,
618                                            gYTotalAntiProtons,1.,1.0);
619   SetError(gYSecondaryAntiProtonsPercentage,gYTotalAntiProtons);
620   gYSecondaryAntiProtonsPercentage->Scale(100.);
621   gYSecondaryAntiProtonsPercentage->SetMarkerStyle(kOpenCircle);
622   
623   
624   TH2F *hEmptyY = new TH2F("hEmptyCompositionY","",
625                            100,-1.2,1.2,100,-10.0,130); 
626   hEmptyY->SetStats(kFALSE); 
627   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
628   hEmptyY->GetYaxis()->SetTitleOffset(1.3);
629   hEmptyY->GetXaxis()->SetTitle("y");
630
631   TCanvas *c7 = new TCanvas("c7","(Anti)Proton contamination vs y",
632                             150,150,700,400);
633   c7->SetFillColor(10); c7->GetFrame()->SetFillColor(10); 
634   c7->SetHighLightColor(10); c7->Divide(2,1);
635
636   c7->cd(1)->SetBottomMargin(0.15); 
637   c7->cd(1)->SetLeftMargin(0.15); 
638   c7->cd(1)->SetGridx(); c7->cd(1)->SetGridy();
639   hEmptyY->SetTitle("Protons");
640   hEmptyY->DrawCopy();
641   gYPrimaryProtonsPercentage->DrawCopy("ESAME");
642   gYSecondaryProtonsPercentage->DrawCopy("ESAME");
643
644   DrawMarker(0, 55, kFullCircle, 1.2, 1);
645   t1->DrawLatex(0.1,53,"Primaries");
646   DrawMarker(0, 45, kOpenCircle, 1.2, 1);
647   t1->DrawLatex(0.1,43,"Secondaries");
648
649   c7->cd(2)->SetBottomMargin(0.15); 
650   c7->cd(2)->SetLeftMargin(0.15); 
651   c7->cd(2)->SetGridx(); c7->cd(2)->SetGridy();
652   hEmptyY->SetTitle("Antiprotons");
653   hEmptyY->DrawCopy();
654   gYPrimaryAntiProtonsPercentage->DrawCopy("ESAME");
655   gYSecondaryAntiProtonsPercentage->DrawCopy("ESAME");
656
657   DrawMarker(0, 55, kFullCircle, 1.2, 1);
658   t1->DrawLatex(0.1,53,"Primaries");
659   DrawMarker(0, 45, kOpenCircle, 1.2, 1);
660   t1->DrawLatex(0.1,41,"Secondaries");
661
662   c7->SaveAs("Contamination-Protons-Rapidity.gif");
663
664   //pT dependence
665   //Protons
666   TH1D *gPtPrimaryProtons = (TH1D *)hPrimaryProtons->ProjectionY("gPtPrimaryProtons",0,hPrimaryProtons->GetYaxis()->GetNbins(),"e");
667   TH1D *gPtSecondaryProtons = (TH1D *)hSecondaryProtons->ProjectionY("gPtSecondaryProtons",0,hSecondaryProtons->GetYaxis()->GetNbins(),"e");
668   TH1D *gPtTotalProtons = (TH1D *)hPrimaryProtons->ProjectionY("gPtTotalProtons",0,hPrimaryProtons->GetYaxis()->GetNbins(),"e");
669   gPtTotalProtons->Add(gPtSecondaryProtons);
670
671   TH1D *gPtPrimaryProtonsPercentage = new TH1D("gPtPrimaryProtonsPercentage",
672                                                "",
673                                                hPrimaryProtons->GetYaxis()->GetNbins(),
674                                                hPrimaryProtons->GetYaxis()->GetXmin(),
675                                                hPrimaryProtons->GetYaxis()->GetXmax());                                       
676   gPtPrimaryProtonsPercentage->Divide(gPtPrimaryProtons,
677                                       gPtTotalProtons,1.,1.0);
678   SetError(gPtPrimaryProtonsPercentage,gPtTotalProtons);
679   gPtPrimaryProtonsPercentage->Scale(100.);
680   gPtPrimaryProtonsPercentage->SetMarkerStyle(kFullCircle);
681   
682   TH1D *gPtSecondaryProtonsPercentage = new TH1D("gPtSecondaryProtonsPercentage",
683                                                  "",
684                                                  hSecondaryProtons->GetYaxis()->GetNbins(),
685                                                  hSecondaryProtons->GetYaxis()->GetXmin(),
686                                                  hSecondaryProtons->GetYaxis()->GetXmax());                                           
687   gPtSecondaryProtonsPercentage->Divide(gPtSecondaryProtons,
688                                         gPtTotalProtons,1.,1.0);
689   SetError(gPtSecondaryProtonsPercentage,gPtTotalProtons);
690   gPtSecondaryProtonsPercentage->Scale(100.);
691   gPtSecondaryProtonsPercentage->SetMarkerStyle(kOpenCircle);
692
693
694   //Antiprotons
695   TH1D *gPtPrimaryAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionY("gPtPrimaryAntiProtons",0,hPrimaryAntiProtons->GetYaxis()->GetNbins(),"e");
696   TH1D *gPtSecondaryAntiProtons = (TH1D *)hSecondaryAntiProtons->ProjectionY("gPtSecondaryAntiProtons",0,hSecondaryAntiProtons->GetYaxis()->GetNbins(),"e");
697   TH1D *gPtTotalAntiProtons = (TH1D *)hPrimaryAntiProtons->ProjectionY("gPtTotalAntiProtons",0,hPrimaryAntiProtons->GetYaxis()->GetNbins(),"e");
698   gPtTotalAntiProtons->Add(gPtSecondaryAntiProtons);
699   
700   TH1D *gPtPrimaryAntiProtonsPercentage = new TH1D("gPtPrimaryAntiProtonsPercentage",
701                                                    "",
702                                                    hPrimaryAntiProtons->GetYaxis()->GetNbins(),
703                                                    hPrimaryAntiProtons->GetYaxis()->GetXmin(),
704                                                    hPrimaryAntiProtons->GetYaxis()->GetXmax());                                       
705   gPtPrimaryAntiProtonsPercentage->Divide(gPtPrimaryAntiProtons,
706                                           gPtTotalAntiProtons,1.,1.0);
707   SetError(gPtPrimaryAntiProtonsPercentage,gPtTotalAntiProtons);
708   gPtPrimaryAntiProtonsPercentage->Scale(100.);
709   gPtPrimaryAntiProtonsPercentage->SetMarkerStyle(kFullCircle);
710   
711   TH1D *gPtSecondaryAntiProtonsPercentage = new TH1D("gPtSecondaryAntiProtonsPercentage",
712                                                      "",
713                                                      hSecondaryAntiProtons->GetYaxis()->GetNbins(),
714                                                      hSecondaryAntiProtons->GetYaxis()->GetXmin(),
715                                                      hSecondaryAntiProtons->GetYaxis()->GetXmax());                                           
716   gPtSecondaryAntiProtonsPercentage->Divide(gPtSecondaryAntiProtons,
717                                             gPtTotalAntiProtons,1.,1.0);
718   SetError(gPtSecondaryAntiProtonsPercentage,gPtTotalAntiProtons);
719   gPtSecondaryAntiProtonsPercentage->Scale(100.);
720   gPtSecondaryAntiProtonsPercentage->SetMarkerStyle(kOpenCircle);
721   
722   TH2F *hEmptyPt = new TH2F("hEmptyCompositionPt","",
723                            100,0.0,4.0,100,-10.0,130); 
724   hEmptyPt->SetStats(kFALSE); 
725   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
726   hEmptyPt->GetYaxis()->SetTitleOffset(1.3);
727   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
728
729   TCanvas *c8 = new TCanvas("c8","(Anti)Proton comtamination vs pT",
730                             200,200,700,400);
731   c8->SetFillColor(10); c8->GetFrame()->SetFillColor(10); 
732   c8->SetHighLightColor(10); c8->Divide(2,1);
733
734   c8->cd(1)->SetBottomMargin(0.15); 
735   c8->cd(1)->SetLeftMargin(0.15); 
736   c8->cd(1)->SetGridx(); c8->cd(1)->SetGridy();
737   hEmptyPt->SetTitle("Protons");
738   hEmptyPt->GetXaxis()->SetRangeUser(gPtPrimaryProtonsPercentage->GetXaxis()->GetXmin()-0.2,gPtPrimaryProtonsPercentage->GetXaxis()->GetXmax()+0.2);
739   hEmptyPt->DrawCopy();
740   gPtPrimaryProtonsPercentage->DrawCopy("ESAME");
741   gPtSecondaryProtonsPercentage->DrawCopy("ESAME");
742
743   DrawMarker(0.5, 55, kFullCircle, 1.2, 1);
744   t1->DrawLatex(0.6,53,"Primaries");
745   DrawMarker(0.5, 45, kOpenCircle, 1.2, 1);
746   t1->DrawLatex(0.6,41,"Secondaries");
747
748   c8->cd(2)->SetBottomMargin(0.15); 
749   c8->cd(2)->SetLeftMargin(0.15); 
750   c8->cd(2)->SetGridx(); c8->cd(2)->SetGridy();
751   hEmptyPt->SetTitle("Antirotons");
752   hEmptyPt->DrawCopy();
753   gPtPrimaryAntiProtonsPercentage->DrawCopy("ESAME");
754   gPtSecondaryAntiProtonsPercentage->DrawCopy("ESAME");
755
756   DrawMarker(2.0, 55, kFullCircle, 1.2, 1);
757   t1->DrawLatex(2.1,53,"Primaries");
758   DrawMarker(2.0, 45, kOpenCircle, 1.2, 1);
759   t1->DrawLatex(2.1,43,"Secondaries");
760
761   c8->SaveAs("Contamination-Protons-Pt.gif");
762
763   TString outputFileName = "Contamination."; 
764   outputFileName += analysisType; outputFileName += ".root";
765   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
766   gYPrimaryProtonsPercentage->Write();
767   gYSecondaryProtonsPercentage->Write();
768   gPtPrimaryProtonsPercentage->Write();
769   gPtSecondaryProtonsPercentage->Write();
770   gYPrimaryAntiProtonsPercentage->Write();
771   gYSecondaryAntiProtonsPercentage->Write();
772   gPtPrimaryAntiProtonsPercentage->Write();
773   gPtSecondaryAntiProtonsPercentage->Write();
774   fout->Close();
775 }
776
777 //________________________________________________//
778 void DrawCutEfficiency(TList *inputList,
779                        const char* analysisType) {
780   //loops over the list entries and
781   //draws the rapidity and pT dependence
782   //of the percentage of primary and secondary
783   //protons and antiprotons after the track cuts
784   cout<<"Extracting the entries for the histograms in the list: "<<
785     inputList->GetName()<<"..."<<endl;
786
787   TLatex *t1 = new TLatex();
788   t1->SetTextSize(0.04);
789
790   TH2F *hPrimaryESDProtons = (TH2F *)inputList->At(0);
791   TH2F *hPrimaryESDAntiProtons = (TH2F *)inputList->At(4);
792   TH2F *hPrimaryMCProtons = (TH2F *)inputList->At(8);
793   TH2F *hPrimaryMCAntiProtons = (TH2F *)inputList->At(9);
794
795   //rapidity dependence
796   //Protons
797   TH1D *gYPrimaryESDProtons = (TH1D *)hPrimaryESDProtons->ProjectionX("gYPrimaryESDProtons",0,hPrimaryESDProtons->GetXaxis()->GetNbins(),"e");
798   TH1D *gYPrimaryMCProtons = (TH1D *)hPrimaryMCProtons->ProjectionX("gYPrimaryMCProtons",0,hPrimaryMCProtons->GetXaxis()->GetNbins(),"e");
799   gYPrimaryESDProtons->Divide(gYPrimaryMCProtons);
800   SetError(gYPrimaryESDProtons,gYPrimaryMCProtons);
801   gYPrimaryESDProtons->Scale(100.);
802   gYPrimaryESDProtons->SetMarkerStyle(kFullCircle);
803
804   //Antiprotons
805   TH1D *gYPrimaryESDAntiProtons = (TH1D *)hPrimaryESDAntiProtons->ProjectionX("gYPrimaryESDAntiProtons",0,hPrimaryESDAntiProtons->GetXaxis()->GetNbins(),"e");
806   TH1D *gYPrimaryMCAntiProtons = (TH1D *)hPrimaryMCAntiProtons->ProjectionX("gYPrimaryMCAntiProtons",0,hPrimaryMCAntiProtons->GetXaxis()->GetNbins(),"e");
807   gYPrimaryESDAntiProtons->Divide(gYPrimaryMCAntiProtons);
808   SetError(gYPrimaryESDAntiProtons,gYPrimaryMCAntiProtons);
809   gYPrimaryESDAntiProtons->Scale(100.);
810   gYPrimaryESDAntiProtons->SetMarkerStyle(kFullCircle);
811   
812   TH2F *hEmptyY = new TH2F("hEmptyEfficiencyY","",
813                            100,-1.2,1.2,100,-10.0,130); 
814   hEmptyY->SetStats(kFALSE); 
815   hEmptyY->GetYaxis()->SetTitle("#epsilon [%]");
816   hEmptyY->GetYaxis()->SetTitleOffset(1.3);
817   hEmptyY->GetXaxis()->SetTitle("y");
818
819   TCanvas *c10 = new TCanvas("c10","(Anti)Proton cut efficiency vs y",
820                             250,250,700,400);
821   c10->SetFillColor(10); c10->GetFrame()->SetFillColor(10); 
822   c10->SetHighLightColor(10); c10->Divide(2,1);
823
824   c10->cd(1)->SetBottomMargin(0.15); 
825   c10->cd(1)->SetLeftMargin(0.15); 
826   c10->cd(1)->SetGridx(); c10->cd(1)->SetGridy();
827   hEmptyY->SetTitle("Protons");
828   hEmptyY->GetXaxis()->SetRangeUser(gYPrimaryESDAntiProtons->GetXaxis()->GetXmin()-0.2,gYPrimaryESDAntiProtons->GetXaxis()->GetXmax()+0.2);
829   hEmptyY->DrawCopy();
830   gYPrimaryESDProtons->DrawCopy("ESAME");
831
832   c10->cd(2)->SetBottomMargin(0.15); 
833   c10->cd(2)->SetLeftMargin(0.15); 
834   c10->cd(2)->SetGridx(); c10->cd(2)->SetGridy();
835   hEmptyY->SetTitle("Antiprotons");
836   hEmptyY->DrawCopy();
837   gYPrimaryESDAntiProtons->DrawCopy("ESAME");
838
839   c10->SaveAs("CutEfficiency-Protons-Rapidity.gif");
840
841   //pT dependence
842   //Protons
843   TH1D *gPtPrimaryESDProtons = (TH1D *)hPrimaryESDProtons->ProjectionY("gPtPrimaryESDProtons",0,hPrimaryESDProtons->GetYaxis()->GetNbins(),"e");
844   TH1D *gPtPrimaryMCProtons = (TH1D *)hPrimaryMCProtons->ProjectionY("gPtPrimaryMCProtons",0,hPrimaryMCProtons->GetYaxis()->GetNbins(),"e");
845   gPtPrimaryESDProtons->Divide(gPtPrimaryMCProtons);
846   SetError(gPtPrimaryESDProtons,gPtPrimaryMCProtons);
847   gPtPrimaryESDProtons->Scale(100.);
848   gPtPrimaryESDProtons->SetMarkerStyle(kFullCircle);
849
850   //Antiprotons
851   TH1D *gPtPrimaryESDAntiProtons = (TH1D *)hPrimaryESDAntiProtons->ProjectionY("gPtPrimaryESDAntiProtons",0,hPrimaryESDAntiProtons->GetYaxis()->GetNbins(),"e");
852   TH1D *gPtPrimaryMCAntiProtons = (TH1D *)hPrimaryMCAntiProtons->ProjectionY("gPtPrimaryMCAntiProtons",0,hPrimaryMCAntiProtons->GetYaxis()->GetNbins(),"e");
853   gPtPrimaryESDAntiProtons->Divide(gPtPrimaryMCAntiProtons);
854   SetError(gPtPrimaryESDAntiProtons,gPtPrimaryMCAntiProtons);
855   gPtPrimaryESDAntiProtons->Scale(100.);
856   gPtPrimaryESDAntiProtons->SetMarkerStyle(kFullCircle);
857
858   TH2F *hEmptyPt = new TH2F("hEmptyEfficiencyPt","",
859                            100,0.0,4.0,100,-10.0,130); 
860   hEmptyPt->SetStats(kFALSE); 
861   hEmptyPt->GetYaxis()->SetTitle("#epsilon [%]");
862   hEmptyPt->GetYaxis()->SetTitleOffset(1.3);
863   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
864
865   TCanvas *c11 = new TCanvas("c11","(Anti)Proton cut efficiency vs pT",
866                             300,300,700,400);
867   c11->SetFillColor(10); c11->GetFrame()->SetFillColor(10); 
868   c11->SetHighLightColor(10); c11->Divide(2,1);
869
870   c11->cd(1)->SetBottomMargin(0.15); 
871   c11->cd(1)->SetLeftMargin(0.15); 
872   c11->cd(1)->SetGridx(); c11->cd(1)->SetGridy();
873   hEmptyPt->SetTitle("Protons");
874   hEmptyPt->GetXaxis()->SetRangeUser(gPtPrimaryESDAntiProtons->GetXaxis()->GetXmin()-0.2,gPtPrimaryESDAntiProtons->GetXaxis()->GetXmax()+0.2);
875   hEmptyPt->DrawCopy();
876   gPtPrimaryESDProtons->DrawCopy("ESAME");
877
878   c11->cd(2)->SetBottomMargin(0.15); 
879   c11->cd(2)->SetLeftMargin(0.15); 
880   c11->cd(2)->SetGridx(); c11->cd(2)->SetGridy();
881   hEmptyPt->SetTitle("Antirotons");
882   hEmptyPt->DrawCopy();
883   gPtPrimaryESDAntiProtons->DrawCopy("ESAME");
884
885   c11->SaveAs("CutEfficiency-Protons-Pt.gif");
886
887   TString outputFileName = "CutEfficiency.";
888   outputFileName += analysisType; outputFileName += ".root";
889   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
890   gYPrimaryESDProtons->Write();
891   gYPrimaryESDAntiProtons->Write();
892   gPtPrimaryESDProtons->Write();
893   gPtPrimaryESDAntiProtons->Write();
894   fout->Close();
895 }
896
897 //________________________________________________//
898 void GetQAEntries(TList *inputList, Double_t *entries) {
899   //loops over the list entries
900   //extracts the entries for each histogram
901   //cout<<"Extracting the entries for the histograms in the list: "<<
902   //inputList->GetName()<<"..."<<endl;
903
904   for(Int_t i = 0; i < inputList->GetEntries(); i++) {
905     TH1F *gHist = (TH1F *)inputList->At(i);
906     entries[i] = gHist->GetEntries();
907     cout<<"Histogram: "<<gHist->GetName()<<
908       " - Entries: "<<entries[i]<<endl;
909     gHist = 0;
910   }
911 }
912
913 //________________________________________________//
914 Double_t GetPercentage(Double_t nPassEntries,
915                        Double_t nRejectEntries) {
916   //returns the percentage of tracks that were rejected by a cut
917   Int_t nTotalEntries = nPassEntries + nRejectEntries;
918
919   if(nTotalEntries == 0)
920     return -1;
921
922   return 100.*nRejectEntries/nTotalEntries;
923 }
924
925 //________________________________________//
926 void drawMCQA(TList *listPDG, TList *listMCProcesses) {
927   //Function to display the composition of secondary (anti)protons
928   //The histogram shows the percentage of secondary (anti)protons
929   //originating from each particle species.
930   //The box summarizes the MC process that gave these secondary (anti)protons
931   TDatabasePDG *db = TDatabasePDG::Instance();
932   TParticlePDG *p = 0x0;
933   
934   TH3F *gHistYPtPDGProtons = (TH3F *)listPDG->At(0);
935   TH3F *gHistYPtPDGAntiProtons = (TH3F *)listPDG->At(1);
936   readProcesses(listMCProcesses);
937   Double_t nParticleCompositionProtonY[100], nParticleCompositionProtonPt[100];
938   Double_t nParticleCompositionAntiProtonY[100], nParticleCompositionAntiProtonPt[100];
939   Double_t gY[100], gPt[100];
940   for(Int_t iBins = 0; iBins < 100; iBins++) {
941     nParticleCompositionProtonY[iBins] = 0;
942     nParticleCompositionProtonPt[iBins] = 0;
943     nParticleCompositionAntiProtonY[iBins] = 0;
944     nParticleCompositionAntiProtonPt[iBins] = 0;
945     gY[iBins] = 0;
946     gPt[iBins] = 0;
947   }
948   
949   TGraph *gParticleProtonY[14];
950   TGraph *gParticleProtonPt[14];
951   TGraph *gParticleAntiProtonY[14];
952   TGraph *gParticleAntiProtonPt[14];
953   for(Int_t iParticle = 0; iParticle < 14; iParticle++) {
954     GetComposition(iParticle,
955                    gHistYPtPDGProtons,
956                    nParticleCompositionProtonY,
957                    gY, nParticleCompositionProtonPt, gPt);
958     gParticleProtonY[iParticle] = new TGraph(gHistYPtPDGProtons->GetNbinsX(),
959                                        gY,nParticleCompositionProtonY);
960     gParticleProtonY[iParticle]->SetMarkerStyle(iParticle+20);
961     gParticleProtonY[iParticle]->SetMarkerSize(1.2);
962
963     gParticleProtonPt[iParticle] = new TGraph(gHistYPtPDGProtons->GetNbinsY(),
964                                         gPt,nParticleCompositionProtonPt);
965     gParticleProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
966     gParticleProtonPt[iParticle]->SetMarkerSize(1.2);
967
968     GetComposition(iParticle,
969                    gHistYPtPDGAntiProtons,
970                    nParticleCompositionAntiProtonY,
971                    gY, nParticleCompositionAntiProtonPt, gPt);
972     gParticleAntiProtonY[iParticle] = new TGraph(gHistYPtPDGAntiProtons->GetNbinsX(),
973                                        gY,nParticleCompositionAntiProtonY);
974     gParticleAntiProtonY[iParticle]->SetMarkerStyle(iParticle+20);
975     gParticleAntiProtonY[iParticle]->SetMarkerSize(1.2);
976
977     gParticleAntiProtonPt[iParticle] = new TGraph(gHistYPtPDGAntiProtons->GetNbinsY(),
978                                         gPt,nParticleCompositionAntiProtonPt);
979     gParticleAntiProtonPt[iParticle]->SetMarkerStyle(iParticle+20);
980     gParticleAntiProtonPt[iParticle]->SetMarkerSize(1.2);
981   }
982
983   //_________________________________________________________//
984   char *fParticleName[14] = {"Primary","K_{L}","#pi","K_{S}","K",
985                              "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
986                              "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
987   TLatex *t1 = new TLatex();
988   t1->SetTextSize(0.04);
989
990   TH2F *hEmptyY = new TH2F("hEmptyY","",100,-1.2,1.2,100,0,120); 
991   hEmptyY->SetStats(kFALSE); 
992   hEmptyY->GetYaxis()->SetTitle("Particle composition [%]");
993   hEmptyY->GetXaxis()->SetTitle("y");
994
995   TCanvas *c3 = new TCanvas("c3","MC secondary composition vs y - Protons",
996                             450,450,700,400);
997   c3->SetFillColor(10); c3->GetFrame()->SetFillColor(10);
998   c3->SetHighLightColor(10); c3->SetBottomMargin(0.15);
999   c3->SetGridx(); c3->SetGridy();
1000   hEmptyY->DrawCopy();
1001   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1002     //if((iParticle == 0)||(iParticle == 2)||(iParticle == 5)||(iParticle == 6)||(iParticle == 8))
1003     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
1004       gParticleProtonY[iParticle]->Draw("P");
1005     if(iParticle < 5) {
1006       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
1007       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
1008     }
1009     else {
1010       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1011       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
1012     }
1013   }
1014
1015   TCanvas *c5 = new TCanvas("c5","MC secondary composition vs y - antiProtons",
1016                             500,500,700,400);
1017   c5->SetFillColor(10); c5->GetFrame()->SetFillColor(10);
1018   c5->SetHighLightColor(10); c5->SetBottomMargin(0.15);
1019   c5->SetGridx(); c5->SetGridy();
1020   hEmptyY->DrawCopy();
1021   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1022     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
1023       gParticleAntiProtonY[iParticle]->Draw("P");
1024     if(iParticle < 5) {
1025       DrawMarker(-1.1, 115-5*iParticle, 20+iParticle, 1.2, 1);
1026       t1->DrawLatex(-1.0,113-5*iParticle,fParticleName[iParticle]);
1027     }
1028     else {
1029       DrawMarker(0.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1030       t1->DrawLatex(0.3,113-5*(iParticle-5),fParticleName[iParticle]);
1031     }
1032   }
1033
1034   TH2F *hEmptyPt = new TH2F("hEmptyPt","",100,0.0,4.0,100,0,120); 
1035   hEmptyPt->SetStats(kFALSE); 
1036   hEmptyPt->GetYaxis()->SetTitle("Particle composition [%]");
1037   hEmptyPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1038
1039   TCanvas *c4 = new TCanvas("c4","MC secondary composition vs pT - Protons",
1040                             550,550,700,400);
1041   c4->SetFillColor(10); c4->GetFrame()->SetFillColor(10);
1042   c4->SetHighLightColor(10); c4->SetBottomMargin(0.15);
1043   c4->SetGridx(); c4->SetGridy();
1044   hEmptyPt->DrawCopy();
1045   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1046     if(iParticle < 5) {
1047       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
1048       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
1049     }
1050     else {
1051       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1052       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
1053     }
1054     if((iParticle == 0)||(iParticle == 2)||(iParticle == 6)||(iParticle == 8))
1055       gParticleProtonPt[iParticle]->Draw("P");
1056   }
1057
1058   TCanvas *c6 = new TCanvas("c6",
1059                             "MC secondary composition vs pT - AntiProtons",
1060                             600,600,700,400);
1061   c6->SetFillColor(10); c6->GetFrame()->SetFillColor(10);
1062   c6->SetHighLightColor(10); c6->SetBottomMargin(0.15);
1063   c6->SetGridx(); c6->SetGridy();
1064   hEmptyPt->DrawCopy();
1065   for(Int_t iParticle = 0; iParticle < 10; iParticle++) {
1066     if(iParticle < 5) {
1067       DrawMarker(0.2, 115-5*iParticle, 20+iParticle, 1.2, 1);
1068       t1->DrawLatex(0.3,113-5*iParticle,fParticleName[iParticle]);
1069     }
1070     else {
1071       DrawMarker(2.2, 115-5*(iParticle-5), 20+iParticle, 1.2, 1);
1072       t1->DrawLatex(2.3,113-5*(iParticle-5),fParticleName[iParticle]);
1073     }
1074     if((iParticle == 0)||(iParticle == 6)||(iParticle == 8))
1075       gParticleAntiProtonPt[iParticle]->Draw("P");
1076   }
1077 }
1078
1079 //________________________________________//
1080 void GetComposition(Int_t iSpecies,
1081                     TH3F *gHist, 
1082                     Double_t *nParticleCompositionY,
1083                     Double_t *gY,
1084                     Double_t *nParticleCompositionPt,
1085                     Double_t *gPt) {
1086   //Returns the pT and y dependence of the MC composition
1087   Double_t ymin = gHist->GetXaxis()->GetXmin();
1088   Double_t ymax = gHist->GetXaxis()->GetXmax();
1089   Double_t nybins = gHist->GetNbinsX();
1090   Double_t ptmin = gHist->GetYaxis()->GetXmin();
1091   Double_t ptmax = gHist->GetYaxis()->GetXmax();
1092   Double_t nptbins = gHist->GetNbinsY();
1093   Double_t nTotalY[100], nTotalPt[100];
1094   for(Int_t iBins = 0; iBins < 100; iBins++) {
1095     nParticleCompositionY[iBins] = 0;
1096     nParticleCompositionPt[iBins] = 0;
1097     nTotalY[iBins] = 0.0;
1098     nTotalPt[iBins] = 0.0;
1099   }
1100
1101   //rapidity dependence
1102   //cout<<"Ymin: "<<ymin<<" - Ymax: "<<ymax<<" - Ybins: "<<nybins<<endl;
1103   for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1104     for(Int_t iZbins = 1; iZbins <= gHist->GetNbinsZ(); iZbins++) {
1105       for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1106         nTotalY[iXbins-1] += gHist->GetBinContent(iXbins,iYbins,iZbins);
1107       }
1108     }
1109   }
1110
1111   for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1112     for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1113       if(nTotalY[iXbins-1] > 0)
1114         nParticleCompositionY[iXbins-1] += 100.*gHist->GetBinContent(iXbins,iYbins,iSpecies+1)/nTotalY[iXbins-1];
1115       //if(nParticleCompositionY[iXbins-1] == 0) 
1116       //nParticleCompositionY[iXbins-1] = -10.0;
1117     }//pt loop
1118     gY[iXbins-1] = ymin + (iXbins-1)*(ymax - ymin)/nybins + 0.5*(ymax - ymin)/nybins;
1119     //cout<<"y: "<<gY[iXbins-1]<<
1120     //" - test: "<<ymin + (iXbins-1)*(ymax - ymin)/nybins + 0.5*(ymax - ymin)/nybins<<
1121     //" - Number of protons: "<<nY[iXbins-1]<<
1122     //" - Total: "<<nTotalY[iXbins-1]<<
1123     //" - Percentage: "<<nParticleCompositionY[iXbins-1]<<endl;
1124   }//y loop
1125
1126   //pt dependence
1127   //cout<<"Ptmin: "<<ptmin<<" - Ptmax: "<<ptmax<<" - Ptbins: "<<nptbins<<endl;
1128   for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1129     for(Int_t iZbins = 1; iZbins <= gHist->GetNbinsZ(); iZbins++) {
1130       for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1131         nTotalPt[iYbins-1] += gHist->GetBinContent(iXbins,iYbins,iZbins);
1132       }
1133     }
1134   }
1135
1136   for(Int_t iYbins = 1; iYbins <= gHist->GetNbinsY(); iYbins++) {
1137     for(Int_t iXbins = 1; iXbins <= gHist->GetNbinsX(); iXbins++) {
1138       if(nTotalPt[iYbins-1] > 0)
1139         nParticleCompositionPt[iYbins-1] += 100.*gHist->GetBinContent(iXbins,iYbins,iSpecies+1)/nTotalPt[iYbins-1];
1140       //if(nParticleCompositionPt[iYbins-1] == 0) 
1141       //nParticleCompositionPt[iYbins-1] = -10.0;
1142     }//pt loop
1143     gPt[iYbins-1] = ptmin + (iYbins-1)*(ptmax - ptmin)/nptbins + 0.5*(ptmax - ptmin)/nptbins;
1144     //cout<<"Pt: "<<gPt[iYbins-1]<<
1145     //" - test: "<<ptmin + (iYbins-1)*(ptmax - ptmin)/nptbins + 0.5*(ptmax - ptmin)/nptbins<<
1146     //" - Number of protons: "<<nY[iXbins-1]<<
1147     //" - Total: "<<nTotalPt[iYbins-1]<<
1148     //" - Percentage: "<<nParticleCompositionPt[iYbins-1]<<endl;
1149   }//pt loop
1150 }
1151
1152 //________________________________________//
1153 void readProcesses(TList *list) {
1154   char *fParticleProtonName[12] = {"K_{L}","#pi","K_{S}","K",
1155                                    "n","p","#Sigma^{-}","#Lambda","#Sigma^{+}",
1156                                    "#Xi^{-}","#Xi^{0}","#Omega^{-}"};
1157   char *fParticleAntiProtonName[8] = {"K_{L}","#pi","K_{S}","K",
1158                                       "n","p","#Lambda","#Sigma^{+}"};
1159   Int_t iProtonCounter = 0, iAntiProtonCounter = 0;
1160   TH1F *gMCProcesses;
1161   for(Int_t iEntry = 0; iEntry < list->GetEntries(); iEntry++) {
1162     gMCProcesses = (TH1F *)list->At(iEntry);
1163     TString histName = gMCProcesses->GetName();
1164     if(histName.Contains("gHistProtons")) {
1165       cout<<"Protons coming from "<<fParticleProtonName[iProtonCounter]<<endl;
1166
1167       iProtonCounter += 1;
1168     }
1169     if(histName.Contains("gHistAntiProtons")) {
1170       cout<<"Antiprotons coming from "<<fParticleAntiProtonName[iAntiProtonCounter]<<endl;
1171
1172       iAntiProtonCounter += 1;
1173     }
1174     for(Int_t iBin = 1; iBin < gMCProcesses->GetNbinsX(); iBin++) {
1175       Double_t binContent = gMCProcesses->GetBinContent(iBin);
1176       if(binContent > 0) {
1177         Int_t processId = gMCProcesses->GetBinCenter(iBin);
1178         cout<<"\t Process ID: "<<processId<<" - "<<
1179           gMCProcessName[processId]<<" - "<<
1180           100.*binContent/gMCProcesses->GetEntries()<<"%"<<endl;
1181       }
1182     }
1183   }
1184 }
1185
1186 //________________________________________________//
1187 void SetError(TH1D *hEff, TH1D *hGen) {
1188   for(Int_t iBin = 1; iBin <= hEff->GetNbinsX(); iBin++) {
1189     Double_t error = 0.0;
1190     if((hEff->GetBinContent(iBin) <= 1  .)&&(hGen->GetBinContent(iBin) != 0))
1191       error = TMath::Sqrt(hEff->GetBinContent(iBin)*(1  . - hEff->GetBinContent(iBin))/hGen->GetBinContent(iBin));
1192     hEff->SetBinError(iBin,error);
1193   }
1194 }
1195
1196 //________________________________________//
1197 void drawEfficiency(TList *list,
1198                     const char* analysisType) {
1199   //Function to display the reconstruction and PID efficiencies
1200   //for protons and antiprotons vs y and pT
1201
1202   TH2F *hEmpty = new TH2F("hEmptyReconstructionEfficiency","",
1203                            100,-1.2,3.5,100,-10.0,130); 
1204   hEmpty->SetStats(kFALSE); 
1205   hEmpty->GetYaxis()->SetTitle("#epsilon [%]");
1206   hEmpty->GetYaxis()->SetTitleOffset(1.3);
1207
1208   //Reconstruction efficiency
1209   TH2D *gHistPrimariesMCYPtProtons = (TH2D *)list->At(0);
1210   TH2D *gHistPrimariesMCYPtAntiProtons = (TH2D *)list->At(1);
1211   TH2D *gHistMCYPtProtonsFromWeak = (TH2D *)list->At(2);
1212   TH2D *gHistMCYPtAntiProtonsFromWeak = (TH2D *)list->At(3);
1213   TH2D *gHistMCYPtProtonsFromHadronic = (TH2D *)list->At(4);
1214   TH2D *gHistMCYPtAntiProtonsFromHadronic = (TH2D *)list->At(5);
1215   TH2D *gHistPrimariesESDYPtProtons = (TH2D *)list->At(6);
1216   TH2D *gHistPrimariesESDYPtAntiProtons = (TH2D *)list->At(7);
1217   TH2D *gHistESDYPtProtonsFromWeak = (TH2D *)list->At(8);
1218   TH2D *gHistESDYPtAntiProtonsFromWeak = (TH2D *)list->At(9);
1219   TH2D *gHistESDYPtProtonsFromHadronic = (TH2D *)list->At(10);
1220   TH2D *gHistESDYPtAntiProtonsFromHadronic = (TH2D *)list->At(11);
1221
1222   //rapidity dependence
1223   TCanvas *c14 = new TCanvas("c14",
1224                              "(Anti)Proton reconstruction efficiency vs y",
1225                              650,650,700,400);
1226   c14->SetFillColor(10); c14->GetFrame()->SetFillColor(10); 
1227   c14->SetHighLightColor(10); c14->Divide(2,1);
1228
1229   //Primary Protons
1230   TH1D *gYPrimariesESDProtons = (TH1D *)gHistPrimariesESDYPtProtons->ProjectionX("gYPrimariesESDProtons",0,gHistPrimariesESDYPtProtons->GetXaxis()->GetNbins(),"e");
1231   TH1D *gYPrimariesMCProtons = (TH1D *)gHistPrimariesMCYPtProtons->ProjectionX("gYPrimariesMCProtons",0,gHistPrimariesMCYPtProtons->GetXaxis()->GetNbins(),"e");
1232   gYPrimariesESDProtons->Divide(gYPrimariesMCProtons);
1233   SetError(gYPrimariesESDProtons,gYPrimariesMCProtons);
1234   gYPrimariesESDProtons->Scale(100.);
1235   gYPrimariesESDProtons->SetMarkerStyle(kFullCircle);
1236
1237   //Primary AntiProtons
1238   TH1D *gYPrimariesESDAntiProtons = (TH1D *)gHistPrimariesESDYPtAntiProtons->ProjectionX("gYPrimariesESDAntiProtons",0,gHistPrimariesESDYPtAntiProtons->GetXaxis()->GetNbins(),"e");
1239   TH1D *gYPrimariesMCAntiProtons = (TH1D *)gHistPrimariesMCYPtAntiProtons->ProjectionX("gYPrimariesMCAntiProtons",0,gHistPrimariesMCYPtProtons->GetXaxis()->GetNbins(),"e");
1240   gYPrimariesESDAntiProtons->Divide(gYPrimariesMCAntiProtons);
1241   SetError(gYPrimariesESDAntiProtons,gYPrimariesMCAntiProtons);
1242   gYPrimariesESDAntiProtons->Scale(100.);
1243   gYPrimariesESDAntiProtons->SetMarkerStyle(kFullCircle);
1244
1245   //Protons from weak decays
1246   TH1D *gYESDProtonsFromWeak = (TH1D *)gHistESDYPtProtonsFromWeak->ProjectionX("gYESDProtonsFromWeak",0,gHistESDYPtProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1247   TH1D *gYMCProtonsFromWeak = (TH1D *)gHistMCYPtProtonsFromWeak->ProjectionX("gYMCProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1248   gYESDProtonsFromWeak->Divide(gYMCProtonsFromWeak);
1249   SetError(gYESDProtonsFromWeak,gYMCProtonsFromWeak);
1250   gYESDProtonsFromWeak->Scale(100.);
1251   gYESDProtonsFromWeak->SetMarkerStyle(21);
1252   gYESDProtonsFromWeak->SetMarkerColor(2);
1253
1254   //AntiProtons from weak decays
1255   TH1D *gYESDAntiProtonsFromWeak = (TH1D *)gHistESDYPtAntiProtonsFromWeak->ProjectionX("gYESDAntiProtonsFromWeak",0,gHistESDYPtAntiProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1256   TH1D *gYMCAntiProtonsFromWeak = (TH1D *)gHistMCYPtAntiProtonsFromWeak->ProjectionX("gYMCAntiProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetXaxis()->GetNbins(),"e");
1257   gYESDAntiProtonsFromWeak->Divide(gYMCAntiProtonsFromWeak);
1258   SetError(gYESDAntiProtonsFromWeak,gYMCAntiProtonsFromWeak);
1259   gYESDAntiProtonsFromWeak->Scale(100.);
1260   gYESDAntiProtonsFromWeak->SetMarkerStyle(21);
1261   gYESDAntiProtonsFromWeak->SetMarkerColor(2);
1262
1263   //Protons from hadronic interactions
1264   TH1D *gYESDProtonsFromHadronic = (TH1D *)gHistESDYPtProtonsFromHadronic->ProjectionX("gYESDProtonsFromHadronic",0,gHistESDYPtProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1265   TH1D *gYMCProtonsFromHadronic = (TH1D *)gHistMCYPtProtonsFromHadronic->ProjectionX("gYMCProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1266   gYESDProtonsFromHadronic->Divide(gYMCProtonsFromHadronic);
1267   SetError(gYESDProtonsFromHadronic,gYMCProtonsFromHadronic);
1268   gYESDProtonsFromHadronic->Scale(100.);
1269   gYESDProtonsFromHadronic->SetMarkerStyle(22);
1270   gYESDProtonsFromHadronic->SetMarkerColor(3);
1271
1272   //AntiProtons from hadronic interactions
1273   TH1D *gYESDAntiProtonsFromHadronic = (TH1D *)gHistESDYPtAntiProtonsFromHadronic->ProjectionX("gYESDAntiProtonsFromHadronic",0,gHistESDYPtAntiProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1274   TH1D *gYMCAntiProtonsFromHadronic = (TH1D *)gHistMCYPtAntiProtonsFromHadronic->ProjectionX("gYMCAntiProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetXaxis()->GetNbins(),"e");
1275   gYESDAntiProtonsFromHadronic->Divide(gYMCAntiProtonsFromHadronic);
1276   SetError(gYESDAntiProtonsFromHadronic,gYMCAntiProtonsFromHadronic);
1277   gYESDAntiProtonsFromHadronic->Scale(100.);
1278   gYESDAntiProtonsFromHadronic->SetMarkerStyle(22);
1279   gYESDAntiProtonsFromHadronic->SetMarkerColor(3);
1280
1281   c14->cd(1)->SetBottomMargin(0.15); 
1282   c14->cd(1)->SetLeftMargin(0.15); 
1283   c14->cd(1)->SetGridx(); c14->cd(1)->SetGridy();
1284   hEmpty->GetXaxis()->SetRangeUser(gYPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.2,
1285                                    gYPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.2);
1286   hEmpty->GetXaxis()->SetTitle(gYPrimariesESDAntiProtons->GetXaxis()->GetTitle());
1287   hEmpty->SetTitle("Protons");
1288   hEmpty->DrawCopy();
1289   gYPrimariesESDProtons->DrawCopy("ESAME");
1290   gYESDProtonsFromWeak->DrawCopy("ESAME");
1291   gYESDProtonsFromHadronic->DrawCopy("ESAME");
1292
1293   c14->cd(2)->SetBottomMargin(0.15); 
1294   c14->cd(2)->SetLeftMargin(0.15); 
1295   c14->cd(2)->SetGridx(); c14->cd(2)->SetGridy();
1296   hEmpty->SetTitle("Antiprotons");
1297   hEmpty->DrawCopy();
1298   gYPrimariesESDAntiProtons->DrawCopy("ESAME");
1299   gYESDAntiProtonsFromWeak->DrawCopy("ESAME");
1300   gYESDAntiProtonsFromHadronic->DrawCopy("ESAME");
1301   c14->SaveAs("ReconstructionEfficiency-Protons-Rapidity.gif");
1302
1303   //pT dependence
1304   TCanvas *c15 = new TCanvas("c15",
1305                              "(Anti)Proton reconstruction efficiency vs pT",
1306                              700,700,700,400);
1307   c15->SetFillColor(10); c15->GetFrame()->SetFillColor(10); 
1308   c15->SetHighLightColor(10); c15->Divide(2,1);
1309
1310   //Primary Protons
1311   TH1D *gPtPrimariesESDProtons = (TH1D *)gHistPrimariesESDYPtProtons->ProjectionY("gPtPrimariesESDProtons",0,gHistPrimariesESDYPtProtons->GetYaxis()->GetNbins(),"e");
1312   TH1D *gPtPrimariesMCProtons = (TH1D *)gHistPrimariesMCYPtProtons->ProjectionY("gPtPrimariesMCProtons",0,gHistPrimariesMCYPtProtons->GetYaxis()->GetNbins(),"e");
1313   gPtPrimariesESDProtons->Divide(gPtPrimariesMCProtons);
1314   SetError(gPtPrimariesESDProtons,gPtPrimariesMCProtons);
1315   gPtPrimariesESDProtons->Scale(100.);
1316   gPtPrimariesESDProtons->SetMarkerStyle(kFullCircle);
1317
1318   //Primary AntiProtons
1319   TH1D *gPtPrimariesESDAntiProtons = (TH1D *)gHistPrimariesESDYPtAntiProtons->ProjectionY("gPtPrimariesESDAntiProtons",0,gHistPrimariesESDYPtAntiProtons->GetYaxis()->GetNbins(),"e");
1320   TH1D *gPtPrimariesMCAntiProtons = (TH1D *)gHistPrimariesMCYPtAntiProtons->ProjectionY("gPtPrimariesMCAntiProtons",0,gHistPrimariesMCYPtProtons->GetYaxis()->GetNbins(),"e");
1321   gPtPrimariesESDAntiProtons->Divide(gPtPrimariesMCAntiProtons);
1322   SetError(gPtPrimariesESDAntiProtons,gPtPrimariesMCAntiProtons);
1323   gPtPrimariesESDAntiProtons->Scale(100.);
1324   gPtPrimariesESDAntiProtons->SetMarkerStyle(kFullCircle);
1325
1326   //Protons from weak decays
1327   TH1D *gPtESDProtonsFromWeak = (TH1D *)gHistESDYPtProtonsFromWeak->ProjectionY("gPtESDProtonsFromWeak",0,gHistESDYPtProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1328   TH1D *gPtMCProtonsFromWeak = (TH1D *)gHistMCYPtProtonsFromWeak->ProjectionY("gPtMCProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1329   gPtESDProtonsFromWeak->Divide(gPtMCProtonsFromWeak);
1330   SetError(gPtESDProtonsFromWeak,gPtMCProtonsFromWeak);
1331   gPtESDProtonsFromWeak->Scale(100.);
1332   gPtESDProtonsFromWeak->SetMarkerStyle(21);
1333   gPtESDProtonsFromWeak->SetMarkerColor(2);
1334
1335   //AntiProtons from weak decays
1336   TH1D *gPtESDAntiProtonsFromWeak = (TH1D *)gHistESDYPtAntiProtonsFromWeak->ProjectionY("gPtESDAntiProtonsFromWeak",0,gHistESDYPtAntiProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1337   TH1D *gPtMCAntiProtonsFromWeak = (TH1D *)gHistMCYPtAntiProtonsFromWeak->ProjectionY("gPtMCAntiProtonsFromWeak",0,gHistMCYPtProtonsFromWeak->GetYaxis()->GetNbins(),"e");
1338   gPtESDAntiProtonsFromWeak->Divide(gPtMCAntiProtonsFromWeak);
1339   SetError(gPtESDAntiProtonsFromWeak,gPtMCAntiProtonsFromWeak);
1340   gPtESDAntiProtonsFromWeak->Scale(100.);
1341   gPtESDAntiProtonsFromWeak->SetMarkerStyle(21);
1342   gPtESDAntiProtonsFromWeak->SetMarkerColor(2);
1343
1344   //Protons from hadronic interactions
1345   TH1D *gPtESDProtonsFromHadronic = (TH1D *)gHistESDYPtProtonsFromHadronic->ProjectionY("gPtESDProtonsFromHadronic",0,gHistESDYPtProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1346   TH1D *gPtMCProtonsFromHadronic = (TH1D *)gHistMCYPtProtonsFromHadronic->ProjectionY("gPtMCProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1347   gPtESDProtonsFromHadronic->Divide(gPtMCProtonsFromHadronic);
1348   SetError(gPtESDProtonsFromHadronic,gPtMCProtonsFromHadronic);
1349   gPtESDProtonsFromHadronic->Scale(100.);
1350   gPtESDProtonsFromHadronic->SetMarkerStyle(22);
1351   gPtESDProtonsFromHadronic->SetMarkerColor(3);
1352
1353   //AntiProtons from hadronic interactions
1354   TH1D *gPtESDAntiProtonsFromHadronic = (TH1D *)gHistESDYPtAntiProtonsFromHadronic->ProjectionY("gPtESDAntiProtonsFromHadronic",0,gHistESDYPtAntiProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1355   TH1D *gPtMCAntiProtonsFromHadronic = (TH1D *)gHistMCYPtAntiProtonsFromHadronic->ProjectionY("gPtMCAntiProtonsFromHadronic",0,gHistMCYPtProtonsFromHadronic->GetYaxis()->GetNbins(),"e");
1356   gPtESDAntiProtonsFromHadronic->Divide(gPtMCAntiProtonsFromHadronic);
1357   SetError(gPtESDAntiProtonsFromHadronic,gPtMCAntiProtonsFromHadronic);
1358   gPtESDAntiProtonsFromHadronic->Scale(100.);
1359   gPtESDAntiProtonsFromHadronic->SetMarkerStyle(22);
1360   gPtESDAntiProtonsFromHadronic->SetMarkerColor(3);
1361
1362
1363   c15->cd(1)->SetBottomMargin(0.15); 
1364   c15->cd(1)->SetLeftMargin(0.15); 
1365   c15->cd(1)->SetGridx(); c15->cd(1)->SetGridy();
1366   hEmpty->GetXaxis()->SetRangeUser(gPtPrimariesESDAntiProtons->GetXaxis()->GetXmin()-0.2,
1367                                    gPtPrimariesESDAntiProtons->GetXaxis()->GetXmax()+0.2);
1368   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1369   hEmpty->SetTitle("Protons");
1370   hEmpty->DrawCopy();
1371   gPtPrimariesESDProtons->DrawCopy("ESAME");
1372   gPtESDProtonsFromWeak->DrawCopy("ESAME");
1373   gPtESDProtonsFromHadronic->DrawCopy("ESAME");
1374
1375   c15->cd(2)->SetBottomMargin(0.15); 
1376   c15->cd(2)->SetLeftMargin(0.15); 
1377   c15->cd(2)->SetGridx(); c15->cd(2)->SetGridy();
1378   hEmpty->SetTitle("Antiprotons");
1379   hEmpty->DrawCopy();
1380   gPtPrimariesESDAntiProtons->DrawCopy("ESAME");
1381   gPtESDAntiProtonsFromWeak->DrawCopy("ESAME");
1382   gPtESDAntiProtonsFromHadronic->DrawCopy("ESAME");
1383   c15->SaveAs("ReconstructionEfficiency-Protons-Pt.gif");
1384
1385   //______________//
1386   //PID efficiency//
1387   //______________//
1388   TH2D *gHistESDInitYPtProtons = (TH2D *)list->At(12);
1389   TH2D *gHistESDIdYPtProtons = (TH2D *)list->At(13);
1390   TH2D *gHistESDRecIdYPtProtons = (TH2D *)list->At(14);
1391   TH2D *gHistESDContamYPtProtons = (TH2D *)list->At(15);
1392
1393   TCanvas *c16 = new TCanvas("c16",
1394                              "(Anti)Proton PID efficiency vs y and pT",
1395                              750,750,700,400);
1396   c16->SetFillColor(10); c16->GetFrame()->SetFillColor(10); 
1397   c16->SetHighLightColor(10); c16->Divide(2,1);
1398
1399   //rapidity dependence
1400   //protons pid efficiency
1401   TH1D *gYESDIdProtons = (TH1D *)gHistESDIdYPtProtons->ProjectionX("gYESDIdProtons",0,gHistESDIdYPtProtons->GetXaxis()->GetNbins(),"e");
1402   TH1D *gYESDInitProtons = (TH1D *)gHistESDInitYPtProtons->ProjectionX("gYESDInitProtons",0,gHistESDInitYPtProtons->GetXaxis()->GetNbins(),"e");
1403   gYESDIdProtons->Divide(gYESDInitProtons);
1404   SetError(gYESDIdProtons,gYESDInitProtons);
1405   gYESDIdProtons->Scale(100.);
1406   gYESDIdProtons->SetMarkerStyle(kFullCircle);
1407
1408   //protons pid contamination
1409   TH1D *gYESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionX("gYESDContamProtons",0,gHistESDContamYPtProtons->GetXaxis()->GetNbins(),"e");
1410   TH1D *gYESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionX("gYESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetXaxis()->GetNbins(),"e");
1411   gYESDContamProtons->Divide(gYESDRecIdProtons);
1412   SetError(gYESDContamProtons,gYESDRecIdProtons);
1413   gYESDContamProtons->Scale(100.);
1414   gYESDContamProtons->SetMarkerStyle(kOpenCircle);
1415
1416   c16->cd(1)->SetBottomMargin(0.15); 
1417   c16->cd(1)->SetLeftMargin(0.15); 
1418   c16->cd(1)->SetGridx(); c16->cd(1)->SetGridy();
1419   hEmpty->GetXaxis()->SetRangeUser(-1.0.,1.0);
1420   hEmpty->GetXaxis()->SetTitle(gYESDContamProtons->GetXaxis()->GetTitle());
1421   hEmpty->DrawCopy();
1422   gYESDIdProtons->DrawCopy("ESAME");
1423   gYESDContamProtons->DrawCopy("ESAME");
1424
1425   //pT dependence
1426   //protons pid efficiency
1427   TH1D *gPtESDIdProtons = (TH1D *)gHistESDIdYPtProtons->ProjectionY("gPtESDIdProtons",0,gHistESDIdYPtProtons->GetYaxis()->GetNbins(),"e");
1428   TH1D *gPtESDInitProtons = (TH1D *)gHistESDInitYPtProtons->ProjectionY("gPtESDInitProtons",0,gHistESDInitYPtProtons->GetYaxis()->GetNbins(),"e");
1429   gPtESDIdProtons->Divide(gPtESDInitProtons);
1430   SetError(gPtESDIdProtons,gPtESDInitProtons);
1431   gPtESDIdProtons->Scale(100.);
1432   gPtESDIdProtons->SetMarkerStyle(kFullCircle);
1433
1434   //protons pid contamination
1435   TH1D *gPtESDContamProtons = (TH1D *)gHistESDContamYPtProtons->ProjectionY("gPtESDContamProtons",0,gHistESDContamYPtProtons->GetYaxis()->GetNbins(),"e");
1436   TH1D *gPtESDRecIdProtons = (TH1D *)gHistESDRecIdYPtProtons->ProjectionY("gPtESDRecIdProtons",0,gHistESDRecIdYPtProtons->GetYaxis()->GetNbins(),"e");
1437   gPtESDContamProtons->Divide(gPtESDRecIdProtons);
1438   SetError(gPtESDContamProtons,gPtESDRecIdProtons);
1439   gPtESDContamProtons->Scale(100.);
1440   gPtESDContamProtons->SetMarkerStyle(kOpenCircle);
1441
1442   c16->cd(2)->SetBottomMargin(0.15); 
1443   c16->cd(2)->SetLeftMargin(0.15); 
1444   c16->cd(2)->SetGridx(); c16->cd(2)->SetGridy();
1445   hEmpty->GetXaxis()->SetRangeUser(0.0,1.2);
1446   hEmpty->GetXaxis()->SetTitle("P_{T} [GeV/c]");
1447   hEmpty->DrawCopy();
1448   gPtESDIdProtons->DrawCopy("ESAME");
1449   gPtESDContamProtons->DrawCopy("ESAME");
1450
1451   c16->SaveAs("PIDEfficiency-Protons.gif");
1452
1453   TString outputFileName = "Reconstruction-PID-Efficiency.";
1454   outputFileName += analysisType; outputFileName += ".root";
1455   TFile *fout = TFile::Open(outputFileName.Data(),"recreate");
1456   gYPrimariesESDProtons->Write();
1457   gYESDProtonsFromWeak->Write();
1458   gYESDProtonsFromHadronic->Write();
1459   gPtPrimariesESDProtons->Write();
1460   gPtESDProtonsFromWeak->Write();
1461   gPtESDProtonsFromHadronic->Write();
1462   gYPrimariesESDAntiProtons->Write();
1463   gYESDAntiProtonsFromWeak->Write();
1464   gYESDAntiProtonsFromHadronic->Write();
1465   gPtPrimariesESDAntiProtons->Write();
1466   gPtESDAntiProtonsFromWeak->Write();
1467   gPtESDAntiProtonsFromHadronic->Write();
1468   gYESDIdProtons->Write();
1469   gYESDContamProtons->Write();
1470   gPtESDIdProtons->Write();
1471   gPtESDContamProtons->Write();
1472   fout->Close();
1473 }
1474
1475 //________________________________________________//
1476 void DrawMarker(Double_t x, Double_t y, Int_t style, 
1477                 Double_t size, Int_t color) {
1478   TMarker *m = new TMarker(x,y,style);
1479   m->SetMarkerSize(size);
1480   m->SetMarkerColor(color);
1481   m->Draw();
1482 }
1483
1484 //________________________________________________//
1485 const char * const gMCProcessName[45] = {
1486   "Primary particle emission",
1487   "Multiple scattering",
1488   "Energy loss",
1489   "Bending in magnetic field",
1490   "Decay",
1491   "Lepton pair production",
1492   "Compton scattering",
1493   "Photoelectric effect",
1494   "Bremstrahlung",
1495   "Delta ray",
1496   "Positron annihilation",
1497   "Positron annihilation at rest",
1498   "Positron annihilation in flight",
1499   "Hadronic interaction",
1500   "Nuclear evaporation",
1501   "Nuclear fission",
1502   "Nuclear absorbtion",
1503   "Antiproton annihilation",
1504   "Antineutron annihilation",
1505   "Neutron capture",
1506   "Hadronic elastic",
1507   "Hadronic incoherent elastic",
1508   "Hadronic coherent elastic",
1509   "Hadronic inelastic",
1510   "Photon inelastic",
1511   "Muon nuclear interaction",
1512   "Electron nuclear interaction",
1513   "Positron nuclear interaction",
1514   "Time of flight limit",
1515   "Nuclear photofission",
1516   "Rayleigh effect",
1517   "No active process",
1518   "Energy threshold",
1519   "Light absorption",
1520   "Light detection",
1521   "Light scattering",
1522   "Maximum allowed step",
1523   "Cerenkov production",
1524   "Cerenkov feed back photon",
1525   "Cerenkov photon reflection",
1526   "Cerenkov photon refraction",
1527   "Synchrotron radiation",
1528   "Scintillation",
1529   "Transportation",
1530   "Unknown process"
1531 };