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