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