]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/AliProtonAnalysis.cxx
46d2b23476b0a48b66e04901149fb62eef4c6f7b
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliProtonAnalysis.cxx
1 /**************************************************************************
2  * Author: Panos Christakoglou.                                           *
3  * Contributors are mentioned in the code where appropriate.              *
4  *                                                                        *
5  * Permission to use, copy, modify and distribute this software and its   *
6  * documentation strictly for non-commercial purposes is hereby granted   *
7  * without fee, provided that the above copyright notice appears in all   *
8  * copies and that both the copyright notice and this permission notice   *
9  * appear in the supporting documentation. The authors make no claims     *
10  * about the suitability of this software for any purpose. It is          *
11  * provided "as is" without express or implied warranty.                  *
12  **************************************************************************/
13
14 /* $Id$ */
15
16 //-----------------------------------------------------------------
17 //                 AliProtonAnalysis class
18 //   This is the class to deal with the proton analysis
19 //   Origin: Panos Christakoglou | Panos.Christakoglou@cern.ch
20 //-----------------------------------------------------------------
21 #include <Riostream.h>
22 #include <TFile.h>
23 #include <TSystem.h>
24 #include <TF1.h>
25 #include <TH3F.h>
26 #include <TH2D.h>
27 #include <TH1D.h>
28 #include <TH1I.h>
29 #include <TParticle.h>
30 #include <TList.h>
31
32 #include <AliExternalTrackParam.h>
33 #include <AliAODEvent.h>
34 #include <AliESDEvent.h>
35 //#include <AliLog.h>
36 #include <AliPID.h>
37 #include <AliStack.h>
38 #include <AliCFContainer.h>
39 #include <AliCFEffGrid.h>
40 #include <AliCFDataGrid.h>
41 #include <AliTPCPIDResponse.h>
42 #include <AliESDpid.h>
43 class AliLog;
44 class AliESDVertex;
45
46 #include "AliProtonAnalysis.h"
47 #include "AliProtonAnalysisBase.h"
48
49 ClassImp(AliProtonAnalysis)
50
51 //____________________________________________________________________//
52 AliProtonAnalysis::AliProtonAnalysis() : 
53   TObject(), fProtonAnalysisBase(0),
54   fNBinsY(0), fMinY(0), fMaxY(0),
55   fNBinsPt(0), fMinPt(0), fMaxPt(0),
56   fProtonContainer(0), fAntiProtonContainer(0),
57   fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0),
58   fHistYPtProtonsCorrected(0), fHistYPtAntiProtonsCorrected(0), 
59   fHistEventStats(0), fYRatioInPtBinsList(0),
60   fEffGridListProtons(0), fCorrectionListProtons2D(0), 
61   fEfficiencyListProtons1D(0), fCorrectionListProtons1D(0),
62   fEffGridListAntiProtons(0), fCorrectionListAntiProtons2D(0), 
63   fEfficiencyListAntiProtons1D(0), fCorrectionListAntiProtons1D(0),
64   fCorrectProtons(0), fCorrectAntiProtons(0),
65   fHistEfficiencyYPtProtons(0), fHistEfficiencyYPtAntiProtons(0),
66   fHistCorrectionForCrossSectionYPtProtons(0),
67   fHistCorrectionForCrossSectionYPtAntiProtons(0),
68   fHistCorrectionForCrossSectionFlag(kFALSE),
69   fHistYPtCorrectionForSecondaries(0), fCorrectForSecondariesFlag(kFALSE),
70   fGlobalQAList(0), fQA2DList(0),
71   fQAProtonsAcceptedList(0), fQAProtonsRejectedList(0),
72   fQAAntiProtonsAcceptedList(0), fQAAntiProtonsRejectedList(0),
73   fInitQAFlag(kFALSE) {
74   //Default constructor
75 }
76
77 //____________________________________________________________________//
78 AliProtonAnalysis::AliProtonAnalysis(Int_t nbinsY, 
79                                      Float_t fLowY, Float_t fHighY,
80                                      Int_t nbinsPt, 
81                                      Float_t fLowPt, Float_t fHighPt) : 
82   TObject(), fProtonAnalysisBase(0),
83   fNBinsY(nbinsY), fMinY(fLowY), fMaxY(fHighY),
84   fNBinsPt(nbinsPt), fMinPt(fLowPt), fMaxPt(fHighPt),
85   fProtonContainer(0), fAntiProtonContainer(0),
86   fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0), 
87   fHistYPtProtonsCorrected(0), fHistYPtAntiProtonsCorrected(0), 
88   fHistEventStats(0), fYRatioInPtBinsList(0),
89   fEffGridListProtons(0), fCorrectionListProtons2D(0), 
90   fEfficiencyListProtons1D(0), fCorrectionListProtons1D(0),
91   fEffGridListAntiProtons(0), fCorrectionListAntiProtons2D(0), 
92   fEfficiencyListAntiProtons1D(0), fCorrectionListAntiProtons1D(0),
93   fCorrectProtons(0), fCorrectAntiProtons(0),
94   fHistEfficiencyYPtProtons(0), fHistEfficiencyYPtAntiProtons(0),
95   fHistCorrectionForCrossSectionYPtProtons(0),
96   fHistCorrectionForCrossSectionYPtAntiProtons(0),
97   fHistCorrectionForCrossSectionFlag(kFALSE),
98   fHistYPtCorrectionForSecondaries(0), fCorrectForSecondariesFlag(kFALSE),
99   fGlobalQAList(0), fQA2DList(0),
100   fQAProtonsAcceptedList(0), fQAProtonsRejectedList(0),
101   fQAAntiProtonsAcceptedList(0), fQAAntiProtonsRejectedList(0),
102   fInitQAFlag(kFALSE) {
103   //Default constructor
104   fHistEvents = new TH1I("fHistEvents","Analyzed events",2,0.5,2.5);
105   fHistEvents->GetXaxis()->SetBinLabel(1,"Analyzed events");
106   fHistEvents->GetXaxis()->SetBinLabel(2,"Events with (anti)protons");
107
108   fHistYPtProtons = new TH2D("fHistYPtProtons","Protons",
109                              fNBinsY,fMinY,fMaxY,
110                              fNBinsPt,fMinPt,fMaxPt);
111   fHistYPtProtons->SetStats(kTRUE);
112   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
113   if(fProtonAnalysisBase->GetEtaMode())
114     fHistYPtProtons->GetXaxis()->SetTitle("#eta");
115   else
116     fHistYPtProtons->GetXaxis()->SetTitle("y");
117   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
118
119   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","Antiprotons",
120                                  fNBinsY,fMinY,fMaxY,
121                                  fNBinsPt,fMinPt,fMaxPt);
122   fHistYPtAntiProtons->SetStats(kTRUE);
123   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
124   if(fProtonAnalysisBase->GetEtaMode())
125     fHistYPtAntiProtons->GetXaxis()->SetTitle("#eta");
126   else
127     fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
128   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
129
130   fHistYPtProtonsCorrected = new TH2D("fHistYPtProtonsCorrected","Protons",
131                                       fNBinsY,fMinY,fMaxY,
132                                       fNBinsPt,fMinPt,fMaxPt);
133   fHistYPtProtonsCorrected->SetStats(kTRUE);
134   fHistYPtProtonsCorrected->GetYaxis()->SetTitle("P_{T} [GeV/c]");
135   if(fProtonAnalysisBase->GetEtaMode())
136     fHistYPtProtonsCorrected->GetXaxis()->SetTitle("#eta");
137   else
138     fHistYPtProtonsCorrected->GetXaxis()->SetTitle("y");
139   fHistYPtProtonsCorrected->GetXaxis()->SetTitleColor(1);
140
141   fHistYPtAntiProtonsCorrected = new TH2D("fHistYPtAntiProtonsCorrected",
142                                           "Antiprotons",
143                                           fNBinsY,fMinY,fMaxY,
144                                           fNBinsPt,fMinPt,fMaxPt);
145   fHistYPtAntiProtonsCorrected->SetStats(kTRUE);
146   fHistYPtAntiProtonsCorrected->GetYaxis()->SetTitle("P_{T} [GeV/c]");
147   if(fProtonAnalysisBase->GetEtaMode())
148     fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitle("#eta");
149   else
150     fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitle("y");
151   fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitleColor(1);
152
153   //setting up the containers
154   Int_t iBin[2];
155   iBin[0] = nbinsY;
156   iBin[1] = nbinsPt;
157   Double_t *binLimY = new Double_t[nbinsY+1];
158   Double_t *binLimPt = new Double_t[nbinsPt+1];
159   //values for bin lower bounds
160   for(Int_t i = 0; i <= nbinsY; i++) 
161     binLimY[i]=(Double_t)fLowY  + (fHighY - fLowY)  /nbinsY*(Double_t)i;
162   for(Int_t i = 0; i <= nbinsPt; i++) 
163     binLimPt[i]=(Double_t)fLowPt  + (fHighPt - fLowPt)  /nbinsPt*(Double_t)i;
164
165   fProtonContainer = new AliCFContainer("containerProtons",
166                                         "container for protons",
167                                         kNSteps,2,iBin);
168   fProtonContainer->SetBinLimits(0,binLimY); //rapidity or eta
169   fProtonContainer->SetBinLimits(1,binLimPt); //pT
170   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
171                                             "container for antiprotons",
172                                             kNSteps,2,iBin);
173   fAntiProtonContainer->SetBinLimits(0,binLimY); //rapidity or eta
174   fAntiProtonContainer->SetBinLimits(1,binLimPt); //pT
175
176   //Initialize the QA
177   if(!fInitQAFlag) InitQA();
178
179
180 //____________________________________________________________________//
181 AliProtonAnalysis::AliProtonAnalysis(Int_t nbinsY, Double_t *gY,
182                                      Int_t nbinsPt,Double_t *gPt) : 
183   TObject(), fProtonAnalysisBase(0),
184   fNBinsY(nbinsY), fMinY(gY[0]), fMaxY(gY[nbinsY]),
185   fNBinsPt(nbinsPt), fMinPt(gPt[0]), fMaxPt(gPt[nbinsPt]),
186   fProtonContainer(0), fAntiProtonContainer(0),
187   fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0), 
188   fHistYPtProtonsCorrected(0), fHistYPtAntiProtonsCorrected(0), 
189   fHistEventStats(0), fYRatioInPtBinsList(0),
190   fEffGridListProtons(0), fCorrectionListProtons2D(0), 
191   fEfficiencyListProtons1D(0), fCorrectionListProtons1D(0),
192   fEffGridListAntiProtons(0), fCorrectionListAntiProtons2D(0), 
193   fEfficiencyListAntiProtons1D(0), fCorrectionListAntiProtons1D(0),
194   fCorrectProtons(0), fCorrectAntiProtons(0),
195   fHistEfficiencyYPtProtons(0), fHistEfficiencyYPtAntiProtons(0),
196   fHistCorrectionForCrossSectionYPtProtons(0),
197   fHistCorrectionForCrossSectionYPtAntiProtons(0),
198   fHistCorrectionForCrossSectionFlag(kFALSE),
199   fHistYPtCorrectionForSecondaries(0), fCorrectForSecondariesFlag(kFALSE),
200   fGlobalQAList(0), fQA2DList(0),
201   fQAProtonsAcceptedList(0), fQAProtonsRejectedList(0),
202   fQAAntiProtonsAcceptedList(0), fQAAntiProtonsRejectedList(0),
203   fInitQAFlag(kFALSE) {
204   //Default constructor
205   fHistEvents = new TH1I("fHistEvents","Analyzed events",2,0.5,2.5);
206   fHistEvents->GetXaxis()->SetBinLabel(1,"Analyzed events");
207   fHistEvents->GetXaxis()->SetBinLabel(2,"Events with (anti)protons");
208
209   fHistYPtProtons = new TH2D("fHistYPtProtons","Protons",
210                              fNBinsY,gY,fNBinsPt,gPt);
211   fHistYPtProtons->SetStats(kTRUE);
212   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
213   if(fProtonAnalysisBase->GetEtaMode())
214     fHistYPtProtons->GetXaxis()->SetTitle("#eta");
215   else
216     fHistYPtProtons->GetXaxis()->SetTitle("y");
217   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
218
219   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","Antiprotons",
220                                  fNBinsY,gY,fNBinsPt,gPt);
221   fHistYPtAntiProtons->SetStats(kTRUE);
222   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
223   if(fProtonAnalysisBase->GetEtaMode())
224     fHistYPtAntiProtons->GetXaxis()->SetTitle("#eta");
225   else
226     fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
227   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
228
229   fHistYPtProtonsCorrected = new TH2D("fHistYPtProtonsCorrected","Protons",
230                                       fNBinsY,fMinY,fMaxY,
231                                       fNBinsPt,fMinPt,fMaxPt);
232   fHistYPtProtonsCorrected->SetStats(kTRUE);
233   fHistYPtProtonsCorrected->GetYaxis()->SetTitle("P_{T} [GeV/c]");
234   if(fProtonAnalysisBase->GetEtaMode())
235     fHistYPtProtonsCorrected->GetXaxis()->SetTitle("#eta");
236   else
237     fHistYPtProtonsCorrected->GetXaxis()->SetTitle("y");
238   fHistYPtProtonsCorrected->GetXaxis()->SetTitleColor(1);
239
240   fHistYPtAntiProtonsCorrected = new TH2D("fHistYPtAntiProtonsCorrected",
241                                           "Antiprotons",
242                                           fNBinsY,fMinY,fMaxY,
243                                           fNBinsPt,fMinPt,fMaxPt);
244   fHistYPtAntiProtonsCorrected->SetStats(kTRUE);
245   fHistYPtAntiProtonsCorrected->GetYaxis()->SetTitle("P_{T} [GeV/c]");
246   if(fProtonAnalysisBase->GetEtaMode())
247     fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitle("#eta");
248   else
249     fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitle("y");
250   fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitleColor(1);
251
252   //setting up the containers
253   Int_t iBin[2];
254   iBin[0] = nbinsY;
255   iBin[1] = nbinsPt;
256   fProtonContainer = new AliCFContainer("containerProtons",
257                                         "container for protons",
258                                         kNSteps,2,iBin);
259   fProtonContainer->SetBinLimits(0,gY); //rapidity or eta
260   fProtonContainer->SetBinLimits(1,gPt); //pT
261   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
262                                             "container for antiprotons",
263                                             kNSteps,2,iBin);
264   fAntiProtonContainer->SetBinLimits(0,gY); //rapidity or eta
265   fAntiProtonContainer->SetBinLimits(1,gPt); //pT
266
267   //Initialize the QA
268   if(!fInitQAFlag) InitQA();
269
270
271 //____________________________________________________________________//
272 AliProtonAnalysis::~AliProtonAnalysis() {
273   //Default destructor
274   if(fProtonAnalysisBase) delete fProtonAnalysisBase;
275
276   if(fHistEvents) delete fHistEvents;
277   if(fHistYPtProtons) delete fHistYPtProtons;
278   if(fHistYPtAntiProtons) delete fHistYPtAntiProtons;
279   if(fHistYPtProtonsCorrected) delete fHistYPtProtonsCorrected;
280   if(fHistYPtAntiProtonsCorrected) delete fHistYPtAntiProtonsCorrected;
281   if(fHistEventStats) delete fHistEventStats;
282   if(fYRatioInPtBinsList) delete fYRatioInPtBinsList;
283
284   if(fProtonContainer) delete fProtonContainer;
285   if(fAntiProtonContainer) delete fAntiProtonContainer;
286
287   if(fEffGridListProtons) delete fEffGridListProtons;
288   if(fCorrectionListProtons2D) delete fCorrectionListProtons2D;
289   if(fEfficiencyListProtons1D) delete fEfficiencyListProtons1D;
290   if(fCorrectionListProtons1D) delete fCorrectionListProtons1D;
291   if(fEffGridListAntiProtons) delete fEffGridListAntiProtons;
292   if(fCorrectionListAntiProtons2D) delete fCorrectionListAntiProtons2D;
293   if(fEfficiencyListAntiProtons1D) delete fEfficiencyListAntiProtons1D;
294   if(fCorrectionListAntiProtons1D) delete fCorrectionListAntiProtons1D;
295   if(fCorrectProtons) delete fCorrectProtons;
296   if(fCorrectAntiProtons) delete fCorrectAntiProtons;
297   if(fHistEfficiencyYPtProtons) delete fHistEfficiencyYPtProtons;
298   if(fHistEfficiencyYPtAntiProtons) delete fHistEfficiencyYPtAntiProtons;
299   if(fHistCorrectionForCrossSectionYPtProtons) delete fHistCorrectionForCrossSectionYPtProtons;
300   if(fHistCorrectionForCrossSectionYPtAntiProtons) delete fHistCorrectionForCrossSectionYPtAntiProtons;
301   if(fHistYPtCorrectionForSecondaries) delete fHistYPtCorrectionForSecondaries;
302
303   //QA lists
304   if(fGlobalQAList) delete fGlobalQAList;
305   if(fQA2DList) delete fQA2DList;
306   if(fQAProtonsAcceptedList) delete fQAProtonsAcceptedList; 
307   if(fQAProtonsRejectedList) delete fQAProtonsRejectedList;
308   if(fQAAntiProtonsAcceptedList) delete fQAAntiProtonsAcceptedList; 
309   if(fQAAntiProtonsRejectedList) delete fQAAntiProtonsRejectedList;
310 }
311
312 //____________________________________________________________________//
313 void AliProtonAnalysis::InitAnalysisHistograms(Int_t nbinsY, 
314                                                Float_t fLowY, Float_t fHighY, 
315                                                Int_t nbinsPt, 
316                                                Float_t fLowPt, Float_t fHighPt) {
317   //Initializes the histograms
318   fNBinsY = nbinsY;
319   fMinY = fLowY;
320   fMaxY = fHighY;
321   fNBinsPt = nbinsPt;
322   fMinPt = fLowPt;
323   fMaxPt = fHighPt;
324
325   fHistEvents = new TH1I("fHistEvents","Analyzed events",2,0.5,2.5);
326   fHistEvents->GetXaxis()->SetBinLabel(1,"Analyzed events");
327   fHistEvents->GetXaxis()->SetBinLabel(2,"Events with (anti)protons");
328
329   fHistYPtProtons = new TH2D("fHistYPtProtons","Protons",
330                              fNBinsY,fMinY,fMaxY,
331                              fNBinsPt,fMinPt,fMaxPt);
332   fHistYPtProtons->SetStats(kTRUE);
333   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
334   if(fProtonAnalysisBase->GetEtaMode())
335     fHistYPtProtons->GetXaxis()->SetTitle("#eta");
336   else
337     fHistYPtProtons->GetXaxis()->SetTitle("y");
338   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
339
340   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","Antiprotons",
341                                  fNBinsY,fMinY,fMaxY,
342                                  fNBinsPt,fMinPt,fMaxPt);
343   fHistYPtAntiProtons->SetStats(kTRUE);
344   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
345   if(fProtonAnalysisBase->GetEtaMode())
346     fHistYPtAntiProtons->GetXaxis()->SetTitle("#eta");
347   else
348     fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
349   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
350
351   fHistYPtProtonsCorrected = new TH2D("fHistYPtProtonsCorrected","Protons",
352                                       fNBinsY,fMinY,fMaxY,
353                                       fNBinsPt,fMinPt,fMaxPt);
354   fHistYPtProtonsCorrected->SetStats(kTRUE);
355   fHistYPtProtonsCorrected->GetYaxis()->SetTitle("P_{T} [GeV/c]");
356   if(fProtonAnalysisBase->GetEtaMode())
357     fHistYPtProtonsCorrected->GetXaxis()->SetTitle("#eta");
358   else
359     fHistYPtProtonsCorrected->GetXaxis()->SetTitle("y");
360   fHistYPtProtonsCorrected->GetXaxis()->SetTitleColor(1);
361
362   fHistYPtAntiProtonsCorrected = new TH2D("fHistYPtAntiProtonsCorrected",
363                                           "Antiprotons",
364                                           fNBinsY,fMinY,fMaxY,
365                                           fNBinsPt,fMinPt,fMaxPt);
366   fHistYPtAntiProtonsCorrected->SetStats(kTRUE);
367   fHistYPtAntiProtonsCorrected->GetYaxis()->SetTitle("P_{T} [GeV/c]");
368   if(fProtonAnalysisBase->GetEtaMode())
369     fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitle("#eta");
370   else
371     fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitle("y");
372   fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitleColor(1);
373
374   //setting up the containers
375   Int_t iBin[2];
376   iBin[0] = nbinsY;
377   iBin[1] = nbinsPt;
378   Double_t *binLimY = new Double_t[nbinsY+1];
379   Double_t *binLimPt = new Double_t[nbinsPt+1];
380   //values for bin lower bounds
381   for(Int_t i = 0; i <= nbinsY; i++) 
382     binLimY[i]=(Double_t)fLowY  + (fHighY - fLowY)  /nbinsY*(Double_t)i;
383   for(Int_t i = 0; i <= nbinsPt; i++) 
384     binLimPt[i]=(Double_t)fLowPt  + (fHighPt - fLowPt)  /nbinsPt*(Double_t)i;
385
386   fProtonContainer = new AliCFContainer("containerProtons",
387                                         "container for protons",
388                                         kNSteps,2,iBin);
389   fProtonContainer->SetBinLimits(0,binLimY); //rapidity
390   fProtonContainer->SetBinLimits(1,binLimPt); //pT
391   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
392                                             "container for antiprotons",
393                                             kNSteps,2,iBin);
394   fAntiProtonContainer->SetBinLimits(0,binLimY); //rapidity
395   fAntiProtonContainer->SetBinLimits(1,binLimPt); //pT
396
397   //Initialize the QA
398   if(!fInitQAFlag) InitQA();
399 }
400
401 //____________________________________________________________________//
402 void AliProtonAnalysis::InitAnalysisHistograms(Int_t nbinsY, Double_t *gY, 
403                                                Int_t nbinsPt, Double_t *gPt) {
404   //Initializes the histograms using asymmetric values - global tracking
405   fNBinsY = nbinsY;
406   fMinY = gY[0];
407   fMaxY = gY[nbinsY];
408   fNBinsPt = nbinsPt;
409   fMinPt = gPt[0];
410   fMaxPt = gPt[nbinsPt];
411
412   fHistEvents = new TH1I("fHistEvents","Analyzed events",2,0.5,2.5);
413   fHistEvents->GetXaxis()->SetBinLabel(1,"Analyzed events");
414   fHistEvents->GetXaxis()->SetBinLabel(2,"Events with (anti)protons");
415
416   fHistYPtProtons = new TH2D("fHistYPtProtons","Protons",
417                              fNBinsY,gY,fNBinsPt,gPt);
418   fHistYPtProtons->SetStats(kTRUE);
419   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
420   if(fProtonAnalysisBase->GetEtaMode())
421     fHistYPtProtons->GetXaxis()->SetTitle("#eta");
422   else
423     fHistYPtProtons->GetXaxis()->SetTitle("y");
424   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
425
426   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","Antiprotons",
427                                  fNBinsY,gY,fNBinsPt,gPt);
428   fHistYPtAntiProtons->SetStats(kTRUE);
429   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
430   if(fProtonAnalysisBase->GetEtaMode())
431     fHistYPtAntiProtons->GetXaxis()->SetTitle("#eta");
432   else
433     fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
434   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
435
436   fHistYPtProtonsCorrected = new TH2D("fHistYPtProtonsCorrected","Protons",
437                                       fNBinsY,gY,fNBinsPt,gPt);
438   fHistYPtProtonsCorrected->SetStats(kTRUE);
439   fHistYPtProtonsCorrected->GetYaxis()->SetTitle("P_{T} [GeV/c]");
440   if(fProtonAnalysisBase->GetEtaMode())
441     fHistYPtProtonsCorrected->GetXaxis()->SetTitle("#eta");
442   else
443     fHistYPtProtonsCorrected->GetXaxis()->SetTitle("y");
444   fHistYPtProtonsCorrected->GetXaxis()->SetTitleColor(1);
445
446   fHistYPtAntiProtonsCorrected = new TH2D("fHistYPtAntiProtonsCorrected",
447                                           "Antiprotons",
448                                           fNBinsY,gY,fNBinsPt,gPt);
449   fHistYPtAntiProtonsCorrected->SetStats(kTRUE);
450   fHistYPtAntiProtonsCorrected->GetYaxis()->SetTitle("P_{T} [GeV/c]");
451   if(fProtonAnalysisBase->GetEtaMode())
452     fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitle("#eta");
453   else
454     fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitle("y");
455   fHistYPtAntiProtonsCorrected->GetXaxis()->SetTitleColor(1);
456
457   //setting up the containers
458   Int_t iBin[2];
459   iBin[0] = nbinsY;
460   iBin[1] = nbinsPt;
461
462   fProtonContainer = new AliCFContainer("containerProtons",
463                                         "container for protons",
464                                         kNSteps,2,iBin);
465   fProtonContainer->SetBinLimits(0,gY); //rapidity
466   fProtonContainer->SetBinLimits(1,gPt); //pT
467   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
468                                             "container for antiprotons",
469                                             kNSteps,2,iBin);
470   fAntiProtonContainer->SetBinLimits(0,gY); //rapidity
471   fAntiProtonContainer->SetBinLimits(1,gPt); //pT
472
473   //Initialize the QA
474   if(!fInitQAFlag) InitQA();
475 }
476
477 //____________________________________________________________________//
478 Bool_t AliProtonAnalysis::ReadFromFile(const char* filename) {
479   //Read the containers from the existing file
480   Bool_t status = kTRUE;
481
482   TFile *file = TFile::Open(filename);
483   if(!file) {
484     cout<<"Could not find the input file "<<filename<<endl;
485     status = kFALSE;
486   }
487
488   TList *list = (TList *)file->Get("outputList");
489   if(list) {
490     cout<<"Retrieving objects from the list "<<list->GetName()<<"..."<<endl; 
491     fHistYPtProtons = (TH2D *)list->At(0);
492     fHistYPtAntiProtons = (TH2D *)list->At(1);
493     fHistEvents = (TH1I *)list->At(2);
494     fProtonContainer = (AliCFContainer *)list->At(3);
495     fAntiProtonContainer = (AliCFContainer *)list->At(4);
496     fHistEventStats = (TH1F *)list->At(5);
497   }
498   else if(!list) {
499     cout<<"Retrieving objects from the file... "<<endl;
500     fHistYPtProtons = (TH2D *)file->Get("fHistYPtProtons");
501     fHistYPtAntiProtons = (TH2D *)file->Get("fHistYPtAntiProtons");
502     fHistEvents = (TH1I *)file->Get("fHistEvents");
503     fProtonContainer = (AliCFContainer *)file->Get("containerProtons");
504     fAntiProtonContainer = (AliCFContainer *)file->Get("containerAntiProtons");
505     fHistEventStats = (TH1F *)file->Get("fHistEventStats");
506   }
507   if((!fHistYPtProtons)||(!fHistYPtAntiProtons)||(!fHistEvents)
508      ||(!fProtonContainer)||(!fAntiProtonContainer)||(!fHistEventStats)) {
509     cout<<"Input containers were not found!!!"<<endl;
510     status = kFALSE;
511   }
512   else {
513     //fHistYPtProtons = fProtonContainer->ShowProjection(0,1,0);
514     //fHistYPtAntiProtons = fAntiProtonContainer->ShowProjection(0,1,0);
515     fHistYPtProtons->Sumw2();
516     fHistYPtAntiProtons->Sumw2();
517   }
518
519   return status;
520 }
521
522 //____________________________________________________________________//
523 TList *AliProtonAnalysis::GetYRatioHistogramsInPtBins() {
524   //Returns a TList obkect with the eta (or y) dependent ratios for each 
525   //pT bin taken from the 2D histograms (not from the containers)
526   fYRatioInPtBinsList = new TList();
527   
528   //Protons
529   TH1D *gHistYProtons[100];
530   TString title;
531   for(Int_t iBin = 1; iBin <= fHistYPtProtons->GetNbinsY(); iBin++) {
532     title = "gHistYProtons_PtBin"; title += iBin;
533     gHistYProtons[iBin] = (TH1D *)fHistYPtProtons->ProjectionX(title.Data(),
534                                                                iBin,
535                                                                iBin,"b");
536     gHistYProtons[iBin]->Sumw2();
537   }
538
539   //Antiprotons
540   TH1D *gHistYAntiProtons[100];
541   for(Int_t iBin = 1; iBin <= fHistYPtAntiProtons->GetNbinsY(); iBin++) {
542     title = "gHistYAntiProtons_PtBin"; title += iBin;
543     gHistYAntiProtons[iBin] = (TH1D *)fHistYPtAntiProtons->ProjectionX(title.Data(),
544                                                                        iBin,
545                                                                        iBin,"b");
546     gHistYAntiProtons[iBin]->Sumw2();
547   }
548
549   Double_t pTmin = fHistYPtProtons->GetYaxis()->GetXmin();
550   Double_t pTStep = (fHistYPtProtons->GetYaxis()->GetXmax() - fHistYPtProtons->GetYaxis()->GetXmin())/fHistYPtProtons->GetNbinsY();
551   Double_t pTmax = pTmin + pTStep;
552   //Ratio
553   TH1D *gHistYRatio[100];
554   for(Int_t iBin = 1; iBin <= fHistYPtProtons->GetNbinsY(); iBin++) {
555     title = "gHistYRatio_PtBin"; title += iBin;
556     gHistYRatio[iBin] = new TH1D(title.Data(),"",
557                                  fHistYPtProtons->GetNbinsX(),
558                                  fHistYPtProtons->GetXaxis()->GetXmin(),
559                                  fHistYPtProtons->GetXaxis()->GetXmax());
560     title = "Pt: "; title += pTmin; title += " - "; title += pTmax;
561     gHistYRatio[iBin]->SetTitle(title.Data());
562     gHistYRatio[iBin]->GetYaxis()->SetTitle("#bar{p}/p");
563     gHistYRatio[iBin]->GetXaxis()->SetTitle(fHistYPtProtons->GetXaxis()->GetTitle());
564     gHistYRatio[iBin]->Divide(gHistYAntiProtons[iBin],
565                               gHistYProtons[iBin],1.0,1.0,"b");
566     fYRatioInPtBinsList->Add(gHistYRatio[iBin]);
567     pTmin += pTStep;
568     pTmax += pTStep;
569   }
570   
571   return fYRatioInPtBinsList;
572 }
573
574 //____________________________________________________________________//
575 TH1D *AliProtonAnalysis::GetProtonYHistogram() {
576   //Get the y histogram for protons
577   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
578
579   //TH1D *fYProtons = (TH1D *)fHistYPtProtons->ProjectionX("fYProtons",0,fHistYPtProtons->GetYaxis()->GetNbins(),"");
580   TH1D *fYProtons = fProtonContainer->ShowProjection(0,kStepInPhaseSpace); //variable-step
581    
582   fYProtons->SetStats(kFALSE);
583   fYProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
584   fYProtons->SetTitle("dN/dy protons");
585   fYProtons->SetMarkerStyle(kFullCircle);
586   fYProtons->SetMarkerColor(4);
587   if(nAnalyzedEvents > 0)
588   fYProtons->Scale(1./nAnalyzedEvents);
589   
590   return fYProtons;
591 }
592
593 //____________________________________________________________________//
594 TH1D *AliProtonAnalysis::GetAntiProtonYHistogram() {
595   //Get the y histogram for antiprotons
596   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
597   
598   //TH1D *fYAntiProtons = (TH1D *)fHistYPtAntiProtons->ProjectionX("fYAntiProtons",0,fHistYPtAntiProtons->GetYaxis()->GetNbins(),"");
599   TH1D *fYAntiProtons = fAntiProtonContainer->ShowProjection(0,kStepInPhaseSpace);//variable-step 
600  
601   fYAntiProtons->SetStats(kFALSE);
602   fYAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
603   fYAntiProtons->SetTitle("dN/dy antiprotons");
604   fYAntiProtons->SetMarkerStyle(kFullCircle);
605   fYAntiProtons->SetMarkerColor(4);
606   if(nAnalyzedEvents > 0)
607     fYAntiProtons->Scale(1./nAnalyzedEvents);
608
609   return fYAntiProtons;
610 }
611
612 //____________________________________________________________________//
613 TH1D *AliProtonAnalysis::GetProtonPtHistogram() {
614   //Get the Pt histogram for protons
615   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
616   
617   //TH1D *fPtProtons = (TH1D *)fHistYPtProtons->ProjectionY("fPtProtons",0,fHistYPtProtons->GetXaxis()->GetNbins(),""); 
618   TH1D *fPtProtons = fProtonContainer->ShowProjection(1,kStepInPhaseSpace); //variable-step
619
620   fPtProtons->SetStats(kFALSE);
621   fPtProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
622   fPtProtons->SetTitle("dN/dPt protons");
623   fPtProtons->SetMarkerStyle(kFullCircle);
624   fPtProtons->SetMarkerColor(4);
625   if(nAnalyzedEvents > 0)
626     fPtProtons->Scale(1./nAnalyzedEvents);
627
628   return fPtProtons;
629 }
630
631 //____________________________________________________________________//
632 TH1D *AliProtonAnalysis::GetAntiProtonPtHistogram() {
633   //Get the Pt histogram for antiprotons
634   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
635   
636   //TH1D *fPtAntiProtons = (TH1D *)fHistYPtAntiProtons->ProjectionY("fPtAntiProtons",0,fHistYPtProtons->GetXaxis()->GetNbins(),""); 
637   TH1D *fPtAntiProtons = fAntiProtonContainer->ShowProjection(1,kStepInPhaseSpace); //variable-step
638
639   fPtAntiProtons->SetStats(kFALSE);
640   fPtAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
641   fPtAntiProtons->SetTitle("dN/dPt antiprotons");
642   fPtAntiProtons->SetMarkerStyle(kFullCircle);
643   fPtAntiProtons->SetMarkerColor(4);
644   if(nAnalyzedEvents > 0)
645     fPtAntiProtons->Scale(1./nAnalyzedEvents);
646
647   return fPtAntiProtons;
648 }
649
650 //____________________________________________________________________//
651 TH1D *AliProtonAnalysis::GetProtonCorrectedYHistogram() {
652   //Get the corrected y histogram for protons
653   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
654
655   TH1D *fYProtons = (TH1D *)fHistYPtProtonsCorrected->ProjectionX("fYProtons",1,fHistYPtProtons->GetYaxis()->GetNbins(),"e");
656   //TH1D *fYProtons = fCorrectProtons->Project(0); //0: rapidity
657    
658   fYProtons->SetStats(kFALSE);
659   fYProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
660   fYProtons->GetXaxis()->SetTitle("y");
661   fYProtons->SetTitle("dN/dy protons");
662   fYProtons->SetMarkerStyle(kFullCircle);
663   fYProtons->SetMarkerColor(4);
664   if(nAnalyzedEvents > 0)
665     fYProtons->Scale(1./nAnalyzedEvents);
666   
667   return fYProtons;
668 }
669
670 //____________________________________________________________________//
671 TH1D *AliProtonAnalysis::GetAntiProtonCorrectedYHistogram() {
672   //Get the corrected y histogram for antiprotons
673   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
674   
675   TH1D *fYAntiProtons = (TH1D *)fHistYPtAntiProtonsCorrected->ProjectionX("fYAntiProtons",1,fHistYPtAntiProtons->GetYaxis()->GetNbins(),"e");
676   //TH1D *fYAntiProtons = fCorrectAntiProtons->Project(0); //0: rapidity
677    
678   fYAntiProtons->SetStats(kFALSE);
679   fYAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
680   fYAntiProtons->GetXaxis()->SetTitle("y");
681   fYAntiProtons->SetTitle("dN/dy protons");
682   fYAntiProtons->SetMarkerStyle(kFullCircle);
683   fYAntiProtons->SetMarkerColor(4);
684   if(nAnalyzedEvents > 0)
685     fYAntiProtons->Scale(1./nAnalyzedEvents);
686   
687   return fYAntiProtons;
688 }
689
690 //____________________________________________________________________//
691 TH1D *AliProtonAnalysis::GetProtonCorrectedPtHistogram() {
692   //Get the corrected Pt histogram for protons
693   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
694
695   TH1D *fPtProtons = (TH1D *)fHistYPtProtonsCorrected->ProjectionY("fPtProtons",2,fHistYPtProtons->GetXaxis()->GetNbins()-1,"e");
696   //TH1D *fPtProtons = fCorrectProtons->Project(0); //0: rapidity
697    
698   fPtProtons->SetStats(kFALSE);
699   fPtProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
700   fPtProtons->GetXaxis()->SetTitle("P_{T} [GeV/c]");
701   fPtProtons->SetTitle("dN/dPt protons");
702   fPtProtons->SetMarkerStyle(kFullCircle);
703   fPtProtons->SetMarkerColor(4);
704   if(nAnalyzedEvents > 0)
705     fPtProtons->Scale(1./nAnalyzedEvents);
706   
707   return fPtProtons;
708 }
709
710 //____________________________________________________________________//
711 TH1D *AliProtonAnalysis::GetAntiProtonCorrectedPtHistogram() {
712   //Get the corrected Pt histogram for antiprotons
713   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
714
715   TH1D *fPtAntiProtons = (TH1D *)fHistYPtAntiProtonsCorrected->ProjectionY("fPtAntiProtons",2,fHistYPtAntiProtons->GetXaxis()->GetNbins()-1,"e");
716 //TH1D *fPtAntiProtons = fCorrectAntiProtons->Project(0); //0: rapidity
717    
718   fPtAntiProtons->SetStats(kFALSE);
719   fPtAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
720   fPtAntiProtons->GetXaxis()->SetTitle("P_{T} [GeV/c]");
721   fPtAntiProtons->SetTitle("dN/dPt antiprotons");
722   fPtAntiProtons->SetMarkerStyle(kFullCircle);
723   fPtAntiProtons->SetMarkerColor(4);
724   if(nAnalyzedEvents > 0)
725     fPtAntiProtons->Scale(1./nAnalyzedEvents);
726   
727   return fPtAntiProtons;
728 }
729
730 //____________________________________________________________________//
731 TH1D *AliProtonAnalysis::GetYRatioHistogram() {
732   //Returns the rapidity dependence of the ratio (uncorrected)
733   TH1D *fYProtons = GetProtonYHistogram();
734   TH1D *fYAntiProtons = GetAntiProtonYHistogram();
735   
736   TH1D *hRatioY = new TH1D("hRatioY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
737   hRatioY->Divide(fYAntiProtons,fYProtons,1.0,1.0,"e");
738   hRatioY->SetMarkerStyle(kFullCircle);
739   hRatioY->SetMarkerColor(4);
740   hRatioY->GetYaxis()->SetTitle("#bar{p}/p");
741   hRatioY->GetYaxis()->SetTitleOffset(1.4);
742   hRatioY->GetXaxis()->SetTitle("y");
743   hRatioY->GetXaxis()->SetTitleColor(1);
744   hRatioY->SetStats(kFALSE);
745
746   return hRatioY;
747 }
748
749 //____________________________________________________________________//
750 TH1D *AliProtonAnalysis::GetYRatioCorrectedHistogram() {
751 //TH2D *gCorrectionProtons, 
752 //TH2D *gCorrectionAntiProtons) {
753   //Returns the rapidity dependence of the ratio (corrected)
754   //fHistYPtProtons->Multiply(gCorrectionProtons);
755   TH1D *fYProtons = GetProtonCorrectedYHistogram();
756   //fHistYPtAntiProtons->Multiply(gCorrectionAntiProtons);
757   TH1D *fYAntiProtons = GetAntiProtonCorrectedYHistogram();
758   
759   TH1D *hRatioY = new TH1D("hRatioY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
760   hRatioY->Divide(fYAntiProtons,fYProtons,1.0,1.0,"e");
761   hRatioY->SetMarkerStyle(kFullCircle);
762   hRatioY->SetMarkerColor(4);
763   hRatioY->GetYaxis()->SetTitle("#bar{p}/p");
764   hRatioY->GetYaxis()->SetTitleOffset(1.4);
765   hRatioY->GetXaxis()->SetTitle("y");
766   hRatioY->GetXaxis()->SetTitleColor(1);
767   hRatioY->SetStats(kFALSE);
768
769   return hRatioY;
770 }
771
772 //____________________________________________________________________//
773 TH1D *AliProtonAnalysis::GetPtRatioHistogram() {
774   //Returns the pT dependence of the ratio (uncorrected)
775   TH1D *fPtProtons = GetProtonPtHistogram();
776   TH1D *fPtAntiProtons = GetAntiProtonPtHistogram();
777   
778   TH1D *hRatioPt = new TH1D("hRatioPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
779   hRatioPt->Divide(fPtAntiProtons,fPtProtons,1.0,1.0,"e");
780   hRatioPt->SetMarkerStyle(kFullCircle);
781   hRatioPt->SetMarkerColor(4);
782   hRatioPt->GetYaxis()->SetTitle("#bar{p}/p");
783   hRatioPt->GetYaxis()->SetTitleOffset(1.4);
784   hRatioPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
785   hRatioPt->GetXaxis()->SetTitleColor(1);
786   hRatioPt->SetStats(kFALSE);
787
788   return hRatioPt;
789 }
790
791 //____________________________________________________________________//
792 TH1D *AliProtonAnalysis::GetPtRatioCorrectedHistogram() {
793   //TH2D *gCorrectionProtons, 
794   //TH2D *gCorrectionAntiProtons) {
795   //Returns the Pt dependence of the ratio (corrected)
796   //fHistYPtProtons->Multiply(gCorrectionProtons);
797   TH1D *fPtProtons = GetProtonCorrectedPtHistogram();
798   //fHistYPtAntiProtons->Multiply(gCorrectionAntiProtons);
799   TH1D *fPtAntiProtons = GetAntiProtonCorrectedPtHistogram();
800   
801   TH1D *hRatioPt = new TH1D("hRatioPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
802   hRatioPt->Divide(fPtAntiProtons,fPtProtons,1.0,1.0,"e");
803   hRatioPt->SetMarkerStyle(kFullCircle);
804   hRatioPt->SetMarkerColor(4);
805   hRatioPt->GetYaxis()->SetTitle("#bar{p}/p");
806   hRatioPt->GetYaxis()->SetTitleOffset(1.4);
807   hRatioPt->GetXaxis()->SetTitle("y");
808   hRatioPt->GetXaxis()->SetTitleColor(1);
809   hRatioPt->SetStats(kFALSE);
810
811   return hRatioPt;
812 }
813
814 //____________________________________________________________________//
815 TH1D *AliProtonAnalysis::GetYAsymmetryHistogram() {
816   //Returns the rapidity dependence of the asymmetry (uncorrected)
817   TH1D *fYProtons = GetProtonYHistogram();
818   TH1D *fYAntiProtons = GetAntiProtonYHistogram();
819   
820   TH1D *hsum = new TH1D("hsumY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
821   hsum->Add(fYProtons,fYAntiProtons,1.0,1.0);
822
823   TH1D *hdiff = new TH1D("hdiffY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
824   hdiff->Add(fYProtons,fYAntiProtons,1.0,-1.0);
825
826   TH1D *hAsymmetryY = new TH1D("hAsymmetryY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
827   hAsymmetryY->Divide(hdiff,hsum,2.0,1.,"e");
828   hAsymmetryY->SetMarkerStyle(kFullCircle);
829   hAsymmetryY->SetMarkerColor(4);
830   hAsymmetryY->GetYaxis()->SetTitle("A_{p}");
831   hAsymmetryY->GetYaxis()->SetTitleOffset(1.4);
832   hAsymmetryY->GetXaxis()->SetTitle("y");
833   hAsymmetryY->GetXaxis()->SetTitleColor(1);
834   hAsymmetryY->SetStats(kFALSE);
835
836   return hAsymmetryY;
837 }
838
839 //____________________________________________________________________//
840 TH1D *AliProtonAnalysis::GetPtAsymmetryHistogram() {
841   //Returns the pT dependence of the asymmetry (uncorrected)
842   TH1D *fPtProtons = GetProtonPtHistogram();
843   TH1D *fPtAntiProtons = GetAntiProtonPtHistogram();
844   
845   TH1D *hsum = new TH1D("hsumPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
846   hsum->Add(fPtProtons,fPtAntiProtons,1.0,1.0);
847
848   TH1D *hdiff = new TH1D("hdiffPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
849   hdiff->Add(fPtProtons,fPtAntiProtons,1.0,-1.0);
850
851   TH1D *hAsymmetryPt = new TH1D("hAsymmetryPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
852   hAsymmetryPt->Divide(hdiff,hsum,2.0,1.,"e");
853   hAsymmetryPt->SetMarkerStyle(kFullCircle);
854   hAsymmetryPt->SetMarkerColor(4);
855   hAsymmetryPt->GetYaxis()->SetTitle("A_{p}");
856   hAsymmetryPt->GetYaxis()->SetTitleOffset(1.4);
857   hAsymmetryPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
858   hAsymmetryPt->GetXaxis()->SetTitleColor(1);
859   hAsymmetryPt->SetStats(kFALSE);
860
861   return hAsymmetryPt;
862 }
863
864 //____________________________________________________________________//
865 void AliProtonAnalysis::Analyze(AliESDEvent* esd,
866                                 const AliESDVertex *vertex) {
867   //Main analysis part - ESD
868   Int_t nTracks = 0;
869   Int_t nIdentifiedProtons = 0, nIdentifiedAntiProtons = 0;
870   Int_t nSurvivedProtons = 0, nSurvivedAntiProtons = 0;
871   
872   //=========================================//
873   //Aleph parametrization
874   Double_t fAlephParameters[5];
875   if(fProtonAnalysisBase->GetMCAnalysisMode()) {
876     fAlephParameters[0] = 2.15898e+00/50.;
877     fAlephParameters[1] = 1.75295e+01;
878     fAlephParameters[2] = 3.40030e-09;
879     fAlephParameters[3] = 1.96178e+00;
880     fAlephParameters[4] = 3.91720e+00;
881   }
882   else {
883     fAlephParameters[0] = 0.0283086;
884     fAlephParameters[1] = 2.63394e+01;
885     fAlephParameters[2] = 5.04114e-11;
886     fAlephParameters[3] = 2.12543e+00;
887     fAlephParameters[4] = 4.88663e+00;
888   }
889   AliESDpid *fESDpid = new AliESDpid();
890   AliTPCPIDResponse tpcResponse = fESDpid->GetTPCResponse(); 
891   tpcResponse.SetBetheBlochParameters(fAlephParameters[0],fAlephParameters[1],fAlephParameters[2],fAlephParameters[3],fAlephParameters[4]);
892   //=========================================//  
893
894   fHistEvents->Fill(1); //number of analyzed events
895   Double_t containerInput[2] ;
896   Double_t gPt = 0.0, gP = 0.0;
897   Float_t dcaXY = 0.0, dcaZ = 0.0;
898
899   nTracks = esd->GetNumberOfTracks();
900   for(Int_t iTracks = 0; iTracks < nTracks; iTracks++) {
901     AliESDtrack* track = esd->GetTrack(iTracks);
902     AliESDtrack trackTPC;
903
904     //in case it's a TPC only track relate it to the proper vertex
905     /*if(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC) {
906       Float_t p[2],cov[3];
907       track->GetImpactParametersTPC(p,cov);
908       if (p[0]==0 && p[1]==0)  
909         track->RelateToVertexTPC(((AliESDEvent*)esd)->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
910       if (!track->FillTPCOnlyTrack(trackTPC)) {
911         continue;
912       }
913       track = &trackTPC ;
914       }*/
915
916     Int_t  fIdxInt[200];
917     Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
918     Int_t npointsTPCdEdx = track->GetTPCsignalN();
919     Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};  //The impact parameters and their covariance.
920     Double_t dca3D = 0.0;
921
922     if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)||(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
923       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
924       if(!tpcTrack) continue;
925       gPt = tpcTrack->Pt();
926       //gP = tpcTrack->P();
927       gP = track->GetInnerParam()->P();
928       tpcTrack->PropagateToDCA(vertex,
929                                esd->GetMagneticField(),
930                                100.,dca,cov);
931       dca3D = TMath::Sqrt(TMath::Power(dca[0],2) +
932                           TMath::Power(dca[1],2));
933
934       if(fProtonAnalysisBase->IsPrimary(esd,vertex,track)) {
935         if(fProtonAnalysisBase->IsAccepted(track)) {
936           ((TH2F *)(fQA2DList->At(0)))->Fill(gP,track->GetTPCsignal());
937           ((TH2F *)(fQA2DList->At(2)))->Fill(gP,TMath::Log(track->GetTPCsignal()/tpcResponse.GetExpectedSignal(gP,AliPID::kProton)));
938           ((TH3F *)(fQA2DList->At(4)))->Fill(tpcTrack->Eta(),
939                                              tpcTrack->Phi()*180./TMath::Pi(),
940                                              npointsTPCdEdx);
941           ((TH3F *)(fQA2DList->At(6)))->Fill(tpcTrack->Eta(),
942                                              tpcTrack->Phi()*180./TMath::Pi(),
943                                              nClustersTPC);
944           ((TH3F *)(fQA2DList->At(8)))->Fill(gPt,
945                                              tpcTrack->Phi()*180./TMath::Pi(),
946                                              npointsTPCdEdx);
947           ((TH3F *)(fQA2DList->At(10)))->Fill(gPt,
948                                              tpcTrack->Phi()*180./TMath::Pi(),
949                                              nClustersTPC);     
950         }//quality cuts
951       }//primary cuts
952       
953       if(fProtonAnalysisBase->IsProton(track)) {
954         //Step: kStepIdentified
955         if(fProtonAnalysisBase->GetEtaMode())
956           containerInput[0] = tpcTrack->Eta();
957         else
958           containerInput[0] = fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
959                                                             tpcTrack->Py(),
960                                                             tpcTrack->Pz());
961         containerInput[1] = gPt;
962         if(tpcTrack->Charge() > 0) {
963           nIdentifiedProtons += 1;
964           fProtonContainer->Fill(containerInput,kStepIdentified);
965         }//protons
966         else if(tpcTrack->Charge() < 0) {
967           nIdentifiedAntiProtons += 1;
968           fAntiProtonContainer->Fill(containerInput,kStepIdentified);
969         }//protons
970         
971         //Step: kStepIsPrimary
972         if(fProtonAnalysisBase->IsPrimary(esd,vertex,track)) {
973           if(tpcTrack->Charge() > 0)
974             fProtonContainer->Fill(containerInput,kStepIsPrimary);   
975           else if(tpcTrack->Charge() < 0) 
976             fAntiProtonContainer->Fill(containerInput,kStepIsPrimary);   
977           
978           FillQA(esd,vertex,track);       
979           
980           //Step: kStepSurvived
981           if(fProtonAnalysisBase->IsAccepted(track)) {
982             ((TH2F *)(fQA2DList->At(1)))->Fill(gP,track->GetTPCsignal());
983             ((TH2F *)(fQA2DList->At(3)))->Fill(gP,TMath::Log(track->GetTPCsignal()/tpcResponse.GetExpectedSignal(gP,AliPID::kProton)));
984             ((TH3F *)(fQA2DList->At(5)))->Fill(tpcTrack->Eta(),
985                                                tpcTrack->Phi()*180./TMath::Pi(),
986                                                npointsTPCdEdx);
987             ((TH3F *)(fQA2DList->At(7)))->Fill(tpcTrack->Eta(),
988                                                tpcTrack->Phi()*180./TMath::Pi(),
989                                                nClustersTPC);
990             ((TH3F *)(fQA2DList->At(9)))->Fill(gPt,
991                                                tpcTrack->Phi()*180./TMath::Pi(),
992                                                npointsTPCdEdx);
993             ((TH3F *)(fQA2DList->At(11)))->Fill(gPt,
994                                                tpcTrack->Phi()*180./TMath::Pi(),
995                                                nClustersTPC);
996             
997             if(tpcTrack->Charge() > 0) {
998               fProtonContainer->Fill(containerInput,kStepSurvived);   
999               ((TH2F *)(fQA2DList->At(12)))->Fill(tpcTrack->Eta(),
1000                                                   tpcTrack->Phi()*180./TMath::Pi());
1001               if(fProtonAnalysisBase->GetEtaMode()) {
1002                 ((TH3F *)(fQA2DList->At(14)))->Fill(tpcTrack->Eta(),
1003                                                     tpcTrack->Pt(),
1004                                                     dca[0]);
1005                 ((TH3F *)(fQA2DList->At(15)))->Fill(tpcTrack->Eta(),
1006                                                     tpcTrack->Pt(),
1007                                                     dca[1]);
1008                 ((TH3F *)(fQA2DList->At(18)))->Fill(tpcTrack->Eta(),
1009                                                     tpcTrack->Pt(),
1010                                                     TMath::Abs(dca3D));
1011               }
1012               else {
1013                 ((TH3F *)(fQA2DList->At(14)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1014                                                     tpcTrack->Pt(),
1015                                                     dca[0]);
1016                 ((TH3F *)(fQA2DList->At(15)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1017                                                     tpcTrack->Pt(),
1018                                                     dca[1]);
1019                 ((TH3F *)(fQA2DList->At(18)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1020                                                     tpcTrack->Pt(),
1021                                                     TMath::Abs(dca3D));
1022               }
1023             }//protons
1024             else if(tpcTrack->Charge() < 0) {
1025               fAntiProtonContainer->Fill(containerInput,kStepSurvived);   
1026               ((TH2F *)(fQA2DList->At(13)))->Fill(tpcTrack->Eta(),
1027                                                   tpcTrack->Phi()*180./TMath::Pi());
1028               if(fProtonAnalysisBase->GetEtaMode()) {
1029                 ((TH3F *)(fQA2DList->At(16)))->Fill(tpcTrack->Eta(),
1030                                                     tpcTrack->Pt(),
1031                                                     dca[0]);
1032                 ((TH3F *)(fQA2DList->At(17)))->Fill(tpcTrack->Eta(),
1033                                                     tpcTrack->Pt(),
1034                                                     dca[1]);
1035                 ((TH3F *)(fQA2DList->At(19)))->Fill(tpcTrack->Eta(),
1036                                                     tpcTrack->Pt(),
1037                                                     TMath::Abs(dca3D));
1038               }
1039               else {
1040                 ((TH3F *)(fQA2DList->At(16)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1041                                                     tpcTrack->Pt(),
1042                                                     dca[0]);
1043                 ((TH3F *)(fQA2DList->At(17)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1044                                                     tpcTrack->Pt(),
1045                                                     dca[1]);
1046                 ((TH3F *)(fQA2DList->At(19)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1047                                                     tpcTrack->Pt(),
1048                                                     TMath::Abs(dca3D));
1049               }
1050             }//antiprotons
1051             
1052             //Step: kStepInPhaseSpace
1053             if(fProtonAnalysisBase->IsInPhaseSpace(track)) {
1054               if(tpcTrack->Charge() > 0) {
1055                 nSurvivedProtons += 1;
1056                 fHistYPtProtons->Fill(containerInput[0],
1057                                       containerInput[1]);
1058                 fProtonContainer->Fill(containerInput,kStepInPhaseSpace);   
1059               }//protons
1060               else if(tpcTrack->Charge() < 0) {
1061                 nSurvivedAntiProtons += 1;
1062                 fHistYPtAntiProtons->Fill(containerInput[0],
1063                                           containerInput[1]);
1064                 fAntiProtonContainer->Fill(containerInput,kStepInPhaseSpace);
1065               }//antiprotons
1066             }//Step: kStepInPhaseSpace
1067           }//Step: kStepSurvived
1068         }//Step: kStepIsPrimary
1069       }//Step: kStepIdentified
1070     }//TPC only tracks
1071     if(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kFullHybrid) {
1072       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
1073       if(!tpcTrack) continue;
1074
1075       AliExternalTrackParam cParam;
1076       /*Double_t phi = tpcTrack->Phi();
1077       Double_t eta = tpcTrack->Eta();
1078       Double_t gPx = tpcTrack->Px();
1079       Double_t gPy = tpcTrack->Py();
1080       Double_t gPz = tpcTrack->Pz();*/
1081       gPt = tpcTrack->Pt();
1082       //gP = tpcTrack->P();
1083       gP = track->GetInnerParam()->P();
1084       track->RelateToVertex(vertex,
1085                             esd->GetMagneticField(),
1086                             100.,&cParam);
1087       track->GetImpactParameters(dcaXY,dcaZ);
1088       dca[0] = dcaXY; dca[1] = dcaZ;
1089       dca3D = TMath::Sqrt(TMath::Power(dca[0],2) +
1090                           TMath::Power(dca[1],2));
1091
1092       if(fProtonAnalysisBase->IsPrimary(esd,vertex,track)) {
1093         if(fProtonAnalysisBase->IsAccepted(track)) {
1094           ((TH2F *)(fQA2DList->At(0)))->Fill(gP,track->GetTPCsignal());
1095           ((TH2F *)(fQA2DList->At(2)))->Fill(gP,TMath::Log(track->GetTPCsignal()/tpcResponse.GetExpectedSignal(gP,AliPID::kProton)));
1096           ((TH3F *)(fQA2DList->At(4)))->Fill(tpcTrack->Eta(),
1097                                              tpcTrack->Phi()*180./TMath::Pi(),
1098                                              npointsTPCdEdx);
1099           ((TH3F *)(fQA2DList->At(6)))->Fill(tpcTrack->Eta(),
1100                                              tpcTrack->Phi()*180./TMath::Pi(),
1101                                              nClustersTPC);
1102           ((TH3F *)(fQA2DList->At(8)))->Fill(gPt,
1103                                              tpcTrack->Phi()*180./TMath::Pi(),
1104                                              npointsTPCdEdx);
1105           ((TH3F *)(fQA2DList->At(10)))->Fill(gPt,
1106                                              tpcTrack->Phi()*180./TMath::Pi(),
1107                                              nClustersTPC);     
1108         }//quality cuts
1109       }//primary cuts
1110       
1111       if(fProtonAnalysisBase->IsProton(track)) {
1112         //Step: kStepIdentified
1113         if(fProtonAnalysisBase->GetEtaMode())
1114           containerInput[0] = tpcTrack->Eta();
1115         else
1116           containerInput[0] = fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
1117                                                             tpcTrack->Py(),
1118                                                             tpcTrack->Pz());
1119         containerInput[1] = gPt;
1120         if(tpcTrack->Charge() > 0) {
1121           nIdentifiedProtons += 1;
1122           fProtonContainer->Fill(containerInput,kStepIdentified);
1123         }//protons
1124         else if(tpcTrack->Charge() < 0) {
1125           nIdentifiedAntiProtons += 1;
1126           fAntiProtonContainer->Fill(containerInput,kStepIdentified);
1127         }//protons
1128         
1129         //Step: kStepIsPrimary
1130         if(fProtonAnalysisBase->IsPrimary(esd,vertex,track)) {
1131           if(tpcTrack->Charge() > 0)
1132             fProtonContainer->Fill(containerInput,kStepIsPrimary);   
1133           else if(tpcTrack->Charge() < 0) 
1134             fAntiProtonContainer->Fill(containerInput,kStepIsPrimary);   
1135           
1136           FillQA(esd,vertex,track);       
1137           
1138           //Step: kStepSurvived
1139           if(fProtonAnalysisBase->IsAccepted(track)) {
1140             ((TH2F *)(fQA2DList->At(1)))->Fill(gP,track->GetTPCsignal());
1141             ((TH2F *)(fQA2DList->At(3)))->Fill(gP,TMath::Log(track->GetTPCsignal()/tpcResponse.GetExpectedSignal(gP,AliPID::kProton)));
1142             ((TH3F *)(fQA2DList->At(5)))->Fill(tpcTrack->Eta(),
1143                                                tpcTrack->Phi()*180./TMath::Pi(),
1144                                                npointsTPCdEdx);
1145             ((TH3F *)(fQA2DList->At(7)))->Fill(tpcTrack->Eta(),
1146                                                tpcTrack->Phi()*180./TMath::Pi(),
1147                                                nClustersTPC);
1148             ((TH3F *)(fQA2DList->At(9)))->Fill(gPt,
1149                                                tpcTrack->Phi()*180./TMath::Pi(),
1150                                                npointsTPCdEdx);
1151             ((TH3F *)(fQA2DList->At(11)))->Fill(gPt,
1152                                                tpcTrack->Phi()*180./TMath::Pi(),
1153                                                nClustersTPC);
1154             
1155             if(tpcTrack->Charge() > 0) {
1156               fProtonContainer->Fill(containerInput,kStepSurvived);   
1157               ((TH2F *)(fQA2DList->At(12)))->Fill(tpcTrack->Eta(),
1158                                                   tpcTrack->Phi()*180./TMath::Pi());
1159               if(fProtonAnalysisBase->GetEtaMode()) {
1160                 ((TH3F *)(fQA2DList->At(14)))->Fill(tpcTrack->Eta(),
1161                                                     tpcTrack->Pt(),
1162                                                     dca[0]);
1163                 ((TH3F *)(fQA2DList->At(15)))->Fill(tpcTrack->Eta(),
1164                                                     tpcTrack->Pt(),
1165                                                     dca[1]);
1166                 ((TH3F *)(fQA2DList->At(18)))->Fill(tpcTrack->Eta(),
1167                                                     tpcTrack->Pt(),
1168                                                     TMath::Abs(dca3D));
1169               }
1170               else {
1171                 ((TH3F *)(fQA2DList->At(14)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1172                                                     tpcTrack->Pt(),
1173                                                     dca[0]);
1174                 ((TH3F *)(fQA2DList->At(15)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1175                                                     tpcTrack->Pt(),
1176                                                     dca[1]);
1177                 ((TH3F *)(fQA2DList->At(18)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1178                                                     tpcTrack->Pt(),
1179                                                     TMath::Abs(dca3D));
1180               }
1181             }//protons
1182             else if(tpcTrack->Charge() < 0) {
1183               fAntiProtonContainer->Fill(containerInput,kStepSurvived);   
1184               ((TH2F *)(fQA2DList->At(13)))->Fill(tpcTrack->Eta(),
1185                                                   tpcTrack->Phi()*180./TMath::Pi());
1186               if(fProtonAnalysisBase->GetEtaMode()) {
1187                 ((TH3F *)(fQA2DList->At(16)))->Fill(tpcTrack->Eta(),
1188                                                     tpcTrack->Pt(),
1189                                                     dca[0]);
1190                 ((TH3F *)(fQA2DList->At(17)))->Fill(tpcTrack->Eta(),
1191                                                     tpcTrack->Pt(),
1192                                                     dca[1]);
1193                 ((TH3F *)(fQA2DList->At(19)))->Fill(tpcTrack->Eta(),
1194                                                     tpcTrack->Pt(),
1195                                                     TMath::Abs(dca3D));
1196               }
1197               else {
1198                 ((TH3F *)(fQA2DList->At(16)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1199                                                     tpcTrack->Pt(),
1200                                                     dca[0]);
1201                 ((TH3F *)(fQA2DList->At(17)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1202                                                     tpcTrack->Pt(),
1203                                                     dca[1]);
1204                 ((TH3F *)(fQA2DList->At(19)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),
1205                                                     tpcTrack->Pt(),
1206                                                     TMath::Abs(dca3D));
1207               }
1208             }//antiprotons
1209             
1210             //Step: kStepInPhaseSpace
1211             if(fProtonAnalysisBase->IsInPhaseSpace(track)) {
1212               if(tpcTrack->Charge() > 0) {
1213                 nSurvivedProtons += 1;
1214                 fHistYPtProtons->Fill(containerInput[0],
1215                                       containerInput[1]);
1216                 fProtonContainer->Fill(containerInput,kStepInPhaseSpace);   
1217               }//protons
1218               else if(tpcTrack->Charge() < 0) {
1219                 nSurvivedAntiProtons += 1;
1220                 fHistYPtAntiProtons->Fill(containerInput[0],
1221                                           containerInput[1]);
1222                 fAntiProtonContainer->Fill(containerInput,kStepInPhaseSpace);
1223               }//antiprotons
1224             }//Step: kStepInPhaseSpace
1225           }//Step: kStepSurvived
1226         }//Step: kStepIsPrimary
1227       }//Step: kStepIdentified
1228     }//Full hybrid
1229     else if(fProtonAnalysisBase->GetAnalysisMode() == AliProtonAnalysisBase::kGlobal) {
1230       gPt = track->Pt();
1231       //gP = track->P();
1232       gP = track->GetInnerParam()->P();
1233
1234       track->PropagateToDCA(vertex,
1235                             esd->GetMagneticField(),
1236                             100.,dca,cov);
1237       dca3D = TMath::Sqrt(TMath::Power(dca[0],2) +
1238                           TMath::Power(dca[1],2));
1239
1240       if(fProtonAnalysisBase->IsPrimary(esd,vertex,track)) {
1241         if(fProtonAnalysisBase->IsAccepted(track)) {
1242           ((TH2F *)(fQA2DList->At(0)))->Fill(gP,track->GetTPCsignal());
1243           ((TH2F *)(fQA2DList->At(2)))->Fill(gP,TMath::Log(track->GetTPCsignal()/tpcResponse.GetExpectedSignal(gP,AliPID::kProton)));
1244           ((TH3F *)(fQA2DList->At(4)))->Fill(track->Eta(),
1245                                              track->Phi()*180./TMath::Pi(),
1246                                              npointsTPCdEdx);
1247           ((TH3F *)(fQA2DList->At(6)))->Fill(track->Eta(),
1248                                              track->Phi()*180./TMath::Pi(),
1249                                              nClustersTPC);
1250           ((TH3F *)(fQA2DList->At(8)))->Fill(gPt,
1251                                              track->Phi()*180./TMath::Pi(),
1252                                              npointsTPCdEdx);
1253           ((TH3F *)(fQA2DList->At(10)))->Fill(gPt,
1254                                              track->Phi()*180./TMath::Pi(),
1255                                              nClustersTPC);     
1256         }//quality cuts
1257       }//primary cuts
1258       
1259       if(fProtonAnalysisBase->IsProton(track)) {
1260         //Step: kStepIdentified
1261         if(fProtonAnalysisBase->GetEtaMode())
1262           containerInput[0] = track->Eta();
1263         else
1264           containerInput[0] = fProtonAnalysisBase->Rapidity(track->Px(),
1265                                                             track->Py(),
1266                                                             track->Pz());
1267         containerInput[1] = gPt;
1268         if(track->Charge() > 0) {
1269           nIdentifiedProtons += 1;
1270           fProtonContainer->Fill(containerInput,kStepIdentified);
1271         }//protons
1272         else if(track->Charge() < 0) {
1273           nIdentifiedAntiProtons += 1;
1274           fAntiProtonContainer->Fill(containerInput,kStepIdentified);
1275         }//protons
1276         
1277         //Step: kStepIsPrimary
1278         if(fProtonAnalysisBase->IsPrimary(esd,vertex,track)) {
1279           if(track->Charge() > 0)
1280             fProtonContainer->Fill(containerInput,kStepIsPrimary);   
1281           else if(track->Charge() < 0) 
1282             fAntiProtonContainer->Fill(containerInput,kStepIsPrimary);   
1283           
1284           FillQA(esd,vertex,track);       
1285           
1286           //Step: kStepSurvived
1287           if(fProtonAnalysisBase->IsAccepted(track)) {
1288             ((TH2F *)(fQA2DList->At(1)))->Fill(gP,track->GetTPCsignal());
1289             ((TH2F *)(fQA2DList->At(3)))->Fill(gP,TMath::Log(track->GetTPCsignal()/tpcResponse.GetExpectedSignal(gP,AliPID::kProton)));
1290             ((TH3F *)(fQA2DList->At(5)))->Fill(track->Eta(),
1291                                                track->Phi()*180./TMath::Pi(),
1292                                                npointsTPCdEdx);
1293             ((TH3F *)(fQA2DList->At(7)))->Fill(track->Eta(),
1294                                                track->Phi()*180./TMath::Pi(),
1295                                                nClustersTPC);
1296             ((TH3F *)(fQA2DList->At(9)))->Fill(gPt,
1297                                                track->Phi()*180./TMath::Pi(),
1298                                                npointsTPCdEdx);
1299             ((TH3F *)(fQA2DList->At(11)))->Fill(gPt,
1300                                                track->Phi()*180./TMath::Pi(),
1301                                                nClustersTPC);
1302             
1303             if(track->Charge() > 0) {
1304               fProtonContainer->Fill(containerInput,kStepSurvived);   
1305               ((TH2F *)(fQA2DList->At(12)))->Fill(track->Eta(),
1306                                                   track->Phi()*180./TMath::Pi());
1307               if(fProtonAnalysisBase->GetEtaMode()) {
1308                 ((TH3F *)(fQA2DList->At(14)))->Fill(track->Eta(),
1309                                                     track->Pt(),
1310                                                     dca[0]);
1311                 ((TH3F *)(fQA2DList->At(15)))->Fill(track->Eta(),
1312                                                     track->Pt(),
1313                                                     dca[1]);
1314                 ((TH3F *)(fQA2DList->At(18)))->Fill(track->Eta(),
1315                                                     track->Pt(),
1316                                                     TMath::Abs(dca3D));
1317
1318               }
1319               else {
1320                 ((TH3F *)(fQA2DList->At(14)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),track->Py(),track->Pz()),
1321                                                     track->Pt(),
1322                                                     dca[0]);
1323                 ((TH3F *)(fQA2DList->At(15)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),track->Py(),track->Pz()),
1324                                                     track->Pt(),
1325                                                     dca[1]);
1326                 ((TH3F *)(fQA2DList->At(18)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),track->Py(),track->Pz()),
1327                                                     track->Pt(),
1328                                                     TMath::Abs(dca3D));
1329               }
1330             }//protons
1331             else if(track->Charge() < 0) {
1332               fAntiProtonContainer->Fill(containerInput,kStepSurvived);   
1333               ((TH2F *)(fQA2DList->At(13)))->Fill(track->Eta(),
1334                                                   track->Phi()*180./TMath::Pi());
1335               if(fProtonAnalysisBase->GetEtaMode()) {
1336                 ((TH3F *)(fQA2DList->At(16)))->Fill(track->Eta(),
1337                                                     track->Pt(),
1338                                                     dca[0]);
1339                 ((TH3F *)(fQA2DList->At(17)))->Fill(track->Eta(),
1340                                                     track->Pt(),
1341                                                     dca[1]);
1342                 ((TH3F *)(fQA2DList->At(19)))->Fill(track->Eta(),
1343                                                     track->Pt(),
1344                                                     TMath::Abs(dca3D));
1345               }
1346               else {
1347                 ((TH3F *)(fQA2DList->At(16)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),track->Py(),track->Pz()),
1348                                                     track->Pt(),
1349                                                     dca[0]);
1350                 ((TH3F *)(fQA2DList->At(17)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),track->Py(),track->Pz()),
1351                                                     track->Pt(),
1352                                                     dca[1]);
1353                 ((TH3F *)(fQA2DList->At(19)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),track->Py(),track->Pz()),
1354                                                     track->Pt(),
1355                                                     TMath::Abs(dca3D));
1356               }
1357             }//antiprotons
1358             
1359             //Step: kStepInPhaseSpace
1360             if(fProtonAnalysisBase->IsInPhaseSpace(track)) {
1361               if(track->Charge() > 0) {
1362                 nSurvivedProtons += 1;
1363                 fHistYPtProtons->Fill(containerInput[0],
1364                                       containerInput[1]);
1365                 fProtonContainer->Fill(containerInput,kStepInPhaseSpace);   
1366               }//protons
1367               else if(track->Charge() < 0) {
1368                 nSurvivedAntiProtons += 1;
1369                 fHistYPtAntiProtons->Fill(containerInput[0],
1370                                           containerInput[1]);
1371                 fAntiProtonContainer->Fill(containerInput,kStepInPhaseSpace);
1372               }//antiprotons
1373             }//Step: kStepInPhaseSpace
1374           }//Step: kStepSurvived
1375         }//Step: kStepIsPrimary
1376       }//Step: kStepIdentified
1377     }//Global tracking
1378   }//track loop 
1379   
1380   if((nIdentifiedProtons > 0)||(nIdentifiedAntiProtons > 0))
1381     fHistEvents->Fill(2); //number of analyzed events with at least one (anti)proton
1382
1383   if(fProtonAnalysisBase->GetDebugMode())
1384     Printf("Initial number of tracks: %d | Identified (anti)protons: %d - %d | Survived (anti)protons: %d - %d",nTracks,nIdentifiedProtons,nIdentifiedAntiProtons,nSurvivedProtons,nSurvivedAntiProtons);
1385 }
1386
1387 //____________________________________________________________________//
1388 void AliProtonAnalysis::Analyze(AliAODEvent* const fAOD) {
1389   //Main analysis part - AOD
1390   fHistEvents->Fill(1); //number of analyzed events
1391   Int_t nTracks = fAOD->GetNumberOfTracks();
1392   for(Int_t iTracks = 0; iTracks < nTracks; iTracks++) {
1393     AliAODTrack* track = fAOD->GetTrack(iTracks);
1394     Double_t gPt = track->Pt();
1395     Double_t gP = track->P();
1396     
1397     //pid
1398     Double_t probability[10];
1399     track->GetPID(probability);
1400     Double_t rcc = 0.0;
1401     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) rcc += probability[i]*fProtonAnalysisBase->GetParticleFraction(i,gP);
1402     if(rcc == 0.0) continue;
1403     Double_t w[10];
1404     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) w[i] = probability[i]*fProtonAnalysisBase->GetParticleFraction(i,gP)/rcc;
1405     Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIESN,w);
1406     if(fParticleType == 4) {
1407       if(track->Charge() > 0) 
1408         fHistYPtProtons->Fill(track->Y(fParticleType),gPt);
1409       else if(track->Charge() < 0) 
1410         fHistYPtAntiProtons->Fill(track->Y(fParticleType),gPt);
1411     }//proton check
1412   }//track loop 
1413 }
1414
1415 //____________________________________________________________________//
1416 void AliProtonAnalysis::Analyze(AliStack* const stack, 
1417                                 Bool_t iInclusive) {
1418   //Main analysis part - MC
1419   fHistEvents->Fill(1); //number of analyzed events
1420
1421   Int_t nParticles = 0;
1422   //inclusive protons - 
1423   if(iInclusive) nParticles = stack->GetNtrack();
1424   else nParticles = stack->GetNprimary();
1425
1426   for(Int_t i = 0; i < nParticles; i++) {
1427     TParticle *particle = stack->Particle(i);
1428     if(!particle) continue;
1429
1430     //in case of inclusive protons reject the secondaries from hadronic inter.
1431     if(particle->GetUniqueID() == 13) continue;
1432
1433     if(TMath::Abs(particle->Eta()) > 1.0) continue;
1434     if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
1435     if((fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
1436
1437     Int_t pdgcode = particle->GetPdgCode();
1438     if(pdgcode == 2212) fHistYPtProtons->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
1439                                                                             particle->Py(),
1440                                                                             particle->Pz()),
1441                                               particle->Pt());
1442     if(pdgcode == -2212) fHistYPtAntiProtons->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
1443                                                                                  particle->Py(),
1444                                                                                  particle->Pz()),
1445                                                    particle->Pt());
1446   }//particle loop
1447 }
1448
1449 //____________________________________________________________________//
1450 Bool_t AliProtonAnalysis::PrintMean(TH1 *hist, Double_t edge) {
1451   //calculates the mean value of the ratio/asymmetry within \pm edge
1452   Double_t sum = 0.0, sumError = 0.0;
1453   Int_t nentries = 0;
1454   //calculate the mean
1455   for(Int_t i = 1; i <= hist->GetXaxis()->GetNbins(); i++) {
1456     Double_t x = hist->GetBinCenter(i);
1457     Double_t y = hist->GetBinContent(i);
1458     if(TMath::Abs(x) < edge) {
1459       sum += y;
1460       sumError += TMath::Power(hist->GetBinError(i),2);
1461       nentries += 1;
1462     }
1463     //Printf("eta: %lf - sum: %lf - sumError: %lf - counter: %d",
1464     //TMath::Abs(x),sum,sumError,nentries);
1465   }
1466   Double_t mean = 0.0;
1467   Double_t error = 0.0;
1468   if(nentries != 0) {
1469     mean = sum/nentries;
1470     error =  TMath::Sqrt(sumError)/nentries;
1471   }
1472
1473   //calculate the error
1474     /*for(Int_t i = 1; i <= hist->GetXaxis()->GetNbins(); i++) {
1475     Double_t x = hist->GetBinCenter(i);
1476     Double_t y = hist->GetBinContent(i);
1477     if(TMath::Abs(x) < edge) {
1478       sum += TMath::Power((mean - y),2);
1479       nentries += 1;
1480     }
1481     }*/
1482
1483
1484   cout<<"========================================="<<endl;
1485   cout<<"Input distribution: "<<hist->GetName()<<endl;
1486   cout<<"Interval used: -"<<edge<<" -> "<<edge<<endl;
1487   cout<<"Mean value :"<<mean<<endl;
1488   cout<<"Error: "<<error<<endl;
1489   cout<<"========================================="<<endl;
1490
1491   return 0;
1492 }
1493
1494 //____________________________________________________________________//
1495 Bool_t AliProtonAnalysis::PrintYields(TH1 *hist, Double_t edge) {
1496   //calculates the (anti)proton yields within the \pm edge
1497   Double_t sum = 0.0, sumerror = 0.0;
1498   Double_t error = 0.0;
1499   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1500     Double_t x = hist->GetBinCenter(i+1);
1501     Double_t y = hist->GetBinContent(i+1);
1502     if(TMath::Abs(x) < edge) {
1503       sum += y;
1504       sumerror += TMath::Power(hist->GetBinError(i+1),2); 
1505     }
1506   }
1507
1508   error = TMath::Sqrt(sumerror);
1509
1510   cout<<"========================================="<<endl;
1511   cout<<"Input distribution: "<<hist->GetName()<<endl;
1512   cout<<"Interval used: -"<<edge<<" -> "<<edge<<endl;
1513   cout<<"Yields :"<<sum<<endl;
1514   cout<<"Error: "<<error<<endl;
1515   cout<<"========================================="<<endl;
1516
1517   return 0;
1518 }
1519
1520 //____________________________________________________________________//
1521 void AliProtonAnalysis::SetCorrectionMapForSecondaries(const char* filename) {
1522   //Reads the file with the correction maps for the secondaries
1523   TFile *gCorrectionForSecondaries = TFile::Open(filename);
1524   if(!gCorrectionForSecondaries) {
1525     Printf("The TFile object is not valid!!!");
1526     return;
1527   }
1528   if(!gCorrectionForSecondaries->IsOpen()) {
1529     Printf("The file is not found!!!");
1530     return;
1531   }
1532
1533   fHistYPtCorrectionForSecondaries = dynamic_cast<TH2D *>(gCorrectionForSecondaries->Get("gHistCorrectionForSecondaries"));
1534   fCorrectForSecondariesFlag = kTRUE;
1535 }
1536
1537 //____________________________________________________________________//
1538 void AliProtonAnalysis::SetCorrectionMapForCrossSection(const char* filename) {
1539   //Reads the file with the correction maps for the proper x-section
1540   TFile *gCorrectionForXSection = TFile::Open(filename);
1541   if(!gCorrectionForXSection) {
1542     Printf("The TFile object is not valid!!!");
1543     return;
1544   }
1545   if(!gCorrectionForXSection->IsOpen()) {
1546     Printf("The file is not found!!!");
1547     return;
1548   }
1549
1550   fHistCorrectionForCrossSectionYPtProtons = dynamic_cast<TH2D *>(gCorrectionForXSection->Get("gHistCorrectionForCrossSectionProtons"));
1551   fHistCorrectionForCrossSectionYPtAntiProtons = dynamic_cast<TH2D *>(gCorrectionForXSection->Get("gHistCorrectionForCrossSectionAntiProtons"));
1552   fHistCorrectionForCrossSectionFlag = kTRUE;
1553 }
1554
1555 //____________________________________________________________________//
1556 void AliProtonAnalysis::Correct() {
1557   //Apply the corrections: Fast & dirty way for the absorption corrections
1558   //Correct the protons for the efficiency
1559   fHistYPtProtonsCorrected = fProtonContainer->ShowProjection(0,1,kStepInPhaseSpace);
1560   fHistYPtProtonsCorrected->Divide(fHistEfficiencyYPtProtons);
1561   //Correct the protons for proper cross-section
1562   if(fHistCorrectionForCrossSectionFlag)
1563     fHistYPtProtonsCorrected->Multiply(fHistCorrectionForCrossSectionYPtProtons);
1564   //Correct the protons for secondaries
1565   if(fCorrectForSecondariesFlag)
1566     fHistYPtProtonsCorrected->Divide(fHistYPtCorrectionForSecondaries);
1567
1568   //Correct the antiprotons for the efficiency
1569   fHistYPtAntiProtonsCorrected = fAntiProtonContainer->ShowProjection(0,1,kStepInPhaseSpace);
1570   fHistYPtAntiProtonsCorrected->Divide(fHistEfficiencyYPtAntiProtons);
1571   //Correct the antiprotons for proper cross-section
1572   if(fHistCorrectionForCrossSectionFlag)
1573     fHistYPtAntiProtonsCorrected->Multiply(fHistCorrectionForCrossSectionYPtAntiProtons);
1574 }
1575
1576 //____________________________________________________________________//
1577 void AliProtonAnalysis::Correct(Int_t step) {
1578   //Applies the correction maps to the initial containers
1579   fCorrectProtons = new AliCFDataGrid("correctProtons",
1580                                       "corrected data",
1581                                       *fProtonContainer);
1582   fCorrectProtons->SetMeasured(0);
1583   fCorrectProtons->ApplyEffCorrection(*(AliCFEffGrid *)fEffGridListProtons->At(step));
1584
1585   fCorrectAntiProtons = new AliCFDataGrid("correctAntiProtons",
1586                                           "corrected data",
1587                                           *fAntiProtonContainer);
1588   fCorrectAntiProtons->SetMeasured(0);
1589   fCorrectAntiProtons->ApplyEffCorrection(*(AliCFEffGrid *)fEffGridListAntiProtons->At(step));
1590 }
1591
1592 //____________________________________________________________________//
1593 Bool_t AliProtonAnalysis::ReadCorrectionContainer(const char* filename) {
1594   // Reads the outout of the correction framework task
1595   // Creates the correction maps
1596   // Puts the results in the different TList objects
1597   Bool_t status = kTRUE;
1598
1599   TFile *file = TFile::Open(filename);
1600   if(!file) {
1601     cout<<"Could not find the input CORRFW file "<<filename<<endl;
1602     status = kFALSE;
1603   }
1604   TList *list = dynamic_cast<TList *>(file->Get("outputList"));
1605   Int_t iRap = 0, iPt = 1;
1606
1607   //Calculation of efficiency/correction: Protons
1608   AliCFContainer *gProtonContainer = dynamic_cast<AliCFContainer *>(list->At(0));
1609   AliCFEffGrid *effProtonsStep0Step2 = new AliCFEffGrid("eff20",
1610                                                         "effProtonsStep0Step2",
1611                                                         *gProtonContainer);
1612   effProtonsStep0Step2->CalculateEfficiency(2,0); 
1613   fHistEfficiencyYPtProtons = effProtonsStep0Step2->Project(iRap,iPt);
1614   fHistEfficiencyYPtProtons->Sumw2();
1615
1616   //Calculation of efficiency/correction: Protons
1617   AliCFContainer *gAntiProtonContainer = dynamic_cast<AliCFContainer *>(list->At(1));
1618   AliCFEffGrid *effAntiProtonsStep0Step2 = new AliCFEffGrid("eff20",
1619                                                             "effAntiProtonsStep0Step2",
1620                                                             *gAntiProtonContainer);
1621   effAntiProtonsStep0Step2->CalculateEfficiency(2,0); 
1622   fHistEfficiencyYPtAntiProtons = effAntiProtonsStep0Step2->Project(iRap,iPt);
1623   fHistEfficiencyYPtAntiProtons->Sumw2();
1624
1625   Correct();
1626
1627   return status;
1628 }
1629
1630 //____________________________________________________________________//
1631 /*Bool_t AliProtonAnalysis::ReadCorrectionContainer(const char* filename) {
1632   // Reads the outout of the correction framework task
1633   // Creates the correction maps
1634   // Puts the results in the different TList objects
1635   Bool_t status = kTRUE;
1636
1637   TFile *file = TFile::Open(filename);
1638   if(!file) {
1639     cout<<"Could not find the input CORRFW file "<<filename<<endl;
1640     status = kFALSE;
1641   }
1642
1643   //________________________________________//
1644   //Protons
1645   fEffGridListProtons = new TList();
1646   fCorrectionListProtons2D = new TList(); 
1647   fEfficiencyListProtons1D = new TList(); 
1648   fCorrectionListProtons1D = new TList();
1649   
1650   AliCFContainer *corrfwContainerProtons = (AliCFContainer*) (file->Get("containerProtons"));
1651   if(!corrfwContainerProtons) {
1652     cout<<"CORRFW container for protons not found!"<<endl;
1653     status = kFALSE;
1654   }
1655   
1656   Int_t nSteps = corrfwContainerProtons->GetNStep();
1657   TH2D *gYPt[4];
1658   //currently the GRID is formed by the y-pT parameters
1659   //Add Vz as a next step
1660   Int_t iRap = 0, iPt = 1;
1661   AliCFEffGrid *effProtonsStep0Step1 = new AliCFEffGrid("eff10",
1662                                          "effProtonsStep0Step1",
1663                                          *corrfwContainerProtons);
1664   effProtonsStep0Step1->CalculateEfficiency(1,0); //eff= step1/step0
1665   fEffGridListProtons->Add(effProtonsStep0Step1);
1666   gYPt[0] = effProtonsStep0Step1->Project(iRap,iPt);
1667   fCorrectionListProtons2D->Add(gYPt[0]);
1668   
1669   AliCFEffGrid *effProtonsStep0Step2 = new AliCFEffGrid("eff20",
1670                                          "effProtonsStep0Step2",
1671                                          *corrfwContainerProtons);
1672   effProtonsStep0Step2->CalculateEfficiency(2,0); //eff= step2/step0
1673   fEffGridListProtons->Add(effProtonsStep0Step2);
1674   gYPt[1] = effProtonsStep0Step2->Project(iRap,iPt);
1675   fCorrectionListProtons2D->Add(gYPt[1]);
1676
1677   AliCFEffGrid *effProtonsStep0Step3 = new AliCFEffGrid("eff30",
1678                                          "effProtonsStep0Step3",
1679                                          *corrfwContainerProtons);
1680   effProtonsStep0Step3->CalculateEfficiency(3,0); //eff= step1/step0
1681   fEffGridListProtons->Add(effProtonsStep0Step3);
1682   gYPt[2] = effProtonsStep0Step3->Project(iRap,iPt);
1683   fCorrectionListProtons2D->Add(gYPt[2]);
1684
1685   TH1D *gEfficiency[2][3]; //efficiency as a function of pT and of y (raws-[2])
1686   TH1D *gCorrection[2][3]; //efficiency as a function of pT and of y (raws-[2])
1687   TString gTitle;
1688   //Get the projection of the efficiency maps
1689   for(Int_t iParameter = 0; iParameter < 2; iParameter++) {
1690     gEfficiency[iParameter][0] = effProtonsStep0Step1->Project(iParameter);
1691     gTitle = "ProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1692     gTitle += "_Step0_Step1"; 
1693     gEfficiency[iParameter][0]->SetName(gTitle.Data());
1694     fEfficiencyListProtons1D->Add(gEfficiency[iParameter][0]);  
1695     gTitle = "ProtonsCorrection_Parameter"; gTitle += iParameter+1;
1696     gTitle += "_Step0_Step1"; 
1697     gCorrection[iParameter][0] = new TH1D(gTitle.Data(),
1698                                           gTitle.Data(),
1699                                           gEfficiency[iParameter][0]->GetNbinsX(),
1700                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmin(),
1701                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmax());
1702     //initialisation of the correction
1703     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][0]->GetNbinsX(); iBin++)
1704       gCorrection[iParameter][0]->SetBinContent(iBin,1.0);
1705
1706     gEfficiency[iParameter][1] = effProtonsStep0Step2->Project(iParameter);
1707     gTitle = "ProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1708     gTitle += "_Step0_Step2"; 
1709     gEfficiency[iParameter][1]->SetName(gTitle.Data());
1710     fEfficiencyListProtons1D->Add(gEfficiency[iParameter][1]);  
1711     gTitle = "ProtonsCorrection_Parameter"; gTitle += iParameter+1;
1712     gTitle += "_Step0_Step2"; 
1713     gCorrection[iParameter][1] = new TH1D(gTitle.Data(),
1714                                           gTitle.Data(),
1715                                           gEfficiency[iParameter][1]->GetNbinsX(),
1716                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmin(),
1717                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmax());
1718     //initialisation of the correction
1719     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][1]->GetNbinsX(); iBin++)
1720       gCorrection[iParameter][1]->SetBinContent(iBin,1.0);
1721
1722     gEfficiency[iParameter][2] = effProtonsStep0Step3->Project(iParameter);
1723     gTitle = "ProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1724     gTitle += "_Step0_Step3"; 
1725     gEfficiency[iParameter][2]->SetName(gTitle.Data());
1726     fEfficiencyListProtons1D->Add(gEfficiency[iParameter][2]);  
1727     gTitle = "ProtonsCorrection_Parameter"; gTitle += iParameter+1;
1728     gTitle += "_Step0_Step3"; 
1729     gCorrection[iParameter][2] = new TH1D(gTitle.Data(),
1730                                           gTitle.Data(),
1731                                           gEfficiency[iParameter][2]->GetNbinsX(),
1732                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmin(),
1733                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmax());
1734     //initialisation of the correction
1735     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][2]->GetNbinsX(); iBin++)
1736       gCorrection[iParameter][2]->SetBinContent(iBin,1.0);
1737   }//parameter loop
1738   //Calculate the 1D correction parameters as a function of y and pT
1739   for(Int_t iParameter = 0; iParameter < 2; iParameter++) { 
1740     for(Int_t iStep = 1; iStep < nSteps; iStep++) { 
1741       gCorrection[iParameter][iStep-1]->Divide(gEfficiency[iParameter][iStep-1]);
1742       fCorrectionListProtons1D->Add(gCorrection[iParameter][iStep-1]);  
1743     }
1744   }
1745
1746   //________________________________________//
1747   //AntiProtons
1748   fEffGridListAntiProtons = new TList();
1749   fCorrectionListAntiProtons2D = new TList(); 
1750   fEfficiencyListAntiProtons1D = new TList(); 
1751   fCorrectionListAntiProtons1D = new TList();
1752   
1753   AliCFContainer *corrfwContainerAntiProtons = (AliCFContainer*) (file->Get("containerAntiProtons"));
1754   if(!corrfwContainerAntiProtons) {
1755     cout<<"CORRFW container for antiprotons not found!"<<endl;
1756     status = kFALSE;
1757   }
1758   
1759   nSteps = corrfwContainerAntiProtons->GetNStep();
1760   //currently the GRID is formed by the y-pT parameters
1761   //Add Vz as a next step
1762   AliCFEffGrid *effAntiProtonsStep0Step1 = new AliCFEffGrid("eff10",
1763                                          "effAntiProtonsStep0Step1",
1764                                          *corrfwContainerAntiProtons);
1765   effAntiProtonsStep0Step1->CalculateEfficiency(1,0); //eff= step1/step0
1766   fEffGridListAntiProtons->Add(effAntiProtonsStep0Step1);
1767   gYPt[0] = effAntiProtonsStep0Step1->Project(iRap,iPt);
1768   fCorrectionListAntiProtons2D->Add(gYPt[0]);
1769   
1770   AliCFEffGrid *effAntiProtonsStep0Step2 = new AliCFEffGrid("eff20",
1771                                          "effAntiProtonsStep0Step2",
1772                                          *corrfwContainerAntiProtons);
1773   effAntiProtonsStep0Step2->CalculateEfficiency(2,0); //eff= step2/step0
1774   fEffGridListAntiProtons->Add(effAntiProtonsStep0Step2);
1775   gYPt[1] = effAntiProtonsStep0Step2->Project(iRap,iPt);
1776   fCorrectionListAntiProtons2D->Add(gYPt[1]);
1777
1778   AliCFEffGrid *effAntiProtonsStep0Step3 = new AliCFEffGrid("eff30",
1779                                          "effAntiProtonsStep0Step3",
1780                                          *corrfwContainerAntiProtons);
1781   effAntiProtonsStep0Step3->CalculateEfficiency(3,0); //eff= step1/step0
1782   fEffGridListAntiProtons->Add(effAntiProtonsStep0Step3);
1783   gYPt[2] = effAntiProtonsStep0Step3->Project(iRap,iPt);
1784   fCorrectionListAntiProtons2D->Add(gYPt[2]);
1785
1786   //Get the projection of the efficiency maps
1787   for(Int_t iParameter = 0; iParameter < 2; iParameter++) {
1788     gEfficiency[iParameter][0] = effAntiProtonsStep0Step1->Project(iParameter);
1789     gTitle = "AntiProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1790     gTitle += "_Step0_Step1"; 
1791     gEfficiency[iParameter][0]->SetName(gTitle.Data());
1792     fEfficiencyListAntiProtons1D->Add(gEfficiency[iParameter][0]);  
1793     gTitle = "AntiProtonsCorrection_Parameter"; gTitle += iParameter+1;
1794     gTitle += "_Step0_Step1"; 
1795     gCorrection[iParameter][0] = new TH1D(gTitle.Data(),
1796                                           gTitle.Data(),
1797                                           gEfficiency[iParameter][0]->GetNbinsX(),
1798                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmin(),
1799                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmax());
1800     //initialisation of the correction
1801     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][0]->GetNbinsX(); iBin++)
1802       gCorrection[iParameter][0]->SetBinContent(iBin,1.0);
1803
1804     gEfficiency[iParameter][1] = effAntiProtonsStep0Step2->Project(iParameter);
1805     gTitle = "AntiProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1806     gTitle += "_Step0_Step2"; 
1807     gEfficiency[iParameter][1]->SetName(gTitle.Data());
1808     fEfficiencyListAntiProtons1D->Add(gEfficiency[iParameter][1]);  
1809     gTitle = "AntiProtonsCorrection_Parameter"; gTitle += iParameter+1;
1810     gTitle += "_Step0_Step2"; 
1811     gCorrection[iParameter][1] = new TH1D(gTitle.Data(),
1812                                           gTitle.Data(),
1813                                           gEfficiency[iParameter][1]->GetNbinsX(),
1814                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmin(),
1815                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmax());
1816     //initialisation of the correction
1817     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][1]->GetNbinsX(); iBin++)
1818       gCorrection[iParameter][1]->SetBinContent(iBin,1.0);
1819
1820     gEfficiency[iParameter][2] = effAntiProtonsStep0Step3->Project(iParameter);
1821     gTitle = "AntiProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1822     gTitle += "_Step0_Step3"; 
1823     gEfficiency[iParameter][2]->SetName(gTitle.Data());
1824     fEfficiencyListAntiProtons1D->Add(gEfficiency[iParameter][2]);  
1825     gTitle = "AntiProtonsCorrection_Parameter"; gTitle += iParameter+1;
1826     gTitle += "_Step0_Step3"; 
1827     gCorrection[iParameter][2] = new TH1D(gTitle.Data(),
1828                                           gTitle.Data(),
1829                                           gEfficiency[iParameter][2]->GetNbinsX(),
1830                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmin(),
1831                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmax());
1832     //initialisation of the correction
1833     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][2]->GetNbinsX(); iBin++)
1834       gCorrection[iParameter][2]->SetBinContent(iBin,1.0);
1835   }//parameter loop
1836   //Calculate the 1D correction parameters as a function of y and pT
1837   for(Int_t iParameter = 0; iParameter < 2; iParameter++) { 
1838     for(Int_t iStep = 1; iStep < nSteps; iStep++) { 
1839       gCorrection[iParameter][iStep-1]->Divide(gEfficiency[iParameter][iStep-1]);
1840       fCorrectionListAntiProtons1D->Add(gCorrection[iParameter][iStep-1]);  
1841     }
1842   }
1843
1844   return status;
1845   }*/
1846  
1847 //____________________________________________________________________//
1848 void AliProtonAnalysis::InitQA() {
1849   //Applies the correction maps to the initial containers
1850   fInitQAFlag = kTRUE;
1851   fGlobalQAList = new TList();
1852   fGlobalQAList->SetName("fGlobalQAList");
1853
1854   //========================================================//
1855   fQA2DList = new TList();
1856   fQA2DList->SetName("fQA2DList");
1857   fGlobalQAList->Add(fQA2DList);
1858
1859   //dEdx plots
1860   TH2F *gHistdEdxP = new TH2F("gHistdEdxP","dE/dx (TPC); P [GeV/c]; dE/dx [a.u]",1000,0.05,20.05,600,0,600);
1861   fQA2DList->Add(gHistdEdxP);
1862   TH2F *gHistProtonsdEdxP = new TH2F("gHistProtonsdEdxP","Accepted protons dE/dx (TPC); P [GeV/c]; dE/dx [a.u]",1000,0.05,20.05,600,0,600);
1863   fQA2DList->Add(gHistProtonsdEdxP);
1864
1865   //normalized dEdx plots
1866   TH2F *gHistZP = new TH2F("gHistZP","Normalized dE/dx (TPC); P [GeV/c]; ln[(dE/dx)_{exp.}/(dE/dx)_{BB}] ",1000,0.05,20.05,100,-2.0,2.0);
1867   fQA2DList->Add(gHistZP);
1868   TH2F *gHistProtonsZP = new TH2F("gHistProtonsZP","Normalized dE/dx (TPC); P [GeV/c]; ln[(dE/dx)_{exp.}/(dE/dx)_{BB}] ",1000,0.05,20.05,100,-2.0,2.0);
1869   fQA2DList->Add(gHistProtonsZP);
1870
1871   //eta-phi-Npoints(dEdx)
1872   TH3F *gHistEtaPhiTPCdEdxNPoints = new TH3F("gHistEtaPhiTPCdEdxNPoints",
1873                                              ";#eta;#phi;N_{points}(TPC)",
1874                                              18,-0.9,0.9,
1875                                              180,0,360,
1876                                              100,0,200);
1877   gHistEtaPhiTPCdEdxNPoints->SetStats(kTRUE);
1878   fQA2DList->Add(gHistEtaPhiTPCdEdxNPoints);
1879   TH3F *gHistProtonsEtaPhiTPCdEdxNPoints = new TH3F("gHistProtonsEtaPhiTPCdEdxNPoints",
1880                                                     ";#eta;#phi;N_{points}(TPC)",
1881                                                     18,-0.9,0.9,
1882                                                     180,0,360,
1883                                                     100,0,200);
1884   gHistProtonsEtaPhiTPCdEdxNPoints->SetStats(kTRUE);
1885   fQA2DList->Add(gHistProtonsEtaPhiTPCdEdxNPoints);
1886
1887   //eta-phi-Npoints
1888   TH3F *gHistEtaPhiTPCNPoints = new TH3F("gHistEtaPhiTPCNPoints",
1889                                          ";#eta;#phi;N_{points}(TPC)",
1890                                          18,-0.9,0.9,
1891                                          180,0,360,
1892                                          100,0,200);
1893   gHistEtaPhiTPCNPoints->SetStats(kTRUE);
1894   fQA2DList->Add(gHistEtaPhiTPCNPoints);
1895   TH3F *gHistProtonsEtaPhiTPCNPoints = new TH3F("gHistProtonsEtaPhiTPCNPoints",
1896                                                 ";#eta;#phi;N_{points}(TPC)",
1897                                                 18,-0.9,0.9,
1898                                                 180,0,360,
1899                                                 100,0,200);
1900   gHistProtonsEtaPhiTPCNPoints->SetStats(kTRUE);
1901   fQA2DList->Add(gHistProtonsEtaPhiTPCNPoints);
1902
1903   //pt-phi-Npoints(dEdx)
1904   TH3F *gHistPtPhiTPCdEdxNPoints = new TH3F("gHistPtPhiTPCdEdxNPoints",
1905                                             ";P_{T} [GeV/c];#phi;N_{points}(TPC)",
1906                                             fNBinsPt,fMinPt,fMaxPt,
1907                                             180,0,360,
1908                                             100,0,200);
1909   gHistPtPhiTPCdEdxNPoints->SetStats(kTRUE);
1910   fQA2DList->Add(gHistPtPhiTPCdEdxNPoints);
1911   TH3F *gHistProtonsPtPhiTPCdEdxNPoints = new TH3F("gHistProtonsPtPhiTPCdEdxNPoints",
1912                                                     ";P_{T} [GeV/c];#phi;N_{points}(TPC)",
1913                                                     fNBinsPt,fMinPt,fMaxPt,
1914                                                     180,0,360,
1915                                                     100,0,200);
1916   gHistProtonsPtPhiTPCdEdxNPoints->SetStats(kTRUE);
1917   fQA2DList->Add(gHistProtonsPtPhiTPCdEdxNPoints);
1918
1919   //pt-phi-Npoints
1920   TH3F *gHistPtPhiTPCNPoints = new TH3F("gHistPtPhiTPCNPoints",
1921                                         ";P_{T} [GeV/c];#phi;N_{points}(TPC)",
1922                                         fNBinsPt,fMinPt,fMaxPt,
1923                                         180,0,360,
1924                                         100,0,200);
1925   gHistPtPhiTPCNPoints->SetStats(kTRUE);
1926   fQA2DList->Add(gHistPtPhiTPCNPoints);
1927   TH3F *gHistProtonsPtPhiTPCNPoints = new TH3F("gHistProtonsPtPhiTPCNPoints",
1928                                                ";P_{T} [GeV/c];#phi;N_{points}(TPC)",
1929                                                fNBinsPt,fMinPt,fMaxPt,
1930                                                180,0,360,
1931                                                100,0,200);
1932   gHistProtonsPtPhiTPCNPoints->SetStats(kTRUE);
1933   fQA2DList->Add(gHistProtonsPtPhiTPCNPoints);
1934
1935   //eta-phi for protons & antiprotons
1936   TH2F *gHistProtonsEtaPhi = new TH2F("gHistProtonsEtaPhi",
1937                                       ";#eta;#phi",
1938                                       18,-0.9,0.9,
1939                                       180,0,360);
1940   gHistProtonsEtaPhi->SetStats(kTRUE);
1941   fQA2DList->Add(gHistProtonsEtaPhi);
1942   TH2F *gHistAntiProtonsEtaPhi = new TH2F("gHistAntiProtonsEtaPhi",
1943                                           ";#eta;#phi",
1944                                           18,-0.9,0.9,
1945                                           180,0,360);
1946   gHistAntiProtonsEtaPhi->SetStats(kTRUE);
1947   fQA2DList->Add(gHistAntiProtonsEtaPhi);
1948
1949   //dca vs pT for protons & antiprotons
1950   TH3F *gHistProtonsDCAxyEtaPt = new TH3F("gHistProtonsDCAxyEtaPt",
1951                                           ";P_{T} [GeV/c];dca_{xy} [cm]",
1952                                           fNBinsY,fMinY,fMaxY,
1953                                           fNBinsPt,fMinPt,fMaxPt,
1954                                           400,-10.,10.);
1955   if(fProtonAnalysisBase->GetEtaMode())
1956     gHistProtonsDCAxyEtaPt->GetXaxis()->SetTitle("#eta");
1957   else
1958     gHistProtonsDCAxyEtaPt->GetXaxis()->SetTitle("y");
1959   gHistProtonsDCAxyEtaPt->SetStats(kTRUE);
1960   fQA2DList->Add(gHistProtonsDCAxyEtaPt);
1961   TH3F *gHistProtonsDCAzEtaPt = new TH3F("gHistProtonsDCAzEtaPt",
1962                                          ";P_{T} [GeV/c];dca_{z} [cm]",
1963                                          fNBinsY,fMinY,fMaxY,
1964                                          fNBinsPt,fMinPt,fMaxPt,
1965                                          400,-10.,10.);
1966   if(fProtonAnalysisBase->GetEtaMode())
1967     gHistProtonsDCAzEtaPt->GetXaxis()->SetTitle("#eta");
1968   else
1969     gHistProtonsDCAzEtaPt->GetXaxis()->SetTitle("y");
1970   gHistProtonsDCAzEtaPt->SetStats(kTRUE);
1971   fQA2DList->Add(gHistProtonsDCAzEtaPt);
1972   TH3F *gHistAntiProtonsDCAxyEtaPt = new TH3F("gHistAntiProtonsDCAxyEtaPt",
1973                                               ";P_{T} [GeV/c];dca_{xy} [cm]",
1974                                               fNBinsY,fMinY,fMaxY,
1975                                               fNBinsPt,fMinPt,fMaxPt,
1976                                               400,-10.,10.);
1977   if(fProtonAnalysisBase->GetEtaMode())
1978     gHistAntiProtonsDCAxyEtaPt->GetXaxis()->SetTitle("#eta");
1979   else
1980     gHistAntiProtonsDCAxyEtaPt->GetXaxis()->SetTitle("y");
1981   gHistAntiProtonsDCAxyEtaPt->SetStats(kTRUE);
1982   fQA2DList->Add(gHistAntiProtonsDCAxyEtaPt);
1983   TH3F *gHistAntiProtonsDCAzEtaPt = new TH3F("gHistAntiProtonsDCAzEtaPt",
1984                                              ";P_{T} [GeV/c];dca_{z} [cm]",
1985                                              fNBinsY,fMinY,fMaxY,
1986                                              fNBinsPt,fMinPt,fMaxPt,
1987                                              400,-10.,10.);
1988   if(fProtonAnalysisBase->GetEtaMode())
1989     gHistAntiProtonsDCAzEtaPt->GetXaxis()->SetTitle("#eta");
1990   else
1991     gHistAntiProtonsDCAzEtaPt->GetXaxis()->SetTitle("y");
1992   gHistAntiProtonsDCAzEtaPt->SetStats(kTRUE);
1993   fQA2DList->Add(gHistAntiProtonsDCAzEtaPt);
1994
1995   TH3F *gHistProtonsDCA3DEtaPt = new TH3F("gHistProtonsDCA3DEtaPt",
1996                                           ";P_{T} [GeV/c];dca [cm]",
1997                                           fNBinsY,fMinY,fMaxY,
1998                                           fNBinsPt,fMinPt,fMaxPt,
1999                                           100,0,20);
2000   if(fProtonAnalysisBase->GetEtaMode())
2001     gHistProtonsDCA3DEtaPt->GetXaxis()->SetTitle("#eta");
2002   else
2003     gHistProtonsDCA3DEtaPt->GetXaxis()->SetTitle("y");
2004   gHistProtonsDCA3DEtaPt->SetStats(kTRUE);
2005   fQA2DList->Add(gHistProtonsDCA3DEtaPt);
2006   TH3F *gHistAntiProtonsDCA3DEtaPt = new TH3F("gHistAntiProtonsDCA3DEtaPt",
2007                                               ";P_{T} [GeV/c];dca [cm]",
2008                                               fNBinsY,fMinY,fMaxY,
2009                                               fNBinsPt,fMinPt,fMaxPt,
2010                                               100,0,20);
2011   if(fProtonAnalysisBase->GetEtaMode())
2012     gHistAntiProtonsDCA3DEtaPt->GetXaxis()->SetTitle("#eta");
2013   else
2014     gHistAntiProtonsDCA3DEtaPt->GetXaxis()->SetTitle("y");
2015   gHistAntiProtonsDCA3DEtaPt->SetStats(kTRUE);
2016   fQA2DList->Add(gHistAntiProtonsDCA3DEtaPt);
2017
2018   //========================================================//
2019   fQAProtonsAcceptedList = new TList();
2020   fQAProtonsAcceptedList->SetName("fQAProtonsAcceptedList");
2021   fGlobalQAList->Add(fQAProtonsAcceptedList);
2022   //Accepted protons
2023   TH1F *gProtonsITSClustersPass = new TH1F("gProtonsITSClustersPass",
2024                                             ";N_{clusters} (ITS);Entries",
2025                                             7,0,7);
2026   fQAProtonsAcceptedList->Add(gProtonsITSClustersPass);
2027   TH1F *gProtonsChi2PerClusterITSPass = new TH1F("gProtonsChi2PerClusterITSPass",
2028                                                  ";x^{2}/N_{clusters} (ITS);Entries",
2029                                                  100,0,4);
2030   fQAProtonsAcceptedList->Add(gProtonsChi2PerClusterITSPass);
2031   TH1F *gProtonsTPCClustersPass = new TH1F("gProtonsTPCClustersPass",
2032                                            ";N_{clusters} (TPC);Entries",
2033                                            100,0,200);
2034   fQAProtonsAcceptedList->Add(gProtonsTPCClustersPass);
2035   TH1F *gProtonsChi2PerClusterTPCPass = new TH1F("gProtonsChi2PerClusterTPCPass",
2036                                                  ";x^{2}/N_{clusters} (TPC);Entries",
2037                                                  100,0,4);
2038   fQAProtonsAcceptedList->Add(gProtonsChi2PerClusterTPCPass);
2039   TH1F *gProtonsExtCov11Pass = new TH1F("gProtonsExtCov11Pass",
2040                                         ";#sigma_{y} [cm];Entries",
2041                                         100,0,4);
2042   fQAProtonsAcceptedList->Add(gProtonsExtCov11Pass);
2043   TH1F *gProtonsExtCov22Pass = new TH1F("gProtonsExtCov22Pass",
2044                                         ";#sigma_{z} [cm];Entries",
2045                                         100,0,4);
2046   fQAProtonsAcceptedList->Add(gProtonsExtCov22Pass);
2047   TH1F *gProtonsExtCov33Pass = new TH1F("gProtonsExtCov33Pass",
2048                                         ";#sigma_{sin(#phi)};Entries",
2049                                         100,0,4);
2050   fQAProtonsAcceptedList->Add(gProtonsExtCov33Pass);
2051   TH1F *gProtonsExtCov44Pass = new TH1F("gProtonsExtCov44Pass",
2052                                         ";#sigma_{tan(#lambda)};Entries",
2053                                         100,0,4);
2054   fQAProtonsAcceptedList->Add(gProtonsExtCov44Pass);
2055   TH1F *gProtonsExtCov55Pass = new TH1F("gProtonsExtCov55Pass",
2056                                         ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2057                                         100,0,4);
2058   fQAProtonsAcceptedList->Add(gProtonsExtCov55Pass);
2059   TH1F *gProtonsSigmaToVertexPass = new TH1F("gProtonsSigmaToVertexPass",
2060                                              ";#sigma_{Vertex};Entries",
2061                                              100,0.,10.);
2062   fQAProtonsAcceptedList->Add(gProtonsSigmaToVertexPass);
2063   TH1F *gProtonsSigmaToVertexTPCPass = new TH1F("gProtonsSigmaToVertexTPCPass",
2064                                                 ";#sigma_{Vertex};Entries",
2065                                                 100,0.,10.);
2066   fQAProtonsAcceptedList->Add(gProtonsSigmaToVertexTPCPass);
2067   TH1F *gProtonsDCAXYPass = new TH1F("gProtonsDCAXYPass",
2068                                      ";DCA_{xy} [cm];Entries",
2069                                      100,0,20);
2070   fQAProtonsAcceptedList->Add(gProtonsDCAXYPass);
2071   TH1F *gProtonsDCAXYTPCPass = new TH1F("gProtonsDCAXYTPCPass",
2072                                         ";DCA_{xy} [cm];Entries",
2073                                         100,0,20);
2074   fQAProtonsAcceptedList->Add(gProtonsDCAXYTPCPass);
2075   TH1F *gProtonsDCAZPass = new TH1F("gProtonsDCAZPass",
2076                                     ";DCA_{z} [cm];Entries",
2077                                     100,0,20);
2078   fQAProtonsAcceptedList->Add(gProtonsDCAZPass);
2079   TH1F *gProtonsDCAZTPCPass = new TH1F("gProtonsDCAZTPCPass",
2080                                        ";DCA_{z} [cm];Entries",
2081                                        100,0,20);
2082   fQAProtonsAcceptedList->Add(gProtonsDCAZTPCPass);
2083   TH1F *gProtonsConstrainChi2Pass = new TH1F("gProtonsConstrainChi2Pass",
2084                                              ";Log_{10}(#chi^{2});Entries",
2085                                              100,-10,10);
2086   fQAProtonsAcceptedList->Add(gProtonsConstrainChi2Pass);
2087   TH1F *gProtonsITSRefitPass = new TH1F("gProtonsITSRefitPass",
2088                                         "",10,-1,1);
2089   fQAProtonsAcceptedList->Add(gProtonsITSRefitPass);
2090   TH1F *gProtonsTPCRefitPass = new TH1F("gProtonsTPCRefitPass",
2091                                         "",10,-1,1);
2092   fQAProtonsAcceptedList->Add(gProtonsTPCRefitPass);
2093   TH1F *gProtonsESDpidPass = new TH1F("gProtonsESDpidPass",
2094                                       "",10,-1,1);
2095   fQAProtonsAcceptedList->Add(gProtonsESDpidPass);
2096   TH1F *gProtonsTPCpidPass = new TH1F("gProtonsTPCpidPass",
2097                                       "",10,-1,1);
2098   fQAProtonsAcceptedList->Add(gProtonsTPCpidPass);
2099   TH1F *gProtonsPointOnITSLayer1Pass = new TH1F("gProtonsPointOnITSLayer1Pass",
2100                                                 "",10,-1,1);
2101   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer1Pass);
2102   TH1F *gProtonsPointOnITSLayer2Pass = new TH1F("gProtonsPointOnITSLayer2Pass",
2103                                                 "",10,-1,1);
2104   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer2Pass);
2105   TH1F *gProtonsPointOnITSLayer3Pass = new TH1F("gProtonsPointOnITSLayer3Pass",
2106                                                 "",10,-1,1);
2107   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer3Pass);
2108   TH1F *gProtonsPointOnITSLayer4Pass = new TH1F("gProtonsPointOnITSLayer4Pass",
2109                                                 "",10,-1,1);
2110   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer4Pass);
2111   TH1F *gProtonsPointOnITSLayer5Pass = new TH1F("gProtonsPointOnITSLayer5Pass",
2112                                                 "",10,-1,1);
2113   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer5Pass);
2114   TH1F *gProtonsPointOnITSLayer6Pass = new TH1F("gProtonsPointOnITSLayer6Pass",
2115                                                 "",10,-1,1);
2116   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer6Pass);
2117   TH1F *gProtonsNumberOfTPCdEdxPointsPass = new TH1F("gProtonsNumberOfTPCdEdxPointsPass","",100,0,200);
2118   fQAProtonsAcceptedList->Add(gProtonsNumberOfTPCdEdxPointsPass);
2119   TH1F *gProtonsITSClusterMapPass = new TH1F("gProtonsITSClusterMapPass",";ITS Layer;Entries",6,0.5,6.5);
2120   fQAProtonsAcceptedList->Add(gProtonsITSClusterMapPass);
2121   TH1F *gProtonsDCA3DPass = new TH1F("gProtonsDCA3DPass",
2122                                      ";dca [cm];Entries",
2123                                      100,0,20);
2124   fQAProtonsAcceptedList->Add(gProtonsDCA3DPass);
2125
2126   //========================================================//  
2127   fQAProtonsRejectedList = new TList();
2128   fQAProtonsRejectedList->SetName("fQAProtonsRejectedList");
2129   fGlobalQAList->Add(fQAProtonsRejectedList);
2130   //Rejected protons
2131   TH1F *gProtonsITSClustersReject = new TH1F("gProtonsITSClustersReject",
2132                                              ";N_{clusters} (ITS);Entries",
2133                                              7,0,7);
2134   gProtonsITSClustersReject->SetFillColor(kRed-2);
2135   fQAProtonsRejectedList->Add(gProtonsITSClustersReject);
2136   TH1F *gProtonsChi2PerClusterITSReject = new TH1F("gProtonsChi2PerClusterITSReject",
2137                                                    ";x^{2}/N_{clusters} (ITS);Entries",
2138                                                    100,0,4);
2139   gProtonsChi2PerClusterITSReject->SetFillColor(kRed-2);
2140   fQAProtonsRejectedList->Add(gProtonsChi2PerClusterITSReject);
2141   TH1F *gProtonsTPCClustersReject = new TH1F("gProtonsTPCClustersReject",
2142                                              ";N_{clusters} (TPC);Entries",
2143                                              100,0,200);
2144   gProtonsTPCClustersReject->SetFillColor(kRed-2);
2145   fQAProtonsRejectedList->Add(gProtonsTPCClustersReject);
2146   TH1F *gProtonsChi2PerClusterTPCReject = new TH1F("gProtonsChi2PerClusterTPCReject",
2147                                                    ";x^{2}/N_{clusters} (TPC);Entries",
2148                                                    100,0,4);
2149   gProtonsChi2PerClusterTPCReject->SetFillColor(kRed-2);
2150   fQAProtonsRejectedList->Add(gProtonsChi2PerClusterTPCReject);
2151   TH1F *gProtonsExtCov11Reject = new TH1F("gProtonsExtCov11Reject",
2152                                           ";#sigma_{y} [cm];Entries",
2153                                           100,0,4);
2154   gProtonsExtCov11Reject->SetFillColor(kRed-2);
2155   fQAProtonsRejectedList->Add(gProtonsExtCov11Reject);
2156   TH1F *gProtonsExtCov22Reject = new TH1F("gProtonsExtCov22Reject",
2157                                           ";#sigma_{z} [cm];Entries",
2158                                           100,0,4);
2159   gProtonsExtCov22Reject->SetFillColor(kRed-2);
2160   fQAProtonsRejectedList->Add(gProtonsExtCov22Reject);
2161   TH1F *gProtonsExtCov33Reject = new TH1F("gProtonsExtCov33Reject",
2162                                           ";#sigma_{sin(#phi)};Entries",
2163                                           100,0,4);
2164   gProtonsExtCov33Reject->SetFillColor(kRed-2);
2165   fQAProtonsRejectedList->Add(gProtonsExtCov33Reject);
2166   TH1F *gProtonsExtCov44Reject = new TH1F("gProtonsExtCov44Reject",
2167                                           ";#sigma_{tan(#lambda)};Entries",
2168                                           100,0,4);
2169   gProtonsExtCov44Reject->SetFillColor(kRed-2);
2170   fQAProtonsRejectedList->Add(gProtonsExtCov44Reject);
2171   TH1F *gProtonsExtCov55Reject = new TH1F("gProtonsExtCov55Reject",
2172                                           ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2173                                           100,0,4);
2174   gProtonsExtCov55Reject->SetFillColor(kRed-2);
2175   fQAProtonsRejectedList->Add(gProtonsExtCov55Reject);
2176   TH1F *gProtonsSigmaToVertexReject = new TH1F("gProtonsSigmaToVertexReject",
2177                                                ";#sigma_{Vertex};Entries",
2178                                                100,0,10);
2179   gProtonsSigmaToVertexReject->SetFillColor(kRed-2);
2180   fQAProtonsRejectedList->Add(gProtonsSigmaToVertexReject);
2181   TH1F *gProtonsSigmaToVertexTPCReject = new TH1F("gProtonsSigmaToVertexTPCReject",
2182                                                   ";#sigma_{Vertex};Entries",
2183                                                   100,0,10);
2184   gProtonsSigmaToVertexTPCReject->SetFillColor(kRed-2);
2185   fQAProtonsRejectedList->Add(gProtonsSigmaToVertexTPCReject);
2186   TH1F *gProtonsDCAXYReject = new TH1F("gProtonsDCAXYReject",
2187                                        ";DCA_{xy} [cm];Entries",
2188                                        100,0,20);
2189   gProtonsDCAXYReject->SetFillColor(kRed-2);
2190   fQAProtonsRejectedList->Add(gProtonsDCAXYReject);
2191   TH1F *gProtonsDCAXYTPCReject = new TH1F("gProtonsDCAXYTPCReject",
2192                                           ";DCA_{xy} [cm];Entries",
2193                                           100,0,20);
2194   gProtonsDCAXYTPCReject->SetFillColor(kRed-2);
2195   fQAProtonsRejectedList->Add(gProtonsDCAXYTPCReject);
2196   TH1F *gProtonsDCAZReject = new TH1F("gProtonsDCAZReject",
2197                                       ";DCA_{z} [cm];Entries",
2198                                       100,0,20);
2199   gProtonsDCAZReject->SetFillColor(kRed-2);
2200   fQAProtonsRejectedList->Add(gProtonsDCAZReject);
2201   TH1F *gProtonsDCAZTPCReject = new TH1F("gProtonsDCAZTPCReject",
2202                                          ";DCA_{z} [cm];Entries",
2203                                          100,0,20);
2204   gProtonsDCAZTPCReject->SetFillColor(kRed-2);
2205   fQAProtonsRejectedList->Add(gProtonsDCAZTPCReject);
2206   TH1F *gProtonsConstrainChi2Reject = new TH1F("gProtonsConstrainChi2Reject",
2207                                                ";Log_{10}(#chi^{2});Entries",
2208                                                100,-10,10);
2209   gProtonsConstrainChi2Reject->SetFillColor(kRed-2);
2210   fQAProtonsRejectedList->Add(gProtonsConstrainChi2Reject);
2211   TH1F *gProtonsITSRefitReject = new TH1F("gProtonsITSRefitReject",
2212                                           "",10,-1,1);
2213   gProtonsITSRefitReject->SetFillColor(kRed-2);
2214   fQAProtonsRejectedList->Add(gProtonsITSRefitReject);
2215   TH1F *gProtonsTPCRefitReject = new TH1F("gProtonsTPCRefitReject",
2216                                           "",10,-1,1);
2217   gProtonsTPCRefitReject->SetFillColor(kRed-2);
2218   fQAProtonsRejectedList->Add(gProtonsTPCRefitReject);
2219   TH1F *gProtonsESDpidReject = new TH1F("gProtonsESDpidReject",
2220                                         "",10,-1,1);
2221   gProtonsESDpidReject->SetFillColor(kRed-2);
2222   fQAProtonsRejectedList->Add(gProtonsESDpidReject);
2223   TH1F *gProtonsTPCpidReject = new TH1F("gProtonsTPCpidReject",
2224                                         "",10,-1,1);
2225   gProtonsTPCpidReject->SetFillColor(kRed-2);
2226   fQAProtonsRejectedList->Add(gProtonsTPCpidReject);
2227   TH1F *gProtonsPointOnITSLayer1Reject = new TH1F("gProtonsPointOnITSLayer1Reject",
2228                                                   "",10,-1,1);
2229   gProtonsPointOnITSLayer1Reject->SetFillColor(kRed-2);
2230   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer1Reject);
2231   TH1F *gProtonsPointOnITSLayer2Reject = new TH1F("gProtonsPointOnITSLayer2Reject",
2232                                                   "",10,-1,1);
2233   gProtonsPointOnITSLayer2Reject->SetFillColor(kRed-2);
2234   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer2Reject);
2235   TH1F *gProtonsPointOnITSLayer3Reject = new TH1F("gProtonsPointOnITSLayer3Reject",
2236                                                   "",10,-1,1);
2237   gProtonsPointOnITSLayer3Reject->SetFillColor(kRed-2);
2238   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer3Reject);
2239   TH1F *gProtonsPointOnITSLayer4Reject = new TH1F("gProtonsPointOnITSLayer4Reject",
2240                                                   "",10,-1,1);
2241   gProtonsPointOnITSLayer4Reject->SetFillColor(kRed-2);
2242   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer4Reject);
2243   TH1F *gProtonsPointOnITSLayer5Reject = new TH1F("gProtonsPointOnITSLayer5Reject",
2244                                                   "",10,-1,1);
2245   gProtonsPointOnITSLayer5Reject->SetFillColor(kRed-2);
2246   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer5Reject);
2247   TH1F *gProtonsPointOnITSLayer6Reject = new TH1F("gProtonsPointOnITSLayer6Reject",
2248                                                   "",10,-1,1);
2249   gProtonsPointOnITSLayer6Reject->SetFillColor(kRed-2);
2250   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer6Reject);
2251   TH1F *gProtonsNumberOfTPCdEdxPointsReject = new TH1F("gProtonsNumberOfTPCdEdxPointsReject","",100,0,200);
2252   gProtonsNumberOfTPCdEdxPointsReject->SetFillColor(kRed-2);
2253   fQAProtonsRejectedList->Add(gProtonsNumberOfTPCdEdxPointsReject);
2254   TH1F *gProtonsITSClusterMapReject = new TH1F("gProtonsITSClusterMapReject",";ITS Layer;Entries",6,0.5,6.5);
2255   gProtonsITSClusterMapReject->SetFillColor(kRed-2);
2256   fQAProtonsRejectedList->Add(gProtonsITSClusterMapReject);
2257   TH1F *gProtonsDCA3DReject = new TH1F("gProtonsDCA3DReject",
2258                                        ";dca [cm];Entries",
2259                                        100,0,20);
2260   gProtonsDCA3DReject->SetFillColor(kRed-2);
2261   fQAProtonsRejectedList->Add(gProtonsDCA3DReject);
2262     
2263   //========================================================//
2264   fQAAntiProtonsAcceptedList = new TList();
2265   fQAAntiProtonsAcceptedList->SetName("fQAAntiProtonsAcceptedList");
2266   fGlobalQAList->Add(fQAAntiProtonsAcceptedList);
2267   //Accepted antiprotons
2268   TH1F *gAntiProtonsITSClustersPass = new TH1F("gAntiProtonsITSClustersPass",
2269                                                ";N_{clusters} (ITS);Entries",
2270                                                7,0,7);
2271   fQAAntiProtonsAcceptedList->Add(gAntiProtonsITSClustersPass);
2272   TH1F *gAntiProtonsChi2PerClusterITSPass = new TH1F("gAntiProtonsChi2PerClusterITSPass",
2273                                                      ";x^{2}/N_{clusters} (ITS);Entries",
2274                                                      100,0,4);
2275   fQAAntiProtonsAcceptedList->Add(gAntiProtonsChi2PerClusterITSPass);
2276   TH1F *gAntiProtonsTPCClustersPass = new TH1F("gAntiProtonsTPCClustersPass",
2277                                                ";N_{clusters} (TPC);Entries",
2278                                                100,0,200);
2279   fQAAntiProtonsAcceptedList->Add(gAntiProtonsTPCClustersPass);
2280   TH1F *gAntiProtonsChi2PerClusterTPCPass = new TH1F("gAntiProtonsChi2PerClusterTPCPass",
2281                                                      ";x^{2}/N_{clusters} (TPC);Entries",
2282                                                      100,0,4);
2283   fQAAntiProtonsAcceptedList->Add(gAntiProtonsChi2PerClusterTPCPass);
2284   TH1F *gAntiProtonsExtCov11Pass = new TH1F("gAntiProtonsExtCov11Pass",
2285                                             ";#sigma_{y} [cm];Entries",
2286                                             100,0,4);
2287   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov11Pass);
2288   TH1F *gAntiProtonsExtCov22Pass = new TH1F("gAntiProtonsExtCov22Pass",
2289                                             ";#sigma_{z} [cm];Entries",
2290                                             100,0,4);
2291   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov22Pass);
2292   TH1F *gAntiProtonsExtCov33Pass = new TH1F("gAntiProtonsExtCov33Pass",
2293                                             ";#sigma_{sin(#phi)};Entries",
2294                                             100,0,4);
2295   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov33Pass);
2296   TH1F *gAntiProtonsExtCov44Pass = new TH1F("gAntiProtonsExtCov44Pass",
2297                                             ";#sigma_{tan(#lambda)};Entries",
2298                                             100,0,4);
2299   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov44Pass);
2300   TH1F *gAntiProtonsExtCov55Pass = new TH1F("gAntiProtonsExtCov55Pass",
2301                                             ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2302                                             100,0,4);
2303   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov55Pass);
2304   TH1F *gAntiProtonsSigmaToVertexPass = new TH1F("gAntiProtonsSigmaToVertexPass",
2305                                                  ";#sigma_{Vertex};Entries",
2306                                                  100,0,10);
2307   fQAAntiProtonsAcceptedList->Add(gAntiProtonsSigmaToVertexPass);
2308   TH1F *gAntiProtonsSigmaToVertexTPCPass = new TH1F("gAntiProtonsSigmaToVertexTPCPass",
2309                                                     ";#sigma_{Vertex};Entries",
2310                                                     100,0,10);
2311   fQAAntiProtonsAcceptedList->Add(gAntiProtonsSigmaToVertexTPCPass);
2312   TH1F *gAntiProtonsDCAXYPass = new TH1F("gAntiProtonsDCAXYPass",
2313                                          ";DCA_{xy} [cm];Entries",
2314                                          100,0,20);
2315   fQAAntiProtonsAcceptedList->Add(gAntiProtonsDCAXYPass);
2316   TH1F *gAntiProtonsDCAXYTPCPass = new TH1F("gAntiProtonsDCAXYTPCPass",
2317                                             ";DCA_{xy} [cm];Entries",
2318                                             100,0,20);
2319   fQAAntiProtonsAcceptedList->Add(gAntiProtonsDCAXYTPCPass);
2320   TH1F *gAntiProtonsDCAZPass = new TH1F("gAntiProtonsDCAZPass",
2321                                         ";DCA_{z} [cm];Entries",
2322                                         100,0,20);
2323   fQAAntiProtonsAcceptedList->Add(gAntiProtonsDCAZPass);
2324   TH1F *gAntiProtonsDCAZTPCPass = new TH1F("gAntiProtonsDCAZTPCPass",
2325                                            ";DCA_{z} [cm];Entries",
2326                                            100,0,20);
2327   fQAAntiProtonsAcceptedList->Add(gAntiProtonsDCAZTPCPass);
2328   TH1F *gAntiProtonsConstrainChi2Pass = new TH1F("gAntiProtonsConstrainChi2Pass",
2329                                                  ";Log_{10}(#chi^{2});Entries",
2330                                                  100,-10,10);
2331   fQAAntiProtonsAcceptedList->Add(gAntiProtonsConstrainChi2Pass);
2332   TH1F *gAntiProtonsITSRefitPass = new TH1F("gAntiProtonsITSRefitPass",
2333                                             "",10,-1,1);
2334   fQAAntiProtonsAcceptedList->Add(gAntiProtonsITSRefitPass);
2335   TH1F *gAntiProtonsTPCRefitPass = new TH1F("gAntiProtonsTPCRefitPass",
2336                                             "",10,-1,1);
2337   fQAAntiProtonsAcceptedList->Add(gAntiProtonsTPCRefitPass);
2338   TH1F *gAntiProtonsESDpidPass = new TH1F("gAntiProtonsESDpidPass",
2339                                           "",10,-1,1);
2340   fQAAntiProtonsAcceptedList->Add(gAntiProtonsESDpidPass);
2341   TH1F *gAntiProtonsTPCpidPass = new TH1F("gAntiProtonsTPCpidPass",
2342                                           "",10,-1,1);
2343   fQAAntiProtonsAcceptedList->Add(gAntiProtonsTPCpidPass);
2344   TH1F *gAntiProtonsPointOnITSLayer1Pass = new TH1F("gAntiProtonsPointOnITSLayer1Pass",
2345                                                     "",10,-1,1);
2346   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer1Pass);
2347   TH1F *gAntiProtonsPointOnITSLayer2Pass = new TH1F("gAntiProtonsPointOnITSLayer2Pass",
2348                                                     "",10,-1,1);
2349   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer2Pass);
2350   TH1F *gAntiProtonsPointOnITSLayer3Pass = new TH1F("gAntiProtonsPointOnITSLayer3Pass",
2351                                                     "",10,-1,1);
2352   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer3Pass);
2353   TH1F *gAntiProtonsPointOnITSLayer4Pass = new TH1F("gAntiProtonsPointOnITSLayer4Pass",
2354                                                     "",10,-1,1);
2355   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer4Pass);
2356   TH1F *gAntiProtonsPointOnITSLayer5Pass = new TH1F("gAntiProtonsPointOnITSLayer5Pass",
2357                                                     "",10,-1,1);
2358   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer5Pass);
2359   TH1F *gAntiProtonsPointOnITSLayer6Pass = new TH1F("gAntiProtonsPointOnITSLayer6Pass",
2360                                                     "",10,-1,1);
2361   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer6Pass);
2362   TH1F *gAntiProtonsNumberOfTPCdEdxPointsPass = new TH1F("gAntiProtonsNumberOfTPCdEdxPointsPass","",100,0,200);
2363   fQAAntiProtonsAcceptedList->Add(gAntiProtonsNumberOfTPCdEdxPointsPass);
2364   TH1F *gAntiProtonsITSClusterMapPass = new TH1F("gAntiProtonsITSClusterMapPass",";ITS Layer;Entries",6,0.5,6.5);
2365   fQAAntiProtonsAcceptedList->Add(gAntiProtonsITSClusterMapPass);
2366   TH1F *gAntiProtonsDCA3DPass = new TH1F("gAntiProtonsDCA3DPass",
2367                                          ";dca [cm];Entries",
2368                                          100,0,20);
2369   fQAAntiProtonsAcceptedList->Add(gAntiProtonsDCA3DPass);
2370
2371   //========================================================//
2372   fQAAntiProtonsRejectedList = new TList();
2373   fQAAntiProtonsRejectedList->SetName("fQAAntiProtonsRejectedList");
2374   fGlobalQAList->Add(fQAAntiProtonsRejectedList);
2375   //Rejected antiprotons
2376   TH1F *gAntiProtonsITSClustersReject = new TH1F("gAntiProtonsITSClustersReject",
2377                                                  ";N_{clusters} (ITS);Entries",
2378                                                  7,0,7);
2379   gAntiProtonsITSClustersReject->SetFillColor(kRed-2);
2380   fQAAntiProtonsRejectedList->Add(gAntiProtonsITSClustersReject);
2381   TH1F *gAntiProtonsChi2PerClusterITSReject = new TH1F("gAntiProtonsChi2PerClusterITSReject",
2382                                                        ";x^{2}/N_{clusters} (ITS);Entries",
2383                                                        100,0,4);
2384   gAntiProtonsChi2PerClusterITSReject->SetFillColor(kRed-2);
2385   fQAAntiProtonsRejectedList->Add(gAntiProtonsChi2PerClusterITSReject);
2386   TH1F *gAntiProtonsTPCClustersReject = new TH1F("gAntiProtonsTPCClustersReject",
2387                                                  ";N_{clusters} (TPC);Entries",
2388                                                  100,0,200);
2389   gAntiProtonsTPCClustersReject->SetFillColor(kRed-2);
2390   fQAAntiProtonsRejectedList->Add(gAntiProtonsTPCClustersReject);
2391   TH1F *gAntiProtonsChi2PerClusterTPCReject = new TH1F("gAntiProtonsChi2PerClusterTPCReject",
2392                                                        ";x^{2}/N_{clusters} (TPC);Entries",
2393                                                        100,0,4);
2394   gAntiProtonsChi2PerClusterTPCReject->SetFillColor(kRed-2);
2395   fQAAntiProtonsRejectedList->Add(gAntiProtonsChi2PerClusterTPCReject);
2396   TH1F *gAntiProtonsExtCov11Reject = new TH1F("gAntiProtonsExtCov11Reject",
2397                                               ";#sigma_{y} [cm];Entries",
2398                                               100,0,4);
2399   gAntiProtonsExtCov11Reject->SetFillColor(kRed-2);
2400   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov11Reject);
2401   TH1F *gAntiProtonsExtCov22Reject = new TH1F("gAntiProtonsExtCov22Reject",
2402                                               ";#sigma_{z} [cm];Entries",
2403                                               100,0,4);
2404   gAntiProtonsExtCov22Reject->SetFillColor(kRed-2);
2405   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov22Reject);
2406   TH1F *gAntiProtonsExtCov33Reject = new TH1F("gAntiProtonsExtCov33Reject",
2407                                               ";#sigma_{sin(#phi)};Entries",
2408                                               100,0,4);
2409   gAntiProtonsExtCov33Reject->SetFillColor(kRed-2);
2410   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov33Reject);
2411   TH1F *gAntiProtonsExtCov44Reject = new TH1F("gAntiProtonsExtCov44Reject",
2412                                               ";#sigma_{tan(#lambda)};Entries",
2413                                               100,0,4);
2414   gAntiProtonsExtCov44Reject->SetFillColor(kRed-2);
2415   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov44Reject);
2416   TH1F *gAntiProtonsExtCov55Reject = new TH1F("gAntiProtonsExtCov55Reject",
2417                                               ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2418                                               100,0,4);
2419   gAntiProtonsExtCov55Reject->SetFillColor(kRed-2);
2420   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov55Reject);
2421   TH1F *gAntiProtonsSigmaToVertexReject = new TH1F("gAntiProtonsSigmaToVertexReject",
2422                                                    ";#sigma_{Vertex};Entries",
2423                                                    100,0,10);
2424   gAntiProtonsSigmaToVertexReject->SetFillColor(kRed-2);
2425   fQAAntiProtonsRejectedList->Add(gAntiProtonsSigmaToVertexReject);
2426   TH1F *gAntiProtonsSigmaToVertexTPCReject = new TH1F("gAntiProtonsSigmaToVertexTPCReject",
2427                                                       ";#sigma_{Vertex};Entries",
2428                                                       100,0,10);
2429   gAntiProtonsSigmaToVertexTPCReject->SetFillColor(kRed-2);
2430   fQAAntiProtonsRejectedList->Add(gAntiProtonsSigmaToVertexTPCReject);
2431   TH1F *gAntiProtonsDCAXYReject = new TH1F("gAntiProtonsDCAXYReject",
2432                                            ";DCA_{xy} [cm];Entries",
2433                                            100,0,20);
2434   gAntiProtonsDCAXYReject->SetFillColor(kRed-2);
2435   fQAAntiProtonsRejectedList->Add(gAntiProtonsDCAXYReject);
2436   TH1F *gAntiProtonsDCAXYTPCReject = new TH1F("gAntiProtonsDCAXYTPCReject",
2437                                               ";DCA_{xy} [cm];Entries",
2438                                               100,0,20);
2439   gAntiProtonsDCAXYTPCReject->SetFillColor(kRed-2);
2440   fQAAntiProtonsRejectedList->Add(gAntiProtonsDCAXYTPCReject);
2441   TH1F *gAntiProtonsDCAZReject = new TH1F("gAntiProtonsDCAZReject",
2442                                           ";DCA_{z} [cm];Entries",
2443                                           100,0,20);
2444   gAntiProtonsDCAZReject->SetFillColor(kRed-2);
2445   fQAAntiProtonsRejectedList->Add(gAntiProtonsDCAZReject);
2446   TH1F *gAntiProtonsDCAZTPCReject = new TH1F("gAntiProtonsDCAZTPCReject",
2447                                              ";DCA_{z} [cm];Entries",
2448                                              100,0,20);
2449   gAntiProtonsDCAZTPCReject->SetFillColor(kRed-2);
2450   fQAAntiProtonsRejectedList->Add(gAntiProtonsDCAZTPCReject);
2451   TH1F *gAntiProtonsConstrainChi2Reject = new TH1F("gAntiProtonsConstrainChi2Reject",
2452                                                    ";Log_{10}(#chi^{2});Entries",
2453                                                    100,-10,10);
2454   gAntiProtonsConstrainChi2Reject->SetFillColor(kRed-2);
2455   fQAAntiProtonsRejectedList->Add(gAntiProtonsConstrainChi2Reject);
2456   TH1F *gAntiProtonsITSRefitReject = new TH1F("gAntiProtonsITSRefitReject",
2457                                               "",10,-1,1);
2458   gAntiProtonsITSRefitReject->SetFillColor(kRed-2);
2459   fQAAntiProtonsRejectedList->Add(gAntiProtonsITSRefitReject);
2460   TH1F *gAntiProtonsTPCRefitReject = new TH1F("gAntiProtonsTPCRefitReject",
2461                                               "",10,-1,1);
2462   gAntiProtonsTPCRefitReject->SetFillColor(kRed-2);
2463   fQAAntiProtonsRejectedList->Add(gAntiProtonsTPCRefitReject);
2464   TH1F *gAntiProtonsESDpidReject = new TH1F("gAntiProtonsESDpidReject",
2465                                             "",10,-1,1);
2466   gAntiProtonsESDpidReject->SetFillColor(kRed-2);
2467   fQAAntiProtonsRejectedList->Add(gAntiProtonsESDpidReject);
2468   TH1F *gAntiProtonsTPCpidReject = new TH1F("gAntiProtonsTPCpidReject",
2469                                             "",10,-1,1);
2470   gAntiProtonsTPCpidReject->SetFillColor(kRed-2);
2471   fQAAntiProtonsRejectedList->Add(gAntiProtonsTPCpidReject);
2472   TH1F *gAntiProtonsPointOnITSLayer1Reject = new TH1F("gAntiProtonsPointOnITSLayer1Reject",
2473                                                       "",10,-1,1);
2474   gAntiProtonsPointOnITSLayer1Reject->SetFillColor(kRed-2);
2475   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer1Reject);
2476   TH1F *gAntiProtonsPointOnITSLayer2Reject = new TH1F("gAntiProtonsPointOnITSLayer2Reject",
2477                                                       "",10,-1,1);
2478   gAntiProtonsPointOnITSLayer2Reject->SetFillColor(kRed-2);
2479   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer2Reject);
2480   TH1F *gAntiProtonsPointOnITSLayer3Reject = new TH1F("gAntiProtonsPointOnITSLayer3Reject",
2481                                                       "",10,-1,1);
2482   gAntiProtonsPointOnITSLayer3Reject->SetFillColor(kRed-2);
2483   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer3Reject);
2484   TH1F *gAntiProtonsPointOnITSLayer4Reject = new TH1F("gAntiProtonsPointOnITSLayer4Reject",
2485                                                       "",10,-1,1);
2486   gAntiProtonsPointOnITSLayer4Reject->SetFillColor(kRed-2);
2487   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer4Reject);
2488   TH1F *gAntiProtonsPointOnITSLayer5Reject = new TH1F("gAntiProtonsPointOnITSLayer5Reject",
2489                                                       "",10,-1,1);
2490   gAntiProtonsPointOnITSLayer5Reject->SetFillColor(kRed-2);
2491   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer5Reject);
2492   TH1F *gAntiProtonsPointOnITSLayer6Reject = new TH1F("gAntiProtonsPointOnITSLayer6Reject",
2493                                                       "",10,-1,1);
2494   gAntiProtonsPointOnITSLayer6Reject->SetFillColor(kRed-2);
2495   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer6Reject);
2496   TH1F *gAntiProtonsNumberOfTPCdEdxPointsReject = new TH1F("gAntiProtonsNumberOfTPCdEdxPointsReject","",100,0,200);
2497   gAntiProtonsNumberOfTPCdEdxPointsReject->SetFillColor(kRed-2);
2498   fQAAntiProtonsRejectedList->Add(gAntiProtonsNumberOfTPCdEdxPointsReject);
2499   TH1F *gAntiProtonsITSClusterMapReject = new TH1F("gAntiProtonsITSClusterMapReject",";ITS Layer;Entries",6,0.5,6.5);
2500   gAntiProtonsITSClusterMapReject->SetFillColor(kRed-2);
2501   fQAAntiProtonsRejectedList->Add(gAntiProtonsITSClusterMapReject);
2502   TH1F *gAntiProtonsDCA3DReject = new TH1F("gAntiProtonsDCA3DReject",
2503                                            ";dca [cm];Entries",
2504                                            100,0,20);
2505   gAntiProtonsDCA3DReject->SetFillColor(kRed-2);
2506   fQAAntiProtonsRejectedList->Add(gAntiProtonsDCA3DReject);
2507 }
2508
2509 //____________________________________________________________________//
2510 void AliProtonAnalysis::FillQA(AliESDEvent *esd,
2511                                const AliESDVertex *vertex, 
2512                                AliESDtrack* track) {
2513   //Fills the QA histograms
2514   Double_t gPt = 0.0, gPx = 0.0, gPy = 0.0, gPz = 0.0;
2515   Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};  //The impact parameters and their covariance.
2516   Double_t dca3D = 0.0;
2517   Float_t dcaXY = 0.0, dcaZ = 0.0;
2518
2519   if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)||(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
2520     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
2521     if(!tpcTrack) {
2522       gPt = 0.0; gPx = 0.0; gPy = 0.0; gPz = 0.0;
2523       dca[0] = -100.; dca[1] = -100.;
2524       cov[0] = -100.; cov[1] = -100.; cov[2] = -100.;
2525     }
2526     else {
2527       gPt = tpcTrack->Pt();
2528       gPx = tpcTrack->Px();
2529       gPy = tpcTrack->Py();
2530       gPz = tpcTrack->Pz();
2531       tpcTrack->PropagateToDCA(vertex,
2532                                esd->GetMagneticField(),
2533                                100.,dca,cov);
2534     }
2535   }
2536   if(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kFullHybrid) {
2537     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
2538     AliExternalTrackParam cParam;
2539     if(!tpcTrack) {
2540       gPt = 0.0; gPx = 0.0; gPy = 0.0; gPz = 0.0;
2541       dca[0] = -100.; dca[1] = -100.;
2542       cov[0] = -100.; cov[1] = -100.; cov[2] = -100.;
2543     }
2544     else {
2545       gPt = tpcTrack->Pt();
2546       gPx = tpcTrack->Px();
2547       gPy = tpcTrack->Py();
2548       gPz = tpcTrack->Pz();
2549       track->RelateToVertex(vertex,
2550                             esd->GetMagneticField(),
2551                             100.,&cParam);
2552       track->GetImpactParameters(dcaXY,dcaZ);
2553       dca[0] = dcaXY; dca[1] = dcaZ;
2554     }
2555   }
2556   else{
2557     gPt = track->Pt();
2558     gPx = track->Px();
2559     gPy = track->Py();
2560     gPz = track->Pz();
2561     track->PropagateToDCA(vertex,
2562                           esd->GetMagneticField(),
2563                           100.,dca,cov);
2564   }
2565
2566   dca3D = TMath::Sqrt(TMath::Power(dca[0],2) +
2567                       TMath::Power(dca[1],2));
2568
2569   Int_t  fIdxInt[200];
2570   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
2571   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
2572
2573   Float_t chi2PerClusterITS = -1;
2574   if (nClustersITS!=0)
2575     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
2576   Float_t chi2PerClusterTPC = -1;
2577   if (nClustersTPC!=0)
2578     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
2579
2580   Double_t extCov[15];
2581   track->GetExternalCovariance(extCov);
2582   
2583   //protons
2584   if(track->Charge() > 0) {
2585     if(fProtonAnalysisBase->IsUsedMinITSClusters()) {
2586       if(nClustersITS < fProtonAnalysisBase->GetMinITSClusters()) {
2587         ((TH1F *)(fQAProtonsRejectedList->At(0)))->Fill(nClustersITS);
2588       }
2589       else if(nClustersITS >= fProtonAnalysisBase->GetMinITSClusters()) 
2590         ((TH1F *)(fQAProtonsAcceptedList->At(0)))->Fill(nClustersITS);
2591     }//ITS clusters
2592     if(fProtonAnalysisBase->IsUsedMaxChi2PerITSCluster()) {
2593       if(chi2PerClusterITS > fProtonAnalysisBase->GetMaxChi2PerITSCluster()) {
2594         ((TH1F *)(fQAProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
2595       }
2596       else if(chi2PerClusterITS <= fProtonAnalysisBase->GetMaxChi2PerITSCluster())
2597         ((TH1F *)(fQAProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
2598     }//chi2 per ITS cluster
2599     if(fProtonAnalysisBase->IsUsedMinTPCClusters()) {
2600       if(nClustersTPC < fProtonAnalysisBase->GetMinTPCClusters()) {
2601         ((TH1F *)(fQAProtonsRejectedList->At(2)))->Fill(nClustersTPC);
2602       }
2603       else if(nClustersTPC >= fProtonAnalysisBase->GetMinTPCClusters()) {
2604         ((TH1F *)(fQAProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
2605       }
2606     }//TPC clusters
2607     if(fProtonAnalysisBase->IsUsedMaxChi2PerTPCCluster()) {
2608       if(chi2PerClusterTPC > fProtonAnalysisBase->GetMaxChi2PerTPCCluster()) {
2609         ((TH1F *)(fQAProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
2610       }
2611       else if(chi2PerClusterTPC <= fProtonAnalysisBase->GetMaxChi2PerTPCCluster())
2612         ((TH1F *)(fQAProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
2613     }//chi2 per TPC cluster
2614     if(fProtonAnalysisBase->IsUsedMaxCov11()) {
2615       if(extCov[0] > fProtonAnalysisBase->GetMaxCov11()) {
2616         ((TH1F *)(fQAProtonsRejectedList->At(4)))->Fill(extCov[0]);
2617       }
2618       else if(extCov[0] <= fProtonAnalysisBase->GetMaxCov11())
2619         ((TH1F *)(fQAProtonsAcceptedList->At(4)))->Fill(extCov[0]);
2620     }//cov11
2621     if(fProtonAnalysisBase->IsUsedMaxCov22()) {
2622       if(extCov[2] > fProtonAnalysisBase->GetMaxCov22()) {
2623         ((TH1F *)(fQAProtonsRejectedList->At(5)))->Fill(extCov[2]);
2624       }
2625       else if(extCov[2] <= fProtonAnalysisBase->GetMaxCov22())
2626         ((TH1F *)(fQAProtonsAcceptedList->At(5)))->Fill(extCov[2]);
2627     }//cov11
2628     if(fProtonAnalysisBase->IsUsedMaxCov33()) {
2629       if(extCov[5] > fProtonAnalysisBase->GetMaxCov33()) {
2630         ((TH1F *)(fQAProtonsRejectedList->At(6)))->Fill(extCov[5]);
2631       }
2632       else if(extCov[5] <= fProtonAnalysisBase->GetMaxCov33())
2633         ((TH1F *)(fQAProtonsAcceptedList->At(6)))->Fill(extCov[5]);
2634     }//cov11
2635     if(fProtonAnalysisBase->IsUsedMaxCov44()) {
2636       if(extCov[9] > fProtonAnalysisBase->GetMaxCov44()) {
2637         ((TH1F *)(fQAProtonsRejectedList->At(7)))->Fill(extCov[9]);
2638       }
2639       else if(extCov[9] <= fProtonAnalysisBase->GetMaxCov44())
2640         ((TH1F *)(fQAProtonsAcceptedList->At(7)))->Fill(extCov[9]);
2641     }//cov11
2642     if(fProtonAnalysisBase->IsUsedMaxCov55()) {
2643       if(extCov[14] > fProtonAnalysisBase->GetMaxCov55()) {
2644         ((TH1F *)(fQAProtonsRejectedList->At(8)))->Fill(extCov[14]);
2645       }
2646       else if(extCov[14] <= fProtonAnalysisBase->GetMaxCov55())
2647         ((TH1F *)(fQAProtonsAcceptedList->At(8)))->Fill(extCov[14]);
2648     }//cov55
2649     if(fProtonAnalysisBase->IsUsedMaxSigmaToVertex()) {
2650       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertex()) {
2651         ((TH1F *)(fQAProtonsRejectedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2652       }
2653       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertex())
2654         ((TH1F *)(fQAProtonsAcceptedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2655     }//sigma to vertex
2656     if(fProtonAnalysisBase->IsUsedMaxSigmaToVertexTPC()) {
2657       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertexTPC()) {
2658         ((TH1F *)(fQAProtonsRejectedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2659       }
2660       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertexTPC())
2661         ((TH1F *)(fQAProtonsAcceptedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2662     }//sigma to vertex TPC
2663     if(fProtonAnalysisBase->IsUsedMaxDCAXY()) {
2664       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXY()) {
2665         ((TH1F *)(fQAProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
2666       }
2667       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXY())
2668         ((TH1F *)(fQAProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
2669     }//DCA xy global tracking
2670     if(fProtonAnalysisBase->IsUsedMaxDCAXYTPC()) {
2671       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXYTPC()) {
2672         ((TH1F *)(fQAProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
2673       }
2674       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXYTPC())
2675         ((TH1F *)(fQAProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
2676     }//DCA xy TPC tracking
2677     if(fProtonAnalysisBase->IsUsedMaxDCAZ()) {
2678       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZ()) {
2679         ((TH1F *)(fQAProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
2680       }
2681       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZ())
2682         ((TH1F *)(fQAProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
2683     }//DCA z global tracking
2684     if(fProtonAnalysisBase->IsUsedMaxDCAZTPC()) {
2685       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZTPC()) {
2686         ((TH1F *)(fQAProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
2687       }
2688       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZTPC())
2689         ((TH1F *)(fQAProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
2690     }//DCA z TPC tracking
2691     if(fProtonAnalysisBase->IsUsedMaxConstrainChi2()) {
2692       if(track->GetConstrainedChi2() > 0) {
2693         if(TMath::Log(track->GetConstrainedChi2()) > fProtonAnalysisBase->GetMaxConstrainChi2()) {
2694           ((TH1F *)(fQAProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
2695         }
2696         else if(TMath::Log(track->GetConstrainedChi2()) <= fProtonAnalysisBase->GetMaxConstrainChi2())
2697           ((TH1F *)(fQAProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
2698       }
2699     }//constrain chi2 - vertex
2700     if(fProtonAnalysisBase->IsUsedITSRefit()) {
2701       if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
2702         ((TH1F *)(fQAProtonsRejectedList->At(16)))->Fill(0);
2703       }
2704       else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
2705         ((TH1F *)(fQAProtonsAcceptedList->At(16)))->Fill(0);
2706     }//ITS refit
2707     if(fProtonAnalysisBase->IsUsedTPCRefit()) {
2708       if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
2709         ((TH1F *)(fQAProtonsRejectedList->At(17)))->Fill(0);
2710       }
2711       else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
2712         ((TH1F *)(fQAProtonsAcceptedList->At(17)))->Fill(0);
2713     }//TPC refit
2714     if(fProtonAnalysisBase->IsUsedESDpid()) {
2715       if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
2716         ((TH1F *)(fQAProtonsRejectedList->At(18)))->Fill(0);
2717       }
2718       else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
2719         ((TH1F *)(fQAProtonsAcceptedList->At(18)))->Fill(0);
2720     }//ESD pid
2721     if(fProtonAnalysisBase->IsUsedTPCpid()) {
2722       if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
2723         ((TH1F *)(fQAProtonsRejectedList->At(19)))->Fill(0);
2724       }
2725       else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
2726         ((TH1F *)(fQAProtonsAcceptedList->At(19)))->Fill(0);
2727     }//TPC pid
2728     if(fProtonAnalysisBase->IsUsedPointOnITSLayer1()) {
2729       if(!track->HasPointOnITSLayer(0)) {
2730         ((TH1F *)(fQAProtonsRejectedList->At(20)))->Fill(0);
2731       }
2732       else if(track->HasPointOnITSLayer(0))
2733         ((TH1F *)(fQAProtonsAcceptedList->At(20)))->Fill(0);
2734     }//point on SPD1
2735     if(fProtonAnalysisBase->IsUsedPointOnITSLayer2()) {
2736       if(!track->HasPointOnITSLayer(1)) {
2737         ((TH1F *)(fQAProtonsRejectedList->At(21)))->Fill(0);
2738       }
2739       else if(track->HasPointOnITSLayer(1))
2740         ((TH1F *)(fQAProtonsAcceptedList->At(21)))->Fill(0);
2741     }//point on SPD2
2742     if(fProtonAnalysisBase->IsUsedPointOnITSLayer3()) {
2743       if(!track->HasPointOnITSLayer(2)) {
2744         ((TH1F *)(fQAProtonsRejectedList->At(22)))->Fill(0);
2745       }
2746       else if(track->HasPointOnITSLayer(2))
2747         ((TH1F *)(fQAProtonsAcceptedList->At(22)))->Fill(0);
2748     }//point on SDD1
2749     if(fProtonAnalysisBase->IsUsedPointOnITSLayer4()) {
2750       if(!track->HasPointOnITSLayer(3)) {
2751         ((TH1F *)(fQAProtonsRejectedList->At(23)))->Fill(0);
2752       }
2753       else if(track->HasPointOnITSLayer(3))
2754         ((TH1F *)(fQAProtonsAcceptedList->At(23)))->Fill(0);
2755     }//point on SDD2
2756     if(fProtonAnalysisBase->IsUsedPointOnITSLayer5()) {
2757       if(!track->HasPointOnITSLayer(4)) {
2758         ((TH1F *)(fQAProtonsRejectedList->At(24)))->Fill(0);
2759       }
2760       else if(track->HasPointOnITSLayer(4))
2761         ((TH1F *)(fQAProtonsAcceptedList->At(24)))->Fill(0);
2762     }//point on SSD1
2763     if(fProtonAnalysisBase->IsUsedPointOnITSLayer6()) {
2764       if(!track->HasPointOnITSLayer(5)) {
2765         ((TH1F *)(fQAProtonsRejectedList->At(25)))->Fill(0);
2766       }
2767       else if(track->HasPointOnITSLayer(5))
2768         ((TH1F *)(fQAProtonsAcceptedList->At(25)))->Fill(0);
2769     }//point on SSD2
2770     if(fProtonAnalysisBase->IsUsedMinTPCdEdxPoints()) {
2771       if(track->GetTPCsignalN() < fProtonAnalysisBase->GetMinTPCdEdxPoints()) {
2772         ((TH1F *)(fQAProtonsRejectedList->At(26)))->Fill(track->GetTPCsignalN());
2773       }
2774       if(track->GetTPCsignalN() >= fProtonAnalysisBase->GetMinTPCdEdxPoints())
2775         ((TH1F *)(fQAProtonsAcceptedList->At(26)))->Fill(track->GetTPCsignalN());
2776     }//number of TPC points for the dE/dx
2777     if(fProtonAnalysisBase->IsUsedPointOnSPDLayer()) {
2778       if((!track->HasPointOnITSLayer(0))&&(!track->HasPointOnITSLayer(1))) {
2779         for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2780           if(track->HasPointOnITSLayer(iLayer))
2781             ((TH1F *)(fQAProtonsRejectedList->At(27)))->Fill(iLayer+1);
2782         }
2783       }
2784       else if((track->HasPointOnITSLayer(0))||(track->HasPointOnITSLayer(1))) {
2785         for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2786           if(track->HasPointOnITSLayer(iLayer))
2787             ((TH1F *)(fQAProtonsAcceptedList->At(27)))->Fill(iLayer+1);
2788         }
2789       }
2790     }//point on either SPD layers
2791     if(fProtonAnalysisBase->IsUsedMaxDCA3D()) {
2792       if(dca3D > fProtonAnalysisBase->GetMaxDCA3D()) {
2793         ((TH1F *)(fQAProtonsRejectedList->At(28)))->Fill(dca3D);
2794       }
2795       if(dca3D < fProtonAnalysisBase->GetMaxDCA3D()) 
2796         ((TH1F *)(fQAProtonsAcceptedList->At(28)))->Fill(dca3D);
2797     }//dca3D
2798   }//protons
2799
2800   //antiprotons
2801   if(track->Charge() < 0) {
2802     if(fProtonAnalysisBase->IsUsedMinITSClusters()) {
2803       if(nClustersITS < fProtonAnalysisBase->GetMinITSClusters()) {
2804         ((TH1F *)(fQAAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
2805       }
2806       else if(nClustersITS >= fProtonAnalysisBase->GetMinITSClusters()) 
2807         ((TH1F *)(fQAAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
2808     }//ITS clusters
2809     if(fProtonAnalysisBase->IsUsedMaxChi2PerITSCluster()) {
2810       if(chi2PerClusterITS > fProtonAnalysisBase->GetMaxChi2PerITSCluster()) {
2811         ((TH1F *)(fQAAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
2812       }
2813       else if(chi2PerClusterITS <= fProtonAnalysisBase->GetMaxChi2PerITSCluster())
2814         ((TH1F *)(fQAAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
2815     }//chi2 per ITS cluster
2816     if(fProtonAnalysisBase->IsUsedMinTPCClusters()) {
2817       if(nClustersTPC < fProtonAnalysisBase->GetMinTPCClusters()) {
2818         ((TH1F *)(fQAAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
2819       }
2820       else if(nClustersTPC >= fProtonAnalysisBase->GetMinTPCClusters()) {
2821         ((TH1F *)(fQAAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
2822       }
2823     }//TPC clusters
2824     if(fProtonAnalysisBase->IsUsedMaxChi2PerTPCCluster()) {
2825       if(chi2PerClusterTPC > fProtonAnalysisBase->GetMaxChi2PerTPCCluster()) {
2826         ((TH1F *)(fQAAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
2827       }
2828       else if(chi2PerClusterTPC <= fProtonAnalysisBase->GetMaxChi2PerTPCCluster())
2829         ((TH1F *)(fQAAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
2830     }//chi2 per TPC cluster
2831     if(fProtonAnalysisBase->IsUsedMaxCov11()) {
2832       if(extCov[0] > fProtonAnalysisBase->GetMaxCov11()) {
2833         ((TH1F *)(fQAAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
2834       }
2835       else if(extCov[0] <= fProtonAnalysisBase->GetMaxCov11())
2836         ((TH1F *)(fQAAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
2837     }//cov11
2838     if(fProtonAnalysisBase->IsUsedMaxCov22()) {
2839       if(extCov[2] > fProtonAnalysisBase->GetMaxCov22()) {
2840         ((TH1F *)(fQAAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
2841       }
2842       else if(extCov[2] <= fProtonAnalysisBase->GetMaxCov22())
2843         ((TH1F *)(fQAAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
2844     }//cov11
2845     if(fProtonAnalysisBase->IsUsedMaxCov33()) {
2846       if(extCov[5] > fProtonAnalysisBase->GetMaxCov33()) {
2847         ((TH1F *)(fQAAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
2848       }
2849       else if(extCov[5] <= fProtonAnalysisBase->GetMaxCov33())
2850         ((TH1F *)(fQAAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
2851     }//cov11
2852     if(fProtonAnalysisBase->IsUsedMaxCov44()) {
2853       if(extCov[9] > fProtonAnalysisBase->GetMaxCov44()) {
2854         ((TH1F *)(fQAAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
2855       }
2856       else if(extCov[9] <= fProtonAnalysisBase->GetMaxCov44())
2857         ((TH1F *)(fQAAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
2858     }//cov11
2859     if(fProtonAnalysisBase->IsUsedMaxCov55()) {
2860       if(extCov[14] > fProtonAnalysisBase->GetMaxCov55()) {
2861         ((TH1F *)(fQAAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
2862       }
2863       else if(extCov[14] <= fProtonAnalysisBase->GetMaxCov55())
2864         ((TH1F *)(fQAAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
2865     }//cov55
2866     if(fProtonAnalysisBase->IsUsedMaxSigmaToVertex()) {
2867       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertex()) {
2868         ((TH1F *)(fQAAntiProtonsRejectedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2869       }
2870       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertex())
2871         ((TH1F *)(fQAAntiProtonsAcceptedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2872     }//sigma to vertex
2873     if(fProtonAnalysisBase->IsUsedMaxSigmaToVertexTPC()) {
2874       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertexTPC()) {
2875         ((TH1F *)(fQAAntiProtonsRejectedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2876       }
2877       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertexTPC())
2878         ((TH1F *)(fQAAntiProtonsAcceptedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2879     }//sigma to vertex TPC
2880     if(fProtonAnalysisBase->IsUsedMaxDCAXY()) {
2881       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXY()) {
2882         ((TH1F *)(fQAAntiProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
2883       }
2884       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXY())
2885         ((TH1F *)(fQAAntiProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
2886     }//DCA xy global tracking
2887     if(fProtonAnalysisBase->IsUsedMaxDCAXYTPC()) {
2888       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXYTPC()) {
2889         ((TH1F *)(fQAAntiProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
2890       }
2891       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXYTPC())
2892         ((TH1F *)(fQAAntiProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
2893     }//DCA xy TPC tracking
2894     if(fProtonAnalysisBase->IsUsedMaxDCAZ()) {
2895       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZ()) {
2896         ((TH1F *)(fQAAntiProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
2897       }
2898       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZ())
2899         ((TH1F *)(fQAAntiProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
2900     }//DCA z global tracking
2901     if(fProtonAnalysisBase->IsUsedMaxDCAZTPC()) {
2902       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZTPC()) {
2903         ((TH1F *)(fQAAntiProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
2904       }
2905       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZTPC())
2906         ((TH1F *)(fQAAntiProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
2907     }//DCA z TPC tracking
2908     if(fProtonAnalysisBase->IsUsedMaxConstrainChi2()) {
2909       if(track->GetConstrainedChi2() > 0) {
2910         if(TMath::Log(track->GetConstrainedChi2()) > fProtonAnalysisBase->GetMaxConstrainChi2()) {
2911           ((TH1F *)(fQAAntiProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
2912         }
2913         else if(TMath::Log(track->GetConstrainedChi2()) <= fProtonAnalysisBase->GetMaxConstrainChi2())
2914           ((TH1F *)(fQAAntiProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
2915       }
2916     }//constrain chi2 - vertex
2917     if(fProtonAnalysisBase->IsUsedITSRefit()) {
2918       if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
2919         ((TH1F *)(fQAAntiProtonsRejectedList->At(16)))->Fill(0);
2920       }
2921       else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
2922         ((TH1F *)(fQAAntiProtonsAcceptedList->At(16)))->Fill(0);
2923     }//ITS refit
2924     if(fProtonAnalysisBase->IsUsedTPCRefit()) {
2925       if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
2926         ((TH1F *)(fQAAntiProtonsRejectedList->At(17)))->Fill(0);
2927       }
2928       else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
2929         ((TH1F *)(fQAAntiProtonsAcceptedList->At(17)))->Fill(0);
2930     }//TPC refit
2931     if(fProtonAnalysisBase->IsUsedESDpid()) {
2932       if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
2933         ((TH1F *)(fQAAntiProtonsRejectedList->At(18)))->Fill(0);
2934       }
2935       else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
2936         ((TH1F *)(fQAAntiProtonsAcceptedList->At(18)))->Fill(0);
2937     }//ESD pid
2938     if(fProtonAnalysisBase->IsUsedTPCpid()) {
2939       if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
2940         ((TH1F *)(fQAAntiProtonsRejectedList->At(19)))->Fill(0);
2941       }
2942       else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
2943         ((TH1F *)(fQAAntiProtonsAcceptedList->At(19)))->Fill(0);
2944     }//TPC pid
2945     if(fProtonAnalysisBase->IsUsedPointOnITSLayer1()) {
2946       if(!track->HasPointOnITSLayer(0)) {
2947         ((TH1F *)(fQAAntiProtonsRejectedList->At(20)))->Fill(0);
2948       }
2949       else if(track->HasPointOnITSLayer(0))
2950         ((TH1F *)(fQAAntiProtonsAcceptedList->At(20)))->Fill(0);
2951     }//point on SPD1
2952     if(fProtonAnalysisBase->IsUsedPointOnITSLayer2()) {
2953       if(!track->HasPointOnITSLayer(1)) {
2954         ((TH1F *)(fQAAntiProtonsRejectedList->At(21)))->Fill(0);
2955       }
2956       else if(track->HasPointOnITSLayer(1))
2957         ((TH1F *)(fQAAntiProtonsAcceptedList->At(21)))->Fill(0);
2958     }//point on SPD2
2959     if(fProtonAnalysisBase->IsUsedPointOnITSLayer3()) {
2960       if(!track->HasPointOnITSLayer(2)) {
2961         ((TH1F *)(fQAAntiProtonsRejectedList->At(22)))->Fill(0);
2962       }
2963       else if(track->HasPointOnITSLayer(2))
2964         ((TH1F *)(fQAAntiProtonsAcceptedList->At(22)))->Fill(0);
2965     }//point on SDD1
2966     if(fProtonAnalysisBase->IsUsedPointOnITSLayer4()) {
2967       if(!track->HasPointOnITSLayer(3)) {
2968         ((TH1F *)(fQAAntiProtonsRejectedList->At(23)))->Fill(0);
2969       }
2970       else if(track->HasPointOnITSLayer(3))
2971         ((TH1F *)(fQAAntiProtonsAcceptedList->At(23)))->Fill(0);
2972     }//point on SDD2
2973     if(fProtonAnalysisBase->IsUsedPointOnITSLayer5()) {
2974       if(!track->HasPointOnITSLayer(4)) {
2975         ((TH1F *)(fQAAntiProtonsRejectedList->At(24)))->Fill(0);
2976       }
2977       else if(track->HasPointOnITSLayer(4))
2978         ((TH1F *)(fQAAntiProtonsAcceptedList->At(24)))->Fill(0);
2979     }//point on SSD1
2980     if(fProtonAnalysisBase->IsUsedPointOnITSLayer6()) {
2981       if(!track->HasPointOnITSLayer(5)) {
2982         ((TH1F *)(fQAAntiProtonsRejectedList->At(25)))->Fill(0);
2983       }
2984       else if(track->HasPointOnITSLayer(5))
2985         ((TH1F *)(fQAAntiProtonsAcceptedList->At(25)))->Fill(0);
2986     }//point on SSD2
2987     if(fProtonAnalysisBase->IsUsedMinTPCdEdxPoints()) {
2988       if(track->GetTPCsignalN() < fProtonAnalysisBase->GetMinTPCdEdxPoints()) {
2989         ((TH1F *)(fQAAntiProtonsRejectedList->At(26)))->Fill(track->GetTPCsignalN());
2990       }
2991       if(track->GetTPCsignalN() >= fProtonAnalysisBase->GetMinTPCdEdxPoints())
2992         ((TH1F *)(fQAAntiProtonsAcceptedList->At(26)))->Fill(track->GetTPCsignalN());
2993     }//number of TPC points for the dE/dx
2994     if(fProtonAnalysisBase->IsUsedPointOnSPDLayer()) {
2995       if((!track->HasPointOnITSLayer(0))&&(!track->HasPointOnITSLayer(1))) {
2996         for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2997           if(track->HasPointOnITSLayer(iLayer))
2998             ((TH1F *)(fQAAntiProtonsRejectedList->At(27)))->Fill(iLayer+1);
2999         }
3000       }
3001       else if((track->HasPointOnITSLayer(0))||(track->HasPointOnITSLayer(1))) {
3002         for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3003           if(track->HasPointOnITSLayer(iLayer))
3004             ((TH1F *)(fQAAntiProtonsAcceptedList->At(27)))->Fill(iLayer+1);
3005         }
3006       }
3007     }//point on either SPD layers
3008     if(fProtonAnalysisBase->IsUsedMaxDCA3D()) {
3009       if(dca3D > fProtonAnalysisBase->GetMaxDCA3D()) {
3010         ((TH1F *)(fQAAntiProtonsRejectedList->At(28)))->Fill(dca3D);
3011       }
3012       if(dca3D < fProtonAnalysisBase->GetMaxDCA3D()) 
3013         ((TH1F *)(fQAAntiProtonsAcceptedList->At(28)))->Fill(dca3D);
3014     }//dca3D
3015   }//antiprotons
3016 }