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