]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/AliProtonQAAnalysis.cxx
51b1bc7edf9eb569832ad162d8a28c1bdb370f60
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliProtonQAAnalysis.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: AliProtonQAAnalysis.cxx 29114 2008-10-03 16:49:02Z pchrist $ */
15
16 //-----------------------------------------------------------------
17 //                 AliProtonQAAnalysis class
18 //   This is the class to deal with the proton analysis
19 //   Origin: Panos Christakoglou | Panos.Christakoglou@cern.ch
20 //-----------------------------------------------------------------
21 #include <Riostream.h>
22 #include <TFile.h>
23 #include <TSystem.h>
24 #include <TF1.h>
25 #include <TH2D.h>
26 #include <TH3F.h>
27 #include <TH1D.h>
28 #include <TArrayI.h>
29 #include <TParticle.h>
30
31 #include "AliProtonQAAnalysis.h"
32
33 #include <AliExternalTrackParam.h>
34 #include <AliESDEvent.h>
35 #include <AliLog.h>
36 #include <AliPID.h>
37 #include <AliStack.h>
38 #include <AliESDVertex.h>
39 #include <AliGenEventHeader.h>
40
41 ClassImp(AliProtonQAAnalysis)
42
43 //____________________________________________________________________//
44 AliProtonQAAnalysis::AliProtonQAAnalysis() : 
45   TObject(), fAnalysisEtaMode(kFALSE),
46   fNBinsY(0), fMinY(0), fMaxY(0),
47   fNBinsPt(0), fMinPt(0), fMaxPt(0),
48   fMinTPCClusters(0), fMinITSClusters(0),
49   fMaxChi2PerTPCCluster(0), fMaxChi2PerITSCluster(0),
50   fMaxCov11(0), fMaxCov22(0), fMaxCov33(0), fMaxCov44(0), fMaxCov55(0),
51   fMaxSigmaToVertex(0), fMaxSigmaToVertexTPC(0),
52   fMaxDCAXY(0), fMaxDCAXYTPC(0),
53   fMaxDCAZ(0), fMaxDCAZTPC(0),
54   fMaxConstrainChi2(0),
55   fMinTPCClustersFlag(kFALSE), fMinITSClustersFlag(kFALSE),
56   fMaxChi2PerTPCClusterFlag(kFALSE), fMaxChi2PerITSClusterFlag(kFALSE),
57   fMaxCov11Flag(kFALSE), fMaxCov22Flag(kFALSE), 
58   fMaxCov33Flag(kFALSE), fMaxCov44Flag(kFALSE), fMaxCov55Flag(kFALSE),
59   fMaxSigmaToVertexFlag(kFALSE), fMaxSigmaToVertexTPCFlag(kFALSE),
60   fMaxDCAXYFlag(kFALSE), fMaxDCAXYTPCFlag(kFALSE),
61   fMaxDCAZFlag(kFALSE), fMaxDCAZTPCFlag(kFALSE),
62   fMaxConstrainChi2Flag(kFALSE),
63   fITSRefitFlag(kFALSE), fTPCRefitFlag(kFALSE),
64   fESDpidFlag(kFALSE), fTPCpidFlag(kFALSE),
65   fPointOnITSLayer1Flag(0), fPointOnITSLayer2Flag(0),
66   fPointOnITSLayer3Flag(0), fPointOnITSLayer4Flag(0),
67   fPointOnITSLayer5Flag(0), fPointOnITSLayer6Flag(0),
68   fGlobalQAList(0), fQAVertexList(0), fQA2DList(0),
69   fQAPrimaryProtonsAcceptedList(0),
70   fQAPrimaryProtonsRejectedList(0),
71   fQASecondaryProtonsAcceptedList(0),
72   fQASecondaryProtonsRejectedList(0),
73   fQAPrimaryAntiProtonsAcceptedList(0),
74   fQAPrimaryAntiProtonsRejectedList(0),
75   fQASecondaryAntiProtonsAcceptedList(0),
76   fQASecondaryAntiProtonsRejectedList(0),
77   fFunctionProbabilityFlag(kFALSE), 
78   fElectronFunction(0), fMuonFunction(0),
79   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
80   fUseTPCOnly(kFALSE), fUseHybridTPC(kFALSE),
81   fPDGList(0), fMCProcessesList(0),
82   fRunMCAnalysis(kFALSE),
83   fMCProcessIdFlag(kFALSE), fMCProcessId(0),
84   fMotherParticlePDGCodeFlag(kFALSE), fMotherParticlePDGCode(0),
85   fAcceptedCutList(0), fRejectedCutList(0),
86   fAcceptedDCAList(0), fRejectedDCAList(0),
87   fRunEfficiencyAnalysis(kFALSE),
88   fUseCutsInEfficiency(kFALSE),
89   fEfficiencyList(0) {
90   //Default constructor
91   for(Int_t i = 0; i < 5; i++) fPartFrac[i] = 0.0;
92 }
93
94 //____________________________________________________________________//
95 AliProtonQAAnalysis::~AliProtonQAAnalysis() {
96   //Default destructor
97   if(fGlobalQAList) delete fGlobalQAList;
98   if(fQAVertexList) delete fQAVertexList;
99   if(fQA2DList) delete fQA2DList;
100   if(fQAPrimaryProtonsAcceptedList) delete fQAPrimaryProtonsAcceptedList;
101   if(fQAPrimaryProtonsRejectedList) delete fQAPrimaryProtonsRejectedList;
102   if(fQASecondaryProtonsAcceptedList) delete fQASecondaryProtonsAcceptedList;
103   if(fQASecondaryProtonsRejectedList) delete fQASecondaryProtonsRejectedList;
104   if(fQAPrimaryAntiProtonsAcceptedList) 
105     delete fQAPrimaryAntiProtonsAcceptedList;
106   if(fQAPrimaryAntiProtonsRejectedList) 
107     delete fQAPrimaryAntiProtonsRejectedList;
108   if(fQASecondaryAntiProtonsAcceptedList) 
109     delete fQASecondaryAntiProtonsAcceptedList;
110   if(fQASecondaryAntiProtonsRejectedList) 
111     delete fQASecondaryAntiProtonsRejectedList; 
112
113   if(fPDGList) delete fPDGList;
114   if(fMCProcessesList) delete fMCProcessesList;
115   
116   if(fAcceptedCutList) delete fAcceptedCutList;
117   if(fRejectedCutList) delete fRejectedCutList;
118   if(fAcceptedDCAList) delete fAcceptedDCAList;
119   if(fRejectedDCAList) delete fRejectedDCAList;
120  
121   if(fEfficiencyList) delete fEfficiencyList;
122 }
123
124 //____________________________________________________________________//
125 Double_t AliProtonQAAnalysis::GetParticleFraction(Int_t i, Double_t p) {
126   Double_t partFrac=0;
127   if(fFunctionProbabilityFlag) {
128     if(i == 0) partFrac = fElectronFunction->Eval(p);
129     if(i == 1) partFrac = fMuonFunction->Eval(p);
130     if(i == 2) partFrac = fPionFunction->Eval(p);
131     if(i == 3) partFrac = fKaonFunction->Eval(p);
132     if(i == 4) partFrac = fProtonFunction->Eval(p);
133   }
134   else partFrac = fPartFrac[i];
135
136   return partFrac;
137 }
138
139 //____________________________________________________________________//
140 Bool_t AliProtonQAAnalysis::IsInPhaseSpace(AliESDtrack* const track) {
141   // Checks if the track is outside the analyzed y-Pt phase space
142   Double_t gPt = 0.0, gPx = 0.0, gPy = 0.0, gPz = 0.0;
143   Double_t eta = 0.0;
144
145   if(fUseTPCOnly) {
146     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
147     if(!tpcTrack) {
148       gPt = 0.0; gPx = 0.0; gPy = 0.0; gPz = 0.0; eta = -10.0;
149     }
150     else {
151       gPt = tpcTrack->Pt();
152       gPx = tpcTrack->Px();
153       gPy = tpcTrack->Py();
154       gPz = tpcTrack->Pz();
155       eta = tpcTrack->Eta();
156     }
157   }
158   else {
159     gPt = track->Pt();
160     gPx = track->Px();
161     gPy = track->Py();
162     gPz = track->Pz();
163     eta = track->Eta();
164   }
165   
166   if((gPt < fMinPt) || (gPt > fMaxPt)) return kFALSE;
167   if(fAnalysisEtaMode) {
168     if((eta < fMinY) || (eta > fMaxY)) 
169       return kFALSE;
170   }
171   else {
172     if((Rapidity(gPx,gPy,gPz) < fMinY) || (Rapidity(gPx,gPy,gPz) > fMaxY)) 
173       return kFALSE;
174   }
175
176   return kTRUE;
177 }
178
179 //____________________________________________________________________//
180 Bool_t AliProtonQAAnalysis::IsAccepted(AliESDEvent *esd,
181                                        const AliESDVertex *vertex, 
182                                        AliESDtrack* track) {
183   // Checks if the track is excluded from the cuts
184   Double_t gPt = 0.0, gPx = 0.0, gPy = 0.0, gPz = 0.0;
185   Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};  //The impact parameters and their covariance.
186   
187   if((fUseTPCOnly)&&(!fUseHybridTPC)) {
188     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
189     if(!tpcTrack) {
190       gPt = 0.0; gPx = 0.0; gPy = 0.0; gPz = 0.0;
191       dca[0] = -100.; dca[1] = -100.;
192       cov[0] = -100.; cov[1] = -100.; cov[2] = -100.;
193     }
194     else {
195       gPt = tpcTrack->Pt();
196       gPx = tpcTrack->Px();
197       gPy = tpcTrack->Py();
198       gPz = tpcTrack->Pz();
199       tpcTrack->PropagateToDCA(vertex,
200                                esd->GetMagneticField(),
201                                100.,dca,cov);
202     }
203   }
204   else if(fUseHybridTPC) {
205      AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
206     if(!tpcTrack) {
207       gPt = 0.0; gPx = 0.0; gPy = 0.0; gPz = 0.0;
208       dca[0] = -100.; dca[1] = -100.;
209       cov[0] = -100.; cov[1] = -100.; cov[2] = -100.;
210     }
211     else {
212       gPt = tpcTrack->Pt();
213       gPx = tpcTrack->Px();
214       gPy = tpcTrack->Py();
215       gPz = tpcTrack->Pz();
216       tpcTrack->PropagateToDCA(vertex,
217                                esd->GetMagneticField(),
218                                100.,dca,cov);
219     }
220   }
221   else{
222     gPt = track->Pt();
223     gPx = track->Px();
224     gPy = track->Py();
225     gPz = track->Pz();
226     track->PropagateToDCA(vertex,
227                           esd->GetMagneticField(),
228                           100.,dca,cov);
229   }
230      
231   Int_t  fIdxInt[200];
232   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
233   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
234
235   Float_t chi2PerClusterITS = -1;
236   if (nClustersITS!=0)
237     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
238   Float_t chi2PerClusterTPC = -1;
239   if (nClustersTPC!=0)
240     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
241
242   Double_t extCov[15];
243   track->GetExternalCovariance(extCov);
244
245   if(fPointOnITSLayer1Flag)
246     if(!track->HasPointOnITSLayer(0)) return kFALSE;
247   if(fPointOnITSLayer2Flag)
248     if(!track->HasPointOnITSLayer(1)) return kFALSE;
249   if(fPointOnITSLayer3Flag)
250     if(!track->HasPointOnITSLayer(2)) return kFALSE;
251   if(fPointOnITSLayer4Flag)
252     if(!track->HasPointOnITSLayer(3)) return kFALSE;
253   if(fPointOnITSLayer5Flag)
254     if(!track->HasPointOnITSLayer(4)) return kFALSE;
255   if(fPointOnITSLayer6Flag)
256     if(!track->HasPointOnITSLayer(5)) return kFALSE;
257   if(fMinITSClustersFlag)
258     if(nClustersITS < fMinITSClusters) return kFALSE;
259   if(fMaxChi2PerITSClusterFlag)
260     if(chi2PerClusterITS > fMaxChi2PerITSCluster) return kFALSE; 
261   if(fMinTPCClustersFlag)
262     if(nClustersTPC < fMinTPCClusters) return kFALSE;
263   if(fMaxChi2PerTPCClusterFlag)
264     if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) return kFALSE; 
265   if(fMaxCov11Flag)
266     if(extCov[0] > fMaxCov11) return kFALSE;
267   if(fMaxCov22Flag)
268     if(extCov[2] > fMaxCov22) return kFALSE;
269   if(fMaxCov33Flag)
270     if(extCov[5] > fMaxCov33) return kFALSE;
271   if(fMaxCov44Flag)
272     if(extCov[9] > fMaxCov44) return kFALSE;
273   if(fMaxCov55Flag)
274     if(extCov[14] > fMaxCov55) return kFALSE;
275   if(fMaxSigmaToVertexFlag)
276     if(GetSigmaToVertex(track) > fMaxSigmaToVertex) return kFALSE;
277   if(fMaxSigmaToVertexTPCFlag)
278     if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) return kFALSE;
279   if(fMaxDCAXYFlag) 
280     if(TMath::Abs(dca[0]) > fMaxDCAXY) return kFALSE;
281   if(fMaxDCAXYTPCFlag) 
282     if(TMath::Abs(dca[0]) > fMaxDCAXYTPC) return kFALSE;
283     if(fMaxDCAZFlag) 
284     if(TMath::Abs(dca[1]) > fMaxDCAZ) return kFALSE;
285   if(fMaxDCAZTPCFlag) 
286     if(TMath::Abs(dca[1]) > fMaxDCAZTPC) return kFALSE;
287   if(fMaxConstrainChi2Flag) {
288     if(track->GetConstrainedChi2() > 0) 
289       if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) return kFALSE;
290   }
291   if(fITSRefitFlag)
292     if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) return kFALSE;
293   if(fTPCRefitFlag)
294     if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) return kFALSE;
295   if(fESDpidFlag)
296     if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) return kFALSE;
297   if(fTPCpidFlag)
298     if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) return kFALSE;
299
300   return kTRUE;
301 }
302
303 //____________________________________________________________________//
304 Float_t AliProtonQAAnalysis::GetSigmaToVertex(AliESDtrack* esdTrack) const {
305   // Calculates the number of sigma to the vertex.
306   
307   Float_t b[2];
308   Float_t bRes[2];
309   Float_t bCov[3];
310   if((fUseTPCOnly)&&(!fUseHybridTPC))
311     esdTrack->GetImpactParametersTPC(b,bCov);
312   else
313     esdTrack->GetImpactParameters(b,bCov);
314   
315   if (bCov[0]<=0 || bCov[2]<=0) {
316     //AliDebug(1, "Estimated b resolution lower or equal zero!");
317     bCov[0]=0; bCov[2]=0;
318   }
319   bRes[0] = TMath::Sqrt(bCov[0]);
320   bRes[1] = TMath::Sqrt(bCov[2]);
321   
322   if (bRes[0] == 0 || bRes[1] ==0) return -1;
323   
324   Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
325   
326   if (TMath::Exp(-d * d / 2) < 1e-10) return 1000;
327   
328   d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
329   
330   return d;
331 }
332
333 //____________________________________________________________________//
334 Double_t AliProtonQAAnalysis::Rapidity(Double_t gPx, 
335                                        Double_t gPy, 
336                                        Double_t gPz) const {
337   //returns the rapidity of the proton - to be removed
338   Double_t fMass = 9.38270000000000048e-01;
339   
340   Double_t gP = TMath::Sqrt(TMath::Power(gPx,2) + 
341                            TMath::Power(gPy,2) + 
342                            TMath::Power(gPz,2));
343   Double_t energy = TMath::Sqrt(gP*gP + fMass*fMass);
344   Double_t y = -999;
345   if(energy != gPz) 
346     y = 0.5*TMath::Log((energy + gPz)/(energy - gPz));
347
348   return y;
349 }
350
351 //____________________________________________________________________//
352 void AliProtonQAAnalysis::FillQA(AliStack *stack,
353                                  AliESDEvent *esd,
354                                  const AliESDVertex *vertex, 
355                                  AliESDtrack* track) {
356   // Checks if the track is excluded from the cuts
357   Int_t nPrimaries = stack->GetNprimary();
358   Int_t label = TMath::Abs(track->GetLabel());
359
360   Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
361   Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};  //The impact parameters and their covariance.
362
363   if((fUseTPCOnly)&&(!fUseHybridTPC)) {
364     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
365     if(!tpcTrack) {
366       Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
367       dca[0] = -100.; dca[1] = -100.;
368       cov[0] = -100.; cov[1] = -100.; cov[2] = -100.;
369     }
370     else {
371       Pt = tpcTrack->Pt();
372       Px = tpcTrack->Px();
373       Py = tpcTrack->Py();
374       Pz = tpcTrack->Pz();
375       tpcTrack->PropagateToDCA(vertex,
376                                esd->GetMagneticField(),
377                                100.,dca,cov);
378     }
379   }
380   else if(fUseHybridTPC) {
381      AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
382     if(!tpcTrack) {
383       Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
384       dca[0] = -100.; dca[1] = -100.;
385       cov[0] = -100.; cov[1] = -100.; cov[2] = -100.;
386     }
387     else {
388       Pt = tpcTrack->Pt();
389       Px = tpcTrack->Px();
390       Py = tpcTrack->Py();
391       Pz = tpcTrack->Pz();
392       tpcTrack->PropagateToDCA(vertex,
393                                esd->GetMagneticField(),
394                                100.,dca,cov);
395     }
396   }
397   else{
398     Pt = track->Pt();
399     Px = track->Px();
400     Py = track->Py();
401     Pz = track->Pz();
402     track->PropagateToDCA(vertex,
403                           esd->GetMagneticField(),
404                           100.,dca,cov);
405   }
406
407   Int_t  fIdxInt[200];
408   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
409   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
410
411   Float_t chi2PerClusterITS = -1;
412   if (nClustersITS!=0)
413     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
414   Float_t chi2PerClusterTPC = -1;
415   if (nClustersTPC!=0)
416     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
417
418   Double_t extCov[15];
419   track->GetExternalCovariance(extCov);
420   
421   //cout<<"Charge: "<<track->Charge()<<
422   //" - Label/Primaries: "<<label<<"/"<<nPrimaries<<
423   //" - TPC clusters: "<<nClustersTPC<<endl;
424   //protons
425   if(track->Charge() > 0) {
426     //Primaries
427     if(label <= nPrimaries) {
428       if(fMinITSClustersFlag) {
429         if(nClustersITS < fMinITSClusters) {
430           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
431           //status = kFALSE;
432         }
433         else if(nClustersITS >= fMinITSClusters) 
434           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
435       }//ITS clusters
436       if(fMaxChi2PerITSClusterFlag) {
437         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
438           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
439           //status = kFALSE;
440         }
441         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
442           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
443       }//chi2 per ITS cluster
444       if(fMinTPCClustersFlag) {
445         if(nClustersTPC < fMinTPCClusters) {
446           //cout<<"Primary proton rejected"<<endl;
447           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
448           //status = kFALSE;
449         }
450         else if(nClustersTPC >= fMinTPCClusters) {
451           //cout<<"Primary proton accepted"<<endl;
452           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
453         }
454       }//TPC clusters
455       if(fMaxChi2PerTPCClusterFlag) {
456         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
457           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
458           //status = kFALSE;
459         }
460         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
461           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
462       }//chi2 per TPC cluster
463       if(fMaxCov11Flag) {
464         if(extCov[0] > fMaxCov11) {
465           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
466           //status = kFALSE;
467         }
468         else if(extCov[0] <= fMaxCov11)
469           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
470       }//cov11
471       if(fMaxCov22Flag) {
472         if(extCov[2] > fMaxCov22) {
473           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
474           //status = kFALSE;
475         }
476         else if(extCov[2] <= fMaxCov22)
477           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
478       }//cov11
479       if(fMaxCov33Flag) {
480         if(extCov[5] > fMaxCov33) {
481           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
482           //status = kFALSE;
483         }
484         else if(extCov[5] <= fMaxCov33)
485           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
486       }//cov11
487       if(fMaxCov44Flag) {
488         if(extCov[9] > fMaxCov44) {
489           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
490           //status = kFALSE;
491         }
492         else if(extCov[9] <= fMaxCov44)
493           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
494       }//cov11
495       if(fMaxCov55Flag) {
496         if(extCov[14] > fMaxCov55) {
497           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
498           //status = kFALSE;
499         }
500         else if(extCov[14] <= fMaxCov55)
501           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
502       }//cov55
503       if(fMaxSigmaToVertexFlag) {
504         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
505           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
506           //status = kFALSE;
507         }
508         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
509           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
510       }//sigma to vertex
511       if(fMaxSigmaToVertexTPCFlag) {
512         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
513           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
514           //status = kFALSE;
515         }
516         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
517           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
518       }//sigma to vertex TPC
519       if(fMaxDCAXYFlag) {
520         if(TMath::Abs(dca[0]) > fMaxDCAXY) {
521           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
522           //status = kFALSE;
523         }
524         else if(TMath::Abs(dca[0]) <= fMaxDCAXY)
525           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
526       }//DCA xy global tracking
527       if(fMaxDCAXYTPCFlag) {
528         if(TMath::Abs(dca[0]) > fMaxDCAXYTPC) {
529           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
530           //status = kFALSE;
531         }
532         else if(TMath::Abs(dca[0]) <= fMaxDCAXYTPC)
533           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
534       }//DCA xy TPC tracking
535       if(fMaxDCAZFlag) {
536         if(TMath::Abs(dca[1]) > fMaxDCAZ) {
537           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
538           //status = kFALSE;
539         }
540         else if(TMath::Abs(dca[1]) <= fMaxDCAZ)
541           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
542       }//DCA z global tracking
543       if(fMaxDCAZTPCFlag) {
544         if(TMath::Abs(dca[1]) > fMaxDCAZTPC) {
545           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
546           //status = kFALSE;
547         }
548         else if(TMath::Abs(dca[1]) <= fMaxDCAZTPC)
549           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
550       }//DCA z TPC tracking
551       if(fMaxConstrainChi2Flag) {
552         if(track->GetConstrainedChi2() > 0) {
553           if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
554             ((TH1F *)(fQAPrimaryProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
555             //status = kFALSE;
556           }
557           else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
558             ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
559         }
560       }//constrain chi2 - vertex
561       if(fITSRefitFlag) {
562         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
563           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(16)))->Fill(0);
564         //status = kFALSE;
565         }
566         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
567           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(16)))->Fill(0);
568       }//ITS refit
569       if(fTPCRefitFlag) {
570         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
571           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(17)))->Fill(0);
572           //status = kFALSE;
573         }
574         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
575           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(17)))->Fill(0);
576       }//TPC refit
577       if(fESDpidFlag) {
578         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
579           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(18)))->Fill(0);
580           //status = kFALSE;
581         }
582         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
583           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(18)))->Fill(0);
584       }//ESD pid
585       if(fTPCpidFlag) {
586         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
587           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(19)))->Fill(0);
588           //status = kFALSE;
589         }
590         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
591           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(19)))->Fill(0);
592       }//TPC pid
593       if(fPointOnITSLayer1Flag) {
594         if(!track->HasPointOnITSLayer(0)) {
595           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(20)))->Fill(0);
596         }
597         else if(track->HasPointOnITSLayer(0))
598           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(20)))->Fill(0);
599       }//point on SPD1
600       if(fPointOnITSLayer2Flag) {
601         if(!track->HasPointOnITSLayer(1)) {
602           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(21)))->Fill(0);
603         }
604         else if(track->HasPointOnITSLayer(1))
605           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(21)))->Fill(0);
606       }//point on SPD2
607       if(fPointOnITSLayer3Flag) {
608         if(!track->HasPointOnITSLayer(2)) {
609           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(22)))->Fill(0);
610         }
611         else if(track->HasPointOnITSLayer(2))
612           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(22)))->Fill(0);
613       }//point on SDD1
614       if(fPointOnITSLayer4Flag) {
615         if(!track->HasPointOnITSLayer(3)) {
616           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(23)))->Fill(0);
617         }
618         else if(track->HasPointOnITSLayer(3))
619           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(23)))->Fill(0);
620       }//point on SDD2
621       if(fPointOnITSLayer5Flag) {
622         if(!track->HasPointOnITSLayer(4)) {
623           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(24)))->Fill(0);
624         }
625         else if(track->HasPointOnITSLayer(4))
626           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(24)))->Fill(0);
627       }//point on SSD1
628       if(fPointOnITSLayer6Flag) {
629         if(!track->HasPointOnITSLayer(5)) {
630           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(25)))->Fill(0);
631         }
632         else if(track->HasPointOnITSLayer(5))
633           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(25)))->Fill(0);
634       }//point on SSD2
635     }//primary particle cut
636
637     //Secondaries
638     if(label > nPrimaries) {
639       if(fMinITSClustersFlag) {
640         if(nClustersITS < fMinITSClusters) {
641           ((TH1F *)(fQASecondaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
642           //status = kFALSE;
643         }
644         else if(nClustersITS >= fMinITSClusters) 
645           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
646       }//ITS clusters
647       if(fMaxChi2PerITSClusterFlag) {
648         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
649           ((TH1F *)(fQASecondaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
650           //status = kFALSE;
651         }
652         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
653           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
654       }//chi2 per ITS cluster
655       if(fMinTPCClustersFlag) {
656         if(nClustersTPC < fMinTPCClusters) {
657           //cout<<"Secondary proton rejected"<<endl;
658           ((TH1F *)(fQASecondaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
659           //status = kFALSE;
660         }
661         else if(nClustersTPC >= fMinTPCClusters) {
662           //cout<<"Secondary proton accepted"<<endl;
663           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
664         }
665       }//TPC clusters
666       if(fMaxChi2PerTPCClusterFlag) {
667         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
668           ((TH1F *)(fQASecondaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
669           //status = kFALSE;
670         }
671         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
672           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
673       }//chi2 per TPC cluster
674       if(fMaxCov11Flag) {
675         if(extCov[0] > fMaxCov11) {
676           ((TH1F *)(fQASecondaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
677           //status = kFALSE;
678         }
679         else if(extCov[0] <= fMaxCov11)
680           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
681       }//cov11
682       if(fMaxCov22Flag) {
683         if(extCov[2] > fMaxCov22) {
684           ((TH1F *)(fQASecondaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
685           //status = kFALSE;
686         }
687         else if(extCov[2] <= fMaxCov22)
688           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
689       }//cov11
690       if(fMaxCov33Flag) {
691         if(extCov[5] > fMaxCov33) {
692           ((TH1F *)(fQASecondaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
693           //status = kFALSE;
694         }
695         else if(extCov[5] <= fMaxCov33)
696           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
697       }//cov11
698       if(fMaxCov44Flag) {
699         if(extCov[9] > fMaxCov44) {
700           ((TH1F *)(fQASecondaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
701           //status = kFALSE;
702         }
703         else if(extCov[9] <= fMaxCov44)
704           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
705       }//cov11
706       if(fMaxCov55Flag) {
707         if(extCov[14] > fMaxCov55) {
708           ((TH1F *)(fQASecondaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
709           //status = kFALSE;
710         }
711         else if(extCov[14] <= fMaxCov55)
712           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
713       }//cov55
714       if(fMaxSigmaToVertexFlag) {
715         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
716           ((TH1F *)(fQASecondaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
717           //status = kFALSE;
718         }
719         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
720           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
721       }//sigma to vertex
722       if(fMaxSigmaToVertexTPCFlag) {
723         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
724           ((TH1F *)(fQASecondaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
725           //status = kFALSE;
726         }
727         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
728           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
729       }//sigma to vertex TPC
730       if(fMaxDCAXYFlag) {
731         if(TMath::Abs(dca[0]) > fMaxDCAXY) {
732           ((TH1F *)(fQASecondaryProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
733           //status = kFALSE;
734         }
735         else if(TMath::Abs(dca[0]) <= fMaxDCAXY)
736           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
737       }//DCA xy global tracking
738       if(fMaxDCAXYTPCFlag) {
739         if(TMath::Abs(dca[0]) > fMaxDCAXYTPC) {
740           ((TH1F *)(fQASecondaryProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
741           //status = kFALSE;
742         }
743         else if(TMath::Abs(dca[0]) <= fMaxDCAXYTPC)
744           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
745       }//DCA xy TPC tracking
746       if(fMaxDCAZFlag) {
747         if(TMath::Abs(dca[1]) > fMaxDCAZ) {
748           ((TH1F *)(fQASecondaryProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
749           //status = kFALSE;
750         }
751         else if(TMath::Abs(dca[1]) <= fMaxDCAZ)
752           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
753       }//DCA z global tracking
754       if(fMaxDCAZTPCFlag) {
755         if(TMath::Abs(dca[1]) > fMaxDCAZTPC) {
756           ((TH1F *)(fQASecondaryProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
757           //status = kFALSE;
758         }
759         else if(TMath::Abs(dca[1]) <= fMaxDCAZTPC)
760           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
761       }//DCA z TPC tracking
762       if(fMaxConstrainChi2Flag) {
763         if(track->GetConstrainedChi2() > 0) {
764           if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
765             ((TH1F *)(fQASecondaryProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
766             //status = kFALSE;
767           }
768           else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
769             ((TH1F *)(fQASecondaryProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
770         }
771       }//constrain chi2 - vertex
772       if(fITSRefitFlag) {
773         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
774           ((TH1F *)(fQASecondaryProtonsRejectedList->At(16)))->Fill(0);
775         //status = kFALSE;
776         }
777         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
778           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(16)))->Fill(0);
779       }//ITS refit
780       if(fTPCRefitFlag) {
781         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
782           ((TH1F *)(fQASecondaryProtonsRejectedList->At(17)))->Fill(0);
783           //status = kFALSE;
784         }
785         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
786           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(17)))->Fill(0);
787       }//TPC refit
788       if(fESDpidFlag) {
789         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
790           ((TH1F *)(fQASecondaryProtonsRejectedList->At(18)))->Fill(0);
791           //status = kFALSE;
792         }
793         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
794           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(18)))->Fill(0);
795       }//ESD pid
796       if(fTPCpidFlag) {
797         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
798           ((TH1F *)(fQASecondaryProtonsRejectedList->At(19)))->Fill(0);
799           //status = kFALSE;
800         }
801         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
802           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(19)))->Fill(0);
803       }//TPC pid
804       if(fPointOnITSLayer1Flag) {
805         if(!track->HasPointOnITSLayer(0)) {
806           ((TH1F *)(fQASecondaryProtonsRejectedList->At(20)))->Fill(0);
807         }
808         else if(track->HasPointOnITSLayer(0))
809           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(20)))->Fill(0);
810       }//point on SPD1
811       if(fPointOnITSLayer2Flag) {
812         if(!track->HasPointOnITSLayer(1)) {
813           ((TH1F *)(fQASecondaryProtonsRejectedList->At(21)))->Fill(0);
814         }
815         else if(track->HasPointOnITSLayer(1))
816           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(21)))->Fill(0);
817       }//point on SPD2
818       if(fPointOnITSLayer3Flag) {
819         if(!track->HasPointOnITSLayer(2)) {
820           ((TH1F *)(fQASecondaryProtonsRejectedList->At(22)))->Fill(0);
821         }
822         else if(track->HasPointOnITSLayer(2))
823           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(22)))->Fill(0);
824       }//point on SDD1
825       if(fPointOnITSLayer4Flag) {
826         if(!track->HasPointOnITSLayer(3)) {
827           ((TH1F *)(fQASecondaryProtonsRejectedList->At(23)))->Fill(0);
828         }
829         else if(track->HasPointOnITSLayer(3))
830           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(23)))->Fill(0);
831       }//point on SDD2
832       if(fPointOnITSLayer5Flag) {
833         if(!track->HasPointOnITSLayer(4)) {
834           ((TH1F *)(fQASecondaryProtonsRejectedList->At(24)))->Fill(0);
835         }
836         else if(track->HasPointOnITSLayer(4))
837           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(24)))->Fill(0);
838       }//point on SSD1
839       if(fPointOnITSLayer6Flag) {
840         if(!track->HasPointOnITSLayer(5)) {
841           ((TH1F *)(fQASecondaryProtonsRejectedList->At(25)))->Fill(0);
842         }
843         else if(track->HasPointOnITSLayer(5))
844           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(25)))->Fill(0);
845       }//point on SSD2
846     }//secondary particle cut
847   }//protons
848
849   //antiprotons
850   if(track->Charge() < 0) {
851     //Primaries
852     if(label <= nPrimaries) {
853       if(fMinITSClustersFlag) {
854         if(nClustersITS < fMinITSClusters) {
855           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
856           //status = kFALSE;
857         }
858         else if(nClustersITS >= fMinITSClusters) 
859           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
860       }//ITS clusters
861       if(fMaxChi2PerITSClusterFlag) {
862         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
863           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
864           //status = kFALSE;
865         }
866         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
867           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
868       }//chi2 per ITS cluster
869       if(fMinTPCClustersFlag) {
870         if(nClustersTPC < fMinTPCClusters) {
871           //cout<<"Primary antiproton rejected"<<endl;
872           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
873           //status = kFALSE;
874         }
875         else if(nClustersTPC >= fMinTPCClusters) {
876           //cout<<"Primary antiproton accepted"<<endl;
877           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
878         }
879       }//TPC clusters
880       if(fMaxChi2PerTPCClusterFlag) {
881         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
882           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
883           //status = kFALSE;
884         }
885         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
886           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
887       }//chi2 per TPC cluster
888       if(fMaxCov11Flag) {
889         if(extCov[0] > fMaxCov11) {
890           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
891           //status = kFALSE;
892         }
893         else if(extCov[0] <= fMaxCov11)
894           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
895       }//cov11
896       if(fMaxCov22Flag) {
897         if(extCov[2] > fMaxCov22) {
898           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
899           //status = kFALSE;
900         }
901         else if(extCov[2] <= fMaxCov22)
902           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
903       }//cov11
904       if(fMaxCov33Flag) {
905         if(extCov[5] > fMaxCov33) {
906           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
907           //status = kFALSE;
908         }
909         else if(extCov[5] <= fMaxCov33)
910           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
911       }//cov11
912       if(fMaxCov44Flag) {
913         if(extCov[9] > fMaxCov44) {
914           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
915           //status = kFALSE;
916         }
917         else if(extCov[9] <= fMaxCov44)
918           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
919       }//cov11
920       if(fMaxCov55Flag) {
921         if(extCov[14] > fMaxCov55) {
922           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
923           //status = kFALSE;
924         }
925         else if(extCov[14] <= fMaxCov55)
926           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
927       }//cov55
928       if(fMaxSigmaToVertexFlag) {
929         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
930           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
931           //status = kFALSE;
932         }
933         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
934           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
935       }//sigma to vertex
936       if(fMaxSigmaToVertexTPCFlag) {
937         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
938           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
939           //status = kFALSE;
940         }
941         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
942           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
943       }//sigma to vertex TPC
944       if(fMaxDCAXYFlag) {
945         if(TMath::Abs(dca[0]) > fMaxDCAXY) {
946           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
947           //status = kFALSE;
948         }
949         else if(TMath::Abs(dca[0]) <= fMaxDCAXY)
950           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
951       }//DCA xy global tracking
952       if(fMaxDCAXYTPCFlag) {
953         if(TMath::Abs(dca[0]) > fMaxDCAXYTPC) {
954           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
955           //status = kFALSE;
956         }
957         else if(TMath::Abs(dca[0]) <= fMaxDCAXYTPC)
958           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
959       }//DCA xy TPC tracking
960       if(fMaxDCAZFlag) {
961         if(TMath::Abs(dca[1]) > fMaxDCAZ) {
962           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
963           //status = kFALSE;
964         }
965         else if(TMath::Abs(dca[1]) <= fMaxDCAZ)
966           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
967       }//DCA z global tracking
968       if(fMaxDCAZTPCFlag) {
969         if(TMath::Abs(dca[1]) > fMaxDCAZTPC) {
970           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
971           //status = kFALSE;
972         }
973         else if(TMath::Abs(dca[1]) <= fMaxDCAZTPC)
974           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
975       }//DCA z TPC tracking
976       if(fMaxConstrainChi2Flag) {
977         if(track->GetConstrainedChi2() > 0) {
978           if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
979             ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
980             //status = kFALSE;
981           }
982           else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
983             ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
984         }
985       }//constrain chi2 - vertex
986       if(fITSRefitFlag) {
987         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
988           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(16)))->Fill(0);
989         //status = kFALSE;
990         }
991         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
992           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(16)))->Fill(0);
993       }//ITS refit
994       if(fTPCRefitFlag) {
995         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
996           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(17)))->Fill(0);
997           //status = kFALSE;
998         }
999         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
1000           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(17)))->Fill(0);
1001       }//TPC refit
1002       if(fESDpidFlag) {
1003         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
1004           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(18)))->Fill(0);
1005           //status = kFALSE;
1006         }
1007         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
1008           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(18)))->Fill(0);
1009       }//ESD pid
1010       if(fTPCpidFlag) {
1011         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
1012           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(19)))->Fill(0);
1013           //status = kFALSE;
1014         }
1015         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
1016           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(19)))->Fill(0);
1017       }//TPC pid
1018       if(fPointOnITSLayer1Flag) {
1019         if(!track->HasPointOnITSLayer(0)) {
1020           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(20)))->Fill(0);
1021         }
1022         else if(track->HasPointOnITSLayer(0))
1023           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(20)))->Fill(0);
1024       }//point on SPD1
1025       if(fPointOnITSLayer2Flag) {
1026         if(!track->HasPointOnITSLayer(1)) {
1027           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(21)))->Fill(0);
1028         }
1029         else if(track->HasPointOnITSLayer(1))
1030           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(21)))->Fill(0);
1031       }//point on SPD2
1032       if(fPointOnITSLayer3Flag) {
1033         if(!track->HasPointOnITSLayer(2)) {
1034           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(22)))->Fill(0);
1035         }
1036         else if(track->HasPointOnITSLayer(2))
1037           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(22)))->Fill(0);
1038       }//point on SDD1
1039       if(fPointOnITSLayer4Flag) {
1040         if(!track->HasPointOnITSLayer(3)) {
1041           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(23)))->Fill(0);
1042         }
1043         else if(track->HasPointOnITSLayer(3))
1044           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(23)))->Fill(0);
1045       }//point on SDD2
1046       if(fPointOnITSLayer5Flag) {
1047         if(!track->HasPointOnITSLayer(4)) {
1048           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(24)))->Fill(0);
1049         }
1050         else if(track->HasPointOnITSLayer(4))
1051           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(24)))->Fill(0);
1052       }//point on SSD1
1053       if(fPointOnITSLayer6Flag) {
1054         if(!track->HasPointOnITSLayer(5)) {
1055           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(25)))->Fill(0);
1056         }
1057         else if(track->HasPointOnITSLayer(5))
1058           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(25)))->Fill(0);
1059       }//point on SSD2
1060     }//primary particle cut
1061
1062     //Secondaries
1063     if(label > nPrimaries) {
1064       if(fMinITSClustersFlag) {
1065         if(nClustersITS < fMinITSClusters) {
1066           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
1067           //status = kFALSE;
1068         }
1069         else if(nClustersITS >= fMinITSClusters) 
1070           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
1071       }//ITS clusters
1072       if(fMaxChi2PerITSClusterFlag) {
1073         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
1074           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
1075           //status = kFALSE;
1076         }
1077         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
1078           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
1079       }//chi2 per ITS cluster
1080       if(fMinTPCClustersFlag) {
1081         if(nClustersTPC < fMinTPCClusters) {
1082           //cout<<"Secondary antiproton rejected"<<endl;
1083           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
1084           //status = kFALSE;
1085         }
1086         else if(nClustersTPC >= fMinTPCClusters) {
1087           //cout<<"Secondary antiproton accepted"<<endl;
1088           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
1089         }
1090       }//TPC clusters
1091       if(fMaxChi2PerTPCClusterFlag) {
1092         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
1093           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
1094           //status = kFALSE;
1095         }
1096         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
1097           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
1098       }//chi2 per TPC cluster
1099       if(fMaxCov11Flag) {
1100         if(extCov[0] > fMaxCov11) {
1101           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
1102           //status = kFALSE;
1103         }
1104         else if(extCov[0] <= fMaxCov11)
1105           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
1106       }//cov11
1107       if(fMaxCov22Flag) {
1108         if(extCov[2] > fMaxCov22) {
1109           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
1110           //status = kFALSE;
1111         }
1112         else if(extCov[2] <= fMaxCov22)
1113           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
1114       }//cov11
1115       if(fMaxCov33Flag) {
1116         if(extCov[5] > fMaxCov33) {
1117           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
1118           //status = kFALSE;
1119         }
1120         else if(extCov[5] <= fMaxCov33)
1121           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
1122       }//cov11
1123       if(fMaxCov44Flag) {
1124         if(extCov[9] > fMaxCov44) {
1125           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
1126           //status = kFALSE;
1127         }
1128         else if(extCov[9] <= fMaxCov44)
1129           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
1130       }//cov11
1131       if(fMaxCov55Flag) {
1132         if(extCov[14] > fMaxCov55) {
1133           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
1134           //status = kFALSE;
1135         }
1136         else if(extCov[14] <= fMaxCov55)
1137           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
1138       }//cov55
1139       if(fMaxSigmaToVertexFlag) {
1140         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
1141           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
1142           //status = kFALSE;
1143         }
1144         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
1145           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
1146       }//sigma to vertex
1147       if(fMaxSigmaToVertexTPCFlag) {
1148         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
1149           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
1150           //status = kFALSE;
1151         }
1152         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
1153           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
1154       }//sigma to vertex TPC
1155       if(fMaxDCAXYFlag) {
1156         if(TMath::Abs(dca[0]) > fMaxDCAXY) {
1157           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
1158           //status = kFALSE;
1159         }
1160         else if(TMath::Abs(dca[0]) <= fMaxDCAXY)
1161           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
1162       }//DCA xy global tracking
1163       if(fMaxDCAXYTPCFlag) {
1164         if(TMath::Abs(dca[0]) > fMaxDCAXYTPC) {
1165           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
1166           //status = kFALSE;
1167         }
1168         else if(TMath::Abs(dca[0]) <= fMaxDCAXYTPC)
1169           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
1170       }//DCA xy TPC tracking
1171       if(fMaxDCAZFlag) {
1172         if(TMath::Abs(dca[1]) > fMaxDCAZ) {
1173           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
1174           //status = kFALSE;
1175         }
1176         else if(TMath::Abs(dca[1]) <= fMaxDCAZ)
1177           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
1178       }//DCA z global tracking
1179       if(fMaxDCAZTPCFlag) {
1180         if(TMath::Abs(dca[1]) > fMaxDCAZTPC) {
1181           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
1182           //status = kFALSE;
1183         }
1184         else if(TMath::Abs(dca[1]) <= fMaxDCAZTPC)
1185           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
1186       }//DCA z TPC tracking
1187       if(fMaxConstrainChi2Flag) {
1188         if(track->GetConstrainedChi2() > 0) {
1189           if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
1190             ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
1191             //status = kFALSE;
1192           }
1193           else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
1194             ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
1195         }
1196       }//constrain chi2 - vertex
1197       if(fITSRefitFlag) {
1198         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
1199           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(16)))->Fill(0);
1200         //status = kFALSE;
1201         }
1202         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
1203           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(16)))->Fill(0);
1204       }//ITS refit
1205       if(fTPCRefitFlag) {
1206         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
1207           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(17)))->Fill(0);
1208           //status = kFALSE;
1209         }
1210         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
1211           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(17)))->Fill(0);
1212       }//TPC refit
1213       if(fESDpidFlag) {
1214         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
1215           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(18)))->Fill(0);
1216           //status = kFALSE;
1217         }
1218         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
1219           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(18)))->Fill(0);
1220       }//ESD pid
1221       if(fTPCpidFlag) {
1222         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
1223           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(19)))->Fill(0);
1224           //status = kFALSE;
1225         }
1226         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
1227           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(19)))->Fill(0);
1228       }//TPC pid
1229       if(fPointOnITSLayer1Flag) {
1230         if(!track->HasPointOnITSLayer(0)) {
1231           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(20)))->Fill(0);
1232         }
1233         else if(track->HasPointOnITSLayer(0))
1234           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(20)))->Fill(0);
1235       }//point on SPD1
1236       if(fPointOnITSLayer2Flag) {
1237         if(!track->HasPointOnITSLayer(1)) {
1238           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(21)))->Fill(0);
1239         }
1240         else if(track->HasPointOnITSLayer(1))
1241           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(21)))->Fill(0);
1242       }//point on SPD2
1243       if(fPointOnITSLayer3Flag) {
1244         if(!track->HasPointOnITSLayer(2)) {
1245           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(22)))->Fill(0);
1246         }
1247         else if(track->HasPointOnITSLayer(2))
1248           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(22)))->Fill(0);
1249       }//point on SDD1
1250       if(fPointOnITSLayer4Flag) {
1251         if(!track->HasPointOnITSLayer(3)) {
1252           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(23)))->Fill(0);
1253         }
1254         else if(track->HasPointOnITSLayer(3))
1255           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(23)))->Fill(0);
1256       }//point on SDD2
1257       if(fPointOnITSLayer5Flag) {
1258         if(!track->HasPointOnITSLayer(4)) {
1259           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(24)))->Fill(0);
1260         }
1261         else if(track->HasPointOnITSLayer(4))
1262           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(24)))->Fill(0);
1263       }//point on SSD1
1264       if(fPointOnITSLayer6Flag) {
1265         if(!track->HasPointOnITSLayer(5)) {
1266           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(25)))->Fill(0);
1267         }
1268         else if(track->HasPointOnITSLayer(5))
1269           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(25)))->Fill(0);
1270       }//point on SSD2
1271     }//secondary particle cut
1272   }//antiprotons
1273 }
1274
1275 //____________________________________________________________________//
1276 void AliProtonQAAnalysis::SetRunQAAnalysis() {
1277   //initializes the QA lists
1278   //fQAHistograms = kTRUE;
1279   fGlobalQAList = new TList();
1280
1281   fQA2DList = new TList();
1282   fQA2DList->SetName("fQA2DList");
1283   fGlobalQAList->Add(fQA2DList);
1284   
1285   fQAPrimaryProtonsAcceptedList = new TList();
1286   fQAPrimaryProtonsAcceptedList->SetName("fQAPrimaryProtonsAcceptedList");
1287   fGlobalQAList->Add(fQAPrimaryProtonsAcceptedList);
1288   
1289   fQAPrimaryProtonsRejectedList = new TList();
1290   fQAPrimaryProtonsRejectedList->SetName("fQAPrimaryProtonsRejectedList");
1291   fGlobalQAList->Add(fQAPrimaryProtonsRejectedList);
1292   
1293   fQASecondaryProtonsAcceptedList = new TList();
1294   fQASecondaryProtonsAcceptedList->SetName("fQASecondaryProtonsAcceptedList");
1295   fGlobalQAList->Add(fQASecondaryProtonsAcceptedList);
1296   
1297   fQASecondaryProtonsRejectedList = new TList();
1298   fQASecondaryProtonsRejectedList->SetName("fQASecondaryProtonsRejectedList");
1299   fGlobalQAList->Add(fQASecondaryProtonsRejectedList);
1300   
1301   fQAPrimaryAntiProtonsAcceptedList = new TList();
1302   fQAPrimaryAntiProtonsAcceptedList->SetName("fQAPrimaryAntiProtonsAcceptedList");
1303   fGlobalQAList->Add(fQAPrimaryAntiProtonsAcceptedList);
1304   
1305   fQAPrimaryAntiProtonsRejectedList = new TList();
1306   fQAPrimaryAntiProtonsRejectedList->SetName("fQAPrimaryAntiProtonsRejectedList");
1307   fGlobalQAList->Add(fQAPrimaryAntiProtonsRejectedList);
1308   
1309   fQASecondaryAntiProtonsAcceptedList = new TList();
1310   fQASecondaryAntiProtonsAcceptedList->SetName("fQASecondaryAntiProtonsAcceptedList");
1311   fGlobalQAList->Add(fQASecondaryAntiProtonsAcceptedList);
1312   
1313   fQASecondaryAntiProtonsRejectedList = new TList();
1314   fQASecondaryAntiProtonsRejectedList->SetName("fQASecondaryAntiProtonsRejectedList");
1315   fGlobalQAList->Add(fQASecondaryAntiProtonsRejectedList);
1316 }
1317
1318 //____________________________________________________________________//
1319 void AliProtonQAAnalysis::SetQAYPtBins(Int_t nbinsY, Double_t minY, Double_t maxY,
1320                                       Int_t nbinsPt, Double_t minPt, Double_t maxPt) {
1321   //Initializes the QA binning
1322   fNBinsY = nbinsY;
1323   fMinY = minY; fMaxY = maxY;
1324   fNBinsPt = nbinsPt;
1325   fMinPt = minPt; fMaxPt = maxPt;
1326   InitQA();
1327   InitCutLists();
1328   InitVertexQA();
1329   if(fRunMCAnalysis) InitMCAnalysis();
1330   if(fRunEfficiencyAnalysis) InitEfficiencyAnalysis();
1331 }
1332
1333 //____________________________________________________________________//
1334 void AliProtonQAAnalysis::InitEfficiencyAnalysis() {
1335   //Initialization of the efficiency list - reconstruction & PID efficiency
1336   //Adding each monitored object in the list
1337   fEfficiencyList = new TList();
1338
1339   //MC primary protons and antiprotons for the reconstruction efficiency
1340   TH2D *gHistMCYPtProtons = new TH2D("gHistMCYPtProtons",
1341                                      ";;P_{T} [GeV/c]",
1342                                      fNBinsY,fMinY,fMaxY,
1343                                      fNBinsPt,fMinPt,fMaxPt);
1344   if(fAnalysisEtaMode) 
1345     gHistMCYPtProtons->GetXaxis()->SetTitle("#eta");
1346   else 
1347     gHistMCYPtProtons->GetXaxis()->SetTitle("y");
1348   gHistMCYPtProtons->SetStats(kTRUE);
1349   gHistMCYPtProtons->GetXaxis()->SetTitleColor(1);
1350   fEfficiencyList->Add(gHistMCYPtProtons);
1351   TH2D *gHistMCYPtAntiProtons = new TH2D("gHistMCYPtAntiProtons",
1352                                          ";y;P_{T} [GeV/c]",
1353                                          fNBinsY,fMinY,fMaxY,
1354                                          fNBinsPt,fMinPt,fMaxPt);
1355   if(fAnalysisEtaMode) 
1356     gHistMCYPtAntiProtons->GetXaxis()->SetTitle("#eta");
1357   else 
1358     gHistMCYPtAntiProtons->GetXaxis()->SetTitle("y");
1359   gHistMCYPtAntiProtons->SetStats(kTRUE);
1360   gHistMCYPtAntiProtons->GetXaxis()->SetTitleColor(1);
1361   fEfficiencyList->Add(gHistMCYPtAntiProtons);
1362
1363   //MC secondary protons and antiprotons that come from weak decay for the reconstruction efficiency
1364   TH2D *gHistMCYPtProtonsFromWeak = new TH2D("gHistMCYPtProtonsFromWeak",
1365                                              ";;P_{T} [GeV/c]",
1366                                              fNBinsY,fMinY,fMaxY,
1367                                              fNBinsPt,fMinPt,fMaxPt);
1368   if(fAnalysisEtaMode) 
1369     gHistMCYPtProtonsFromWeak->GetXaxis()->SetTitle("#eta");
1370   else 
1371     gHistMCYPtProtonsFromWeak->GetXaxis()->SetTitle("y");
1372   gHistMCYPtProtonsFromWeak->SetStats(kTRUE);
1373   gHistMCYPtProtonsFromWeak->GetXaxis()->SetTitleColor(1);
1374   fEfficiencyList->Add(gHistMCYPtProtonsFromWeak);
1375   TH2D *gHistMCYPtAntiProtonsFromWeak = new TH2D("gHistMCYPtAntiProtonsFromWeak",
1376                                                  ";y;P_{T} [GeV/c]",
1377                                                  fNBinsY,fMinY,fMaxY,
1378                                                  fNBinsPt,fMinPt,fMaxPt);
1379   if(fAnalysisEtaMode) 
1380     gHistMCYPtAntiProtonsFromWeak->GetXaxis()->SetTitle("#eta");
1381   else 
1382     gHistMCYPtAntiProtonsFromWeak->GetXaxis()->SetTitle("y");
1383   gHistMCYPtAntiProtonsFromWeak->SetStats(kTRUE);
1384   gHistMCYPtAntiProtonsFromWeak->GetXaxis()->SetTitleColor(1);
1385   fEfficiencyList->Add(gHistMCYPtAntiProtonsFromWeak);
1386
1387   //MC secondary protons and antiprotons that come from hadronic interactions for the reconstruction efficiency
1388   TH2D *gHistMCYPtProtonsFromHadronic = new TH2D("gHistMCYPtProtonsFromHadronic",
1389                                                  ";;P_{T} [GeV/c]",
1390                                                  fNBinsY,fMinY,fMaxY,
1391                                                  fNBinsPt,fMinPt,fMaxPt);
1392   if(fAnalysisEtaMode) 
1393     gHistMCYPtProtonsFromHadronic->GetXaxis()->SetTitle("#eta");
1394   else 
1395     gHistMCYPtProtonsFromHadronic->GetXaxis()->SetTitle("y");
1396   gHistMCYPtProtonsFromHadronic->SetStats(kTRUE);
1397   gHistMCYPtProtonsFromHadronic->GetXaxis()->SetTitleColor(1);
1398   fEfficiencyList->Add(gHistMCYPtProtonsFromHadronic);
1399   TH2D *gHistMCYPtAntiProtonsFromHadronic = new TH2D("gHistMCYPtAntiProtonsFromHadronic",
1400                                                      ";y;P_{T} [GeV/c]",
1401                                                      fNBinsY,fMinY,fMaxY,
1402                                                      fNBinsPt,fMinPt,fMaxPt);
1403   if(fAnalysisEtaMode) 
1404     gHistMCYPtAntiProtonsFromHadronic->GetXaxis()->SetTitle("#eta");
1405   else 
1406     gHistMCYPtAntiProtonsFromHadronic->GetXaxis()->SetTitle("y");
1407   gHistMCYPtAntiProtonsFromHadronic->SetStats(kTRUE);
1408   gHistMCYPtAntiProtonsFromHadronic->GetXaxis()->SetTitleColor(1);
1409   fEfficiencyList->Add(gHistMCYPtAntiProtonsFromHadronic);
1410   
1411   //ESD primary protons and antiprotons for the reconstruction efficiency
1412   TH2D *gHistESDYPtProtons = new TH2D("gHistESDYPtProtons",
1413                                       ";;P_{T} [GeV/c]",
1414                                       fNBinsY,fMinY,fMaxY,
1415                                       fNBinsPt,fMinPt,fMaxPt);
1416   if(fAnalysisEtaMode) 
1417     gHistESDYPtProtons->GetXaxis()->SetTitle("#eta");
1418   else 
1419     gHistESDYPtProtons->GetXaxis()->SetTitle("y");
1420   gHistESDYPtProtons->SetStats(kTRUE);
1421   gHistESDYPtProtons->GetXaxis()->SetTitleColor(1);
1422   fEfficiencyList->Add(gHistESDYPtProtons);
1423   TH2D *gHistESDYPtAntiProtons = new TH2D("gHistESDYPtAntiProtons",
1424                                           ";;P_{T} [GeV/c]",
1425                                           fNBinsY,fMinY,fMaxY,
1426                                           fNBinsPt,fMinPt,fMaxPt);
1427   if(fAnalysisEtaMode) 
1428     gHistESDYPtAntiProtons->GetXaxis()->SetTitle("#eta");
1429   else 
1430     gHistESDYPtAntiProtons->GetXaxis()->SetTitle("y");
1431   gHistESDYPtAntiProtons->SetStats(kTRUE);
1432   gHistESDYPtAntiProtons->GetXaxis()->SetTitleColor(1);
1433   fEfficiencyList->Add(gHistESDYPtAntiProtons);
1434
1435   //ESD (anti)protons from weak decays for the reconstruction efficiency
1436   TH2D *gHistESDYPtProtonsFromWeak = new TH2D("gHistESDYPtProtonsFromWeak",
1437                                               ";;P_{T} [GeV/c]",
1438                                               fNBinsY,fMinY,fMaxY,
1439                                               fNBinsPt,fMinPt,fMaxPt);
1440   if(fAnalysisEtaMode) 
1441     gHistESDYPtProtonsFromWeak->GetXaxis()->SetTitle("#eta");
1442   else 
1443     gHistESDYPtProtonsFromWeak->GetXaxis()->SetTitle("y");
1444   gHistESDYPtProtonsFromWeak->SetStats(kTRUE);
1445   gHistESDYPtProtonsFromWeak->GetXaxis()->SetTitleColor(1);
1446   fEfficiencyList->Add(gHistESDYPtProtonsFromWeak);
1447   TH2D *gHistESDYPtAntiProtonsFromWeak = new TH2D("gHistESDYPtAntiProtonsFromWeak",
1448                                                   ";;P_{T} [GeV/c]",
1449                                                   fNBinsY,fMinY,fMaxY,
1450                                                   fNBinsPt,fMinPt,fMaxPt);
1451   if(fAnalysisEtaMode) 
1452     gHistESDYPtAntiProtonsFromWeak->GetXaxis()->SetTitle("#eta");
1453   else 
1454     gHistESDYPtAntiProtonsFromWeak->GetXaxis()->SetTitle("y");
1455   gHistESDYPtAntiProtonsFromWeak->SetStats(kTRUE);
1456   gHistESDYPtAntiProtonsFromWeak->GetXaxis()->SetTitleColor(1);
1457   fEfficiencyList->Add(gHistESDYPtAntiProtonsFromWeak);
1458
1459   //ESD (anti)protons from hadronic interactions for the reconstruction efficiency
1460   TH2D *gHistESDYPtProtonsFromHadronic = new TH2D("gHistESDYPtProtonsFromHadronic",
1461                                                   ";;P_{T} [GeV/c]",
1462                                                   fNBinsY,fMinY,fMaxY,
1463                                                   fNBinsPt,fMinPt,fMaxPt);
1464   if(fAnalysisEtaMode) 
1465     gHistESDYPtProtonsFromHadronic->GetXaxis()->SetTitle("#eta");
1466   else 
1467     gHistESDYPtProtonsFromHadronic->GetXaxis()->SetTitle("y");
1468   gHistESDYPtProtonsFromHadronic->SetStats(kTRUE);
1469   gHistESDYPtProtonsFromHadronic->GetXaxis()->SetTitleColor(1);
1470   fEfficiencyList->Add(gHistESDYPtProtonsFromHadronic);
1471   TH2D *gHistESDYPtAntiProtonsFromHadronic = new TH2D("gHistESDYPtAntiProtonsFromHadronic",
1472                                                       ";;P_{T} [GeV/c]",
1473                                                       fNBinsY,fMinY,fMaxY,
1474                                                       fNBinsPt,fMinPt,fMaxPt);
1475   if(fAnalysisEtaMode) 
1476     gHistESDYPtAntiProtonsFromHadronic->GetXaxis()->SetTitle("#eta");
1477   else 
1478     gHistESDYPtAntiProtonsFromHadronic->GetXaxis()->SetTitle("y");
1479   gHistESDYPtAntiProtonsFromHadronic->SetStats(kTRUE);
1480   gHistESDYPtAntiProtonsFromHadronic->GetXaxis()->SetTitleColor(1);
1481   fEfficiencyList->Add(gHistESDYPtAntiProtonsFromHadronic);
1482   
1483   
1484   //ESD reconstructed tracks that were initially protons for the PID efficiency
1485   TH2D *gHistESDInitYPtProtons = new TH2D("gHistESDInitYPtProtons",
1486                                           ";;P_{T} [GeV/c]",
1487                                           fNBinsY,fMinY,fMaxY,
1488                                           fNBinsPt,fMinPt,fMaxPt);
1489   if(fAnalysisEtaMode) 
1490     gHistESDInitYPtProtons->GetXaxis()->SetTitle("#eta");
1491   else 
1492     gHistESDInitYPtProtons->GetXaxis()->SetTitle("y");
1493   gHistESDInitYPtProtons->SetStats(kTRUE);
1494   gHistESDInitYPtProtons->GetXaxis()->SetTitleColor(1);
1495   fEfficiencyList->Add(gHistESDInitYPtProtons);
1496   
1497   //ESD reconstructed tracks that were initially protons and were identified as protons for the PID efficiency
1498   TH2D *gHistESDIdYPtProtons = new TH2D("gHistESDIdYPtProtons",
1499                                         ";;P_{T} [GeV/c]",
1500                                         fNBinsY,fMinY,fMaxY,
1501                                         fNBinsPt,fMinPt,fMaxPt);
1502   if(fAnalysisEtaMode) 
1503     gHistESDIdYPtProtons->GetXaxis()->SetTitle("#eta");
1504   else 
1505     gHistESDIdYPtProtons->GetXaxis()->SetTitle("y");
1506   gHistESDIdYPtProtons->SetStats(kTRUE);
1507   gHistESDIdYPtProtons->GetXaxis()->SetTitleColor(1);
1508   fEfficiencyList->Add(gHistESDIdYPtProtons);
1509  
1510   //ESD reconstructed tracks that were identified as protons for the PID contamination
1511   TH2D *gHistESDRecIdYPtProtons = new TH2D("gHistESDRecIdYPtProtons",
1512                                            ";;P_{T} [GeV/c]",
1513                                            fNBinsY,fMinY,fMaxY,
1514                                            fNBinsPt,fMinPt,fMaxPt);
1515   if(fAnalysisEtaMode) 
1516     gHistESDRecIdYPtProtons->GetXaxis()->SetTitle("#eta");
1517   else 
1518     gHistESDRecIdYPtProtons->GetXaxis()->SetTitle("y");
1519   gHistESDRecIdYPtProtons->SetStats(kTRUE);
1520   gHistESDRecIdYPtProtons->GetXaxis()->SetTitleColor(1);
1521   fEfficiencyList->Add(gHistESDRecIdYPtProtons);
1522
1523   //ESD reconstructed tracks that were identified as protons but were initially not protons for the PID contamination
1524   TH2D *gHistESDContamYPtProtons = new TH2D("gHistESDContamYPtProtons",
1525                                             ";;P_{T} [GeV/c]",
1526                                             fNBinsY,fMinY,fMaxY,
1527                                             fNBinsPt,fMinPt,fMaxPt);
1528   if(fAnalysisEtaMode) 
1529     gHistESDContamYPtProtons->GetXaxis()->SetTitle("#eta");
1530   else 
1531     gHistESDContamYPtProtons->GetXaxis()->SetTitle("y");
1532   gHistESDContamYPtProtons->SetStats(kTRUE);
1533   gHistESDContamYPtProtons->GetXaxis()->SetTitleColor(1);
1534   fEfficiencyList->Add(gHistESDContamYPtProtons);
1535 }
1536
1537 //____________________________________________________________________//
1538 void AliProtonQAAnalysis::InitCutLists() {
1539   //Initialization of the cut lists
1540   //Adding each monitored object in each list
1541
1542   //Accepted cut list
1543   fAcceptedCutList = new TList();
1544   TH1F *gPrimaryProtonsClustersOnITSLayers = new TH1F("gPrimaryProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
1545   fAcceptedCutList->Add(gPrimaryProtonsClustersOnITSLayers);
1546   TH1F *gPrimaryAntiProtonsClustersOnITSLayers = new TH1F("gPrimaryAntiProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
1547   fAcceptedCutList->Add(gPrimaryAntiProtonsClustersOnITSLayers);
1548   TH1F *gSecondaryProtonsClustersOnITSLayers = new TH1F("gSecondaryProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
1549   fAcceptedCutList->Add(gSecondaryProtonsClustersOnITSLayers);
1550   TH1F *gSecondaryAntiProtonsClustersOnITSLayers = new TH1F("gSecondaryAntiProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
1551   fAcceptedCutList->Add(gSecondaryAntiProtonsClustersOnITSLayers);
1552
1553   TH1F *gPrimaryProtonsNClustersITS = new TH1F("gPrimaryProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
1554   fAcceptedCutList->Add(gPrimaryProtonsNClustersITS);
1555   TH1F *gPrimaryAntiProtonsNClustersITS = new TH1F("gPrimaryAntiProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
1556   fAcceptedCutList->Add(gPrimaryAntiProtonsNClustersITS);
1557   TH1F *gSecondaryProtonsNClustersITS = new TH1F("gSecondaryProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
1558   fAcceptedCutList->Add(gSecondaryProtonsNClustersITS);
1559   TH1F *gSecondaryAntiProtonsNClustersITS = new TH1F("gSecondaryAntiProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
1560   fAcceptedCutList->Add(gSecondaryAntiProtonsNClustersITS);
1561
1562   TH1F *gPrimaryProtonsChi2PerClusterITS = new TH1F("gPrimaryProtonsChi2PerClusterITS",
1563                                                     ";x^{2}/N_{clusters} (ITS);Entries",
1564                                                     100,0,20);
1565   fAcceptedCutList->Add(gPrimaryProtonsChi2PerClusterITS);
1566   TH1F *gPrimaryAntiProtonsChi2PerClusterITS = new TH1F("gPrimaryAntiProtonsChi2PerClusterITS",
1567                                                         ";x^{2}/N_{clusters} (ITS);Entries",
1568                                                         100,0,20);
1569   fAcceptedCutList->Add(gPrimaryAntiProtonsChi2PerClusterITS);
1570   TH1F *gSecondaryProtonsChi2PerClusterITS = new TH1F("gSecondaryProtonsChi2PerClusterITS",
1571                                                       ";x^{2}/N_{clusters} (ITS);Entries",
1572                                                       100,0,20);
1573   fAcceptedCutList->Add(gSecondaryProtonsChi2PerClusterITS);
1574   TH1F *gSecondaryAntiProtonsChi2PerClusterITS = new TH1F("gSecondaryAntiProtonsChi2PerClusterITS",
1575                                                           ";x^{2}/N_{clusters} (ITS);Entries",
1576                                                           100,0,20);
1577   fAcceptedCutList->Add(gSecondaryAntiProtonsChi2PerClusterITS);
1578
1579   TH1F *gPrimaryProtonsConstrainChi2 = new TH1F("gPrimaryProtonsConstrainChi2",
1580                                                 ";Log_{10}(#chi^{2});Entries",
1581                                                 100,-10,10);
1582   fAcceptedCutList->Add(gPrimaryProtonsConstrainChi2);
1583   TH1F *gPrimaryAntiProtonsConstrainChi2 = new TH1F("gPrimaryAntiProtonsConstrainChi2",
1584                                                     ";Log_{10}(#chi^{2});Entries",
1585                                                     100,-10,10);
1586   fAcceptedCutList->Add(gPrimaryAntiProtonsConstrainChi2);
1587   TH1F *gSecondaryProtonsConstrainChi2 = new TH1F("gSecondaryProtonsConstrainChi2",
1588                                                   ";Log_{10}(#chi^{2});Entries",
1589                                                   100,-10,10);
1590   fAcceptedCutList->Add(gSecondaryProtonsConstrainChi2);
1591   TH1F *gSecondaryAntiProtonsConstrainChi2 = new TH1F("gSecondaryAntiProtonsConstrainChi2",
1592                                                       ";Log_{10}(#chi^{2});Entries",
1593                                                       100,-10,10);
1594   fAcceptedCutList->Add(gSecondaryAntiProtonsConstrainChi2);
1595
1596   TH1F *gPrimaryProtonsTPCClusters = new TH1F("gPrimaryProtonsTPCClusters",
1597                                               ";N_{clusters} (TPC);Entries",
1598                                               100,0,200);
1599   fAcceptedCutList->Add(gPrimaryProtonsTPCClusters);
1600   TH1F *gPrimaryAntiProtonsTPCClusters = new TH1F("gPrimaryAntiProtonsTPCClusters",
1601                                                   ";N_{clusters} (TPC);Entries",
1602                                                   100,0,200);
1603   fAcceptedCutList->Add(gPrimaryAntiProtonsTPCClusters);
1604   TH1F *gSecondaryProtonsTPCClusters = new TH1F("gSecondaryProtonsTPCClusters",
1605                                                 ";N_{clusters} (TPC);Entries",
1606                                                 100,0,200);
1607   fAcceptedCutList->Add(gSecondaryProtonsTPCClusters);
1608   TH1F *gSecondaryAntiProtonsTPCClusters = new TH1F("gSecondaryAntiProtonsTPCClusters",
1609                                                     ";N_{clusters} (TPC);Entries",
1610                                                     100,0,200);
1611   fAcceptedCutList->Add(gSecondaryAntiProtonsTPCClusters);
1612
1613   TH1F *gPrimaryProtonsChi2PerClusterTPC = new TH1F("gPrimaryProtonsChi2PerClusterTPC",
1614                                                     ";x^{2}/N_{clusters} (TPC);Entries",
1615                                                     100,0,4);
1616   fAcceptedCutList->Add(gPrimaryProtonsChi2PerClusterTPC);
1617   TH1F *gPrimaryAntiProtonsChi2PerClusterTPC = new TH1F("gPrimaryAntiProtonsChi2PerClusterTPC",
1618                                                         ";x^{2}/N_{clusters} (TPC);Entries",
1619                                                         100,0,4);
1620   fAcceptedCutList->Add(gPrimaryAntiProtonsChi2PerClusterTPC);
1621   TH1F *gSecondaryProtonsChi2PerClusterTPC = new TH1F("gSecondaryProtonsChi2PerClusterTPC",
1622                                                       ";x^{2}/N_{clusters} (TPC);Entries",
1623                                                       100,0,4);
1624   fAcceptedCutList->Add(gSecondaryProtonsChi2PerClusterTPC);
1625   TH1F *gSecondaryAntiProtonsChi2PerClusterTPC = new TH1F("gSecondaryAntiProtonsChi2PerClusterTPC",
1626                                                           ";x^{2}/N_{clusters} (TPC);Entries",
1627                                                           100,0,4);
1628   fAcceptedCutList->Add(gSecondaryAntiProtonsChi2PerClusterTPC);
1629
1630   TH1F *gPrimaryProtonsExtCov11 = new TH1F("gPrimaryProtonsExtCov11",
1631                                            ";#sigma_{y} [cm];Entries",
1632                                            100,0,4);
1633   fAcceptedCutList->Add(gPrimaryProtonsExtCov11);
1634   TH1F *gPrimaryAntiProtonsExtCov11 = new TH1F("gPrimaryAntiProtonsExtCov11",
1635                                                ";#sigma_{y} [cm];Entries",
1636                                                100,0,4);
1637   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov11);
1638   TH1F *gSecondaryProtonsExtCov11 = new TH1F("gSecondaryProtonsExtCov11",
1639                                              ";#sigma_{y} [cm];Entries",
1640                                              100,0,4);
1641   fAcceptedCutList->Add(gSecondaryProtonsExtCov11);
1642   TH1F *gSecondaryAntiProtonsExtCov11 = new TH1F("gSecondaryAntiProtonsExtCov11",
1643                                                  ";#sigma_{y} [cm];Entries",
1644                                                  100,0,4);
1645   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov11);
1646
1647
1648   TH1F *gPrimaryProtonsExtCov22 = new TH1F("gPrimaryProtonsExtCov22",
1649                                            ";#sigma_{z} [cm];Entries",
1650                                            100,0,4);
1651   fAcceptedCutList->Add(gPrimaryProtonsExtCov22);
1652   TH1F *gPrimaryAntiProtonsExtCov22 = new TH1F("gPrimaryAntiProtonsExtCov22",
1653                                                ";#sigma_{z} [cm];Entries",
1654                                                100,0,4);
1655   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov22);
1656   TH1F *gSecondaryProtonsExtCov22 = new TH1F("gSecondaryProtonsExtCov22",
1657                                              ";#sigma_{z} [cm];Entries",
1658                                              100,0,4);
1659   fAcceptedCutList->Add(gSecondaryProtonsExtCov22);
1660   TH1F *gSecondaryAntiProtonsExtCov22 = new TH1F("gSecondaryAntiProtonsExtCov22",
1661                                                  ";#sigma_{z} [cm];Entries",
1662                                                  100,0,4);
1663   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov22);
1664
1665
1666   TH1F *gPrimaryProtonsExtCov33 = new TH1F("gPrimaryProtonsExtCov33",
1667                                            ";#sigma_{sin(#phi)};Entries",
1668                                            100,0,4);
1669   fAcceptedCutList->Add(gPrimaryProtonsExtCov33);
1670   TH1F *gPrimaryAntiProtonsExtCov33 = new TH1F("gPrimaryAntiProtonsExtCov33",
1671                                                ";#sigma_{sin(#phi)};Entries",
1672                                                100,0,4);
1673   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov33);
1674   TH1F *gSecondaryProtonsExtCov33 = new TH1F("gSecondaryProtonsExtCov33",
1675                                              ";#sigma_{sin(#phi)};Entries",
1676                                              100,0,4);
1677   fAcceptedCutList->Add(gSecondaryProtonsExtCov33);
1678   TH1F *gSecondaryAntiProtonsExtCov33 = new TH1F("gSecondaryAntiProtonsExtCov33",
1679                                                  ";#sigma_{sin(#phi)};Entries",
1680                                                  100,0,4);
1681   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov33);
1682
1683
1684   TH1F *gPrimaryProtonsExtCov44 = new TH1F("gPrimaryProtonsExtCov44",
1685                                            ";#sigma_{tan(#lambda)};Entries",
1686                                            100,0,4);
1687   fAcceptedCutList->Add(gPrimaryProtonsExtCov44);
1688   TH1F *gPrimaryAntiProtonsExtCov44 = new TH1F("gPrimaryAntiProtonsExtCov44",
1689                                                ";#sigma_{tan(#lambda)};Entries",
1690                                                100,0,4);
1691   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov44);
1692   TH1F *gSecondaryProtonsExtCov44 = new TH1F("gSecondaryProtonsExtCov44",
1693                                              ";#sigma_{tan(#lambda)};Entries",
1694                                              100,0,4);
1695   fAcceptedCutList->Add(gSecondaryProtonsExtCov44);
1696   TH1F *gSecondaryAntiProtonsExtCov44 = new TH1F("gSecondaryAntiProtonsExtCov44",
1697                                                  ";#sigma_{tan(#lambda)};Entries",
1698                                                  100,0,4);
1699   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov44);
1700
1701
1702   TH1F *gPrimaryProtonsExtCov55 = new TH1F("gPrimaryProtonsExtCov55",
1703                                            ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1704                                            100,0,4);
1705   fAcceptedCutList->Add(gPrimaryProtonsExtCov55);
1706   TH1F *gPrimaryAntiProtonsExtCov55 = new TH1F("gPrimaryAntiProtonsExtCov55",
1707                                                ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1708                                                100,0,4);
1709   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov55);
1710   TH1F *gSecondaryProtonsExtCov55 = new TH1F("gSecondaryProtonsExtCov55",
1711                                              ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1712                                              100,0,4);
1713   fAcceptedCutList->Add(gSecondaryProtonsExtCov55);
1714   TH1F *gSecondaryAntiProtonsExtCov55 = new TH1F("gSecondaryAntiProtonsExtCov55",
1715                                                  ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1716                                                  100,0,4);
1717   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov55);
1718
1719   //DCA list
1720   fAcceptedDCAList = new TList();
1721   TH1F *gPrimaryProtonsDCAXY = new TH1F("gPrimaryProtonsDCAXY",
1722                                         ";DCA_{xy} [cm];Entries",
1723                                         100,0,20);
1724   fAcceptedDCAList->Add(gPrimaryProtonsDCAXY);
1725   TH1F *gPrimaryAntiProtonsDCAXY = new TH1F("gPrimaryAntiProtonsDCAXY",
1726                                             ";DCA_{xy} [cm];Entries",
1727                                             100,0,20);
1728   fAcceptedDCAList->Add(gPrimaryAntiProtonsDCAXY);
1729   TH1F *gSecondaryProtonsDCAXY = new TH1F("gSecondaryProtonsDCAXY",
1730                                           ";DCA_{xy} [cm];Entries",
1731                                           100,0,20);
1732   fAcceptedDCAList->Add(gSecondaryProtonsDCAXY);
1733   TH1F *gSecondaryAntiProtonsDCAXY = new TH1F("gSecondaryAntiProtonsDCAXY",
1734                                               ";DCA_{xy} [cm];Entries",
1735                                               100,0,20);
1736
1737   fAcceptedDCAList->Add(gSecondaryAntiProtonsDCAXY);
1738   TH1F *gPrimaryProtonsDCAZ = new TH1F("gPrimaryProtonsDCAZ",
1739                                        ";DCA_{z} [cm];Entries",
1740                                        100,0,20);
1741   fAcceptedDCAList->Add(gPrimaryProtonsDCAZ);
1742   TH1F *gPrimaryAntiProtonsDCAZ = new TH1F("gPrimaryAntiProtonsDCAZ",
1743                                            ";DCA_{z} [cm];Entries",
1744                                            100,0,20);
1745   fAcceptedDCAList->Add(gPrimaryAntiProtonsDCAZ);
1746   TH1F *gSecondaryProtonsDCAZ = new TH1F("gSecondaryProtonsDCAZ",
1747                                          ";DCA_{z} [cm];Entries",
1748                                          100,0,20);
1749   fAcceptedDCAList->Add(gSecondaryProtonsDCAZ);
1750   TH1F *gSecondaryAntiProtonsDCAZ = new TH1F("gSecondaryAntiProtonsDCAZ",
1751                                              ";DCA_{z} [cm];Entries",
1752                                              100,0,20);
1753   fAcceptedDCAList->Add(gSecondaryAntiProtonsDCAZ);
1754
1755   TH1F *gPrimaryProtonsSigmaToVertex = new TH1F("gPrimaryProtonsSigmaToVertex",
1756                                                 ";#sigma_{Vertex};Entries",
1757                                                 100,0,10);
1758   fAcceptedDCAList->Add(gPrimaryProtonsSigmaToVertex);
1759   TH1F *gPrimaryAntiProtonsSigmaToVertex = new TH1F("gPrimaryAntiProtonsSigmaToVertex",
1760                                                     ";#sigma_{Vertex};Entries",
1761                                                     100,0,10);
1762   fAcceptedDCAList->Add(gPrimaryAntiProtonsSigmaToVertex);
1763   TH1F *gSecondaryProtonsSigmaToVertex = new TH1F("gSecondaryProtonsSigmaToVertex",
1764                                                   ";#sigma_{Vertex};Entries",
1765                                                   100,0,10);
1766   fAcceptedDCAList->Add(gSecondaryProtonsSigmaToVertex);
1767   TH1F *gSecondaryAntiProtonsSigmaToVertex = new TH1F("gSecondaryAntiProtonsSigmaToVertex",
1768                                                       ";#sigma_{Vertex};Entries",
1769                                                       100,0,10);
1770   fAcceptedDCAList->Add(gSecondaryAntiProtonsSigmaToVertex);
1771
1772 }
1773
1774 //____________________________________________________________________//
1775 void AliProtonQAAnalysis::InitVertexQA() {
1776   //Initializes the Vertex QA histograms
1777   fQAVertexList = new TList();
1778   fQAVertexList->SetName("fQAVertexList");
1779
1780   //MC primary multiplicity (vertex efficiency calculation)
1781   TH1I *gHistMCPrimaryMultiplicity = new TH1I("gHistMCPrimaryMultiplicity",
1782                                               ";N_{prim. gen.};Entries",
1783                                               1000,0,2000);
1784   fQAVertexList->Add(gHistMCPrimaryMultiplicity);
1785   
1786   //TPC
1787   TH1I *gHistMCPrimaryMultiplicityTPC = new TH1I("gHistMCPrimaryMultiplicityTPC",
1788                                                  ";N_{prim. gen.};Entries",
1789                                                  1000,0,2000);
1790   fQAVertexList->Add(gHistMCPrimaryMultiplicityTPC);
1791   TH2F *gHistTPCESDVx = new TH2F("gHistTPCESDVx",
1792                                  "Primary vertex TPC;V_{x} [cm];N_{contributors}",
1793                                  100,-10.,10.,100,0,100);
1794   fQAVertexList->Add(gHistTPCESDVx);
1795   TH2F *gHistTPCESDVy = new TH2F("gHistTPCESDVy",
1796                                  "Primary vertex TPC;V_{y} [cm];N_{contributors}",
1797                                  100,-10.,10.,100,0,100);
1798   fQAVertexList->Add(gHistTPCESDVy);
1799   TH2F *gHistTPCESDVz = new TH2F("gHistTPCESDVz",
1800                                  "Primary vertex TPC;V_{z} [cm];N_{contributors}",
1801                                  100,-20.,20.,100,0,100);
1802   fQAVertexList->Add(gHistTPCESDVz);
1803   TH1F *gHistTPCDiffVx = new TH1F("gHistTPCDiffVx",
1804                                   ";V_{x}(rec.) - V_{x}(true) [#mu m];Entries",
1805                                   100,-10000.,10000.);
1806   fQAVertexList->Add(gHistTPCDiffVx);
1807   TH1F *gHistTPCDiffVy = new TH1F("gHistTPCDiffVy",
1808                                   ";V_{y}(rec.) - V_{y}(true) [#mu m];Entries",
1809                                   100,-10000.,10000.);
1810   fQAVertexList->Add(gHistTPCDiffVy);
1811   TH1F *gHistTPCDiffVz = new TH1F("gHistTPCDiffVz",
1812                                   ";V_{z}(rec.) - V_{z}(true) [#mu m];Entries",
1813                                   100,-10000.,10000.);
1814   fQAVertexList->Add(gHistTPCDiffVz);
1815   TH1F *gHistTPCResolutionVx = new TH1F("gHistTPCResolutionVx",
1816                                         ";#sigma_{x} [#mu m];Entries",
1817                                         100,0.,1000.);
1818   fQAVertexList->Add(gHistTPCResolutionVx);
1819   TH1F *gHistTPCResolutionVy = new TH1F("gHistTPCResolutionVy",
1820                                         ";#sigma_{y} [#mu m];Entries",
1821                                         100,0.,1000.);
1822   fQAVertexList->Add(gHistTPCResolutionVy);
1823   TH1F *gHistTPCResolutionVz = new TH1F("gHistTPCResolutionVz",
1824                                         ";#sigma_{z} [#mu m];Entries",
1825                                         100,0.,500.);
1826   fQAVertexList->Add(gHistTPCResolutionVz);
1827   
1828   //SPD
1829   TH1I *gHistMCPrimaryMultiplicitySPD = new TH1I("gHistMCPrimaryMultiplicitySPD",
1830                                                  ";N_{prim. gen.};Entries",
1831                                                  1000,0,2000);
1832   fQAVertexList->Add(gHistMCPrimaryMultiplicitySPD);
1833   TH2F *gHistSPDESDVx = new TH2F("gHistSPDESDVx",
1834                                  "Primary vertex SPD;V_{x} [cm];N_{contributors}",
1835                                  100,-10.,10.,100,0,100);
1836   fQAVertexList->Add(gHistSPDESDVx);
1837   TH2F *gHistSPDESDVy = new TH2F("gHistSPDESDVy",
1838                                  "Primary vertex SPD;V_{y} [cm];N_{contributors}",
1839                                  100,-10.,10.,100,0,100);
1840   fQAVertexList->Add(gHistSPDESDVy);
1841   TH2F *gHistSPDESDVz = new TH2F("gHistSPDESDVz",
1842                                  "Primary vertex SPD;V_{z} [cm];N_{contributors}",
1843                                  100,-20.,20.,100,0,100);
1844   fQAVertexList->Add(gHistSPDESDVz);
1845   TH1F *gHistSPDDiffVx = new TH1F("gHistSPDDiffVx",
1846                                   ";V_{x}(rec.) - V_{x}(true) [#mu m];Entries",
1847                                   100,-10000.,10000.);
1848   fQAVertexList->Add(gHistSPDDiffVx);
1849   TH1F *gHistSPDDiffVy = new TH1F("gHistSPDDiffVy",
1850                                   ";V_{y}(rec.) - V_{y}(true) [#mu m];Entries",
1851                                   100,-10000.,10000.);
1852   fQAVertexList->Add(gHistSPDDiffVy);
1853   TH1F *gHistSPDDiffVz = new TH1F("gHistSPDDiffVz",
1854                                   ";V_{z}(rec.) - V_{z}(true) [#mu m];Entries",
1855                                   100,-10000.,10000.);
1856   fQAVertexList->Add(gHistSPDDiffVz);
1857   TH1F *gHistSPDResolutionVx = new TH1F("gHistSPDResolutionVx",
1858                                         ";#sigma_{x} [#mu m];Entries",
1859                                         100,0.,1000.);
1860   fQAVertexList->Add(gHistSPDResolutionVx);
1861   TH1F *gHistSPDResolutionVy = new TH1F("gHistSPDResolutionVy",
1862                                         ";#sigma_{y} [#mu m];Entries",
1863                                         100,0.,1000.);
1864   fQAVertexList->Add(gHistSPDResolutionVy);
1865   TH1F *gHistSPDResolutionVz = new TH1F("gHistSPDResolutionVz",
1866                                         ";#sigma_{z} [#mu m];Entries",
1867                                         100,0.,500.);
1868   fQAVertexList->Add(gHistSPDResolutionVz);
1869   
1870   //Tracks
1871   TH1I *gHistMCPrimaryMultiplicityTracks = new TH1I("gHistMCPrimaryMultiplicityTracks",
1872                                                     ";N_{prim. gen.};Entries",
1873                                                     1000,0,2000);
1874   fQAVertexList->Add(gHistMCPrimaryMultiplicityTracks);
1875   TH2F *gHistTracksESDVx = new TH2F("gHistTracksESDVx",
1876                                     "Primary vertex Tracks;V_{x} [cm];N_{contributors}",
1877                                     100,-10.,10.,100,0,100);
1878   fQAVertexList->Add(gHistTracksESDVx);
1879   TH2F *gHistTracksESDVy = new TH2F("gHistTracksESDVy",
1880                                     "Primary vertex Tracks;V_{y} [cm];N_{contributors}",
1881                                     100,-10.,10.,100,0,100);
1882   fQAVertexList->Add(gHistTracksESDVy);
1883   TH2F *gHistTracksESDVz = new TH2F("gHistTracksESDVz",
1884                                     "Primary vertex Tracks;V_{z} [cm];N_{contributors}",
1885                                     100,-20.,20.,100,0,100);
1886   fQAVertexList->Add(gHistTracksESDVz);
1887   TH1F *gHistTracksDiffVx = new TH1F("gHistTracksDiffVx",
1888                                      ";V_{x}(rec.) - V_{x}(true) [#mu m];Entries",
1889                                      100,-10000.,10000.);
1890   fQAVertexList->Add(gHistTracksDiffVx);
1891   TH1F *gHistTracksDiffVy = new TH1F("gHistTracksDiffVy",
1892                                      ";V_{y}(rec.) - V_{y}(true) [#mu m];Entries",
1893                                      100,-10000.,10000.);
1894   fQAVertexList->Add(gHistTracksDiffVy);
1895   TH1F *gHistTracksDiffVz = new TH1F("gHistTracksDiffVz",
1896                                      ";V_{z}(rec.) - V_{z}(true) [#mu m];Entries",
1897                                      100,-10000.,10000.);
1898   fQAVertexList->Add(gHistTracksDiffVz);
1899   TH1F *gHistTracksResolutionVx = new TH1F("gHistTracksResolutionVx",
1900                                            ";#sigma_{x} [#mu m];Entries",
1901                                            100,0.,1000.);
1902   fQAVertexList->Add(gHistTracksResolutionVx);
1903   TH1F *gHistTracksResolutionVy = new TH1F("gHistTracksResolutionVy",
1904                                            ";#sigma_{y} [#mu m];Entries",
1905                                            100,0.,1000.);
1906   fQAVertexList->Add(gHistTracksResolutionVy);
1907   TH1F *gHistTracksResolutionVz = new TH1F("gHistTracksResolutionVz",
1908                                            ";#sigma_{z} [#mu m];Entries",
1909                                            100,0.,500.);
1910   fQAVertexList->Add(gHistTracksResolutionVz);
1911 }
1912
1913 //____________________________________________________________________//
1914 void AliProtonQAAnalysis::InitQA() {
1915   //Initializes the QA histograms
1916   //if(!fQAHistograms) 
1917   SetRunQAAnalysis();
1918
1919   //2D histograms
1920   //TDirectory *dir2D = gDirectory->mkdir("2D");
1921   //fGlobalQAList->Add(dir2D); dir2D->cd();
1922   TH2D *gHistYPtPrimaryProtonsPass = new TH2D("gHistYPtPrimaryProtonsPass",
1923                                               ";;P_{T} [GeV/c]",
1924                                               fNBinsY,fMinY,fMaxY,
1925                                               fNBinsPt,fMinPt,fMaxPt);
1926   if(fAnalysisEtaMode) 
1927     gHistYPtPrimaryProtonsPass->GetXaxis()->SetTitle("#eta");
1928   else 
1929     gHistYPtPrimaryProtonsPass->GetXaxis()->SetTitle("y");
1930   gHistYPtPrimaryProtonsPass->SetStats(kTRUE);
1931   gHistYPtPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
1932   fQA2DList->Add(gHistYPtPrimaryProtonsPass);//y-pT of primary accepted ESD protons
1933   TH2D *gHistYPtPrimaryProtonsReject = new TH2D("gHistYPtPrimaryProtonsReject",
1934                                                 ";;P_{T} [GeV/c]",
1935                                                 fNBinsY,fMinY,fMaxY,
1936                                                 fNBinsPt,fMinPt,fMaxPt);
1937   if(fAnalysisEtaMode) 
1938     gHistYPtPrimaryProtonsReject->GetXaxis()->SetTitle("#eta");
1939   else 
1940     gHistYPtPrimaryProtonsReject->GetXaxis()->SetTitle("y");
1941   gHistYPtPrimaryProtonsReject->SetStats(kTRUE);
1942   gHistYPtPrimaryProtonsReject->GetXaxis()->SetTitleColor(1);
1943   fQA2DList->Add(gHistYPtPrimaryProtonsReject);//y-pT of primary rejected ESD protons
1944
1945   TH2D *gHistYPtSecondaryProtonsPass = new TH2D("gHistYPtSecondaryProtonsPass",
1946                                                 ";;P_{T} [GeV/c]",
1947                                                 fNBinsY,fMinY,fMaxY,
1948                                                 fNBinsPt,fMinPt,fMaxPt);
1949   if(fAnalysisEtaMode) 
1950     gHistYPtSecondaryProtonsPass->GetXaxis()->SetTitle("#eta");
1951   else 
1952     gHistYPtSecondaryProtonsPass->GetXaxis()->SetTitle("y");
1953   gHistYPtSecondaryProtonsPass->SetStats(kTRUE);
1954   gHistYPtSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
1955   fQA2DList->Add(gHistYPtSecondaryProtonsPass);//y-pT of secondary accepted ESD protons
1956   TH2D *gHistYPtSecondaryProtonsReject = new TH2D("gHistYPtSecondaryProtonsReject",
1957                                                   ";;P_{T} [GeV/c]",
1958                                                   fNBinsY,fMinY,fMaxY,
1959                                                   fNBinsPt,fMinPt,fMaxPt);
1960   if(fAnalysisEtaMode) 
1961     gHistYPtSecondaryProtonsReject->GetXaxis()->SetTitle("#eta");
1962   else 
1963     gHistYPtSecondaryProtonsReject->GetXaxis()->SetTitle("y");
1964   gHistYPtSecondaryProtonsReject->SetStats(kTRUE);
1965   gHistYPtSecondaryProtonsReject->GetXaxis()->SetTitleColor(1);
1966   fQA2DList->Add(gHistYPtSecondaryProtonsReject);//y-pT of secondary rejected ESD protons
1967
1968   TH2D *gHistYPtPrimaryAntiProtonsPass = new TH2D("gHistYPtPrimaryAntiProtonsPass",
1969                                                   ";;P_{T} [GeV/c]",
1970                                                   fNBinsY,fMinY,fMaxY,
1971                                                   fNBinsPt,fMinPt,fMaxPt);
1972   if(fAnalysisEtaMode) 
1973     gHistYPtPrimaryAntiProtonsPass->GetXaxis()->SetTitle("#eta");
1974   else 
1975     gHistYPtPrimaryAntiProtonsPass->GetXaxis()->SetTitle("y");
1976   gHistYPtPrimaryAntiProtonsPass->SetStats(kTRUE);
1977   gHistYPtPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
1978   fQA2DList->Add(gHistYPtPrimaryAntiProtonsPass);//y-pT of primary accepted ESD antiprotons
1979   TH2D *gHistYPtPrimaryAntiProtonsReject = new TH2D("gHistYPtPrimaryAntiProtonsReject",
1980                                                     ";;P_{T} [GeV/c]",
1981                                                     fNBinsY,fMinY,fMaxY,
1982                                                     fNBinsPt,fMinPt,fMaxPt);
1983   if(fAnalysisEtaMode) 
1984     gHistYPtPrimaryAntiProtonsReject->GetXaxis()->SetTitle("#eta");
1985   else 
1986     gHistYPtPrimaryAntiProtonsReject->GetXaxis()->SetTitle("y");
1987   gHistYPtPrimaryAntiProtonsReject->SetStats(kTRUE);
1988   gHistYPtPrimaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
1989   fQA2DList->Add(gHistYPtPrimaryAntiProtonsReject);//y-pT of primary rejected ESD antiprotons
1990
1991   TH2D *gHistYPtSecondaryAntiProtonsPass = new TH2D("gHistYPtSecondaryAntiProtonsPass",
1992                                                     ";;P_{T} [GeV/c]",
1993                                                     fNBinsY,fMinY,fMaxY,
1994                                                     fNBinsPt,fMinPt,fMaxPt);
1995   if(fAnalysisEtaMode) 
1996     gHistYPtSecondaryAntiProtonsPass->GetXaxis()->SetTitle("#eta");
1997   else 
1998     gHistYPtSecondaryAntiProtonsPass->GetXaxis()->SetTitle("y");
1999   gHistYPtSecondaryAntiProtonsPass->SetStats(kTRUE);
2000   gHistYPtSecondaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
2001   fQA2DList->Add(gHistYPtSecondaryAntiProtonsPass);//y-pT of secondary accepted ESD antiprotons
2002   TH2D *gHistYPtSecondaryAntiProtonsReject = new TH2D("gHistYPtSecondaryAntiProtonsReject",
2003                                                       ";;P_{T} [GeV/c]",
2004                                                       fNBinsY,fMinY,fMaxY,
2005                                                       fNBinsPt,fMinPt,fMaxPt);
2006   if(fAnalysisEtaMode) 
2007     gHistYPtSecondaryAntiProtonsReject->GetXaxis()->SetTitle("#eta");
2008   else 
2009     gHistYPtSecondaryAntiProtonsReject->GetXaxis()->SetTitle("y");
2010   gHistYPtSecondaryAntiProtonsReject->SetStats(kTRUE);
2011   gHistYPtSecondaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
2012   fQA2DList->Add(gHistYPtSecondaryAntiProtonsReject);//y-pT of secondary rejected ESD antiprotons
2013
2014   TH2D *gHistYPtPrimaryProtonsMC = new TH2D("gHistYPtPrimaryProtonsMC",
2015                                             ";;P_{T} [GeV/c]",
2016                                             fNBinsY,fMinY,fMaxY,
2017                                             fNBinsPt,fMinPt,fMaxPt);
2018   if(fAnalysisEtaMode) 
2019     gHistYPtPrimaryProtonsMC->GetXaxis()->SetTitle("#eta");
2020   else 
2021     gHistYPtPrimaryProtonsMC->GetXaxis()->SetTitle("y");
2022   gHistYPtPrimaryProtonsMC->SetStats(kTRUE);
2023   gHistYPtPrimaryProtonsMC->GetXaxis()->SetTitleColor(1);
2024   fQA2DList->Add(gHistYPtPrimaryProtonsMC);//y-pT of primary MC protons
2025   TH2D *gHistYPtPrimaryAntiProtonsMC = new TH2D("gHistYPtPrimaryAntiProtonsMC",
2026                                                 ";;P_{T} [GeV/c]",
2027                                                 fNBinsY,fMinY,fMaxY,
2028                                                 fNBinsPt,fMinPt,fMaxPt);
2029   if(fAnalysisEtaMode) 
2030     gHistYPtPrimaryAntiProtonsMC->GetXaxis()->SetTitle("#eta");
2031   else 
2032     gHistYPtPrimaryAntiProtonsMC->GetXaxis()->SetTitle("y");
2033   gHistYPtPrimaryAntiProtonsMC->SetStats(kTRUE);
2034   gHistYPtPrimaryAntiProtonsMC->GetXaxis()->SetTitleColor(1);
2035   fQA2DList->Add(gHistYPtPrimaryAntiProtonsMC);//y-pT of primary MC antiprotons
2036
2037   TH3F *gHistYPtPDGProtonsPass = new TH3F("gHistYPtPDGProtonsPass",
2038                                           ";;P_{T} [GeV/c];PDG",
2039                                           fNBinsY,fMinY,fMaxY,
2040                                           fNBinsPt,fMinPt,fMaxPt,
2041                                           14,-0.5,13.5);
2042   if(fAnalysisEtaMode) 
2043     gHistYPtPDGProtonsPass->GetXaxis()->SetTitle("#eta");
2044   else 
2045     gHistYPtPDGProtonsPass->GetXaxis()->SetTitle("y");
2046   fQA2DList->Add(gHistYPtPDGProtonsPass);//composition of secondary protons
2047   TH3F *gHistYPtPDGAntiProtonsPass = new TH3F("gHistYPtPDGAntiProtonsPass",
2048                                               ";;P_{T} [GeV/c];PDG",
2049                                               fNBinsY,fMinY,fMaxY,
2050                                               fNBinsPt,fMinPt,fMaxPt,
2051                                               14,-0.5,13.5);
2052   if(fAnalysisEtaMode) 
2053     gHistYPtPDGAntiProtonsPass->GetXaxis()->SetTitle("#eta");
2054   else 
2055     gHistYPtPDGAntiProtonsPass->GetXaxis()->SetTitle("y");
2056   fQA2DList->Add(gHistYPtPDGAntiProtonsPass);//composition of secondary antiprotons
2057
2058   //eta-phi
2059   TH2D *gHistEtaPhiPrimaryProtonsPass = new TH2D("gHistEtaPhiPrimaryProtonsPass",
2060                                                  ";#eta;#phi [deg.]",
2061                                                  fNBinsY,fMinY,fMaxY,
2062                                                  100,0.,360.);
2063   gHistEtaPhiPrimaryProtonsPass->SetStats(kTRUE);
2064   gHistEtaPhiPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
2065   fQA2DList->Add(gHistEtaPhiPrimaryProtonsPass);//eta-phi of primary accepted ESD protons
2066   TH2D *gHistEtaPhiPrimaryProtonsReject = new TH2D("gHistEtaPhiPrimaryProtonsReject",
2067                                                    ";#eta;#phi [deg.]",
2068                                                    fNBinsY,fMinY,fMaxY,
2069                                                    100,0.,360.);
2070   gHistEtaPhiPrimaryProtonsReject->SetStats(kTRUE);
2071   gHistEtaPhiPrimaryProtonsReject->GetXaxis()->SetTitleColor(1);
2072   fQA2DList->Add(gHistEtaPhiPrimaryProtonsReject);//eta-phi of primary rejected ESD protons
2073   TH2D *gHistEtaPhiSecondaryProtonsPass = new TH2D("gHistEtaPhiSecondaryProtonsPass",
2074                                                    ";#eta;#phi [deg.]",
2075                                                    fNBinsY,fMinY,fMaxY,
2076                                                    100,0.,360.);
2077   gHistEtaPhiSecondaryProtonsPass->SetStats(kTRUE);
2078   gHistEtaPhiSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
2079   fQA2DList->Add(gHistEtaPhiSecondaryProtonsPass);//eta-phi of secondary accepted ESD protons
2080   TH2D *gHistEtaPhiSecondaryProtonsReject = new TH2D("gHistEtaPhiSecondaryProtonsReject",
2081                                                      ";#eta;#phi [deg.]",
2082                                                      fNBinsY,fMinY,fMaxY,
2083                                                      100,0.,360.);
2084   gHistEtaPhiSecondaryProtonsReject->SetStats(kTRUE);
2085   gHistEtaPhiSecondaryProtonsReject->GetXaxis()->SetTitleColor(1);
2086   fQA2DList->Add(gHistEtaPhiSecondaryProtonsReject);//eta-phi of secondary rejected ESD protons
2087
2088   TH2D *gHistEtaPhiPrimaryAntiProtonsPass = new TH2D("gHistEtaPhiPrimaryAntiProtonsPass",
2089                                                      ";#eta;#phi [deg.]",
2090                                                      fNBinsY,fMinY,fMaxY,
2091                                                      100,0.,360.);
2092   gHistEtaPhiPrimaryAntiProtonsPass->SetStats(kTRUE);
2093   gHistEtaPhiPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
2094   fQA2DList->Add(gHistEtaPhiPrimaryAntiProtonsPass);//eta-phi of primary accepted ESD antiprotons
2095   TH2D *gHistEtaPhiPrimaryAntiProtonsReject = new TH2D("gHistEtaPhiPrimaryAntiProtonsReject",
2096                                                        ";#eta;#phi [deg.]",
2097                                                        fNBinsY,fMinY,fMaxY,
2098                                                        100,0.,360.);
2099   gHistEtaPhiPrimaryAntiProtonsReject->SetStats(kTRUE);
2100   gHistEtaPhiPrimaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
2101   fQA2DList->Add(gHistEtaPhiPrimaryAntiProtonsReject);//eta-phi of primary rejected ESD antiprotons
2102   TH2D *gHistEtaPhiSecondaryAntiProtonsPass = new TH2D("gHistEtaPhiSecondaryAntiProtonsPass",
2103                                                        ";#eta;#phi [deg.]",
2104                                                        fNBinsY,fMinY,fMaxY,
2105                                                        100,0.,360.);
2106   gHistEtaPhiSecondaryAntiProtonsPass->SetStats(kTRUE);
2107   gHistEtaPhiSecondaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
2108   fQA2DList->Add(gHistEtaPhiSecondaryAntiProtonsPass);//eta-phi of secondary accepted ESD antiprotons
2109   TH2D *gHistEtaPhiSecondaryAntiProtonsReject = new TH2D("gHistEtaPhiSecondaryAntiProtonsReject",
2110                                                          ";#eta;#phi [deg.]",
2111                                                          fNBinsY,fMinY,fMaxY,
2112                                                          100,0.,360.);
2113   gHistEtaPhiSecondaryAntiProtonsReject->SetStats(kTRUE);
2114   gHistEtaPhiSecondaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
2115   fQA2DList->Add(gHistEtaPhiSecondaryAntiProtonsReject);//eta-phi of secondary rejected ESD antiprotons
2116
2117   /*gDirectory->cd("../");
2118   //protons
2119   TDirectory *dirProtons = gDirectory->mkdir("Protons");
2120   fGlobalQAList->Add(dirProtons); dirProtons->cd();*/
2121   
2122   //________________________________________________________________//
2123   /*TDirectory *dirProtonsPrimary = gDirectory->mkdir("Primaries");
2124   dirProtonsPrimary->cd();
2125   TDirectory *dirProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
2126   dirProtonsPrimaryAccepted->cd();*/
2127
2128   //Accepted primary protons
2129   TH1F *gPrimaryProtonsITSClustersPass = new TH1F("gPrimaryProtonsITSClustersPass",
2130                                             ";N_{clusters} (ITS);Entries",
2131                                             7,0,7);
2132   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsITSClustersPass);
2133   TH1F *gPrimaryProtonsChi2PerClusterITSPass = new TH1F("gPrimaryProtonsChi2PerClusterITSPass",
2134                                                   ";x^{2}/N_{clusters} (ITS);Entries",
2135                                                   100,0,4);
2136   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsChi2PerClusterITSPass);
2137   TH1F *gPrimaryProtonsTPCClustersPass = new TH1F("gPrimaryProtonsTPCClustersPass",
2138                                             ";N_{clusters} (TPC);Entries",
2139                                             100,0,200);
2140   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsTPCClustersPass);
2141   TH1F *gPrimaryProtonsChi2PerClusterTPCPass = new TH1F("gPrimaryProtonsChi2PerClusterTPCPass",
2142                                                   ";x^{2}/N_{clusters} (TPC);Entries",
2143                                                   100,0,4);
2144   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsChi2PerClusterTPCPass);
2145   TH1F *gPrimaryProtonsExtCov11Pass = new TH1F("gPrimaryProtonsExtCov11Pass",
2146                                          ";#sigma_{y} [cm];Entries",
2147                                          100,0,4);
2148   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov11Pass);
2149   TH1F *gPrimaryProtonsExtCov22Pass = new TH1F("gPrimaryProtonsExtCov22Pass",
2150                                          ";#sigma_{z} [cm];Entries",
2151                                          100,0,4);
2152   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov22Pass);
2153   TH1F *gPrimaryProtonsExtCov33Pass = new TH1F("gPrimaryProtonsExtCov33Pass",
2154                                          ";#sigma_{sin(#phi)};Entries",
2155                                          100,0,4);
2156   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov33Pass);
2157   TH1F *gPrimaryProtonsExtCov44Pass = new TH1F("gPrimaryProtonsExtCov44Pass",
2158                                          ";#sigma_{tan(#lambda)};Entries",
2159                                          100,0,4);
2160   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov44Pass);
2161   TH1F *gPrimaryProtonsExtCov55Pass = new TH1F("gPrimaryProtonsExtCov55Pass",
2162                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2163                                          100,0,4);
2164   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov55Pass);
2165   TH1F *gPrimaryProtonsSigmaToVertexPass = new TH1F("gPrimaryProtonsSigmaToVertexPass",
2166                                              ";#sigma_{Vertex};Entries",
2167                                              100,0,10);
2168   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsSigmaToVertexPass);
2169   TH1F *gPrimaryProtonsSigmaToVertexTPCPass = new TH1F("gPrimaryProtonsSigmaToVertexTPCPass",
2170                                              ";#sigma_{Vertex};Entries",
2171                                              100,0,10);
2172   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsSigmaToVertexTPCPass);
2173   TH1F *gPrimaryProtonsDCAXYPass = new TH1F("gPrimaryProtonsDCAXYPass",
2174                                              ";DCA_{xy} [cm];Entries",
2175                                              100,0,20);
2176   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAXYPass);
2177   TH1F *gPrimaryProtonsDCAXYTPCPass = new TH1F("gPrimaryProtonsDCAXYTPCPass",
2178                                                ";DCA_{xy} [cm];Entries",
2179                                                100,0,20);
2180   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAXYTPCPass);
2181   TH1F *gPrimaryProtonsDCAZPass = new TH1F("gPrimaryProtonsDCAZPass",
2182                                            ";DCA_{z} [cm];Entries",
2183                                            100,0,20);
2184   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAZPass);
2185   TH1F *gPrimaryProtonsDCAZTPCPass = new TH1F("gPrimaryProtonsDCAZTPCPass",
2186                                               ";DCA_{z} [cm];Entries",
2187                                               100,0,20);
2188   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAZTPCPass);
2189   TH1F *gPrimaryProtonsConstrainChi2Pass = new TH1F("gPrimaryProtonsConstrainChi2Pass",
2190                                                     ";Log_{10}(#chi^{2});Entries",
2191                                                     100,-10,10);
2192   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsConstrainChi2Pass);
2193   TH1F *gPrimaryProtonsITSRefitPass = new TH1F("gPrimaryProtonsITSRefitPass",
2194                                                "",10,-1,1);
2195   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsITSRefitPass);
2196   TH1F *gPrimaryProtonsTPCRefitPass = new TH1F("gPrimaryProtonsTPCRefitPass",
2197                                                "",10,-1,1);
2198   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsTPCRefitPass);
2199   TH1F *gPrimaryProtonsESDpidPass = new TH1F("gPrimaryProtonsESDpidPass",
2200                                              "",10,-1,1);
2201   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsESDpidPass);
2202   TH1F *gPrimaryProtonsTPCpidPass = new TH1F("gPrimaryProtonsTPCpidPass",
2203                                              "",10,-1,1);
2204   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsTPCpidPass);
2205   TH1F *gPrimaryProtonsPointOnITSLayer1Pass = new TH1F("gPrimaryProtonsPointOnITSLayer1Pass",
2206                                              "",10,-1,1);
2207   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer1Pass);
2208   TH1F *gPrimaryProtonsPointOnITSLayer2Pass = new TH1F("gPrimaryProtonsPointOnITSLayer2Pass",
2209                                              "",10,-1,1);
2210   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer2Pass);
2211   TH1F *gPrimaryProtonsPointOnITSLayer3Pass = new TH1F("gPrimaryProtonsPointOnITSLayer3Pass",
2212                                              "",10,-1,1);
2213   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer3Pass);
2214   TH1F *gPrimaryProtonsPointOnITSLayer4Pass = new TH1F("gPrimaryProtonsPointOnITSLayer4Pass",
2215                                              "",10,-1,1);
2216   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer4Pass);
2217   TH1F *gPrimaryProtonsPointOnITSLayer5Pass = new TH1F("gPrimaryProtonsPointOnITSLayer5Pass",
2218                                              "",10,-1,1);
2219   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer5Pass);
2220   TH1F *gPrimaryProtonsPointOnITSLayer6Pass = new TH1F("gPrimaryProtonsPointOnITSLayer6Pass",
2221                                              "",10,-1,1);
2222   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer6Pass);
2223
2224   //Rejected primary protons
2225   /*gDirectory->cd("../");
2226   TDirectory *dirProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
2227   dirProtonsPrimaryRejected->cd();*/
2228
2229   TH1F *gPrimaryProtonsITSClustersReject = new TH1F("gPrimaryProtonsITSClustersReject",
2230                                                     ";N_{clusters} (ITS);Entries",
2231                                                     7,0,7);
2232   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsITSClustersReject);
2233   TH1F *gPrimaryProtonsChi2PerClusterITSReject = new TH1F("gPrimaryProtonsChi2PerClusterITSReject",
2234                                                           ";x^{2}/N_{clusters} (ITS);Entries",
2235                                                           100,0,4);
2236   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsChi2PerClusterITSReject);
2237   TH1F *gPrimaryProtonsTPCClustersReject = new TH1F("gPrimaryProtonsTPCClustersReject",
2238                                             ";N_{clusters} (TPC);Entries",
2239                                             100,0,200);
2240   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsTPCClustersReject);
2241   TH1F *gPrimaryProtonsChi2PerClusterTPCReject = new TH1F("gPrimaryProtonsChi2PerClusterTPCReject",
2242                                                   ";x^{2}/N_{clusters} (TPC);Entries",
2243                                                   100,0,4);
2244   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsChi2PerClusterTPCReject);
2245   TH1F *gPrimaryProtonsExtCov11Reject = new TH1F("gPrimaryProtonsExtCov11Reject",
2246                                          ";#sigma_{y} [cm];Entries",
2247                                          100,0,4);
2248   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov11Reject);
2249   TH1F *gPrimaryProtonsExtCov22Reject = new TH1F("gPrimaryProtonsExtCov22Reject",
2250                                          ";#sigma_{z} [cm];Entries",
2251                                          100,0,4);
2252   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov22Reject);
2253   TH1F *gPrimaryProtonsExtCov33Reject = new TH1F("gPrimaryProtonsExtCov33Reject",
2254                                          ";#sigma_{sin(#phi)};Entries",
2255                                          100,0,4);
2256   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov33Reject);
2257   TH1F *gPrimaryProtonsExtCov44Reject = new TH1F("gPrimaryProtonsExtCov44Reject",
2258                                          ";#sigma_{tan(#lambda)};Entries",
2259                                          100,0,4);
2260   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov44Reject);
2261   TH1F *gPrimaryProtonsExtCov55Reject = new TH1F("gPrimaryProtonsExtCov55Reject",
2262                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2263                                          100,0,4);
2264   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov55Reject);
2265   TH1F *gPrimaryProtonsSigmaToVertexReject = new TH1F("gPrimaryProtonsSigmaToVertexReject",
2266                                              ";#sigma_{Vertex};Entries",
2267                                              100,0,10);
2268   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsSigmaToVertexReject);
2269   TH1F *gPrimaryProtonsSigmaToVertexTPCReject = new TH1F("gPrimaryProtonsSigmaToVertexTPCReject",
2270                                              ";#sigma_{Vertex};Entries",
2271                                              100,0,10);
2272   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsSigmaToVertexTPCReject);
2273   TH1F *gPrimaryProtonsDCAXYReject = new TH1F("gPrimaryProtonsDCAXYReject",
2274                                               ";DCA_{xy} [cm];Entries",
2275                                               100,0,20);
2276   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAXYReject);
2277   TH1F *gPrimaryProtonsDCAXYTPCReject = new TH1F("gPrimaryProtonsDCAXYTPCReject",
2278                                                  ";DCA_{xy} [cm];Entries",
2279                                                  100,0,20);
2280   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAXYTPCReject);
2281   TH1F *gPrimaryProtonsDCAZReject = new TH1F("gPrimaryProtonsDCAZReject",
2282                                              ";DCA_{z} [cm];Entries",
2283                                              100,0,20);
2284   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAZReject);
2285   TH1F *gPrimaryProtonsDCAZTPCReject = new TH1F("gPrimaryProtonsDCAZTPCReject",
2286                                                 ";DCA_{z} [cm];Entries",
2287                                                 100,0,20);
2288   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAZTPCReject);
2289   TH1F *gPrimaryProtonsConstrainChi2Reject = new TH1F("gPrimaryProtonsConstrainChi2Reject",
2290                                                     ";Log_{10}(#chi^{2});Entries",
2291                                                     100,-10,10);
2292   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsConstrainChi2Reject);
2293   TH1F *gPrimaryProtonsITSRefitReject = new TH1F("gPrimaryProtonsITSRefitReject",
2294                                                  "",10,-1,1);
2295   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsITSRefitReject);
2296   TH1F *gPrimaryProtonsTPCRefitReject = new TH1F("gPrimaryProtonsTPCRefitReject",
2297                                                  "",10,-1,1);
2298   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsTPCRefitReject);
2299   TH1F *gPrimaryProtonsESDpidReject = new TH1F("gPrimaryProtonsESDpidReject",
2300                                                "",10,-1,1);
2301   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsESDpidReject);
2302   TH1F *gPrimaryProtonsTPCpidReject = new TH1F("gPrimaryProtonsTPCpidReject",
2303                                                "",10,-1,1);
2304   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsTPCpidReject);
2305   TH1F *gPrimaryProtonsPointOnITSLayer1Reject = new TH1F("gPrimaryProtonsPointOnITSLayer1Reject",
2306                                              "",10,-1,1);
2307   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer1Reject);
2308   TH1F *gPrimaryProtonsPointOnITSLayer2Reject = new TH1F("gPrimaryProtonsPointOnITSLayer2Reject",
2309                                              "",10,-1,1);
2310   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer2Reject);
2311   TH1F *gPrimaryProtonsPointOnITSLayer3Reject = new TH1F("gPrimaryProtonsPointOnITSLayer3Reject",
2312                                              "",10,-1,1);
2313   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer3Reject);
2314   TH1F *gPrimaryProtonsPointOnITSLayer4Reject = new TH1F("gPrimaryProtonsPointOnITSLayer4Reject",
2315                                              "",10,-1,1);
2316   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer4Reject);
2317   TH1F *gPrimaryProtonsPointOnITSLayer5Reject = new TH1F("gPrimaryProtonsPointOnITSLayer5Reject",
2318                                              "",10,-1,1);
2319   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer5Reject);
2320   TH1F *gPrimaryProtonsPointOnITSLayer6Reject = new TH1F("gPrimaryProtonsPointOnITSLayer6Reject",
2321                                              "",10,-1,1);
2322   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer6Reject);
2323
2324   //________________________________________________________________//
2325   /*gDirectory->cd("../../");
2326
2327   TDirectory *dirProtonsSecondary = gDirectory->mkdir("Secondaries");
2328   dirProtonsSecondary->cd();
2329   TDirectory *dirProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
2330   dirProtonsSecondaryAccepted->cd();*/
2331
2332   //Accepted secondary protons
2333   TH1F *gSecondaryProtonsITSClustersPass = new TH1F("gSecondaryProtonsITSClustersPass",
2334                                                     ";N_{clusters} (ITS);Entries",
2335                                                     7,0,7);
2336   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsITSClustersPass);
2337   TH1F *gSecondaryProtonsChi2PerClusterITSPass = new TH1F("gSecondaryProtonsChi2PerClusterITSPass",
2338                                                           ";x^{2}/N_{clusters} (ITS);Entries",
2339                                                           100,0,4);
2340   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsChi2PerClusterITSPass);
2341   TH1F *gSecondaryProtonsTPCClustersPass = new TH1F("gSecondaryProtonsTPCClustersPass",
2342                                             ";N_{clusters} (TPC);Entries",
2343                                             100,0,200);
2344   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsTPCClustersPass);
2345   TH1F *gSecondaryProtonsChi2PerClusterTPCPass = new TH1F("gSecondaryProtonsChi2PerClusterTPCPass",
2346                                                   ";x^{2}/N_{clusters} (TPC);Entries",
2347                                                   100,0,4);
2348   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsChi2PerClusterTPCPass);
2349   TH1F *gSecondaryProtonsExtCov11Pass = new TH1F("gSecondaryProtonsExtCov11Pass",
2350                                          ";#sigma_{y} [cm];Entries",
2351                                          100,0,4);
2352   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov11Pass);
2353   TH1F *gSecondaryProtonsExtCov22Pass = new TH1F("gSecondaryProtonsExtCov22Pass",
2354                                          ";#sigma_{z} [cm];Entries",
2355                                          100,0,4);
2356   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov22Pass);
2357   TH1F *gSecondaryProtonsExtCov33Pass = new TH1F("gSecondaryProtonsExtCov33Pass",
2358                                          ";#sigma_{sin(#phi)};Entries",
2359                                          100,0,4);
2360   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov33Pass);
2361   TH1F *gSecondaryProtonsExtCov44Pass = new TH1F("gSecondaryProtonsExtCov44Pass",
2362                                          ";#sigma_{tan(#lambda)};Entries",
2363                                          100,0,4);
2364   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov44Pass);
2365   TH1F *gSecondaryProtonsExtCov55Pass = new TH1F("gSecondaryProtonsExtCov55Pass",
2366                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2367                                          100,0,4);
2368   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov55Pass);
2369   TH1F *gSecondaryProtonsSigmaToVertexPass = new TH1F("gSecondaryProtonsSigmaToVertexPass",
2370                                              ";#sigma_{Vertex};Entries",
2371                                              100,0,10);
2372   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsSigmaToVertexPass);
2373   TH1F *gSecondaryProtonsSigmaToVertexTPCPass = new TH1F("gSecondaryProtonsSigmaToVertexTPCPass",
2374                                              ";#sigma_{Vertex};Entries",
2375                                              100,0,10);
2376   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsSigmaToVertexTPCPass);
2377   TH1F *gSecondaryProtonsDCAXYPass = new TH1F("gSecondaryProtonsDCAXYPass",
2378                                               ";DCA_{xy} [cm];Entries",
2379                                               100,0,20);
2380   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAXYPass);
2381   TH1F *gSecondaryProtonsDCAXYTPCPass = new TH1F("gSecondaryProtonsDCAXYTPCPass",
2382                                                  ";DCA_{xy} [cm];Entries",
2383                                                  100,0,20);
2384   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAXYTPCPass);
2385   TH1F *gSecondaryProtonsDCAZPass = new TH1F("gSecondaryProtonsDCAZPass",
2386                                              ";DCA_{z} [cm];Entries",
2387                                              100,0,20);
2388   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAZPass);
2389   TH1F *gSecondaryProtonsDCAZTPCPass = new TH1F("gSecondaryProtonsDCAZTPCPass",
2390                                                 ";DCA_{z} [cm];Entries",
2391                                                 100,0,20);
2392   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAZTPCPass);
2393   TH1F *gSecondaryProtonsConstrainChi2Pass = new TH1F("gSecondaryProtonsConstrainChi2Pass",
2394                                                     ";Log_{10}(#chi^{2});Entries",
2395                                                     100,-10,10);
2396   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsConstrainChi2Pass);
2397   TH1F *gSecondaryProtonsITSRefitPass = new TH1F("gSecondaryProtonsITSRefitPass",
2398                                                  "",10,-1,1);
2399   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsITSRefitPass);
2400   TH1F *gSecondaryProtonsTPCRefitPass = new TH1F("gSecondaryProtonsTPCRefitPass",
2401                                                  "",10,-1,1);
2402   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsTPCRefitPass);
2403   TH1F *gSecondaryProtonsESDpidPass = new TH1F("gSecondaryProtonsESDpidPass",
2404                                                "",10,-1,1);
2405   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsESDpidPass);
2406   TH1F *gSecondaryProtonsTPCpidPass = new TH1F("gSecondaryProtonsTPCpidPass",
2407                                                "",10,-1,1);
2408   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsTPCpidPass);
2409   TH1F *gSecondaryProtonsPointOnITSLayer1Pass = new TH1F("gSecondaryProtonsPointOnITSLayer1Pass",
2410                                                          "",10,-1,1);
2411   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer1Pass);
2412   TH1F *gSecondaryProtonsPointOnITSLayer2Pass = new TH1F("gSecondaryProtonsPointOnITSLayer2Pass",
2413                                                          "",10,-1,1);
2414   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer2Pass);
2415   TH1F *gSecondaryProtonsPointOnITSLayer3Pass = new TH1F("gSecondaryProtonsPointOnITSLayer3Pass",
2416                                                          "",10,-1,1);
2417   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer3Pass);
2418   TH1F *gSecondaryProtonsPointOnITSLayer4Pass = new TH1F("gSecondaryProtonsPointOnITSLayer4Pass",
2419                                                          "",10,-1,1);
2420   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer4Pass);
2421   TH1F *gSecondaryProtonsPointOnITSLayer5Pass = new TH1F("gSecondaryProtonsPointOnITSLayer5Pass",
2422                                                          "",10,-1,1);
2423   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer5Pass);
2424   TH1F *gSecondaryProtonsPointOnITSLayer6Pass = new TH1F("gSecondaryProtonsPointOnITSLayer6Pass",
2425                                                          "",10,-1,1);
2426   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer6Pass);
2427
2428   //Rejected secondary protons
2429   /*gDirectory->cd("../");
2430   TDirectory *dirProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
2431   dirProtonsSecondaryRejected->cd();*/
2432
2433   TH1F *gSecondaryProtonsITSClustersReject = new TH1F("gSecondaryProtonsITSClustersReject",
2434                                                       ";N_{clusters} (ITS);Entries",
2435                                                       7,0,7);
2436   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsITSClustersReject);
2437   TH1F *gSecondaryProtonsChi2PerClusterITSReject = new TH1F("gSecondaryProtonsChi2PerClusterITSReject",
2438                                                             ";x^{2}/N_{clusters} (ITS);Entries",
2439                                                             100,0,4);
2440   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsChi2PerClusterITSReject);
2441   TH1F *gSecondaryProtonsTPCClustersReject = new TH1F("gSecondaryProtonsTPCClustersReject",
2442                                             ";N_{clusters} (TPC);Entries",
2443                                             100,0,200);
2444   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsTPCClustersReject);
2445   TH1F *gSecondaryProtonsChi2PerClusterTPCReject = new TH1F("gSecondaryProtonsChi2PerClusterTPCReject",
2446                                                   ";x^{2}/N_{clusters} (TPC);Entries",
2447                                                   100,0,4);
2448   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsChi2PerClusterTPCReject);
2449   TH1F *gSecondaryProtonsExtCov11Reject = new TH1F("gSecondaryProtonsExtCov11Reject",
2450                                          ";#sigma_{y} [cm];Entries",
2451                                          100,0,4);
2452   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov11Reject);
2453   TH1F *gSecondaryProtonsExtCov22Reject = new TH1F("gSecondaryProtonsExtCov22Reject",
2454                                          ";#sigma_{z} [cm];Entries",
2455                                          100,0,4);
2456   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov22Reject);
2457   TH1F *gSecondaryProtonsExtCov33Reject = new TH1F("gSecondaryProtonsExtCov33Reject",
2458                                          ";#sigma_{sin(#phi)};Entries",
2459                                          100,0,4);
2460   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov33Reject);
2461   TH1F *gSecondaryProtonsExtCov44Reject = new TH1F("gSecondaryProtonsExtCov44Reject",
2462                                          ";#sigma_{tan(#lambda)};Entries",
2463                                          100,0,4);
2464   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov44Reject);
2465   TH1F *gSecondaryProtonsExtCov55Reject = new TH1F("gSecondaryProtonsExtCov55Reject",
2466                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2467                                          100,0,4);
2468   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov55Reject);
2469   TH1F *gSecondaryProtonsSigmaToVertexReject = new TH1F("gSecondaryProtonsSigmaToVertexReject",
2470                                              ";#sigma_{Vertex};Entries",
2471                                              100,0,10);
2472   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsSigmaToVertexReject);
2473   TH1F *gSecondaryProtonsSigmaToVertexTPCReject = new TH1F("gSecondaryProtonsSigmaToVertexTPCReject",
2474                                                            ";#sigma_{Vertex};Entries",
2475                                                            100,0,10);
2476   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsSigmaToVertexTPCReject);
2477   TH1F *gSecondaryProtonsDCAXYReject = new TH1F("gSecondaryProtonsDCAXYReject",
2478                                                 ";DCA_{xy} [cm];Entries",
2479                                                 100,0,20);
2480   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAXYReject);
2481   TH1F *gSecondaryProtonsDCAXYTPCReject = new TH1F("gSecondaryProtonsDCAXYTPCReject",
2482                                                    ";DCA_{xy} [cm];Entries",
2483                                                    100,0,20);
2484   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAXYTPCReject);
2485   TH1F *gSecondaryProtonsDCAZReject = new TH1F("gSecondaryProtonsDCAZReject",
2486                                                ";DCA_{z} [cm];Entries",
2487                                                100,0,20);
2488   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAZReject);
2489   TH1F *gSecondaryProtonsDCAZTPCReject = new TH1F("gSecondaryProtonsDCAZTPCReject",
2490                                                   ";DCA_{z} [cm];Entries",
2491                                                   100,0,20);
2492   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAZTPCReject);
2493   TH1F *gSecondaryProtonsConstrainChi2Reject = new TH1F("gSecondaryProtonsConstrainChi2Reject",
2494                                                         ";Log_{10}(#chi^{2});Entries",
2495                                                         100,-10,10);
2496   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsConstrainChi2Reject);
2497   TH1F *gSecondaryProtonsITSRefitReject = new TH1F("gSecondaryProtonsITSRefitReject",
2498                                                    "",10,-1,1);
2499   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsITSRefitReject);
2500   TH1F *gSecondaryProtonsTPCRefitReject = new TH1F("gSecondaryProtonsTPCRefitReject",
2501                                                    "",10,-1,1);
2502   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsTPCRefitReject);
2503   TH1F *gSecondaryProtonsESDpidReject = new TH1F("gSecondaryProtonsESDpidReject",
2504                                                  "",10,-1,1);
2505   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsESDpidReject);
2506   TH1F *gSecondaryProtonsTPCpidReject = new TH1F("gSecondaryProtonsTPCpidReject",
2507                                                  "",10,-1,1);
2508   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsTPCpidReject);
2509   TH1F *gSecondaryProtonsPointOnITSLayer1Reject = new TH1F("gSecondaryProtonsPointOnITSLayer1Reject",
2510                                                            "",10,-1,1);
2511   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer1Reject);
2512   TH1F *gSecondaryProtonsPointOnITSLayer2Reject = new TH1F("gSecondaryProtonsPointOnITSLayer2Reject",
2513                                                            "",10,-1,1);
2514   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer2Reject);
2515   TH1F *gSecondaryProtonsPointOnITSLayer3Reject = new TH1F("gSecondaryProtonsPointOnITSLayer3Reject",
2516                                                            "",10,-1,1);
2517   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer3Reject);
2518   TH1F *gSecondaryProtonsPointOnITSLayer4Reject = new TH1F("gSecondaryProtonsPointOnITSLayer4Reject",
2519                                                            "",10,-1,1);
2520   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer4Reject);
2521   TH1F *gSecondaryProtonsPointOnITSLayer5Reject = new TH1F("gSecondaryProtonsPointOnITSLayer5Reject",
2522                                                            "",10,-1,1);
2523   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer5Reject);
2524   TH1F *gSecondaryProtonsPointOnITSLayer6Reject = new TH1F("gSecondaryProtonsPointOnITSLayer6Reject",
2525                                                            "",10,-1,1);
2526   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer6Reject);
2527   
2528
2529   /*gDirectory->cd("../../../");
2530
2531   //antiprotons
2532   TDirectory *dirAntiProtons = gDirectory->mkdir("AntiProtons");
2533   fGlobalQAList->Add(dirAntiProtons); dirAntiProtons->cd();*/
2534   
2535   //________________________________________________________________//
2536   /*TDirectory *dirAntiProtonsPrimary = gDirectory->mkdir("Primaries");
2537   dirAntiProtonsPrimary->cd();
2538   TDirectory *dirAntiProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
2539   dirAntiProtonsPrimaryAccepted->cd();*/
2540   
2541   //Accepted primary antiprotons
2542   TH1F *gPrimaryAntiProtonsITSClustersPass = new TH1F("gPrimaryAntiProtonsITSClustersPass",
2543                                                       ";N_{clusters} (ITS);Entries",
2544                                                       7,0,7);
2545   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsITSClustersPass);
2546   TH1F *gPrimaryAntiProtonsChi2PerClusterITSPass = new TH1F("gPrimaryAntiProtonsChi2PerClusterITSPass",
2547                                                             ";x^{2}/N_{clusters} (ITS);Entries",
2548                                                             100,0,4);
2549   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsChi2PerClusterITSPass);
2550   TH1F *gPrimaryAntiProtonsTPCClustersPass = new TH1F("gPrimaryAntiProtonsTPCClustersPass",
2551                                                       ";N_{clusters} (TPC);Entries",
2552                                                       100,0,200);
2553   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsTPCClustersPass);
2554   TH1F *gPrimaryAntiProtonsChi2PerClusterTPCPass = new TH1F("gPrimaryAntiProtonsChi2PerClusterTPCPass",
2555                                                             ";x^{2}/N_{clusters} (TPC);Entries",
2556                                                             100,0,4);
2557   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsChi2PerClusterTPCPass);
2558   TH1F *gPrimaryAntiProtonsExtCov11Pass = new TH1F("gPrimaryAntiProtonsExtCov11Pass",
2559                                                    ";#sigma_{y} [cm];Entries",
2560                                                    100,0,4);
2561   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov11Pass);
2562   TH1F *gPrimaryAntiProtonsExtCov22Pass = new TH1F("gPrimaryAntiProtonsExtCov22Pass",
2563                                                    ";#sigma_{z} [cm];Entries",
2564                                                    100,0,4);
2565   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov22Pass);
2566   TH1F *gPrimaryAntiProtonsExtCov33Pass = new TH1F("gPrimaryAntiProtonsExtCov33Pass",
2567                                                    ";#sigma_{sin(#phi)};Entries",
2568                                                    100,0,4);
2569   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov33Pass);
2570   TH1F *gPrimaryAntiProtonsExtCov44Pass = new TH1F("gPrimaryAntiProtonsExtCov44Pass",
2571                                                    ";#sigma_{tan(#lambda)};Entries",
2572                                                    100,0,4);
2573   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov44Pass);
2574   TH1F *gPrimaryAntiProtonsExtCov55Pass = new TH1F("gPrimaryAntiProtonsExtCov55Pass",
2575                                                    ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2576                                                    100,0,4);
2577   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov55Pass);
2578   TH1F *gPrimaryAntiProtonsSigmaToVertexPass = new TH1F("gPrimaryAntiProtonsSigmaToVertexPass",
2579                                                         ";#sigma_{Vertex};Entries",
2580                                                         100,0,10);
2581   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsSigmaToVertexPass);
2582   TH1F *gPrimaryAntiProtonsSigmaToVertexTPCPass = new TH1F("gPrimaryAntiProtonsSigmaToVertexTPCPass",
2583                                                            ";#sigma_{Vertex};Entries",
2584                                                            100,0,10);
2585   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsSigmaToVertexTPCPass);
2586   TH1F *gPrimaryAntiProtonsDCAXYPass = new TH1F("gPrimaryAntiProtonsDCAXYPass",
2587                                                 ";DCA_{xy} [cm];Entries",
2588                                                 100,0,20);
2589   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAXYPass);
2590   TH1F *gPrimaryAntiProtonsDCAXYTPCPass = new TH1F("gPrimaryAntiProtonsDCAXYTPCPass",
2591                                                    ";DCA_{xy} [cm];Entries",
2592                                                    100,0,20);
2593   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAXYTPCPass);
2594   TH1F *gPrimaryAntiProtonsDCAZPass = new TH1F("gPrimaryAntiProtonsDCAZPass",
2595                                                ";DCA_{z} [cm];Entries",
2596                                                100,0,20);
2597   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAZPass);
2598   TH1F *gPrimaryAntiProtonsDCAZTPCPass = new TH1F("gPrimaryAntiProtonsDCAZTPCPass",
2599                                                   ";DCA_{z} [cm];Entries",
2600                                                   100,0,20);
2601   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAZTPCPass);
2602   TH1F *gPrimaryAntiProtonsConstrainChi2Pass = new TH1F("gPrimaryAntiProtonsConstrainChi2Pass",
2603                                                         ";Log_{10}(#chi^{2});Entries",
2604                                                         100,-10,10);
2605   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsConstrainChi2Pass);
2606   TH1F *gPrimaryAntiProtonsITSRefitPass = new TH1F("gPrimaryAntiProtonsITSRefitPass",
2607                                                    "",10,-1,1);
2608   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsITSRefitPass);
2609   TH1F *gPrimaryAntiProtonsTPCRefitPass = new TH1F("gPrimaryAntiProtonsTPCRefitPass",
2610                                                    "",10,-1,1);
2611   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsTPCRefitPass);
2612   TH1F *gPrimaryAntiProtonsESDpidPass = new TH1F("gPrimaryAntiProtonsESDpidPass",
2613                                                  "",10,-1,1);
2614   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsESDpidPass);
2615   TH1F *gPrimaryAntiProtonsTPCpidPass = new TH1F("gPrimaryAntiProtonsTPCpidPass",
2616                                                  "",10,-1,1);
2617   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsTPCpidPass);
2618   TH1F *gPrimaryAntiProtonsPointOnITSLayer1Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer1Pass",
2619                                                            "",10,-1,1);
2620   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer1Pass);
2621   TH1F *gPrimaryAntiProtonsPointOnITSLayer2Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer2Pass",
2622                                                            "",10,-1,1);
2623   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer2Pass);
2624   TH1F *gPrimaryAntiProtonsPointOnITSLayer3Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer3Pass",
2625                                                            "",10,-1,1);
2626   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer3Pass);
2627   TH1F *gPrimaryAntiProtonsPointOnITSLayer4Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer4Pass",
2628                                                            "",10,-1,1);
2629   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer4Pass);
2630   TH1F *gPrimaryAntiProtonsPointOnITSLayer5Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer5Pass",
2631                                                            "",10,-1,1);
2632   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer5Pass);
2633   TH1F *gPrimaryAntiProtonsPointOnITSLayer6Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer6Pass",
2634                                                            "",10,-1,1);
2635   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer6Pass);
2636   
2637   //Rejected primary antiprotons
2638   /*gDirectory->cd("../");
2639   TDirectory *dirAntiProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
2640   dirAntiProtonsPrimaryRejected->cd();*/
2641   
2642   TH1F *gPrimaryAntiProtonsITSClustersReject = new TH1F("gPrimaryAntiProtonsITSClustersReject",
2643                                                         ";N_{clusters} (ITS);Entries",
2644                                                         7,0,7);
2645   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsITSClustersReject);
2646   TH1F *gPrimaryAntiProtonsChi2PerClusterITSReject = new TH1F("gPrimaryAntiProtonsChi2PerClusterITSReject",
2647                                                               ";x^{2}/N_{clusters} (ITS);Entries",
2648                                                               100,0,4);
2649   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsChi2PerClusterITSReject);
2650   TH1F *gPrimaryAntiProtonsTPCClustersReject = new TH1F("gPrimaryAntiProtonsTPCClustersReject",
2651                                                         ";N_{clusters} (TPC);Entries",
2652                                                         100,0,200);
2653   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsTPCClustersReject);
2654   TH1F *gPrimaryAntiProtonsChi2PerClusterTPCReject = new TH1F("gPrimaryAntiProtonsChi2PerClusterTPCReject",
2655                                                               ";x^{2}/N_{clusters} (TPC);Entries",
2656                                                               100,0,4);
2657   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsChi2PerClusterTPCReject);
2658   TH1F *gPrimaryAntiProtonsExtCov11Reject = new TH1F("gPrimaryAntiProtonsExtCov11Reject",
2659                                                      ";#sigma_{y} [cm];Entries",
2660                                                      100,0,4);
2661   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov11Reject);
2662   TH1F *gPrimaryAntiProtonsExtCov22Reject = new TH1F("gPrimaryAntiProtonsExtCov22Reject",
2663                                                      ";#sigma_{z} [cm];Entries",
2664                                                      100,0,4);
2665   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov22Reject);
2666   TH1F *gPrimaryAntiProtonsExtCov33Reject = new TH1F("gPrimaryAntiProtonsExtCov33Reject",
2667                                                      ";#sigma_{sin(#phi)};Entries",
2668                                                      100,0,4);
2669   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov33Reject);
2670   TH1F *gPrimaryAntiProtonsExtCov44Reject = new TH1F("gPrimaryAntiProtonsExtCov44Reject",
2671                                                      ";#sigma_{tan(#lambda)};Entries",
2672                                                      100,0,4);
2673   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov44Reject);
2674   TH1F *gPrimaryAntiProtonsExtCov55Reject = new TH1F("gPrimaryAntiProtonsExtCov55Reject",
2675                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2676                                                      100,0,4);
2677   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov55Reject);
2678   TH1F *gPrimaryAntiProtonsSigmaToVertexReject = new TH1F("gPrimaryAntiProtonsSigmaToVertexReject",
2679                                                           ";#sigma_{Vertex};Entries",
2680                                                           100,0,10);
2681   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsSigmaToVertexReject);
2682   TH1F *gPrimaryAntiProtonsSigmaToVertexTPCReject = new TH1F("gPrimaryAntiProtonsSigmaToVertexTPCReject",
2683                                                              ";#sigma_{Vertex};Entries",
2684                                                              100,0,10);
2685   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsSigmaToVertexTPCReject);
2686   TH1F *gPrimaryAntiProtonsDCAXYReject = new TH1F("gPrimaryAntiProtonsDCAXYReject",
2687                                                   ";DCA_{xy} [cm];Entries",
2688                                                   100,0,20);
2689   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAXYReject);
2690   TH1F *gPrimaryAntiProtonsDCAXYTPCReject = new TH1F("gPrimaryAntiProtonsDCAXYTPCReject",
2691                                                      ";DCA_{xy} [cm];Entries",
2692                                                      100,0,20);
2693   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAXYTPCReject);
2694   TH1F *gPrimaryAntiProtonsDCAZReject = new TH1F("gPrimaryAntiProtonsDCAZReject",
2695                                                  ";DCA_{z} [cm];Entries",
2696                                                  100,0,20);
2697   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAZReject);
2698   TH1F *gPrimaryAntiProtonsDCAZTPCReject = new TH1F("gPrimaryAntiProtonsDCAZTPCReject",
2699                                                     ";DCA_{z} [cm];Entries",
2700                                                     100,0,20);
2701   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAZTPCReject);
2702   TH1F *gPrimaryAntiProtonsConstrainChi2Reject = new TH1F("gPrimaryAntiProtonsConstrainChi2Reject",
2703                                                           ";Log_{10}(#chi^{2});Entries",
2704                                                           100,-10,10);
2705   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsConstrainChi2Reject);
2706   TH1F *gPrimaryAntiProtonsITSRefitReject = new TH1F("gPrimaryAntiProtonsITSRefitReject",
2707                                                      "",10,-1,1);
2708   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsITSRefitReject);
2709   TH1F *gPrimaryAntiProtonsTPCRefitReject = new TH1F("gPrimaryAntiProtonsTPCRefitReject",
2710                                                      "",10,-1,1);
2711   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsTPCRefitReject);
2712   TH1F *gPrimaryAntiProtonsESDpidReject = new TH1F("gPrimaryAntiProtonsESDpidReject",
2713                                                    "",10,-1,1);
2714   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsESDpidReject);
2715   TH1F *gPrimaryAntiProtonsTPCpidReject = new TH1F("gPrimaryAntiProtonsTPCpidReject",
2716                                                    "",10,-1,1);
2717   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsTPCpidReject);
2718   TH1F *gPrimaryAntiProtonsPointOnITSLayer1Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer1Reject",
2719                                                              "",10,-1,1);
2720   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer1Reject);
2721   TH1F *gPrimaryAntiProtonsPointOnITSLayer2Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer2Reject",
2722                                                              "",10,-1,1);
2723   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer2Reject);
2724   TH1F *gPrimaryAntiProtonsPointOnITSLayer3Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer3Reject",
2725                                                              "",10,-1,1);
2726   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer3Reject);
2727   TH1F *gPrimaryAntiProtonsPointOnITSLayer4Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer4Reject",
2728                                                              "",10,-1,1);
2729   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer4Reject);
2730   TH1F *gPrimaryAntiProtonsPointOnITSLayer5Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer5Reject",
2731                                                              "",10,-1,1);
2732   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer5Reject);
2733   TH1F *gPrimaryAntiProtonsPointOnITSLayer6Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer6Reject",
2734                                                              "",10,-1,1);
2735   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer6Reject);
2736   
2737   //________________________________________________________________//
2738   /*gDirectory->cd("../../");
2739
2740   TDirectory *dirAntiProtonsSecondary = gDirectory->mkdir("Secondaries");
2741   dirAntiProtonsSecondary->cd();
2742   TDirectory *dirAntiProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
2743   dirAntiProtonsSecondaryAccepted->cd();*/
2744
2745   //Accepted secondary antiprotons
2746   TH1F *gSecondaryAntiProtonsITSClustersPass = new TH1F("gSecondaryAntiProtonsITSClustersPass",
2747                                                         ";N_{clusters} (ITS);Entries",
2748                                                         7,0,7);
2749   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsITSClustersPass);
2750   TH1F *gSecondaryAntiProtonsChi2PerClusterITSPass = new TH1F("gSecondaryAntiProtonsChi2PerClusterITSPass",
2751                                                               ";x^{2}/N_{clusters} (ITS);Entries",
2752                                                               100,0,4);
2753   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsChi2PerClusterITSPass);
2754   TH1F *gSecondaryAntiProtonsTPCClustersPass = new TH1F("gSecondaryAntiProtonsTPCClustersPass",
2755                                                         ";N_{clusters} (TPC);Entries",
2756                                                         100,0,200);
2757   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsTPCClustersPass);
2758   TH1F *gSecondaryAntiProtonsChi2PerClusterTPCPass = new TH1F("gSecondaryAntiProtonsChi2PerClusterTPCPass",
2759                                                               ";x^{2}/N_{clusters} (TPC);Entries",
2760                                                               100,0,4);
2761   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsChi2PerClusterTPCPass);
2762   TH1F *gSecondaryAntiProtonsExtCov11Pass = new TH1F("gSecondaryAntiProtonsExtCov11Pass",
2763                                                      ";#sigma_{y} [cm];Entries",
2764                                                      100,0,4);
2765   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov11Pass);
2766   TH1F *gSecondaryAntiProtonsExtCov22Pass = new TH1F("gSecondaryAntiProtonsExtCov22Pass",
2767                                                      ";#sigma_{z} [cm];Entries",
2768                                                      100,0,4);
2769   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov22Pass);
2770   TH1F *gSecondaryAntiProtonsExtCov33Pass = new TH1F("gSecondaryAntiProtonsExtCov33Pass",
2771                                                      ";#sigma_{sin(#phi)};Entries",
2772                                                      100,0,4);
2773   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov33Pass);
2774   TH1F *gSecondaryAntiProtonsExtCov44Pass = new TH1F("gSecondaryAntiProtonsExtCov44Pass",
2775                                                      ";#sigma_{tan(#lambda)};Entries",
2776                                                      100,0,4);
2777   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov44Pass);
2778   TH1F *gSecondaryAntiProtonsExtCov55Pass = new TH1F("gSecondaryAntiProtonsExtCov55Pass",
2779                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2780                                                      100,0,4);
2781   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov55Pass);
2782   TH1F *gSecondaryAntiProtonsSigmaToVertexPass = new TH1F("gSecondaryAntiProtonsSigmaToVertexPass",
2783                                                           ";#sigma_{Vertex};Entries",
2784                                                           100,0,10);
2785   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsSigmaToVertexPass);
2786   TH1F *gSecondaryAntiProtonsSigmaToVertexTPCPass = new TH1F("gSecondaryAntiProtonsSigmaToVertexTPCPass",
2787                                                              ";#sigma_{Vertex};Entries",
2788                                                              100,0,10);
2789   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsSigmaToVertexTPCPass);
2790   TH1F *gSecondaryAntiProtonsDCAXYPass = new TH1F("gSecondaryAntiProtonsDCAXYPass",
2791                                                   ";DCA_{xy} [cm];Entries",
2792                                                   100,0,20);
2793   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAXYPass);
2794   TH1F *gSecondaryAntiProtonsDCAXYTPCPass = new TH1F("gSecondaryAntiProtonsDCAXYTPCPass",
2795                                                      ";DCA_{xy} [cm];Entries",
2796                                                      100,0,20);
2797   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAXYTPCPass);
2798   TH1F *gSecondaryAntiProtonsDCAZPass = new TH1F("gSecondaryAntiProtonsDCAZPass",
2799                                                  ";DCA_{z} [cm];Entries",
2800                                                  100,0,20);
2801   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAZPass);
2802   TH1F *gSecondaryAntiProtonsDCAZTPCPass = new TH1F("gSecondaryAntiProtonsDCAZTPCPass",
2803                                                     ";DCA_{z} [cm];Entries",
2804                                                     100,0,20);
2805   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAZTPCPass);
2806   TH1F *gSecondaryAntiProtonsConstrainChi2Pass = new TH1F("gSecondaryAntiProtonsConstrainChi2Pass",
2807                                                           ";Log_{10}(#chi^{2});Entries",
2808                                                           100,-10,10);
2809   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsConstrainChi2Pass);
2810   TH1F *gSecondaryAntiProtonsITSRefitPass = new TH1F("gSecondaryAntiProtonsITSRefitPass",
2811                                                      "",10,-1,1);
2812   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsITSRefitPass);
2813   TH1F *gSecondaryAntiProtonsTPCRefitPass = new TH1F("gSecondaryAntiProtonsTPCRefitPass",
2814                                                      "",10,-1,1);
2815   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsTPCRefitPass);
2816   TH1F *gSecondaryAntiProtonsESDpidPass = new TH1F("gSecondaryAntiProtonsESDpidPass",
2817                                                    "",10,-1,1);
2818   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsESDpidPass);
2819   TH1F *gSecondaryAntiProtonsTPCpidPass = new TH1F("gSecondaryAntiProtonsTPCpidPass",
2820                                                    "",10,-1,1);
2821   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsTPCpidPass);
2822   TH1F *gSecondaryAntiProtonsPointOnITSLayer1Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer1Pass",
2823                                                              "",10,-1,1);
2824   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer1Pass);
2825   TH1F *gSecondaryAntiProtonsPointOnITSLayer2Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer2Pass",
2826                                                              "",10,-1,1);
2827   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer2Pass);
2828   TH1F *gSecondaryAntiProtonsPointOnITSLayer3Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer3Pass",
2829                                                              "",10,-1,1);
2830   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer3Pass);
2831   TH1F *gSecondaryAntiProtonsPointOnITSLayer4Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer4Pass",
2832                                                              "",10,-1,1);
2833   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer4Pass);
2834   TH1F *gSecondaryAntiProtonsPointOnITSLayer5Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer5Pass",
2835                                                              "",10,-1,1);
2836   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer5Pass);
2837   TH1F *gSecondaryAntiProtonsPointOnITSLayer6Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer6Pass",
2838                                                              "",10,-1,1);
2839   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer6Pass);
2840   
2841   //Rejected secondary antiprotons
2842   /*gDirectory->cd("../");
2843   TDirectory *dirAntiProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
2844   dirAntiProtonsSecondaryRejected->cd();*/
2845
2846   TH1F *gSecondaryAntiProtonsITSClustersReject = new TH1F("gSecondaryAntiProtonsITSClustersReject",
2847                                                           ";N_{clusters} (ITS);Entries",
2848                                                           7,0,7);
2849   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsITSClustersReject);
2850   TH1F *gSecondaryAntiProtonsChi2PerClusterITSReject = new TH1F("gSecondaryAntiProtonsChi2PerClusterITSReject",
2851                                                                 ";x^{2}/N_{clusters} (ITS);Entries",
2852                                                                 100,0,4);
2853   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsChi2PerClusterITSReject);
2854   TH1F *gSecondaryAntiProtonsTPCClustersReject = new TH1F("gSecondaryAntiProtonsTPCClustersReject",
2855                                                           ";N_{clusters} (TPC);Entries",
2856                                                           100,0,200);
2857   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsTPCClustersReject);
2858   TH1F *gSecondaryAntiProtonsChi2PerClusterTPCReject = new TH1F("gSecondaryAntiProtonsChi2PerClusterTPCReject",
2859                                                                 ";x^{2}/N_{clusters} (TPC);Entries",
2860                                                                 100,0,4);
2861   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsChi2PerClusterTPCReject);
2862   TH1F *gSecondaryAntiProtonsExtCov11Reject = new TH1F("gSecondaryAntiProtonsExtCov11Reject",
2863                                                        ";#sigma_{y} [cm];Entries",
2864                                                        100,0,4);
2865   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov11Reject);
2866   TH1F *gSecondaryAntiProtonsExtCov22Reject = new TH1F("gSecondaryAntiProtonsExtCov22Reject",
2867                                                        ";#sigma_{z} [cm];Entries",
2868                                                        100,0,4);
2869   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov22Reject);
2870   TH1F *gSecondaryAntiProtonsExtCov33Reject = new TH1F("gSecondaryAntiProtonsExtCov33Reject",
2871                                                        ";#sigma_{sin(#phi)};Entries",
2872                                                        100,0,4);
2873   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov33Reject);
2874   TH1F *gSecondaryAntiProtonsExtCov44Reject = new TH1F("gSecondaryAntiProtonsExtCov44Reject",
2875                                                        ";#sigma_{tan(#lambda)};Entries",
2876                                                        100,0,4);
2877   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov44Reject);
2878   TH1F *gSecondaryAntiProtonsExtCov55Reject = new TH1F("gSecondaryAntiProtonsExtCov55Reject",
2879                                                        ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2880                                                        100,0,4);
2881   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov55Reject);
2882   TH1F *gSecondaryAntiProtonsSigmaToVertexReject = new TH1F("gSecondaryAntiProtonsSigmaToVertexReject",
2883                                                             ";#sigma_{Vertex};Entries",
2884                                                             100,0,10);
2885   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsSigmaToVertexReject);
2886   TH1F *gSecondaryAntiProtonsSigmaToVertexTPCReject = new TH1F("gSecondaryAntiProtonsSigmaToVertexTPCReject",
2887                                                                ";#sigma_{Vertex};Entries",
2888                                                                100,0,10);
2889   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsSigmaToVertexTPCReject);
2890   TH1F *gSecondaryAntiProtonsDCAXYReject = new TH1F("gSecondaryAntiProtonsDCAXYReject",
2891                                                     ";DCA_{xy} [cm];Entries",
2892                                                     100,0,20);
2893   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAXYReject);
2894   TH1F *gSecondaryAntiProtonsDCAXYTPCReject = new TH1F("gSecondaryAntiProtonsDCAXYTPCReject",
2895                                                        ";DCA_{xy} [cm];Entries",
2896                                                        100,0,20);
2897   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAXYTPCReject);
2898   TH1F *gSecondaryAntiProtonsDCAZReject = new TH1F("gSecondaryAntiProtonsDCAZReject",
2899                                                    ";DCA_{z} [cm];Entries",
2900                                                    100,0,20);
2901   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAZReject);
2902   TH1F *gSecondaryAntiProtonsDCAZTPCReject = new TH1F("gSecondaryAntiProtonsDCAZTPCReject",
2903                                                       ";DCA_{z} [cm];Entries",
2904                                                       100,0,20);
2905   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAZTPCReject);
2906   TH1F *gSecondaryAntiProtonsConstrainChi2Reject = new TH1F("gSecondaryAntiProtonsConstrainChi2Reject",
2907                                                             ";Log_{10}(#chi^{2});Entries",
2908                                                             100,-10,10);
2909   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsConstrainChi2Reject);
2910   TH1F *gSecondaryAntiProtonsITSRefitReject = new TH1F("gSecondaryAntiProtonsITSRefitReject",
2911                                                        "",10,-1,1);
2912   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsITSRefitReject);
2913   TH1F *gSecondaryAntiProtonsTPCRefitReject = new TH1F("gSecondaryAntiProtonsTPCRefitReject",
2914                                                        "",10,-1,1);
2915   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsTPCRefitReject);
2916   TH1F *gSecondaryAntiProtonsESDpidReject = new TH1F("gSecondaryAntiProtonsESDpidReject",
2917                                                      "",10,-1,1);
2918   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsESDpidReject);
2919   TH1F *gSecondaryAntiProtonsTPCpidReject = new TH1F("gSecondaryAntiProtonsTPCpidReject",
2920                                                      "",10,-1,1);
2921   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsTPCpidReject);
2922   TH1F *gSecondaryAntiProtonsPointOnITSLayer1Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer1Reject",
2923                                                              "",10,-1,1);
2924   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer1Reject);
2925   TH1F *gSecondaryAntiProtonsPointOnITSLayer2Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer2Reject",
2926                                                              "",10,-1,1);
2927   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer2Reject);
2928   TH1F *gSecondaryAntiProtonsPointOnITSLayer3Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer3Reject",
2929                                                              "",10,-1,1);
2930   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer3Reject);
2931   TH1F *gSecondaryAntiProtonsPointOnITSLayer4Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer4Reject",
2932                                                              "",10,-1,1);
2933   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer4Reject);
2934   TH1F *gSecondaryAntiProtonsPointOnITSLayer5Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer5Reject",
2935                                                              "",10,-1,1);
2936   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer5Reject);
2937   TH1F *gSecondaryAntiProtonsPointOnITSLayer6Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer6Reject",
2938                                                              "",10,-1,1);
2939   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer6Reject);
2940 }
2941
2942 //____________________________________________________________________//
2943 void AliProtonQAAnalysis::RunEfficiencyAnalysis(AliStack *stack, 
2944                                                 AliESDEvent *esd,
2945                                                 const AliESDVertex *vertex) {
2946   //Runs the efficiency code
2947   //MC loop
2948   Int_t nMCProtons = 0, nESDProtons = 0;
2949   for(Int_t iParticle = 0; iParticle < stack->GetNtrack(); iParticle++) {
2950     TParticle *particle = stack->Particle(iParticle);
2951     if(!particle) continue;
2952
2953     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
2954     if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
2955     if(fAnalysisEtaMode) {
2956       if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
2957     }
2958     else 
2959       if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
2960
2961     Int_t pdgcode = particle->GetPdgCode();
2962     if(TMath::Abs(pdgcode) != 2212) continue;
2963
2964     if(iParticle <= stack->GetNprimary()) {
2965       if(pdgcode == 2212) {
2966         nMCProtons += 1;
2967         if(fAnalysisEtaMode) 
2968           ((TH2D *)(fEfficiencyList->At(0)))->Fill(particle->Eta(),
2969                                                    particle->Pt());
2970         else
2971           ((TH2D *)(fEfficiencyList->At(0)))->Fill(Rapidity(particle->Px(),
2972                                                             particle->Py(),
2973                                                             particle->Pz()),
2974                                                    particle->Pt());
2975       }//protons
2976       if(pdgcode == -2212) {
2977         if(fAnalysisEtaMode) 
2978           ((TH2D *)(fEfficiencyList->At(1)))->Fill(particle->Eta(),
2979                                                    particle->Pt());
2980         else
2981           ((TH2D *)(fEfficiencyList->At(1)))->Fill(Rapidity(particle->Px(),
2982                                                             particle->Py(),
2983                                                             particle->Pz()),
2984                                                    particle->Pt());
2985       }//antiprotons
2986     }//primaries
2987     else {
2988       //secondaries
2989       Int_t lPartMother = -1;
2990       Int_t motherPDGCode = -1;
2991       lPartMother = particle->GetFirstMother();
2992       TParticle *motherParticle = stack->Particle(lPartMother);
2993       if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
2994
2995       if(pdgcode == 2212) {
2996         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
2997           if(fAnalysisEtaMode) 
2998             ((TH2D *)(fEfficiencyList->At(2)))->Fill(particle->Eta(),
2999                                                      particle->Pt());
3000           else
3001             ((TH2D *)(fEfficiencyList->At(2)))->Fill(Rapidity(particle->Px(),
3002                                                               particle->Py(),
3003                                                               particle->Pz()),
3004                                                      particle->Pt());
3005         }//weak decays
3006         if((particle->GetUniqueID() == 13)) {
3007           if(fAnalysisEtaMode) 
3008             ((TH2D *)(fEfficiencyList->At(4)))->Fill(particle->Eta(),
3009                                                      particle->Pt());
3010           else
3011             ((TH2D *)(fEfficiencyList->At(4)))->Fill(Rapidity(particle->Px(),
3012                                                               particle->Py(),
3013                                                               particle->Pz()),
3014                                                      particle->Pt());
3015         }//hadronic interactions
3016       }//protons
3017       if(pdgcode == -2212) {
3018         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
3019           if(fAnalysisEtaMode) 
3020             ((TH2D *)(fEfficiencyList->At(3)))->Fill(particle->Eta(),
3021                                                      particle->Pt());
3022           else
3023             ((TH2D *)(fEfficiencyList->At(3)))->Fill(Rapidity(particle->Px(),
3024                                                               particle->Py(),
3025                                                               particle->Pz()),
3026                                                      particle->Pt());
3027         }//weak decays
3028         if((particle->GetUniqueID() == 13)) {
3029           if(fAnalysisEtaMode) 
3030             ((TH2D *)(fEfficiencyList->At(5)))->Fill(particle->Eta(),
3031                                                      particle->Pt());
3032           else
3033             ((TH2D *)(fEfficiencyList->At(5)))->Fill(Rapidity(particle->Px(),
3034                                                               particle->Py(),
3035                                                               particle->Pz()),
3036                                                      particle->Pt());
3037         }//hadronic interactions
3038       }//antiprotons
3039     }//secondaries
3040   
3041   }//MC loop
3042
3043   //ESD track loop
3044   Int_t nGoodTracks = esd->GetNumberOfTracks();
3045   TArrayI labelArray(nGoodTracks);
3046   Int_t labelCounter = 0;
3047   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
3048     AliESDtrack* track = esd->GetTrack(iTracks);
3049     if(!track) continue;
3050     
3051     Int_t label = TMath::Abs(track->GetLabel());
3052     if(IsLabelUsed(labelArray,label)) continue;
3053     labelArray.AddAt(label,labelCounter);
3054     labelCounter += 1;
3055     
3056     TParticle *particle = stack->Particle(label);
3057     if(!particle) continue;
3058     Int_t pdgcode = particle->GetPdgCode();
3059     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
3060     
3061     Double_t Pt = 0.0, P = 0.0;
3062     Double_t probability[5];
3063     
3064     //TPC only
3065     if(fUseTPCOnly) {
3066       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
3067       if(!tpcTrack) continue;
3068       Pt = tpcTrack->Pt();
3069       P = tpcTrack->P();
3070       
3071       if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
3072       if(fAnalysisEtaMode) {
3073         if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
3074       }
3075       else 
3076         if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
3077       
3078       if(fUseCutsInEfficiency) 
3079         if(!IsAccepted(esd,vertex,track)) continue;
3080       
3081       //reconstructed primary (anti)protons
3082       if(pdgcode == 2212) {
3083         if(fAnalysisEtaMode)
3084           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
3085                                                     particle->Pt());
3086         else
3087           ((TH2D *)(fEfficiencyList->At(12)))->Fill(Rapidity(particle->Px(),
3088                                                              particle->Py(),
3089                                                              particle->Pz()),
3090                                                     particle->Pt());
3091         if(label <= stack->GetNprimary()) {
3092           nESDProtons += 1;
3093           if(fAnalysisEtaMode)
3094             ((TH2D *)(fEfficiencyList->At(6)))->Fill(particle->Eta(),
3095                                                      particle->Pt());
3096           else
3097             ((TH2D *)(fEfficiencyList->At(6)))->Fill(Rapidity(particle->Px(),
3098                                                               particle->Py(),
3099                                                               particle->Pz()),
3100                                                      particle->Pt());
3101         }//primaries
3102         if(label > stack->GetNprimary()) {
3103           Int_t lPartMother = -1;
3104           Int_t motherPDGCode = -1;
3105           lPartMother = particle->GetFirstMother();
3106           TParticle *motherParticle = stack->Particle(lPartMother);
3107           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3108           
3109           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
3110             if(fAnalysisEtaMode)
3111               ((TH2D *)(fEfficiencyList->At(8)))->Fill(particle->Eta(),
3112                                                        particle->Pt());
3113             else
3114               ((TH2D *)(fEfficiencyList->At(8)))->Fill(Rapidity(particle->Px(),
3115                                                                 particle->Py(),
3116                                                                 particle->Pz()),
3117                                                        particle->Pt());
3118           }//weak decays
3119           if((particle->GetUniqueID() == 13)) {
3120             if(fAnalysisEtaMode)
3121               ((TH2D *)(fEfficiencyList->At(10)))->Fill(particle->Eta(),
3122                                                         particle->Pt());
3123             else
3124               ((TH2D *)(fEfficiencyList->At(10)))->Fill(Rapidity(particle->Px(),
3125                                                                  particle->Py(),
3126                                                                  particle->Pz()),
3127                                                         particle->Pt());
3128           }//hadronic interactions
3129         }//secondaries
3130       }//initial protons
3131       if(pdgcode == -2212) {    
3132         if(fAnalysisEtaMode)
3133           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
3134                                                     particle->Pt());
3135         else
3136           ((TH2D *)(fEfficiencyList->At(12)))->Fill(Rapidity(particle->Px(),
3137                                                              particle->Py(),
3138                                                              particle->Pz()),
3139                                                     particle->Pt());
3140         if(label <= stack->GetNprimary()) {
3141           if(fAnalysisEtaMode)
3142             ((TH2D *)(fEfficiencyList->At(7)))->Fill(particle->Eta(),
3143                                                      particle->Pt());
3144           else
3145             ((TH2D *)(fEfficiencyList->At(7)))->Fill(Rapidity(particle->Px(),
3146                                                               particle->Py(),
3147                                                               particle->Pz()),
3148                                                      particle->Pt());
3149         }//primaries
3150         if(label > stack->GetNprimary()) {
3151           Int_t lPartMother = -1;
3152           Int_t motherPDGCode = -1;
3153           lPartMother = particle->GetFirstMother();
3154           TParticle *motherParticle = stack->Particle(lPartMother);
3155           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3156           
3157           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
3158             if(fAnalysisEtaMode)
3159               ((TH2D *)(fEfficiencyList->At(9)))->Fill(particle->Eta(),
3160                                                        particle->Pt());
3161             else
3162               ((TH2D *)(fEfficiencyList->At(9)))->Fill(Rapidity(particle->Px(),
3163                                                                 particle->Py(),
3164                                                                 particle->Pz()),
3165                                                        particle->Pt());
3166           }//weak decays
3167           if((particle->GetUniqueID() == 13)) {
3168             if(fAnalysisEtaMode)
3169               ((TH2D *)(fEfficiencyList->At(11)))->Fill(particle->Eta(),
3170                                                         particle->Pt());
3171             else
3172               ((TH2D *)(fEfficiencyList->At(11)))->Fill(Rapidity(particle->Px(),
3173                                                                  particle->Py(),
3174                                                                  particle->Pz()),
3175                                                         particle->Pt());
3176           }//hadronic interactions
3177         }//secondaries
3178       }//initial antiprotons
3179       
3180       //pid
3181       track->GetTPCpid(probability);
3182       Double_t rcc = 0.0;
3183       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3184         rcc += probability[i]*GetParticleFraction(i,P);
3185       if(rcc == 0.0) continue;
3186       Double_t w[5];
3187       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3188         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
3189       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
3190       if(fParticleType == 4) {
3191         if(fAnalysisEtaMode)
3192           ((TH2D *)(fEfficiencyList->At(14)))->Fill(particle->Eta(),
3193                                                     particle->Pt());
3194         else
3195           ((TH2D *)(fEfficiencyList->At(14)))->Fill(Rapidity(particle->Px(),
3196                                                              particle->Py(),
3197                                                              particle->Pz()),
3198                                                     particle->Pt());
3199         if(TMath::Abs(pdgcode) == 2212) {
3200           if(fAnalysisEtaMode)
3201             ((TH2D *)(fEfficiencyList->At(13)))->Fill(particle->Eta(),
3202                                                       particle->Pt());
3203           else
3204             ((TH2D *)(fEfficiencyList->At(13)))->Fill(Rapidity(particle->Px(),
3205                                                                particle->Py(),
3206                                                                particle->Pz()),
3207                                                       particle->Pt());
3208         }//properly identified as proton
3209         else {
3210           if(fAnalysisEtaMode)
3211             ((TH2D *)(fEfficiencyList->At(15)))->Fill(particle->Eta(),
3212                                                       particle->Pt());
3213           else
3214             ((TH2D *)(fEfficiencyList->At(15)))->Fill(Rapidity(particle->Px(),
3215                                                                particle->Py(),
3216                                                                particle->Pz()),
3217                                                       particle->Pt());
3218         }//contamination
3219       }//identified as proton
3220     }//TPC only tracks
3221     else if(!fUseTPCOnly) {
3222       if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
3223       if(fAnalysisEtaMode) {
3224         if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
3225       }
3226       else {
3227         if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
3228       }
3229       
3230       if(fUseCutsInEfficiency) 
3231         if(!IsAccepted(esd,vertex,track)) continue;
3232       
3233       //reconstructed primary (anti)protons
3234       if(pdgcode == 2212) {
3235         if(fAnalysisEtaMode)
3236           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
3237                                                     particle->Pt());
3238         else
3239           ((TH2D *)(fEfficiencyList->At(12)))->Fill(Rapidity(particle->Px(),
3240                                                              particle->Py(),
3241                                                              particle->Pz()),
3242                                                     particle->Pt());
3243         if(label <= stack->GetNprimary()) {
3244           nESDProtons += 1;
3245           if(fAnalysisEtaMode)
3246             ((TH2D *)(fEfficiencyList->At(6)))->Fill(particle->Eta(),
3247                                                      particle->Pt());
3248           else
3249             ((TH2D *)(fEfficiencyList->At(6)))->Fill(Rapidity(particle->Px(),
3250                                                               particle->Py(),
3251                                                               particle->Pz()),
3252                                                      particle->Pt());
3253         }//primaries
3254         if(label > stack->GetNprimary()) {
3255           Int_t lPartMother = -1;
3256           Int_t motherPDGCode = -1;
3257           lPartMother = particle->GetFirstMother();
3258           TParticle *motherParticle = stack->Particle(lPartMother);
3259           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3260           
3261           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
3262             if(fAnalysisEtaMode)
3263               ((TH2D *)(fEfficiencyList->At(8)))->Fill(particle->Eta(),
3264                                                        particle->Pt());
3265             else
3266               ((TH2D *)(fEfficiencyList->At(8)))->Fill(Rapidity(particle->Px(),
3267                                                                 particle->Py(),
3268                                                                 particle->Pz()),
3269                                                        particle->Pt());
3270           }//weak decays
3271           if((particle->GetUniqueID() == 13)) {
3272             if(fAnalysisEtaMode)
3273               ((TH2D *)(fEfficiencyList->At(10)))->Fill(particle->Eta(),
3274                                                         particle->Pt());
3275             else
3276               ((TH2D *)(fEfficiencyList->At(10)))->Fill(Rapidity(particle->Px(),
3277                                                                  particle->Py(),
3278                                                                  particle->Pz()),
3279                                                         particle->Pt());
3280           }//hadronic interactions
3281         }//secondaries
3282       }//initial protons
3283       if(pdgcode == -2212) {    
3284         if(fAnalysisEtaMode)
3285           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
3286                                                     particle->Pt());
3287         else
3288           ((TH2D *)(fEfficiencyList->At(12)))->Fill(Rapidity(particle->Px(),
3289                                                              particle->Py(),
3290                                                              particle->Pz()),
3291                                                     particle->Pt());
3292         if(label <= stack->GetNprimary()) {
3293           if(fAnalysisEtaMode)
3294             ((TH2D *)(fEfficiencyList->At(7)))->Fill(particle->Eta(),
3295                                                      particle->Pt());
3296           else
3297             ((TH2D *)(fEfficiencyList->At(7)))->Fill(Rapidity(particle->Px(),
3298                                                               particle->Py(),
3299                                                               particle->Pz()),
3300                                                      particle->Pt());
3301         }//primaries
3302         if(label > stack->GetNprimary()) {
3303           Int_t lPartMother = -1;
3304           Int_t motherPDGCode = -1;
3305           lPartMother = particle->GetFirstMother();
3306           TParticle *motherParticle = stack->Particle(lPartMother);
3307           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3308           
3309           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
3310             if(fAnalysisEtaMode)
3311               ((TH2D *)(fEfficiencyList->At(9)))->Fill(particle->Eta(),
3312                                                        particle->Pt());
3313             else
3314               ((TH2D *)(fEfficiencyList->At(9)))->Fill(Rapidity(particle->Px(),
3315                                                                 particle->Py(),
3316                                                                 particle->Pz()),
3317                                                        particle->Pt());
3318           }//weak decays
3319           if((particle->GetUniqueID() == 13)) {
3320             if(fAnalysisEtaMode)
3321               ((TH2D *)(fEfficiencyList->At(11)))->Fill(particle->Eta(),
3322                                                         particle->Pt());
3323             else
3324               ((TH2D *)(fEfficiencyList->At(11)))->Fill(Rapidity(particle->Px(),
3325                                                                  particle->Py(),
3326                                                                  particle->Pz()),
3327                                                         particle->Pt());
3328           }//hadronic interactions
3329         }//secondaries
3330       }//initial antiprotons
3331       
3332       //pid
3333       track->GetESDpid(probability);
3334       Double_t rcc = 0.0;
3335       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3336         rcc += probability[i]*GetParticleFraction(i,P);
3337       if(rcc == 0.0) continue;
3338       Double_t w[5];
3339       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3340         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
3341       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
3342       if(fParticleType == 4) {
3343         if(fAnalysisEtaMode)
3344           ((TH2D *)(fEfficiencyList->At(14)))->Fill(particle->Eta(),
3345                                                     particle->Pt());
3346         else ((TH2D *)(fEfficiencyList->At(14)))->Fill(Rapidity(particle->Px(),
3347                                                                 particle->Py(),
3348                                                                 particle->Pz()),
3349                                                        particle->Pt());
3350         if(TMath::Abs(pdgcode) == 2212) {
3351           if(fAnalysisEtaMode)
3352             ((TH2D *)(fEfficiencyList->At(13)))->Fill(particle->Eta(),
3353                                                       particle->Pt());
3354           else
3355             ((TH2D *)(fEfficiencyList->At(13)))->Fill(Rapidity(particle->Px(),
3356                                                                particle->Py(),
3357                                                                particle->Pz()),
3358                                                       particle->Pt());
3359         }//properly identified as proton
3360         else {
3361           if(fAnalysisEtaMode)
3362             ((TH2D *)(fEfficiencyList->At(15)))->Fill(particle->Eta(),
3363                                                       particle->Pt());
3364           else
3365             ((TH2D *)(fEfficiencyList->At(15)))->Fill(Rapidity(particle->Px(),
3366                                                                particle->Py(),
3367                                                                particle->Pz()),
3368                                                       particle->Pt());
3369         }//contamination
3370       }//identified as proton
3371     }//global tracking
3372   }//track loop
3373   
3374   //Printf("MC protons: %d - ESD protons: %d",nMCProtons,nESDProtons);
3375 }
3376
3377 //____________________________________________________________________//
3378 Bool_t AliProtonQAAnalysis::IsLabelUsed(TArrayI labelArray, 
3379                                         Int_t label) {
3380   //Checks if the label is used already
3381   Bool_t status = kFALSE;
3382   for(Int_t i = 0; i < labelArray.GetSize(); i++) {
3383     if(labelArray.At(i) == label)
3384       status = kTRUE;
3385   }
3386
3387   return status;
3388 }
3389
3390 //____________________________________________________________________//
3391 void AliProtonQAAnalysis::RunVertexQA(AliGenEventHeader *header,
3392                                       AliStack *stack, 
3393                                       AliESDEvent *esd) {
3394   //Runs the vertex QA
3395   //MC vertex
3396   TArrayF primaryVertex(3);
3397   header->PrimaryVertex(primaryVertex);
3398
3399   Int_t nPrimaries = stack->GetNprimary();
3400   ((TH1I *)(fQAVertexList->At(0)))->Fill(nPrimaries);
3401
3402   //TPC vertex
3403   const AliESDVertex *vertexTPC = esd->GetPrimaryVertexTPC();
3404   if(!vertexTPC) {
3405     Printf("ERROR: Could not retrieve the TPC vertex");
3406     return;
3407   }
3408   if(vertexTPC->GetNContributors() > 0) {
3409     ((TH1I *)(fQAVertexList->At(1)))->Fill(nPrimaries);
3410     ((TH2F *)(fQAVertexList->At(2)))->Fill(vertexTPC->GetXv(),
3411                                            vertexTPC->GetNContributors());
3412     ((TH2F *)(fQAVertexList->At(3)))->Fill(vertexTPC->GetYv(),
3413                                            vertexTPC->GetNContributors());
3414     ((TH2F *)(fQAVertexList->At(4)))->Fill(vertexTPC->GetZv(),
3415                                            vertexTPC->GetNContributors());
3416     ((TH1F *)(fQAVertexList->At(5)))->Fill((vertexTPC->GetXv()-primaryVertex[0])*10000.);
3417     ((TH1F *)(fQAVertexList->At(6)))->Fill((vertexTPC->GetYv()-primaryVertex[1])*10000.);
3418     ((TH1F *)(fQAVertexList->At(7)))->Fill((vertexTPC->GetZv()-primaryVertex[2])*10000.);
3419     ((TH1F *)(fQAVertexList->At(8)))->Fill(vertexTPC->GetXRes()*10000.);
3420     ((TH1F *)(fQAVertexList->At(9)))->Fill(vertexTPC->GetYRes()*10000.);
3421     ((TH1F *)(fQAVertexList->At(10)))->Fill(vertexTPC->GetZRes()*10000.);
3422   }//TPC vertex
3423
3424   //SPD vertex
3425   const AliESDVertex *vertexSPD = esd->GetPrimaryVertexSPD();
3426   if(!vertexSPD) {
3427     Printf("ERROR: Could not retrieve the SPD vertex");
3428     return;
3429   }
3430   if(vertexSPD->GetNContributors() > 0) {
3431     ((TH1I *)(fQAVertexList->At(11)))->Fill(nPrimaries);
3432     ((TH2F *)(fQAVertexList->At(12)))->Fill(vertexSPD->GetXv(),
3433                                             vertexSPD->GetNContributors());
3434     ((TH2F *)(fQAVertexList->At(13)))->Fill(vertexSPD->GetYv(),
3435                                             vertexSPD->GetNContributors());
3436     ((TH2F *)(fQAVertexList->At(14)))->Fill(vertexSPD->GetZv(),
3437                                             vertexSPD->GetNContributors());
3438     ((TH1F *)(fQAVertexList->At(15)))->Fill((vertexSPD->GetXv()-primaryVertex[0])*10000.);
3439     ((TH1F *)(fQAVertexList->At(16)))->Fill((vertexSPD->GetYv()-primaryVertex[1])*10000.);
3440     ((TH1F *)(fQAVertexList->At(17)))->Fill((vertexSPD->GetZv()-primaryVertex[2])*10000.);
3441     ((TH1F *)(fQAVertexList->At(18)))->Fill(vertexSPD->GetXRes()*10000.);
3442     ((TH1F *)(fQAVertexList->At(19)))->Fill(vertexSPD->GetYRes()*10000.);
3443     ((TH1F *)(fQAVertexList->At(20)))->Fill(vertexSPD->GetZRes()*10000.);
3444   }//SPD vertex
3445   
3446   //Tracks vertex
3447   const AliESDVertex *vertexTracks = esd->GetPrimaryVertex();
3448   if(!vertexTracks) {
3449     Printf("ERROR: Could not retrieve the Tracks vertex");
3450     return;
3451   }
3452   if(vertexTracks->GetNContributors() > 0) {
3453     ((TH1I *)(fQAVertexList->At(21)))->Fill(nPrimaries);
3454     ((TH2F *)(fQAVertexList->At(22)))->Fill(vertexTracks->GetXv(),
3455                                             vertexTracks->GetNContributors());
3456     ((TH2F *)(fQAVertexList->At(23)))->Fill(vertexTracks->GetYv(),
3457                                             vertexTracks->GetNContributors());
3458     ((TH2F *)(fQAVertexList->At(24)))->Fill(vertexTracks->GetZv(),
3459                                             vertexTracks->GetNContributors());
3460     ((TH1F *)(fQAVertexList->At(25)))->Fill((vertexTracks->GetXv()-primaryVertex[0])*10000.);
3461     ((TH1F *)(fQAVertexList->At(26)))->Fill((vertexTracks->GetYv()-primaryVertex[1])*10000.);
3462     ((TH1F *)(fQAVertexList->At(27)))->Fill((vertexTracks->GetZv()-primaryVertex[2])*10000.);
3463     ((TH1F *)(fQAVertexList->At(28)))->Fill(vertexTracks->GetXRes()*10000.);
3464     ((TH1F *)(fQAVertexList->At(29)))->Fill(vertexTracks->GetYRes()*10000.);
3465     ((TH1F *)(fQAVertexList->At(30)))->Fill(vertexTracks->GetZRes()*10000.);
3466   }//Tracks vertex
3467
3468 }
3469
3470 //____________________________________________________________________//
3471 void AliProtonQAAnalysis::RunQAAnalysis(AliStack *stack, 
3472                                         AliESDEvent *esd,
3473                                         const AliESDVertex *vertex) {
3474   //Runs the QA code
3475   //MC loop
3476   for(Int_t iParticle = 0; iParticle < stack->GetNprimary(); iParticle++) {
3477     TParticle *particle = stack->Particle(iParticle);
3478     if(!particle) continue;
3479
3480     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
3481     if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
3482     if(fAnalysisEtaMode) {
3483       if((particle->Eta() > fMaxY)||(particle->Eta() < fMinY)) continue;
3484     }
3485     else {
3486       if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
3487     }
3488     Int_t pdgcode = particle->GetPdgCode();
3489     if(pdgcode == 2212) {
3490       if(fAnalysisEtaMode)
3491         ((TH2D *)(fQA2DList->At(8)))->Fill(particle->Eta(),
3492                                            particle->Pt());
3493       else
3494         ((TH2D *)(fQA2DList->At(8)))->Fill(Rapidity(particle->Px(),
3495                                                     particle->Py(),
3496                                                     particle->Pz()),
3497                                            particle->Pt());
3498     }
3499     if(pdgcode == -2212) {
3500       if(fAnalysisEtaMode)
3501         ((TH2D *)(fQA2DList->At(9)))->Fill(particle->Eta(),
3502                                            particle->Pt());
3503       else
3504         ((TH2D *)(fQA2DList->At(9)))->Fill(Rapidity(particle->Px(),
3505                                                     particle->Py(),
3506                                                     particle->Pz()),
3507                                            particle->Pt());
3508     }
3509   }//MC loop
3510   
3511   //ESD track loop
3512   Int_t nGoodTracks = esd->GetNumberOfTracks();
3513   TArrayI labelArray(nGoodTracks);
3514   Int_t labelCounter = 0;
3515   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
3516     AliESDtrack* track = esd->GetTrack(iTracks);
3517     if(!track) continue;
3518     
3519     Int_t label = TMath::Abs(track->GetLabel()); 
3520     if(IsLabelUsed(labelArray,label)) continue;
3521     labelArray.AddAt(label,labelCounter);
3522     labelCounter += 1;
3523     
3524     TParticle *particle = stack->Particle(label);
3525     if(!particle) continue;
3526     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
3527     
3528     AliESDtrack trackTPC;
3529     
3530     //in case it's a TPC only track relate it to the proper vertex
3531     if((fUseTPCOnly)&&(!fUseHybridTPC)) {
3532       Float_t p[2],cov[3];
3533       track->GetImpactParametersTPC(p,cov);
3534       if (p[0]==0 && p[1]==0)  
3535         track->RelateToVertexTPC(((AliESDEvent*)esd)->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
3536       if (!track->FillTPCOnlyTrack(trackTPC)) {
3537         continue;
3538       }
3539       track = &trackTPC ;
3540     }
3541     
3542     Double_t Pt = 0.0, P = 0.0;
3543     Double_t probability[5];
3544     Float_t dcaXY = 0.0, dcaZ = 0.0;
3545     Double_t nSigmaToVertex = GetSigmaToVertex(track);
3546     Int_t  fIdxInt[200];
3547     Int_t nClustersITS = track->GetITSclusters(fIdxInt);
3548     Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
3549     
3550     Float_t chi2PerClusterITS = -1;
3551     if (nClustersITS!=0)
3552       chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
3553     Float_t chi2PerClusterTPC = -1;
3554     if (nClustersTPC!=0)
3555       chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
3556     Double_t chi2ConstrainVertex = TMath::Log(track->GetConstrainedChi2());    
3557     Double_t extCov[15];
3558     track->GetExternalCovariance(extCov);
3559     
3560     //TPC only
3561     if(fUseTPCOnly) {
3562       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
3563       if(!tpcTrack) continue;
3564       Pt = tpcTrack->Pt();
3565       P = tpcTrack->P();
3566       if(fUseHybridTPC) track->GetImpactParameters(dcaXY,dcaZ);
3567       else track->GetImpactParametersTPC(dcaXY,dcaZ);
3568       
3569       //pid
3570       track->GetTPCpid(probability);
3571       Double_t rcc = 0.0;
3572       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3573         rcc += probability[i]*GetParticleFraction(i,P);
3574       if(rcc == 0.0) continue;
3575       Double_t w[5];
3576       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3577         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
3578       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
3579       if(fParticleType == 4) {
3580         if(!IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
3581
3582         FillQA(stack,esd,vertex,track);
3583         if(IsAccepted(esd,vertex,track)) {
3584           if(label <= stack->GetNprimary()) {
3585             if(track->Charge() > 0) {
3586               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3587                 if(track->HasPointOnITSLayer(iLayer))
3588                   ((TH1F *)(fAcceptedCutList->At(0)))->Fill(iLayer+1);
3589               }
3590               ((TH1F *)(fAcceptedCutList->At(4)))->Fill(nClustersITS);
3591               ((TH1F *)(fAcceptedCutList->At(8)))->Fill(chi2PerClusterITS);
3592               ((TH1F *)(fAcceptedCutList->At(12)))->Fill(chi2ConstrainVertex);
3593               ((TH1F *)(fAcceptedCutList->At(16)))->Fill(nClustersTPC);
3594               ((TH1F *)(fAcceptedCutList->At(20)))->Fill(chi2PerClusterTPC);
3595               ((TH1F *)(fAcceptedCutList->At(24)))->Fill(extCov[0]);
3596               ((TH1F *)(fAcceptedCutList->At(28)))->Fill(extCov[2]);
3597               ((TH1F *)(fAcceptedCutList->At(32)))->Fill(extCov[5]);
3598               ((TH1F *)(fAcceptedCutList->At(36)))->Fill(extCov[9]);
3599               ((TH1F *)(fAcceptedCutList->At(40)))->Fill(extCov[14]);
3600               
3601               ((TH1F *)(fAcceptedDCAList->At(0)))->Fill(TMath::Abs(dcaXY));
3602               ((TH1F *)(fAcceptedDCAList->At(4)))->Fill(TMath::Abs(dcaZ));
3603               ((TH1F *)(fAcceptedDCAList->At(8)))->Fill(nSigmaToVertex);
3604               if(fAnalysisEtaMode)
3605                 ((TH2D *)(fQA2DList->At(0)))->Fill(tpcTrack->Eta(),Pt);
3606               else
3607                 ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(tpcTrack->Px(),
3608                                                             tpcTrack->Py(),
3609                                                             tpcTrack->Pz()),
3610                                                    Pt);
3611               ((TH2D *)(fQA2DList->At(12)))->Fill(tpcTrack->Eta(),
3612                                                   tpcTrack->Phi()*180./TMath::Pi());
3613             }//accepted primary protons
3614             else if(track->Charge() < 0) {
3615               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3616                 if(track->HasPointOnITSLayer(iLayer))
3617                   ((TH1F *)(fAcceptedCutList->At(1)))->Fill(iLayer+1);
3618               }
3619               ((TH1F *)(fAcceptedCutList->At(5)))->Fill(nClustersITS);
3620               ((TH1F *)(fAcceptedCutList->At(9)))->Fill(chi2PerClusterITS);
3621               ((TH1F *)(fAcceptedCutList->At(13)))->Fill(chi2ConstrainVertex);
3622               ((TH1F *)(fAcceptedCutList->At(17)))->Fill(nClustersTPC);
3623               ((TH1F *)(fAcceptedCutList->At(21)))->Fill(chi2PerClusterTPC);
3624               ((TH1F *)(fAcceptedCutList->At(25)))->Fill(extCov[0]);
3625               ((TH1F *)(fAcceptedCutList->At(29)))->Fill(extCov[2]);
3626               ((TH1F *)(fAcceptedCutList->At(33)))->Fill(extCov[5]);
3627               ((TH1F *)(fAcceptedCutList->At(37)))->Fill(extCov[9]);
3628               ((TH1F *)(fAcceptedCutList->At(41)))->Fill(extCov[14]);
3629               
3630               ((TH1F *)(fAcceptedDCAList->At(1)))->Fill(TMath::Abs(dcaXY));
3631               ((TH1F *)(fAcceptedDCAList->At(5)))->Fill(TMath::Abs(dcaZ));
3632               ((TH1F *)(fAcceptedDCAList->At(9)))->Fill(nSigmaToVertex);
3633               if(fAnalysisEtaMode)
3634                 ((TH2D *)(fQA2DList->At(4)))->Fill(tpcTrack->Eta(),Pt);
3635               else
3636                 ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(tpcTrack->Px(),
3637                                                             tpcTrack->Py(),
3638                                                             tpcTrack->Pz()),
3639                                                    Pt);
3640               ((TH2D *)(fQA2DList->At(16)))->Fill(tpcTrack->Eta(),
3641                                                   tpcTrack->Phi()*180./TMath::Pi());
3642             }//accepted primary antiprotons
3643           }//accepted primary particles
3644           else if(label > stack->GetNprimary()) {
3645             Int_t lPartMother = -1;
3646             Int_t motherPDGCode = -1;
3647             if(particle) {
3648               lPartMother = particle->GetFirstMother();
3649               TParticle *motherParticle = stack->Particle(lPartMother);
3650               if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3651             }
3652             
3653             if(fMCProcessIdFlag)
3654               if(particle->GetUniqueID() != fMCProcessId) continue;
3655             if(fMotherParticlePDGCodeFlag)
3656               if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
3657             
3658             if(track->Charge() > 0) {
3659               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3660                 if(track->HasPointOnITSLayer(iLayer))
3661                   ((TH1F *)(fAcceptedCutList->At(2)))->Fill(iLayer+1);
3662               }
3663               ((TH1F *)(fAcceptedCutList->At(6)))->Fill(nClustersITS);
3664               ((TH1F *)(fAcceptedCutList->At(10)))->Fill(chi2PerClusterITS);
3665               ((TH1F *)(fAcceptedCutList->At(14)))->Fill(chi2ConstrainVertex);
3666               ((TH1F *)(fAcceptedCutList->At(18)))->Fill(nClustersTPC);
3667               ((TH1F *)(fAcceptedCutList->At(22)))->Fill(chi2PerClusterTPC);
3668               ((TH1F *)(fAcceptedCutList->At(26)))->Fill(extCov[0]);
3669               ((TH1F *)(fAcceptedCutList->At(30)))->Fill(extCov[2]);
3670               ((TH1F *)(fAcceptedCutList->At(34)))->Fill(extCov[5]);
3671               ((TH1F *)(fAcceptedCutList->At(38)))->Fill(extCov[9]);
3672               ((TH1F *)(fAcceptedCutList->At(42)))->Fill(extCov[14]);
3673               
3674               ((TH1F *)(fAcceptedDCAList->At(2)))->Fill(TMath::Abs(dcaXY));
3675               ((TH1F *)(fAcceptedDCAList->At(6)))->Fill(TMath::Abs(dcaZ));
3676               ((TH1F *)(fAcceptedDCAList->At(10)))->Fill(nSigmaToVertex);
3677               if(fAnalysisEtaMode)
3678                 ((TH2D *)(fQA2DList->At(2)))->Fill(tpcTrack->Eta(),Pt);
3679               else
3680                 ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(tpcTrack->Px(),
3681                                                             tpcTrack->Py(),
3682                                                             tpcTrack->Pz()),
3683                                                    Pt);
3684               ((TH2D *)(fQA2DList->At(14)))->Fill(tpcTrack->Eta(),
3685                                                   tpcTrack->Phi()*180./TMath::Pi());
3686               if(fAnalysisEtaMode)
3687               ((TH3F *)(fQA2DList->At(10)))->Fill(tpcTrack->Eta(),Pt,
3688                                                   ConvertPDGToInt(motherPDGCode));
3689               else
3690                 ((TH3F *)(fQA2DList->At(10)))->Fill(Rapidity(tpcTrack->Px(),
3691                                                              tpcTrack->Py(),
3692                                                              tpcTrack->Pz()),
3693                                                     Pt,
3694                                                     ConvertPDGToInt(motherPDGCode));
3695             }//accepted secondary protons
3696             else if(track->Charge() < 0) {
3697               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3698                 if(track->HasPointOnITSLayer(iLayer))
3699                   ((TH1F *)(fAcceptedCutList->At(3)))->Fill(iLayer+1);
3700               }
3701               ((TH1F *)(fAcceptedCutList->At(7)))->Fill(nClustersITS);
3702               ((TH1F *)(fAcceptedCutList->At(11)))->Fill(chi2PerClusterITS);
3703               ((TH1F *)(fAcceptedCutList->At(15)))->Fill(chi2ConstrainVertex);
3704               ((TH1F *)(fAcceptedCutList->At(19)))->Fill(nClustersTPC);
3705               ((TH1F *)(fAcceptedCutList->At(23)))->Fill(chi2PerClusterTPC);
3706               ((TH1F *)(fAcceptedCutList->At(27)))->Fill(extCov[0]);
3707               ((TH1F *)(fAcceptedCutList->At(31)))->Fill(extCov[2]);
3708               ((TH1F *)(fAcceptedCutList->At(35)))->Fill(extCov[5]);
3709               ((TH1F *)(fAcceptedCutList->At(39)))->Fill(extCov[9]);
3710               ((TH1F *)(fAcceptedCutList->At(43)))->Fill(extCov[14]);
3711               
3712               ((TH1F *)(fAcceptedDCAList->At(3)))->Fill(TMath::Abs(dcaXY));
3713               ((TH1F *)(fAcceptedDCAList->At(7)))->Fill(TMath::Abs(dcaZ));
3714               ((TH1F *)(fAcceptedDCAList->At(11)))->Fill(nSigmaToVertex);
3715               if(fAnalysisEtaMode)
3716                 ((TH2D *)(fQA2DList->At(6)))->Fill(tpcTrack->Eta(),Pt);
3717               else
3718                 ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(tpcTrack->Px(),
3719                                                             tpcTrack->Py(),
3720                                                             tpcTrack->Pz()),
3721                                                    Pt);
3722               ((TH2D *)(fQA2DList->At(18)))->Fill(tpcTrack->Eta(),
3723                                                   tpcTrack->Phi()*180./TMath::Pi());
3724               if(fAnalysisEtaMode)
3725                 ((TH3F *)(fQA2DList->At(11)))->Fill(tpcTrack->Eta(),Pt,
3726                                                     ConvertPDGToInt(motherPDGCode));
3727               else
3728                 ((TH3F *)(fQA2DList->At(11)))->Fill(Rapidity(tpcTrack->Px(),
3729                                                              tpcTrack->Py(),
3730                                                              tpcTrack->Pz()),
3731                                                     Pt,
3732                                                     ConvertPDGToInt(motherPDGCode));
3733             }//accepted secondary antiprotons
3734           }//accepted secondary particles
3735         }//accepted - track cuts
3736         else {
3737           if(label <= stack->GetNprimary()) {
3738             if(track->Charge() > 0) {
3739               if(fAnalysisEtaMode)
3740                 ((TH2D *)(fQA2DList->At(1)))->Fill(tpcTrack->Eta(),Pt);
3741               else
3742                 ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(tpcTrack->Px(),
3743                                                             tpcTrack->Py(),
3744                                                             tpcTrack->Pz()),
3745                                                    Pt);
3746               ((TH2D *)(fQA2DList->At(13)))->Fill(tpcTrack->Eta(),
3747                                                   tpcTrack->Phi()*180./TMath::Pi());
3748             }
3749             else if(track->Charge() < 0) {
3750               if(fAnalysisEtaMode)
3751                 ((TH2D *)(fQA2DList->At(5)))->Fill(tpcTrack->Eta(),Pt);
3752               else
3753                 ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(tpcTrack->Px(),
3754                                                             tpcTrack->Py(),
3755                                                             tpcTrack->Pz()),
3756                                                    Pt);
3757               ((TH2D *)(fQA2DList->At(17)))->Fill(tpcTrack->Eta(),
3758                                                   tpcTrack->Phi()*180./TMath::Pi());
3759             }
3760           }//rejected primary particles
3761           else if(label > stack->GetNprimary()) {
3762             if(track->Charge() > 0) {
3763               if(fAnalysisEtaMode)
3764                 ((TH2D *)(fQA2DList->At(3)))->Fill(tpcTrack->Eta(),Pt);
3765               else
3766                 ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(tpcTrack->Px(),
3767                                                             tpcTrack->Py(),
3768                                                             tpcTrack->Pz()),
3769                                                    Pt);
3770               ((TH2D *)(fQA2DList->At(15)))->Fill(tpcTrack->Eta(),
3771                                                   tpcTrack->Phi()*180./TMath::Pi());
3772             }
3773             else if(track->Charge() < 0) {
3774               if(fAnalysisEtaMode)
3775                 ((TH2D *)(fQA2DList->At(7)))->Fill(tpcTrack->Eta(),Pt);
3776               else
3777                 ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(tpcTrack->Px(),
3778                                                             tpcTrack->Py(),
3779                                                             tpcTrack->Pz()),
3780                                                    Pt);
3781               ((TH2D *)(fQA2DList->At(19)))->Fill(tpcTrack->Eta(),
3782                                                   tpcTrack->Phi()*180./TMath::Pi());
3783             }
3784           }//rejected secondary particles
3785         }//rejected - track cuts
3786       }//proton check
3787     }//TPC only tracks
3788     //combined tracking
3789     else if(!fUseTPCOnly) {
3790       Pt = track->Pt();
3791       P = track->P();
3792       track->GetImpactParameters(dcaXY,dcaZ);
3793       
3794       //pid
3795       track->GetESDpid(probability);
3796       Double_t rcc = 0.0;
3797       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3798         rcc += probability[i]*GetParticleFraction(i,P);
3799       if(rcc == 0.0) continue;
3800       Double_t w[5];
3801       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3802         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
3803       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
3804       if(fParticleType == 4) {
3805         if(!IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
3806
3807         FillQA(stack,esd,vertex,track);
3808         if(IsAccepted(esd,vertex,track)) {
3809           if(label <= stack->GetNprimary()) {
3810             if(track->Charge() > 0) {
3811               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3812                 if(track->HasPointOnITSLayer(iLayer))
3813                   ((TH1F *)(fAcceptedCutList->At(0)))->Fill(iLayer+1);
3814               }
3815               ((TH1F *)(fAcceptedCutList->At(4)))->Fill(nClustersITS);
3816               ((TH1F *)(fAcceptedCutList->At(8)))->Fill(chi2PerClusterITS);
3817               ((TH1F *)(fAcceptedCutList->At(12)))->Fill(chi2ConstrainVertex);
3818               ((TH1F *)(fAcceptedCutList->At(16)))->Fill(nClustersTPC);
3819               ((TH1F *)(fAcceptedCutList->At(20)))->Fill(chi2PerClusterTPC);
3820               ((TH1F *)(fAcceptedCutList->At(24)))->Fill(extCov[0]);
3821               ((TH1F *)(fAcceptedCutList->At(28)))->Fill(extCov[2]);
3822               ((TH1F *)(fAcceptedCutList->At(32)))->Fill(extCov[5]);
3823               ((TH1F *)(fAcceptedCutList->At(36)))->Fill(extCov[9]);
3824               ((TH1F *)(fAcceptedCutList->At(40)))->Fill(extCov[14]);
3825               
3826               ((TH1F *)(fAcceptedDCAList->At(0)))->Fill(TMath::Abs(dcaXY));
3827               ((TH1F *)(fAcceptedDCAList->At(4)))->Fill(TMath::Abs(dcaZ));
3828               ((TH1F *)(fAcceptedDCAList->At(8)))->Fill(nSigmaToVertex);
3829               if(fAnalysisEtaMode)
3830                 ((TH2D *)(fQA2DList->At(0)))->Fill(track->Eta(),Pt);
3831               else
3832                 ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),
3833                                                             track->Py(),
3834                                                             track->Pz()),
3835                                                    Pt);
3836               ((TH2D *)(fQA2DList->At(12)))->Fill(track->Eta(),
3837                                                   track->Phi()*180./TMath::Pi());
3838             }
3839             else if(track->Charge() < 0) {
3840               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3841                 if(track->HasPointOnITSLayer(iLayer))
3842                   ((TH1F *)(fAcceptedCutList->At(1)))->Fill(iLayer+1);
3843               }
3844               ((TH1F *)(fAcceptedCutList->At(5)))->Fill(nClustersITS);
3845               ((TH1F *)(fAcceptedCutList->At(9)))->Fill(chi2PerClusterITS);
3846               ((TH1F *)(fAcceptedCutList->At(13)))->Fill(chi2ConstrainVertex);
3847               ((TH1F *)(fAcceptedCutList->At(17)))->Fill(nClustersTPC);
3848               ((TH1F *)(fAcceptedCutList->At(21)))->Fill(chi2PerClusterTPC);
3849               ((TH1F *)(fAcceptedCutList->At(25)))->Fill(extCov[0]);
3850               ((TH1F *)(fAcceptedCutList->At(29)))->Fill(extCov[2]);
3851               ((TH1F *)(fAcceptedCutList->At(33)))->Fill(extCov[5]);
3852               ((TH1F *)(fAcceptedCutList->At(37)))->Fill(extCov[9]);
3853               ((TH1F *)(fAcceptedCutList->At(41)))->Fill(extCov[14]);
3854               
3855               ((TH1F *)(fAcceptedDCAList->At(1)))->Fill(TMath::Abs(dcaXY));
3856               ((TH1F *)(fAcceptedDCAList->At(5)))->Fill(TMath::Abs(dcaZ));
3857               ((TH1F *)(fAcceptedDCAList->At(9)))->Fill(nSigmaToVertex);
3858               if(fAnalysisEtaMode)
3859                 ((TH2D *)(fQA2DList->At(4)))->Fill(track->Eta(),Pt);
3860               else
3861                 ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(track->Px(),
3862                                                             track->Py(),
3863                                                             track->Pz()),
3864                                                    Pt);
3865               ((TH2D *)(fQA2DList->At(16)))->Fill(track->Eta(),
3866                                                   track->Phi()*180./TMath::Pi());
3867             }
3868           }//primary particles
3869           else if(label > stack->GetNprimary()) {
3870             Int_t lPartMother = -1;
3871             Int_t motherPDGCode = -1;
3872             if(particle) {
3873               lPartMother = particle->GetFirstMother();
3874               TParticle *motherParticle = stack->Particle(lPartMother);
3875               if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3876             }
3877             
3878             if(fMCProcessIdFlag)
3879               if(particle->GetUniqueID() != fMCProcessId) continue;
3880             if(fMotherParticlePDGCodeFlag)
3881               if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
3882             
3883             if(track->Charge() > 0) {
3884               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3885                 if(track->HasPointOnITSLayer(iLayer))
3886                   ((TH1F *)(fAcceptedCutList->At(2)))->Fill(iLayer+1);
3887               }
3888               ((TH1F *)(fAcceptedCutList->At(6)))->Fill(nClustersITS);
3889               ((TH1F *)(fAcceptedCutList->At(10)))->Fill(chi2PerClusterITS);
3890               ((TH1F *)(fAcceptedCutList->At(14)))->Fill(chi2ConstrainVertex);
3891               ((TH1F *)(fAcceptedCutList->At(18)))->Fill(nClustersTPC);
3892               ((TH1F *)(fAcceptedCutList->At(22)))->Fill(chi2PerClusterTPC);
3893               ((TH1F *)(fAcceptedCutList->At(26)))->Fill(extCov[0]);
3894               ((TH1F *)(fAcceptedCutList->At(30)))->Fill(extCov[2]);
3895               ((TH1F *)(fAcceptedCutList->At(34)))->Fill(extCov[5]);
3896               ((TH1F *)(fAcceptedCutList->At(38)))->Fill(extCov[9]);
3897               ((TH1F *)(fAcceptedCutList->At(42)))->Fill(extCov[14]);
3898               
3899               ((TH1F *)(fAcceptedDCAList->At(2)))->Fill(TMath::Abs(dcaXY));
3900               ((TH1F *)(fAcceptedDCAList->At(6)))->Fill(TMath::Abs(dcaZ));
3901               ((TH1F *)(fAcceptedDCAList->At(10)))->Fill(nSigmaToVertex);
3902               if(fAnalysisEtaMode)
3903                 ((TH2D *)(fQA2DList->At(2)))->Fill(track->Eta(),Pt);
3904               else
3905                 ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),
3906                                                             track->Py(),
3907                                                             track->Pz()),
3908                                                    Pt);
3909               ((TH2D *)(fQA2DList->At(14)))->Fill(track->Eta(),
3910                                                   track->Phi()*180./TMath::Pi());
3911               if(fAnalysisEtaMode)
3912                 ((TH3F *)(fQA2DList->At(10)))->Fill(track->Eta(),Pt,
3913                                                     ConvertPDGToInt(motherPDGCode));
3914               else
3915                 ((TH3F *)(fQA2DList->At(10)))->Fill(Rapidity(track->Px(),
3916                                                              track->Py(),
3917                                                              track->Pz()),
3918                                                     Pt,
3919                                                     ConvertPDGToInt(motherPDGCode));
3920             }
3921             else if(track->Charge() < 0) {
3922               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3923                 if(track->HasPointOnITSLayer(iLayer))
3924                   ((TH1F *)(fAcceptedCutList->At(3)))->Fill(iLayer+1);
3925               }
3926               ((TH1F *)(fAcceptedCutList->At(7)))->Fill(nClustersITS);
3927               ((TH1F *)(fAcceptedCutList->At(11)))->Fill(chi2PerClusterITS);
3928               ((TH1F *)(fAcceptedCutList->At(15)))->Fill(chi2ConstrainVertex);
3929               ((TH1F *)(fAcceptedCutList->At(19)))->Fill(nClustersTPC);
3930               ((TH1F *)(fAcceptedCutList->At(23)))->Fill(chi2PerClusterTPC);
3931               ((TH1F *)(fAcceptedCutList->At(27)))->Fill(extCov[0]);
3932               ((TH1F *)(fAcceptedCutList->At(31)))->Fill(extCov[2]);
3933               ((TH1F *)(fAcceptedCutList->At(35)))->Fill(extCov[5]);
3934               ((TH1F *)(fAcceptedCutList->At(39)))->Fill(extCov[9]);
3935               ((TH1F *)(fAcceptedCutList->At(43)))->Fill(extCov[14]);
3936               
3937               ((TH1F *)(fAcceptedDCAList->At(3)))->Fill(TMath::Abs(dcaXY));
3938               ((TH1F *)(fAcceptedDCAList->At(7)))->Fill(TMath::Abs(dcaZ));
3939               ((TH1F *)(fAcceptedDCAList->At(11)))->Fill(nSigmaToVertex);
3940               if(fAnalysisEtaMode)
3941                 ((TH2D *)(fQA2DList->At(6)))->Fill(track->Eta(),Pt);
3942               else
3943                 ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(track->Px(),
3944                                                             track->Py(),
3945                                                             track->Pz()),
3946                                                    Pt);
3947               
3948               ((TH2D *)(fQA2DList->At(18)))->Fill(track->Eta(),
3949                                                   track->Phi()*180./TMath::Pi());
3950               if(fAnalysisEtaMode)
3951                 ((TH3F *)(fQA2DList->At(11)))->Fill(track->Eta(),Pt,
3952                                                     ConvertPDGToInt(motherPDGCode));
3953               else
3954                 ((TH3F *)(fQA2DList->At(11)))->Fill(Rapidity(track->Px(),
3955                                                              track->Py(),
3956                                                              track->Pz()),
3957                                                     Pt,
3958                                                     ConvertPDGToInt(motherPDGCode));
3959             }
3960           }//secondary particles
3961         }//accepted - track cuts
3962         else if(!IsAccepted(esd,vertex,track)) {
3963           if(label <= stack->GetNprimary()) {
3964             if(track->Charge() > 0) {
3965               if(fAnalysisEtaMode)
3966                 ((TH2D *)(fQA2DList->At(1)))->Fill(track->Eta(),Pt);
3967               else
3968                 ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),
3969                                                             track->Py(),
3970                                                             track->Pz()),
3971                                                    Pt);
3972               ((TH2D *)(fQA2DList->At(13)))->Fill(track->Eta(),
3973                                                   track->Phi()*180./TMath::Pi());
3974             }
3975             else if(track->Charge() < 0) {
3976               if(fAnalysisEtaMode)
3977                 ((TH2D *)(fQA2DList->At(5)))->Fill(track->Eta(),Pt);
3978               else
3979                 ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(track->Px(),
3980                                                             track->Py(),
3981                                                             track->Pz()),
3982                                                    Pt);
3983               ((TH2D *)(fQA2DList->At(17)))->Fill(track->Eta(),
3984                                                   track->Phi()*180./TMath::Pi());
3985             }
3986           }//primary particles
3987           else if(label > stack->GetNprimary()) {
3988             if(track->Charge() > 0) {
3989               if(fAnalysisEtaMode)
3990                 ((TH2D *)(fQA2DList->At(3)))->Fill(track->Eta(),Pt);
3991               else
3992                 ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),
3993                                                             track->Py(),
3994                                                             track->Pz()),
3995                                                    Pt);
3996               ((TH2D *)(fQA2DList->At(15)))->Fill(track->Eta(),
3997                                                   track->Phi()*180./TMath::Pi());
3998             }
3999             else if(track->Charge() < 0) {
4000               if(fAnalysisEtaMode)
4001                 ((TH2D *)(fQA2DList->At(7)))->Fill(track->Eta(),Pt);
4002               else
4003                 ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(track->Px(),
4004                                                             track->Py(),
4005                                                             track->Pz()),
4006                                                    Pt);
4007               ((TH2D *)(fQA2DList->At(19)))->Fill(track->Eta(),
4008                                                   track->Phi()*180./TMath::Pi());
4009             }
4010           }//secondary particles
4011         }//rejected - track cuts
4012       }//proton check
4013     }//combined tracking
4014   }//track loop
4015     
4016 }
4017
4018 //____________________________________________________________________//
4019 void AliProtonQAAnalysis::InitMCAnalysis() {
4020   //MC analysis - 3D histograms: y-pT-pdg
4021   fPDGList = new TList();
4022   TH3F *gHistYPtPDGProtons = new TH3F("gHistYPtPDGProtons",
4023                                       ";;P_{T} [GeV/c];PDG",
4024                                       fNBinsY,fMinY,fMaxY,
4025                                       fNBinsPt,fMinPt,fMaxPt,
4026                                       14,-0.5,13.5);
4027   if(fAnalysisEtaMode) 
4028     gHistYPtPDGProtons->GetXaxis()->SetTitle("#eta");
4029   else 
4030     gHistYPtPDGProtons->GetXaxis()->SetTitle("y");
4031   fPDGList->Add(gHistYPtPDGProtons);
4032   TH3F *gHistYPtPDGAntiProtons = new TH3F("gHistYPtPDGAntiProtons",
4033                                           ";;P_{T} [GeV/c];PDG",
4034                                           fNBinsY,fMinY,fMaxY,
4035                                           fNBinsPt,fMinPt,fMaxPt,
4036                                           14,-0.5,13.5);
4037   if(fAnalysisEtaMode) 
4038     gHistYPtPDGAntiProtons->GetXaxis()->SetTitle("#eta");
4039   else 
4040     gHistYPtPDGAntiProtons->GetXaxis()->SetTitle("y");
4041   fPDGList->Add(gHistYPtPDGAntiProtons);
4042
4043   //MC processes
4044   fMCProcessesList = new TList();
4045   TH1F *gHistProtonsFromKLProcess = new TH1F("gHistProtonsFromKLProcess","",51,-0.5,50.5);
4046   fMCProcessesList->Add(gHistProtonsFromKLProcess);
4047   TH1F *gHistProtonsFromPionProcess = new TH1F("gHistProtonsFromPionProcess","",51,-0.5,50.5);
4048   fMCProcessesList->Add(gHistProtonsFromPionProcess);
4049   TH1F *gHistProtonsFromKSProcess = new TH1F("gHistProtonsFromKSProcess","",51,-0.5,50.5);
4050   fMCProcessesList->Add(gHistProtonsFromKSProcess);
4051   TH1F *gHistProtonsFromKaonProcess = new TH1F("gHistProtonsFromKaonProcess","",51,-0.5,50.5);
4052   fMCProcessesList->Add(gHistProtonsFromKaonProcess);
4053   TH1F *gHistProtonsFromNeutronProcess = new TH1F("gHistProtonsFromNeutronProcess","",51,-0.5,50.5);
4054   fMCProcessesList->Add(gHistProtonsFromNeutronProcess);
4055   TH1F *gHistProtonsFromProtonProcess = new TH1F("gHistProtonsFromProtonProcess","",51,-0.5,50.5);
4056   fMCProcessesList->Add(gHistProtonsFromProtonProcess);
4057   TH1F *gHistProtonsFromSigmaMinusProcess = new TH1F("gHistProtonsFromSigmaMinusProcess","",51,-0.5,50.5);
4058   fMCProcessesList->Add(gHistProtonsFromSigmaMinusProcess);
4059   TH1F *gHistProtonsFromLambda0Process = new TH1F("gHistProtonsFromLambda0Process","",51,-0.5,50.5);
4060   fMCProcessesList->Add(gHistProtonsFromLambda0Process);
4061   TH1F *gHistProtonsFromSigmaPlusProcess = new TH1F("gHistProtonsFromSigmaPlusProcess","",51,-0.5,50.5);
4062   fMCProcessesList->Add(gHistProtonsFromSigmaPlusProcess);
4063   TH1F *gHistProtonsFromXiMinusProcess = new TH1F("gHistProtonsFromXiMinusProcess","",51,-0.5,50.5);
4064   fMCProcessesList->Add(gHistProtonsFromXiMinusProcess);
4065   TH1F *gHistProtonsFromXi0Process = new TH1F("gHistProtonsFromXi0Process","",51,-0.5,50.5);                                        
4066   fMCProcessesList->Add(gHistProtonsFromXi0Process);
4067   TH1F *gHistProtonsFromOmegaProcess = new TH1F("gHistProtonsFromOmegaProcess","",51,-0.5,50.5); 
4068   fMCProcessesList->Add(gHistProtonsFromOmegaProcess);
4069
4070   TH1F *gHistAntiProtonsFromKLProcess = new TH1F("gHistAntiProtonsFromKLProcess","",51,-0.5,50.5); 
4071   fMCProcessesList->Add(gHistAntiProtonsFromKLProcess);
4072   TH1F *gHistAntiProtonsFromPionProcess = new TH1F("gHistAntiProtonsFromPionProcess","",51,-0.5,50.5); 
4073   fMCProcessesList->Add(gHistAntiProtonsFromPionProcess);
4074   TH1F *gHistAntiProtonsFromKSProcess = new TH1F("gHistAntiProtonsFromKSProcess","",51,-0.5,50.5); 
4075   fMCProcessesList->Add(gHistAntiProtonsFromKSProcess);
4076   TH1F *gHistAntiProtonsFromKaonProcess = new TH1F("gHistAntiProtonsFromKaonProcess","",51,-0.5,50.5); 
4077   fMCProcessesList->Add(gHistAntiProtonsFromKaonProcess);
4078   TH1F *gHistAntiProtonsFromNeutronProcess = new TH1F("gHistAntiProtonsFromNeutronProcess","",51,-0.5,50.5); 
4079   fMCProcessesList->Add(gHistAntiProtonsFromNeutronProcess);
4080   TH1F *gHistAntiProtonsFromProtonProcess = new TH1F("gHistAntiProtonsFromProtonProcess","",51,-0.5,50.5); 
4081   fMCProcessesList->Add(gHistAntiProtonsFromProtonProcess);
4082   TH1F *gHistAntiProtonsFromLambda0Process = new TH1F("gHistAntiProtonsFromLambda0Process","",51,-0.5,50.5); 
4083   fMCProcessesList->Add(gHistAntiProtonsFromLambda0Process);
4084   TH1F *gHistAntiProtonsFromSigmaPlusProcess = new TH1F("gHistAntiProtonsFromSigmaPlusProcess","",51,-0.5,50.5); 
4085   fMCProcessesList->Add(gHistAntiProtonsFromSigmaPlusProcess);
4086 }
4087
4088 //____________________________________________________________________//
4089 void AliProtonQAAnalysis::RunMCAnalysis(AliStack* stack) {
4090   //Main analysis part - MC 
4091   for(Int_t iParticle = 0; iParticle < stack->GetNtrack(); iParticle++) {
4092     TParticle *particle = stack->Particle(iParticle);
4093     if(!particle) continue;
4094
4095     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
4096     if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
4097     if(fAnalysisEtaMode) {
4098       if((particle->Eta() > fMaxY)||(particle->Eta() < fMinY)) continue;
4099     }
4100     else {
4101       if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
4102     }
4103
4104     Int_t pdgcode = particle->GetPdgCode();
4105     if(pdgcode == 2212) {
4106       if(iParticle <= stack->GetNprimary()) {
4107         if(fAnalysisEtaMode)
4108           ((TH3F *)(fPDGList->At(0)))->Fill(particle->Eta(),particle->Pt(),0);
4109         else
4110           ((TH3F *)(fPDGList->At(0)))->Fill(Rapidity(particle->Px(),
4111                                                      particle->Py(),
4112                                                      particle->Pz()),
4113                                             particle->Pt(),0);
4114       }
4115       else if(iParticle > stack->GetNprimary()) {
4116         Int_t lPartMother = particle->GetFirstMother();
4117         TParticle *motherParticle = stack->Particle(lPartMother);
4118         if(!motherParticle) continue;
4119         Int_t motherPDGCode = motherParticle->GetPdgCode();
4120         if(fMCProcessIdFlag)
4121           if(particle->GetUniqueID() != fMCProcessId) continue;
4122         if(fMotherParticlePDGCodeFlag)
4123           if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
4124
4125         if(fAnalysisEtaMode)
4126           ((TH3F *)(fPDGList->At(0)))->Fill(particle->Eta(),
4127                                             particle->Pt(),
4128                                             ConvertPDGToInt(motherParticle->GetPdgCode()));
4129         else
4130           ((TH3F *)(fPDGList->At(0)))->Fill(Rapidity(particle->Px(),
4131                                                      particle->Py(),
4132                                                      particle->Pz()),
4133                                             particle->Pt(),
4134                                             ConvertPDGToInt(motherParticle->GetPdgCode()));
4135         //processes
4136         if(TMath::Abs(motherParticle->GetPdgCode()) == 130)
4137           ((TH1F *)(fMCProcessesList->At(0)))->Fill(particle->GetUniqueID());
4138         if(TMath::Abs(motherParticle->GetPdgCode()) == 211)
4139           ((TH1F *)(fMCProcessesList->At(1)))->Fill(particle->GetUniqueID());
4140         if(TMath::Abs(motherParticle->GetPdgCode()) == 310)
4141           ((TH1F *)(fMCProcessesList->At(2)))->Fill(particle->GetUniqueID());
4142         if(TMath::Abs(motherParticle->GetPdgCode()) == 321)
4143           ((TH1F *)(fMCProcessesList->At(3)))->Fill(particle->GetUniqueID());
4144         if(TMath::Abs(motherParticle->GetPdgCode()) == 2112)
4145           ((TH1F *)(fMCProcessesList->At(4)))->Fill(particle->GetUniqueID());
4146         if(TMath::Abs(motherParticle->GetPdgCode()) == 2212)
4147           ((TH1F *)(fMCProcessesList->At(5)))->Fill(particle->GetUniqueID());
4148         if(TMath::Abs(motherParticle->GetPdgCode()) == 3112)
4149           ((TH1F *)(fMCProcessesList->At(6)))->Fill(particle->GetUniqueID());
4150         if(TMath::Abs(motherParticle->GetPdgCode()) == 3122)
4151           ((TH1F *)(fMCProcessesList->At(7)))->Fill(particle->GetUniqueID());
4152         if(TMath::Abs(motherParticle->GetPdgCode()) == 3222)
4153           ((TH1F *)(fMCProcessesList->At(8)))->Fill(particle->GetUniqueID());
4154         if(TMath::Abs(motherParticle->GetPdgCode()) == 3312)
4155           ((TH1F *)(fMCProcessesList->At(9)))->Fill(particle->GetUniqueID());
4156         if(TMath::Abs(motherParticle->GetPdgCode()) == 3322)
4157           ((TH1F *)(fMCProcessesList->At(10)))->Fill(particle->GetUniqueID());
4158         if(TMath::Abs(motherParticle->GetPdgCode()) == 3334)
4159           ((TH1F *)(fMCProcessesList->At(11)))->Fill(particle->GetUniqueID());
4160       }//secondary proton
4161     }//pdgcode of proton
4162
4163     if(pdgcode == -2212) {
4164       if(iParticle <= stack->GetNprimary()) {
4165         if(fAnalysisEtaMode)
4166           ((TH3F *)(fPDGList->At(1)))->Fill(particle->Eta(),particle->Pt(),0);
4167         else
4168           ((TH3F *)(fPDGList->At(1)))->Fill(Rapidity(particle->Px(),
4169                                                      particle->Py(),
4170                                                      particle->Pz()),
4171                                             particle->Pt(),0);
4172       }
4173       else if(iParticle > stack->GetNprimary()) {
4174         Int_t lPartMother = particle->GetFirstMother();
4175         TParticle *motherParticle = stack->Particle(lPartMother);
4176         if(!motherParticle) continue;
4177         Int_t motherPDGCode = motherParticle->GetPdgCode();
4178         if(fMCProcessIdFlag)
4179           if(particle->GetUniqueID() != fMCProcessId) continue;
4180         if(fMotherParticlePDGCodeFlag)
4181           if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
4182
4183         if(fAnalysisEtaMode)
4184           ((TH3F *)(fPDGList->At(1)))->Fill(particle->Eta(),
4185                                             particle->Pt(),
4186                                             ConvertPDGToInt(motherParticle->GetPdgCode()));
4187         else
4188           ((TH3F *)(fPDGList->At(1)))->Fill(Rapidity(particle->Px(),
4189                                                      particle->Py(),
4190                                                      particle->Pz()),
4191                                             particle->Pt(),
4192                                             ConvertPDGToInt(motherParticle->GetPdgCode()));
4193
4194         //processes
4195         if(TMath::Abs(motherParticle->GetPdgCode()) == 130)
4196           ((TH1F *)(fMCProcessesList->At(12)))->Fill(particle->GetUniqueID());
4197         if(TMath::Abs(motherParticle->GetPdgCode()) == 211)
4198           ((TH1F *)(fMCProcessesList->At(13)))->Fill(particle->GetUniqueID());
4199         if(TMath::Abs(motherParticle->GetPdgCode()) == 310)
4200           ((TH1F *)(fMCProcessesList->At(14)))->Fill(particle->GetUniqueID());
4201         if(TMath::Abs(motherParticle->GetPdgCode()) == 321)
4202           ((TH1F *)(fMCProcessesList->At(15)))->Fill(particle->GetUniqueID());
4203         if(TMath::Abs(motherParticle->GetPdgCode()) == 2112)
4204           ((TH1F *)(fMCProcessesList->At(16)))->Fill(particle->GetUniqueID());
4205         if(TMath::Abs(motherParticle->GetPdgCode()) == 2212)
4206           ((TH1F *)(fMCProcessesList->At(17)))->Fill(particle->GetUniqueID());
4207         if(TMath::Abs(motherParticle->GetPdgCode()) == 3122)
4208           ((TH1F *)(fMCProcessesList->At(18)))->Fill(particle->GetUniqueID());
4209         if(TMath::Abs(motherParticle->GetPdgCode()) == 3222)
4210           ((TH1F *)(fMCProcessesList->At(19)))->Fill(particle->GetUniqueID());
4211       }//secondary antiproton
4212     }//pdgcode of antiproton
4213
4214   }//particle loop
4215 }
4216
4217 //____________________________________________________________________//
4218 Int_t AliProtonQAAnalysis::ConvertPDGToInt(Int_t pdgCode) {
4219   //Converts the pdg code to an int based on the following scheme:
4220   //1: PDG code: 130 - Name: K_L0
4221   //2: PDG code: 211 - Name: pi+
4222   //3: PDG code: 310 - Name: K_S0
4223   //4: PDG code: 321 - Name: K+
4224   //5: PDG code: 2112 - Name: neutron
4225   //6: PDG code: 2212 - Name: proton
4226   //7: PDG code: 3112 - Name: Sigma-
4227   //8: PDG code: 3122 - Name: Lambda0
4228   //9: PDG code: 3222 - Name: Sigma+
4229   //10: PDG code: 3312 - Name: Xi-
4230   //11: PDG code: 3322 - Name: Xi0
4231   //12: PDG code: 3334 - Name: Omega-
4232   Int_t code = -1;
4233   switch (TMath::Abs(pdgCode)) {
4234   case 130: {
4235     code = 1;
4236     break;
4237   }
4238   case 211: {
4239     code = 2;
4240     break;
4241   }
4242   case 310: {
4243     code = 3;
4244     break;
4245   }
4246   case 321: {
4247     code = 4;
4248     break;
4249   }
4250   case 2112: {
4251     code = 5;
4252     break;
4253   }
4254   case 2212: {
4255     code = 6;
4256     break;
4257   }
4258   case 3112: {
4259     code = 7;
4260     break;
4261   }
4262   case 3122: {
4263     code = 8;
4264     break;
4265   }
4266   case 3222: {
4267     code = 9;
4268     break;
4269   }
4270   case 3312: {
4271     code = 10;
4272     break;
4273   }
4274   case 3322: {
4275     code = 11;
4276     break;
4277   }
4278   case 3334: {
4279     code = 12;
4280     break;
4281   }
4282   default: {
4283     code = -1;
4284     break;
4285   }
4286   }//switch
4287
4288   return code;
4289 }
4290
4291 //________________________________________________________________________
4292 /*const AliESDVertex* AliProtonQAAnalysis::GetVertex(AliESDEvent* esd,
4293                                                    Double_t gVxMax,
4294                                                    Double_t gVyMax,
4295                                                    Double_t gVzMax) {
4296   // Get the vertex from the ESD and returns it if the vertex is valid
4297   // depending on the analysis mode: TPC - Hybrid - Global
4298   const AliESDVertex* vertex = 0;
4299   if((fUseTPCOnly)&&(!fUseHybridTPC)) {
4300     Double_t kBz = esd->GetMagneticField();
4301     AliVertexerTracks vertexer(kBz);
4302     vertexer.SetTPCMode();
4303     AliESDVertex *vTPC = vertexer.FindPrimaryVertex(esd);
4304     esd->SetPrimaryVertexTPC(vTPC);
4305     for (Int_t i=0; i<esd->GetNumberOfTracks(); i++) {
4306       AliESDtrack *t = esd->GetTrack(i);
4307       t->RelateToVertexTPC(vTPC, kBz, kVeryBig);
4308     }
4309     delete vTPC;
4310     vertex = esd->GetPrimaryVertexTPC();
4311   }
4312   else if(fUseHybridTPC)
4313     vertex = esd->GetPrimaryVertexSPD();
4314   else if(!fUseTPCOnly)
4315     vertex = esd->GetPrimaryVertex();
4316   else
4317     Printf("GetVertex: ERROR: Invalid analysis mode");
4318   
4319   if(!vertex) return 0;
4320   
4321   // check Ncontributors
4322   if(vertex->GetNContributors() <= 0) return 0;
4323   
4324   // check resolution
4325   Double_t zRes = vertex->GetZRes();
4326   if(zRes == 0) return 0;
4327   
4328   //check position
4329   if(TMath::Abs(vertex->GetXv()) > gVxMax) return 0;
4330   if(TMath::Abs(vertex->GetYv()) > gVyMax) return 0;
4331   if(TMath::Abs(vertex->GetZv()) > gVzMax) return 0;
4332
4333   return vertex;
4334   }*/
4335
4336
4337
4338
4339
4340
4341