]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/AliProtonAnalysis.cxx
Adding new macro to visualize the QA results - A couple of modifications in the 2D...
[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, UOA-CERN, Panos.Christakoglou@cern.ch
20 //-----------------------------------------------------------------
21 #include <Riostream.h>
22 #include <TFile.h>
23 #include <TSystem.h>
24 #include <TF1.h>
25 #include <TH2D.h>
26 #include <TH1D.h>
27 #include <TH1I.h>
28 #include <TParticle.h>
29
30 #include "AliProtonAnalysis.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
42 ClassImp(AliProtonAnalysis)
43
44 //____________________________________________________________________//
45 AliProtonAnalysis::AliProtonAnalysis() : 
46   TObject(), 
47   fNBinsY(0), fMinY(0), fMaxY(0),
48   fNBinsPt(0), fMinPt(0), fMaxPt(0),
49   fMinTPCClusters(0), fMinITSClusters(0),
50   fMaxChi2PerTPCCluster(0), fMaxChi2PerITSCluster(0),
51   fMaxCov11(0), fMaxCov22(0), fMaxCov33(0), fMaxCov44(0), fMaxCov55(0),
52   fMaxSigmaToVertex(0), fMaxSigmaToVertexTPC(0),
53   fMinTPCClustersFlag(kFALSE), fMinITSClustersFlag(kFALSE),
54   fMaxChi2PerTPCClusterFlag(kFALSE), fMaxChi2PerITSClusterFlag(kFALSE),
55   fMaxCov11Flag(kFALSE), fMaxCov22Flag(kFALSE), 
56   fMaxCov33Flag(kFALSE), fMaxCov44Flag(kFALSE), fMaxCov55Flag(kFALSE),
57   fMaxSigmaToVertexFlag(kFALSE), fMaxSigmaToVertexTPCFlag(kFALSE),
58   fITSRefitFlag(kFALSE), fTPCRefitFlag(kFALSE),
59   fESDpidFlag(kFALSE), fTPCpidFlag(kFALSE),
60   //fQAHistograms(kFALSE),
61   fGlobalQAList(0), fQA2DList(0),
62   fQAPrimaryProtonsAcceptedList(0),
63   fQAPrimaryProtonsRejectedList(0),
64   fQASecondaryProtonsAcceptedList(0),
65   fQASecondaryProtonsRejectedList(0),
66   fQAPrimaryAntiProtonsAcceptedList(0),
67   fQAPrimaryAntiProtonsRejectedList(0),
68   fQASecondaryAntiProtonsAcceptedList(0),
69   fQASecondaryAntiProtonsRejectedList(0),
70   fFunctionProbabilityFlag(kFALSE), 
71   fElectronFunction(0), fMuonFunction(0),
72   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
73   fUseTPCOnly(kFALSE), 
74   fProtonContainer(0), fAntiProtonContainer(0),
75   fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0),
76   fEffGridListProtons(0), fCorrectionListProtons2D(0), 
77   fEfficiencyListProtons1D(0), fCorrectionListProtons1D(0),
78   fEffGridListAntiProtons(0), fCorrectionListAntiProtons2D(0), 
79   fEfficiencyListAntiProtons1D(0), fCorrectionListAntiProtons1D(0),
80   fCorrectProtons(0), fCorrectAntiProtons(0) {
81   //Default constructor
82   for(Int_t i = 0; i < 5; i++) fPartFrac[i] = 0.0;
83 }
84
85 //____________________________________________________________________//
86 AliProtonAnalysis::AliProtonAnalysis(Int_t nbinsY, Float_t fLowY, Float_t fHighY,Int_t nbinsPt, Float_t fLowPt, Float_t fHighPt) : 
87   TObject(),
88   fNBinsY(nbinsY), fMinY(fLowY), fMaxY(fHighY),
89   fNBinsPt(nbinsPt), fMinPt(fLowPt), fMaxPt(fHighPt),
90   fMinTPCClusters(0), fMinITSClusters(0),
91   fMaxChi2PerTPCCluster(0), fMaxChi2PerITSCluster(0),
92   fMaxCov11(0), fMaxCov22(0), fMaxCov33(0), fMaxCov44(0), fMaxCov55(0),
93   fMaxSigmaToVertex(0), fMaxSigmaToVertexTPC(0),
94   fMinTPCClustersFlag(kFALSE), fMinITSClustersFlag(kFALSE),
95   fMaxChi2PerTPCClusterFlag(kFALSE), fMaxChi2PerITSClusterFlag(kFALSE),
96   fMaxCov11Flag(kFALSE), fMaxCov22Flag(kFALSE), 
97   fMaxCov33Flag(kFALSE), fMaxCov44Flag(kFALSE), fMaxCov55Flag(kFALSE),
98   fMaxSigmaToVertexFlag(kFALSE), fMaxSigmaToVertexTPCFlag(kFALSE),
99   fITSRefitFlag(kFALSE), fTPCRefitFlag(kFALSE),
100   fESDpidFlag(kFALSE), fTPCpidFlag(kFALSE),
101   //fQAHistograms(kFALSE), 
102   fGlobalQAList(0), fQA2DList(0),
103   fQAPrimaryProtonsAcceptedList(0),
104   fQAPrimaryProtonsRejectedList(0),
105   fQASecondaryProtonsAcceptedList(0),
106   fQASecondaryProtonsRejectedList(0),
107   fQAPrimaryAntiProtonsAcceptedList(0),
108   fQAPrimaryAntiProtonsRejectedList(0),
109   fQASecondaryAntiProtonsAcceptedList(0),
110   fQASecondaryAntiProtonsRejectedList(0),
111   fFunctionProbabilityFlag(kFALSE), 
112   fElectronFunction(0), fMuonFunction(0),
113   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
114   fUseTPCOnly(kFALSE),   
115   fProtonContainer(0), fAntiProtonContainer(0),
116   fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0),
117   fEffGridListProtons(0), fCorrectionListProtons2D(0), 
118   fEfficiencyListProtons1D(0), fCorrectionListProtons1D(0),
119   fEffGridListAntiProtons(0), fCorrectionListAntiProtons2D(0), 
120   fEfficiencyListAntiProtons1D(0), fCorrectionListAntiProtons1D(0),
121   fCorrectProtons(0), fCorrectAntiProtons(0){
122   //Default constructor
123
124   fHistEvents = new TH1I("fHistEvents","Analyzed events",1,0,1);
125
126   fHistYPtProtons = new TH2D("fHistYPtProtons","y-Pt Protons",fNBinsY,fMinY,fMaxY,fNBinsPt,fMinPt,fMaxPt);
127   fHistYPtProtons->SetStats(kTRUE);
128   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV]");
129   fHistYPtProtons->GetXaxis()->SetTitle("y");
130   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
131
132   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","y-Pt Antiprotons",fNBinsY,fMinY,fMaxY,fNBinsPt,fMinPt,fMaxPt);
133   fHistYPtAntiProtons->SetStats(kTRUE);
134   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV]");
135   fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
136   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
137
138   //setting up the containers
139   Int_t iBin[2];
140   iBin[0] = nbinsY;
141   iBin[1] = nbinsPt;
142   Double_t *binLimY = new Double_t[nbinsY+1];
143   Double_t *binLimPt = new Double_t[nbinsPt+1];
144   //values for bin lower bounds
145   for(Int_t i = 0; i <= nbinsY; i++) 
146     binLimY[i]=(Double_t)fLowY  + (fHighY - fLowY)  /nbinsY*(Double_t)i;
147   for(Int_t i = 0; i <= nbinsPt; i++) 
148     binLimPt[i]=(Double_t)fLowPt  + (fHighPt - fLowPt)  /nbinsPt*(Double_t)i;
149
150   fProtonContainer = new AliCFContainer("containerProtons",
151                                         "container for protons",
152                                         1,2,iBin);
153   fProtonContainer->SetBinLimits(0,binLimY); //rapidity
154   fProtonContainer->SetBinLimits(1,binLimPt); //pT
155   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
156                                             "container for antiprotons",
157                                             1,2,iBin);
158   fAntiProtonContainer->SetBinLimits(0,binLimY); //rapidity
159   fAntiProtonContainer->SetBinLimits(1,binLimPt); //pT
160
161
162 //____________________________________________________________________//
163 AliProtonAnalysis::~AliProtonAnalysis() {
164   //Default destructor
165   if(fHistEvents) delete fHistEvents;
166   if(fHistYPtProtons) delete fHistYPtProtons;
167   if(fHistYPtAntiProtons) delete fHistYPtAntiProtons;
168   if(fProtonContainer) delete fProtonContainer;
169   if(fAntiProtonContainer) delete fAntiProtonContainer;
170
171   if(fGlobalQAList) delete fGlobalQAList;
172   if(fQA2DList) delete fQA2DList;
173   if(fQAPrimaryProtonsAcceptedList) delete fQAPrimaryProtonsAcceptedList;
174   if(fQAPrimaryProtonsRejectedList) delete fQAPrimaryProtonsRejectedList;
175   if(fQASecondaryProtonsAcceptedList) delete fQASecondaryProtonsAcceptedList;
176   if(fQASecondaryProtonsRejectedList) delete fQASecondaryProtonsRejectedList;
177   if(fQAPrimaryAntiProtonsAcceptedList) 
178     delete fQAPrimaryAntiProtonsAcceptedList;
179   if(fQAPrimaryAntiProtonsRejectedList) 
180     delete fQAPrimaryAntiProtonsRejectedList;
181   if(fQASecondaryAntiProtonsAcceptedList) 
182     delete fQASecondaryAntiProtonsAcceptedList;
183   if(fQASecondaryAntiProtonsRejectedList) 
184     delete fQASecondaryAntiProtonsRejectedList; 
185
186   if(fEffGridListProtons) delete fEffGridListProtons;
187   if(fCorrectionListProtons2D) delete fCorrectionListProtons2D;
188   if(fEfficiencyListProtons1D) delete fEfficiencyListProtons1D;
189   if(fCorrectionListProtons1D) delete fCorrectionListProtons1D;
190   if(fEffGridListAntiProtons) delete fEffGridListAntiProtons;
191   if(fCorrectionListAntiProtons2D) delete fCorrectionListAntiProtons2D;
192   if(fEfficiencyListAntiProtons1D) delete fEfficiencyListAntiProtons1D;
193   if(fCorrectionListAntiProtons1D) delete fCorrectionListAntiProtons1D;
194   if(fCorrectProtons) delete fCorrectProtons;
195   if(fCorrectAntiProtons) delete fCorrectAntiProtons;
196 }
197
198 //____________________________________________________________________//
199 void AliProtonAnalysis::InitAnalysisHistograms(Int_t nbinsY, 
200                                                Float_t fLowY, Float_t fHighY, 
201                                                Int_t nbinsPt, 
202                                                Float_t fLowPt, Float_t fHighPt) {
203   fNBinsY = nbinsY;
204   fMinY = fLowY;
205   fMaxY = fHighY;
206   fNBinsPt = nbinsPt;
207   fMinPt = fLowPt;
208   fMaxPt = fHighPt;
209
210   fHistEvents = new TH1I("fHistEvents","Anallyzed events",1,0,1);
211
212   fHistYPtProtons = new TH2D("fHistYPtProtons","y-Pt Protons",
213                              fNBinsY,fMinY,fMaxY,fNBinsPt,fMinPt,fMaxPt);
214   fHistYPtProtons->SetStats(kTRUE);
215   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV]");
216   fHistYPtProtons->GetXaxis()->SetTitle("y");
217   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
218
219   fHistYPtAntiProtons = new TH2D("fHistYPtAntiProtons","y-Pt Antiprotons",
220                                  fNBinsY,fMinY,fMaxY,fNBinsPt,fMinPt,fMaxPt);
221   fHistYPtAntiProtons->SetStats(kTRUE);
222   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV]");
223   fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
224   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
225
226   //setting up the containers
227   Int_t iBin[2];
228   iBin[0] = nbinsY;
229   iBin[1] = nbinsPt;
230   Double_t *binLimY = new Double_t[nbinsY+1];
231   Double_t *binLimPt = new Double_t[nbinsPt+1];
232   //values for bin lower bounds
233   for(Int_t i = 0; i <= nbinsY; i++) 
234     binLimY[i]=(Double_t)fLowY  + (fHighY - fLowY)  /nbinsY*(Double_t)i;
235   for(Int_t i = 0; i <= nbinsPt; i++) 
236     binLimPt[i]=(Double_t)fLowPt  + (fHighPt - fLowPt)  /nbinsPt*(Double_t)i;
237
238   fProtonContainer = new AliCFContainer("containerProtons",
239                                         "container for protons",
240                                         1,2,iBin);
241   fProtonContainer->SetBinLimits(0,binLimY); //rapidity
242   fProtonContainer->SetBinLimits(1,binLimPt); //pT
243   fAntiProtonContainer = new AliCFContainer("containerAntiProtons",
244                                             "container for antiprotons",
245                                             1,2,iBin);
246   fAntiProtonContainer->SetBinLimits(0,binLimY); //rapidity
247   fAntiProtonContainer->SetBinLimits(1,binLimPt); //pT
248 }
249
250 //____________________________________________________________________//
251 Bool_t AliProtonAnalysis::ReadFromFile(const char* filename) {
252   Bool_t status = kTRUE;
253
254   TFile *file = TFile::Open(filename);
255   if(!file) {
256     cout<<"Could not find the input file "<<filename<<endl;
257     status = kFALSE;
258   }
259
260   TList *list = (TList *)file->Get("outputList1");
261   if(list) {
262     cout<<"Retrieving objects from the list "<<list->GetName()<<"..."<<endl; 
263     fHistYPtProtons = (TH2D *)list->At(0);
264     fHistYPtAntiProtons = (TH2D *)list->At(1);
265     fHistEvents = (TH1I *)list->At(2);
266     fProtonContainer = (AliCFContainer *)list->At(3);
267     fAntiProtonContainer = (AliCFContainer *)list->At(4);
268   }
269   else if(!list) {
270     cout<<"Retrieving objects from the file... "<<endl;
271     fHistYPtProtons = (TH2D *)file->Get("fHistYPtProtons");
272     fHistYPtAntiProtons = (TH2D *)file->Get("fHistYPtAntiProtons");
273     fHistEvents = (TH1I *)file->Get("fHistEvents");
274     fProtonContainer = (AliCFContainer *)file->Get("containerProtons");
275     fAntiProtonContainer = (AliCFContainer *)file->Get("containerAntiProtons");
276   }
277   if((!fHistYPtProtons)||(!fHistYPtAntiProtons)||(!fHistEvents)
278      ||(!fProtonContainer)||(!fAntiProtonContainer)) {
279     cout<<"Input containers were not found!!!"<<endl;
280     status = kFALSE;
281   }
282   else {
283     fHistYPtProtons = fProtonContainer->ShowProjection(0,1,0);
284     fHistYPtAntiProtons = fAntiProtonContainer->ShowProjection(0,1,0);
285     //fHistYPtProtons->Sumw2();
286     //fHistYPtAntiProtons->Sumw2();
287   }
288
289   return status;
290 }
291
292 //____________________________________________________________________//
293 TH1D *AliProtonAnalysis::GetProtonYHistogram() {
294   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
295
296   //TH1D *fYProtons = (TH1D *)fHistYPtProtons->ProjectionX("fYProtons",0,fHistYPtProtons->GetYaxis()->GetNbins(),"e");
297   TH1D *fYProtons = fProtonContainer->ShowProjection(0,0); //variable-step
298    
299   fYProtons->SetStats(kFALSE);
300   fYProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
301   fYProtons->SetTitle("dN/dy protons");
302   fYProtons->SetMarkerStyle(kFullCircle);
303   fYProtons->SetMarkerColor(4);
304   if(nAnalyzedEvents > 0)
305   fYProtons->Scale(1./nAnalyzedEvents);
306   
307   return fYProtons;
308 }
309
310 //____________________________________________________________________//
311 TH1D *AliProtonAnalysis::GetAntiProtonYHistogram() {
312   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
313   //TH1D *fYAntiProtons = (TH1D *)fHistYPtAntiProtons->ProjectionX("fYAntiProtons",0,fHistYPtAntiProtons->GetYaxis()->GetNbins(),"e");
314   TH1D *fYAntiProtons = fAntiProtonContainer->ShowProjection(0,0);//variable-step 
315  
316   fYAntiProtons->SetStats(kFALSE);
317   fYAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
318   fYAntiProtons->SetTitle("dN/dy antiprotons");
319   fYAntiProtons->SetMarkerStyle(kFullCircle);
320   fYAntiProtons->SetMarkerColor(4);
321   if(nAnalyzedEvents > 0)
322     fYAntiProtons->Scale(1./nAnalyzedEvents);
323
324   return fYAntiProtons;
325 }
326
327 //____________________________________________________________________//
328 TH1D *AliProtonAnalysis::GetProtonPtHistogram() {
329   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
330   //TH1D *fPtProtons = (TH1D *)fHistYPtProtons->ProjectionY("fPtProtons",0,fHistYPtProtons->GetXaxis()->GetNbins(),"e"); 
331   TH1D *fPtProtons = fProtonContainer->ShowProjection(1,0); //variable-step
332
333   fPtProtons->SetStats(kFALSE);
334   fPtProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
335   fPtProtons->SetTitle("dN/dPt protons");
336   fPtProtons->SetMarkerStyle(kFullCircle);
337   fPtProtons->SetMarkerColor(4);
338   if(nAnalyzedEvents > 0)
339     fPtProtons->Scale(1./nAnalyzedEvents);
340
341   return fPtProtons;
342 }
343
344 //____________________________________________________________________//
345 TH1D *AliProtonAnalysis::GetAntiProtonPtHistogram() {
346   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
347   //TH1D *fPtAntiProtons = (TH1D *)fHistYPtAntiProtons->ProjectionY("fPtAntiProtons",0,fHistYPtProtons->GetXaxis()->GetNbins(),"e"); 
348   TH1D *fPtAntiProtons = fAntiProtonContainer->ShowProjection(1,0); //variable-step
349
350   fPtAntiProtons->SetStats(kFALSE);
351   fPtAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
352   fPtAntiProtons->SetTitle("dN/dPt antiprotons");
353   fPtAntiProtons->SetMarkerStyle(kFullCircle);
354   fPtAntiProtons->SetMarkerColor(4);
355   if(nAnalyzedEvents > 0)
356     fPtAntiProtons->Scale(1./nAnalyzedEvents);
357
358   return fPtAntiProtons;
359 }
360
361 //____________________________________________________________________//
362 TH1D *AliProtonAnalysis::GetProtonCorrectedYHistogram() {
363   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
364
365   TH1D *fYProtons = fCorrectProtons->Project(0); //0: rapidity
366    
367   fYProtons->SetStats(kFALSE);
368   fYProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
369   fYProtons->GetXaxis()->SetTitle("y");
370   fYProtons->SetTitle("dN/dy protons");
371   fYProtons->SetMarkerStyle(kFullCircle);
372   fYProtons->SetMarkerColor(4);
373   if(nAnalyzedEvents > 0)
374     fYProtons->Scale(1./nAnalyzedEvents);
375   
376   return fYProtons;
377 }
378
379 //____________________________________________________________________//
380 TH1D *AliProtonAnalysis::GetAntiProtonCorrectedYHistogram() {
381   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
382
383   TH1D *fYAntiProtons = fCorrectAntiProtons->Project(0); //0: rapidity
384    
385   fYAntiProtons->SetStats(kFALSE);
386   fYAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
387   fYAntiProtons->GetXaxis()->SetTitle("y");
388   fYAntiProtons->SetTitle("dN/dy protons");
389   fYAntiProtons->SetMarkerStyle(kFullCircle);
390   fYAntiProtons->SetMarkerColor(4);
391   if(nAnalyzedEvents > 0)
392     fYAntiProtons->Scale(1./nAnalyzedEvents);
393   
394   return fYAntiProtons;
395 }
396
397 //____________________________________________________________________//
398 TH1D *AliProtonAnalysis::GetProtonCorrectedPtHistogram() {
399   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
400
401   TH1D *fPtProtons = fCorrectProtons->Project(0); //0: rapidity
402    
403   fPtProtons->SetStats(kFALSE);
404   fPtProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
405   fPtProtons->GetXaxis()->SetTitle("P_{T} [GeV/c]");
406   fPtProtons->SetTitle("dN/dPt protons");
407   fPtProtons->SetMarkerStyle(kFullCircle);
408   fPtProtons->SetMarkerColor(4);
409   if(nAnalyzedEvents > 0)
410     fPtProtons->Scale(1./nAnalyzedEvents);
411   
412   return fPtProtons;
413 }
414
415 //____________________________________________________________________//
416 TH1D *AliProtonAnalysis::GetAntiProtonCorrectedPtHistogram() {
417   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
418
419   TH1D *fPtAntiProtons = fCorrectAntiProtons->Project(0); //0: rapidity
420    
421   fPtAntiProtons->SetStats(kFALSE);
422   fPtAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
423   fPtAntiProtons->GetXaxis()->SetTitle("P_{T} [GeV/c]");
424   fPtAntiProtons->SetTitle("dN/dPt antiprotons");
425   fPtAntiProtons->SetMarkerStyle(kFullCircle);
426   fPtAntiProtons->SetMarkerColor(4);
427   if(nAnalyzedEvents > 0)
428     fPtAntiProtons->Scale(1./nAnalyzedEvents);
429   
430   return fPtAntiProtons;
431 }
432
433 //____________________________________________________________________//
434 TH1D *AliProtonAnalysis::GetYRatioHistogram() {
435   TH1D *fYProtons = GetProtonYHistogram();
436   TH1D *fYAntiProtons = GetAntiProtonYHistogram();
437   
438   TH1D *hRatioY = new TH1D("hRatioY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
439   hRatioY->Divide(fYAntiProtons,fYProtons,1.0,1.0);
440   hRatioY->SetMarkerStyle(kFullCircle);
441   hRatioY->SetMarkerColor(4);
442   hRatioY->GetYaxis()->SetTitle("#bar{p}/p");
443   hRatioY->GetYaxis()->SetTitleOffset(1.4);
444   hRatioY->GetXaxis()->SetTitle("y");
445   hRatioY->GetXaxis()->SetTitleColor(1);
446   hRatioY->SetStats(kFALSE);
447
448   return hRatioY;
449 }
450
451 //____________________________________________________________________//
452 TH1D *AliProtonAnalysis::GetPtRatioHistogram() {
453   TH1D *fPtProtons = GetProtonPtHistogram();
454   TH1D *fPtAntiProtons = GetAntiProtonPtHistogram();
455   
456   TH1D *hRatioPt = new TH1D("hRatioPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
457   hRatioPt->Divide(fPtAntiProtons,fPtProtons,1.0,1.0);
458   hRatioPt->SetMarkerStyle(kFullCircle);
459   hRatioPt->SetMarkerColor(4);
460   hRatioPt->GetYaxis()->SetTitle("#bar{p}/p");
461   hRatioPt->GetYaxis()->SetTitleOffset(1.4);
462   hRatioPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
463   hRatioPt->GetXaxis()->SetTitleColor(1);
464   hRatioPt->SetStats(kFALSE);
465
466   return hRatioPt;
467 }
468
469 //____________________________________________________________________//
470 TH1D *AliProtonAnalysis::GetYAsymmetryHistogram() {
471   TH1D *fYProtons = GetProtonYHistogram();
472   TH1D *fYAntiProtons = GetAntiProtonYHistogram();
473   
474   TH1D *hsum = new TH1D("hsumY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
475   hsum->Add(fYProtons,fYAntiProtons,1.0,1.0);
476
477   TH1D *hdiff = new TH1D("hdiffY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
478   hdiff->Add(fYProtons,fYAntiProtons,1.0,-1.0);
479
480   TH1D *hAsymmetryY = new TH1D("hAsymmetryY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
481   hAsymmetryY->Divide(hdiff,hsum,2.0,1.);
482   hAsymmetryY->SetMarkerStyle(kFullCircle);
483   hAsymmetryY->SetMarkerColor(4);
484   hAsymmetryY->GetYaxis()->SetTitle("A_{p}");
485   hAsymmetryY->GetYaxis()->SetTitleOffset(1.4);
486   hAsymmetryY->GetXaxis()->SetTitle("y");
487   hAsymmetryY->GetXaxis()->SetTitleColor(1);
488   hAsymmetryY->SetStats(kFALSE);
489
490   return hAsymmetryY;
491 }
492
493 //____________________________________________________________________//
494 TH1D *AliProtonAnalysis::GetPtAsymmetryHistogram() {
495   TH1D *fPtProtons = GetProtonPtHistogram();
496   TH1D *fPtAntiProtons = GetAntiProtonPtHistogram();
497   
498   TH1D *hsum = new TH1D("hsumPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
499   hsum->Add(fPtProtons,fPtAntiProtons,1.0,1.0);
500
501   TH1D *hdiff = new TH1D("hdiffPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
502   hdiff->Add(fPtProtons,fPtAntiProtons,1.0,-1.0);
503
504   TH1D *hAsymmetryPt = new TH1D("hAsymmetryPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
505   hAsymmetryPt->Divide(hdiff,hsum,2.0,1.);
506   hAsymmetryPt->SetMarkerStyle(kFullCircle);
507   hAsymmetryPt->SetMarkerColor(4);
508   hAsymmetryPt->GetYaxis()->SetTitle("A_{p}");
509   hAsymmetryPt->GetYaxis()->SetTitleOffset(1.4);
510   hAsymmetryPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
511   hAsymmetryPt->GetXaxis()->SetTitleColor(1);
512   hAsymmetryPt->SetStats(kFALSE);
513
514   return hAsymmetryPt;
515 }
516
517 //____________________________________________________________________//
518 Double_t AliProtonAnalysis::GetParticleFraction(Int_t i, Double_t p) {
519   Double_t partFrac=0;
520   if(fFunctionProbabilityFlag) {
521     if(i == 0) partFrac = fElectronFunction->Eval(p);
522     if(i == 1) partFrac = fMuonFunction->Eval(p);
523     if(i == 2) partFrac = fPionFunction->Eval(p);
524     if(i == 3) partFrac = fKaonFunction->Eval(p);
525     if(i == 4) partFrac = fProtonFunction->Eval(p);
526   }
527   else partFrac = fPartFrac[i];
528
529   return partFrac;
530 }
531
532 //____________________________________________________________________//
533 void AliProtonAnalysis::Analyze(AliESDEvent* fESD) {
534   //Main analysis part - ESD
535   fHistEvents->Fill(0); //number of analyzed events
536   Double_t containerInput[2] ;
537   Double_t Pt = 0.0, P = 0.0;
538   Int_t nGoodTracks = fESD->GetNumberOfTracks();
539   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
540     AliESDtrack* track = fESD->GetTrack(iTracks);
541     Double_t probability[5];
542
543     if(IsAccepted(track)) {     
544       if(fUseTPCOnly) {
545         AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
546         if(!tpcTrack) continue;
547         Pt = tpcTrack->Pt();
548         P = tpcTrack->P();
549         
550         //pid
551         track->GetTPCpid(probability);
552         Double_t rcc = 0.0;
553         for(Int_t i = 0; i < AliPID::kSPECIES; i++) 
554           rcc += probability[i]*GetParticleFraction(i,P);
555         if(rcc == 0.0) continue;
556         Double_t w[5];
557         for(Int_t i = 0; i < AliPID::kSPECIES; i++) 
558           w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
559         Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
560         if(fParticleType == 4) {
561           if(tpcTrack->Charge() > 0) {
562             fHistYPtProtons->Fill(Rapidity(tpcTrack->Px(),
563                                            tpcTrack->Py(),
564                                            tpcTrack->Pz()),
565                                   Pt);
566             //fill the container
567             containerInput[0] = Rapidity(tpcTrack->Px(),
568                                          tpcTrack->Py(),
569                                          tpcTrack->Pz());
570             containerInput[1] = Pt;
571             fProtonContainer->Fill(containerInput,0);   
572           }//protons
573           else if(tpcTrack->Charge() < 0) {
574             fHistYPtAntiProtons->Fill(Rapidity(tpcTrack->Px(),
575                                                tpcTrack->Py(),
576                                                tpcTrack->Pz()),
577                                       Pt);
578             //fill the container
579             containerInput[0] = Rapidity(tpcTrack->Px(),
580                                          tpcTrack->Py(),
581                                          tpcTrack->Pz());
582             containerInput[1] = Pt;
583             fAntiProtonContainer->Fill(containerInput,0);
584           }//antiprotons   
585         }//proton check
586       }//TPC only tracks
587       else if(!fUseTPCOnly) {
588         Pt = track->Pt();
589         P = track->P();
590         
591         //pid
592         track->GetESDpid(probability);
593         Double_t rcc = 0.0;
594         for(Int_t i = 0; i < AliPID::kSPECIES; i++) 
595           rcc += probability[i]*GetParticleFraction(i,P);
596         if(rcc == 0.0) continue;
597         Double_t w[5];
598         for(Int_t i = 0; i < AliPID::kSPECIES; i++) 
599           w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
600         Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
601         if(fParticleType == 4) {
602           //cout<<"(Anti)protons found..."<<endl;
603           if(track->Charge() > 0) {
604             fHistYPtProtons->Fill(Rapidity(track->Px(),
605                                            track->Py(),
606                                            track->Pz()),
607                                   Pt);
608             //fill the container
609             containerInput[0] = Rapidity(track->Px(),
610                                          track->Py(),
611                                          track->Pz());
612             containerInput[1] = Pt;
613             fProtonContainer->Fill(containerInput,0);   
614           }//protons
615           else if(track->Charge() < 0) {
616             fHistYPtAntiProtons->Fill(Rapidity(track->Px(),
617                                                track->Py(),
618                                                track->Pz()),
619                                       Pt);
620             //fill the container
621             containerInput[0] = Rapidity(track->Px(),
622                                          track->Py(),
623                                          track->Pz());
624             containerInput[1] = Pt;
625             fAntiProtonContainer->Fill(containerInput,0);   
626           }//antiprotons
627         }//proton check 
628       }//combined tracking
629     }//cuts
630   }//track loop 
631 }
632
633 //____________________________________________________________________//
634 void AliProtonAnalysis::Analyze(AliAODEvent* fAOD) {
635   //Main analysis part - AOD
636   fHistEvents->Fill(0); //number of analyzed events
637   Int_t nGoodTracks = fAOD->GetNumberOfTracks();
638   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
639     AliAODTrack* track = fAOD->GetTrack(iTracks);
640     Double_t Pt = track->Pt();
641     Double_t P = track->P();
642     
643     //pid
644     Double_t probability[10];
645     track->GetPID(probability);
646     Double_t rcc = 0.0;
647     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) rcc += probability[i]*GetParticleFraction(i,P);
648     if(rcc == 0.0) continue;
649     Double_t w[10];
650     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
651     Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIESN,w);
652     if(fParticleType == 4) {
653       if(track->Charge() > 0) 
654         fHistYPtProtons->Fill(track->Y(fParticleType),Pt);
655       else if(track->Charge() < 0) 
656         fHistYPtAntiProtons->Fill(track->Y(fParticleType),Pt);
657     }//proton check
658   }//track loop 
659 }
660
661 //____________________________________________________________________//
662 void AliProtonAnalysis::Analyze(AliStack* stack) {
663   //Main analysis part - MC
664   fHistEvents->Fill(0); //number of analyzed events
665   for(Int_t i = 0; i < stack->GetNprimary(); i++) {
666     TParticle *particle = stack->Particle(i);
667     if(particle->Pt() < 0.1) continue;
668     if(TMath::Abs(particle->Eta()) > 1.0) continue;
669     Int_t pdgcode = particle->GetPdgCode();
670     if(pdgcode == 2212) fHistYPtProtons->Fill(Rapidity(particle->Px(),
671                                                        particle->Py(),
672                                                        particle->Pz()),
673                                               particle->Pt());
674     if(pdgcode == -2212) fHistYPtAntiProtons->Fill(Rapidity(particle->Px(),
675                                                             particle->Py(),
676                                                             particle->Pz()),
677                                                    particle->Pt());
678   }//particle loop
679 }
680
681 //____________________________________________________________________//
682 Bool_t AliProtonAnalysis::IsAccepted(AliESDtrack* track) {
683   // Checks if the track is excluded from the cuts
684   Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
685   if(fUseTPCOnly) {
686     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
687     if(!tpcTrack) {
688       Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
689     }
690     else {
691       Pt = tpcTrack->Pt();
692       Px = tpcTrack->Px();
693       Py = tpcTrack->Py();
694       Pz = tpcTrack->Pz();
695     }
696   }
697   else{
698     Pt = track->Pt();
699     Px = track->Px();
700     Py = track->Py();
701     Pz = track->Pz();
702   }
703      
704   Int_t  fIdxInt[200];
705   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
706   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
707
708   Float_t chi2PerClusterITS = -1;
709   if (nClustersITS!=0)
710     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
711   Float_t chi2PerClusterTPC = -1;
712   if (nClustersTPC!=0)
713     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
714
715   Double_t extCov[15];
716   track->GetExternalCovariance(extCov);
717
718   if(fMinITSClustersFlag)
719     if(nClustersITS < fMinITSClusters) return kFALSE;
720   if(fMaxChi2PerITSClusterFlag)
721     if(chi2PerClusterITS > fMaxChi2PerITSCluster) return kFALSE; 
722   if(fMinTPCClustersFlag)
723     if(nClustersTPC < fMinTPCClusters) return kFALSE;
724   if(fMaxChi2PerTPCClusterFlag)
725     if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) return kFALSE; 
726   if(fMaxCov11Flag)
727     if(extCov[0] > fMaxCov11) return kFALSE;
728   if(fMaxCov22Flag)
729     if(extCov[2] > fMaxCov22) return kFALSE;
730   if(fMaxCov33Flag)
731     if(extCov[5] > fMaxCov33) return kFALSE;
732   if(fMaxCov44Flag)
733     if(extCov[9] > fMaxCov44) return kFALSE;
734   if(fMaxCov55Flag)
735     if(extCov[14] > fMaxCov55) return kFALSE;
736   if(fMaxSigmaToVertexFlag)
737     if(GetSigmaToVertex(track) > fMaxSigmaToVertex) return kFALSE;
738   if(fMaxSigmaToVertexTPCFlag)
739     if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) return kFALSE;
740   if(fITSRefitFlag)
741     if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) return kFALSE;
742   if(fTPCRefitFlag)
743     if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) return kFALSE;
744   if(fESDpidFlag)
745     if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) return kFALSE;
746   if(fTPCpidFlag)
747     if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) return kFALSE;
748
749   if((Pt < fMinPt) || (Pt > fMaxPt)) return kFALSE;
750   if((Rapidity(Px,Py,Pz) < fMinY) || (Rapidity(Px,Py,Pz) > fMaxY)) 
751     return kFALSE;
752
753   return kTRUE;
754 }
755
756 //____________________________________________________________________//
757 void AliProtonAnalysis::FillQA(AliESDtrack* track, AliStack *stack) {
758   // Checks if the track is excluded from the cuts
759   Int_t nPrimaries = stack->GetNprimary();
760   Int_t label = TMath::Abs(track->GetLabel());
761
762   Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
763   if(fUseTPCOnly) {
764     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
765     if(!tpcTrack) {
766       Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
767     }
768     else {
769       Pt = tpcTrack->Pt();
770       Px = tpcTrack->Px();
771       Py = tpcTrack->Py();
772       Pz = tpcTrack->Pz();
773     }
774   }
775   else{
776     Pt = track->Pt();
777     Px = track->Px();
778     Py = track->Py();
779     Pz = track->Pz();
780   }
781      
782   Int_t  fIdxInt[200];
783   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
784   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
785
786   Float_t chi2PerClusterITS = -1;
787   if (nClustersITS!=0)
788     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
789   Float_t chi2PerClusterTPC = -1;
790   if (nClustersTPC!=0)
791     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
792
793   Double_t extCov[15];
794   track->GetExternalCovariance(extCov);
795   
796   //cout<<"Charge: "<<track->Charge()<<
797   //" - Label/Primaries: "<<label<<"/"<<nPrimaries<<
798   //" - TPC clusters: "<<nClustersTPC<<endl;
799   //protons
800   if(track->Charge() > 0) {
801     //Primaries
802     if(label <= nPrimaries) {
803       if(fMinITSClustersFlag) {
804         if(nClustersITS < fMinITSClusters) {
805           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
806           //status = kFALSE;
807         }
808         else if(nClustersITS >= fMinITSClusters) 
809           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
810       }//ITS clusters
811       if(fMaxChi2PerITSClusterFlag) {
812         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
813           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
814           //status = kFALSE;
815         }
816         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
817           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
818       }//chi2 per ITS cluster
819       if(fMinTPCClustersFlag) {
820         if(nClustersTPC < fMinTPCClusters) {
821           //cout<<"Primary proton rejected"<<endl;
822           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
823           //status = kFALSE;
824         }
825         else if(nClustersTPC >= fMinTPCClusters) {
826           //cout<<"Primary proton accepted"<<endl;
827           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
828         }
829       }//TPC clusters
830       if(fMaxChi2PerTPCClusterFlag) {
831         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
832           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
833           //status = kFALSE;
834         }
835         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
836           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
837       }//chi2 per TPC cluster
838       if(fMaxCov11Flag) {
839         if(extCov[0] > fMaxCov11) {
840           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
841           //status = kFALSE;
842         }
843         else if(extCov[0] <= fMaxCov11)
844           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
845       }//cov11
846       if(fMaxCov22Flag) {
847         if(extCov[2] > fMaxCov22) {
848           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
849           //status = kFALSE;
850         }
851         else if(extCov[2] <= fMaxCov22)
852           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
853       }//cov11
854       if(fMaxCov33Flag) {
855         if(extCov[5] > fMaxCov33) {
856           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
857           //status = kFALSE;
858         }
859         else if(extCov[5] <= fMaxCov33)
860           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
861       }//cov11
862       if(fMaxCov44Flag) {
863         if(extCov[9] > fMaxCov44) {
864           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
865           //status = kFALSE;
866         }
867         else if(extCov[9] <= fMaxCov44)
868           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
869       }//cov11
870       if(fMaxCov55Flag) {
871         if(extCov[14] > fMaxCov55) {
872           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
873           //status = kFALSE;
874         }
875         else if(extCov[14] <= fMaxCov55)
876           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
877       }//cov55
878       if(fMaxSigmaToVertexFlag) {
879         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
880           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
881           //status = kFALSE;
882         }
883         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
884           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
885       }//sigma to vertex
886       if(fMaxSigmaToVertexTPCFlag) {
887         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
888           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
889           //status = kFALSE;
890         }
891         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
892           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
893       }//sigma to vertex TPC
894       if(fITSRefitFlag) {
895         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
896           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(11)))->Fill(0);
897         //status = kFALSE;
898         }
899         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
900           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(11)))->Fill(0);
901       }//ITS refit
902       if(fTPCRefitFlag) {
903         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
904           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(12)))->Fill(0);
905           //status = kFALSE;
906         }
907         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
908           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(12)))->Fill(0);
909       }//TPC refit
910       if(fESDpidFlag) {
911         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
912           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(13)))->Fill(0);
913           //status = kFALSE;
914         }
915         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
916           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(13)))->Fill(0);
917       }//ESD pid
918       if(fTPCpidFlag) {
919         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
920           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(13)))->Fill(0);
921           //status = kFALSE;
922         }
923         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
924           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(13)))->Fill(0);
925       }//TPC pid
926     }//primary particle cut
927
928     //Secondaries
929     if(label > nPrimaries) {
930       if(fMinITSClustersFlag) {
931         if(nClustersITS < fMinITSClusters) {
932           ((TH1F *)(fQASecondaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
933           //status = kFALSE;
934         }
935         else if(nClustersITS >= fMinITSClusters) 
936           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
937       }//ITS clusters
938       if(fMaxChi2PerITSClusterFlag) {
939         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
940           ((TH1F *)(fQASecondaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
941           //status = kFALSE;
942         }
943         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
944           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
945       }//chi2 per ITS cluster
946       if(fMinTPCClustersFlag) {
947         if(nClustersTPC < fMinTPCClusters) {
948           //cout<<"Secondary proton rejected"<<endl;
949           ((TH1F *)(fQASecondaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
950           //status = kFALSE;
951         }
952         else if(nClustersTPC >= fMinTPCClusters) {
953           //cout<<"Secondary proton accepted"<<endl;
954           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
955         }
956       }//TPC clusters
957       if(fMaxChi2PerTPCClusterFlag) {
958         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
959           ((TH1F *)(fQASecondaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
960           //status = kFALSE;
961         }
962         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
963           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
964       }//chi2 per TPC cluster
965       if(fMaxCov11Flag) {
966         if(extCov[0] > fMaxCov11) {
967           ((TH1F *)(fQASecondaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
968           //status = kFALSE;
969         }
970         else if(extCov[0] <= fMaxCov11)
971           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
972       }//cov11
973       if(fMaxCov22Flag) {
974         if(extCov[2] > fMaxCov22) {
975           ((TH1F *)(fQASecondaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
976           //status = kFALSE;
977         }
978         else if(extCov[2] <= fMaxCov22)
979           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
980       }//cov11
981       if(fMaxCov33Flag) {
982         if(extCov[5] > fMaxCov33) {
983           ((TH1F *)(fQASecondaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
984           //status = kFALSE;
985         }
986         else if(extCov[5] <= fMaxCov33)
987           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
988       }//cov11
989       if(fMaxCov44Flag) {
990         if(extCov[9] > fMaxCov44) {
991           ((TH1F *)(fQASecondaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
992           //status = kFALSE;
993         }
994         else if(extCov[9] <= fMaxCov44)
995           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
996       }//cov11
997       if(fMaxCov55Flag) {
998         if(extCov[14] > fMaxCov55) {
999           ((TH1F *)(fQASecondaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
1000           //status = kFALSE;
1001         }
1002         else if(extCov[14] <= fMaxCov55)
1003           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
1004       }//cov55
1005       if(fMaxSigmaToVertexFlag) {
1006         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
1007           ((TH1F *)(fQASecondaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
1008           //status = kFALSE;
1009         }
1010         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
1011           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
1012       }//sigma to vertex
1013       if(fMaxSigmaToVertexTPCFlag) {
1014         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
1015           ((TH1F *)(fQASecondaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
1016           //status = kFALSE;
1017         }
1018         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
1019           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
1020       }//sigma to vertex TPC
1021       if(fITSRefitFlag) {
1022         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
1023           ((TH1F *)(fQASecondaryProtonsRejectedList->At(11)))->Fill(0);
1024         //status = kFALSE;
1025         }
1026         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
1027           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(11)))->Fill(0);
1028       }//ITS refit
1029       if(fTPCRefitFlag) {
1030         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
1031           ((TH1F *)(fQASecondaryProtonsRejectedList->At(12)))->Fill(0);
1032           //status = kFALSE;
1033         }
1034         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
1035           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(12)))->Fill(0);
1036       }//TPC refit
1037       if(fESDpidFlag) {
1038         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
1039           ((TH1F *)(fQASecondaryProtonsRejectedList->At(13)))->Fill(0);
1040           //status = kFALSE;
1041         }
1042         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
1043           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(13)))->Fill(0);
1044       }//ESD pid
1045       if(fTPCpidFlag) {
1046         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
1047           ((TH1F *)(fQASecondaryProtonsRejectedList->At(13)))->Fill(0);
1048           //status = kFALSE;
1049         }
1050         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
1051           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(13)))->Fill(0);
1052       }//TPC pid
1053     }//secondary particle cut
1054   }//protons
1055
1056   //antiprotons
1057   if(track->Charge() < 0) {
1058     //Primaries
1059     if(label <= nPrimaries) {
1060       if(fMinITSClustersFlag) {
1061         if(nClustersITS < fMinITSClusters) {
1062           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
1063           //status = kFALSE;
1064         }
1065         else if(nClustersITS >= fMinITSClusters) 
1066           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
1067       }//ITS clusters
1068       if(fMaxChi2PerITSClusterFlag) {
1069         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
1070           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
1071           //status = kFALSE;
1072         }
1073         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
1074           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
1075       }//chi2 per ITS cluster
1076       if(fMinTPCClustersFlag) {
1077         if(nClustersTPC < fMinTPCClusters) {
1078           //cout<<"Primary antiproton rejected"<<endl;
1079           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
1080           //status = kFALSE;
1081         }
1082         else if(nClustersTPC >= fMinTPCClusters) {
1083           //cout<<"Primary antiproton accepted"<<endl;
1084           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
1085         }
1086       }//TPC clusters
1087       if(fMaxChi2PerTPCClusterFlag) {
1088         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
1089           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
1090           //status = kFALSE;
1091         }
1092         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
1093           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
1094       }//chi2 per TPC cluster
1095       if(fMaxCov11Flag) {
1096         if(extCov[0] > fMaxCov11) {
1097           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
1098           //status = kFALSE;
1099         }
1100         else if(extCov[0] <= fMaxCov11)
1101           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
1102       }//cov11
1103       if(fMaxCov22Flag) {
1104         if(extCov[2] > fMaxCov22) {
1105           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
1106           //status = kFALSE;
1107         }
1108         else if(extCov[2] <= fMaxCov22)
1109           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
1110       }//cov11
1111       if(fMaxCov33Flag) {
1112         if(extCov[5] > fMaxCov33) {
1113           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
1114           //status = kFALSE;
1115         }
1116         else if(extCov[5] <= fMaxCov33)
1117           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
1118       }//cov11
1119       if(fMaxCov44Flag) {
1120         if(extCov[9] > fMaxCov44) {
1121           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
1122           //status = kFALSE;
1123         }
1124         else if(extCov[9] <= fMaxCov44)
1125           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
1126       }//cov11
1127       if(fMaxCov55Flag) {
1128         if(extCov[14] > fMaxCov55) {
1129           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
1130           //status = kFALSE;
1131         }
1132         else if(extCov[14] <= fMaxCov55)
1133           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
1134       }//cov55
1135       if(fMaxSigmaToVertexFlag) {
1136         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
1137           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
1138           //status = kFALSE;
1139         }
1140         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
1141           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
1142       }//sigma to vertex
1143       if(fMaxSigmaToVertexTPCFlag) {
1144         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
1145           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
1146           //status = kFALSE;
1147         }
1148         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
1149           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
1150       }//sigma to vertex TPC
1151       if(fITSRefitFlag) {
1152         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
1153           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(11)))->Fill(0);
1154         //status = kFALSE;
1155         }
1156         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
1157           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(11)))->Fill(0);
1158       }//ITS refit
1159       if(fTPCRefitFlag) {
1160         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
1161           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(12)))->Fill(0);
1162           //status = kFALSE;
1163         }
1164         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
1165           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(12)))->Fill(0);
1166       }//TPC refit
1167       if(fESDpidFlag) {
1168         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
1169           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(13)))->Fill(0);
1170           //status = kFALSE;
1171         }
1172         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
1173           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(13)))->Fill(0);
1174       }//ESD pid
1175       if(fTPCpidFlag) {
1176         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
1177           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(13)))->Fill(0);
1178           //status = kFALSE;
1179         }
1180         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
1181           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(13)))->Fill(0);
1182       }//TPC pid
1183     }//primary particle cut
1184
1185     //Secondaries
1186     if(label > nPrimaries) {
1187       if(fMinITSClustersFlag) {
1188         if(nClustersITS < fMinITSClusters) {
1189           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
1190           //status = kFALSE;
1191         }
1192         else if(nClustersITS >= fMinITSClusters) 
1193           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
1194       }//ITS clusters
1195       if(fMaxChi2PerITSClusterFlag) {
1196         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
1197           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
1198           //status = kFALSE;
1199         }
1200         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
1201           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
1202       }//chi2 per ITS cluster
1203       if(fMinTPCClustersFlag) {
1204         if(nClustersTPC < fMinTPCClusters) {
1205           //cout<<"Secondary antiproton rejected"<<endl;
1206           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
1207           //status = kFALSE;
1208         }
1209         else if(nClustersTPC >= fMinTPCClusters) {
1210           //cout<<"Secondary antiproton accepted"<<endl;
1211           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
1212         }
1213       }//TPC clusters
1214       if(fMaxChi2PerTPCClusterFlag) {
1215         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
1216           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
1217           //status = kFALSE;
1218         }
1219         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
1220           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
1221       }//chi2 per TPC cluster
1222       if(fMaxCov11Flag) {
1223         if(extCov[0] > fMaxCov11) {
1224           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
1225           //status = kFALSE;
1226         }
1227         else if(extCov[0] <= fMaxCov11)
1228           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
1229       }//cov11
1230       if(fMaxCov22Flag) {
1231         if(extCov[2] > fMaxCov22) {
1232           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
1233           //status = kFALSE;
1234         }
1235         else if(extCov[2] <= fMaxCov22)
1236           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
1237       }//cov11
1238       if(fMaxCov33Flag) {
1239         if(extCov[5] > fMaxCov33) {
1240           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
1241           //status = kFALSE;
1242         }
1243         else if(extCov[5] <= fMaxCov33)
1244           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
1245       }//cov11
1246       if(fMaxCov44Flag) {
1247         if(extCov[9] > fMaxCov44) {
1248           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
1249           //status = kFALSE;
1250         }
1251         else if(extCov[9] <= fMaxCov44)
1252           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
1253       }//cov11
1254       if(fMaxCov55Flag) {
1255         if(extCov[14] > fMaxCov55) {
1256           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
1257           //status = kFALSE;
1258         }
1259         else if(extCov[14] <= fMaxCov55)
1260           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
1261       }//cov55
1262       if(fMaxSigmaToVertexFlag) {
1263         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
1264           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
1265           //status = kFALSE;
1266         }
1267         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
1268           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
1269       }//sigma to vertex
1270       if(fMaxSigmaToVertexTPCFlag) {
1271         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
1272           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
1273           //status = kFALSE;
1274         }
1275         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
1276           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
1277       }//sigma to vertex TPC
1278       if(fITSRefitFlag) {
1279         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
1280           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(11)))->Fill(0);
1281         //status = kFALSE;
1282         }
1283         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
1284           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(11)))->Fill(0);
1285       }//ITS refit
1286       if(fTPCRefitFlag) {
1287         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
1288           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(12)))->Fill(0);
1289           //status = kFALSE;
1290         }
1291         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
1292           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(12)))->Fill(0);
1293       }//TPC refit
1294       if(fESDpidFlag) {
1295         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
1296           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(13)))->Fill(0);
1297           //status = kFALSE;
1298         }
1299         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
1300           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(13)))->Fill(0);
1301       }//ESD pid
1302       if(fTPCpidFlag) {
1303         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
1304           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(13)))->Fill(0);
1305           //status = kFALSE;
1306         }
1307         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
1308           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(13)))->Fill(0);
1309       }//TPC pid
1310     }//secondary particle cut
1311   }//antiprotons
1312
1313   //if((Pt < fMinPt) || (Pt > fMaxPt)) //status = kFALSE;
1314   //if((Rapidity(Px,Py,Pz) < fMinY) || (Rapidity(Px,Py,Pz) > fMaxY)) 
1315   //status = kFALSE;
1316
1317   //return status;
1318 }
1319
1320 //____________________________________________________________________//
1321 Float_t AliProtonAnalysis::GetSigmaToVertex(AliESDtrack* esdTrack) {
1322   // Calculates the number of sigma to the vertex.
1323   
1324   Float_t b[2];
1325   Float_t bRes[2];
1326   Float_t bCov[3];
1327   if(fUseTPCOnly) 
1328     esdTrack->GetImpactParametersTPC(b,bCov);
1329   else
1330     esdTrack->GetImpactParameters(b,bCov);
1331   
1332   if (bCov[0]<=0 || bCov[2]<=0) {
1333     //AliDebug(1, "Estimated b resolution lower or equal zero!");
1334     bCov[0]=0; bCov[2]=0;
1335   }
1336   bRes[0] = TMath::Sqrt(bCov[0]);
1337   bRes[1] = TMath::Sqrt(bCov[2]);
1338   
1339   if (bRes[0] == 0 || bRes[1] ==0) return -1;
1340   
1341   Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
1342   
1343   if (TMath::Exp(-d * d / 2) < 1e-10) return 1000;
1344   
1345   d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
1346   
1347   return d;
1348 }
1349
1350 //____________________________________________________________________//
1351 Double_t AliProtonAnalysis::Rapidity(Double_t Px, Double_t Py, Double_t Pz) {
1352   //returns the rapidity of the proton - to be removed
1353   Double_t fMass = 9.38270000000000048e-01;
1354   
1355   Double_t P = TMath::Sqrt(TMath::Power(Px,2) + 
1356                            TMath::Power(Py,2) + 
1357                            TMath::Power(Pz,2));
1358   Double_t energy = TMath::Sqrt(P*P + fMass*fMass);
1359   Double_t y = -999;
1360   if(energy != Pz) 
1361     y = 0.5*TMath::Log((energy + Pz)/(energy - Pz));
1362
1363   return y;
1364 }
1365
1366 //____________________________________________________________________//
1367 Bool_t AliProtonAnalysis::PrintMean(TH1 *hist, Double_t edge) {
1368   //calculates the mean value of the ratio/asymmetry within \pm edge
1369   Double_t sum = 0.0;
1370   Int_t nentries = 0;
1371   //calculate the mean
1372   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1373     Double_t x = hist->GetBinCenter(i+1);
1374     Double_t y = hist->GetBinContent(i+1);
1375     if(TMath::Abs(x) < edge) {
1376       sum += y;
1377       nentries += 1;
1378     }
1379   }
1380   Double_t mean = 0.0;
1381   if(nentries != 0)
1382     mean = sum/nentries;
1383
1384   //calculate the error
1385   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1386     Double_t x = hist->GetBinCenter(i+1);
1387     Double_t y = hist->GetBinContent(i+1);
1388     if(TMath::Abs(x) < edge) {
1389       sum += TMath::Power((mean - y),2);
1390       nentries += 1;
1391     }
1392   }
1393
1394   Double_t error = 0.0;
1395   if(nentries != 0)
1396     error =  TMath::Sqrt(sum)/nentries;
1397
1398   cout<<"========================================="<<endl;
1399   cout<<"Input distribution: "<<hist->GetName()<<endl;
1400   cout<<"Interval used: -"<<edge<<" -> "<<edge<<endl;
1401   cout<<"Mean value :"<<mean<<endl;
1402   cout<<"Error: "<<error<<endl;
1403   cout<<"========================================="<<endl;
1404
1405   return 0;
1406 }
1407
1408 //____________________________________________________________________//
1409 Bool_t AliProtonAnalysis::PrintYields(TH1 *hist, Double_t edge) {
1410   //calculates the (anti)proton yields within the \pm edge
1411   Double_t sum = 0.0, sumerror = 0.0;
1412   Double_t error = 0.0;
1413   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1414     Double_t x = hist->GetBinCenter(i+1);
1415     Double_t y = hist->GetBinContent(i+1);
1416     if(TMath::Abs(x) < edge) {
1417       sum += y;
1418       sumerror += TMath::Power(hist->GetBinError(i+1),2); 
1419     }
1420   }
1421
1422   error = TMath::Sqrt(sumerror);
1423
1424   cout<<"========================================="<<endl;
1425   cout<<"Input distribution: "<<hist->GetName()<<endl;
1426   cout<<"Interval used: -"<<edge<<" -> "<<edge<<endl;
1427   cout<<"Yields :"<<sum<<endl;
1428   cout<<"Error: "<<error<<endl;
1429   cout<<"========================================="<<endl;
1430
1431   return 0;
1432 }
1433
1434 //____________________________________________________________________//
1435 void AliProtonAnalysis::Correct(Int_t step) {
1436   //Applies the correction maps to the initial containers
1437   fCorrectProtons = new AliCFDataGrid("correctProtons",
1438                                       "corrected data",
1439                                       *fProtonContainer);
1440   fCorrectProtons->ApplyEffCorrection(*(AliCFEffGrid *)fEffGridListProtons->At(step));
1441
1442   fCorrectAntiProtons = new AliCFDataGrid("correctAntiProtons",
1443                                           "corrected data",
1444                                           *fAntiProtonContainer);
1445   fCorrectAntiProtons->ApplyEffCorrection(*(AliCFEffGrid *)fEffGridListAntiProtons->At(step));
1446 }
1447
1448 //____________________________________________________________________//
1449 Bool_t AliProtonAnalysis::ReadCorrectionContainer(const char* filename) {
1450   // Reads the outout of the correction framework task
1451   // Creates the correction maps
1452   // Puts the results in the different TList objects
1453   Bool_t status = kTRUE;
1454
1455   TFile *file = TFile::Open(filename);
1456   if(!file) {
1457     cout<<"Could not find the input CORRFW file "<<filename<<endl;
1458     status = kFALSE;
1459   }
1460
1461   //________________________________________//
1462   //Protons
1463   fEffGridListProtons = new TList();
1464   fCorrectionListProtons2D = new TList(); 
1465   fEfficiencyListProtons1D = new TList(); 
1466   fCorrectionListProtons1D = new TList();
1467   
1468   AliCFContainer *corrfwContainerProtons = (AliCFContainer*) (file->Get("containerProtons"));
1469   if(!corrfwContainerProtons) {
1470     cout<<"CORRFW container for protons not found!"<<endl;
1471     status = kFALSE;
1472   }
1473   
1474   Int_t nSteps = corrfwContainerProtons->GetNStep();
1475   TH2D *gYPt[4];
1476   //currently the GRID is formed by the y-pT parameters
1477   //Add Vz as a next step
1478   Int_t iRap = 0, iPt = 1;
1479   AliCFEffGrid *effProtonsStep0Step1 = new AliCFEffGrid("eff10",
1480                                          "effProtonsStep0Step1",
1481                                          *corrfwContainerProtons);
1482   effProtonsStep0Step1->CalculateEfficiency(1,0); //eff= step1/step0
1483   fEffGridListProtons->Add(effProtonsStep0Step1);
1484   gYPt[0] = effProtonsStep0Step1->Project(iRap,iPt);
1485   fCorrectionListProtons2D->Add(gYPt[0]);
1486   
1487   AliCFEffGrid *effProtonsStep0Step2 = new AliCFEffGrid("eff20",
1488                                          "effProtonsStep0Step2",
1489                                          *corrfwContainerProtons);
1490   effProtonsStep0Step2->CalculateEfficiency(2,0); //eff= step2/step0
1491   fEffGridListProtons->Add(effProtonsStep0Step2);
1492   gYPt[1] = effProtonsStep0Step2->Project(iRap,iPt);
1493   fCorrectionListProtons2D->Add(gYPt[1]);
1494
1495   AliCFEffGrid *effProtonsStep0Step3 = new AliCFEffGrid("eff30",
1496                                          "effProtonsStep0Step3",
1497                                          *corrfwContainerProtons);
1498   effProtonsStep0Step3->CalculateEfficiency(3,0); //eff= step1/step0
1499   fEffGridListProtons->Add(effProtonsStep0Step3);
1500   gYPt[2] = effProtonsStep0Step3->Project(iRap,iPt);
1501   fCorrectionListProtons2D->Add(gYPt[2]);
1502
1503   TH1D *gEfficiency[2][3]; //efficiency as a function of pT and of y (raws-[2])
1504   TH1D *gCorrection[2][3]; //efficiency as a function of pT and of y (raws-[2])
1505   TString gTitle = 0;
1506   //Get the projection of the efficiency maps
1507   for(Int_t iParameter = 0; iParameter < 2; iParameter++) {
1508     gEfficiency[iParameter][0] = effProtonsStep0Step1->Project(iParameter);
1509     gTitle = "ProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1510     gTitle += "_Step0_Step1"; 
1511     gEfficiency[iParameter][0]->SetName(gTitle.Data());
1512     fEfficiencyListProtons1D->Add(gEfficiency[iParameter][0]);  
1513     gTitle = "ProtonsCorrection_Parameter"; gTitle += iParameter+1;
1514     gTitle += "_Step0_Step1"; 
1515     gCorrection[iParameter][0] = new TH1D(gTitle.Data(),
1516                                           gTitle.Data(),
1517                                           gEfficiency[iParameter][0]->GetNbinsX(),
1518                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmin(),
1519                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmax());
1520     //initialisation of the correction
1521     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][0]->GetNbinsX(); iBin++)
1522       gCorrection[iParameter][0]->SetBinContent(iBin,1.0);
1523
1524     gEfficiency[iParameter][1] = effProtonsStep0Step2->Project(iParameter);
1525     gTitle = "ProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1526     gTitle += "_Step0_Step2"; 
1527     gEfficiency[iParameter][1]->SetName(gTitle.Data());
1528     fEfficiencyListProtons1D->Add(gEfficiency[iParameter][1]);  
1529     gTitle = "ProtonsCorrection_Parameter"; gTitle += iParameter+1;
1530     gTitle += "_Step0_Step2"; 
1531     gCorrection[iParameter][1] = new TH1D(gTitle.Data(),
1532                                           gTitle.Data(),
1533                                           gEfficiency[iParameter][1]->GetNbinsX(),
1534                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmin(),
1535                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmax());
1536     //initialisation of the correction
1537     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][1]->GetNbinsX(); iBin++)
1538       gCorrection[iParameter][1]->SetBinContent(iBin,1.0);
1539
1540     gEfficiency[iParameter][2] = effProtonsStep0Step3->Project(iParameter);
1541     gTitle = "ProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1542     gTitle += "_Step0_Step3"; 
1543     gEfficiency[iParameter][2]->SetName(gTitle.Data());
1544     fEfficiencyListProtons1D->Add(gEfficiency[iParameter][2]);  
1545     gTitle = "ProtonsCorrection_Parameter"; gTitle += iParameter+1;
1546     gTitle += "_Step0_Step3"; 
1547     gCorrection[iParameter][2] = new TH1D(gTitle.Data(),
1548                                           gTitle.Data(),
1549                                           gEfficiency[iParameter][2]->GetNbinsX(),
1550                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmin(),
1551                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmax());
1552     //initialisation of the correction
1553     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][2]->GetNbinsX(); iBin++)
1554       gCorrection[iParameter][2]->SetBinContent(iBin,1.0);
1555   }//parameter loop
1556   //Calculate the 1D correction parameters as a function of y and pT
1557   for(Int_t iParameter = 0; iParameter < 2; iParameter++) { 
1558     for(Int_t iStep = 1; iStep < nSteps; iStep++) { 
1559       gCorrection[iParameter][iStep-1]->Divide(gEfficiency[iParameter][iStep-1]);
1560       fCorrectionListProtons1D->Add(gCorrection[iParameter][iStep-1]);  
1561     }
1562   }
1563
1564   //________________________________________//
1565   //AntiProtons
1566   fEffGridListAntiProtons = new TList();
1567   fCorrectionListAntiProtons2D = new TList(); 
1568   fEfficiencyListAntiProtons1D = new TList(); 
1569   fCorrectionListAntiProtons1D = new TList();
1570   
1571   AliCFContainer *corrfwContainerAntiProtons = (AliCFContainer*) (file->Get("containerAntiProtons"));
1572   if(!corrfwContainerAntiProtons) {
1573     cout<<"CORRFW container for antiprotons not found!"<<endl;
1574     status = kFALSE;
1575   }
1576   
1577   nSteps = corrfwContainerAntiProtons->GetNStep();
1578   //currently the GRID is formed by the y-pT parameters
1579   //Add Vz as a next step
1580   AliCFEffGrid *effAntiProtonsStep0Step1 = new AliCFEffGrid("eff10",
1581                                          "effAntiProtonsStep0Step1",
1582                                          *corrfwContainerAntiProtons);
1583   effAntiProtonsStep0Step1->CalculateEfficiency(1,0); //eff= step1/step0
1584   fEffGridListAntiProtons->Add(effAntiProtonsStep0Step1);
1585   gYPt[0] = effAntiProtonsStep0Step1->Project(iRap,iPt);
1586   fCorrectionListAntiProtons2D->Add(gYPt[0]);
1587   
1588   AliCFEffGrid *effAntiProtonsStep0Step2 = new AliCFEffGrid("eff20",
1589                                          "effAntiProtonsStep0Step2",
1590                                          *corrfwContainerAntiProtons);
1591   effAntiProtonsStep0Step2->CalculateEfficiency(2,0); //eff= step2/step0
1592   fEffGridListAntiProtons->Add(effAntiProtonsStep0Step2);
1593   gYPt[1] = effAntiProtonsStep0Step2->Project(iRap,iPt);
1594   fCorrectionListAntiProtons2D->Add(gYPt[1]);
1595
1596   AliCFEffGrid *effAntiProtonsStep0Step3 = new AliCFEffGrid("eff30",
1597                                          "effAntiProtonsStep0Step3",
1598                                          *corrfwContainerAntiProtons);
1599   effAntiProtonsStep0Step3->CalculateEfficiency(3,0); //eff= step1/step0
1600   fEffGridListAntiProtons->Add(effAntiProtonsStep0Step3);
1601   gYPt[2] = effAntiProtonsStep0Step3->Project(iRap,iPt);
1602   fCorrectionListAntiProtons2D->Add(gYPt[2]);
1603
1604   //Get the projection of the efficiency maps
1605   for(Int_t iParameter = 0; iParameter < 2; iParameter++) {
1606     gEfficiency[iParameter][0] = effAntiProtonsStep0Step1->Project(iParameter);
1607     gTitle = "AntiProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1608     gTitle += "_Step0_Step1"; 
1609     gEfficiency[iParameter][0]->SetName(gTitle.Data());
1610     fEfficiencyListAntiProtons1D->Add(gEfficiency[iParameter][0]);  
1611     gTitle = "AntiProtonsCorrection_Parameter"; gTitle += iParameter+1;
1612     gTitle += "_Step0_Step1"; 
1613     gCorrection[iParameter][0] = new TH1D(gTitle.Data(),
1614                                           gTitle.Data(),
1615                                           gEfficiency[iParameter][0]->GetNbinsX(),
1616                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmin(),
1617                                           gEfficiency[iParameter][0]->GetXaxis()->GetXmax());
1618     //initialisation of the correction
1619     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][0]->GetNbinsX(); iBin++)
1620       gCorrection[iParameter][0]->SetBinContent(iBin,1.0);
1621
1622     gEfficiency[iParameter][1] = effAntiProtonsStep0Step2->Project(iParameter);
1623     gTitle = "AntiProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1624     gTitle += "_Step0_Step2"; 
1625     gEfficiency[iParameter][1]->SetName(gTitle.Data());
1626     fEfficiencyListAntiProtons1D->Add(gEfficiency[iParameter][1]);  
1627     gTitle = "AntiProtonsCorrection_Parameter"; gTitle += iParameter+1;
1628     gTitle += "_Step0_Step2"; 
1629     gCorrection[iParameter][1] = new TH1D(gTitle.Data(),
1630                                           gTitle.Data(),
1631                                           gEfficiency[iParameter][1]->GetNbinsX(),
1632                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmin(),
1633                                           gEfficiency[iParameter][1]->GetXaxis()->GetXmax());
1634     //initialisation of the correction
1635     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][1]->GetNbinsX(); iBin++)
1636       gCorrection[iParameter][1]->SetBinContent(iBin,1.0);
1637
1638     gEfficiency[iParameter][2] = effAntiProtonsStep0Step3->Project(iParameter);
1639     gTitle = "AntiProtonsEfficiency_Parameter"; gTitle += iParameter+1;
1640     gTitle += "_Step0_Step3"; 
1641     gEfficiency[iParameter][2]->SetName(gTitle.Data());
1642     fEfficiencyListAntiProtons1D->Add(gEfficiency[iParameter][2]);  
1643     gTitle = "AntiProtonsCorrection_Parameter"; gTitle += iParameter+1;
1644     gTitle += "_Step0_Step3"; 
1645     gCorrection[iParameter][2] = new TH1D(gTitle.Data(),
1646                                           gTitle.Data(),
1647                                           gEfficiency[iParameter][2]->GetNbinsX(),
1648                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmin(),
1649                                           gEfficiency[iParameter][2]->GetXaxis()->GetXmax());
1650     //initialisation of the correction
1651     for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][2]->GetNbinsX(); iBin++)
1652       gCorrection[iParameter][2]->SetBinContent(iBin,1.0);
1653   }//parameter loop
1654   //Calculate the 1D correction parameters as a function of y and pT
1655   for(Int_t iParameter = 0; iParameter < 2; iParameter++) { 
1656     for(Int_t iStep = 1; iStep < nSteps; iStep++) { 
1657       gCorrection[iParameter][iStep-1]->Divide(gEfficiency[iParameter][iStep-1]);
1658       fCorrectionListAntiProtons1D->Add(gCorrection[iParameter][iStep-1]);  
1659     }
1660   }
1661
1662   return status;
1663 }
1664  
1665 //____________________________________________________________________//
1666 void AliProtonAnalysis::SetQAOn() {
1667   //initializes the QA lists
1668   //fQAHistograms = kTRUE;
1669   fGlobalQAList = new TList();
1670   fQA2DList = new TList();
1671   fQA2DList->SetName("fQA2DList");
1672   fGlobalQAList->Add(fQA2DList);
1673   
1674   fQAPrimaryProtonsAcceptedList = new TList();
1675   fQAPrimaryProtonsAcceptedList->SetName("fQAPrimaryProtonsAcceptedList");
1676   fGlobalQAList->Add(fQAPrimaryProtonsAcceptedList);
1677   
1678   fQAPrimaryProtonsRejectedList = new TList();
1679   fQAPrimaryProtonsRejectedList->SetName("fQAPrimaryProtonsRejectedList");
1680   fGlobalQAList->Add(fQAPrimaryProtonsRejectedList);
1681   
1682   fQASecondaryProtonsAcceptedList = new TList();
1683   fQASecondaryProtonsAcceptedList->SetName("fQASecondaryProtonsAcceptedList");
1684   fGlobalQAList->Add(fQASecondaryProtonsAcceptedList);
1685   
1686   fQASecondaryProtonsRejectedList = new TList();
1687   fQASecondaryProtonsRejectedList->SetName("fQASecondaryProtonsRejectedList");
1688   fGlobalQAList->Add(fQASecondaryProtonsRejectedList);
1689   
1690   fQAPrimaryAntiProtonsAcceptedList = new TList();
1691   fQAPrimaryAntiProtonsAcceptedList->SetName("fQAPrimaryAntiProtonsAcceptedList");
1692   fGlobalQAList->Add(fQAPrimaryAntiProtonsAcceptedList);
1693   
1694   fQAPrimaryAntiProtonsRejectedList = new TList();
1695   fQAPrimaryAntiProtonsRejectedList->SetName("fQAPrimaryAntiProtonsRejectedList");
1696   fGlobalQAList->Add(fQAPrimaryAntiProtonsRejectedList);
1697   
1698   fQASecondaryAntiProtonsAcceptedList = new TList();
1699   fQASecondaryAntiProtonsAcceptedList->SetName("fQASecondaryAntiProtonsAcceptedList");
1700   fGlobalQAList->Add(fQASecondaryAntiProtonsAcceptedList);
1701   
1702   fQASecondaryAntiProtonsRejectedList = new TList();
1703   fQASecondaryAntiProtonsRejectedList->SetName("fQASecondaryAntiProtonsRejectedList");
1704   fGlobalQAList->Add(fQASecondaryAntiProtonsRejectedList);
1705 }
1706
1707 //____________________________________________________________________//
1708 void AliProtonAnalysis::SetQAYPtBins(Int_t nbinsY, Double_t minY, Double_t maxY,
1709                                       Int_t nbinsPt, Double_t minPt, Double_t maxPt) {
1710   //Initializes the QA binning
1711   fNBinsY = nbinsY;
1712   fMinY = minY; fMaxY = maxY;
1713   fNBinsPt = nbinsPt;
1714   fMinPt = minPt; fMaxPt = maxPt;
1715   InitQA();
1716 }
1717
1718 //____________________________________________________________________//
1719 void AliProtonAnalysis::InitQA() {
1720   //Initializes the QA histograms and builds the directory structure
1721   //if(!fQAHistograms) 
1722   SetQAOn();
1723
1724   //2D histograms
1725   //TDirectory *dir2D = gDirectory->mkdir("2D");
1726   //fGlobalQAList->Add(dir2D); dir2D->cd();
1727   TH2D *gHistYPtPrimaryProtonsPass = new TH2D("gHistYPtPrimaryProtonsPass",
1728                                               ";y;P_{T} [GeV/c]",
1729                                               fNBinsY,fMinY,fMaxY,
1730                                               fNBinsPt,fMinPt,fMaxPt);
1731   gHistYPtPrimaryProtonsPass->SetStats(kTRUE);
1732   gHistYPtPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
1733   fQA2DList->Add(gHistYPtPrimaryProtonsPass);
1734   TH2D *gHistYPtPrimaryProtonsReject = new TH2D("gHistYPtPrimaryProtonsReject",
1735                                                 ";y;P_{T} [GeV/c]",
1736                                                 fNBinsY,fMinY,fMaxY,
1737                                                 fNBinsPt,fMinPt,fMaxPt);
1738   gHistYPtPrimaryProtonsReject->SetStats(kTRUE);
1739   gHistYPtPrimaryProtonsReject->GetXaxis()->SetTitleColor(1);
1740   fQA2DList->Add(gHistYPtPrimaryProtonsReject);
1741
1742   TH2D *gHistYPtSecondaryProtonsPass = new TH2D("gHistYPtSecondaryProtonsPass",
1743                                                 ";y;P_{T} [GeV/c]",
1744                                                 fNBinsY,fMinY,fMaxY,
1745                                                 fNBinsPt,fMinPt,fMaxPt);
1746   gHistYPtSecondaryProtonsPass->SetStats(kTRUE);
1747   gHistYPtSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
1748   fQA2DList->Add(gHistYPtSecondaryProtonsPass);
1749   TH2D *gHistYPtSecondaryProtonsReject = new TH2D("gHistYPtSecondaryProtonsReject",
1750                                                   ";y;P_{T} [GeV/c]",
1751                                                   fNBinsY,fMinY,fMaxY,
1752                                                   fNBinsPt,fMinPt,fMaxPt);
1753   gHistYPtSecondaryProtonsReject->SetStats(kTRUE);
1754   gHistYPtSecondaryProtonsReject->GetXaxis()->SetTitleColor(1);
1755   fQA2DList->Add(gHistYPtSecondaryProtonsReject);
1756
1757   TH2D *gHistYPtPrimaryAntiProtonsPass = new TH2D("gHistYPtPrimaryAntiProtonsPass",
1758                                                   ";y;P_{T} [GeV/c]",
1759                                                   fNBinsY,fMinY,fMaxY,
1760                                                   fNBinsPt,fMinPt,fMaxPt);
1761   gHistYPtPrimaryAntiProtonsPass->SetStats(kTRUE);
1762   gHistYPtPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
1763   fQA2DList->Add(gHistYPtPrimaryAntiProtonsPass);
1764   TH2D *gHistYPtPrimaryAntiProtonsReject = new TH2D("gHistYPtPrimaryAntiProtonsReject",
1765                                                   ";y;P_{T} [GeV/c]",
1766                                                   fNBinsY,fMinY,fMaxY,
1767                                                   fNBinsPt,fMinPt,fMaxPt);
1768   gHistYPtPrimaryAntiProtonsReject->SetStats(kTRUE);
1769   gHistYPtPrimaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
1770   fQA2DList->Add(gHistYPtPrimaryAntiProtonsReject);
1771
1772   TH2D *gHistYPtSecondaryAntiProtonsPass = new TH2D("gHistYPtSecondaryAntiProtonsPass",
1773                                                   ";y;P_{T} [GeV/c]",
1774                                                   fNBinsY,fMinY,fMaxY,
1775                                                   fNBinsPt,fMinPt,fMaxPt);
1776   gHistYPtSecondaryAntiProtonsPass->SetStats(kTRUE);
1777   gHistYPtSecondaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
1778   fQA2DList->Add(gHistYPtSecondaryAntiProtonsPass);
1779   TH2D *gHistYPtSecondaryAntiProtonsReject = new TH2D("gHistYPtSecondaryAntiProtonsReject",
1780                                                   ";y;P_{T} [GeV/c]",
1781                                                   fNBinsY,fMinY,fMaxY,
1782                                                   fNBinsPt,fMinPt,fMaxPt);
1783   gHistYPtSecondaryAntiProtonsReject->SetStats(kTRUE);
1784   gHistYPtSecondaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
1785   fQA2DList->Add(gHistYPtSecondaryAntiProtonsReject);
1786
1787   /*gDirectory->cd("../");
1788   //protons
1789   TDirectory *dirProtons = gDirectory->mkdir("Protons");
1790   fGlobalQAList->Add(dirProtons); dirProtons->cd();*/
1791   
1792   //________________________________________________________________//
1793   /*TDirectory *dirProtonsPrimary = gDirectory->mkdir("Primaries");
1794   dirProtonsPrimary->cd();
1795   TDirectory *dirProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
1796   dirProtonsPrimaryAccepted->cd();*/
1797
1798   //Accepted primary protons
1799   TH1F *fPrimaryProtonsITSClustersPass = new TH1F("fPrimaryProtonsITSClustersPass",
1800                                             ";N_{clusters} (ITS);Entries",
1801                                             7,0,7);
1802   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsITSClustersPass);
1803   TH1F *fPrimaryProtonsChi2PerClusterITSPass = new TH1F("fPrimaryProtonsChi2PerClusterITSPass",
1804                                                   ";x^{2}/N_{clusters} (ITS);Entries",
1805                                                   100,0,4);
1806   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsChi2PerClusterITSPass);
1807   TH1F *fPrimaryProtonsTPCClustersPass = new TH1F("fPrimaryProtonsTPCClustersPass",
1808                                             ";N_{clusters} (TPC);Entries",
1809                                             100,0,200);
1810   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsTPCClustersPass);
1811   TH1F *fPrimaryProtonsChi2PerClusterTPCPass = new TH1F("fPrimaryProtonsChi2PerClusterTPCPass",
1812                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1813                                                   100,0,4);
1814   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsChi2PerClusterTPCPass);
1815   TH1F *fPrimaryProtonsExtCov11Pass = new TH1F("fPrimaryProtonsExtCov11Pass",
1816                                          ";#sigma_{y} [cm];Entries",
1817                                          100,0,4);
1818   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov11Pass);
1819   TH1F *fPrimaryProtonsExtCov22Pass = new TH1F("fPrimaryProtonsExtCov22Pass",
1820                                          ";#sigma_{z} [cm];Entries",
1821                                          100,0,4);
1822   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov22Pass);
1823   TH1F *fPrimaryProtonsExtCov33Pass = new TH1F("fPrimaryProtonsExtCov33Pass",
1824                                          ";#sigma_{sin(#phi)};Entries",
1825                                          100,0,4);
1826   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov33Pass);
1827   TH1F *fPrimaryProtonsExtCov44Pass = new TH1F("fPrimaryProtonsExtCov44Pass",
1828                                          ";#sigma_{tan(#lambda)};Entries",
1829                                          100,0,4);
1830   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov44Pass);
1831   TH1F *fPrimaryProtonsExtCov55Pass = new TH1F("fPrimaryProtonsExtCov55Pass",
1832                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1833                                          100,0,4);
1834   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov55Pass);
1835   TH1F *fPrimaryProtonsSigmaToVertexPass = new TH1F("fPrimaryProtonsSigmaToVertexPass",
1836                                              ";#sigma_{Vertex};Entries",
1837                                              100,0,10);
1838   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsSigmaToVertexPass);
1839   TH1F *fPrimaryProtonsSigmaToVertexTPCPass = new TH1F("fPrimaryProtonsSigmaToVertexTPCPass",
1840                                              ";#sigma_{Vertex};Entries",
1841                                              100,0,10);
1842   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsSigmaToVertexTPCPass);
1843   TH1F *fPrimaryProtonsITSRefitPass = new TH1F("fPrimaryProtonsITSRefitPass",
1844                                          "",10,-1,1);
1845   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsITSRefitPass);
1846   TH1F *fPrimaryProtonsTPCRefitPass = new TH1F("fPrimaryProtonsTPCRefitPass",
1847                                          "",10,-1,1);
1848   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsTPCRefitPass);
1849   TH1F *fPrimaryProtonsESDpidPass = new TH1F("fPrimaryProtonsESDpidPass",
1850                                        "",10,-1,1);
1851   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsESDpidPass);
1852   TH1F *fPrimaryProtonsTPCpidPass = new TH1F("fPrimaryProtonsTPCpidPass",
1853                                        "",10,-1,1);
1854   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsTPCpidPass);
1855
1856   //Rejected primary protons
1857   /*gDirectory->cd("../");
1858   TDirectory *dirProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
1859   dirProtonsPrimaryRejected->cd();*/
1860
1861   TH1F *fPrimaryProtonsITSClustersReject = new TH1F("fPrimaryProtonsITSClustersReject",
1862                                                     ";N_{clusters} (ITS);Entries",
1863                                                     7,0,7);
1864   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsITSClustersReject);
1865   TH1F *fPrimaryProtonsChi2PerClusterITSReject = new TH1F("fPrimaryProtonsChi2PerClusterITSReject",
1866                                                           ";x^{2}/N_{clusters} (ITS);Entries",
1867                                                           100,0,4);
1868   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsChi2PerClusterITSReject);
1869   TH1F *fPrimaryProtonsTPCClustersReject = new TH1F("fPrimaryProtonsTPCClustersReject",
1870                                             ";N_{clusters} (TPC);Entries",
1871                                             100,0,200);
1872   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsTPCClustersReject);
1873   TH1F *fPrimaryProtonsChi2PerClusterTPCReject = new TH1F("fPrimaryProtonsChi2PerClusterTPCReject",
1874                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1875                                                   100,0,4);
1876   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsChi2PerClusterTPCReject);
1877   TH1F *fPrimaryProtonsExtCov11Reject = new TH1F("fPrimaryProtonsExtCov11Reject",
1878                                          ";#sigma_{y} [cm];Entries",
1879                                          100,0,4);
1880   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov11Reject);
1881   TH1F *fPrimaryProtonsExtCov22Reject = new TH1F("fPrimaryProtonsExtCov22Reject",
1882                                          ";#sigma_{z} [cm];Entries",
1883                                          100,0,4);
1884   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov22Reject);
1885   TH1F *fPrimaryProtonsExtCov33Reject = new TH1F("fPrimaryProtonsExtCov33Reject",
1886                                          ";#sigma_{sin(#phi)};Entries",
1887                                          100,0,4);
1888   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov33Reject);
1889   TH1F *fPrimaryProtonsExtCov44Reject = new TH1F("fPrimaryProtonsExtCov44Reject",
1890                                          ";#sigma_{tan(#lambda)};Entries",
1891                                          100,0,4);
1892   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov44Reject);
1893   TH1F *fPrimaryProtonsExtCov55Reject = new TH1F("fPrimaryProtonsExtCov55Reject",
1894                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1895                                          100,0,4);
1896   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov55Reject);
1897   TH1F *fPrimaryProtonsSigmaToVertexReject = new TH1F("fPrimaryProtonsSigmaToVertexReject",
1898                                              ";#sigma_{Vertex};Entries",
1899                                              100,0,10);
1900   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsSigmaToVertexReject);
1901   TH1F *fPrimaryProtonsSigmaToVertexTPCReject = new TH1F("fPrimaryProtonsSigmaToVertexTPCReject",
1902                                              ";#sigma_{Vertex};Entries",
1903                                              100,0,10);
1904   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsSigmaToVertexTPCReject);
1905   TH1F *fPrimaryProtonsITSRefitReject = new TH1F("fPrimaryProtonsITSRefitReject",
1906                                          "",10,-1,1);
1907   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsITSRefitReject);
1908   TH1F *fPrimaryProtonsTPCRefitReject = new TH1F("fPrimaryProtonsTPCRefitReject",
1909                                          "",10,-1,1);
1910   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsTPCRefitReject);
1911   TH1F *fPrimaryProtonsESDpidReject = new TH1F("fPrimaryProtonsESDpidReject",
1912                                        "",10,-1,1);
1913   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsESDpidReject);
1914   TH1F *fPrimaryProtonsTPCpidReject = new TH1F("fPrimaryProtonsTPCpidReject",
1915                                        "",10,-1,1);
1916   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsTPCpidReject);
1917
1918   //________________________________________________________________//
1919   /*gDirectory->cd("../../");
1920
1921   TDirectory *dirProtonsSecondary = gDirectory->mkdir("Secondaries");
1922   dirProtonsSecondary->cd();
1923   TDirectory *dirProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
1924   dirProtonsSecondaryAccepted->cd();*/
1925
1926   //Accepted secondary protons
1927   TH1F *fSecondaryProtonsITSClustersPass = new TH1F("fSecondaryProtonsITSClustersPass",
1928                                                     ";N_{clusters} (ITS);Entries",
1929                                                     7,0,7);
1930   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsITSClustersPass);
1931   TH1F *fSecondaryProtonsChi2PerClusterITSPass = new TH1F("fSecondaryProtonsChi2PerClusterITSPass",
1932                                                           ";x^{2}/N_{clusters} (ITS);Entries",
1933                                                           100,0,4);
1934   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsChi2PerClusterITSPass);
1935   TH1F *fSecondaryProtonsTPCClustersPass = new TH1F("fSecondaryProtonsTPCClustersPass",
1936                                             ";N_{clusters} (TPC);Entries",
1937                                             100,0,200);
1938   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsTPCClustersPass);
1939   TH1F *fSecondaryProtonsChi2PerClusterTPCPass = new TH1F("fSecondaryProtonsChi2PerClusterTPCPass",
1940                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1941                                                   100,0,4);
1942   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsChi2PerClusterTPCPass);
1943   TH1F *fSecondaryProtonsExtCov11Pass = new TH1F("fSecondaryProtonsExtCov11Pass",
1944                                          ";#sigma_{y} [cm];Entries",
1945                                          100,0,4);
1946   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov11Pass);
1947   TH1F *fSecondaryProtonsExtCov22Pass = new TH1F("fSecondaryProtonsExtCov22Pass",
1948                                          ";#sigma_{z} [cm];Entries",
1949                                          100,0,4);
1950   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov22Pass);
1951   TH1F *fSecondaryProtonsExtCov33Pass = new TH1F("fSecondaryProtonsExtCov33Pass",
1952                                          ";#sigma_{sin(#phi)};Entries",
1953                                          100,0,4);
1954   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov33Pass);
1955   TH1F *fSecondaryProtonsExtCov44Pass = new TH1F("fSecondaryProtonsExtCov44Pass",
1956                                          ";#sigma_{tan(#lambda)};Entries",
1957                                          100,0,4);
1958   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov44Pass);
1959   TH1F *fSecondaryProtonsExtCov55Pass = new TH1F("fSecondaryProtonsExtCov55Pass",
1960                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1961                                          100,0,4);
1962   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov55Pass);
1963   TH1F *fSecondaryProtonsSigmaToVertexPass = new TH1F("fSecondaryProtonsSigmaToVertexPass",
1964                                              ";#sigma_{Vertex};Entries",
1965                                              100,0,10);
1966   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsSigmaToVertexPass);
1967   TH1F *fSecondaryProtonsSigmaToVertexTPCPass = new TH1F("fSecondaryProtonsSigmaToVertexTPCPass",
1968                                              ";#sigma_{Vertex};Entries",
1969                                              100,0,10);
1970   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsSigmaToVertexTPCPass);
1971   TH1F *fSecondaryProtonsITSRefitPass = new TH1F("fSecondaryProtonsITSRefitPass",
1972                                          "",10,-1,1);
1973   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsITSRefitPass);
1974   TH1F *fSecondaryProtonsTPCRefitPass = new TH1F("fSecondaryProtonsTPCRefitPass",
1975                                          "",10,-1,1);
1976   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsTPCRefitPass);
1977   TH1F *fSecondaryProtonsESDpidPass = new TH1F("fSecondaryProtonsESDpidPass",
1978                                        "",10,-1,1);
1979   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsESDpidPass);
1980   TH1F *fSecondaryProtonsTPCpidPass = new TH1F("fSecondaryProtonsTPCpidPass",
1981                                        "",10,-1,1);
1982   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsTPCpidPass);
1983
1984   //Rejected secondary protons
1985   /*gDirectory->cd("../");
1986   TDirectory *dirProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
1987   dirProtonsSecondaryRejected->cd();*/
1988
1989   TH1F *fSecondaryProtonsITSClustersReject = new TH1F("fSecondaryProtonsITSClustersReject",
1990                                                       ";N_{clusters} (ITS);Entries",
1991                                                       7,0,7);
1992   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsITSClustersReject);
1993   TH1F *fSecondaryProtonsChi2PerClusterITSReject = new TH1F("fSecondaryProtonsChi2PerClusterITSReject",
1994                                                             ";x^{2}/N_{clusters} (ITS);Entries",
1995                                                             100,0,4);
1996   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsChi2PerClusterITSReject);
1997   TH1F *fSecondaryProtonsTPCClustersReject = new TH1F("fSecondaryProtonsTPCClustersReject",
1998                                             ";N_{clusters} (TPC);Entries",
1999                                             100,0,200);
2000   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsTPCClustersReject);
2001   TH1F *fSecondaryProtonsChi2PerClusterTPCReject = new TH1F("fSecondaryProtonsChi2PerClusterTPCReject",
2002                                                   ";x^{2}/N_{clusters} (TPC);Entries",
2003                                                   100,0,4);
2004   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsChi2PerClusterTPCReject);
2005   TH1F *fSecondaryProtonsExtCov11Reject = new TH1F("fSecondaryProtonsExtCov11Reject",
2006                                          ";#sigma_{y} [cm];Entries",
2007                                          100,0,4);
2008   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov11Reject);
2009   TH1F *fSecondaryProtonsExtCov22Reject = new TH1F("fSecondaryProtonsExtCov22Reject",
2010                                          ";#sigma_{z} [cm];Entries",
2011                                          100,0,4);
2012   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov22Reject);
2013   TH1F *fSecondaryProtonsExtCov33Reject = new TH1F("fSecondaryProtonsExtCov33Reject",
2014                                          ";#sigma_{sin(#phi)};Entries",
2015                                          100,0,4);
2016   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov33Reject);
2017   TH1F *fSecondaryProtonsExtCov44Reject = new TH1F("fSecondaryProtonsExtCov44Reject",
2018                                          ";#sigma_{tan(#lambda)};Entries",
2019                                          100,0,4);
2020   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov44Reject);
2021   TH1F *fSecondaryProtonsExtCov55Reject = new TH1F("fSecondaryProtonsExtCov55Reject",
2022                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2023                                          100,0,4);
2024   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov55Reject);
2025   TH1F *fSecondaryProtonsSigmaToVertexReject = new TH1F("fSecondaryProtonsSigmaToVertexReject",
2026                                              ";#sigma_{Vertex};Entries",
2027                                              100,0,10);
2028   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsSigmaToVertexReject);
2029   TH1F *fSecondaryProtonsSigmaToVertexTPCReject = new TH1F("fSecondaryProtonsSigmaToVertexTPCReject",
2030                                              ";#sigma_{Vertex};Entries",
2031                                              100,0,10);
2032   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsSigmaToVertexTPCReject);
2033   TH1F *fSecondaryProtonsITSRefitReject = new TH1F("fSecondaryProtonsITSRefitReject",
2034                                          "",10,-1,1);
2035   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsITSRefitReject);
2036   TH1F *fSecondaryProtonsTPCRefitReject = new TH1F("fSecondaryProtonsTPCRefitReject",
2037                                          "",10,-1,1);
2038   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsTPCRefitReject);
2039   TH1F *fSecondaryProtonsESDpidReject = new TH1F("fSecondaryProtonsESDpidReject",
2040                                        "",10,-1,1);
2041   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsESDpidReject);
2042   TH1F *fSecondaryProtonsTPCpidReject = new TH1F("fSecondaryProtonsTPCpidReject",
2043                                        "",10,-1,1);
2044   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsTPCpidReject);
2045
2046
2047   /*gDirectory->cd("../../../");
2048
2049   //antiprotons
2050   TDirectory *dirAntiProtons = gDirectory->mkdir("AntiProtons");
2051   fGlobalQAList->Add(dirAntiProtons); dirAntiProtons->cd();*/
2052   
2053   //________________________________________________________________//
2054   /*TDirectory *dirAntiProtonsPrimary = gDirectory->mkdir("Primaries");
2055   dirAntiProtonsPrimary->cd();
2056   TDirectory *dirAntiProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
2057   dirAntiProtonsPrimaryAccepted->cd();*/
2058   
2059   //Accepted primary antiprotons
2060   TH1F *fPrimaryAntiProtonsITSClustersPass = new TH1F("fPrimaryAntiProtonsITSClustersPass",
2061                                                       ";N_{clusters} (ITS);Entries",
2062                                                       7,0,7);
2063   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsITSClustersPass);
2064   TH1F *fPrimaryAntiProtonsChi2PerClusterITSPass = new TH1F("fPrimaryAntiProtonsChi2PerClusterITSPass",
2065                                                             ";x^{2}/N_{clusters} (ITS);Entries",
2066                                                             100,0,4);
2067   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsChi2PerClusterITSPass);
2068   TH1F *fPrimaryAntiProtonsTPCClustersPass = new TH1F("fPrimaryAntiProtonsTPCClustersPass",
2069                                                       ";N_{clusters} (TPC);Entries",
2070                                                       100,0,200);
2071   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsTPCClustersPass);
2072   TH1F *fPrimaryAntiProtonsChi2PerClusterTPCPass = new TH1F("fPrimaryAntiProtonsChi2PerClusterTPCPass",
2073                                                             ";x^{2}/N_{clusters} (TPC);Entries",
2074                                                             100,0,4);
2075   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsChi2PerClusterTPCPass);
2076   TH1F *fPrimaryAntiProtonsExtCov11Pass = new TH1F("fPrimaryAntiProtonsExtCov11Pass",
2077                                                    ";#sigma_{y} [cm];Entries",
2078                                                    100,0,4);
2079   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov11Pass);
2080   TH1F *fPrimaryAntiProtonsExtCov22Pass = new TH1F("fPrimaryAntiProtonsExtCov22Pass",
2081                                                    ";#sigma_{z} [cm];Entries",
2082                                                    100,0,4);
2083   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov22Pass);
2084   TH1F *fPrimaryAntiProtonsExtCov33Pass = new TH1F("fPrimaryAntiProtonsExtCov33Pass",
2085                                                    ";#sigma_{sin(#phi)};Entries",
2086                                                    100,0,4);
2087   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov33Pass);
2088   TH1F *fPrimaryAntiProtonsExtCov44Pass = new TH1F("fPrimaryAntiProtonsExtCov44Pass",
2089                                                    ";#sigma_{tan(#lambda)};Entries",
2090                                                    100,0,4);
2091   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov44Pass);
2092   TH1F *fPrimaryAntiProtonsExtCov55Pass = new TH1F("fPrimaryAntiProtonsExtCov55Pass",
2093                                                    ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2094                                                    100,0,4);
2095   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov55Pass);
2096   TH1F *fPrimaryAntiProtonsSigmaToVertexPass = new TH1F("fPrimaryAntiProtonsSigmaToVertexPass",
2097                                                         ";#sigma_{Vertex};Entries",
2098                                                         100,0,10);
2099   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsSigmaToVertexPass);
2100   TH1F *fPrimaryAntiProtonsSigmaToVertexTPCPass = new TH1F("fPrimaryAntiProtonsSigmaToVertexTPCPass",
2101                                                            ";#sigma_{Vertex};Entries",
2102                                                            100,0,10);
2103   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsSigmaToVertexTPCPass);
2104   TH1F *fPrimaryAntiProtonsITSRefitPass = new TH1F("fPrimaryAntiProtonsITSRefitPass",
2105                                                    "",10,-1,1);
2106   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsITSRefitPass);
2107   TH1F *fPrimaryAntiProtonsTPCRefitPass = new TH1F("fPrimaryAntiProtonsTPCRefitPass",
2108                                                    "",10,-1,1);
2109   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsTPCRefitPass);
2110   TH1F *fPrimaryAntiProtonsESDpidPass = new TH1F("fPrimaryAntiProtonsESDpidPass",
2111                                                  "",10,-1,1);
2112   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsESDpidPass);
2113   TH1F *fPrimaryAntiProtonsTPCpidPass = new TH1F("fPrimaryAntiProtonsTPCpidPass",
2114                                                  "",10,-1,1);
2115   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsTPCpidPass);
2116   
2117   //Rejected primary antiprotons
2118   /*gDirectory->cd("../");
2119   TDirectory *dirAntiProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
2120   dirAntiProtonsPrimaryRejected->cd();*/
2121   
2122   TH1F *fPrimaryAntiProtonsITSClustersReject = new TH1F("fPrimaryAntiProtonsITSClustersReject",
2123                                                         ";N_{clusters} (ITS);Entries",
2124                                                         7,0,7);
2125   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsITSClustersReject);
2126   TH1F *fPrimaryAntiProtonsChi2PerClusterITSReject = new TH1F("fPrimaryAntiProtonsChi2PerClusterITSReject",
2127                                                               ";x^{2}/N_{clusters} (ITS);Entries",
2128                                                               100,0,4);
2129   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsChi2PerClusterITSReject);
2130   TH1F *fPrimaryAntiProtonsTPCClustersReject = new TH1F("fPrimaryAntiProtonsTPCClustersReject",
2131                                                         ";N_{clusters} (TPC);Entries",
2132                                                         100,0,200);
2133   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsTPCClustersReject);
2134   TH1F *fPrimaryAntiProtonsChi2PerClusterTPCReject = new TH1F("fPrimaryAntiProtonsChi2PerClusterTPCReject",
2135                                                               ";x^{2}/N_{clusters} (TPC);Entries",
2136                                                               100,0,4);
2137   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsChi2PerClusterTPCReject);
2138   TH1F *fPrimaryAntiProtonsExtCov11Reject = new TH1F("fPrimaryAntiProtonsExtCov11Reject",
2139                                                      ";#sigma_{y} [cm];Entries",
2140                                                      100,0,4);
2141   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov11Reject);
2142   TH1F *fPrimaryAntiProtonsExtCov22Reject = new TH1F("fPrimaryAntiProtonsExtCov22Reject",
2143                                                      ";#sigma_{z} [cm];Entries",
2144                                                      100,0,4);
2145   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov22Reject);
2146   TH1F *fPrimaryAntiProtonsExtCov33Reject = new TH1F("fPrimaryAntiProtonsExtCov33Reject",
2147                                                      ";#sigma_{sin(#phi)};Entries",
2148                                                      100,0,4);
2149   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov33Reject);
2150   TH1F *fPrimaryAntiProtonsExtCov44Reject = new TH1F("fPrimaryAntiProtonsExtCov44Reject",
2151                                                      ";#sigma_{tan(#lambda)};Entries",
2152                                                      100,0,4);
2153   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov44Reject);
2154   TH1F *fPrimaryAntiProtonsExtCov55Reject = new TH1F("fPrimaryAntiProtonsExtCov55Reject",
2155                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2156                                                      100,0,4);
2157   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov55Reject);
2158   TH1F *fPrimaryAntiProtonsSigmaToVertexReject = new TH1F("fPrimaryAntiProtonsSigmaToVertexReject",
2159                                                           ";#sigma_{Vertex};Entries",
2160                                                           100,0,10);
2161   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsSigmaToVertexReject);
2162   TH1F *fPrimaryAntiProtonsSigmaToVertexTPCReject = new TH1F("fPrimaryAntiProtonsSigmaToVertexTPCReject",
2163                                                              ";#sigma_{Vertex};Entries",
2164                                                              100,0,10);
2165   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsSigmaToVertexTPCReject);
2166   TH1F *fPrimaryAntiProtonsITSRefitReject = new TH1F("fPrimaryAntiProtonsITSRefitReject",
2167                                                      "",10,-1,1);
2168   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsITSRefitReject);
2169   TH1F *fPrimaryAntiProtonsTPCRefitReject = new TH1F("fPrimaryAntiProtonsTPCRefitReject",
2170                                                      "",10,-1,1);
2171   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsTPCRefitReject);
2172   TH1F *fPrimaryAntiProtonsESDpidReject = new TH1F("fPrimaryAntiProtonsESDpidReject",
2173                                                    "",10,-1,1);
2174   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsESDpidReject);
2175   TH1F *fPrimaryAntiProtonsTPCpidReject = new TH1F("fPrimaryAntiProtonsTPCpidReject",
2176                                                    "",10,-1,1);
2177   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsTPCpidReject);
2178   
2179   //________________________________________________________________//
2180   /*gDirectory->cd("../../");
2181
2182   TDirectory *dirAntiProtonsSecondary = gDirectory->mkdir("Secondaries");
2183   dirAntiProtonsSecondary->cd();
2184   TDirectory *dirAntiProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
2185   dirAntiProtonsSecondaryAccepted->cd();*/
2186
2187   //Accepted secondary antiprotons
2188   TH1F *fSecondaryAntiProtonsITSClustersPass = new TH1F("fSecondaryAntiProtonsITSClustersPass",
2189                                                         ";N_{clusters} (ITS);Entries",
2190                                                         7,0,7);
2191   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsITSClustersPass);
2192   TH1F *fSecondaryAntiProtonsChi2PerClusterITSPass = new TH1F("fSecondaryAntiProtonsChi2PerClusterITSPass",
2193                                                               ";x^{2}/N_{clusters} (ITS);Entries",
2194                                                               100,0,4);
2195   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsChi2PerClusterITSPass);
2196   TH1F *fSecondaryAntiProtonsTPCClustersPass = new TH1F("fSecondaryAntiProtonsTPCClustersPass",
2197                                                         ";N_{clusters} (TPC);Entries",
2198                                                         100,0,200);
2199   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsTPCClustersPass);
2200   TH1F *fSecondaryAntiProtonsChi2PerClusterTPCPass = new TH1F("fSecondaryAntiProtonsChi2PerClusterTPCPass",
2201                                                               ";x^{2}/N_{clusters} (TPC);Entries",
2202                                                               100,0,4);
2203   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsChi2PerClusterTPCPass);
2204   TH1F *fSecondaryAntiProtonsExtCov11Pass = new TH1F("fSecondaryAntiProtonsExtCov11Pass",
2205                                                      ";#sigma_{y} [cm];Entries",
2206                                                      100,0,4);
2207   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov11Pass);
2208   TH1F *fSecondaryAntiProtonsExtCov22Pass = new TH1F("fSecondaryAntiProtonsExtCov22Pass",
2209                                                      ";#sigma_{z} [cm];Entries",
2210                                                      100,0,4);
2211   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov22Pass);
2212   TH1F *fSecondaryAntiProtonsExtCov33Pass = new TH1F("fSecondaryAntiProtonsExtCov33Pass",
2213                                                      ";#sigma_{sin(#phi)};Entries",
2214                                                      100,0,4);
2215   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov33Pass);
2216   TH1F *fSecondaryAntiProtonsExtCov44Pass = new TH1F("fSecondaryAntiProtonsExtCov44Pass",
2217                                                      ";#sigma_{tan(#lambda)};Entries",
2218                                                      100,0,4);
2219   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov44Pass);
2220   TH1F *fSecondaryAntiProtonsExtCov55Pass = new TH1F("fSecondaryAntiProtonsExtCov55Pass",
2221                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2222                                                      100,0,4);
2223   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov55Pass);
2224   TH1F *fSecondaryAntiProtonsSigmaToVertexPass = new TH1F("fSecondaryAntiProtonsSigmaToVertexPass",
2225                                                           ";#sigma_{Vertex};Entries",
2226                                                           100,0,10);
2227   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsSigmaToVertexPass);
2228   TH1F *fSecondaryAntiProtonsSigmaToVertexTPCPass = new TH1F("fSecondaryAntiProtonsSigmaToVertexTPCPass",
2229                                                              ";#sigma_{Vertex};Entries",
2230                                                              100,0,10);
2231   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsSigmaToVertexTPCPass);
2232   TH1F *fSecondaryAntiProtonsITSRefitPass = new TH1F("fSecondaryAntiProtonsITSRefitPass",
2233                                                      "",10,-1,1);
2234   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsITSRefitPass);
2235   TH1F *fSecondaryAntiProtonsTPCRefitPass = new TH1F("fSecondaryAntiProtonsTPCRefitPass",
2236                                                      "",10,-1,1);
2237   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsTPCRefitPass);
2238   TH1F *fSecondaryAntiProtonsESDpidPass = new TH1F("fSecondaryAntiProtonsESDpidPass",
2239                                                    "",10,-1,1);
2240   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsESDpidPass);
2241   TH1F *fSecondaryAntiProtonsTPCpidPass = new TH1F("fSecondaryAntiProtonsTPCpidPass",
2242                                                    "",10,-1,1);
2243   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsTPCpidPass);
2244   
2245   //Rejected secondary antiprotons
2246   /*gDirectory->cd("../");
2247   TDirectory *dirAntiProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
2248   dirAntiProtonsSecondaryRejected->cd();*/
2249
2250   TH1F *fSecondaryAntiProtonsITSClustersReject = new TH1F("fSecondaryAntiProtonsITSClustersReject",
2251                                                           ";N_{clusters} (ITS);Entries",
2252                                                           7,0,7);
2253   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsITSClustersReject);
2254   TH1F *fSecondaryAntiProtonsChi2PerClusterITSReject = new TH1F("fSecondaryAntiProtonsChi2PerClusterITSReject",
2255                                                                 ";x^{2}/N_{clusters} (ITS);Entries",
2256                                                                 100,0,4);
2257   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsChi2PerClusterITSReject);
2258   TH1F *fSecondaryAntiProtonsTPCClustersReject = new TH1F("fSecondaryAntiProtonsTPCClustersReject",
2259                                                           ";N_{clusters} (TPC);Entries",
2260                                                           100,0,200);
2261   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsTPCClustersReject);
2262   TH1F *fSecondaryAntiProtonsChi2PerClusterTPCReject = new TH1F("fSecondaryAntiProtonsChi2PerClusterTPCReject",
2263                                                                 ";x^{2}/N_{clusters} (TPC);Entries",
2264                                                                 100,0,4);
2265   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsChi2PerClusterTPCReject);
2266   TH1F *fSecondaryAntiProtonsExtCov11Reject = new TH1F("fSecondaryAntiProtonsExtCov11Reject",
2267                                                        ";#sigma_{y} [cm];Entries",
2268                                                        100,0,4);
2269   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov11Reject);
2270   TH1F *fSecondaryAntiProtonsExtCov22Reject = new TH1F("fSecondaryAntiProtonsExtCov22Reject",
2271                                                        ";#sigma_{z} [cm];Entries",
2272                                                        100,0,4);
2273   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov22Reject);
2274   TH1F *fSecondaryAntiProtonsExtCov33Reject = new TH1F("fSecondaryAntiProtonsExtCov33Reject",
2275                                                        ";#sigma_{sin(#phi)};Entries",
2276                                                        100,0,4);
2277   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov33Reject);
2278   TH1F *fSecondaryAntiProtonsExtCov44Reject = new TH1F("fSecondaryAntiProtonsExtCov44Reject",
2279                                                        ";#sigma_{tan(#lambda)};Entries",
2280                                                        100,0,4);
2281   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov44Reject);
2282   TH1F *fSecondaryAntiProtonsExtCov55Reject = new TH1F("fSecondaryAntiProtonsExtCov55Reject",
2283                                                        ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2284                                                        100,0,4);
2285   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov55Reject);
2286   TH1F *fSecondaryAntiProtonsSigmaToVertexReject = new TH1F("fSecondaryAntiProtonsSigmaToVertexReject",
2287                                                             ";#sigma_{Vertex};Entries",
2288                                                             100,0,10);
2289   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsSigmaToVertexReject);
2290   TH1F *fSecondaryAntiProtonsSigmaToVertexTPCReject = new TH1F("fSecondaryAntiProtonsSigmaToVertexTPCReject",
2291                                                                ";#sigma_{Vertex};Entries",
2292                                                                100,0,10);
2293   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsSigmaToVertexTPCReject);
2294   TH1F *fSecondaryAntiProtonsITSRefitReject = new TH1F("fSecondaryAntiProtonsITSRefitReject",
2295                                                        "",10,-1,1);
2296   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsITSRefitReject);
2297   TH1F *fSecondaryAntiProtonsTPCRefitReject = new TH1F("fSecondaryAntiProtonsTPCRefitReject",
2298                                                        "",10,-1,1);
2299   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsTPCRefitReject);
2300   TH1F *fSecondaryAntiProtonsESDpidReject = new TH1F("fSecondaryAntiProtonsESDpidReject",
2301                                                      "",10,-1,1);
2302   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsESDpidReject);
2303   TH1F *fSecondaryAntiProtonsTPCpidReject = new TH1F("fSecondaryAntiProtonsTPCpidReject",
2304                                                      "",10,-1,1);
2305   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsTPCpidReject);
2306   
2307 }
2308
2309 //____________________________________________________________________//
2310 void AliProtonAnalysis::RunQA(AliStack *stack, AliESDEvent *fESD) {
2311   //Runs the QA code
2312   Int_t nGoodTracks = fESD->GetNumberOfTracks();
2313   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
2314     AliESDtrack* track = fESD->GetTrack(iTracks);
2315     Int_t label = TMath::Abs(track->GetLabel()); 
2316     Double_t Pt = 0.0, P = 0.0;
2317     Double_t probability[5];
2318
2319     if(fUseTPCOnly) {
2320       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
2321       if(!tpcTrack) continue;
2322       Pt = tpcTrack->Pt();
2323       P = tpcTrack->P();
2324       
2325       //pid
2326       track->GetTPCpid(probability);
2327       Double_t rcc = 0.0;
2328       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
2329         rcc += probability[i]*GetParticleFraction(i,P);
2330       if(rcc == 0.0) continue;
2331       Double_t w[5];
2332       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
2333         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
2334       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
2335       if(fParticleType == 4) {
2336         FillQA(track, stack);
2337         if(IsAccepted(track)) {
2338           if(label <= stack->GetNprimary()) {
2339             if(track->Charge() > 0)
2340               ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),
2341                                                           track->Py(),
2342                                                           track->Pz()),
2343                                                  Pt);
2344             else if(track->Charge() < 0)
2345               ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(track->Px(),
2346                                                           track->Py(),
2347                                                           track->Pz()),
2348                                                  Pt);
2349           }//primary particles
2350           else if(label > stack->GetNprimary()) {
2351             if(track->Charge() > 0)
2352               ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),
2353                                                           track->Py(),
2354                                                           track->Pz()),
2355                                                  Pt);
2356             else if(track->Charge() < 0)
2357               ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(track->Px(),
2358                                                           track->Py(),
2359                                                           track->Pz()),
2360                                                  Pt);
2361           }//secondary particles
2362         }//cuts
2363         else if(!IsAccepted(track)) {
2364           if(label <= stack->GetNprimary()) {
2365             if(track->Charge() > 0)
2366               ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),
2367                                                           track->Py(),
2368                                                           track->Pz()),
2369                                                  Pt);
2370             else if(track->Charge() < 0)
2371               ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(track->Px(),
2372                                                           track->Py(),
2373                                                           track->Pz()),
2374                                                  Pt);
2375           }//primary particles
2376           else if(label > stack->GetNprimary()) {
2377             if(track->Charge() > 0)
2378               ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),
2379                                                           track->Py(),
2380                                                           track->Pz()),
2381                                                  Pt);
2382             else if(track->Charge() < 0)
2383               ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(track->Px(),
2384                                                           track->Py(),
2385                                                           track->Pz()),
2386                                                  Pt);
2387           }//secondary particles
2388         }//cuts
2389       }//proton check
2390     }//TPC only tracks
2391     else if(!fUseTPCOnly) {
2392       Pt = track->Pt();
2393       P = track->P();
2394       
2395       //pid
2396       track->GetESDpid(probability);
2397       Double_t rcc = 0.0;
2398       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
2399         rcc += probability[i]*GetParticleFraction(i,P);
2400       if(rcc == 0.0) continue;
2401       Double_t w[5];
2402       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
2403         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
2404       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
2405       if(fParticleType == 4) {
2406         FillQA(track, stack);
2407         if(IsAccepted(track)) {
2408           if(label <= stack->GetNprimary()) {
2409             if(track->Charge() > 0)
2410               ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),
2411                                                           track->Py(),
2412                                                           track->Pz()),
2413                                                  Pt);
2414             else if(track->Charge() < 0)
2415               ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(track->Px(),
2416                                                           track->Py(),
2417                                                           track->Pz()),
2418                                                  Pt);
2419           }//primary particles
2420           else if(label > stack->GetNprimary()) {
2421             if(track->Charge() > 0)
2422               ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),
2423                                                           track->Py(),
2424                                                           track->Pz()),
2425                                                  Pt);
2426             else if(track->Charge() < 0)
2427               ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(track->Px(),
2428                                                           track->Py(),
2429                                                           track->Pz()),
2430                                                  Pt);
2431           }//secondary particles
2432         }//cuts
2433         else if(!IsAccepted(track)) {
2434           if(label <= stack->GetNprimary()) {
2435             if(track->Charge() > 0)
2436               ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),
2437                                                           track->Py(),
2438                                                           track->Pz()),
2439                                                  Pt);
2440             else if(track->Charge() < 0)
2441               ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(track->Px(),
2442                                                           track->Py(),
2443                                                           track->Pz()),
2444                                                  Pt);
2445           }//primary particles
2446           else if(label > stack->GetNprimary()) {
2447             if(track->Charge() > 0)
2448               ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),
2449                                                           track->Py(),
2450                                                           track->Pz()),
2451                                                  Pt);
2452             else if(track->Charge() < 0)
2453               ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(track->Px(),
2454                                                           track->Py(),
2455                                                           track->Pz()),
2456                                                  Pt);
2457           }//secondary particles
2458         }//cuts
2459       }//proton check
2460     }//combined tracking
2461   }//track loop
2462     
2463 }
2464
2465
2466
2467
2468
2469
2470
2471
2472