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