]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/AliProtonQAAnalysis.cxx
Monitoring the eta-phi plots
[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   //eta-phi
1913   TH2D *gHistEtaPhiPrimaryProtonsPass = new TH2D("gHistEtaPhiPrimaryProtonsPass",
1914                                                  ";#eta;#phi [deg.]",
1915                                                  fNBinsY,fMinY,fMaxY,
1916                                                  100,0.,360.);
1917   gHistEtaPhiPrimaryProtonsPass->SetStats(kTRUE);
1918   gHistEtaPhiPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
1919   fQA2DList->Add(gHistEtaPhiPrimaryProtonsPass);//eta-phi of primary accepted ESD protons
1920   TH2D *gHistEtaPhiPrimaryProtonsReject = new TH2D("gHistEtaPhiPrimaryProtonsReject",
1921                                                    ";#eta;#phi [deg.]",
1922                                                    fNBinsY,fMinY,fMaxY,
1923                                                    100,0.,360.);
1924   gHistEtaPhiPrimaryProtonsReject->SetStats(kTRUE);
1925   gHistEtaPhiPrimaryProtonsReject->GetXaxis()->SetTitleColor(1);
1926   fQA2DList->Add(gHistEtaPhiPrimaryProtonsReject);//eta-phi of primary rejected ESD protons
1927   TH2D *gHistEtaPhiSecondaryProtonsPass = new TH2D("gHistEtaPhiSecondaryProtonsPass",
1928                                                    ";#eta;#phi [deg.]",
1929                                                    fNBinsY,fMinY,fMaxY,
1930                                                    100,0.,360.);
1931   gHistEtaPhiSecondaryProtonsPass->SetStats(kTRUE);
1932   gHistEtaPhiSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
1933   fQA2DList->Add(gHistEtaPhiSecondaryProtonsPass);//eta-phi of secondary accepted ESD protons
1934   TH2D *gHistEtaPhiSecondaryProtonsReject = new TH2D("gHistEtaPhiSecondaryProtonsReject",
1935                                                      ";#eta;#phi [deg.]",
1936                                                      fNBinsY,fMinY,fMaxY,
1937                                                      100,0.,360.);
1938   gHistEtaPhiSecondaryProtonsReject->SetStats(kTRUE);
1939   gHistEtaPhiSecondaryProtonsReject->GetXaxis()->SetTitleColor(1);
1940   fQA2DList->Add(gHistEtaPhiSecondaryProtonsReject);//eta-phi of secondary rejected ESD protons
1941
1942   TH2D *gHistEtaPhiPrimaryAntiProtonsPass = new TH2D("gHistEtaPhiPrimaryAntiProtonsPass",
1943                                                      ";#eta;#phi [deg.]",
1944                                                      fNBinsY,fMinY,fMaxY,
1945                                                      100,0.,360.);
1946   gHistEtaPhiPrimaryAntiProtonsPass->SetStats(kTRUE);
1947   gHistEtaPhiPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
1948   fQA2DList->Add(gHistEtaPhiPrimaryAntiProtonsPass);//eta-phi of primary accepted ESD antiprotons
1949   TH2D *gHistEtaPhiPrimaryAntiProtonsReject = new TH2D("gHistEtaPhiPrimaryAntiProtonsReject",
1950                                                        ";#eta;#phi [deg.]",
1951                                                        fNBinsY,fMinY,fMaxY,
1952                                                        100,0.,360.);
1953   gHistEtaPhiPrimaryAntiProtonsReject->SetStats(kTRUE);
1954   gHistEtaPhiPrimaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
1955   fQA2DList->Add(gHistEtaPhiPrimaryAntiProtonsReject);//eta-phi of primary rejected ESD antiprotons
1956   TH2D *gHistEtaPhiSecondaryAntiProtonsPass = new TH2D("gHistEtaPhiSecondaryAntiProtonsPass",
1957                                                        ";#eta;#phi [deg.]",
1958                                                        fNBinsY,fMinY,fMaxY,
1959                                                        100,0.,360.);
1960   gHistEtaPhiSecondaryAntiProtonsPass->SetStats(kTRUE);
1961   gHistEtaPhiSecondaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
1962   fQA2DList->Add(gHistEtaPhiSecondaryAntiProtonsPass);//eta-phi of secondary accepted ESD antiprotons
1963   TH2D *gHistEtaPhiSecondaryAntiProtonsReject = new TH2D("gHistEtaPhiSecondaryAntiProtonsReject",
1964                                                          ";#eta;#phi [deg.]",
1965                                                          fNBinsY,fMinY,fMaxY,
1966                                                          100,0.,360.);
1967   gHistEtaPhiSecondaryAntiProtonsReject->SetStats(kTRUE);
1968   gHistEtaPhiSecondaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
1969   fQA2DList->Add(gHistEtaPhiSecondaryAntiProtonsReject);//eta-phi of secondary rejected ESD antiprotons
1970
1971   /*gDirectory->cd("../");
1972   //protons
1973   TDirectory *dirProtons = gDirectory->mkdir("Protons");
1974   fGlobalQAList->Add(dirProtons); dirProtons->cd();*/
1975   
1976   //________________________________________________________________//
1977   /*TDirectory *dirProtonsPrimary = gDirectory->mkdir("Primaries");
1978   dirProtonsPrimary->cd();
1979   TDirectory *dirProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
1980   dirProtonsPrimaryAccepted->cd();*/
1981
1982   //Accepted primary protons
1983   TH1F *gPrimaryProtonsITSClustersPass = new TH1F("gPrimaryProtonsITSClustersPass",
1984                                             ";N_{clusters} (ITS);Entries",
1985                                             7,0,7);
1986   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsITSClustersPass);
1987   TH1F *gPrimaryProtonsChi2PerClusterITSPass = new TH1F("gPrimaryProtonsChi2PerClusterITSPass",
1988                                                   ";x^{2}/N_{clusters} (ITS);Entries",
1989                                                   100,0,4);
1990   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsChi2PerClusterITSPass);
1991   TH1F *gPrimaryProtonsTPCClustersPass = new TH1F("gPrimaryProtonsTPCClustersPass",
1992                                             ";N_{clusters} (TPC);Entries",
1993                                             100,0,200);
1994   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsTPCClustersPass);
1995   TH1F *gPrimaryProtonsChi2PerClusterTPCPass = new TH1F("gPrimaryProtonsChi2PerClusterTPCPass",
1996                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1997                                                   100,0,4);
1998   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsChi2PerClusterTPCPass);
1999   TH1F *gPrimaryProtonsExtCov11Pass = new TH1F("gPrimaryProtonsExtCov11Pass",
2000                                          ";#sigma_{y} [cm];Entries",
2001                                          100,0,4);
2002   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov11Pass);
2003   TH1F *gPrimaryProtonsExtCov22Pass = new TH1F("gPrimaryProtonsExtCov22Pass",
2004                                          ";#sigma_{z} [cm];Entries",
2005                                          100,0,4);
2006   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov22Pass);
2007   TH1F *gPrimaryProtonsExtCov33Pass = new TH1F("gPrimaryProtonsExtCov33Pass",
2008                                          ";#sigma_{sin(#phi)};Entries",
2009                                          100,0,4);
2010   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov33Pass);
2011   TH1F *gPrimaryProtonsExtCov44Pass = new TH1F("gPrimaryProtonsExtCov44Pass",
2012                                          ";#sigma_{tan(#lambda)};Entries",
2013                                          100,0,4);
2014   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov44Pass);
2015   TH1F *gPrimaryProtonsExtCov55Pass = new TH1F("gPrimaryProtonsExtCov55Pass",
2016                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2017                                          100,0,4);
2018   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov55Pass);
2019   TH1F *gPrimaryProtonsSigmaToVertexPass = new TH1F("gPrimaryProtonsSigmaToVertexPass",
2020                                              ";#sigma_{Vertex};Entries",
2021                                              100,0,10);
2022   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsSigmaToVertexPass);
2023   TH1F *gPrimaryProtonsSigmaToVertexTPCPass = new TH1F("gPrimaryProtonsSigmaToVertexTPCPass",
2024                                              ";#sigma_{Vertex};Entries",
2025                                              100,0,10);
2026   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsSigmaToVertexTPCPass);
2027   TH1F *gPrimaryProtonsDCAXYPass = new TH1F("gPrimaryProtonsDCAXYPass",
2028                                              ";DCA_{xy} [cm];Entries",
2029                                              100,0,20);
2030   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAXYPass);
2031   TH1F *gPrimaryProtonsDCAXYTPCPass = new TH1F("gPrimaryProtonsDCAXYTPCPass",
2032                                                ";DCA_{xy} [cm];Entries",
2033                                                100,0,20);
2034   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAXYTPCPass);
2035   TH1F *gPrimaryProtonsDCAZPass = new TH1F("gPrimaryProtonsDCAZPass",
2036                                            ";DCA_{z} [cm];Entries",
2037                                            100,0,20);
2038   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAZPass);
2039   TH1F *gPrimaryProtonsDCAZTPCPass = new TH1F("gPrimaryProtonsDCAZTPCPass",
2040                                               ";DCA_{z} [cm];Entries",
2041                                               100,0,20);
2042   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAZTPCPass);
2043   TH1F *gPrimaryProtonsConstrainChi2Pass = new TH1F("gPrimaryProtonsConstrainChi2Pass",
2044                                                     ";Log_{10}(#chi^{2});Entries",
2045                                                     100,-10,10);
2046   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsConstrainChi2Pass);
2047   TH1F *gPrimaryProtonsITSRefitPass = new TH1F("gPrimaryProtonsITSRefitPass",
2048                                                "",10,-1,1);
2049   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsITSRefitPass);
2050   TH1F *gPrimaryProtonsTPCRefitPass = new TH1F("gPrimaryProtonsTPCRefitPass",
2051                                                "",10,-1,1);
2052   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsTPCRefitPass);
2053   TH1F *gPrimaryProtonsESDpidPass = new TH1F("gPrimaryProtonsESDpidPass",
2054                                              "",10,-1,1);
2055   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsESDpidPass);
2056   TH1F *gPrimaryProtonsTPCpidPass = new TH1F("gPrimaryProtonsTPCpidPass",
2057                                              "",10,-1,1);
2058   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsTPCpidPass);
2059   TH1F *gPrimaryProtonsPointOnITSLayer1Pass = new TH1F("gPrimaryProtonsPointOnITSLayer1Pass",
2060                                              "",10,-1,1);
2061   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer1Pass);
2062   TH1F *gPrimaryProtonsPointOnITSLayer2Pass = new TH1F("gPrimaryProtonsPointOnITSLayer2Pass",
2063                                              "",10,-1,1);
2064   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer2Pass);
2065   TH1F *gPrimaryProtonsPointOnITSLayer3Pass = new TH1F("gPrimaryProtonsPointOnITSLayer3Pass",
2066                                              "",10,-1,1);
2067   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer3Pass);
2068   TH1F *gPrimaryProtonsPointOnITSLayer4Pass = new TH1F("gPrimaryProtonsPointOnITSLayer4Pass",
2069                                              "",10,-1,1);
2070   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer4Pass);
2071   TH1F *gPrimaryProtonsPointOnITSLayer5Pass = new TH1F("gPrimaryProtonsPointOnITSLayer5Pass",
2072                                              "",10,-1,1);
2073   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer5Pass);
2074   TH1F *gPrimaryProtonsPointOnITSLayer6Pass = new TH1F("gPrimaryProtonsPointOnITSLayer6Pass",
2075                                              "",10,-1,1);
2076   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer6Pass);
2077
2078   //Rejected primary protons
2079   /*gDirectory->cd("../");
2080   TDirectory *dirProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
2081   dirProtonsPrimaryRejected->cd();*/
2082
2083   TH1F *gPrimaryProtonsITSClustersReject = new TH1F("gPrimaryProtonsITSClustersReject",
2084                                                     ";N_{clusters} (ITS);Entries",
2085                                                     7,0,7);
2086   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsITSClustersReject);
2087   TH1F *gPrimaryProtonsChi2PerClusterITSReject = new TH1F("gPrimaryProtonsChi2PerClusterITSReject",
2088                                                           ";x^{2}/N_{clusters} (ITS);Entries",
2089                                                           100,0,4);
2090   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsChi2PerClusterITSReject);
2091   TH1F *gPrimaryProtonsTPCClustersReject = new TH1F("gPrimaryProtonsTPCClustersReject",
2092                                             ";N_{clusters} (TPC);Entries",
2093                                             100,0,200);
2094   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsTPCClustersReject);
2095   TH1F *gPrimaryProtonsChi2PerClusterTPCReject = new TH1F("gPrimaryProtonsChi2PerClusterTPCReject",
2096                                                   ";x^{2}/N_{clusters} (TPC);Entries",
2097                                                   100,0,4);
2098   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsChi2PerClusterTPCReject);
2099   TH1F *gPrimaryProtonsExtCov11Reject = new TH1F("gPrimaryProtonsExtCov11Reject",
2100                                          ";#sigma_{y} [cm];Entries",
2101                                          100,0,4);
2102   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov11Reject);
2103   TH1F *gPrimaryProtonsExtCov22Reject = new TH1F("gPrimaryProtonsExtCov22Reject",
2104                                          ";#sigma_{z} [cm];Entries",
2105                                          100,0,4);
2106   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov22Reject);
2107   TH1F *gPrimaryProtonsExtCov33Reject = new TH1F("gPrimaryProtonsExtCov33Reject",
2108                                          ";#sigma_{sin(#phi)};Entries",
2109                                          100,0,4);
2110   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov33Reject);
2111   TH1F *gPrimaryProtonsExtCov44Reject = new TH1F("gPrimaryProtonsExtCov44Reject",
2112                                          ";#sigma_{tan(#lambda)};Entries",
2113                                          100,0,4);
2114   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov44Reject);
2115   TH1F *gPrimaryProtonsExtCov55Reject = new TH1F("gPrimaryProtonsExtCov55Reject",
2116                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2117                                          100,0,4);
2118   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov55Reject);
2119   TH1F *gPrimaryProtonsSigmaToVertexReject = new TH1F("gPrimaryProtonsSigmaToVertexReject",
2120                                              ";#sigma_{Vertex};Entries",
2121                                              100,0,10);
2122   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsSigmaToVertexReject);
2123   TH1F *gPrimaryProtonsSigmaToVertexTPCReject = new TH1F("gPrimaryProtonsSigmaToVertexTPCReject",
2124                                              ";#sigma_{Vertex};Entries",
2125                                              100,0,10);
2126   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsSigmaToVertexTPCReject);
2127   TH1F *gPrimaryProtonsDCAXYReject = new TH1F("gPrimaryProtonsDCAXYReject",
2128                                               ";DCA_{xy} [cm];Entries",
2129                                               100,0,20);
2130   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAXYReject);
2131   TH1F *gPrimaryProtonsDCAXYTPCReject = new TH1F("gPrimaryProtonsDCAXYTPCReject",
2132                                                  ";DCA_{xy} [cm];Entries",
2133                                                  100,0,20);
2134   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAXYTPCReject);
2135   TH1F *gPrimaryProtonsDCAZReject = new TH1F("gPrimaryProtonsDCAZReject",
2136                                              ";DCA_{z} [cm];Entries",
2137                                              100,0,20);
2138   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAZReject);
2139   TH1F *gPrimaryProtonsDCAZTPCReject = new TH1F("gPrimaryProtonsDCAZTPCReject",
2140                                                 ";DCA_{z} [cm];Entries",
2141                                                 100,0,20);
2142   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAZTPCReject);
2143   TH1F *gPrimaryProtonsConstrainChi2Reject = new TH1F("gPrimaryProtonsConstrainChi2Reject",
2144                                                     ";Log_{10}(#chi^{2});Entries",
2145                                                     100,-10,10);
2146   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsConstrainChi2Reject);
2147   TH1F *gPrimaryProtonsITSRefitReject = new TH1F("gPrimaryProtonsITSRefitReject",
2148                                                  "",10,-1,1);
2149   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsITSRefitReject);
2150   TH1F *gPrimaryProtonsTPCRefitReject = new TH1F("gPrimaryProtonsTPCRefitReject",
2151                                                  "",10,-1,1);
2152   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsTPCRefitReject);
2153   TH1F *gPrimaryProtonsESDpidReject = new TH1F("gPrimaryProtonsESDpidReject",
2154                                                "",10,-1,1);
2155   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsESDpidReject);
2156   TH1F *gPrimaryProtonsTPCpidReject = new TH1F("gPrimaryProtonsTPCpidReject",
2157                                                "",10,-1,1);
2158   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsTPCpidReject);
2159   TH1F *gPrimaryProtonsPointOnITSLayer1Reject = new TH1F("gPrimaryProtonsPointOnITSLayer1Reject",
2160                                              "",10,-1,1);
2161   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer1Reject);
2162   TH1F *gPrimaryProtonsPointOnITSLayer2Reject = new TH1F("gPrimaryProtonsPointOnITSLayer2Reject",
2163                                              "",10,-1,1);
2164   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer2Reject);
2165   TH1F *gPrimaryProtonsPointOnITSLayer3Reject = new TH1F("gPrimaryProtonsPointOnITSLayer3Reject",
2166                                              "",10,-1,1);
2167   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer3Reject);
2168   TH1F *gPrimaryProtonsPointOnITSLayer4Reject = new TH1F("gPrimaryProtonsPointOnITSLayer4Reject",
2169                                              "",10,-1,1);
2170   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer4Reject);
2171   TH1F *gPrimaryProtonsPointOnITSLayer5Reject = new TH1F("gPrimaryProtonsPointOnITSLayer5Reject",
2172                                              "",10,-1,1);
2173   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer5Reject);
2174   TH1F *gPrimaryProtonsPointOnITSLayer6Reject = new TH1F("gPrimaryProtonsPointOnITSLayer6Reject",
2175                                              "",10,-1,1);
2176   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer6Reject);
2177
2178   //________________________________________________________________//
2179   /*gDirectory->cd("../../");
2180
2181   TDirectory *dirProtonsSecondary = gDirectory->mkdir("Secondaries");
2182   dirProtonsSecondary->cd();
2183   TDirectory *dirProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
2184   dirProtonsSecondaryAccepted->cd();*/
2185
2186   //Accepted secondary protons
2187   TH1F *gSecondaryProtonsITSClustersPass = new TH1F("gSecondaryProtonsITSClustersPass",
2188                                                     ";N_{clusters} (ITS);Entries",
2189                                                     7,0,7);
2190   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsITSClustersPass);
2191   TH1F *gSecondaryProtonsChi2PerClusterITSPass = new TH1F("gSecondaryProtonsChi2PerClusterITSPass",
2192                                                           ";x^{2}/N_{clusters} (ITS);Entries",
2193                                                           100,0,4);
2194   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsChi2PerClusterITSPass);
2195   TH1F *gSecondaryProtonsTPCClustersPass = new TH1F("gSecondaryProtonsTPCClustersPass",
2196                                             ";N_{clusters} (TPC);Entries",
2197                                             100,0,200);
2198   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsTPCClustersPass);
2199   TH1F *gSecondaryProtonsChi2PerClusterTPCPass = new TH1F("gSecondaryProtonsChi2PerClusterTPCPass",
2200                                                   ";x^{2}/N_{clusters} (TPC);Entries",
2201                                                   100,0,4);
2202   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsChi2PerClusterTPCPass);
2203   TH1F *gSecondaryProtonsExtCov11Pass = new TH1F("gSecondaryProtonsExtCov11Pass",
2204                                          ";#sigma_{y} [cm];Entries",
2205                                          100,0,4);
2206   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov11Pass);
2207   TH1F *gSecondaryProtonsExtCov22Pass = new TH1F("gSecondaryProtonsExtCov22Pass",
2208                                          ";#sigma_{z} [cm];Entries",
2209                                          100,0,4);
2210   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov22Pass);
2211   TH1F *gSecondaryProtonsExtCov33Pass = new TH1F("gSecondaryProtonsExtCov33Pass",
2212                                          ";#sigma_{sin(#phi)};Entries",
2213                                          100,0,4);
2214   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov33Pass);
2215   TH1F *gSecondaryProtonsExtCov44Pass = new TH1F("gSecondaryProtonsExtCov44Pass",
2216                                          ";#sigma_{tan(#lambda)};Entries",
2217                                          100,0,4);
2218   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov44Pass);
2219   TH1F *gSecondaryProtonsExtCov55Pass = new TH1F("gSecondaryProtonsExtCov55Pass",
2220                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2221                                          100,0,4);
2222   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov55Pass);
2223   TH1F *gSecondaryProtonsSigmaToVertexPass = new TH1F("gSecondaryProtonsSigmaToVertexPass",
2224                                              ";#sigma_{Vertex};Entries",
2225                                              100,0,10);
2226   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsSigmaToVertexPass);
2227   TH1F *gSecondaryProtonsSigmaToVertexTPCPass = new TH1F("gSecondaryProtonsSigmaToVertexTPCPass",
2228                                              ";#sigma_{Vertex};Entries",
2229                                              100,0,10);
2230   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsSigmaToVertexTPCPass);
2231   TH1F *gSecondaryProtonsDCAXYPass = new TH1F("gSecondaryProtonsDCAXYPass",
2232                                               ";DCA_{xy} [cm];Entries",
2233                                               100,0,20);
2234   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAXYPass);
2235   TH1F *gSecondaryProtonsDCAXYTPCPass = new TH1F("gSecondaryProtonsDCAXYTPCPass",
2236                                                  ";DCA_{xy} [cm];Entries",
2237                                                  100,0,20);
2238   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAXYTPCPass);
2239   TH1F *gSecondaryProtonsDCAZPass = new TH1F("gSecondaryProtonsDCAZPass",
2240                                              ";DCA_{z} [cm];Entries",
2241                                              100,0,20);
2242   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAZPass);
2243   TH1F *gSecondaryProtonsDCAZTPCPass = new TH1F("gSecondaryProtonsDCAZTPCPass",
2244                                                 ";DCA_{z} [cm];Entries",
2245                                                 100,0,20);
2246   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAZTPCPass);
2247   TH1F *gSecondaryProtonsConstrainChi2Pass = new TH1F("gSecondaryProtonsConstrainChi2Pass",
2248                                                     ";Log_{10}(#chi^{2});Entries",
2249                                                     100,-10,10);
2250   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsConstrainChi2Pass);
2251   TH1F *gSecondaryProtonsITSRefitPass = new TH1F("gSecondaryProtonsITSRefitPass",
2252                                                  "",10,-1,1);
2253   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsITSRefitPass);
2254   TH1F *gSecondaryProtonsTPCRefitPass = new TH1F("gSecondaryProtonsTPCRefitPass",
2255                                                  "",10,-1,1);
2256   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsTPCRefitPass);
2257   TH1F *gSecondaryProtonsESDpidPass = new TH1F("gSecondaryProtonsESDpidPass",
2258                                                "",10,-1,1);
2259   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsESDpidPass);
2260   TH1F *gSecondaryProtonsTPCpidPass = new TH1F("gSecondaryProtonsTPCpidPass",
2261                                                "",10,-1,1);
2262   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsTPCpidPass);
2263   TH1F *gSecondaryProtonsPointOnITSLayer1Pass = new TH1F("gSecondaryProtonsPointOnITSLayer1Pass",
2264                                                          "",10,-1,1);
2265   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer1Pass);
2266   TH1F *gSecondaryProtonsPointOnITSLayer2Pass = new TH1F("gSecondaryProtonsPointOnITSLayer2Pass",
2267                                                          "",10,-1,1);
2268   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer2Pass);
2269   TH1F *gSecondaryProtonsPointOnITSLayer3Pass = new TH1F("gSecondaryProtonsPointOnITSLayer3Pass",
2270                                                          "",10,-1,1);
2271   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer3Pass);
2272   TH1F *gSecondaryProtonsPointOnITSLayer4Pass = new TH1F("gSecondaryProtonsPointOnITSLayer4Pass",
2273                                                          "",10,-1,1);
2274   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer4Pass);
2275   TH1F *gSecondaryProtonsPointOnITSLayer5Pass = new TH1F("gSecondaryProtonsPointOnITSLayer5Pass",
2276                                                          "",10,-1,1);
2277   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer5Pass);
2278   TH1F *gSecondaryProtonsPointOnITSLayer6Pass = new TH1F("gSecondaryProtonsPointOnITSLayer6Pass",
2279                                                          "",10,-1,1);
2280   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer6Pass);
2281
2282   //Rejected secondary protons
2283   /*gDirectory->cd("../");
2284   TDirectory *dirProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
2285   dirProtonsSecondaryRejected->cd();*/
2286
2287   TH1F *gSecondaryProtonsITSClustersReject = new TH1F("gSecondaryProtonsITSClustersReject",
2288                                                       ";N_{clusters} (ITS);Entries",
2289                                                       7,0,7);
2290   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsITSClustersReject);
2291   TH1F *gSecondaryProtonsChi2PerClusterITSReject = new TH1F("gSecondaryProtonsChi2PerClusterITSReject",
2292                                                             ";x^{2}/N_{clusters} (ITS);Entries",
2293                                                             100,0,4);
2294   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsChi2PerClusterITSReject);
2295   TH1F *gSecondaryProtonsTPCClustersReject = new TH1F("gSecondaryProtonsTPCClustersReject",
2296                                             ";N_{clusters} (TPC);Entries",
2297                                             100,0,200);
2298   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsTPCClustersReject);
2299   TH1F *gSecondaryProtonsChi2PerClusterTPCReject = new TH1F("gSecondaryProtonsChi2PerClusterTPCReject",
2300                                                   ";x^{2}/N_{clusters} (TPC);Entries",
2301                                                   100,0,4);
2302   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsChi2PerClusterTPCReject);
2303   TH1F *gSecondaryProtonsExtCov11Reject = new TH1F("gSecondaryProtonsExtCov11Reject",
2304                                          ";#sigma_{y} [cm];Entries",
2305                                          100,0,4);
2306   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov11Reject);
2307   TH1F *gSecondaryProtonsExtCov22Reject = new TH1F("gSecondaryProtonsExtCov22Reject",
2308                                          ";#sigma_{z} [cm];Entries",
2309                                          100,0,4);
2310   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov22Reject);
2311   TH1F *gSecondaryProtonsExtCov33Reject = new TH1F("gSecondaryProtonsExtCov33Reject",
2312                                          ";#sigma_{sin(#phi)};Entries",
2313                                          100,0,4);
2314   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov33Reject);
2315   TH1F *gSecondaryProtonsExtCov44Reject = new TH1F("gSecondaryProtonsExtCov44Reject",
2316                                          ";#sigma_{tan(#lambda)};Entries",
2317                                          100,0,4);
2318   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov44Reject);
2319   TH1F *gSecondaryProtonsExtCov55Reject = new TH1F("gSecondaryProtonsExtCov55Reject",
2320                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2321                                          100,0,4);
2322   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov55Reject);
2323   TH1F *gSecondaryProtonsSigmaToVertexReject = new TH1F("gSecondaryProtonsSigmaToVertexReject",
2324                                              ";#sigma_{Vertex};Entries",
2325                                              100,0,10);
2326   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsSigmaToVertexReject);
2327   TH1F *gSecondaryProtonsSigmaToVertexTPCReject = new TH1F("gSecondaryProtonsSigmaToVertexTPCReject",
2328                                                            ";#sigma_{Vertex};Entries",
2329                                                            100,0,10);
2330   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsSigmaToVertexTPCReject);
2331   TH1F *gSecondaryProtonsDCAXYReject = new TH1F("gSecondaryProtonsDCAXYReject",
2332                                                 ";DCA_{xy} [cm];Entries",
2333                                                 100,0,20);
2334   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAXYReject);
2335   TH1F *gSecondaryProtonsDCAXYTPCReject = new TH1F("gSecondaryProtonsDCAXYTPCReject",
2336                                                    ";DCA_{xy} [cm];Entries",
2337                                                    100,0,20);
2338   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAXYTPCReject);
2339   TH1F *gSecondaryProtonsDCAZReject = new TH1F("gSecondaryProtonsDCAZReject",
2340                                                ";DCA_{z} [cm];Entries",
2341                                                100,0,20);
2342   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAZReject);
2343   TH1F *gSecondaryProtonsDCAZTPCReject = new TH1F("gSecondaryProtonsDCAZTPCReject",
2344                                                   ";DCA_{z} [cm];Entries",
2345                                                   100,0,20);
2346   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAZTPCReject);
2347   TH1F *gSecondaryProtonsConstrainChi2Reject = new TH1F("gSecondaryProtonsConstrainChi2Reject",
2348                                                         ";Log_{10}(#chi^{2});Entries",
2349                                                         100,-10,10);
2350   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsConstrainChi2Reject);
2351   TH1F *gSecondaryProtonsITSRefitReject = new TH1F("gSecondaryProtonsITSRefitReject",
2352                                                    "",10,-1,1);
2353   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsITSRefitReject);
2354   TH1F *gSecondaryProtonsTPCRefitReject = new TH1F("gSecondaryProtonsTPCRefitReject",
2355                                                    "",10,-1,1);
2356   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsTPCRefitReject);
2357   TH1F *gSecondaryProtonsESDpidReject = new TH1F("gSecondaryProtonsESDpidReject",
2358                                                  "",10,-1,1);
2359   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsESDpidReject);
2360   TH1F *gSecondaryProtonsTPCpidReject = new TH1F("gSecondaryProtonsTPCpidReject",
2361                                                  "",10,-1,1);
2362   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsTPCpidReject);
2363   TH1F *gSecondaryProtonsPointOnITSLayer1Reject = new TH1F("gSecondaryProtonsPointOnITSLayer1Reject",
2364                                                            "",10,-1,1);
2365   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer1Reject);
2366   TH1F *gSecondaryProtonsPointOnITSLayer2Reject = new TH1F("gSecondaryProtonsPointOnITSLayer2Reject",
2367                                                            "",10,-1,1);
2368   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer2Reject);
2369   TH1F *gSecondaryProtonsPointOnITSLayer3Reject = new TH1F("gSecondaryProtonsPointOnITSLayer3Reject",
2370                                                            "",10,-1,1);
2371   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer3Reject);
2372   TH1F *gSecondaryProtonsPointOnITSLayer4Reject = new TH1F("gSecondaryProtonsPointOnITSLayer4Reject",
2373                                                            "",10,-1,1);
2374   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer4Reject);
2375   TH1F *gSecondaryProtonsPointOnITSLayer5Reject = new TH1F("gSecondaryProtonsPointOnITSLayer5Reject",
2376                                                            "",10,-1,1);
2377   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer5Reject);
2378   TH1F *gSecondaryProtonsPointOnITSLayer6Reject = new TH1F("gSecondaryProtonsPointOnITSLayer6Reject",
2379                                                            "",10,-1,1);
2380   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer6Reject);
2381   
2382
2383   /*gDirectory->cd("../../../");
2384
2385   //antiprotons
2386   TDirectory *dirAntiProtons = gDirectory->mkdir("AntiProtons");
2387   fGlobalQAList->Add(dirAntiProtons); dirAntiProtons->cd();*/
2388   
2389   //________________________________________________________________//
2390   /*TDirectory *dirAntiProtonsPrimary = gDirectory->mkdir("Primaries");
2391   dirAntiProtonsPrimary->cd();
2392   TDirectory *dirAntiProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
2393   dirAntiProtonsPrimaryAccepted->cd();*/
2394   
2395   //Accepted primary antiprotons
2396   TH1F *gPrimaryAntiProtonsITSClustersPass = new TH1F("gPrimaryAntiProtonsITSClustersPass",
2397                                                       ";N_{clusters} (ITS);Entries",
2398                                                       7,0,7);
2399   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsITSClustersPass);
2400   TH1F *gPrimaryAntiProtonsChi2PerClusterITSPass = new TH1F("gPrimaryAntiProtonsChi2PerClusterITSPass",
2401                                                             ";x^{2}/N_{clusters} (ITS);Entries",
2402                                                             100,0,4);
2403   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsChi2PerClusterITSPass);
2404   TH1F *gPrimaryAntiProtonsTPCClustersPass = new TH1F("gPrimaryAntiProtonsTPCClustersPass",
2405                                                       ";N_{clusters} (TPC);Entries",
2406                                                       100,0,200);
2407   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsTPCClustersPass);
2408   TH1F *gPrimaryAntiProtonsChi2PerClusterTPCPass = new TH1F("gPrimaryAntiProtonsChi2PerClusterTPCPass",
2409                                                             ";x^{2}/N_{clusters} (TPC);Entries",
2410                                                             100,0,4);
2411   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsChi2PerClusterTPCPass);
2412   TH1F *gPrimaryAntiProtonsExtCov11Pass = new TH1F("gPrimaryAntiProtonsExtCov11Pass",
2413                                                    ";#sigma_{y} [cm];Entries",
2414                                                    100,0,4);
2415   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov11Pass);
2416   TH1F *gPrimaryAntiProtonsExtCov22Pass = new TH1F("gPrimaryAntiProtonsExtCov22Pass",
2417                                                    ";#sigma_{z} [cm];Entries",
2418                                                    100,0,4);
2419   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov22Pass);
2420   TH1F *gPrimaryAntiProtonsExtCov33Pass = new TH1F("gPrimaryAntiProtonsExtCov33Pass",
2421                                                    ";#sigma_{sin(#phi)};Entries",
2422                                                    100,0,4);
2423   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov33Pass);
2424   TH1F *gPrimaryAntiProtonsExtCov44Pass = new TH1F("gPrimaryAntiProtonsExtCov44Pass",
2425                                                    ";#sigma_{tan(#lambda)};Entries",
2426                                                    100,0,4);
2427   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov44Pass);
2428   TH1F *gPrimaryAntiProtonsExtCov55Pass = new TH1F("gPrimaryAntiProtonsExtCov55Pass",
2429                                                    ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2430                                                    100,0,4);
2431   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov55Pass);
2432   TH1F *gPrimaryAntiProtonsSigmaToVertexPass = new TH1F("gPrimaryAntiProtonsSigmaToVertexPass",
2433                                                         ";#sigma_{Vertex};Entries",
2434                                                         100,0,10);
2435   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsSigmaToVertexPass);
2436   TH1F *gPrimaryAntiProtonsSigmaToVertexTPCPass = new TH1F("gPrimaryAntiProtonsSigmaToVertexTPCPass",
2437                                                            ";#sigma_{Vertex};Entries",
2438                                                            100,0,10);
2439   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsSigmaToVertexTPCPass);
2440   TH1F *gPrimaryAntiProtonsDCAXYPass = new TH1F("gPrimaryAntiProtonsDCAXYPass",
2441                                                 ";DCA_{xy} [cm];Entries",
2442                                                 100,0,20);
2443   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAXYPass);
2444   TH1F *gPrimaryAntiProtonsDCAXYTPCPass = new TH1F("gPrimaryAntiProtonsDCAXYTPCPass",
2445                                                    ";DCA_{xy} [cm];Entries",
2446                                                    100,0,20);
2447   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAXYTPCPass);
2448   TH1F *gPrimaryAntiProtonsDCAZPass = new TH1F("gPrimaryAntiProtonsDCAZPass",
2449                                                ";DCA_{z} [cm];Entries",
2450                                                100,0,20);
2451   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAZPass);
2452   TH1F *gPrimaryAntiProtonsDCAZTPCPass = new TH1F("gPrimaryAntiProtonsDCAZTPCPass",
2453                                                   ";DCA_{z} [cm];Entries",
2454                                                   100,0,20);
2455   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAZTPCPass);
2456   TH1F *gPrimaryAntiProtonsConstrainChi2Pass = new TH1F("gPrimaryAntiProtonsConstrainChi2Pass",
2457                                                         ";Log_{10}(#chi^{2});Entries",
2458                                                         100,-10,10);
2459   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsConstrainChi2Pass);
2460   TH1F *gPrimaryAntiProtonsITSRefitPass = new TH1F("gPrimaryAntiProtonsITSRefitPass",
2461                                                    "",10,-1,1);
2462   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsITSRefitPass);
2463   TH1F *gPrimaryAntiProtonsTPCRefitPass = new TH1F("gPrimaryAntiProtonsTPCRefitPass",
2464                                                    "",10,-1,1);
2465   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsTPCRefitPass);
2466   TH1F *gPrimaryAntiProtonsESDpidPass = new TH1F("gPrimaryAntiProtonsESDpidPass",
2467                                                  "",10,-1,1);
2468   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsESDpidPass);
2469   TH1F *gPrimaryAntiProtonsTPCpidPass = new TH1F("gPrimaryAntiProtonsTPCpidPass",
2470                                                  "",10,-1,1);
2471   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsTPCpidPass);
2472   TH1F *gPrimaryAntiProtonsPointOnITSLayer1Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer1Pass",
2473                                                            "",10,-1,1);
2474   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer1Pass);
2475   TH1F *gPrimaryAntiProtonsPointOnITSLayer2Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer2Pass",
2476                                                            "",10,-1,1);
2477   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer2Pass);
2478   TH1F *gPrimaryAntiProtonsPointOnITSLayer3Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer3Pass",
2479                                                            "",10,-1,1);
2480   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer3Pass);
2481   TH1F *gPrimaryAntiProtonsPointOnITSLayer4Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer4Pass",
2482                                                            "",10,-1,1);
2483   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer4Pass);
2484   TH1F *gPrimaryAntiProtonsPointOnITSLayer5Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer5Pass",
2485                                                            "",10,-1,1);
2486   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer5Pass);
2487   TH1F *gPrimaryAntiProtonsPointOnITSLayer6Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer6Pass",
2488                                                            "",10,-1,1);
2489   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer6Pass);
2490   
2491   //Rejected primary antiprotons
2492   /*gDirectory->cd("../");
2493   TDirectory *dirAntiProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
2494   dirAntiProtonsPrimaryRejected->cd();*/
2495   
2496   TH1F *gPrimaryAntiProtonsITSClustersReject = new TH1F("gPrimaryAntiProtonsITSClustersReject",
2497                                                         ";N_{clusters} (ITS);Entries",
2498                                                         7,0,7);
2499   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsITSClustersReject);
2500   TH1F *gPrimaryAntiProtonsChi2PerClusterITSReject = new TH1F("gPrimaryAntiProtonsChi2PerClusterITSReject",
2501                                                               ";x^{2}/N_{clusters} (ITS);Entries",
2502                                                               100,0,4);
2503   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsChi2PerClusterITSReject);
2504   TH1F *gPrimaryAntiProtonsTPCClustersReject = new TH1F("gPrimaryAntiProtonsTPCClustersReject",
2505                                                         ";N_{clusters} (TPC);Entries",
2506                                                         100,0,200);
2507   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsTPCClustersReject);
2508   TH1F *gPrimaryAntiProtonsChi2PerClusterTPCReject = new TH1F("gPrimaryAntiProtonsChi2PerClusterTPCReject",
2509                                                               ";x^{2}/N_{clusters} (TPC);Entries",
2510                                                               100,0,4);
2511   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsChi2PerClusterTPCReject);
2512   TH1F *gPrimaryAntiProtonsExtCov11Reject = new TH1F("gPrimaryAntiProtonsExtCov11Reject",
2513                                                      ";#sigma_{y} [cm];Entries",
2514                                                      100,0,4);
2515   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov11Reject);
2516   TH1F *gPrimaryAntiProtonsExtCov22Reject = new TH1F("gPrimaryAntiProtonsExtCov22Reject",
2517                                                      ";#sigma_{z} [cm];Entries",
2518                                                      100,0,4);
2519   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov22Reject);
2520   TH1F *gPrimaryAntiProtonsExtCov33Reject = new TH1F("gPrimaryAntiProtonsExtCov33Reject",
2521                                                      ";#sigma_{sin(#phi)};Entries",
2522                                                      100,0,4);
2523   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov33Reject);
2524   TH1F *gPrimaryAntiProtonsExtCov44Reject = new TH1F("gPrimaryAntiProtonsExtCov44Reject",
2525                                                      ";#sigma_{tan(#lambda)};Entries",
2526                                                      100,0,4);
2527   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov44Reject);
2528   TH1F *gPrimaryAntiProtonsExtCov55Reject = new TH1F("gPrimaryAntiProtonsExtCov55Reject",
2529                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2530                                                      100,0,4);
2531   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov55Reject);
2532   TH1F *gPrimaryAntiProtonsSigmaToVertexReject = new TH1F("gPrimaryAntiProtonsSigmaToVertexReject",
2533                                                           ";#sigma_{Vertex};Entries",
2534                                                           100,0,10);
2535   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsSigmaToVertexReject);
2536   TH1F *gPrimaryAntiProtonsSigmaToVertexTPCReject = new TH1F("gPrimaryAntiProtonsSigmaToVertexTPCReject",
2537                                                              ";#sigma_{Vertex};Entries",
2538                                                              100,0,10);
2539   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsSigmaToVertexTPCReject);
2540   TH1F *gPrimaryAntiProtonsDCAXYReject = new TH1F("gPrimaryAntiProtonsDCAXYReject",
2541                                                   ";DCA_{xy} [cm];Entries",
2542                                                   100,0,20);
2543   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAXYReject);
2544   TH1F *gPrimaryAntiProtonsDCAXYTPCReject = new TH1F("gPrimaryAntiProtonsDCAXYTPCReject",
2545                                                      ";DCA_{xy} [cm];Entries",
2546                                                      100,0,20);
2547   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAXYTPCReject);
2548   TH1F *gPrimaryAntiProtonsDCAZReject = new TH1F("gPrimaryAntiProtonsDCAZReject",
2549                                                  ";DCA_{z} [cm];Entries",
2550                                                  100,0,20);
2551   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAZReject);
2552   TH1F *gPrimaryAntiProtonsDCAZTPCReject = new TH1F("gPrimaryAntiProtonsDCAZTPCReject",
2553                                                     ";DCA_{z} [cm];Entries",
2554                                                     100,0,20);
2555   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAZTPCReject);
2556   TH1F *gPrimaryAntiProtonsConstrainChi2Reject = new TH1F("gPrimaryAntiProtonsConstrainChi2Reject",
2557                                                           ";Log_{10}(#chi^{2});Entries",
2558                                                           100,-10,10);
2559   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsConstrainChi2Reject);
2560   TH1F *gPrimaryAntiProtonsITSRefitReject = new TH1F("gPrimaryAntiProtonsITSRefitReject",
2561                                                      "",10,-1,1);
2562   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsITSRefitReject);
2563   TH1F *gPrimaryAntiProtonsTPCRefitReject = new TH1F("gPrimaryAntiProtonsTPCRefitReject",
2564                                                      "",10,-1,1);
2565   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsTPCRefitReject);
2566   TH1F *gPrimaryAntiProtonsESDpidReject = new TH1F("gPrimaryAntiProtonsESDpidReject",
2567                                                    "",10,-1,1);
2568   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsESDpidReject);
2569   TH1F *gPrimaryAntiProtonsTPCpidReject = new TH1F("gPrimaryAntiProtonsTPCpidReject",
2570                                                    "",10,-1,1);
2571   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsTPCpidReject);
2572   TH1F *gPrimaryAntiProtonsPointOnITSLayer1Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer1Reject",
2573                                                              "",10,-1,1);
2574   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer1Reject);
2575   TH1F *gPrimaryAntiProtonsPointOnITSLayer2Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer2Reject",
2576                                                              "",10,-1,1);
2577   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer2Reject);
2578   TH1F *gPrimaryAntiProtonsPointOnITSLayer3Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer3Reject",
2579                                                              "",10,-1,1);
2580   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer3Reject);
2581   TH1F *gPrimaryAntiProtonsPointOnITSLayer4Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer4Reject",
2582                                                              "",10,-1,1);
2583   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer4Reject);
2584   TH1F *gPrimaryAntiProtonsPointOnITSLayer5Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer5Reject",
2585                                                              "",10,-1,1);
2586   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer5Reject);
2587   TH1F *gPrimaryAntiProtonsPointOnITSLayer6Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer6Reject",
2588                                                              "",10,-1,1);
2589   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer6Reject);
2590   
2591   //________________________________________________________________//
2592   /*gDirectory->cd("../../");
2593
2594   TDirectory *dirAntiProtonsSecondary = gDirectory->mkdir("Secondaries");
2595   dirAntiProtonsSecondary->cd();
2596   TDirectory *dirAntiProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
2597   dirAntiProtonsSecondaryAccepted->cd();*/
2598
2599   //Accepted secondary antiprotons
2600   TH1F *gSecondaryAntiProtonsITSClustersPass = new TH1F("gSecondaryAntiProtonsITSClustersPass",
2601                                                         ";N_{clusters} (ITS);Entries",
2602                                                         7,0,7);
2603   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsITSClustersPass);
2604   TH1F *gSecondaryAntiProtonsChi2PerClusterITSPass = new TH1F("gSecondaryAntiProtonsChi2PerClusterITSPass",
2605                                                               ";x^{2}/N_{clusters} (ITS);Entries",
2606                                                               100,0,4);
2607   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsChi2PerClusterITSPass);
2608   TH1F *gSecondaryAntiProtonsTPCClustersPass = new TH1F("gSecondaryAntiProtonsTPCClustersPass",
2609                                                         ";N_{clusters} (TPC);Entries",
2610                                                         100,0,200);
2611   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsTPCClustersPass);
2612   TH1F *gSecondaryAntiProtonsChi2PerClusterTPCPass = new TH1F("gSecondaryAntiProtonsChi2PerClusterTPCPass",
2613                                                               ";x^{2}/N_{clusters} (TPC);Entries",
2614                                                               100,0,4);
2615   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsChi2PerClusterTPCPass);
2616   TH1F *gSecondaryAntiProtonsExtCov11Pass = new TH1F("gSecondaryAntiProtonsExtCov11Pass",
2617                                                      ";#sigma_{y} [cm];Entries",
2618                                                      100,0,4);
2619   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov11Pass);
2620   TH1F *gSecondaryAntiProtonsExtCov22Pass = new TH1F("gSecondaryAntiProtonsExtCov22Pass",
2621                                                      ";#sigma_{z} [cm];Entries",
2622                                                      100,0,4);
2623   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov22Pass);
2624   TH1F *gSecondaryAntiProtonsExtCov33Pass = new TH1F("gSecondaryAntiProtonsExtCov33Pass",
2625                                                      ";#sigma_{sin(#phi)};Entries",
2626                                                      100,0,4);
2627   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov33Pass);
2628   TH1F *gSecondaryAntiProtonsExtCov44Pass = new TH1F("gSecondaryAntiProtonsExtCov44Pass",
2629                                                      ";#sigma_{tan(#lambda)};Entries",
2630                                                      100,0,4);
2631   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov44Pass);
2632   TH1F *gSecondaryAntiProtonsExtCov55Pass = new TH1F("gSecondaryAntiProtonsExtCov55Pass",
2633                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2634                                                      100,0,4);
2635   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov55Pass);
2636   TH1F *gSecondaryAntiProtonsSigmaToVertexPass = new TH1F("gSecondaryAntiProtonsSigmaToVertexPass",
2637                                                           ";#sigma_{Vertex};Entries",
2638                                                           100,0,10);
2639   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsSigmaToVertexPass);
2640   TH1F *gSecondaryAntiProtonsSigmaToVertexTPCPass = new TH1F("gSecondaryAntiProtonsSigmaToVertexTPCPass",
2641                                                              ";#sigma_{Vertex};Entries",
2642                                                              100,0,10);
2643   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsSigmaToVertexTPCPass);
2644   TH1F *gSecondaryAntiProtonsDCAXYPass = new TH1F("gSecondaryAntiProtonsDCAXYPass",
2645                                                   ";DCA_{xy} [cm];Entries",
2646                                                   100,0,20);
2647   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAXYPass);
2648   TH1F *gSecondaryAntiProtonsDCAXYTPCPass = new TH1F("gSecondaryAntiProtonsDCAXYTPCPass",
2649                                                      ";DCA_{xy} [cm];Entries",
2650                                                      100,0,20);
2651   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAXYTPCPass);
2652   TH1F *gSecondaryAntiProtonsDCAZPass = new TH1F("gSecondaryAntiProtonsDCAZPass",
2653                                                  ";DCA_{z} [cm];Entries",
2654                                                  100,0,20);
2655   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAZPass);
2656   TH1F *gSecondaryAntiProtonsDCAZTPCPass = new TH1F("gSecondaryAntiProtonsDCAZTPCPass",
2657                                                     ";DCA_{z} [cm];Entries",
2658                                                     100,0,20);
2659   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAZTPCPass);
2660   TH1F *gSecondaryAntiProtonsConstrainChi2Pass = new TH1F("gSecondaryAntiProtonsConstrainChi2Pass",
2661                                                           ";Log_{10}(#chi^{2});Entries",
2662                                                           100,-10,10);
2663   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsConstrainChi2Pass);
2664   TH1F *gSecondaryAntiProtonsITSRefitPass = new TH1F("gSecondaryAntiProtonsITSRefitPass",
2665                                                      "",10,-1,1);
2666   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsITSRefitPass);
2667   TH1F *gSecondaryAntiProtonsTPCRefitPass = new TH1F("gSecondaryAntiProtonsTPCRefitPass",
2668                                                      "",10,-1,1);
2669   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsTPCRefitPass);
2670   TH1F *gSecondaryAntiProtonsESDpidPass = new TH1F("gSecondaryAntiProtonsESDpidPass",
2671                                                    "",10,-1,1);
2672   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsESDpidPass);
2673   TH1F *gSecondaryAntiProtonsTPCpidPass = new TH1F("gSecondaryAntiProtonsTPCpidPass",
2674                                                    "",10,-1,1);
2675   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsTPCpidPass);
2676   TH1F *gSecondaryAntiProtonsPointOnITSLayer1Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer1Pass",
2677                                                              "",10,-1,1);
2678   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer1Pass);
2679   TH1F *gSecondaryAntiProtonsPointOnITSLayer2Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer2Pass",
2680                                                              "",10,-1,1);
2681   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer2Pass);
2682   TH1F *gSecondaryAntiProtonsPointOnITSLayer3Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer3Pass",
2683                                                              "",10,-1,1);
2684   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer3Pass);
2685   TH1F *gSecondaryAntiProtonsPointOnITSLayer4Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer4Pass",
2686                                                              "",10,-1,1);
2687   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer4Pass);
2688   TH1F *gSecondaryAntiProtonsPointOnITSLayer5Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer5Pass",
2689                                                              "",10,-1,1);
2690   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer5Pass);
2691   TH1F *gSecondaryAntiProtonsPointOnITSLayer6Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer6Pass",
2692                                                              "",10,-1,1);
2693   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer6Pass);
2694   
2695   //Rejected secondary antiprotons
2696   /*gDirectory->cd("../");
2697   TDirectory *dirAntiProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
2698   dirAntiProtonsSecondaryRejected->cd();*/
2699
2700   TH1F *gSecondaryAntiProtonsITSClustersReject = new TH1F("gSecondaryAntiProtonsITSClustersReject",
2701                                                           ";N_{clusters} (ITS);Entries",
2702                                                           7,0,7);
2703   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsITSClustersReject);
2704   TH1F *gSecondaryAntiProtonsChi2PerClusterITSReject = new TH1F("gSecondaryAntiProtonsChi2PerClusterITSReject",
2705                                                                 ";x^{2}/N_{clusters} (ITS);Entries",
2706                                                                 100,0,4);
2707   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsChi2PerClusterITSReject);
2708   TH1F *gSecondaryAntiProtonsTPCClustersReject = new TH1F("gSecondaryAntiProtonsTPCClustersReject",
2709                                                           ";N_{clusters} (TPC);Entries",
2710                                                           100,0,200);
2711   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsTPCClustersReject);
2712   TH1F *gSecondaryAntiProtonsChi2PerClusterTPCReject = new TH1F("gSecondaryAntiProtonsChi2PerClusterTPCReject",
2713                                                                 ";x^{2}/N_{clusters} (TPC);Entries",
2714                                                                 100,0,4);
2715   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsChi2PerClusterTPCReject);
2716   TH1F *gSecondaryAntiProtonsExtCov11Reject = new TH1F("gSecondaryAntiProtonsExtCov11Reject",
2717                                                        ";#sigma_{y} [cm];Entries",
2718                                                        100,0,4);
2719   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov11Reject);
2720   TH1F *gSecondaryAntiProtonsExtCov22Reject = new TH1F("gSecondaryAntiProtonsExtCov22Reject",
2721                                                        ";#sigma_{z} [cm];Entries",
2722                                                        100,0,4);
2723   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov22Reject);
2724   TH1F *gSecondaryAntiProtonsExtCov33Reject = new TH1F("gSecondaryAntiProtonsExtCov33Reject",
2725                                                        ";#sigma_{sin(#phi)};Entries",
2726                                                        100,0,4);
2727   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov33Reject);
2728   TH1F *gSecondaryAntiProtonsExtCov44Reject = new TH1F("gSecondaryAntiProtonsExtCov44Reject",
2729                                                        ";#sigma_{tan(#lambda)};Entries",
2730                                                        100,0,4);
2731   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov44Reject);
2732   TH1F *gSecondaryAntiProtonsExtCov55Reject = new TH1F("gSecondaryAntiProtonsExtCov55Reject",
2733                                                        ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2734                                                        100,0,4);
2735   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov55Reject);
2736   TH1F *gSecondaryAntiProtonsSigmaToVertexReject = new TH1F("gSecondaryAntiProtonsSigmaToVertexReject",
2737                                                             ";#sigma_{Vertex};Entries",
2738                                                             100,0,10);
2739   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsSigmaToVertexReject);
2740   TH1F *gSecondaryAntiProtonsSigmaToVertexTPCReject = new TH1F("gSecondaryAntiProtonsSigmaToVertexTPCReject",
2741                                                                ";#sigma_{Vertex};Entries",
2742                                                                100,0,10);
2743   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsSigmaToVertexTPCReject);
2744   TH1F *gSecondaryAntiProtonsDCAXYReject = new TH1F("gSecondaryAntiProtonsDCAXYReject",
2745                                                     ";DCA_{xy} [cm];Entries",
2746                                                     100,0,20);
2747   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAXYReject);
2748   TH1F *gSecondaryAntiProtonsDCAXYTPCReject = new TH1F("gSecondaryAntiProtonsDCAXYTPCReject",
2749                                                        ";DCA_{xy} [cm];Entries",
2750                                                        100,0,20);
2751   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAXYTPCReject);
2752   TH1F *gSecondaryAntiProtonsDCAZReject = new TH1F("gSecondaryAntiProtonsDCAZReject",
2753                                                    ";DCA_{z} [cm];Entries",
2754                                                    100,0,20);
2755   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAZReject);
2756   TH1F *gSecondaryAntiProtonsDCAZTPCReject = new TH1F("gSecondaryAntiProtonsDCAZTPCReject",
2757                                                       ";DCA_{z} [cm];Entries",
2758                                                       100,0,20);
2759   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAZTPCReject);
2760   TH1F *gSecondaryAntiProtonsConstrainChi2Reject = new TH1F("gSecondaryAntiProtonsConstrainChi2Reject",
2761                                                             ";Log_{10}(#chi^{2});Entries",
2762                                                             100,-10,10);
2763   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsConstrainChi2Reject);
2764   TH1F *gSecondaryAntiProtonsITSRefitReject = new TH1F("gSecondaryAntiProtonsITSRefitReject",
2765                                                        "",10,-1,1);
2766   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsITSRefitReject);
2767   TH1F *gSecondaryAntiProtonsTPCRefitReject = new TH1F("gSecondaryAntiProtonsTPCRefitReject",
2768                                                        "",10,-1,1);
2769   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsTPCRefitReject);
2770   TH1F *gSecondaryAntiProtonsESDpidReject = new TH1F("gSecondaryAntiProtonsESDpidReject",
2771                                                      "",10,-1,1);
2772   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsESDpidReject);
2773   TH1F *gSecondaryAntiProtonsTPCpidReject = new TH1F("gSecondaryAntiProtonsTPCpidReject",
2774                                                      "",10,-1,1);
2775   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsTPCpidReject);
2776   TH1F *gSecondaryAntiProtonsPointOnITSLayer1Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer1Reject",
2777                                                              "",10,-1,1);
2778   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer1Reject);
2779   TH1F *gSecondaryAntiProtonsPointOnITSLayer2Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer2Reject",
2780                                                              "",10,-1,1);
2781   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer2Reject);
2782   TH1F *gSecondaryAntiProtonsPointOnITSLayer3Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer3Reject",
2783                                                              "",10,-1,1);
2784   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer3Reject);
2785   TH1F *gSecondaryAntiProtonsPointOnITSLayer4Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer4Reject",
2786                                                              "",10,-1,1);
2787   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer4Reject);
2788   TH1F *gSecondaryAntiProtonsPointOnITSLayer5Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer5Reject",
2789                                                              "",10,-1,1);
2790   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer5Reject);
2791   TH1F *gSecondaryAntiProtonsPointOnITSLayer6Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer6Reject",
2792                                                              "",10,-1,1);
2793   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer6Reject);
2794 }
2795
2796 //____________________________________________________________________//
2797 void AliProtonQAAnalysis::RunEfficiencyAnalysis(AliStack *stack, 
2798                                                 AliESDEvent *esd,
2799                                                 const AliESDVertex *vertex) {
2800   //Runs the efficiency code
2801   //MC loop
2802   Int_t nMCProtons = 0, nESDProtons = 0;
2803   for(Int_t iParticle = 0; iParticle < stack->GetNtrack(); iParticle++) {
2804     TParticle *particle = stack->Particle(iParticle);
2805     if(!particle) continue;
2806
2807     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
2808     if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
2809     if(fAnalysisEtaMode) {
2810       if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
2811     }
2812     else 
2813       if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
2814
2815     Int_t pdgcode = particle->GetPdgCode();
2816     if(TMath::Abs(pdgcode) != 2212) continue;
2817
2818     if(iParticle <= stack->GetNprimary()) {
2819       if(pdgcode == 2212) {
2820         nMCProtons += 1;
2821         if(fAnalysisEtaMode) 
2822           ((TH2D *)(fEfficiencyList->At(0)))->Fill(particle->Eta(),
2823                                                    particle->Pt());
2824         else
2825           ((TH2D *)(fEfficiencyList->At(0)))->Fill(Rapidity(particle->Px(),
2826                                                             particle->Py(),
2827                                                             particle->Pz()),
2828                                                    particle->Pt());
2829       }//protons
2830       if(pdgcode == -2212) {
2831         if(fAnalysisEtaMode) 
2832           ((TH2D *)(fEfficiencyList->At(1)))->Fill(particle->Eta(),
2833                                                    particle->Pt());
2834         else
2835           ((TH2D *)(fEfficiencyList->At(1)))->Fill(Rapidity(particle->Px(),
2836                                                             particle->Py(),
2837                                                             particle->Pz()),
2838                                                    particle->Pt());
2839       }//antiprotons
2840     }//primaries
2841     else {
2842       //secondaries
2843       Int_t lPartMother = -1;
2844       Int_t motherPDGCode = -1;
2845       lPartMother = particle->GetFirstMother();
2846       TParticle *motherParticle = stack->Particle(lPartMother);
2847       if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
2848
2849       if(pdgcode == 2212) {
2850         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
2851           if(fAnalysisEtaMode) 
2852             ((TH2D *)(fEfficiencyList->At(2)))->Fill(particle->Eta(),
2853                                                      particle->Pt());
2854           else
2855             ((TH2D *)(fEfficiencyList->At(2)))->Fill(Rapidity(particle->Px(),
2856                                                               particle->Py(),
2857                                                               particle->Pz()),
2858                                                      particle->Pt());
2859         }//weak decays
2860         if((particle->GetUniqueID() == 13)) {
2861           if(fAnalysisEtaMode) 
2862             ((TH2D *)(fEfficiencyList->At(4)))->Fill(particle->Eta(),
2863                                                      particle->Pt());
2864           else
2865             ((TH2D *)(fEfficiencyList->At(4)))->Fill(Rapidity(particle->Px(),
2866                                                               particle->Py(),
2867                                                               particle->Pz()),
2868                                                      particle->Pt());
2869         }//hadronic interactions
2870       }//protons
2871       if(pdgcode == -2212) {
2872         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
2873           if(fAnalysisEtaMode) 
2874             ((TH2D *)(fEfficiencyList->At(3)))->Fill(particle->Eta(),
2875                                                      particle->Pt());
2876           else
2877             ((TH2D *)(fEfficiencyList->At(3)))->Fill(Rapidity(particle->Px(),
2878                                                               particle->Py(),
2879                                                               particle->Pz()),
2880                                                      particle->Pt());
2881         }//weak decays
2882         if((particle->GetUniqueID() == 13)) {
2883           if(fAnalysisEtaMode) 
2884             ((TH2D *)(fEfficiencyList->At(5)))->Fill(particle->Eta(),
2885                                                      particle->Pt());
2886           else
2887             ((TH2D *)(fEfficiencyList->At(5)))->Fill(Rapidity(particle->Px(),
2888                                                               particle->Py(),
2889                                                               particle->Pz()),
2890                                                      particle->Pt());
2891         }//hadronic interactions
2892       }//antiprotons
2893     }//secondaries
2894   
2895   }//MC loop
2896
2897   //ESD track loop
2898   Int_t nGoodTracks = esd->GetNumberOfTracks();
2899   TArrayI labelArray(nGoodTracks);
2900   Int_t labelCounter = 0;
2901   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
2902     AliESDtrack* track = esd->GetTrack(iTracks);
2903     if(!track) continue;
2904     
2905     Int_t label = TMath::Abs(track->GetLabel());
2906     if(IsLabelUsed(labelArray,label)) continue;
2907     labelArray.AddAt(label,labelCounter);
2908     labelCounter += 1;
2909     
2910     TParticle *particle = stack->Particle(label);
2911     if(!particle) continue;
2912     Int_t pdgcode = particle->GetPdgCode();
2913     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
2914     
2915     Double_t Pt = 0.0, P = 0.0;
2916     Double_t probability[5];
2917     
2918     //TPC only
2919     if(fUseTPCOnly) {
2920       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
2921       if(!tpcTrack) continue;
2922       Pt = tpcTrack->Pt();
2923       P = tpcTrack->P();
2924       
2925       if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
2926       if(fAnalysisEtaMode) {
2927         if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
2928       }
2929       else 
2930         if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
2931       
2932       if(fUseCutsInEfficiency) 
2933         if(!IsAccepted(esd,vertex,track)) continue;
2934       
2935       //reconstructed primary (anti)protons
2936       if(pdgcode == 2212) {
2937         if(fAnalysisEtaMode)
2938           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
2939                                                     particle->Pt());
2940         else
2941           ((TH2D *)(fEfficiencyList->At(12)))->Fill(Rapidity(particle->Px(),
2942                                                              particle->Py(),
2943                                                              particle->Pz()),
2944                                                     particle->Pt());
2945         if(label <= stack->GetNprimary()) {
2946           nESDProtons += 1;
2947           if(fAnalysisEtaMode)
2948             ((TH2D *)(fEfficiencyList->At(6)))->Fill(particle->Eta(),
2949                                                      particle->Pt());
2950           else
2951             ((TH2D *)(fEfficiencyList->At(6)))->Fill(Rapidity(particle->Px(),
2952                                                               particle->Py(),
2953                                                               particle->Pz()),
2954                                                      particle->Pt());
2955         }//primaries
2956         if(label > stack->GetNprimary()) {
2957           Int_t lPartMother = -1;
2958           Int_t motherPDGCode = -1;
2959           lPartMother = particle->GetFirstMother();
2960           TParticle *motherParticle = stack->Particle(lPartMother);
2961           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
2962           
2963           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
2964             if(fAnalysisEtaMode)
2965               ((TH2D *)(fEfficiencyList->At(8)))->Fill(particle->Eta(),
2966                                                        particle->Pt());
2967             else
2968               ((TH2D *)(fEfficiencyList->At(8)))->Fill(Rapidity(particle->Px(),
2969                                                                 particle->Py(),
2970                                                                 particle->Pz()),
2971                                                        particle->Pt());
2972           }//weak decays
2973           if((particle->GetUniqueID() == 13)) {
2974             if(fAnalysisEtaMode)
2975               ((TH2D *)(fEfficiencyList->At(10)))->Fill(particle->Eta(),
2976                                                         particle->Pt());
2977             else
2978               ((TH2D *)(fEfficiencyList->At(10)))->Fill(Rapidity(particle->Px(),
2979                                                                  particle->Py(),
2980                                                                  particle->Pz()),
2981                                                         particle->Pt());
2982           }//hadronic interactions
2983         }//secondaries
2984       }//initial protons
2985       if(pdgcode == -2212) {    
2986         if(fAnalysisEtaMode)
2987           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
2988                                                     particle->Pt());
2989         else
2990           ((TH2D *)(fEfficiencyList->At(12)))->Fill(Rapidity(particle->Px(),
2991                                                              particle->Py(),
2992                                                              particle->Pz()),
2993                                                     particle->Pt());
2994         if(label <= stack->GetNprimary()) {
2995           if(fAnalysisEtaMode)
2996             ((TH2D *)(fEfficiencyList->At(7)))->Fill(particle->Eta(),
2997                                                      particle->Pt());
2998           else
2999             ((TH2D *)(fEfficiencyList->At(7)))->Fill(Rapidity(particle->Px(),
3000                                                               particle->Py(),
3001                                                               particle->Pz()),
3002                                                      particle->Pt());
3003         }//primaries
3004         if(label > stack->GetNprimary()) {
3005           Int_t lPartMother = -1;
3006           Int_t motherPDGCode = -1;
3007           lPartMother = particle->GetFirstMother();
3008           TParticle *motherParticle = stack->Particle(lPartMother);
3009           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3010           
3011           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
3012             if(fAnalysisEtaMode)
3013               ((TH2D *)(fEfficiencyList->At(9)))->Fill(particle->Eta(),
3014                                                        particle->Pt());
3015             else
3016               ((TH2D *)(fEfficiencyList->At(9)))->Fill(Rapidity(particle->Px(),
3017                                                                 particle->Py(),
3018                                                                 particle->Pz()),
3019                                                        particle->Pt());
3020           }//weak decays
3021           if((particle->GetUniqueID() == 13)) {
3022             if(fAnalysisEtaMode)
3023               ((TH2D *)(fEfficiencyList->At(11)))->Fill(particle->Eta(),
3024                                                         particle->Pt());
3025             else
3026               ((TH2D *)(fEfficiencyList->At(11)))->Fill(Rapidity(particle->Px(),
3027                                                                  particle->Py(),
3028                                                                  particle->Pz()),
3029                                                         particle->Pt());
3030           }//hadronic interactions
3031         }//secondaries
3032       }//initial antiprotons
3033       
3034       //pid
3035       track->GetTPCpid(probability);
3036       Double_t rcc = 0.0;
3037       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3038         rcc += probability[i]*GetParticleFraction(i,P);
3039       if(rcc == 0.0) continue;
3040       Double_t w[5];
3041       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3042         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
3043       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
3044       if(fParticleType == 4) {
3045         if(fAnalysisEtaMode)
3046           ((TH2D *)(fEfficiencyList->At(14)))->Fill(particle->Eta(),
3047                                                     particle->Pt());
3048         else
3049           ((TH2D *)(fEfficiencyList->At(14)))->Fill(Rapidity(particle->Px(),
3050                                                              particle->Py(),
3051                                                              particle->Pz()),
3052                                                     particle->Pt());
3053         if(TMath::Abs(pdgcode) == 2212) {
3054           if(fAnalysisEtaMode)
3055             ((TH2D *)(fEfficiencyList->At(13)))->Fill(particle->Eta(),
3056                                                       particle->Pt());
3057           else
3058             ((TH2D *)(fEfficiencyList->At(13)))->Fill(Rapidity(particle->Px(),
3059                                                                particle->Py(),
3060                                                                particle->Pz()),
3061                                                       particle->Pt());
3062         }//properly identified as proton
3063         else {
3064           if(fAnalysisEtaMode)
3065             ((TH2D *)(fEfficiencyList->At(15)))->Fill(particle->Eta(),
3066                                                       particle->Pt());
3067           else
3068             ((TH2D *)(fEfficiencyList->At(15)))->Fill(Rapidity(particle->Px(),
3069                                                                particle->Py(),
3070                                                                particle->Pz()),
3071                                                       particle->Pt());
3072         }//contamination
3073       }//identified as proton
3074     }//TPC only tracks
3075     else if(!fUseTPCOnly) {
3076       if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
3077       if(fAnalysisEtaMode) {
3078         if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
3079       }
3080       else {
3081         if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
3082       }
3083       
3084       if(fUseCutsInEfficiency) 
3085         if(!IsAccepted(esd,vertex,track)) continue;
3086       
3087       //reconstructed primary (anti)protons
3088       if(pdgcode == 2212) {
3089         if(fAnalysisEtaMode)
3090           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
3091                                                     particle->Pt());
3092         else
3093           ((TH2D *)(fEfficiencyList->At(12)))->Fill(Rapidity(particle->Px(),
3094                                                              particle->Py(),
3095                                                              particle->Pz()),
3096                                                     particle->Pt());
3097         if(label <= stack->GetNprimary()) {
3098           nESDProtons += 1;
3099           if(fAnalysisEtaMode)
3100             ((TH2D *)(fEfficiencyList->At(6)))->Fill(particle->Eta(),
3101                                                      particle->Pt());
3102           else
3103             ((TH2D *)(fEfficiencyList->At(6)))->Fill(Rapidity(particle->Px(),
3104                                                               particle->Py(),
3105                                                               particle->Pz()),
3106                                                      particle->Pt());
3107         }//primaries
3108         if(label > stack->GetNprimary()) {
3109           Int_t lPartMother = -1;
3110           Int_t motherPDGCode = -1;
3111           lPartMother = particle->GetFirstMother();
3112           TParticle *motherParticle = stack->Particle(lPartMother);
3113           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3114           
3115           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
3116             if(fAnalysisEtaMode)
3117               ((TH2D *)(fEfficiencyList->At(8)))->Fill(particle->Eta(),
3118                                                        particle->Pt());
3119             else
3120               ((TH2D *)(fEfficiencyList->At(8)))->Fill(Rapidity(particle->Px(),
3121                                                                 particle->Py(),
3122                                                                 particle->Pz()),
3123                                                        particle->Pt());
3124           }//weak decays
3125           if((particle->GetUniqueID() == 13)) {
3126             if(fAnalysisEtaMode)
3127               ((TH2D *)(fEfficiencyList->At(10)))->Fill(particle->Eta(),
3128                                                         particle->Pt());
3129             else
3130               ((TH2D *)(fEfficiencyList->At(10)))->Fill(Rapidity(particle->Px(),
3131                                                                  particle->Py(),
3132                                                                  particle->Pz()),
3133                                                         particle->Pt());
3134           }//hadronic interactions
3135         }//secondaries
3136       }//initial protons
3137       if(pdgcode == -2212) {    
3138         if(fAnalysisEtaMode)
3139           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
3140                                                     particle->Pt());
3141         else
3142           ((TH2D *)(fEfficiencyList->At(12)))->Fill(Rapidity(particle->Px(),
3143                                                              particle->Py(),
3144                                                              particle->Pz()),
3145                                                     particle->Pt());
3146         if(label <= stack->GetNprimary()) {
3147           if(fAnalysisEtaMode)
3148             ((TH2D *)(fEfficiencyList->At(7)))->Fill(particle->Eta(),
3149                                                      particle->Pt());
3150           else
3151             ((TH2D *)(fEfficiencyList->At(7)))->Fill(Rapidity(particle->Px(),
3152                                                               particle->Py(),
3153                                                               particle->Pz()),
3154                                                      particle->Pt());
3155         }//primaries
3156         if(label > stack->GetNprimary()) {
3157           Int_t lPartMother = -1;
3158           Int_t motherPDGCode = -1;
3159           lPartMother = particle->GetFirstMother();
3160           TParticle *motherParticle = stack->Particle(lPartMother);
3161           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3162           
3163           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
3164             if(fAnalysisEtaMode)
3165               ((TH2D *)(fEfficiencyList->At(9)))->Fill(particle->Eta(),
3166                                                        particle->Pt());
3167             else
3168               ((TH2D *)(fEfficiencyList->At(9)))->Fill(Rapidity(particle->Px(),
3169                                                                 particle->Py(),
3170                                                                 particle->Pz()),
3171                                                        particle->Pt());
3172           }//weak decays
3173           if((particle->GetUniqueID() == 13)) {
3174             if(fAnalysisEtaMode)
3175               ((TH2D *)(fEfficiencyList->At(11)))->Fill(particle->Eta(),
3176                                                         particle->Pt());
3177             else
3178               ((TH2D *)(fEfficiencyList->At(11)))->Fill(Rapidity(particle->Px(),
3179                                                                  particle->Py(),
3180                                                                  particle->Pz()),
3181                                                         particle->Pt());
3182           }//hadronic interactions
3183         }//secondaries
3184       }//initial antiprotons
3185       
3186       //pid
3187       track->GetESDpid(probability);
3188       Double_t rcc = 0.0;
3189       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3190         rcc += probability[i]*GetParticleFraction(i,P);
3191       if(rcc == 0.0) continue;
3192       Double_t w[5];
3193       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3194         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
3195       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
3196       if(fParticleType == 4) {
3197         if(fAnalysisEtaMode)
3198           ((TH2D *)(fEfficiencyList->At(14)))->Fill(particle->Eta(),
3199                                                     particle->Pt());
3200         else ((TH2D *)(fEfficiencyList->At(14)))->Fill(Rapidity(particle->Px(),
3201                                                                 particle->Py(),
3202                                                                 particle->Pz()),
3203                                                        particle->Pt());
3204         if(TMath::Abs(pdgcode) == 2212) {
3205           if(fAnalysisEtaMode)
3206             ((TH2D *)(fEfficiencyList->At(13)))->Fill(particle->Eta(),
3207                                                       particle->Pt());
3208           else
3209             ((TH2D *)(fEfficiencyList->At(13)))->Fill(Rapidity(particle->Px(),
3210                                                                particle->Py(),
3211                                                                particle->Pz()),
3212                                                       particle->Pt());
3213         }//properly identified as proton
3214         else {
3215           if(fAnalysisEtaMode)
3216             ((TH2D *)(fEfficiencyList->At(15)))->Fill(particle->Eta(),
3217                                                       particle->Pt());
3218           else
3219             ((TH2D *)(fEfficiencyList->At(15)))->Fill(Rapidity(particle->Px(),
3220                                                                particle->Py(),
3221                                                                particle->Pz()),
3222                                                       particle->Pt());
3223         }//contamination
3224       }//identified as proton
3225     }//global tracking
3226   }//track loop
3227   
3228   //Printf("MC protons: %d - ESD protons: %d",nMCProtons,nESDProtons);
3229 }
3230
3231 //____________________________________________________________________//
3232 Bool_t AliProtonQAAnalysis::IsLabelUsed(TArrayI labelArray, 
3233                                         Int_t label) {
3234   //Checks if the label is used already
3235   Bool_t status = kFALSE;
3236   for(Int_t i = 0; i < labelArray.GetSize(); i++) {
3237     if(labelArray.At(i) == label)
3238       status = kTRUE;
3239   }
3240
3241   return status;
3242 }
3243
3244 //____________________________________________________________________//
3245 void AliProtonQAAnalysis::RunQAAnalysis(AliStack *stack, 
3246                                         AliESDEvent *esd,
3247                                         const AliESDVertex *vertex) {
3248   //Runs the QA code
3249   //MC loop
3250   for(Int_t iParticle = 0; iParticle < stack->GetNprimary(); iParticle++) {
3251     TParticle *particle = stack->Particle(iParticle);
3252     if(!particle) continue;
3253
3254     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
3255     if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
3256     if(fAnalysisEtaMode) {
3257       if((particle->Eta() > fMaxY)||(particle->Eta() < fMinY)) continue;
3258     }
3259     else {
3260       if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
3261     }
3262     Int_t pdgcode = particle->GetPdgCode();
3263     if(pdgcode == 2212) {
3264       if(fAnalysisEtaMode)
3265         ((TH2D *)(fQA2DList->At(8)))->Fill(particle->Eta(),
3266                                            particle->Pt());
3267       else
3268         ((TH2D *)(fQA2DList->At(8)))->Fill(Rapidity(particle->Px(),
3269                                                     particle->Py(),
3270                                                     particle->Pz()),
3271                                            particle->Pt());
3272     }
3273     if(pdgcode == -2212) {
3274       if(fAnalysisEtaMode)
3275         ((TH2D *)(fQA2DList->At(9)))->Fill(particle->Eta(),
3276                                            particle->Pt());
3277       else
3278         ((TH2D *)(fQA2DList->At(9)))->Fill(Rapidity(particle->Px(),
3279                                                     particle->Py(),
3280                                                     particle->Pz()),
3281                                            particle->Pt());
3282     }
3283   }//MC loop
3284   
3285   //ESD track loop
3286   Int_t nGoodTracks = esd->GetNumberOfTracks();
3287   TArrayI labelArray(nGoodTracks);
3288   Int_t labelCounter = 0;
3289   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
3290     AliESDtrack* track = esd->GetTrack(iTracks);
3291     if(!track) continue;
3292     
3293     Int_t label = TMath::Abs(track->GetLabel()); 
3294     if(IsLabelUsed(labelArray,label)) continue;
3295     labelArray.AddAt(label,labelCounter);
3296     labelCounter += 1;
3297     
3298     TParticle *particle = stack->Particle(label);
3299     if(!particle) continue;
3300     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
3301     
3302     AliESDtrack trackTPC;
3303     
3304     //in case it's a TPC only track relate it to the proper vertex
3305     if((fUseTPCOnly)&&(!fUseHybridTPC)) {
3306       Float_t p[2],cov[3];
3307       track->GetImpactParametersTPC(p,cov);
3308       if (p[0]==0 && p[1]==0)  
3309         track->RelateToVertexTPC(((AliESDEvent*)esd)->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
3310       if (!track->FillTPCOnlyTrack(trackTPC)) {
3311         continue;
3312       }
3313       track = &trackTPC ;
3314     }
3315     
3316     Double_t Pt = 0.0, P = 0.0;
3317     Double_t probability[5];
3318     Float_t dcaXY = 0.0, dcaZ = 0.0;
3319     Double_t nSigmaToVertex = GetSigmaToVertex(track);
3320     Int_t  fIdxInt[200];
3321     Int_t nClustersITS = track->GetITSclusters(fIdxInt);
3322     Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
3323     
3324     Float_t chi2PerClusterITS = -1;
3325     if (nClustersITS!=0)
3326       chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
3327     Float_t chi2PerClusterTPC = -1;
3328     if (nClustersTPC!=0)
3329       chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
3330     Double_t chi2ConstrainVertex = TMath::Log(track->GetConstrainedChi2());    
3331     Double_t extCov[15];
3332     track->GetExternalCovariance(extCov);
3333     
3334     //TPC only
3335     if(fUseTPCOnly) {
3336       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
3337       if(!tpcTrack) continue;
3338       Pt = tpcTrack->Pt();
3339       P = tpcTrack->P();
3340       if(fUseHybridTPC) track->GetImpactParameters(dcaXY,dcaZ);
3341       else track->GetImpactParametersTPC(dcaXY,dcaZ);
3342       
3343       //pid
3344       track->GetTPCpid(probability);
3345       Double_t rcc = 0.0;
3346       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3347         rcc += probability[i]*GetParticleFraction(i,P);
3348       if(rcc == 0.0) continue;
3349       Double_t w[5];
3350       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3351         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
3352       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
3353       if(fParticleType == 4) {
3354         if(!IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
3355
3356         FillQA(stack,esd,vertex,track);
3357         if(IsAccepted(esd,vertex,track)) {
3358           if(label <= stack->GetNprimary()) {
3359             if(track->Charge() > 0) {
3360               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3361                 if(track->HasPointOnITSLayer(iLayer))
3362                   ((TH1F *)(fAcceptedCutList->At(0)))->Fill(iLayer+1);
3363               }
3364               ((TH1F *)(fAcceptedCutList->At(4)))->Fill(nClustersITS);
3365               ((TH1F *)(fAcceptedCutList->At(8)))->Fill(chi2PerClusterITS);
3366               ((TH1F *)(fAcceptedCutList->At(12)))->Fill(chi2ConstrainVertex);
3367               ((TH1F *)(fAcceptedCutList->At(16)))->Fill(nClustersTPC);
3368               ((TH1F *)(fAcceptedCutList->At(20)))->Fill(chi2PerClusterTPC);
3369               ((TH1F *)(fAcceptedCutList->At(24)))->Fill(extCov[0]);
3370               ((TH1F *)(fAcceptedCutList->At(28)))->Fill(extCov[2]);
3371               ((TH1F *)(fAcceptedCutList->At(32)))->Fill(extCov[5]);
3372               ((TH1F *)(fAcceptedCutList->At(36)))->Fill(extCov[9]);
3373               ((TH1F *)(fAcceptedCutList->At(40)))->Fill(extCov[14]);
3374               
3375               ((TH1F *)(fAcceptedDCAList->At(0)))->Fill(TMath::Abs(dcaXY));
3376               ((TH1F *)(fAcceptedDCAList->At(4)))->Fill(TMath::Abs(dcaZ));
3377               ((TH1F *)(fAcceptedDCAList->At(8)))->Fill(nSigmaToVertex);
3378               if(fAnalysisEtaMode)
3379                 ((TH2D *)(fQA2DList->At(0)))->Fill(tpcTrack->Eta(),Pt);
3380               else
3381                 ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(tpcTrack->Px(),
3382                                                             tpcTrack->Py(),
3383                                                             tpcTrack->Pz()),
3384                                                    Pt);
3385               ((TH2D *)(fQA2DList->At(12)))->Fill(tpcTrack->Eta(),
3386                                                   tpcTrack->Phi()*180./TMath::Pi());
3387             }//accepted primary protons
3388             else if(track->Charge() < 0) {
3389               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3390                 if(track->HasPointOnITSLayer(iLayer))
3391                   ((TH1F *)(fAcceptedCutList->At(1)))->Fill(iLayer+1);
3392               }
3393               ((TH1F *)(fAcceptedCutList->At(5)))->Fill(nClustersITS);
3394               ((TH1F *)(fAcceptedCutList->At(9)))->Fill(chi2PerClusterITS);
3395               ((TH1F *)(fAcceptedCutList->At(13)))->Fill(chi2ConstrainVertex);
3396               ((TH1F *)(fAcceptedCutList->At(17)))->Fill(nClustersTPC);
3397               ((TH1F *)(fAcceptedCutList->At(21)))->Fill(chi2PerClusterTPC);
3398               ((TH1F *)(fAcceptedCutList->At(25)))->Fill(extCov[0]);
3399               ((TH1F *)(fAcceptedCutList->At(29)))->Fill(extCov[2]);
3400               ((TH1F *)(fAcceptedCutList->At(33)))->Fill(extCov[5]);
3401               ((TH1F *)(fAcceptedCutList->At(37)))->Fill(extCov[9]);
3402               ((TH1F *)(fAcceptedCutList->At(41)))->Fill(extCov[14]);
3403               
3404               ((TH1F *)(fAcceptedDCAList->At(1)))->Fill(TMath::Abs(dcaXY));
3405               ((TH1F *)(fAcceptedDCAList->At(5)))->Fill(TMath::Abs(dcaZ));
3406               ((TH1F *)(fAcceptedDCAList->At(9)))->Fill(nSigmaToVertex);
3407               if(fAnalysisEtaMode)
3408                 ((TH2D *)(fQA2DList->At(4)))->Fill(tpcTrack->Eta(),Pt);
3409               else
3410                 ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(tpcTrack->Px(),
3411                                                             tpcTrack->Py(),
3412                                                             tpcTrack->Pz()),
3413                                                    Pt);
3414               ((TH2D *)(fQA2DList->At(16)))->Fill(tpcTrack->Eta(),
3415                                                   tpcTrack->Phi()*180./TMath::Pi());
3416             }//accepted primary antiprotons
3417           }//accepted primary particles
3418           else if(label > stack->GetNprimary()) {
3419             Int_t lPartMother = -1;
3420             Int_t motherPDGCode = -1;
3421             if(particle) {
3422               lPartMother = particle->GetFirstMother();
3423               TParticle *motherParticle = stack->Particle(lPartMother);
3424               if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3425             }
3426             
3427             if(fMCProcessIdFlag)
3428               if(particle->GetUniqueID() != fMCProcessId) continue;
3429             if(fMotherParticlePDGCodeFlag)
3430               if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
3431             
3432             if(track->Charge() > 0) {
3433               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3434                 if(track->HasPointOnITSLayer(iLayer))
3435                   ((TH1F *)(fAcceptedCutList->At(2)))->Fill(iLayer+1);
3436               }
3437               ((TH1F *)(fAcceptedCutList->At(6)))->Fill(nClustersITS);
3438               ((TH1F *)(fAcceptedCutList->At(10)))->Fill(chi2PerClusterITS);
3439               ((TH1F *)(fAcceptedCutList->At(14)))->Fill(chi2ConstrainVertex);
3440               ((TH1F *)(fAcceptedCutList->At(18)))->Fill(nClustersTPC);
3441               ((TH1F *)(fAcceptedCutList->At(22)))->Fill(chi2PerClusterTPC);
3442               ((TH1F *)(fAcceptedCutList->At(26)))->Fill(extCov[0]);
3443               ((TH1F *)(fAcceptedCutList->At(30)))->Fill(extCov[2]);
3444               ((TH1F *)(fAcceptedCutList->At(34)))->Fill(extCov[5]);
3445               ((TH1F *)(fAcceptedCutList->At(38)))->Fill(extCov[9]);
3446               ((TH1F *)(fAcceptedCutList->At(42)))->Fill(extCov[14]);
3447               
3448               ((TH1F *)(fAcceptedDCAList->At(2)))->Fill(TMath::Abs(dcaXY));
3449               ((TH1F *)(fAcceptedDCAList->At(6)))->Fill(TMath::Abs(dcaZ));
3450               ((TH1F *)(fAcceptedDCAList->At(10)))->Fill(nSigmaToVertex);
3451               if(fAnalysisEtaMode)
3452                 ((TH2D *)(fQA2DList->At(2)))->Fill(tpcTrack->Eta(),Pt);
3453               else
3454                 ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(tpcTrack->Px(),
3455                                                             tpcTrack->Py(),
3456                                                             tpcTrack->Pz()),
3457                                                    Pt);
3458               ((TH2D *)(fQA2DList->At(14)))->Fill(tpcTrack->Eta(),
3459                                                   tpcTrack->Phi()*180./TMath::Pi());
3460               if(fAnalysisEtaMode)
3461               ((TH3F *)(fQA2DList->At(10)))->Fill(tpcTrack->Eta(),Pt,
3462                                                   ConvertPDGToInt(motherPDGCode));
3463               else
3464                 ((TH3F *)(fQA2DList->At(10)))->Fill(Rapidity(tpcTrack->Px(),
3465                                                              tpcTrack->Py(),
3466                                                              tpcTrack->Pz()),
3467                                                     Pt,
3468                                                     ConvertPDGToInt(motherPDGCode));
3469             }//accepted secondary protons
3470             else if(track->Charge() < 0) {
3471               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3472                 if(track->HasPointOnITSLayer(iLayer))
3473                   ((TH1F *)(fAcceptedCutList->At(3)))->Fill(iLayer+1);
3474               }
3475               ((TH1F *)(fAcceptedCutList->At(7)))->Fill(nClustersITS);
3476               ((TH1F *)(fAcceptedCutList->At(11)))->Fill(chi2PerClusterITS);
3477               ((TH1F *)(fAcceptedCutList->At(15)))->Fill(chi2ConstrainVertex);
3478               ((TH1F *)(fAcceptedCutList->At(19)))->Fill(nClustersTPC);
3479               ((TH1F *)(fAcceptedCutList->At(23)))->Fill(chi2PerClusterTPC);
3480               ((TH1F *)(fAcceptedCutList->At(27)))->Fill(extCov[0]);
3481               ((TH1F *)(fAcceptedCutList->At(31)))->Fill(extCov[2]);
3482               ((TH1F *)(fAcceptedCutList->At(35)))->Fill(extCov[5]);
3483               ((TH1F *)(fAcceptedCutList->At(39)))->Fill(extCov[9]);
3484               ((TH1F *)(fAcceptedCutList->At(43)))->Fill(extCov[14]);
3485               
3486               ((TH1F *)(fAcceptedDCAList->At(3)))->Fill(TMath::Abs(dcaXY));
3487               ((TH1F *)(fAcceptedDCAList->At(7)))->Fill(TMath::Abs(dcaZ));
3488               ((TH1F *)(fAcceptedDCAList->At(11)))->Fill(nSigmaToVertex);
3489               if(fAnalysisEtaMode)
3490                 ((TH2D *)(fQA2DList->At(6)))->Fill(tpcTrack->Eta(),Pt);
3491               else
3492                 ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(tpcTrack->Px(),
3493                                                             tpcTrack->Py(),
3494                                                             tpcTrack->Pz()),
3495                                                    Pt);
3496               ((TH2D *)(fQA2DList->At(18)))->Fill(tpcTrack->Eta(),
3497                                                   tpcTrack->Phi()*180./TMath::Pi());
3498               if(fAnalysisEtaMode)
3499                 ((TH3F *)(fQA2DList->At(11)))->Fill(tpcTrack->Eta(),Pt,
3500                                                     ConvertPDGToInt(motherPDGCode));
3501               else
3502                 ((TH3F *)(fQA2DList->At(11)))->Fill(Rapidity(tpcTrack->Px(),
3503                                                              tpcTrack->Py(),
3504                                                              tpcTrack->Pz()),
3505                                                     Pt,
3506                                                     ConvertPDGToInt(motherPDGCode));
3507             }//accepted secondary antiprotons
3508           }//accepted secondary particles
3509         }//accepted - track cuts
3510         else {
3511           if(label <= stack->GetNprimary()) {
3512             if(track->Charge() > 0) {
3513               if(fAnalysisEtaMode)
3514                 ((TH2D *)(fQA2DList->At(1)))->Fill(tpcTrack->Eta(),Pt);
3515               else
3516                 ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(tpcTrack->Px(),
3517                                                             tpcTrack->Py(),
3518                                                             tpcTrack->Pz()),
3519                                                    Pt);
3520               ((TH2D *)(fQA2DList->At(13)))->Fill(tpcTrack->Eta(),
3521                                                   tpcTrack->Phi()*180./TMath::Pi());
3522             }
3523             else if(track->Charge() < 0) {
3524               if(fAnalysisEtaMode)
3525                 ((TH2D *)(fQA2DList->At(5)))->Fill(tpcTrack->Eta(),Pt);
3526               else
3527                 ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(tpcTrack->Px(),
3528                                                             tpcTrack->Py(),
3529                                                             tpcTrack->Pz()),
3530                                                    Pt);
3531               ((TH2D *)(fQA2DList->At(17)))->Fill(tpcTrack->Eta(),
3532                                                   tpcTrack->Phi()*180./TMath::Pi());
3533             }
3534           }//rejected primary particles
3535           else if(label > stack->GetNprimary()) {
3536             if(track->Charge() > 0) {
3537               if(fAnalysisEtaMode)
3538                 ((TH2D *)(fQA2DList->At(3)))->Fill(tpcTrack->Eta(),Pt);
3539               else
3540                 ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(tpcTrack->Px(),
3541                                                             tpcTrack->Py(),
3542                                                             tpcTrack->Pz()),
3543                                                    Pt);
3544               ((TH2D *)(fQA2DList->At(15)))->Fill(tpcTrack->Eta(),
3545                                                   tpcTrack->Phi()*180./TMath::Pi());
3546             }
3547             else if(track->Charge() < 0) {
3548               if(fAnalysisEtaMode)
3549                 ((TH2D *)(fQA2DList->At(7)))->Fill(tpcTrack->Eta(),Pt);
3550               else
3551                 ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(tpcTrack->Px(),
3552                                                             tpcTrack->Py(),
3553                                                             tpcTrack->Pz()),
3554                                                    Pt);
3555               ((TH2D *)(fQA2DList->At(19)))->Fill(tpcTrack->Eta(),
3556                                                   tpcTrack->Phi()*180./TMath::Pi());
3557             }
3558           }//rejected secondary particles
3559         }//rejected - track cuts
3560       }//proton check
3561     }//TPC only tracks
3562     //combined tracking
3563     else if(!fUseTPCOnly) {
3564       Pt = track->Pt();
3565       P = track->P();
3566       track->GetImpactParameters(dcaXY,dcaZ);
3567       
3568       //pid
3569       track->GetESDpid(probability);
3570       Double_t rcc = 0.0;
3571       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3572         rcc += probability[i]*GetParticleFraction(i,P);
3573       if(rcc == 0.0) continue;
3574       Double_t w[5];
3575       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
3576         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
3577       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
3578       if(fParticleType == 4) {
3579         if(!IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
3580
3581         FillQA(stack,esd,vertex,track);
3582         if(IsAccepted(esd,vertex,track)) {
3583           if(label <= stack->GetNprimary()) {
3584             if(track->Charge() > 0) {
3585               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3586                 if(track->HasPointOnITSLayer(iLayer))
3587                   ((TH1F *)(fAcceptedCutList->At(0)))->Fill(iLayer+1);
3588               }
3589               ((TH1F *)(fAcceptedCutList->At(4)))->Fill(nClustersITS);
3590               ((TH1F *)(fAcceptedCutList->At(8)))->Fill(chi2PerClusterITS);
3591               ((TH1F *)(fAcceptedCutList->At(12)))->Fill(chi2ConstrainVertex);
3592               ((TH1F *)(fAcceptedCutList->At(16)))->Fill(nClustersTPC);
3593               ((TH1F *)(fAcceptedCutList->At(20)))->Fill(chi2PerClusterTPC);
3594               ((TH1F *)(fAcceptedCutList->At(24)))->Fill(extCov[0]);
3595               ((TH1F *)(fAcceptedCutList->At(28)))->Fill(extCov[2]);
3596               ((TH1F *)(fAcceptedCutList->At(32)))->Fill(extCov[5]);
3597               ((TH1F *)(fAcceptedCutList->At(36)))->Fill(extCov[9]);
3598               ((TH1F *)(fAcceptedCutList->At(40)))->Fill(extCov[14]);
3599               
3600               ((TH1F *)(fAcceptedDCAList->At(0)))->Fill(TMath::Abs(dcaXY));
3601               ((TH1F *)(fAcceptedDCAList->At(4)))->Fill(TMath::Abs(dcaZ));
3602               ((TH1F *)(fAcceptedDCAList->At(8)))->Fill(nSigmaToVertex);
3603               if(fAnalysisEtaMode)
3604                 ((TH2D *)(fQA2DList->At(0)))->Fill(track->Eta(),Pt);
3605               else
3606                 ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),
3607                                                             track->Py(),
3608                                                             track->Pz()),
3609                                                    Pt);
3610               ((TH2D *)(fQA2DList->At(12)))->Fill(track->Eta(),
3611                                                   track->Phi()*180./TMath::Pi());
3612             }
3613             else if(track->Charge() < 0) {
3614               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3615                 if(track->HasPointOnITSLayer(iLayer))
3616                   ((TH1F *)(fAcceptedCutList->At(1)))->Fill(iLayer+1);
3617               }
3618               ((TH1F *)(fAcceptedCutList->At(5)))->Fill(nClustersITS);
3619               ((TH1F *)(fAcceptedCutList->At(9)))->Fill(chi2PerClusterITS);
3620               ((TH1F *)(fAcceptedCutList->At(13)))->Fill(chi2ConstrainVertex);
3621               ((TH1F *)(fAcceptedCutList->At(17)))->Fill(nClustersTPC);
3622               ((TH1F *)(fAcceptedCutList->At(21)))->Fill(chi2PerClusterTPC);
3623               ((TH1F *)(fAcceptedCutList->At(25)))->Fill(extCov[0]);
3624               ((TH1F *)(fAcceptedCutList->At(29)))->Fill(extCov[2]);
3625               ((TH1F *)(fAcceptedCutList->At(33)))->Fill(extCov[5]);
3626               ((TH1F *)(fAcceptedCutList->At(37)))->Fill(extCov[9]);
3627               ((TH1F *)(fAcceptedCutList->At(41)))->Fill(extCov[14]);
3628               
3629               ((TH1F *)(fAcceptedDCAList->At(1)))->Fill(TMath::Abs(dcaXY));
3630               ((TH1F *)(fAcceptedDCAList->At(5)))->Fill(TMath::Abs(dcaZ));
3631               ((TH1F *)(fAcceptedDCAList->At(9)))->Fill(nSigmaToVertex);
3632               if(fAnalysisEtaMode)
3633                 ((TH2D *)(fQA2DList->At(4)))->Fill(track->Eta(),Pt);
3634               else
3635                 ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(track->Px(),
3636                                                             track->Py(),
3637                                                             track->Pz()),
3638                                                    Pt);
3639               ((TH2D *)(fQA2DList->At(16)))->Fill(track->Eta(),
3640                                                   track->Phi()*180./TMath::Pi());
3641             }
3642           }//primary particles
3643           else if(label > stack->GetNprimary()) {
3644             Int_t lPartMother = -1;
3645             Int_t motherPDGCode = -1;
3646             if(particle) {
3647               lPartMother = particle->GetFirstMother();
3648               TParticle *motherParticle = stack->Particle(lPartMother);
3649               if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
3650             }
3651             
3652             if(fMCProcessIdFlag)
3653               if(particle->GetUniqueID() != fMCProcessId) continue;
3654             if(fMotherParticlePDGCodeFlag)
3655               if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
3656             
3657             if(track->Charge() > 0) {
3658               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3659                 if(track->HasPointOnITSLayer(iLayer))
3660                   ((TH1F *)(fAcceptedCutList->At(2)))->Fill(iLayer+1);
3661               }
3662               ((TH1F *)(fAcceptedCutList->At(6)))->Fill(nClustersITS);
3663               ((TH1F *)(fAcceptedCutList->At(10)))->Fill(chi2PerClusterITS);
3664               ((TH1F *)(fAcceptedCutList->At(14)))->Fill(chi2ConstrainVertex);
3665               ((TH1F *)(fAcceptedCutList->At(18)))->Fill(nClustersTPC);
3666               ((TH1F *)(fAcceptedCutList->At(22)))->Fill(chi2PerClusterTPC);
3667               ((TH1F *)(fAcceptedCutList->At(26)))->Fill(extCov[0]);
3668               ((TH1F *)(fAcceptedCutList->At(30)))->Fill(extCov[2]);
3669               ((TH1F *)(fAcceptedCutList->At(34)))->Fill(extCov[5]);
3670               ((TH1F *)(fAcceptedCutList->At(38)))->Fill(extCov[9]);
3671               ((TH1F *)(fAcceptedCutList->At(42)))->Fill(extCov[14]);
3672               
3673               ((TH1F *)(fAcceptedDCAList->At(2)))->Fill(TMath::Abs(dcaXY));
3674               ((TH1F *)(fAcceptedDCAList->At(6)))->Fill(TMath::Abs(dcaZ));
3675               ((TH1F *)(fAcceptedDCAList->At(10)))->Fill(nSigmaToVertex);
3676               if(fAnalysisEtaMode)
3677                 ((TH2D *)(fQA2DList->At(2)))->Fill(track->Eta(),Pt);
3678               else
3679                 ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),
3680                                                             track->Py(),
3681                                                             track->Pz()),
3682                                                    Pt);
3683               ((TH2D *)(fQA2DList->At(14)))->Fill(track->Eta(),
3684                                                   track->Phi()*180./TMath::Pi());
3685               if(fAnalysisEtaMode)
3686                 ((TH3F *)(fQA2DList->At(10)))->Fill(track->Eta(),Pt,
3687                                                     ConvertPDGToInt(motherPDGCode));
3688               else
3689                 ((TH3F *)(fQA2DList->At(10)))->Fill(Rapidity(track->Px(),
3690                                                              track->Py(),
3691                                                              track->Pz()),
3692                                                     Pt,
3693                                                     ConvertPDGToInt(motherPDGCode));
3694             }
3695             else if(track->Charge() < 0) {
3696               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
3697                 if(track->HasPointOnITSLayer(iLayer))
3698                   ((TH1F *)(fAcceptedCutList->At(3)))->Fill(iLayer+1);
3699               }
3700               ((TH1F *)(fAcceptedCutList->At(7)))->Fill(nClustersITS);
3701               ((TH1F *)(fAcceptedCutList->At(11)))->Fill(chi2PerClusterITS);
3702               ((TH1F *)(fAcceptedCutList->At(15)))->Fill(chi2ConstrainVertex);
3703               ((TH1F *)(fAcceptedCutList->At(19)))->Fill(nClustersTPC);
3704               ((TH1F *)(fAcceptedCutList->At(23)))->Fill(chi2PerClusterTPC);
3705               ((TH1F *)(fAcceptedCutList->At(27)))->Fill(extCov[0]);
3706               ((TH1F *)(fAcceptedCutList->At(31)))->Fill(extCov[2]);
3707               ((TH1F *)(fAcceptedCutList->At(35)))->Fill(extCov[5]);
3708               ((TH1F *)(fAcceptedCutList->At(39)))->Fill(extCov[9]);
3709               ((TH1F *)(fAcceptedCutList->At(43)))->Fill(extCov[14]);
3710               
3711               ((TH1F *)(fAcceptedDCAList->At(3)))->Fill(TMath::Abs(dcaXY));
3712               ((TH1F *)(fAcceptedDCAList->At(7)))->Fill(TMath::Abs(dcaZ));
3713               ((TH1F *)(fAcceptedDCAList->At(11)))->Fill(nSigmaToVertex);
3714               if(fAnalysisEtaMode)
3715                 ((TH2D *)(fQA2DList->At(6)))->Fill(track->Eta(),Pt);
3716               else
3717                 ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(track->Px(),
3718                                                             track->Py(),
3719                                                             track->Pz()),
3720                                                    Pt);
3721               
3722               ((TH2D *)(fQA2DList->At(18)))->Fill(track->Eta(),
3723                                                   track->Phi()*180./TMath::Pi());
3724               if(fAnalysisEtaMode)
3725                 ((TH3F *)(fQA2DList->At(11)))->Fill(track->Eta(),Pt,
3726                                                     ConvertPDGToInt(motherPDGCode));
3727               else
3728                 ((TH3F *)(fQA2DList->At(11)))->Fill(Rapidity(track->Px(),
3729                                                              track->Py(),
3730                                                              track->Pz()),
3731                                                     Pt,
3732                                                     ConvertPDGToInt(motherPDGCode));
3733             }
3734           }//secondary particles
3735         }//accepted - track cuts
3736         else if(!IsAccepted(esd,vertex,track)) {
3737           if(label <= stack->GetNprimary()) {
3738             if(track->Charge() > 0) {
3739               if(fAnalysisEtaMode)
3740                 ((TH2D *)(fQA2DList->At(1)))->Fill(track->Eta(),Pt);
3741               else
3742                 ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),
3743                                                             track->Py(),
3744                                                             track->Pz()),
3745                                                    Pt);
3746               ((TH2D *)(fQA2DList->At(13)))->Fill(track->Eta(),
3747                                                   track->Phi()*180./TMath::Pi());
3748             }
3749             else if(track->Charge() < 0) {
3750               if(fAnalysisEtaMode)
3751                 ((TH2D *)(fQA2DList->At(5)))->Fill(track->Eta(),Pt);
3752               else
3753                 ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(track->Px(),
3754                                                             track->Py(),
3755                                                             track->Pz()),
3756                                                    Pt);
3757               ((TH2D *)(fQA2DList->At(17)))->Fill(track->Eta(),
3758                                                   track->Phi()*180./TMath::Pi());
3759             }
3760           }//primary particles
3761           else if(label > stack->GetNprimary()) {
3762             if(track->Charge() > 0) {
3763               if(fAnalysisEtaMode)
3764                 ((TH2D *)(fQA2DList->At(3)))->Fill(track->Eta(),Pt);
3765               else
3766                 ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),
3767                                                             track->Py(),
3768                                                             track->Pz()),
3769                                                    Pt);
3770               ((TH2D *)(fQA2DList->At(15)))->Fill(track->Eta(),
3771                                                   track->Phi()*180./TMath::Pi());
3772             }
3773             else if(track->Charge() < 0) {
3774               if(fAnalysisEtaMode)
3775                 ((TH2D *)(fQA2DList->At(7)))->Fill(track->Eta(),Pt);
3776               else
3777                 ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(track->Px(),
3778                                                             track->Py(),
3779                                                             track->Pz()),
3780                                                    Pt);
3781               ((TH2D *)(fQA2DList->At(19)))->Fill(track->Eta(),
3782                                                   track->Phi()*180./TMath::Pi());
3783             }
3784           }//secondary particles
3785         }//rejected - track cuts
3786       }//proton check
3787     }//combined tracking
3788   }//track loop
3789     
3790 }
3791
3792 //____________________________________________________________________//
3793 void AliProtonQAAnalysis::InitMCAnalysis() {
3794   //MC analysis - 3D histograms: y-pT-pdg
3795   fPDGList = new TList();
3796   TH3F *gHistYPtPDGProtons = new TH3F("gHistYPtPDGProtons",
3797                                       ";;P_{T} [GeV/c];PDG",
3798                                       fNBinsY,fMinY,fMaxY,
3799                                       fNBinsPt,fMinPt,fMaxPt,
3800                                       14,-0.5,13.5);
3801   if(fAnalysisEtaMode) 
3802     gHistYPtPDGProtons->GetXaxis()->SetTitle("#eta");
3803   else 
3804     gHistYPtPDGProtons->GetXaxis()->SetTitle("y");
3805   fPDGList->Add(gHistYPtPDGProtons);
3806   TH3F *gHistYPtPDGAntiProtons = new TH3F("gHistYPtPDGAntiProtons",
3807                                           ";;P_{T} [GeV/c];PDG",
3808                                           fNBinsY,fMinY,fMaxY,
3809                                           fNBinsPt,fMinPt,fMaxPt,
3810                                           14,-0.5,13.5);
3811   if(fAnalysisEtaMode) 
3812     gHistYPtPDGAntiProtons->GetXaxis()->SetTitle("#eta");
3813   else 
3814     gHistYPtPDGAntiProtons->GetXaxis()->SetTitle("y");
3815   fPDGList->Add(gHistYPtPDGAntiProtons);
3816
3817   //MC processes
3818   fMCProcessesList = new TList();
3819   TH1F *gHistProtonsFromKLProcess = new TH1F("gHistProtonsFromKLProcess","",51,-0.5,50.5);
3820   fMCProcessesList->Add(gHistProtonsFromKLProcess);
3821   TH1F *gHistProtonsFromPionProcess = new TH1F("gHistProtonsFromPionProcess","",51,-0.5,50.5);
3822   fMCProcessesList->Add(gHistProtonsFromPionProcess);
3823   TH1F *gHistProtonsFromKSProcess = new TH1F("gHistProtonsFromKSProcess","",51,-0.5,50.5);
3824   fMCProcessesList->Add(gHistProtonsFromKSProcess);
3825   TH1F *gHistProtonsFromKaonProcess = new TH1F("gHistProtonsFromKaonProcess","",51,-0.5,50.5);
3826   fMCProcessesList->Add(gHistProtonsFromKaonProcess);
3827   TH1F *gHistProtonsFromNeutronProcess = new TH1F("gHistProtonsFromNeutronProcess","",51,-0.5,50.5);
3828   fMCProcessesList->Add(gHistProtonsFromNeutronProcess);
3829   TH1F *gHistProtonsFromProtonProcess = new TH1F("gHistProtonsFromProtonProcess","",51,-0.5,50.5);
3830   fMCProcessesList->Add(gHistProtonsFromProtonProcess);
3831   TH1F *gHistProtonsFromSigmaMinusProcess = new TH1F("gHistProtonsFromSigmaMinusProcess","",51,-0.5,50.5);
3832   fMCProcessesList->Add(gHistProtonsFromSigmaMinusProcess);
3833   TH1F *gHistProtonsFromLambda0Process = new TH1F("gHistProtonsFromLambda0Process","",51,-0.5,50.5);
3834   fMCProcessesList->Add(gHistProtonsFromLambda0Process);
3835   TH1F *gHistProtonsFromSigmaPlusProcess = new TH1F("gHistProtonsFromSigmaPlusProcess","",51,-0.5,50.5);
3836   fMCProcessesList->Add(gHistProtonsFromSigmaPlusProcess);
3837   TH1F *gHistProtonsFromXiMinusProcess = new TH1F("gHistProtonsFromXiMinusProcess","",51,-0.5,50.5);
3838   fMCProcessesList->Add(gHistProtonsFromXiMinusProcess);
3839   TH1F *gHistProtonsFromXi0Process = new TH1F("gHistProtonsFromXi0Process","",51,-0.5,50.5);                                        
3840   fMCProcessesList->Add(gHistProtonsFromXi0Process);
3841   TH1F *gHistProtonsFromOmegaProcess = new TH1F("gHistProtonsFromOmegaProcess","",51,-0.5,50.5); 
3842   fMCProcessesList->Add(gHistProtonsFromOmegaProcess);
3843
3844   TH1F *gHistAntiProtonsFromKLProcess = new TH1F("gHistAntiProtonsFromKLProcess","",51,-0.5,50.5); 
3845   fMCProcessesList->Add(gHistAntiProtonsFromKLProcess);
3846   TH1F *gHistAntiProtonsFromPionProcess = new TH1F("gHistAntiProtonsFromPionProcess","",51,-0.5,50.5); 
3847   fMCProcessesList->Add(gHistAntiProtonsFromPionProcess);
3848   TH1F *gHistAntiProtonsFromKSProcess = new TH1F("gHistAntiProtonsFromKSProcess","",51,-0.5,50.5); 
3849   fMCProcessesList->Add(gHistAntiProtonsFromKSProcess);
3850   TH1F *gHistAntiProtonsFromKaonProcess = new TH1F("gHistAntiProtonsFromKaonProcess","",51,-0.5,50.5); 
3851   fMCProcessesList->Add(gHistAntiProtonsFromKaonProcess);
3852   TH1F *gHistAntiProtonsFromNeutronProcess = new TH1F("gHistAntiProtonsFromNeutronProcess","",51,-0.5,50.5); 
3853   fMCProcessesList->Add(gHistAntiProtonsFromNeutronProcess);
3854   TH1F *gHistAntiProtonsFromProtonProcess = new TH1F("gHistAntiProtonsFromProtonProcess","",51,-0.5,50.5); 
3855   fMCProcessesList->Add(gHistAntiProtonsFromProtonProcess);
3856   TH1F *gHistAntiProtonsFromLambda0Process = new TH1F("gHistAntiProtonsFromLambda0Process","",51,-0.5,50.5); 
3857   fMCProcessesList->Add(gHistAntiProtonsFromLambda0Process);
3858   TH1F *gHistAntiProtonsFromSigmaPlusProcess = new TH1F("gHistAntiProtonsFromSigmaPlusProcess","",51,-0.5,50.5); 
3859   fMCProcessesList->Add(gHistAntiProtonsFromSigmaPlusProcess);
3860 }
3861
3862 //____________________________________________________________________//
3863 void AliProtonQAAnalysis::RunMCAnalysis(AliStack* stack) {
3864   //Main analysis part - MC 
3865   for(Int_t iParticle = 0; iParticle < stack->GetNtrack(); iParticle++) {
3866     TParticle *particle = stack->Particle(iParticle);
3867     if(!particle) continue;
3868
3869     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
3870     if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
3871     if(fAnalysisEtaMode) {
3872       if((particle->Eta() > fMaxY)||(particle->Eta() < fMinY)) continue;
3873     }
3874     else {
3875       if((Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
3876     }
3877
3878     Int_t pdgcode = particle->GetPdgCode();
3879     if(pdgcode == 2212) {
3880       if(iParticle <= stack->GetNprimary()) {
3881         if(fAnalysisEtaMode)
3882           ((TH3F *)(fPDGList->At(0)))->Fill(particle->Eta(),particle->Pt(),0);
3883         else
3884           ((TH3F *)(fPDGList->At(0)))->Fill(Rapidity(particle->Px(),
3885                                                      particle->Py(),
3886                                                      particle->Pz()),
3887                                             particle->Pt(),0);
3888       }
3889       else if(iParticle > stack->GetNprimary()) {
3890         Int_t lPartMother = particle->GetFirstMother();
3891         TParticle *motherParticle = stack->Particle(lPartMother);
3892         if(!motherParticle) continue;
3893         Int_t motherPDGCode = motherParticle->GetPdgCode();
3894         if(fMCProcessIdFlag)
3895           if(particle->GetUniqueID() != fMCProcessId) continue;
3896         if(fMotherParticlePDGCodeFlag)
3897           if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
3898
3899         if(fAnalysisEtaMode)
3900           ((TH3F *)(fPDGList->At(0)))->Fill(particle->Eta(),
3901                                             particle->Pt(),
3902                                             ConvertPDGToInt(motherParticle->GetPdgCode()));
3903         else
3904           ((TH3F *)(fPDGList->At(0)))->Fill(Rapidity(particle->Px(),
3905                                                      particle->Py(),
3906                                                      particle->Pz()),
3907                                             particle->Pt(),
3908                                             ConvertPDGToInt(motherParticle->GetPdgCode()));
3909         //processes
3910         if(TMath::Abs(motherParticle->GetPdgCode()) == 130)
3911           ((TH1F *)(fMCProcessesList->At(0)))->Fill(particle->GetUniqueID());
3912         if(TMath::Abs(motherParticle->GetPdgCode()) == 211)
3913           ((TH1F *)(fMCProcessesList->At(1)))->Fill(particle->GetUniqueID());
3914         if(TMath::Abs(motherParticle->GetPdgCode()) == 310)
3915           ((TH1F *)(fMCProcessesList->At(2)))->Fill(particle->GetUniqueID());
3916         if(TMath::Abs(motherParticle->GetPdgCode()) == 321)
3917           ((TH1F *)(fMCProcessesList->At(3)))->Fill(particle->GetUniqueID());
3918         if(TMath::Abs(motherParticle->GetPdgCode()) == 2112)
3919           ((TH1F *)(fMCProcessesList->At(4)))->Fill(particle->GetUniqueID());
3920         if(TMath::Abs(motherParticle->GetPdgCode()) == 2212)
3921           ((TH1F *)(fMCProcessesList->At(5)))->Fill(particle->GetUniqueID());
3922         if(TMath::Abs(motherParticle->GetPdgCode()) == 3112)
3923           ((TH1F *)(fMCProcessesList->At(6)))->Fill(particle->GetUniqueID());
3924         if(TMath::Abs(motherParticle->GetPdgCode()) == 3122)
3925           ((TH1F *)(fMCProcessesList->At(7)))->Fill(particle->GetUniqueID());
3926         if(TMath::Abs(motherParticle->GetPdgCode()) == 3222)
3927           ((TH1F *)(fMCProcessesList->At(8)))->Fill(particle->GetUniqueID());
3928         if(TMath::Abs(motherParticle->GetPdgCode()) == 3312)
3929           ((TH1F *)(fMCProcessesList->At(9)))->Fill(particle->GetUniqueID());
3930         if(TMath::Abs(motherParticle->GetPdgCode()) == 3322)
3931           ((TH1F *)(fMCProcessesList->At(10)))->Fill(particle->GetUniqueID());
3932         if(TMath::Abs(motherParticle->GetPdgCode()) == 3334)
3933           ((TH1F *)(fMCProcessesList->At(11)))->Fill(particle->GetUniqueID());
3934       }//secondary proton
3935     }//pdgcode of proton
3936
3937     if(pdgcode == -2212) {
3938       if(iParticle <= stack->GetNprimary()) {
3939         if(fAnalysisEtaMode)
3940           ((TH3F *)(fPDGList->At(1)))->Fill(particle->Eta(),particle->Pt(),0);
3941         else
3942           ((TH3F *)(fPDGList->At(1)))->Fill(Rapidity(particle->Px(),
3943                                                      particle->Py(),
3944                                                      particle->Pz()),
3945                                             particle->Pt(),0);
3946       }
3947       else if(iParticle > stack->GetNprimary()) {
3948         Int_t lPartMother = particle->GetFirstMother();
3949         TParticle *motherParticle = stack->Particle(lPartMother);
3950         if(!motherParticle) continue;
3951         Int_t motherPDGCode = motherParticle->GetPdgCode();
3952         if(fMCProcessIdFlag)
3953           if(particle->GetUniqueID() != fMCProcessId) continue;
3954         if(fMotherParticlePDGCodeFlag)
3955           if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
3956
3957         if(fAnalysisEtaMode)
3958           ((TH3F *)(fPDGList->At(1)))->Fill(particle->Eta(),
3959                                             particle->Pt(),
3960                                             ConvertPDGToInt(motherParticle->GetPdgCode()));
3961         else
3962           ((TH3F *)(fPDGList->At(1)))->Fill(Rapidity(particle->Px(),
3963                                                      particle->Py(),
3964                                                      particle->Pz()),
3965                                             particle->Pt(),
3966                                             ConvertPDGToInt(motherParticle->GetPdgCode()));
3967
3968         //processes
3969         if(TMath::Abs(motherParticle->GetPdgCode()) == 130)
3970           ((TH1F *)(fMCProcessesList->At(12)))->Fill(particle->GetUniqueID());
3971         if(TMath::Abs(motherParticle->GetPdgCode()) == 211)
3972           ((TH1F *)(fMCProcessesList->At(13)))->Fill(particle->GetUniqueID());
3973         if(TMath::Abs(motherParticle->GetPdgCode()) == 310)
3974           ((TH1F *)(fMCProcessesList->At(14)))->Fill(particle->GetUniqueID());
3975         if(TMath::Abs(motherParticle->GetPdgCode()) == 321)
3976           ((TH1F *)(fMCProcessesList->At(15)))->Fill(particle->GetUniqueID());
3977         if(TMath::Abs(motherParticle->GetPdgCode()) == 2112)
3978           ((TH1F *)(fMCProcessesList->At(16)))->Fill(particle->GetUniqueID());
3979         if(TMath::Abs(motherParticle->GetPdgCode()) == 2212)
3980           ((TH1F *)(fMCProcessesList->At(17)))->Fill(particle->GetUniqueID());
3981         if(TMath::Abs(motherParticle->GetPdgCode()) == 3122)
3982           ((TH1F *)(fMCProcessesList->At(18)))->Fill(particle->GetUniqueID());
3983         if(TMath::Abs(motherParticle->GetPdgCode()) == 3222)
3984           ((TH1F *)(fMCProcessesList->At(19)))->Fill(particle->GetUniqueID());
3985       }//secondary antiproton
3986     }//pdgcode of antiproton
3987
3988   }//particle loop
3989 }
3990
3991 //____________________________________________________________________//
3992 Int_t AliProtonQAAnalysis::ConvertPDGToInt(Int_t pdgCode) {
3993   //Converts the pdg code to an int based on the following scheme:
3994   //1: PDG code: 130 - Name: K_L0
3995   //2: PDG code: 211 - Name: pi+
3996   //3: PDG code: 310 - Name: K_S0
3997   //4: PDG code: 321 - Name: K+
3998   //5: PDG code: 2112 - Name: neutron
3999   //6: PDG code: 2212 - Name: proton
4000   //7: PDG code: 3112 - Name: Sigma-
4001   //8: PDG code: 3122 - Name: Lambda0
4002   //9: PDG code: 3222 - Name: Sigma+
4003   //10: PDG code: 3312 - Name: Xi-
4004   //11: PDG code: 3322 - Name: Xi0
4005   //12: PDG code: 3334 - Name: Omega-
4006   Int_t code = -1;
4007   switch (TMath::Abs(pdgCode)) {
4008   case 130: {
4009     code = 1;
4010     break;
4011   }
4012   case 211: {
4013     code = 2;
4014     break;
4015   }
4016   case 310: {
4017     code = 3;
4018     break;
4019   }
4020   case 321: {
4021     code = 4;
4022     break;
4023   }
4024   case 2112: {
4025     code = 5;
4026     break;
4027   }
4028   case 2212: {
4029     code = 6;
4030     break;
4031   }
4032   case 3112: {
4033     code = 7;
4034     break;
4035   }
4036   case 3122: {
4037     code = 8;
4038     break;
4039   }
4040   case 3222: {
4041     code = 9;
4042     break;
4043   }
4044   case 3312: {
4045     code = 10;
4046     break;
4047   }
4048   case 3322: {
4049     code = 11;
4050     break;
4051   }
4052   case 3334: {
4053     code = 12;
4054     break;
4055   }
4056   default: {
4057     code = -1;
4058     break;
4059   }
4060   }//switch
4061
4062   return code;
4063 }
4064
4065 //________________________________________________________________________
4066 /*const AliESDVertex* AliProtonQAAnalysis::GetVertex(AliESDEvent* esd,
4067                                                    Double_t gVxMax,
4068                                                    Double_t gVyMax,
4069                                                    Double_t gVzMax) {
4070   // Get the vertex from the ESD and returns it if the vertex is valid
4071   // depending on the analysis mode: TPC - Hybrid - Global
4072   const AliESDVertex* vertex = 0;
4073   if((fUseTPCOnly)&&(!fUseHybridTPC)) {
4074     Double_t kBz = esd->GetMagneticField();
4075     AliVertexerTracks vertexer(kBz);
4076     vertexer.SetTPCMode();
4077     AliESDVertex *vTPC = vertexer.FindPrimaryVertex(esd);
4078     esd->SetPrimaryVertexTPC(vTPC);
4079     for (Int_t i=0; i<esd->GetNumberOfTracks(); i++) {
4080       AliESDtrack *t = esd->GetTrack(i);
4081       t->RelateToVertexTPC(vTPC, kBz, kVeryBig);
4082     }
4083     delete vTPC;
4084     vertex = esd->GetPrimaryVertexTPC();
4085   }
4086   else if(fUseHybridTPC)
4087     vertex = esd->GetPrimaryVertexSPD();
4088   else if(!fUseTPCOnly)
4089     vertex = esd->GetPrimaryVertex();
4090   else
4091     Printf("GetVertex: ERROR: Invalid analysis mode");
4092   
4093   if(!vertex) return 0;
4094   
4095   // check Ncontributors
4096   if(vertex->GetNContributors() <= 0) return 0;
4097   
4098   // check resolution
4099   Double_t zRes = vertex->GetZRes();
4100   if(zRes == 0) return 0;
4101   
4102   //check position
4103   if(TMath::Abs(vertex->GetXv()) > gVxMax) return 0;
4104   if(TMath::Abs(vertex->GetYv()) > gVyMax) return 0;
4105   if(TMath::Abs(vertex->GetZv()) > gVzMax) return 0;
4106
4107   return vertex;
4108   }*/
4109
4110
4111
4112
4113
4114
4115