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