]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/AliProtonAnalysis.cxx
07d351ed396c34f8075311004647f84104cc6892
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliProtonAnalysis.cxx
1 /**************************************************************************
2  * Author: Panos Christakoglou.                                           *
3  * Contributors are mentioned in the code where appropriate.              *
4  *                                                                        *
5  * Permission to use, copy, modify and distribute this software and its   *
6  * documentation strictly for non-commercial purposes is hereby granted   *
7  * without fee, provided that the above copyright notice appears in all   *
8  * copies and that both the copyright notice and this permission notice   *
9  * appear in the supporting documentation. The authors make no claims     *
10  * about the suitability of this software for any purpose. It is          *
11  * provided "as is" without express or implied warranty.                  *
12  **************************************************************************/
13
14 /* $Id$ */
15
16 //-----------------------------------------------------------------
17 //                 AliProtonAnalysis class
18 //   This is the class to deal with the proton analysis
19 //   Origin: Panos Christakoglou | Panos.Christakoglou@cern.ch
20 //-----------------------------------------------------------------
21 #include <Riostream.h>
22 #include <TFile.h>
23 #include <TSystem.h>
24 #include <TF1.h>
25 #include <TH3F.h>
26 #include <TH2D.h>
27 #include <TH1D.h>
28 #include <TH1I.h>
29 #include <TParticle.h>
30 #include <TList.h>
31
32 #include <AliExternalTrackParam.h>
33 #include <AliAODEvent.h>
34 #include <AliESDEvent.h>
35 //#include <AliLog.h>
36 #include <AliPID.h>
37 #include <AliStack.h>
38 #include <AliCFContainer.h>
39 #include <AliCFEffGrid.h>
40 #include <AliCFDataGrid.h>
41 //#include <AliESDVertex.h>
42 class AliLog;
43 class AliESDVertex;
44
45 #include "AliProtonAnalysis.h"
46 #include "AliProtonAnalysisBase.h"
47
48 ClassImp(AliProtonAnalysis)
49
50 //____________________________________________________________________//
51 AliProtonAnalysis::AliProtonAnalysis() : 
52   TObject(), fProtonAnalysisBase(0),
53   fNBinsY(0), fMinY(0), fMaxY(0),
54   fNBinsPt(0), fMinPt(0), fMaxPt(0),
55   fProtonContainer(0), fAntiProtonContainer(0),
56   fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0), 
57   fHistEventStats(0),
58   fEffGridListProtons(0), fCorrectionListProtons2D(0), 
59   fEfficiencyListProtons1D(0), fCorrectionListProtons1D(0),
60   fEffGridListAntiProtons(0), fCorrectionListAntiProtons2D(0), 
61   fEfficiencyListAntiProtons1D(0), fCorrectionListAntiProtons1D(0),
62   fCorrectProtons(0), fCorrectAntiProtons(0),
63   fGlobalQAList(0), fQA2DList(0),
64   fQAProtonsAcceptedList(0), fQAProtonsRejectedList(0),
65   fQAAntiProtonsAcceptedList(0), fQAAntiProtonsRejectedList(0),
66   fInitQAFlag(kFALSE) {
67   //Default constructor
68 }
69
70 //____________________________________________________________________//
71 AliProtonAnalysis::AliProtonAnalysis(Int_t nbinsY, 
72                                      Float_t fLowY, Float_t fHighY,
73                                      Int_t nbinsPt, 
74                                      Float_t fLowPt, Float_t fHighPt) : 
75   TObject(), fProtonAnalysisBase(0),
76   fNBinsY(nbinsY), fMinY(fLowY), fMaxY(fHighY),
77   fNBinsPt(nbinsPt), fMinPt(fLowPt), fMaxPt(fHighPt),
78   fProtonContainer(0), fAntiProtonContainer(0),
79   fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0), fHistEventStats(0),
80   fEffGridListProtons(0), fCorrectionListProtons2D(0), 
81   fEfficiencyListProtons1D(0), fCorrectionListProtons1D(0),
82   fEffGridListAntiProtons(0), fCorrectionListAntiProtons2D(0), 
83   fEfficiencyListAntiProtons1D(0), fCorrectionListAntiProtons1D(0),
84   fCorrectProtons(0), fCorrectAntiProtons(0),
85   fGlobalQAList(0), fQA2DList(0),
86   fQAProtonsAcceptedList(0), fQAProtonsRejectedList(0),
87   fQAAntiProtonsAcceptedList(0), fQAAntiProtonsRejectedList(0),
88   fInitQAFlag(kFALSE) {
89   //Default constructor
90   if(!fInitQAFlag) InitQA();
91
92   fHistEvents = new TH1I("fHistEvents","Analyzed events",2,0.5,2.5);
93   fHistEvents->GetXaxis()->SetBinLabel(1,"Analyzed events");
94   fHistEvents->GetXaxis()->SetBinLabel(2,"Events with (anti)protons");
95
96   fHistYPtProtons = new TH2D("fHistYPtProtons","Protons",
97                              fNBinsY,fMinY,fMaxY,
98                              fNBinsPt,fMinPt,fMaxPt);
99   fHistYPtProtons->SetStats(kTRUE);
100   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
101   if(fProtonAnalysisBase->GetEtaMode())
102     fHistYPtProtons->GetXaxis()->SetTitle("#eta");
103   else
104     fHistYPtProtons->GetXaxis()->SetTitle("y");
105   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
106
107   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","Antiprotons",
108                                  fNBinsY,fMinY,fMaxY,
109                                  fNBinsPt,fMinPt,fMaxPt);
110   fHistYPtAntiProtons->SetStats(kTRUE);
111   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
112   if(fProtonAnalysisBase->GetEtaMode())
113     fHistYPtAntiProtons->GetXaxis()->SetTitle("#eta");
114   else
115     fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
116   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
117
118   //setting up the containers
119   Int_t iBin[2];
120   iBin[0] = nbinsY;
121   iBin[1] = nbinsPt;
122   Double_t *binLimY = new Double_t[nbinsY+1];
123   Double_t *binLimPt = new Double_t[nbinsPt+1];
124   //values for bin lower bounds
125   for(Int_t i = 0; i <= nbinsY; i++) 
126     binLimY[i]=(Double_t)fLowY  + (fHighY - fLowY)  /nbinsY*(Double_t)i;
127   for(Int_t i = 0; i <= nbinsPt; i++) 
128     binLimPt[i]=(Double_t)fLowPt  + (fHighPt - fLowPt)  /nbinsPt*(Double_t)i;
129
130   fProtonContainer = new AliCFContainer("containerProtons",
131                                         "container for protons",
132                                         kNSteps,2,iBin);
133   fProtonContainer->SetBinLimits(0,binLimY); //rapidity or eta
134   fProtonContainer->SetBinLimits(1,binLimPt); //pT
135   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
136                                             "container for antiprotons",
137                                             kNSteps,2,iBin);
138   fAntiProtonContainer->SetBinLimits(0,binLimY); //rapidity or eta
139   fAntiProtonContainer->SetBinLimits(1,binLimPt); //pT
140
141
142 //____________________________________________________________________//
143 AliProtonAnalysis::AliProtonAnalysis(Int_t nbinsY, Double_t *gY,
144                                      Int_t nbinsPt,Double_t *gPt) : 
145   TObject(), fProtonAnalysisBase(0),
146   fNBinsY(nbinsY), fMinY(gY[0]), fMaxY(gY[nbinsY]),
147   fNBinsPt(nbinsPt), fMinPt(gPt[0]), fMaxPt(gPt[nbinsPt]),
148   fProtonContainer(0), fAntiProtonContainer(0),
149   fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0), fHistEventStats(0),
150   fEffGridListProtons(0), fCorrectionListProtons2D(0), 
151   fEfficiencyListProtons1D(0), fCorrectionListProtons1D(0),
152   fEffGridListAntiProtons(0), fCorrectionListAntiProtons2D(0), 
153   fEfficiencyListAntiProtons1D(0), fCorrectionListAntiProtons1D(0),
154   fCorrectProtons(0), fCorrectAntiProtons(0),
155   fGlobalQAList(0), fQA2DList(0),
156   fQAProtonsAcceptedList(0), fQAProtonsRejectedList(0),
157   fQAAntiProtonsAcceptedList(0), fQAAntiProtonsRejectedList(0),
158   fInitQAFlag(kFALSE) {
159   //Default constructor
160   if(!fInitQAFlag) InitQA();
161
162   fHistEvents = new TH1I("fHistEvents","Analyzed events",2,0.5,2.5);
163   fHistEvents->GetXaxis()->SetBinLabel(1,"Analyzed events");
164   fHistEvents->GetXaxis()->SetBinLabel(2,"Events with (anti)protons");
165
166   fHistYPtProtons = new TH2D("fHistYPtProtons","Protons",
167                              fNBinsY,gY,fNBinsPt,gPt);
168   fHistYPtProtons->SetStats(kTRUE);
169   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
170   if(fProtonAnalysisBase->GetEtaMode())
171     fHistYPtProtons->GetXaxis()->SetTitle("#eta");
172   else
173     fHistYPtProtons->GetXaxis()->SetTitle("y");
174   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
175
176   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","Antiprotons",
177                                  fNBinsY,gY,fNBinsPt,gPt);
178   fHistYPtAntiProtons->SetStats(kTRUE);
179   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
180   if(fProtonAnalysisBase->GetEtaMode())
181     fHistYPtAntiProtons->GetXaxis()->SetTitle("#eta");
182   else
183     fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
184   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
185
186   //setting up the containers
187   Int_t iBin[2];
188   iBin[0] = nbinsY;
189   iBin[1] = nbinsPt;
190   fProtonContainer = new AliCFContainer("containerProtons",
191                                         "container for protons",
192                                         kNSteps,2,iBin);
193   fProtonContainer->SetBinLimits(0,gY); //rapidity or eta
194   fProtonContainer->SetBinLimits(1,gPt); //pT
195   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
196                                             "container for antiprotons",
197                                             kNSteps,2,iBin);
198   fAntiProtonContainer->SetBinLimits(0,gY); //rapidity or eta
199   fAntiProtonContainer->SetBinLimits(1,gPt); //pT
200
201
202 //____________________________________________________________________//
203 AliProtonAnalysis::~AliProtonAnalysis() {
204   //Default destructor
205   if(fProtonAnalysisBase) delete fProtonAnalysisBase;
206
207   if(fHistEvents) delete fHistEvents;
208   if(fHistYPtProtons) delete fHistYPtProtons;
209   if(fHistYPtAntiProtons) delete fHistYPtAntiProtons;
210   if(fHistEventStats) delete fHistEventStats;
211   if(fProtonContainer) delete fProtonContainer;
212   if(fAntiProtonContainer) delete fAntiProtonContainer;
213
214   if(fEffGridListProtons) delete fEffGridListProtons;
215   if(fCorrectionListProtons2D) delete fCorrectionListProtons2D;
216   if(fEfficiencyListProtons1D) delete fEfficiencyListProtons1D;
217   if(fCorrectionListProtons1D) delete fCorrectionListProtons1D;
218   if(fEffGridListAntiProtons) delete fEffGridListAntiProtons;
219   if(fCorrectionListAntiProtons2D) delete fCorrectionListAntiProtons2D;
220   if(fEfficiencyListAntiProtons1D) delete fEfficiencyListAntiProtons1D;
221   if(fCorrectionListAntiProtons1D) delete fCorrectionListAntiProtons1D;
222   if(fCorrectProtons) delete fCorrectProtons;
223   if(fCorrectAntiProtons) delete fCorrectAntiProtons;
224
225   //QA lists
226   if(fGlobalQAList) delete fGlobalQAList;
227   if(fQA2DList) delete fQA2DList;
228   if(fQAProtonsAcceptedList) delete fQAProtonsAcceptedList; 
229   if(fQAProtonsRejectedList) delete fQAProtonsRejectedList;
230   if(fQAAntiProtonsAcceptedList) delete fQAAntiProtonsAcceptedList; 
231   if(fQAAntiProtonsRejectedList) delete fQAAntiProtonsRejectedList;
232 }
233
234 //____________________________________________________________________//
235 void AliProtonAnalysis::InitAnalysisHistograms(Int_t nbinsY, 
236                                                Float_t fLowY, Float_t fHighY, 
237                                                Int_t nbinsPt, 
238                                                Float_t fLowPt, Float_t fHighPt) {
239   //Initializes the histograms
240   if(!fInitQAFlag) InitQA();
241   fNBinsY = nbinsY;
242   fMinY = fLowY;
243   fMaxY = fHighY;
244   fNBinsPt = nbinsPt;
245   fMinPt = fLowPt;
246   fMaxPt = fHighPt;
247
248   fHistEvents = new TH1I("fHistEvents","Analyzed events",2,0.5,2.5);
249   fHistEvents->GetXaxis()->SetBinLabel(1,"Analyzed events");
250   fHistEvents->GetXaxis()->SetBinLabel(2,"Events with (anti)protons");
251
252   fHistYPtProtons = new TH2D("fHistYPtProtons","Protons",
253                              fNBinsY,fMinY,fMaxY,
254                              fNBinsPt,fMinPt,fMaxPt);
255   fHistYPtProtons->SetStats(kTRUE);
256   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
257   if(fProtonAnalysisBase->GetEtaMode())
258     fHistYPtProtons->GetXaxis()->SetTitle("#eta");
259   else
260     fHistYPtProtons->GetXaxis()->SetTitle("y");
261   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
262
263   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","Antiprotons",
264                                  fNBinsY,fMinY,fMaxY,
265                                  fNBinsPt,fMinPt,fMaxPt);
266   fHistYPtAntiProtons->SetStats(kTRUE);
267   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
268   if(fProtonAnalysisBase->GetEtaMode())
269     fHistYPtAntiProtons->GetXaxis()->SetTitle("#eta");
270   else
271     fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
272   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
273
274   //setting up the containers
275   Int_t iBin[2];
276   iBin[0] = nbinsY;
277   iBin[1] = nbinsPt;
278   Double_t *binLimY = new Double_t[nbinsY+1];
279   Double_t *binLimPt = new Double_t[nbinsPt+1];
280   //values for bin lower bounds
281   for(Int_t i = 0; i <= nbinsY; i++) 
282     binLimY[i]=(Double_t)fLowY  + (fHighY - fLowY)  /nbinsY*(Double_t)i;
283   for(Int_t i = 0; i <= nbinsPt; i++) 
284     binLimPt[i]=(Double_t)fLowPt  + (fHighPt - fLowPt)  /nbinsPt*(Double_t)i;
285
286   fProtonContainer = new AliCFContainer("containerProtons",
287                                         "container for protons",
288                                         kNSteps,2,iBin);
289   fProtonContainer->SetBinLimits(0,binLimY); //rapidity
290   fProtonContainer->SetBinLimits(1,binLimPt); //pT
291   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
292                                             "container for antiprotons",
293                                             kNSteps,2,iBin);
294   fAntiProtonContainer->SetBinLimits(0,binLimY); //rapidity
295   fAntiProtonContainer->SetBinLimits(1,binLimPt); //pT
296 }
297
298 //____________________________________________________________________//
299 void AliProtonAnalysis::InitAnalysisHistograms(Int_t nbinsY, Double_t *gY, 
300                                                Int_t nbinsPt, Double_t *gPt) {
301   //Initializes the histograms using asymmetric values - global tracking
302   if(!fInitQAFlag) InitQA();
303   fNBinsY = nbinsY;
304   fMinY = gY[0];
305   fMaxY = gY[nbinsY];
306   fNBinsPt = nbinsPt;
307   fMinPt = gPt[0];
308   fMaxPt = gPt[nbinsPt];
309
310   fHistEvents = new TH1I("fHistEvents","Analyzed events",2,0.5,2.5);
311   fHistEvents->GetXaxis()->SetBinLabel(1,"Analyzed events");
312   fHistEvents->GetXaxis()->SetBinLabel(2,"Events with (anti)protons");
313
314   fHistYPtProtons = new TH2D("fHistYPtProtons","Protons",
315                              fNBinsY,gY,fNBinsPt,gPt);
316   fHistYPtProtons->SetStats(kTRUE);
317   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
318   if(fProtonAnalysisBase->GetEtaMode())
319     fHistYPtProtons->GetXaxis()->SetTitle("#eta");
320   else
321     fHistYPtProtons->GetXaxis()->SetTitle("y");
322   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
323
324   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","Antiprotons",
325                                  fNBinsY,gY,fNBinsPt,gPt);
326   fHistYPtAntiProtons->SetStats(kTRUE);
327   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV/c]");
328   if(fProtonAnalysisBase->GetEtaMode())
329     fHistYPtAntiProtons->GetXaxis()->SetTitle("#eta");
330   else
331     fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
332   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
333
334   //setting up the containers
335   Int_t iBin[2];
336   iBin[0] = nbinsY;
337   iBin[1] = nbinsPt;
338
339   fProtonContainer = new AliCFContainer("containerProtons",
340                                         "container for protons",
341                                         kNSteps,2,iBin);
342   fProtonContainer->SetBinLimits(0,gY); //rapidity
343   fProtonContainer->SetBinLimits(1,gPt); //pT
344   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
345                                             "container for antiprotons",
346                                             kNSteps,2,iBin);
347   fAntiProtonContainer->SetBinLimits(0,gY); //rapidity
348   fAntiProtonContainer->SetBinLimits(1,gPt); //pT
349 }
350
351 //____________________________________________________________________//
352 Bool_t AliProtonAnalysis::ReadFromFile(const char* filename) {
353   //Read the containers from the existing file
354   Bool_t status = kTRUE;
355
356   TFile *file = TFile::Open(filename);
357   if(!file) {
358     cout<<"Could not find the input file "<<filename<<endl;
359     status = kFALSE;
360   }
361
362   TList *list = (TList *)file->Get("outputList");
363   if(list) {
364     cout<<"Retrieving objects from the list "<<list->GetName()<<"..."<<endl; 
365     fHistYPtProtons = (TH2D *)list->At(0);
366     fHistYPtAntiProtons = (TH2D *)list->At(1);
367     fHistEvents = (TH1I *)list->At(2);
368     fProtonContainer = (AliCFContainer *)list->At(3);
369     fAntiProtonContainer = (AliCFContainer *)list->At(4);
370     fHistEventStats = (TH1F *)list->At(5);
371   }
372   else if(!list) {
373     cout<<"Retrieving objects from the file... "<<endl;
374     fHistYPtProtons = (TH2D *)file->Get("fHistYPtProtons");
375     fHistYPtAntiProtons = (TH2D *)file->Get("fHistYPtAntiProtons");
376     fHistEvents = (TH1I *)file->Get("fHistEvents");
377     fProtonContainer = (AliCFContainer *)file->Get("containerProtons");
378     fAntiProtonContainer = (AliCFContainer *)file->Get("containerAntiProtons");
379     fHistEventStats = (TH1F *)file->Get("fHistEventStats");
380   }
381   if((!fHistYPtProtons)||(!fHistYPtAntiProtons)||(!fHistEvents)
382      ||(!fProtonContainer)||(!fAntiProtonContainer)||(!fHistEventStats)) {
383     cout<<"Input containers were not found!!!"<<endl;
384     status = kFALSE;
385   }
386   else {
387     //fHistYPtProtons = fProtonContainer->ShowProjection(0,1,0);
388     //fHistYPtAntiProtons = fAntiProtonContainer->ShowProjection(0,1,0);
389     fHistYPtProtons->Sumw2();
390     fHistYPtAntiProtons->Sumw2();
391   }
392
393   return status;
394 }
395
396 //____________________________________________________________________//
397 TH1D *AliProtonAnalysis::GetProtonYHistogram() {
398   //Get the y histogram for protons
399   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
400
401   //TH1D *fYProtons = (TH1D *)fHistYPtProtons->ProjectionX("fYProtons",0,fHistYPtProtons->GetYaxis()->GetNbins(),"");
402   TH1D *fYProtons = fProtonContainer->ShowProjection(0,2); //variable-step
403    
404   fYProtons->SetStats(kFALSE);
405   fYProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
406   fYProtons->SetTitle("dN/dy protons");
407   fYProtons->SetMarkerStyle(kFullCircle);
408   fYProtons->SetMarkerColor(4);
409   if(nAnalyzedEvents > 0)
410   fYProtons->Scale(1./nAnalyzedEvents);
411   
412   return fYProtons;
413 }
414
415 //____________________________________________________________________//
416 TH1D *AliProtonAnalysis::GetAntiProtonYHistogram() {
417   //Get the y histogram for antiprotons
418   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
419   
420   //TH1D *fYAntiProtons = (TH1D *)fHistYPtAntiProtons->ProjectionX("fYAntiProtons",0,fHistYPtAntiProtons->GetYaxis()->GetNbins(),"");
421   TH1D *fYAntiProtons = fAntiProtonContainer->ShowProjection(0,2);//variable-step 
422  
423   fYAntiProtons->SetStats(kFALSE);
424   fYAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
425   fYAntiProtons->SetTitle("dN/dy antiprotons");
426   fYAntiProtons->SetMarkerStyle(kFullCircle);
427   fYAntiProtons->SetMarkerColor(4);
428   if(nAnalyzedEvents > 0)
429     fYAntiProtons->Scale(1./nAnalyzedEvents);
430
431   return fYAntiProtons;
432 }
433
434 //____________________________________________________________________//
435 TH1D *AliProtonAnalysis::GetProtonPtHistogram() {
436   //Get the Pt histogram for protons
437   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
438   
439   //TH1D *fPtProtons = (TH1D *)fHistYPtProtons->ProjectionY("fPtProtons",0,fHistYPtProtons->GetXaxis()->GetNbins(),""); 
440   TH1D *fPtProtons = fProtonContainer->ShowProjection(1,2); //variable-step
441
442   fPtProtons->SetStats(kFALSE);
443   fPtProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
444   fPtProtons->SetTitle("dN/dPt protons");
445   fPtProtons->SetMarkerStyle(kFullCircle);
446   fPtProtons->SetMarkerColor(4);
447   if(nAnalyzedEvents > 0)
448     fPtProtons->Scale(1./nAnalyzedEvents);
449
450   return fPtProtons;
451 }
452
453 //____________________________________________________________________//
454 TH1D *AliProtonAnalysis::GetAntiProtonPtHistogram() {
455   //Get the Pt histogram for antiprotons
456   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
457   
458   //TH1D *fPtAntiProtons = (TH1D *)fHistYPtAntiProtons->ProjectionY("fPtAntiProtons",0,fHistYPtProtons->GetXaxis()->GetNbins(),""); 
459   TH1D *fPtAntiProtons = fAntiProtonContainer->ShowProjection(1,2); //variable-step
460
461   fPtAntiProtons->SetStats(kFALSE);
462   fPtAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
463   fPtAntiProtons->SetTitle("dN/dPt antiprotons");
464   fPtAntiProtons->SetMarkerStyle(kFullCircle);
465   fPtAntiProtons->SetMarkerColor(4);
466   if(nAnalyzedEvents > 0)
467     fPtAntiProtons->Scale(1./nAnalyzedEvents);
468
469   return fPtAntiProtons;
470 }
471
472 //____________________________________________________________________//
473 TH1D *AliProtonAnalysis::GetProtonCorrectedYHistogram() {
474   //Get the corrected y histogram for protons
475   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
476
477   TH1D *fYProtons = fCorrectProtons->Project(0); //0: rapidity
478    
479   fYProtons->SetStats(kFALSE);
480   fYProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
481   fYProtons->GetXaxis()->SetTitle("y");
482   fYProtons->SetTitle("dN/dy protons");
483   fYProtons->SetMarkerStyle(kFullCircle);
484   fYProtons->SetMarkerColor(4);
485   if(nAnalyzedEvents > 0)
486     fYProtons->Scale(1./nAnalyzedEvents);
487   
488   return fYProtons;
489 }
490
491 //____________________________________________________________________//
492 TH1D *AliProtonAnalysis::GetAntiProtonCorrectedYHistogram() {
493   //Get the corrected y histogram for antiprotons
494   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
495
496   TH1D *fYAntiProtons = fCorrectAntiProtons->Project(0); //0: rapidity
497    
498   fYAntiProtons->SetStats(kFALSE);
499   fYAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
500   fYAntiProtons->GetXaxis()->SetTitle("y");
501   fYAntiProtons->SetTitle("dN/dy protons");
502   fYAntiProtons->SetMarkerStyle(kFullCircle);
503   fYAntiProtons->SetMarkerColor(4);
504   if(nAnalyzedEvents > 0)
505     fYAntiProtons->Scale(1./nAnalyzedEvents);
506   
507   return fYAntiProtons;
508 }
509
510 //____________________________________________________________________//
511 TH1D *AliProtonAnalysis::GetProtonCorrectedPtHistogram() {
512   //Get the corrected Pt histogram for protons
513   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
514
515   TH1D *fPtProtons = fCorrectProtons->Project(0); //0: rapidity
516    
517   fPtProtons->SetStats(kFALSE);
518   fPtProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
519   fPtProtons->GetXaxis()->SetTitle("P_{T} [GeV/c]");
520   fPtProtons->SetTitle("dN/dPt protons");
521   fPtProtons->SetMarkerStyle(kFullCircle);
522   fPtProtons->SetMarkerColor(4);
523   if(nAnalyzedEvents > 0)
524     fPtProtons->Scale(1./nAnalyzedEvents);
525   
526   return fPtProtons;
527 }
528
529 //____________________________________________________________________//
530 TH1D *AliProtonAnalysis::GetAntiProtonCorrectedPtHistogram() {
531   //Get the corrected Pt histogram for antiprotons
532   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
533
534   TH1D *fPtAntiProtons = fCorrectAntiProtons->Project(0); //0: rapidity
535    
536   fPtAntiProtons->SetStats(kFALSE);
537   fPtAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
538   fPtAntiProtons->GetXaxis()->SetTitle("P_{T} [GeV/c]");
539   fPtAntiProtons->SetTitle("dN/dPt antiprotons");
540   fPtAntiProtons->SetMarkerStyle(kFullCircle);
541   fPtAntiProtons->SetMarkerColor(4);
542   if(nAnalyzedEvents > 0)
543     fPtAntiProtons->Scale(1./nAnalyzedEvents);
544   
545   return fPtAntiProtons;
546 }
547
548 //____________________________________________________________________//
549 TH1D *AliProtonAnalysis::GetYRatioHistogram() {
550   //Returns the rapidity dependence of the ratio (uncorrected)
551   TH1D *fYProtons = GetProtonYHistogram();
552   TH1D *fYAntiProtons = GetAntiProtonYHistogram();
553   
554   TH1D *hRatioY = new TH1D("hRatioY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
555   hRatioY->Divide(fYAntiProtons,fYProtons,1.0,1.0);
556   hRatioY->SetMarkerStyle(kFullCircle);
557   hRatioY->SetMarkerColor(4);
558   hRatioY->GetYaxis()->SetTitle("#bar{p}/p");
559   hRatioY->GetYaxis()->SetTitleOffset(1.4);
560   hRatioY->GetXaxis()->SetTitle("y");
561   hRatioY->GetXaxis()->SetTitleColor(1);
562   hRatioY->SetStats(kFALSE);
563
564   return hRatioY;
565 }
566
567 //____________________________________________________________________//
568 TH1D *AliProtonAnalysis::GetYRatioCorrectedHistogram(TH2D *gCorrectionProtons, 
569                                                      TH2D *gCorrectionAntiProtons) {
570   //Returns the rapidity dependence of the ratio (corrected)
571   fHistYPtProtons->Multiply(gCorrectionProtons);
572   TH1D *fYProtons = GetProtonYHistogram();
573   fHistYPtAntiProtons->Multiply(gCorrectionAntiProtons);
574   TH1D *fYAntiProtons = GetAntiProtonYHistogram();
575   
576   TH1D *hRatioY = new TH1D("hRatioY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
577   hRatioY->Divide(fYAntiProtons,fYProtons,1.0,1.0);
578   hRatioY->SetMarkerStyle(kFullCircle);
579   hRatioY->SetMarkerColor(4);
580   hRatioY->GetYaxis()->SetTitle("#bar{p}/p");
581   hRatioY->GetYaxis()->SetTitleOffset(1.4);
582   hRatioY->GetXaxis()->SetTitle("y");
583   hRatioY->GetXaxis()->SetTitleColor(1);
584   hRatioY->SetStats(kFALSE);
585
586   return hRatioY;
587 }
588
589 //____________________________________________________________________//
590 TH1D *AliProtonAnalysis::GetPtRatioHistogram() {
591   //Returns the pT dependence of the ratio (uncorrected)
592   TH1D *fPtProtons = GetProtonPtHistogram();
593   TH1D *fPtAntiProtons = GetAntiProtonPtHistogram();
594   
595   TH1D *hRatioPt = new TH1D("hRatioPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
596   hRatioPt->Divide(fPtAntiProtons,fPtProtons,1.0,1.0);
597   hRatioPt->SetMarkerStyle(kFullCircle);
598   hRatioPt->SetMarkerColor(4);
599   hRatioPt->GetYaxis()->SetTitle("#bar{p}/p");
600   hRatioPt->GetYaxis()->SetTitleOffset(1.4);
601   hRatioPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
602   hRatioPt->GetXaxis()->SetTitleColor(1);
603   hRatioPt->SetStats(kFALSE);
604
605   return hRatioPt;
606 }
607
608 //____________________________________________________________________//
609 TH1D *AliProtonAnalysis::GetPtRatioCorrectedHistogram(TH2D *gCorrectionProtons, 
610                                                       TH2D *gCorrectionAntiProtons) {
611   //Returns the Pt dependence of the ratio (corrected)
612   fHistYPtProtons->Multiply(gCorrectionProtons);
613   TH1D *fPtProtons = GetProtonPtHistogram();
614   fHistYPtAntiProtons->Multiply(gCorrectionAntiProtons);
615   TH1D *fPtAntiProtons = GetAntiProtonPtHistogram();
616   
617   TH1D *hRatioPt = new TH1D("hRatioPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
618   hRatioPt->Divide(fPtAntiProtons,fPtProtons,1.0,1.0);
619   hRatioPt->SetMarkerStyle(kFullCircle);
620   hRatioPt->SetMarkerColor(4);
621   hRatioPt->GetYaxis()->SetTitle("#bar{p}/p");
622   hRatioPt->GetYaxis()->SetTitleOffset(1.4);
623   hRatioPt->GetXaxis()->SetTitle("y");
624   hRatioPt->GetXaxis()->SetTitleColor(1);
625   hRatioPt->SetStats(kFALSE);
626
627   return hRatioPt;
628 }
629
630 //____________________________________________________________________//
631 TH1D *AliProtonAnalysis::GetYAsymmetryHistogram() {
632   //Returns the rapidity dependence of the asymmetry (uncorrected)
633   TH1D *fYProtons = GetProtonYHistogram();
634   TH1D *fYAntiProtons = GetAntiProtonYHistogram();
635   
636   TH1D *hsum = new TH1D("hsumY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
637   hsum->Add(fYProtons,fYAntiProtons,1.0,1.0);
638
639   TH1D *hdiff = new TH1D("hdiffY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
640   hdiff->Add(fYProtons,fYAntiProtons,1.0,-1.0);
641
642   TH1D *hAsymmetryY = new TH1D("hAsymmetryY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
643   hAsymmetryY->Divide(hdiff,hsum,2.0,1.);
644   hAsymmetryY->SetMarkerStyle(kFullCircle);
645   hAsymmetryY->SetMarkerColor(4);
646   hAsymmetryY->GetYaxis()->SetTitle("A_{p}");
647   hAsymmetryY->GetYaxis()->SetTitleOffset(1.4);
648   hAsymmetryY->GetXaxis()->SetTitle("y");
649   hAsymmetryY->GetXaxis()->SetTitleColor(1);
650   hAsymmetryY->SetStats(kFALSE);
651
652   return hAsymmetryY;
653 }
654
655 //____________________________________________________________________//
656 TH1D *AliProtonAnalysis::GetPtAsymmetryHistogram() {
657   //Returns the pT dependence of the asymmetry (uncorrected)
658   TH1D *fPtProtons = GetProtonPtHistogram();
659   TH1D *fPtAntiProtons = GetAntiProtonPtHistogram();
660   
661   TH1D *hsum = new TH1D("hsumPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
662   hsum->Add(fPtProtons,fPtAntiProtons,1.0,1.0);
663
664   TH1D *hdiff = new TH1D("hdiffPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
665   hdiff->Add(fPtProtons,fPtAntiProtons,1.0,-1.0);
666
667   TH1D *hAsymmetryPt = new TH1D("hAsymmetryPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
668   hAsymmetryPt->Divide(hdiff,hsum,2.0,1.);
669   hAsymmetryPt->SetMarkerStyle(kFullCircle);
670   hAsymmetryPt->SetMarkerColor(4);
671   hAsymmetryPt->GetYaxis()->SetTitle("A_{p}");
672   hAsymmetryPt->GetYaxis()->SetTitleOffset(1.4);
673   hAsymmetryPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
674   hAsymmetryPt->GetXaxis()->SetTitleColor(1);
675   hAsymmetryPt->SetStats(kFALSE);
676
677   return hAsymmetryPt;
678 }
679
680 //____________________________________________________________________//
681 void AliProtonAnalysis::Analyze(AliESDEvent* esd,
682                                 const AliESDVertex *vertex) {
683   //Main analysis part - ESD
684   Int_t nTracks = 0;
685   Int_t nIdentifiedProtons = 0, nIdentifiedAntiProtons = 0;
686   Int_t nSurvivedProtons = 0, nSurvivedAntiProtons = 0;
687
688   fHistEvents->Fill(1); //number of analyzed events
689   Double_t containerInput[2] ;
690   Double_t gPt = 0.0, gP = 0.0;
691   nTracks = esd->GetNumberOfTracks();
692   for(Int_t iTracks = 0; iTracks < nTracks; iTracks++) {
693     AliESDtrack* track = esd->GetTrack(iTracks);
694     AliESDtrack trackTPC;
695
696     //in case it's a TPC only track relate it to the proper vertex
697     /*if(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC) {
698       Float_t p[2],cov[3];
699       track->GetImpactParametersTPC(p,cov);
700       if (p[0]==0 && p[1]==0)  
701         track->RelateToVertexTPC(((AliESDEvent*)esd)->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
702       if (!track->FillTPCOnlyTrack(trackTPC)) {
703         continue;
704       }
705       track = &trackTPC ;
706       }*/
707
708     Int_t  fIdxInt[200];
709     Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
710     Int_t npointsTPCdEdx = track->GetTPCsignalN();
711
712     if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)||(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
713       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
714       if(!tpcTrack) continue;
715       gPt = tpcTrack->Pt();
716       gP = tpcTrack->P();
717       
718       if(fProtonAnalysisBase->IsAccepted(esd,vertex,track)) {
719         ((TH2F *)(fQA2DList->At(0)))->Fill(gP,track->GetTPCsignal());
720         ((TH3F *)(fQA2DList->At(2)))->Fill(tpcTrack->Eta(),
721                                            tpcTrack->Phi()*180./TMath::Pi(),
722                                            npointsTPCdEdx);
723         ((TH3F *)(fQA2DList->At(4)))->Fill(tpcTrack->Eta(),
724                                            tpcTrack->Phi()*180./TMath::Pi(),
725                                            nClustersTPC);
726         ((TH3F *)(fQA2DList->At(6)))->Fill(gPt,
727                                            tpcTrack->Phi()*180./TMath::Pi(),
728                                            npointsTPCdEdx);
729         ((TH3F *)(fQA2DList->At(8)))->Fill(gPt,
730                                            tpcTrack->Phi()*180./TMath::Pi(),
731                                            nClustersTPC);       
732       }
733       if(fProtonAnalysisBase->IsProton(track)) {
734         if(fProtonAnalysisBase->IsAccepted(esd,vertex,track)) { 
735           ((TH2F *)(fQA2DList->At(1)))->Fill(gP,track->GetTPCsignal());
736           ((TH3F *)(fQA2DList->At(3)))->Fill(tpcTrack->Eta(),
737                                              tpcTrack->Phi()*180./TMath::Pi(),
738                                              npointsTPCdEdx);
739           ((TH3F *)(fQA2DList->At(5)))->Fill(tpcTrack->Eta(),
740                                              tpcTrack->Phi()*180./TMath::Pi(),
741                                              nClustersTPC);
742           ((TH3F *)(fQA2DList->At(7)))->Fill(gPt,
743                                              tpcTrack->Phi()*180./TMath::Pi(),
744                                              npointsTPCdEdx);
745           ((TH3F *)(fQA2DList->At(9)))->Fill(gPt,
746                                              tpcTrack->Phi()*180./TMath::Pi(),
747                                              nClustersTPC);
748         }
749         FillQA(esd,vertex,track);
750         if(tpcTrack->Charge() > 0) {
751           nIdentifiedProtons += 1;
752           if(fProtonAnalysisBase->GetEtaMode())
753             containerInput[0] = tpcTrack->Eta();
754           else
755             containerInput[0] = fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
756                                                               tpcTrack->Py(),
757                                                               tpcTrack->Pz());
758           containerInput[1] = gPt;
759           fProtonContainer->Fill(containerInput,0);   
760           
761           if(!fProtonAnalysisBase->IsAccepted(esd,vertex,track)) continue;//track cuts
762           if(fProtonAnalysisBase->GetEtaMode())
763             containerInput[0] = tpcTrack->Eta();
764           else
765             containerInput[0] = fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
766                                                               tpcTrack->Py(),
767                                                               tpcTrack->Pz());
768           containerInput[1] = gPt;
769           fProtonContainer->Fill(containerInput,1);   
770           
771           if(!fProtonAnalysisBase->IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
772           nSurvivedProtons += 1;
773           if(fProtonAnalysisBase->GetEtaMode()) {
774             fHistYPtProtons->Fill(tpcTrack->Eta(),
775                                   gPt);
776             containerInput[0] = tpcTrack->Eta();
777           }
778           else {
779             fHistYPtProtons->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
780                                                                 tpcTrack->Py(),
781                                                                 tpcTrack->Pz()),
782                                   gPt);
783             //fill the container
784             containerInput[0] = fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
785                                                               tpcTrack->Py(),
786                                                               tpcTrack->Pz());
787           }
788           containerInput[1] = gPt;
789           fProtonContainer->Fill(containerInput,2);   
790         }//protons
791         else if(tpcTrack->Charge() < 0) {
792           nIdentifiedAntiProtons += 1;
793           if(fProtonAnalysisBase->GetEtaMode())
794             containerInput[0] = tpcTrack->Eta();
795           else
796             containerInput[0] = fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
797                                                               tpcTrack->Py(),
798                                                               tpcTrack->Pz());
799           containerInput[1] = gPt;
800           fAntiProtonContainer->Fill(containerInput,0);   
801           
802           if(!fProtonAnalysisBase->IsAccepted(esd,vertex,track)) continue;//track cuts
803           if(fProtonAnalysisBase->GetEtaMode())
804             containerInput[0] = tpcTrack->Eta();
805           else
806             containerInput[0] = fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
807                                                               tpcTrack->Py(),
808                                                               tpcTrack->Pz());
809           containerInput[1] = gPt;
810           fAntiProtonContainer->Fill(containerInput,1);   
811           
812           if(!fProtonAnalysisBase->IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
813           nSurvivedAntiProtons += 1;
814           if(fProtonAnalysisBase->GetEtaMode()) {
815             fHistYPtAntiProtons->Fill(tpcTrack->Eta(),
816                                       gPt);
817             containerInput[0] = tpcTrack->Eta();
818           }
819           else {
820             fHistYPtAntiProtons->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
821                                                                     tpcTrack->Py(),
822                                                                     tpcTrack->Pz()),
823                                       gPt);
824             //fill the container
825             containerInput[0] = fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
826                                                               tpcTrack->Py(),
827                                                               tpcTrack->Pz());
828           }
829           containerInput[1] = gPt;
830           fAntiProtonContainer->Fill(containerInput,2);
831         }//antiprotons   
832       }//proton check
833     }//TPC only tracks
834     else if(fProtonAnalysisBase->GetAnalysisMode() == AliProtonAnalysisBase::kGlobal) {
835       gPt = track->Pt();
836       gP = track->P();
837       
838       if(fProtonAnalysisBase->IsAccepted(esd,vertex,track)) {
839         ((TH2F *)(fQA2DList->At(0)))->Fill(gP,track->GetTPCsignal());
840         ((TH3F *)(fQA2DList->At(2)))->Fill(track->Eta(),
841                                            track->Phi()*180./TMath::Pi(),
842                                            npointsTPCdEdx);
843         ((TH3F *)(fQA2DList->At(4)))->Fill(track->Eta(),
844                                            track->Phi()*180./TMath::Pi(),
845                                            nClustersTPC);
846         ((TH3F *)(fQA2DList->At(6)))->Fill(gPt,
847                                            track->Phi()*180./TMath::Pi(),
848                                            npointsTPCdEdx);
849         ((TH3F *)(fQA2DList->At(8)))->Fill(gPt,
850                                            track->Phi()*180./TMath::Pi(),
851                                            nClustersTPC);       
852       }
853       if(fProtonAnalysisBase->IsProton(track)) {
854         if(fProtonAnalysisBase->IsAccepted(esd,vertex,track)) {
855           ((TH2F *)(fQA2DList->At(1)))->Fill(gP,track->GetTPCsignal());
856           ((TH3F *)(fQA2DList->At(3)))->Fill(track->Eta(),
857                                              track->Phi()*180./TMath::Pi(),
858                                              npointsTPCdEdx);
859           ((TH3F *)(fQA2DList->At(5)))->Fill(track->Eta(),
860                                              track->Phi()*180./TMath::Pi(),
861                                              nClustersTPC);
862           ((TH3F *)(fQA2DList->At(7)))->Fill(gPt,
863                                              track->Phi()*180./TMath::Pi(),
864                                              npointsTPCdEdx);
865           ((TH3F *)(fQA2DList->At(9)))->Fill(gPt,
866                                              track->Phi()*180./TMath::Pi(),
867                                              nClustersTPC);     
868         }
869         FillQA(esd,vertex,track);
870         if(track->Charge() > 0) {
871           nIdentifiedProtons += 1;
872           if(fProtonAnalysisBase->GetEtaMode())
873             containerInput[0] = track->Eta();
874           else
875             containerInput[0] = fProtonAnalysisBase->Rapidity(track->Px(),
876                                                               track->Py(),
877                                                               track->Pz());
878           containerInput[1] = gPt;
879           fProtonContainer->Fill(containerInput,0);   
880             
881           if(!fProtonAnalysisBase->IsAccepted(esd,vertex,track)) continue;//track cuts
882           if(fProtonAnalysisBase->GetEtaMode())
883             containerInput[0] = track->Eta();
884           else
885             containerInput[0] = fProtonAnalysisBase->Rapidity(track->Px(),
886                                                               track->Py(),
887                                                               track->Pz());
888           containerInput[1] = gPt;
889           fProtonContainer->Fill(containerInput,1);   
890
891           if(!fProtonAnalysisBase->IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
892           nSurvivedProtons += 1;
893           if(fProtonAnalysisBase->GetEtaMode()) {
894             fHistYPtProtons->Fill(track->Eta(),
895                                   gPt);
896             containerInput[0] = track->Eta();
897           }
898           else {
899             fHistYPtProtons->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
900                                                                 track->Py(),
901                                                                 track->Pz()),
902                                   gPt);
903             //fill the container
904             containerInput[0] = fProtonAnalysisBase->Rapidity(track->Px(),
905                                                               track->Py(),
906                                                               track->Pz());
907           }
908           containerInput[1] = gPt;
909           fProtonContainer->Fill(containerInput,2);   
910         }//protons
911         else if(track->Charge() < 0) {
912           nIdentifiedAntiProtons += 1;
913           if(fProtonAnalysisBase->GetEtaMode())
914             containerInput[0] = track->Eta();
915           else
916             containerInput[0] = fProtonAnalysisBase->Rapidity(track->Px(),
917                                                               track->Py(),
918                                                               track->Pz());
919           containerInput[1] = gPt;
920           fAntiProtonContainer->Fill(containerInput,0);   
921
922           if(!fProtonAnalysisBase->IsAccepted(esd,vertex,track)) continue;//track cuts
923           if(fProtonAnalysisBase->GetEtaMode())
924             containerInput[0] = track->Eta();
925           else
926             containerInput[0] = fProtonAnalysisBase->Rapidity(track->Px(),
927                                                               track->Py(),
928                                                               track->Pz());
929           containerInput[1] = gPt;
930           fAntiProtonContainer->Fill(containerInput,1);   
931           
932           if(!fProtonAnalysisBase->IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
933           nSurvivedAntiProtons += 1;
934           if(fProtonAnalysisBase->GetEtaMode()) {
935             fHistYPtAntiProtons->Fill(track->Eta(),
936                                       gPt);
937             containerInput[0] = track->Eta();
938           }
939           else {
940             fHistYPtAntiProtons->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
941                                                                     track->Py(),
942                                                                     track->Pz()),
943                                       gPt);
944             //fill the container
945             containerInput[0] = fProtonAnalysisBase->Rapidity(track->Px(),
946                                                               track->Py(),
947                                                               track->Pz());
948           }
949           containerInput[1] = gPt;
950           fAntiProtonContainer->Fill(containerInput,2);   
951         }//antiprotons
952       }//proton check 
953     }//combined tracking
954   }//track loop 
955   
956   if((nIdentifiedProtons > 0)||(nIdentifiedAntiProtons > 0))
957     fHistEvents->Fill(2); //number of analyzed events with at least one (anti)proton
958
959   if(fProtonAnalysisBase->GetDebugMode())
960     Printf("Initial number of tracks: %d | Identified (anti)protons: %d - %d | Survived (anti)protons: %d - %d",nTracks,nIdentifiedProtons,nIdentifiedAntiProtons,nSurvivedProtons,nSurvivedAntiProtons);
961 }
962
963 //____________________________________________________________________//
964 void AliProtonAnalysis::Analyze(AliAODEvent* const fAOD) {
965   //Main analysis part - AOD
966   fHistEvents->Fill(1); //number of analyzed events
967   Int_t nTracks = fAOD->GetNumberOfTracks();
968   for(Int_t iTracks = 0; iTracks < nTracks; iTracks++) {
969     AliAODTrack* track = fAOD->GetTrack(iTracks);
970     Double_t gPt = track->Pt();
971     Double_t gP = track->P();
972     
973     //pid
974     Double_t probability[10];
975     track->GetPID(probability);
976     Double_t rcc = 0.0;
977     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) rcc += probability[i]*fProtonAnalysisBase->GetParticleFraction(i,gP);
978     if(rcc == 0.0) continue;
979     Double_t w[10];
980     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) w[i] = probability[i]*fProtonAnalysisBase->GetParticleFraction(i,gP)/rcc;
981     Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIESN,w);
982     if(fParticleType == 4) {
983       if(track->Charge() > 0) 
984         fHistYPtProtons->Fill(track->Y(fParticleType),gPt);
985       else if(track->Charge() < 0) 
986         fHistYPtAntiProtons->Fill(track->Y(fParticleType),gPt);
987     }//proton check
988   }//track loop 
989 }
990
991 //____________________________________________________________________//
992 void AliProtonAnalysis::Analyze(AliStack* const stack, 
993                                 Bool_t iInclusive) {
994   //Main analysis part - MC
995   fHistEvents->Fill(1); //number of analyzed events
996
997   Int_t nParticles = 0;
998   //inclusive protons - 
999   if(iInclusive) nParticles = stack->GetNtrack();
1000   else nParticles = stack->GetNprimary();
1001
1002   for(Int_t i = 0; i < nParticles; i++) {
1003     TParticle *particle = stack->Particle(i);
1004     if(!particle) continue;
1005
1006     //in case of inclusive protons reject the secondaries from hadronic inter.
1007     if(particle->GetUniqueID() == 13) continue;
1008
1009     if(TMath::Abs(particle->Eta()) > 1.0) continue;
1010     if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
1011     if((fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
1012
1013     Int_t pdgcode = particle->GetPdgCode();
1014     if(pdgcode == 2212) fHistYPtProtons->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
1015                                                                             particle->Py(),
1016                                                                             particle->Pz()),
1017                                               particle->Pt());
1018     if(pdgcode == -2212) fHistYPtAntiProtons->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
1019                                                                                  particle->Py(),
1020                                                                                  particle->Pz()),
1021                                                    particle->Pt());
1022   }//particle loop
1023 }
1024
1025 //____________________________________________________________________//
1026 Bool_t AliProtonAnalysis::PrintMean(TH1 *hist, Double_t edge) {
1027   //calculates the mean value of the ratio/asymmetry within \pm edge
1028   Double_t sum = 0.0;
1029   Int_t nentries = 0;
1030   //calculate the mean
1031   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1032     Double_t x = hist->GetBinCenter(i+1);
1033     Double_t y = hist->GetBinContent(i+1);
1034     if(TMath::Abs(x) < edge) {
1035       sum += y;
1036       nentries += 1;
1037     }
1038   }
1039   Double_t mean = 0.0;
1040   if(nentries != 0)
1041     mean = sum/nentries;
1042
1043   //calculate the error
1044   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1045     Double_t x = hist->GetBinCenter(i+1);
1046     Double_t y = hist->GetBinContent(i+1);
1047     if(TMath::Abs(x) < edge) {
1048       sum += TMath::Power((mean - y),2);
1049       nentries += 1;
1050     }
1051   }
1052
1053   Double_t error = 0.0;
1054   if(nentries != 0)
1055     error =  TMath::Sqrt(sum)/nentries;
1056
1057   cout<<"========================================="<<endl;
1058   cout<<"Input distribution: "<<hist->GetName()<<endl;
1059   cout<<"Interval used: -"<<edge<<" -> "<<edge<<endl;
1060   cout<<"Mean value :"<<mean<<endl;
1061   cout<<"Error: "<<error<<endl;
1062   cout<<"========================================="<<endl;
1063
1064   return 0;
1065 }
1066
1067 //____________________________________________________________________//
1068 Bool_t AliProtonAnalysis::PrintYields(TH1 *hist, Double_t edge) {
1069   //calculates the (anti)proton yields within the \pm edge
1070   Double_t sum = 0.0, sumerror = 0.0;
1071   Double_t error = 0.0;
1072   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1073     Double_t x = hist->GetBinCenter(i+1);
1074     Double_t y = hist->GetBinContent(i+1);
1075     if(TMath::Abs(x) < edge) {
1076       sum += y;
1077       sumerror += TMath::Power(hist->GetBinError(i+1),2); 
1078     }
1079   }
1080
1081   error = TMath::Sqrt(sumerror);
1082
1083   cout<<"========================================="<<endl;
1084   cout<<"Input distribution: "<<hist->GetName()<<endl;
1085   cout<<"Interval used: -"<<edge<<" -> "<<edge<<endl;
1086   cout<<"Yields :"<<sum<<endl;
1087   cout<<"Error: "<<error<<endl;
1088   cout<<"========================================="<<endl;
1089
1090   return 0;
1091 }
1092
1093 //____________________________________________________________________//
1094 void AliProtonAnalysis::Correct(Int_t step) {
1095   //Applies the correction maps to the initial containers
1096   fCorrectProtons = new AliCFDataGrid("correctProtons",
1097                                       "corrected data",
1098                                       *fProtonContainer);
1099   fCorrectProtons->SetMeasured(0);
1100   fCorrectProtons->ApplyEffCorrection(*(AliCFEffGrid *)fEffGridListProtons->At(step));
1101
1102   fCorrectAntiProtons = new AliCFDataGrid("correctAntiProtons",
1103                                           "corrected data",
1104                                           *fAntiProtonContainer);
1105   fCorrectAntiProtons->SetMeasured(0);
1106   fCorrectAntiProtons->ApplyEffCorrection(*(AliCFEffGrid *)fEffGridListAntiProtons->At(step));
1107 }
1108
1109 //____________________________________________________________________//
1110 Bool_t AliProtonAnalysis::ReadCorrectionContainer(const char* filename) {
1111   // Reads the outout of the correction framework task
1112   // Creates the correction maps
1113   // Puts the results in the different TList objects
1114   Bool_t status = kTRUE;
1115
1116   TFile *file = TFile::Open(filename);
1117   if(!file) {
1118     cout<<"Could not find the input CORRFW file "<<filename<<endl;
1119     status = kFALSE;
1120   }
1121
1122   //________________________________________//
1123   //Protons
1124   fEffGridListProtons = new TList();
1125   fCorrectionListProtons2D = new TList(); 
1126   fEfficiencyListProtons1D = new TList(); 
1127   fCorrectionListProtons1D = new TList();
1128   
1129   AliCFContainer *corrfwContainerProtons = (AliCFContainer*) (file->Get("containerProtons"));
1130   if(!corrfwContainerProtons) {
1131     cout<<"CORRFW container for protons not found!"<<endl;
1132     status = kFALSE;
1133   }
1134   
1135   Int_t nSteps = corrfwContainerProtons->GetNStep();
1136   TH2D *gYPt[4];
1137   //currently the GRID is formed by the y-pT parameters
1138   //Add Vz as a next step
1139   Int_t iRap = 0, iPt = 1;
1140   AliCFEffGrid *effProtonsStep0Step1 = new AliCFEffGrid("eff10",
1141                                          "effProtonsStep0Step1",
1142                                          *corrfwContainerProtons);
1143   effProtonsStep0Step1->CalculateEfficiency(1,0); //eff= step1/step0
1144   fEffGridListProtons->Add(effProtonsStep0Step1);
1145   gYPt[0] = effProtonsStep0Step1->Project(iRap,iPt);
1146   fCorrectionListProtons2D->Add(gYPt[0]);
1147   
1148   AliCFEffGrid *effProtonsStep0Step2 = new AliCFEffGrid("eff20",
1149                                          "effProtonsStep0Step2",
1150                                          *corrfwContainerProtons);
1151   effProtonsStep0Step2->CalculateEfficiency(2,0); //eff= step2/step0
1152   fEffGridListProtons->Add(effProtonsStep0Step2);
1153   gYPt[1] = effProtonsStep0Step2->Project(iRap,iPt);
1154   fCorrectionListProtons2D->Add(gYPt[1]);
1155
1156   AliCFEffGrid *effProtonsStep0Step3 = new AliCFEffGrid("eff30",
1157                                          "effProtonsStep0Step3",
1158                                          *corrfwContainerProtons);
1159   effProtonsStep0Step3->CalculateEfficiency(3,0); //eff= step1/step0
1160   fEffGridListProtons->Add(effProtonsStep0Step3);
1161   gYPt[2] = effProtonsStep0Step3->Project(iRap,iPt);
1162   fCorrectionListProtons2D->Add(gYPt[2]);
1163
1164   TH1D *gEfficiency[2][3]; //efficiency as a function of pT and of y (raws-[2])
1165   TH1D *gCorrection[2][3]; //efficiency as a function of pT and of y (raws-[2])
1166   TString gTitle;
1167   //Get the projection of the efficiency maps
1168   for(Int_t iParameter = 0; iParameter < 2; iParameter++) {
1169     gEfficiency[iParameter][0] = effProtonsStep0Step1->Project(iParameter);
1170     gTitle = "ProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1171     gTitle += "_Step0_Step1"; 
1172     gEfficiency[iParameter][0]->SetName(gTitle.Data());
1173     fEfficiencyListProtons1D->Add(gEfficiency[iParameter][0]);  
1174     gTitle = "ProtonsCorrection_Parameter"; gTitle += iParameter+1;
1175     gTitle += "_Step0_Step1"; 
1176     gCorrection[iParameter][0] = new TH1D(gTitle.Data(),
1177                                           gTitle.Data(),
1178                                           gEfficiency[iParameter][0]->GetNbinsX(),
1179                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmin(),
1180                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmax());
1181     //initialisation of the correction
1182     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][0]->GetNbinsX(); iBin++)
1183       gCorrection[iParameter][0]->SetBinContent(iBin,1.0);
1184
1185     gEfficiency[iParameter][1] = effProtonsStep0Step2->Project(iParameter);
1186     gTitle = "ProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1187     gTitle += "_Step0_Step2"; 
1188     gEfficiency[iParameter][1]->SetName(gTitle.Data());
1189     fEfficiencyListProtons1D->Add(gEfficiency[iParameter][1]);  
1190     gTitle = "ProtonsCorrection_Parameter"; gTitle += iParameter+1;
1191     gTitle += "_Step0_Step2"; 
1192     gCorrection[iParameter][1] = new TH1D(gTitle.Data(),
1193                                           gTitle.Data(),
1194                                           gEfficiency[iParameter][1]->GetNbinsX(),
1195                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmin(),
1196                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmax());
1197     //initialisation of the correction
1198     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][1]->GetNbinsX(); iBin++)
1199       gCorrection[iParameter][1]->SetBinContent(iBin,1.0);
1200
1201     gEfficiency[iParameter][2] = effProtonsStep0Step3->Project(iParameter);
1202     gTitle = "ProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1203     gTitle += "_Step0_Step3"; 
1204     gEfficiency[iParameter][2]->SetName(gTitle.Data());
1205     fEfficiencyListProtons1D->Add(gEfficiency[iParameter][2]);  
1206     gTitle = "ProtonsCorrection_Parameter"; gTitle += iParameter+1;
1207     gTitle += "_Step0_Step3"; 
1208     gCorrection[iParameter][2] = new TH1D(gTitle.Data(),
1209                                           gTitle.Data(),
1210                                           gEfficiency[iParameter][2]->GetNbinsX(),
1211                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmin(),
1212                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmax());
1213     //initialisation of the correction
1214     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][2]->GetNbinsX(); iBin++)
1215       gCorrection[iParameter][2]->SetBinContent(iBin,1.0);
1216   }//parameter loop
1217   //Calculate the 1D correction parameters as a function of y and pT
1218   for(Int_t iParameter = 0; iParameter < 2; iParameter++) { 
1219     for(Int_t iStep = 1; iStep < nSteps; iStep++) { 
1220       gCorrection[iParameter][iStep-1]->Divide(gEfficiency[iParameter][iStep-1]);
1221       fCorrectionListProtons1D->Add(gCorrection[iParameter][iStep-1]);  
1222     }
1223   }
1224
1225   //________________________________________//
1226   //AntiProtons
1227   fEffGridListAntiProtons = new TList();
1228   fCorrectionListAntiProtons2D = new TList(); 
1229   fEfficiencyListAntiProtons1D = new TList(); 
1230   fCorrectionListAntiProtons1D = new TList();
1231   
1232   AliCFContainer *corrfwContainerAntiProtons = (AliCFContainer*) (file->Get("containerAntiProtons"));
1233   if(!corrfwContainerAntiProtons) {
1234     cout<<"CORRFW container for antiprotons not found!"<<endl;
1235     status = kFALSE;
1236   }
1237   
1238   nSteps = corrfwContainerAntiProtons->GetNStep();
1239   //currently the GRID is formed by the y-pT parameters
1240   //Add Vz as a next step
1241   AliCFEffGrid *effAntiProtonsStep0Step1 = new AliCFEffGrid("eff10",
1242                                          "effAntiProtonsStep0Step1",
1243                                          *corrfwContainerAntiProtons);
1244   effAntiProtonsStep0Step1->CalculateEfficiency(1,0); //eff= step1/step0
1245   fEffGridListAntiProtons->Add(effAntiProtonsStep0Step1);
1246   gYPt[0] = effAntiProtonsStep0Step1->Project(iRap,iPt);
1247   fCorrectionListAntiProtons2D->Add(gYPt[0]);
1248   
1249   AliCFEffGrid *effAntiProtonsStep0Step2 = new AliCFEffGrid("eff20",
1250                                          "effAntiProtonsStep0Step2",
1251                                          *corrfwContainerAntiProtons);
1252   effAntiProtonsStep0Step2->CalculateEfficiency(2,0); //eff= step2/step0
1253   fEffGridListAntiProtons->Add(effAntiProtonsStep0Step2);
1254   gYPt[1] = effAntiProtonsStep0Step2->Project(iRap,iPt);
1255   fCorrectionListAntiProtons2D->Add(gYPt[1]);
1256
1257   AliCFEffGrid *effAntiProtonsStep0Step3 = new AliCFEffGrid("eff30",
1258                                          "effAntiProtonsStep0Step3",
1259                                          *corrfwContainerAntiProtons);
1260   effAntiProtonsStep0Step3->CalculateEfficiency(3,0); //eff= step1/step0
1261   fEffGridListAntiProtons->Add(effAntiProtonsStep0Step3);
1262   gYPt[2] = effAntiProtonsStep0Step3->Project(iRap,iPt);
1263   fCorrectionListAntiProtons2D->Add(gYPt[2]);
1264
1265   //Get the projection of the efficiency maps
1266   for(Int_t iParameter = 0; iParameter < 2; iParameter++) {
1267     gEfficiency[iParameter][0] = effAntiProtonsStep0Step1->Project(iParameter);
1268     gTitle = "AntiProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1269     gTitle += "_Step0_Step1"; 
1270     gEfficiency[iParameter][0]->SetName(gTitle.Data());
1271     fEfficiencyListAntiProtons1D->Add(gEfficiency[iParameter][0]);  
1272     gTitle = "AntiProtonsCorrection_Parameter"; gTitle += iParameter+1;
1273     gTitle += "_Step0_Step1"; 
1274     gCorrection[iParameter][0] = new TH1D(gTitle.Data(),
1275                                           gTitle.Data(),
1276                                           gEfficiency[iParameter][0]->GetNbinsX(),
1277                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmin(),
1278                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmax());
1279     //initialisation of the correction
1280     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][0]->GetNbinsX(); iBin++)
1281       gCorrection[iParameter][0]->SetBinContent(iBin,1.0);
1282
1283     gEfficiency[iParameter][1] = effAntiProtonsStep0Step2->Project(iParameter);
1284     gTitle = "AntiProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1285     gTitle += "_Step0_Step2"; 
1286     gEfficiency[iParameter][1]->SetName(gTitle.Data());
1287     fEfficiencyListAntiProtons1D->Add(gEfficiency[iParameter][1]);  
1288     gTitle = "AntiProtonsCorrection_Parameter"; gTitle += iParameter+1;
1289     gTitle += "_Step0_Step2"; 
1290     gCorrection[iParameter][1] = new TH1D(gTitle.Data(),
1291                                           gTitle.Data(),
1292                                           gEfficiency[iParameter][1]->GetNbinsX(),
1293                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmin(),
1294                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmax());
1295     //initialisation of the correction
1296     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][1]->GetNbinsX(); iBin++)
1297       gCorrection[iParameter][1]->SetBinContent(iBin,1.0);
1298
1299     gEfficiency[iParameter][2] = effAntiProtonsStep0Step3->Project(iParameter);
1300     gTitle = "AntiProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1301     gTitle += "_Step0_Step3"; 
1302     gEfficiency[iParameter][2]->SetName(gTitle.Data());
1303     fEfficiencyListAntiProtons1D->Add(gEfficiency[iParameter][2]);  
1304     gTitle = "AntiProtonsCorrection_Parameter"; gTitle += iParameter+1;
1305     gTitle += "_Step0_Step3"; 
1306     gCorrection[iParameter][2] = new TH1D(gTitle.Data(),
1307                                           gTitle.Data(),
1308                                           gEfficiency[iParameter][2]->GetNbinsX(),
1309                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmin(),
1310                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmax());
1311     //initialisation of the correction
1312     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][2]->GetNbinsX(); iBin++)
1313       gCorrection[iParameter][2]->SetBinContent(iBin,1.0);
1314   }//parameter loop
1315   //Calculate the 1D correction parameters as a function of y and pT
1316   for(Int_t iParameter = 0; iParameter < 2; iParameter++) { 
1317     for(Int_t iStep = 1; iStep < nSteps; iStep++) { 
1318       gCorrection[iParameter][iStep-1]->Divide(gEfficiency[iParameter][iStep-1]);
1319       fCorrectionListAntiProtons1D->Add(gCorrection[iParameter][iStep-1]);  
1320     }
1321   }
1322
1323   return status;
1324 }
1325  
1326 //____________________________________________________________________//
1327 void AliProtonAnalysis::InitQA() {
1328   //Applies the correction maps to the initial containers
1329   fInitQAFlag = kTRUE;
1330   fGlobalQAList = new TList();
1331   fGlobalQAList->SetName("fGlobalQAList");
1332
1333   //========================================================//
1334   fQA2DList = new TList();
1335   fQA2DList->SetName("fQA2DList");
1336   fGlobalQAList->Add(fQA2DList);
1337
1338   //dEdx plots
1339   TH2F *gHistdEdxP = new TH2F("gHistdEdxP","dE/dx (TPC); P [GeV/c]; dE/dx [a.u]",1000,0.05,20.05,600,0,600);
1340   fQA2DList->Add(gHistdEdxP);
1341   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);
1342   fQA2DList->Add(gHistProtonsdEdxP);
1343
1344   //eta-phi-Npoints(dEdx)
1345   TH3F *gHistEtaPhiTPCdEdxNPoints = new TH3F("gHistEtaPhiTPCdEdxNPoints",
1346                                              ";#eta;#phi;N_{points}(TPC)",
1347                                              fNBinsY,fMinY,fMaxY,
1348                                              100,0,360,
1349                                              100,0,200);
1350   gHistEtaPhiTPCdEdxNPoints->SetStats(kTRUE);
1351   fQA2DList->Add(gHistEtaPhiTPCdEdxNPoints);
1352   TH3F *gHistProtonsEtaPhiTPCdEdxNPoints = new TH3F("gHistProtonsEtaPhiTPCdEdxNPoints",
1353                                                     ";#eta;#phi;N_{points}(TPC)",
1354                                                     fNBinsY,fMinY,fMaxY,
1355                                                     100,0,360,
1356                                                     100,0,200);
1357   gHistProtonsEtaPhiTPCdEdxNPoints->SetStats(kTRUE);
1358   fQA2DList->Add(gHistProtonsEtaPhiTPCdEdxNPoints);
1359
1360   //eta-phi-Npoints
1361   TH3F *gHistEtaPhiTPCNPoints = new TH3F("gHistEtaPhiTPCNPoints",
1362                                          ";#eta;#phi;N_{points}(TPC)",
1363                                          fNBinsY,fMinY,fMaxY,
1364                                          100,0,360,
1365                                          100,0,200);
1366   gHistEtaPhiTPCNPoints->SetStats(kTRUE);
1367   fQA2DList->Add(gHistEtaPhiTPCNPoints);
1368   TH3F *gHistProtonsEtaPhiTPCNPoints = new TH3F("gHistProtonsEtaPhiTPCNPoints",
1369                                                 ";#eta;#phi;N_{points}(TPC)",
1370                                                 fNBinsY,fMinY,fMaxY,
1371                                                 100,0,360,
1372                                                 100,0,200);
1373   gHistProtonsEtaPhiTPCNPoints->SetStats(kTRUE);
1374   fQA2DList->Add(gHistProtonsEtaPhiTPCNPoints);
1375
1376   //pt-phi-Npoints(dEdx)
1377   TH3F *gHistPtPhiTPCdEdxNPoints = new TH3F("gHistPtPhiTPCdEdxNPoints",
1378                                             ";P_{T} [GeV/c];#phi;N_{points}(TPC)",
1379                                             fNBinsPt,fMinPt,fMaxPt,
1380                                             100,0,360,
1381                                             100,0,200);
1382   gHistPtPhiTPCdEdxNPoints->SetStats(kTRUE);
1383   fQA2DList->Add(gHistPtPhiTPCdEdxNPoints);
1384   TH3F *gHistProtonsPtPhiTPCdEdxNPoints = new TH3F("gHistProtonsPtPhiTPCdEdxNPoints",
1385                                                     ";P_{T} [GeV/c];#phi;N_{points}(TPC)",
1386                                                     fNBinsPt,fMinPt,fMaxPt,
1387                                                     100,0,360,
1388                                                     100,0,200);
1389   gHistProtonsPtPhiTPCdEdxNPoints->SetStats(kTRUE);
1390   fQA2DList->Add(gHistProtonsPtPhiTPCdEdxNPoints);
1391
1392   //pt-phi-Npoints
1393   TH3F *gHistPtPhiTPCNPoints = new TH3F("gHistPtPhiTPCNPoints",
1394                                         ";P_{T} [GeV/c];#phi;N_{points}(TPC)",
1395                                         fNBinsPt,fMinPt,fMaxPt,
1396                                         100,0,360,
1397                                         100,0,200);
1398   gHistPtPhiTPCNPoints->SetStats(kTRUE);
1399   fQA2DList->Add(gHistPtPhiTPCNPoints);
1400   TH3F *gHistProtonsPtPhiTPCNPoints = new TH3F("gHistProtonsPtPhiTPCNPoints",
1401                                                ";P_{T} [GeV/c];#phi;N_{points}(TPC)",
1402                                                fNBinsPt,fMinPt,fMaxPt,
1403                                                100,0,360,
1404                                                100,0,200);
1405   gHistProtonsPtPhiTPCNPoints->SetStats(kTRUE);
1406   fQA2DList->Add(gHistProtonsPtPhiTPCNPoints);
1407
1408   //========================================================//
1409   fQAProtonsAcceptedList = new TList();
1410   fQAProtonsAcceptedList->SetName("fQAProtonsAcceptedList");
1411   fGlobalQAList->Add(fQAProtonsAcceptedList);
1412   //Accepted protons
1413   TH1F *gProtonsITSClustersPass = new TH1F("gProtonsITSClustersPass",
1414                                             ";N_{clusters} (ITS);Entries",
1415                                             7,0,7);
1416   fQAProtonsAcceptedList->Add(gProtonsITSClustersPass);
1417   TH1F *gProtonsChi2PerClusterITSPass = new TH1F("gProtonsChi2PerClusterITSPass",
1418                                                  ";x^{2}/N_{clusters} (ITS);Entries",
1419                                                  100,0,4);
1420   fQAProtonsAcceptedList->Add(gProtonsChi2PerClusterITSPass);
1421   TH1F *gProtonsTPCClustersPass = new TH1F("gProtonsTPCClustersPass",
1422                                            ";N_{clusters} (TPC);Entries",
1423                                            100,0,200);
1424   fQAProtonsAcceptedList->Add(gProtonsTPCClustersPass);
1425   TH1F *gProtonsChi2PerClusterTPCPass = new TH1F("gProtonsChi2PerClusterTPCPass",
1426                                                  ";x^{2}/N_{clusters} (TPC);Entries",
1427                                                  100,0,4);
1428   fQAProtonsAcceptedList->Add(gProtonsChi2PerClusterTPCPass);
1429   TH1F *gProtonsExtCov11Pass = new TH1F("gProtonsExtCov11Pass",
1430                                         ";#sigma_{y} [cm];Entries",
1431                                         100,0,4);
1432   fQAProtonsAcceptedList->Add(gProtonsExtCov11Pass);
1433   TH1F *gProtonsExtCov22Pass = new TH1F("gProtonsExtCov22Pass",
1434                                         ";#sigma_{z} [cm];Entries",
1435                                         100,0,4);
1436   fQAProtonsAcceptedList->Add(gProtonsExtCov22Pass);
1437   TH1F *gProtonsExtCov33Pass = new TH1F("gProtonsExtCov33Pass",
1438                                         ";#sigma_{sin(#phi)};Entries",
1439                                         100,0,4);
1440   fQAProtonsAcceptedList->Add(gProtonsExtCov33Pass);
1441   TH1F *gProtonsExtCov44Pass = new TH1F("gProtonsExtCov44Pass",
1442                                         ";#sigma_{tan(#lambda)};Entries",
1443                                         100,0,4);
1444   fQAProtonsAcceptedList->Add(gProtonsExtCov44Pass);
1445   TH1F *gProtonsExtCov55Pass = new TH1F("gProtonsExtCov55Pass",
1446                                         ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1447                                         100,0,4);
1448   fQAProtonsAcceptedList->Add(gProtonsExtCov55Pass);
1449   TH1F *gProtonsSigmaToVertexPass = new TH1F("gProtonsSigmaToVertexPass",
1450                                              ";#sigma_{Vertex};Entries",
1451                                              100,0,10);
1452   fQAProtonsAcceptedList->Add(gProtonsSigmaToVertexPass);
1453   TH1F *gProtonsSigmaToVertexTPCPass = new TH1F("gProtonsSigmaToVertexTPCPass",
1454                                                 ";#sigma_{Vertex};Entries",
1455                                                 100,0,10);
1456   fQAProtonsAcceptedList->Add(gProtonsSigmaToVertexTPCPass);
1457   TH1F *gProtonsDCAXYPass = new TH1F("gProtonsDCAXYPass",
1458                                      ";DCA_{xy} [cm];Entries",
1459                                      100,0,20);
1460   fQAProtonsAcceptedList->Add(gProtonsDCAXYPass);
1461   TH1F *gProtonsDCAXYTPCPass = new TH1F("gProtonsDCAXYTPCPass",
1462                                         ";DCA_{xy} [cm];Entries",
1463                                         100,0,20);
1464   fQAProtonsAcceptedList->Add(gProtonsDCAXYTPCPass);
1465   TH1F *gProtonsDCAZPass = new TH1F("gProtonsDCAZPass",
1466                                     ";DCA_{z} [cm];Entries",
1467                                     100,0,20);
1468   fQAProtonsAcceptedList->Add(gProtonsDCAZPass);
1469   TH1F *gProtonsDCAZTPCPass = new TH1F("gProtonsDCAZTPCPass",
1470                                        ";DCA_{z} [cm];Entries",
1471                                        100,0,20);
1472   fQAProtonsAcceptedList->Add(gProtonsDCAZTPCPass);
1473   TH1F *gProtonsConstrainChi2Pass = new TH1F("gProtonsConstrainChi2Pass",
1474                                              ";Log_{10}(#chi^{2});Entries",
1475                                              100,-10,10);
1476   fQAProtonsAcceptedList->Add(gProtonsConstrainChi2Pass);
1477   TH1F *gProtonsITSRefitPass = new TH1F("gProtonsITSRefitPass",
1478                                         "",10,-1,1);
1479   fQAProtonsAcceptedList->Add(gProtonsITSRefitPass);
1480   TH1F *gProtonsTPCRefitPass = new TH1F("gProtonsTPCRefitPass",
1481                                         "",10,-1,1);
1482   fQAProtonsAcceptedList->Add(gProtonsTPCRefitPass);
1483   TH1F *gProtonsESDpidPass = new TH1F("gProtonsESDpidPass",
1484                                       "",10,-1,1);
1485   fQAProtonsAcceptedList->Add(gProtonsESDpidPass);
1486   TH1F *gProtonsTPCpidPass = new TH1F("gProtonsTPCpidPass",
1487                                       "",10,-1,1);
1488   fQAProtonsAcceptedList->Add(gProtonsTPCpidPass);
1489   TH1F *gProtonsPointOnITSLayer1Pass = new TH1F("gProtonsPointOnITSLayer1Pass",
1490                                                 "",10,-1,1);
1491   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer1Pass);
1492   TH1F *gProtonsPointOnITSLayer2Pass = new TH1F("gProtonsPointOnITSLayer2Pass",
1493                                                 "",10,-1,1);
1494   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer2Pass);
1495   TH1F *gProtonsPointOnITSLayer3Pass = new TH1F("gProtonsPointOnITSLayer3Pass",
1496                                                 "",10,-1,1);
1497   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer3Pass);
1498   TH1F *gProtonsPointOnITSLayer4Pass = new TH1F("gProtonsPointOnITSLayer4Pass",
1499                                                 "",10,-1,1);
1500   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer4Pass);
1501   TH1F *gProtonsPointOnITSLayer5Pass = new TH1F("gProtonsPointOnITSLayer5Pass",
1502                                                 "",10,-1,1);
1503   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer5Pass);
1504   TH1F *gProtonsPointOnITSLayer6Pass = new TH1F("gProtonsPointOnITSLayer6Pass",
1505                                                 "",10,-1,1);
1506   fQAProtonsAcceptedList->Add(gProtonsPointOnITSLayer6Pass);
1507   TH1F *gProtonsNumberOfTPCdEdxPointsPass = new TH1F("gProtonsNumberOfTPCdEdxPointsPass","",100,0,200);
1508   fQAProtonsAcceptedList->Add(gProtonsNumberOfTPCdEdxPointsPass);
1509
1510   //========================================================//  
1511   fQAProtonsRejectedList = new TList();
1512   fQAProtonsRejectedList->SetName("fQAProtonsRejectedList");
1513   fGlobalQAList->Add(fQAProtonsRejectedList);
1514   //Rejected protons
1515   TH1F *gProtonsITSClustersReject = new TH1F("gProtonsITSClustersReject",
1516                                              ";N_{clusters} (ITS);Entries",
1517                                              7,0,7);
1518   gProtonsITSClustersReject->SetFillColor(kRed-2);
1519   fQAProtonsRejectedList->Add(gProtonsITSClustersReject);
1520   TH1F *gProtonsChi2PerClusterITSReject = new TH1F("gProtonsChi2PerClusterITSReject",
1521                                                    ";x^{2}/N_{clusters} (ITS);Entries",
1522                                                    100,0,4);
1523   gProtonsChi2PerClusterITSReject->SetFillColor(kRed-2);
1524   fQAProtonsRejectedList->Add(gProtonsChi2PerClusterITSReject);
1525   TH1F *gProtonsTPCClustersReject = new TH1F("gProtonsTPCClustersReject",
1526                                              ";N_{clusters} (TPC);Entries",
1527                                              100,0,200);
1528   gProtonsTPCClustersReject->SetFillColor(kRed-2);
1529   fQAProtonsRejectedList->Add(gProtonsTPCClustersReject);
1530   TH1F *gProtonsChi2PerClusterTPCReject = new TH1F("gProtonsChi2PerClusterTPCReject",
1531                                                    ";x^{2}/N_{clusters} (TPC);Entries",
1532                                                    100,0,4);
1533   gProtonsChi2PerClusterTPCReject->SetFillColor(kRed-2);
1534   fQAProtonsRejectedList->Add(gProtonsChi2PerClusterTPCReject);
1535   TH1F *gProtonsExtCov11Reject = new TH1F("gProtonsExtCov11Reject",
1536                                           ";#sigma_{y} [cm];Entries",
1537                                           100,0,4);
1538   gProtonsExtCov11Reject->SetFillColor(kRed-2);
1539   fQAProtonsRejectedList->Add(gProtonsExtCov11Reject);
1540   TH1F *gProtonsExtCov22Reject = new TH1F("gProtonsExtCov22Reject",
1541                                           ";#sigma_{z} [cm];Entries",
1542                                           100,0,4);
1543   gProtonsExtCov22Reject->SetFillColor(kRed-2);
1544   fQAProtonsRejectedList->Add(gProtonsExtCov22Reject);
1545   TH1F *gProtonsExtCov33Reject = new TH1F("gProtonsExtCov33Reject",
1546                                           ";#sigma_{sin(#phi)};Entries",
1547                                           100,0,4);
1548   gProtonsExtCov33Reject->SetFillColor(kRed-2);
1549   fQAProtonsRejectedList->Add(gProtonsExtCov33Reject);
1550   TH1F *gProtonsExtCov44Reject = new TH1F("gProtonsExtCov44Reject",
1551                                           ";#sigma_{tan(#lambda)};Entries",
1552                                           100,0,4);
1553   gProtonsExtCov44Reject->SetFillColor(kRed-2);
1554   fQAProtonsRejectedList->Add(gProtonsExtCov44Reject);
1555   TH1F *gProtonsExtCov55Reject = new TH1F("gProtonsExtCov55Reject",
1556                                           ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1557                                           100,0,4);
1558   gProtonsExtCov55Reject->SetFillColor(kRed-2);
1559   fQAProtonsRejectedList->Add(gProtonsExtCov55Reject);
1560   TH1F *gProtonsSigmaToVertexReject = new TH1F("gProtonsSigmaToVertexReject",
1561                                                ";#sigma_{Vertex};Entries",
1562                                                100,0,10);
1563   gProtonsSigmaToVertexReject->SetFillColor(kRed-2);
1564   fQAProtonsRejectedList->Add(gProtonsSigmaToVertexReject);
1565   TH1F *gProtonsSigmaToVertexTPCReject = new TH1F("gProtonsSigmaToVertexTPCReject",
1566                                                   ";#sigma_{Vertex};Entries",
1567                                                   100,0,10);
1568   gProtonsSigmaToVertexTPCReject->SetFillColor(kRed-2);
1569   fQAProtonsRejectedList->Add(gProtonsSigmaToVertexTPCReject);
1570   TH1F *gProtonsDCAXYReject = new TH1F("gProtonsDCAXYReject",
1571                                        ";DCA_{xy} [cm];Entries",
1572                                        100,0,20);
1573   gProtonsDCAXYReject->SetFillColor(kRed-2);
1574   fQAProtonsRejectedList->Add(gProtonsDCAXYReject);
1575   TH1F *gProtonsDCAXYTPCReject = new TH1F("gProtonsDCAXYTPCReject",
1576                                           ";DCA_{xy} [cm];Entries",
1577                                           100,0,20);
1578   gProtonsDCAXYTPCReject->SetFillColor(kRed-2);
1579   fQAProtonsRejectedList->Add(gProtonsDCAXYTPCReject);
1580   TH1F *gProtonsDCAZReject = new TH1F("gProtonsDCAZReject",
1581                                       ";DCA_{z} [cm];Entries",
1582                                       100,0,20);
1583   gProtonsDCAZReject->SetFillColor(kRed-2);
1584   fQAProtonsRejectedList->Add(gProtonsDCAZReject);
1585   TH1F *gProtonsDCAZTPCReject = new TH1F("gProtonsDCAZTPCReject",
1586                                          ";DCA_{z} [cm];Entries",
1587                                          100,0,20);
1588   gProtonsDCAZTPCReject->SetFillColor(kRed-2);
1589   fQAProtonsRejectedList->Add(gProtonsDCAZTPCReject);
1590   TH1F *gProtonsConstrainChi2Reject = new TH1F("gProtonsConstrainChi2Reject",
1591                                                ";Log_{10}(#chi^{2});Entries",
1592                                                100,-10,10);
1593   gProtonsConstrainChi2Reject->SetFillColor(kRed-2);
1594   fQAProtonsRejectedList->Add(gProtonsConstrainChi2Reject);
1595   TH1F *gProtonsITSRefitReject = new TH1F("gProtonsITSRefitReject",
1596                                           "",10,-1,1);
1597   gProtonsITSRefitReject->SetFillColor(kRed-2);
1598   fQAProtonsRejectedList->Add(gProtonsITSRefitReject);
1599   TH1F *gProtonsTPCRefitReject = new TH1F("gProtonsTPCRefitReject",
1600                                           "",10,-1,1);
1601   gProtonsTPCRefitReject->SetFillColor(kRed-2);
1602   fQAProtonsRejectedList->Add(gProtonsTPCRefitReject);
1603   TH1F *gProtonsESDpidReject = new TH1F("gProtonsESDpidReject",
1604                                         "",10,-1,1);
1605   gProtonsESDpidReject->SetFillColor(kRed-2);
1606   fQAProtonsRejectedList->Add(gProtonsESDpidReject);
1607   TH1F *gProtonsTPCpidReject = new TH1F("gProtonsTPCpidReject",
1608                                         "",10,-1,1);
1609   gProtonsTPCpidReject->SetFillColor(kRed-2);
1610   fQAProtonsRejectedList->Add(gProtonsTPCpidReject);
1611   TH1F *gProtonsPointOnITSLayer1Reject = new TH1F("gProtonsPointOnITSLayer1Reject",
1612                                                   "",10,-1,1);
1613   gProtonsPointOnITSLayer1Reject->SetFillColor(kRed-2);
1614   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer1Reject);
1615   TH1F *gProtonsPointOnITSLayer2Reject = new TH1F("gProtonsPointOnITSLayer2Reject",
1616                                                   "",10,-1,1);
1617   gProtonsPointOnITSLayer2Reject->SetFillColor(kRed-2);
1618   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer2Reject);
1619   TH1F *gProtonsPointOnITSLayer3Reject = new TH1F("gProtonsPointOnITSLayer3Reject",
1620                                                   "",10,-1,1);
1621   gProtonsPointOnITSLayer3Reject->SetFillColor(kRed-2);
1622   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer3Reject);
1623   TH1F *gProtonsPointOnITSLayer4Reject = new TH1F("gProtonsPointOnITSLayer4Reject",
1624                                                   "",10,-1,1);
1625   gProtonsPointOnITSLayer4Reject->SetFillColor(kRed-2);
1626   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer4Reject);
1627   TH1F *gProtonsPointOnITSLayer5Reject = new TH1F("gProtonsPointOnITSLayer5Reject",
1628                                                   "",10,-1,1);
1629   gProtonsPointOnITSLayer5Reject->SetFillColor(kRed-2);
1630   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer5Reject);
1631   TH1F *gProtonsPointOnITSLayer6Reject = new TH1F("gProtonsPointOnITSLayer6Reject",
1632                                                   "",10,-1,1);
1633   gProtonsPointOnITSLayer6Reject->SetFillColor(kRed-2);
1634   fQAProtonsRejectedList->Add(gProtonsPointOnITSLayer6Reject);
1635   TH1F *gProtonsNumberOfTPCdEdxPointsReject = new TH1F("gProtonsNumberOfTPCdEdxPointsReject","",100,0,200);
1636   gProtonsNumberOfTPCdEdxPointsReject->SetFillColor(kRed-2);
1637   fQAProtonsRejectedList->Add(gProtonsNumberOfTPCdEdxPointsReject);
1638     
1639   //========================================================//
1640   fQAAntiProtonsAcceptedList = new TList();
1641   fQAAntiProtonsAcceptedList->SetName("fQAAntiProtonsAcceptedList");
1642   fGlobalQAList->Add(fQAAntiProtonsAcceptedList);
1643   //Accepted antiprotons
1644   TH1F *gAntiProtonsITSClustersPass = new TH1F("gAntiProtonsITSClustersPass",
1645                                                ";N_{clusters} (ITS);Entries",
1646                                                7,0,7);
1647   fQAAntiProtonsAcceptedList->Add(gAntiProtonsITSClustersPass);
1648   TH1F *gAntiProtonsChi2PerClusterITSPass = new TH1F("gAntiProtonsChi2PerClusterITSPass",
1649                                                      ";x^{2}/N_{clusters} (ITS);Entries",
1650                                                      100,0,4);
1651   fQAAntiProtonsAcceptedList->Add(gAntiProtonsChi2PerClusterITSPass);
1652   TH1F *gAntiProtonsTPCClustersPass = new TH1F("gAntiProtonsTPCClustersPass",
1653                                                ";N_{clusters} (TPC);Entries",
1654                                                100,0,200);
1655   fQAAntiProtonsAcceptedList->Add(gAntiProtonsTPCClustersPass);
1656   TH1F *gAntiProtonsChi2PerClusterTPCPass = new TH1F("gAntiProtonsChi2PerClusterTPCPass",
1657                                                      ";x^{2}/N_{clusters} (TPC);Entries",
1658                                                      100,0,4);
1659   fQAAntiProtonsAcceptedList->Add(gAntiProtonsChi2PerClusterTPCPass);
1660   TH1F *gAntiProtonsExtCov11Pass = new TH1F("gAntiProtonsExtCov11Pass",
1661                                             ";#sigma_{y} [cm];Entries",
1662                                             100,0,4);
1663   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov11Pass);
1664   TH1F *gAntiProtonsExtCov22Pass = new TH1F("gAntiProtonsExtCov22Pass",
1665                                             ";#sigma_{z} [cm];Entries",
1666                                             100,0,4);
1667   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov22Pass);
1668   TH1F *gAntiProtonsExtCov33Pass = new TH1F("gAntiProtonsExtCov33Pass",
1669                                             ";#sigma_{sin(#phi)};Entries",
1670                                             100,0,4);
1671   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov33Pass);
1672   TH1F *gAntiProtonsExtCov44Pass = new TH1F("gAntiProtonsExtCov44Pass",
1673                                             ";#sigma_{tan(#lambda)};Entries",
1674                                             100,0,4);
1675   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov44Pass);
1676   TH1F *gAntiProtonsExtCov55Pass = new TH1F("gAntiProtonsExtCov55Pass",
1677                                             ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1678                                             100,0,4);
1679   fQAAntiProtonsAcceptedList->Add(gAntiProtonsExtCov55Pass);
1680   TH1F *gAntiProtonsSigmaToVertexPass = new TH1F("gAntiProtonsSigmaToVertexPass",
1681                                                  ";#sigma_{Vertex};Entries",
1682                                                  100,0,10);
1683   fQAAntiProtonsAcceptedList->Add(gAntiProtonsSigmaToVertexPass);
1684   TH1F *gAntiProtonsSigmaToVertexTPCPass = new TH1F("gAntiProtonsSigmaToVertexTPCPass",
1685                                                     ";#sigma_{Vertex};Entries",
1686                                                     100,0,10);
1687   fQAAntiProtonsAcceptedList->Add(gAntiProtonsSigmaToVertexTPCPass);
1688   TH1F *gAntiProtonsDCAXYPass = new TH1F("gAntiProtonsDCAXYPass",
1689                                          ";DCA_{xy} [cm];Entries",
1690                                          100,0,20);
1691   fQAAntiProtonsAcceptedList->Add(gAntiProtonsDCAXYPass);
1692   TH1F *gAntiProtonsDCAXYTPCPass = new TH1F("gAntiProtonsDCAXYTPCPass",
1693                                             ";DCA_{xy} [cm];Entries",
1694                                             100,0,20);
1695   fQAAntiProtonsAcceptedList->Add(gAntiProtonsDCAXYTPCPass);
1696   TH1F *gAntiProtonsDCAZPass = new TH1F("gAntiProtonsDCAZPass",
1697                                         ";DCA_{z} [cm];Entries",
1698                                         100,0,20);
1699   fQAAntiProtonsAcceptedList->Add(gAntiProtonsDCAZPass);
1700   TH1F *gAntiProtonsDCAZTPCPass = new TH1F("gAntiProtonsDCAZTPCPass",
1701                                            ";DCA_{z} [cm];Entries",
1702                                            100,0,20);
1703   fQAAntiProtonsAcceptedList->Add(gAntiProtonsDCAZTPCPass);
1704   TH1F *gAntiProtonsConstrainChi2Pass = new TH1F("gAntiProtonsConstrainChi2Pass",
1705                                                  ";Log_{10}(#chi^{2});Entries",
1706                                                  100,-10,10);
1707   fQAAntiProtonsAcceptedList->Add(gAntiProtonsConstrainChi2Pass);
1708   TH1F *gAntiProtonsITSRefitPass = new TH1F("gAntiProtonsITSRefitPass",
1709                                             "",10,-1,1);
1710   fQAAntiProtonsAcceptedList->Add(gAntiProtonsITSRefitPass);
1711   TH1F *gAntiProtonsTPCRefitPass = new TH1F("gAntiProtonsTPCRefitPass",
1712                                             "",10,-1,1);
1713   fQAAntiProtonsAcceptedList->Add(gAntiProtonsTPCRefitPass);
1714   TH1F *gAntiProtonsESDpidPass = new TH1F("gAntiProtonsESDpidPass",
1715                                           "",10,-1,1);
1716   fQAAntiProtonsAcceptedList->Add(gAntiProtonsESDpidPass);
1717   TH1F *gAntiProtonsTPCpidPass = new TH1F("gAntiProtonsTPCpidPass",
1718                                           "",10,-1,1);
1719   fQAAntiProtonsAcceptedList->Add(gAntiProtonsTPCpidPass);
1720   TH1F *gAntiProtonsPointOnITSLayer1Pass = new TH1F("gAntiProtonsPointOnITSLayer1Pass",
1721                                                     "",10,-1,1);
1722   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer1Pass);
1723   TH1F *gAntiProtonsPointOnITSLayer2Pass = new TH1F("gAntiProtonsPointOnITSLayer2Pass",
1724                                                     "",10,-1,1);
1725   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer2Pass);
1726   TH1F *gAntiProtonsPointOnITSLayer3Pass = new TH1F("gAntiProtonsPointOnITSLayer3Pass",
1727                                                     "",10,-1,1);
1728   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer3Pass);
1729   TH1F *gAntiProtonsPointOnITSLayer4Pass = new TH1F("gAntiProtonsPointOnITSLayer4Pass",
1730                                                     "",10,-1,1);
1731   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer4Pass);
1732   TH1F *gAntiProtonsPointOnITSLayer5Pass = new TH1F("gAntiProtonsPointOnITSLayer5Pass",
1733                                                     "",10,-1,1);
1734   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer5Pass);
1735   TH1F *gAntiProtonsPointOnITSLayer6Pass = new TH1F("gAntiProtonsPointOnITSLayer6Pass",
1736                                                     "",10,-1,1);
1737   fQAAntiProtonsAcceptedList->Add(gAntiProtonsPointOnITSLayer6Pass);
1738   TH1F *gAntiProtonsNumberOfTPCdEdxPointsPass = new TH1F("gAntiProtonsNumberOfTPCdEdxPointsPass","",100,0,200);
1739   fQAAntiProtonsAcceptedList->Add(gAntiProtonsNumberOfTPCdEdxPointsPass);
1740   
1741   //========================================================//
1742   fQAAntiProtonsRejectedList = new TList();
1743   fQAAntiProtonsRejectedList->SetName("fQAAntiProtonsRejectedList");
1744   fGlobalQAList->Add(fQAAntiProtonsRejectedList);
1745   //Rejected antiprotons
1746   TH1F *gAntiProtonsITSClustersReject = new TH1F("gAntiProtonsITSClustersReject",
1747                                                  ";N_{clusters} (ITS);Entries",
1748                                                  7,0,7);
1749   gAntiProtonsITSClustersReject->SetFillColor(kRed-2);
1750   fQAAntiProtonsRejectedList->Add(gAntiProtonsITSClustersReject);
1751   TH1F *gAntiProtonsChi2PerClusterITSReject = new TH1F("gAntiProtonsChi2PerClusterITSReject",
1752                                                        ";x^{2}/N_{clusters} (ITS);Entries",
1753                                                        100,0,4);
1754   gAntiProtonsChi2PerClusterITSReject->SetFillColor(kRed-2);
1755   fQAAntiProtonsRejectedList->Add(gAntiProtonsChi2PerClusterITSReject);
1756   TH1F *gAntiProtonsTPCClustersReject = new TH1F("gAntiProtonsTPCClustersReject",
1757                                                  ";N_{clusters} (TPC);Entries",
1758                                                  100,0,200);
1759   gAntiProtonsTPCClustersReject->SetFillColor(kRed-2);
1760   fQAAntiProtonsRejectedList->Add(gAntiProtonsTPCClustersReject);
1761   TH1F *gAntiProtonsChi2PerClusterTPCReject = new TH1F("gAntiProtonsChi2PerClusterTPCReject",
1762                                                        ";x^{2}/N_{clusters} (TPC);Entries",
1763                                                        100,0,4);
1764   gAntiProtonsChi2PerClusterTPCReject->SetFillColor(kRed-2);
1765   fQAAntiProtonsRejectedList->Add(gAntiProtonsChi2PerClusterTPCReject);
1766   TH1F *gAntiProtonsExtCov11Reject = new TH1F("gAntiProtonsExtCov11Reject",
1767                                               ";#sigma_{y} [cm];Entries",
1768                                               100,0,4);
1769   gAntiProtonsExtCov11Reject->SetFillColor(kRed-2);
1770   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov11Reject);
1771   TH1F *gAntiProtonsExtCov22Reject = new TH1F("gAntiProtonsExtCov22Reject",
1772                                               ";#sigma_{z} [cm];Entries",
1773                                               100,0,4);
1774   gAntiProtonsExtCov22Reject->SetFillColor(kRed-2);
1775   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov22Reject);
1776   TH1F *gAntiProtonsExtCov33Reject = new TH1F("gAntiProtonsExtCov33Reject",
1777                                               ";#sigma_{sin(#phi)};Entries",
1778                                               100,0,4);
1779   gAntiProtonsExtCov33Reject->SetFillColor(kRed-2);
1780   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov33Reject);
1781   TH1F *gAntiProtonsExtCov44Reject = new TH1F("gAntiProtonsExtCov44Reject",
1782                                               ";#sigma_{tan(#lambda)};Entries",
1783                                               100,0,4);
1784   gAntiProtonsExtCov44Reject->SetFillColor(kRed-2);
1785   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov44Reject);
1786   TH1F *gAntiProtonsExtCov55Reject = new TH1F("gAntiProtonsExtCov55Reject",
1787                                               ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1788                                               100,0,4);
1789   gAntiProtonsExtCov55Reject->SetFillColor(kRed-2);
1790   fQAAntiProtonsRejectedList->Add(gAntiProtonsExtCov55Reject);
1791   TH1F *gAntiProtonsSigmaToVertexReject = new TH1F("gAntiProtonsSigmaToVertexReject",
1792                                                    ";#sigma_{Vertex};Entries",
1793                                                    100,0,10);
1794   gAntiProtonsSigmaToVertexReject->SetFillColor(kRed-2);
1795   fQAAntiProtonsRejectedList->Add(gAntiProtonsSigmaToVertexReject);
1796   TH1F *gAntiProtonsSigmaToVertexTPCReject = new TH1F("gAntiProtonsSigmaToVertexTPCReject",
1797                                                       ";#sigma_{Vertex};Entries",
1798                                                       100,0,10);
1799   gAntiProtonsSigmaToVertexTPCReject->SetFillColor(kRed-2);
1800   fQAAntiProtonsRejectedList->Add(gAntiProtonsSigmaToVertexTPCReject);
1801   TH1F *gAntiProtonsDCAXYReject = new TH1F("gAntiProtonsDCAXYReject",
1802                                            ";DCA_{xy} [cm];Entries",
1803                                            100,0,20);
1804   gAntiProtonsDCAXYReject->SetFillColor(kRed-2);
1805   fQAAntiProtonsRejectedList->Add(gAntiProtonsDCAXYReject);
1806   TH1F *gAntiProtonsDCAXYTPCReject = new TH1F("gAntiProtonsDCAXYTPCReject",
1807                                               ";DCA_{xy} [cm];Entries",
1808                                               100,0,20);
1809   gAntiProtonsDCAXYTPCReject->SetFillColor(kRed-2);
1810   fQAAntiProtonsRejectedList->Add(gAntiProtonsDCAXYTPCReject);
1811   TH1F *gAntiProtonsDCAZReject = new TH1F("gAntiProtonsDCAZReject",
1812                                           ";DCA_{z} [cm];Entries",
1813                                           100,0,20);
1814   gAntiProtonsDCAZReject->SetFillColor(kRed-2);
1815   fQAAntiProtonsRejectedList->Add(gAntiProtonsDCAZReject);
1816   TH1F *gAntiProtonsDCAZTPCReject = new TH1F("gAntiProtonsDCAZTPCReject",
1817                                              ";DCA_{z} [cm];Entries",
1818                                              100,0,20);
1819   gAntiProtonsDCAZTPCReject->SetFillColor(kRed-2);
1820   fQAAntiProtonsRejectedList->Add(gAntiProtonsDCAZTPCReject);
1821   TH1F *gAntiProtonsConstrainChi2Reject = new TH1F("gAntiProtonsConstrainChi2Reject",
1822                                                    ";Log_{10}(#chi^{2});Entries",
1823                                                    100,-10,10);
1824   gAntiProtonsConstrainChi2Reject->SetFillColor(kRed-2);
1825   fQAAntiProtonsRejectedList->Add(gAntiProtonsConstrainChi2Reject);
1826   TH1F *gAntiProtonsITSRefitReject = new TH1F("gAntiProtonsITSRefitReject",
1827                                               "",10,-1,1);
1828   gAntiProtonsITSRefitReject->SetFillColor(kRed-2);
1829   fQAAntiProtonsRejectedList->Add(gAntiProtonsITSRefitReject);
1830   TH1F *gAntiProtonsTPCRefitReject = new TH1F("gAntiProtonsTPCRefitReject",
1831                                               "",10,-1,1);
1832   gAntiProtonsTPCRefitReject->SetFillColor(kRed-2);
1833   fQAAntiProtonsRejectedList->Add(gAntiProtonsTPCRefitReject);
1834   TH1F *gAntiProtonsESDpidReject = new TH1F("gAntiProtonsESDpidReject",
1835                                             "",10,-1,1);
1836   gAntiProtonsESDpidReject->SetFillColor(kRed-2);
1837   fQAAntiProtonsRejectedList->Add(gAntiProtonsESDpidReject);
1838   TH1F *gAntiProtonsTPCpidReject = new TH1F("gAntiProtonsTPCpidReject",
1839                                             "",10,-1,1);
1840   gAntiProtonsTPCpidReject->SetFillColor(kRed-2);
1841   fQAAntiProtonsRejectedList->Add(gAntiProtonsTPCpidReject);
1842   TH1F *gAntiProtonsPointOnITSLayer1Reject = new TH1F("gAntiProtonsPointOnITSLayer1Reject",
1843                                                       "",10,-1,1);
1844   gAntiProtonsPointOnITSLayer1Reject->SetFillColor(kRed-2);
1845   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer1Reject);
1846   TH1F *gAntiProtonsPointOnITSLayer2Reject = new TH1F("gAntiProtonsPointOnITSLayer2Reject",
1847                                                       "",10,-1,1);
1848   gAntiProtonsPointOnITSLayer2Reject->SetFillColor(kRed-2);
1849   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer2Reject);
1850   TH1F *gAntiProtonsPointOnITSLayer3Reject = new TH1F("gAntiProtonsPointOnITSLayer3Reject",
1851                                                       "",10,-1,1);
1852   gAntiProtonsPointOnITSLayer3Reject->SetFillColor(kRed-2);
1853   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer3Reject);
1854   TH1F *gAntiProtonsPointOnITSLayer4Reject = new TH1F("gAntiProtonsPointOnITSLayer4Reject",
1855                                                       "",10,-1,1);
1856   gAntiProtonsPointOnITSLayer4Reject->SetFillColor(kRed-2);
1857   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer4Reject);
1858   TH1F *gAntiProtonsPointOnITSLayer5Reject = new TH1F("gAntiProtonsPointOnITSLayer5Reject",
1859                                                       "",10,-1,1);
1860   gAntiProtonsPointOnITSLayer5Reject->SetFillColor(kRed-2);
1861   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer5Reject);
1862   TH1F *gAntiProtonsPointOnITSLayer6Reject = new TH1F("gAntiProtonsPointOnITSLayer6Reject",
1863                                                       "",10,-1,1);
1864   gAntiProtonsPointOnITSLayer6Reject->SetFillColor(kRed-2);
1865   fQAAntiProtonsRejectedList->Add(gAntiProtonsPointOnITSLayer6Reject);
1866   TH1F *gAntiProtonsNumberOfTPCdEdxPointsReject = new TH1F("gAntiProtonsNumberOfTPCdEdxPointsReject","",100,0,200);
1867   gAntiProtonsNumberOfTPCdEdxPointsReject->SetFillColor(kRed-2);
1868   fQAAntiProtonsRejectedList->Add(gAntiProtonsNumberOfTPCdEdxPointsReject);
1869 }
1870
1871 //____________________________________________________________________//
1872 void AliProtonAnalysis::FillQA(AliESDEvent *esd,
1873                                const AliESDVertex *vertex, 
1874                                AliESDtrack* track) {
1875   //Fills the QA histograms
1876   Double_t gPt = 0.0, gPx = 0.0, gPy = 0.0, gPz = 0.0;
1877   Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};  //The impact parameters and their covariance.
1878
1879   if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)||(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
1880     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
1881     if(!tpcTrack) {
1882       gPt = 0.0; gPx = 0.0; gPy = 0.0; gPz = 0.0;
1883       dca[0] = -100.; dca[1] = -100.;
1884       cov[0] = -100.; cov[1] = -100.; cov[2] = -100.;
1885     }
1886     else {
1887       gPt = tpcTrack->Pt();
1888       gPx = tpcTrack->Px();
1889       gPy = tpcTrack->Py();
1890       gPz = tpcTrack->Pz();
1891       tpcTrack->PropagateToDCA(vertex,
1892                                esd->GetMagneticField(),
1893                                100.,dca,cov);
1894     }
1895   }
1896   else{
1897     gPt = track->Pt();
1898     gPx = track->Px();
1899     gPy = track->Py();
1900     gPz = track->Pz();
1901     track->PropagateToDCA(vertex,
1902                           esd->GetMagneticField(),
1903                           100.,dca,cov);
1904   }
1905
1906   Int_t  fIdxInt[200];
1907   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
1908   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
1909
1910   Float_t chi2PerClusterITS = -1;
1911   if (nClustersITS!=0)
1912     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
1913   Float_t chi2PerClusterTPC = -1;
1914   if (nClustersTPC!=0)
1915     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
1916
1917   Double_t extCov[15];
1918   track->GetExternalCovariance(extCov);
1919   
1920   //protons
1921   if(track->Charge() > 0) {
1922     if(fProtonAnalysisBase->IsUsedMinITSClusters()) {
1923       if(nClustersITS < fProtonAnalysisBase->GetMinITSClusters()) {
1924         ((TH1F *)(fQAProtonsRejectedList->At(0)))->Fill(nClustersITS);
1925       }
1926       else if(nClustersITS >= fProtonAnalysisBase->GetMinITSClusters()) 
1927         ((TH1F *)(fQAProtonsAcceptedList->At(0)))->Fill(nClustersITS);
1928     }//ITS clusters
1929     if(fProtonAnalysisBase->IsUsedMaxChi2PerITSCluster()) {
1930       if(chi2PerClusterITS > fProtonAnalysisBase->GetMaxChi2PerITSCluster()) {
1931         ((TH1F *)(fQAProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
1932       }
1933       else if(chi2PerClusterITS <= fProtonAnalysisBase->GetMaxChi2PerITSCluster())
1934         ((TH1F *)(fQAProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
1935     }//chi2 per ITS cluster
1936     if(fProtonAnalysisBase->IsUsedMinTPCClusters()) {
1937       if(nClustersTPC < fProtonAnalysisBase->GetMinTPCClusters()) {
1938         ((TH1F *)(fQAProtonsRejectedList->At(2)))->Fill(nClustersTPC);
1939       }
1940       else if(nClustersTPC >= fProtonAnalysisBase->GetMinTPCClusters()) {
1941         ((TH1F *)(fQAProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
1942       }
1943     }//TPC clusters
1944     if(fProtonAnalysisBase->IsUsedMaxChi2PerTPCCluster()) {
1945       if(chi2PerClusterTPC > fProtonAnalysisBase->GetMaxChi2PerTPCCluster()) {
1946         ((TH1F *)(fQAProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
1947       }
1948       else if(chi2PerClusterTPC <= fProtonAnalysisBase->GetMaxChi2PerTPCCluster())
1949         ((TH1F *)(fQAProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
1950     }//chi2 per TPC cluster
1951     if(fProtonAnalysisBase->IsUsedMaxCov11()) {
1952       if(extCov[0] > fProtonAnalysisBase->GetMaxCov11()) {
1953         ((TH1F *)(fQAProtonsRejectedList->At(4)))->Fill(extCov[0]);
1954       }
1955       else if(extCov[0] <= fProtonAnalysisBase->GetMaxCov11())
1956         ((TH1F *)(fQAProtonsAcceptedList->At(4)))->Fill(extCov[0]);
1957     }//cov11
1958     if(fProtonAnalysisBase->IsUsedMaxCov22()) {
1959       if(extCov[2] > fProtonAnalysisBase->GetMaxCov22()) {
1960         ((TH1F *)(fQAProtonsRejectedList->At(5)))->Fill(extCov[2]);
1961       }
1962       else if(extCov[2] <= fProtonAnalysisBase->GetMaxCov22())
1963         ((TH1F *)(fQAProtonsAcceptedList->At(5)))->Fill(extCov[2]);
1964     }//cov11
1965     if(fProtonAnalysisBase->IsUsedMaxCov33()) {
1966       if(extCov[5] > fProtonAnalysisBase->GetMaxCov33()) {
1967         ((TH1F *)(fQAProtonsRejectedList->At(6)))->Fill(extCov[5]);
1968       }
1969       else if(extCov[5] <= fProtonAnalysisBase->GetMaxCov33())
1970         ((TH1F *)(fQAProtonsAcceptedList->At(6)))->Fill(extCov[5]);
1971     }//cov11
1972     if(fProtonAnalysisBase->IsUsedMaxCov44()) {
1973       if(extCov[9] > fProtonAnalysisBase->GetMaxCov44()) {
1974         ((TH1F *)(fQAProtonsRejectedList->At(7)))->Fill(extCov[9]);
1975       }
1976       else if(extCov[9] <= fProtonAnalysisBase->GetMaxCov44())
1977         ((TH1F *)(fQAProtonsAcceptedList->At(7)))->Fill(extCov[9]);
1978     }//cov11
1979     if(fProtonAnalysisBase->IsUsedMaxCov55()) {
1980       if(extCov[14] > fProtonAnalysisBase->GetMaxCov55()) {
1981         ((TH1F *)(fQAProtonsRejectedList->At(8)))->Fill(extCov[14]);
1982       }
1983       else if(extCov[14] <= fProtonAnalysisBase->GetMaxCov55())
1984         ((TH1F *)(fQAProtonsAcceptedList->At(8)))->Fill(extCov[14]);
1985     }//cov55
1986     if(fProtonAnalysisBase->IsUsedMaxSigmaToVertex()) {
1987       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertex()) {
1988         ((TH1F *)(fQAProtonsRejectedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
1989       }
1990       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertex())
1991         ((TH1F *)(fQAProtonsAcceptedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
1992     }//sigma to vertex
1993     if(fProtonAnalysisBase->IsUsedMaxSigmaToVertexTPC()) {
1994       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertexTPC()) {
1995         ((TH1F *)(fQAProtonsRejectedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
1996       }
1997       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertexTPC())
1998         ((TH1F *)(fQAProtonsAcceptedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
1999     }//sigma to vertex TPC
2000     if(fProtonAnalysisBase->IsUsedMaxDCAXY()) {
2001       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXY()) {
2002         ((TH1F *)(fQAProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
2003       }
2004       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXY())
2005         ((TH1F *)(fQAProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
2006     }//DCA xy global tracking
2007     if(fProtonAnalysisBase->IsUsedMaxDCAXYTPC()) {
2008       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXYTPC()) {
2009         ((TH1F *)(fQAProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
2010       }
2011       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXYTPC())
2012         ((TH1F *)(fQAProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
2013     }//DCA xy TPC tracking
2014     if(fProtonAnalysisBase->IsUsedMaxDCAZ()) {
2015       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZ()) {
2016         ((TH1F *)(fQAProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
2017       }
2018       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZ())
2019         ((TH1F *)(fQAProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
2020     }//DCA z global tracking
2021     if(fProtonAnalysisBase->IsUsedMaxDCAZTPC()) {
2022       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZTPC()) {
2023         ((TH1F *)(fQAProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
2024       }
2025       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZTPC())
2026         ((TH1F *)(fQAProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
2027     }//DCA z TPC tracking
2028     if(fProtonAnalysisBase->IsUsedMaxConstrainChi2()) {
2029       if(track->GetConstrainedChi2() > 0) {
2030         if(TMath::Log(track->GetConstrainedChi2()) > fProtonAnalysisBase->GetMaxConstrainChi2()) {
2031           ((TH1F *)(fQAProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
2032         }
2033         else if(TMath::Log(track->GetConstrainedChi2()) <= fProtonAnalysisBase->GetMaxConstrainChi2())
2034           ((TH1F *)(fQAProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
2035       }
2036     }//constrain chi2 - vertex
2037     if(fProtonAnalysisBase->IsUsedITSRefit()) {
2038       if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
2039         ((TH1F *)(fQAProtonsRejectedList->At(16)))->Fill(0);
2040       }
2041       else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
2042         ((TH1F *)(fQAProtonsAcceptedList->At(16)))->Fill(0);
2043     }//ITS refit
2044     if(fProtonAnalysisBase->IsUsedTPCRefit()) {
2045       if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
2046         ((TH1F *)(fQAProtonsRejectedList->At(17)))->Fill(0);
2047       }
2048       else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
2049         ((TH1F *)(fQAProtonsAcceptedList->At(17)))->Fill(0);
2050     }//TPC refit
2051     if(fProtonAnalysisBase->IsUsedESDpid()) {
2052       if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
2053         ((TH1F *)(fQAProtonsRejectedList->At(18)))->Fill(0);
2054       }
2055       else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
2056         ((TH1F *)(fQAProtonsAcceptedList->At(18)))->Fill(0);
2057     }//ESD pid
2058     if(fProtonAnalysisBase->IsUsedTPCpid()) {
2059       if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
2060         ((TH1F *)(fQAProtonsRejectedList->At(19)))->Fill(0);
2061       }
2062       else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
2063         ((TH1F *)(fQAProtonsAcceptedList->At(19)))->Fill(0);
2064     }//TPC pid
2065     if(fProtonAnalysisBase->IsUsedPointOnITSLayer1()) {
2066       if(!track->HasPointOnITSLayer(0)) {
2067         ((TH1F *)(fQAProtonsRejectedList->At(20)))->Fill(0);
2068       }
2069       else if(track->HasPointOnITSLayer(0))
2070         ((TH1F *)(fQAProtonsAcceptedList->At(20)))->Fill(0);
2071     }//point on SPD1
2072     if(fProtonAnalysisBase->IsUsedPointOnITSLayer2()) {
2073       if(!track->HasPointOnITSLayer(1)) {
2074         ((TH1F *)(fQAProtonsRejectedList->At(21)))->Fill(0);
2075       }
2076       else if(track->HasPointOnITSLayer(1))
2077         ((TH1F *)(fQAProtonsAcceptedList->At(21)))->Fill(0);
2078     }//point on SPD2
2079     if(fProtonAnalysisBase->IsUsedPointOnITSLayer3()) {
2080       if(!track->HasPointOnITSLayer(2)) {
2081         ((TH1F *)(fQAProtonsRejectedList->At(22)))->Fill(0);
2082       }
2083       else if(track->HasPointOnITSLayer(2))
2084         ((TH1F *)(fQAProtonsAcceptedList->At(22)))->Fill(0);
2085     }//point on SDD1
2086     if(fProtonAnalysisBase->IsUsedPointOnITSLayer4()) {
2087       if(!track->HasPointOnITSLayer(3)) {
2088         ((TH1F *)(fQAProtonsRejectedList->At(23)))->Fill(0);
2089       }
2090       else if(track->HasPointOnITSLayer(3))
2091         ((TH1F *)(fQAProtonsAcceptedList->At(23)))->Fill(0);
2092     }//point on SDD2
2093     if(fProtonAnalysisBase->IsUsedPointOnITSLayer5()) {
2094       if(!track->HasPointOnITSLayer(4)) {
2095         ((TH1F *)(fQAProtonsRejectedList->At(24)))->Fill(0);
2096       }
2097       else if(track->HasPointOnITSLayer(4))
2098         ((TH1F *)(fQAProtonsAcceptedList->At(24)))->Fill(0);
2099     }//point on SSD1
2100     if(fProtonAnalysisBase->IsUsedPointOnITSLayer6()) {
2101       if(!track->HasPointOnITSLayer(5)) {
2102         ((TH1F *)(fQAProtonsRejectedList->At(25)))->Fill(0);
2103       }
2104       else if(track->HasPointOnITSLayer(5))
2105         ((TH1F *)(fQAProtonsAcceptedList->At(25)))->Fill(0);
2106     }//point on SSD2
2107     if(fProtonAnalysisBase->IsUsedMinTPCdEdxPoints()) {
2108       if(track->GetTPCsignalN() < fProtonAnalysisBase->GetMinTPCdEdxPoints()) {
2109         ((TH1F *)(fQAProtonsRejectedList->At(26)))->Fill(track->GetTPCsignalN());
2110       }
2111       if(track->GetTPCsignalN() >= fProtonAnalysisBase->GetMinTPCdEdxPoints())
2112         ((TH1F *)(fQAProtonsAcceptedList->At(26)))->Fill(track->GetTPCsignalN());
2113     }//number of TPC points for the dE/dx
2114   }//protons
2115
2116   //antiprotons
2117   if(track->Charge() < 0) {
2118     if(fProtonAnalysisBase->IsUsedMinITSClusters()) {
2119       if(nClustersITS < fProtonAnalysisBase->GetMinITSClusters()) {
2120         ((TH1F *)(fQAAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
2121       }
2122       else if(nClustersITS >= fProtonAnalysisBase->GetMinITSClusters()) 
2123         ((TH1F *)(fQAAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
2124     }//ITS clusters
2125     if(fProtonAnalysisBase->IsUsedMaxChi2PerITSCluster()) {
2126       if(chi2PerClusterITS > fProtonAnalysisBase->GetMaxChi2PerITSCluster()) {
2127         ((TH1F *)(fQAAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
2128       }
2129       else if(chi2PerClusterITS <= fProtonAnalysisBase->GetMaxChi2PerITSCluster())
2130         ((TH1F *)(fQAAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
2131     }//chi2 per ITS cluster
2132     if(fProtonAnalysisBase->IsUsedMinTPCClusters()) {
2133       if(nClustersTPC < fProtonAnalysisBase->GetMinTPCClusters()) {
2134         ((TH1F *)(fQAAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
2135       }
2136       else if(nClustersTPC >= fProtonAnalysisBase->GetMinTPCClusters()) {
2137         ((TH1F *)(fQAAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
2138       }
2139     }//TPC clusters
2140     if(fProtonAnalysisBase->IsUsedMaxChi2PerTPCCluster()) {
2141       if(chi2PerClusterTPC > fProtonAnalysisBase->GetMaxChi2PerTPCCluster()) {
2142         ((TH1F *)(fQAAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
2143       }
2144       else if(chi2PerClusterTPC <= fProtonAnalysisBase->GetMaxChi2PerTPCCluster())
2145         ((TH1F *)(fQAAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
2146     }//chi2 per TPC cluster
2147     if(fProtonAnalysisBase->IsUsedMaxCov11()) {
2148       if(extCov[0] > fProtonAnalysisBase->GetMaxCov11()) {
2149         ((TH1F *)(fQAAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
2150       }
2151       else if(extCov[0] <= fProtonAnalysisBase->GetMaxCov11())
2152         ((TH1F *)(fQAAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
2153     }//cov11
2154     if(fProtonAnalysisBase->IsUsedMaxCov22()) {
2155       if(extCov[2] > fProtonAnalysisBase->GetMaxCov22()) {
2156         ((TH1F *)(fQAAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
2157       }
2158       else if(extCov[2] <= fProtonAnalysisBase->GetMaxCov22())
2159         ((TH1F *)(fQAAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
2160     }//cov11
2161     if(fProtonAnalysisBase->IsUsedMaxCov33()) {
2162       if(extCov[5] > fProtonAnalysisBase->GetMaxCov33()) {
2163         ((TH1F *)(fQAAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
2164       }
2165       else if(extCov[5] <= fProtonAnalysisBase->GetMaxCov33())
2166         ((TH1F *)(fQAAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
2167     }//cov11
2168     if(fProtonAnalysisBase->IsUsedMaxCov44()) {
2169       if(extCov[9] > fProtonAnalysisBase->GetMaxCov44()) {
2170         ((TH1F *)(fQAAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
2171       }
2172       else if(extCov[9] <= fProtonAnalysisBase->GetMaxCov44())
2173         ((TH1F *)(fQAAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
2174     }//cov11
2175     if(fProtonAnalysisBase->IsUsedMaxCov55()) {
2176       if(extCov[14] > fProtonAnalysisBase->GetMaxCov55()) {
2177         ((TH1F *)(fQAAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
2178       }
2179       else if(extCov[14] <= fProtonAnalysisBase->GetMaxCov55())
2180         ((TH1F *)(fQAAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
2181     }//cov55
2182     if(fProtonAnalysisBase->IsUsedMaxSigmaToVertex()) {
2183       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertex()) {
2184         ((TH1F *)(fQAAntiProtonsRejectedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2185       }
2186       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertex())
2187         ((TH1F *)(fQAAntiProtonsAcceptedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2188     }//sigma to vertex
2189     if(fProtonAnalysisBase->IsUsedMaxSigmaToVertexTPC()) {
2190       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertexTPC()) {
2191         ((TH1F *)(fQAAntiProtonsRejectedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2192       }
2193       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertexTPC())
2194         ((TH1F *)(fQAAntiProtonsAcceptedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
2195     }//sigma to vertex TPC
2196     if(fProtonAnalysisBase->IsUsedMaxDCAXY()) {
2197       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXY()) {
2198         ((TH1F *)(fQAAntiProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
2199       }
2200       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXY())
2201         ((TH1F *)(fQAAntiProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
2202     }//DCA xy global tracking
2203     if(fProtonAnalysisBase->IsUsedMaxDCAXYTPC()) {
2204       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXYTPC()) {
2205         ((TH1F *)(fQAAntiProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
2206       }
2207       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXYTPC())
2208         ((TH1F *)(fQAAntiProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
2209     }//DCA xy TPC tracking
2210     if(fProtonAnalysisBase->IsUsedMaxDCAZ()) {
2211       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZ()) {
2212         ((TH1F *)(fQAAntiProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
2213       }
2214       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZ())
2215         ((TH1F *)(fQAAntiProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
2216     }//DCA z global tracking
2217     if(fProtonAnalysisBase->IsUsedMaxDCAZTPC()) {
2218       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZTPC()) {
2219         ((TH1F *)(fQAAntiProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
2220       }
2221       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZTPC())
2222         ((TH1F *)(fQAAntiProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
2223     }//DCA z TPC tracking
2224     if(fProtonAnalysisBase->IsUsedMaxConstrainChi2()) {
2225       if(track->GetConstrainedChi2() > 0) {
2226         if(TMath::Log(track->GetConstrainedChi2()) > fProtonAnalysisBase->GetMaxConstrainChi2()) {
2227           ((TH1F *)(fQAAntiProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
2228         }
2229         else if(TMath::Log(track->GetConstrainedChi2()) <= fProtonAnalysisBase->GetMaxConstrainChi2())
2230           ((TH1F *)(fQAAntiProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
2231       }
2232     }//constrain chi2 - vertex
2233     if(fProtonAnalysisBase->IsUsedITSRefit()) {
2234       if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
2235         ((TH1F *)(fQAAntiProtonsRejectedList->At(16)))->Fill(0);
2236       }
2237       else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
2238         ((TH1F *)(fQAAntiProtonsAcceptedList->At(16)))->Fill(0);
2239     }//ITS refit
2240     if(fProtonAnalysisBase->IsUsedTPCRefit()) {
2241       if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
2242         ((TH1F *)(fQAAntiProtonsRejectedList->At(17)))->Fill(0);
2243       }
2244       else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
2245         ((TH1F *)(fQAAntiProtonsAcceptedList->At(17)))->Fill(0);
2246     }//TPC refit
2247     if(fProtonAnalysisBase->IsUsedESDpid()) {
2248       if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
2249         ((TH1F *)(fQAAntiProtonsRejectedList->At(18)))->Fill(0);
2250       }
2251       else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
2252         ((TH1F *)(fQAAntiProtonsAcceptedList->At(18)))->Fill(0);
2253     }//ESD pid
2254     if(fProtonAnalysisBase->IsUsedTPCpid()) {
2255       if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
2256         ((TH1F *)(fQAAntiProtonsRejectedList->At(19)))->Fill(0);
2257       }
2258       else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
2259         ((TH1F *)(fQAAntiProtonsAcceptedList->At(19)))->Fill(0);
2260     }//TPC pid
2261     if(fProtonAnalysisBase->IsUsedPointOnITSLayer1()) {
2262       if(!track->HasPointOnITSLayer(0)) {
2263         ((TH1F *)(fQAAntiProtonsRejectedList->At(20)))->Fill(0);
2264       }
2265       else if(track->HasPointOnITSLayer(0))
2266         ((TH1F *)(fQAAntiProtonsAcceptedList->At(20)))->Fill(0);
2267     }//point on SPD1
2268     if(fProtonAnalysisBase->IsUsedPointOnITSLayer2()) {
2269       if(!track->HasPointOnITSLayer(1)) {
2270         ((TH1F *)(fQAAntiProtonsRejectedList->At(21)))->Fill(0);
2271       }
2272       else if(track->HasPointOnITSLayer(1))
2273         ((TH1F *)(fQAAntiProtonsAcceptedList->At(21)))->Fill(0);
2274     }//point on SPD2
2275     if(fProtonAnalysisBase->IsUsedPointOnITSLayer3()) {
2276       if(!track->HasPointOnITSLayer(2)) {
2277         ((TH1F *)(fQAAntiProtonsRejectedList->At(22)))->Fill(0);
2278       }
2279       else if(track->HasPointOnITSLayer(2))
2280         ((TH1F *)(fQAAntiProtonsAcceptedList->At(22)))->Fill(0);
2281     }//point on SDD1
2282     if(fProtonAnalysisBase->IsUsedPointOnITSLayer4()) {
2283       if(!track->HasPointOnITSLayer(3)) {
2284         ((TH1F *)(fQAAntiProtonsRejectedList->At(23)))->Fill(0);
2285       }
2286       else if(track->HasPointOnITSLayer(3))
2287         ((TH1F *)(fQAAntiProtonsAcceptedList->At(23)))->Fill(0);
2288     }//point on SDD2
2289     if(fProtonAnalysisBase->IsUsedPointOnITSLayer5()) {
2290       if(!track->HasPointOnITSLayer(4)) {
2291         ((TH1F *)(fQAAntiProtonsRejectedList->At(24)))->Fill(0);
2292       }
2293       else if(track->HasPointOnITSLayer(4))
2294         ((TH1F *)(fQAAntiProtonsAcceptedList->At(24)))->Fill(0);
2295     }//point on SSD1
2296     if(fProtonAnalysisBase->IsUsedPointOnITSLayer6()) {
2297       if(!track->HasPointOnITSLayer(5)) {
2298         ((TH1F *)(fQAAntiProtonsRejectedList->At(25)))->Fill(0);
2299       }
2300       else if(track->HasPointOnITSLayer(5))
2301         ((TH1F *)(fQAAntiProtonsAcceptedList->At(25)))->Fill(0);
2302     }//point on SSD2
2303     if(fProtonAnalysisBase->IsUsedMinTPCdEdxPoints()) {
2304       if(track->GetTPCsignalN() < fProtonAnalysisBase->GetMinTPCdEdxPoints()) {
2305         ((TH1F *)(fQAAntiProtonsRejectedList->At(26)))->Fill(track->GetTPCsignalN());
2306       }
2307       if(track->GetTPCsignalN() >= fProtonAnalysisBase->GetMinTPCdEdxPoints())
2308         ((TH1F *)(fQAAntiProtonsAcceptedList->At(26)))->Fill(track->GetTPCsignalN());
2309     }//number of TPC points for the dE/dx
2310   }//antiprotons
2311 }