]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/AliProtonQAAnalysis.cxx
i)Modifications in the visualization macro. ii)Checking the vmc process id for the...
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliProtonQAAnalysis.cxx
1 /**************************************************************************
2  * Author: Panos Christakoglou.                                           *
3  * Contributors are mentioned in the code where appropriate.              *
4  *                                                                        *
5  * Permission to use, copy, modify and distribute this software and its   *
6  * documentation strictly for non-commercial purposes is hereby granted   *
7  * without fee, provided that the above copyright notice appears in all   *
8  * copies and that both the copyright notice and this permission notice   *
9  * appear in the supporting documentation. The authors make no claims     *
10  * about the suitability of this software for any purpose. It is          *
11  * provided "as is" without express or implied warranty.                  *
12  **************************************************************************/
13
14 /* $Id: AliProtonQAAnalysis.cxx 29114 2008-10-03 16:49:02Z pchrist $ */
15
16 //-----------------------------------------------------------------
17 //                 AliProtonQAAnalysis class
18 //   This is the class to deal with the proton analysis
19 //   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
20 //-----------------------------------------------------------------
21 #include <Riostream.h>
22 #include <TFile.h>
23 #include <TSystem.h>
24 #include <TF1.h>
25 #include <TH2D.h>
26 #include <TH3F.h>
27 #include <TH1D.h>
28 #include <TParticle.h>
29
30 #include "AliProtonQAAnalysis.h"
31
32 #include <AliExternalTrackParam.h>
33 #include <AliESDEvent.h>
34 #include <AliLog.h>
35 #include <AliPID.h>
36 #include <AliStack.h>
37
38 ClassImp(AliProtonQAAnalysis)
39
40 //____________________________________________________________________//
41 AliProtonQAAnalysis::AliProtonQAAnalysis() : 
42   TObject(), 
43   fNBinsY(0), fMinY(0), fMaxY(0),
44   fNBinsPt(0), fMinPt(0), fMaxPt(0),
45   fMinTPCClusters(0), fMinITSClusters(0),
46   fMaxChi2PerTPCCluster(0), fMaxChi2PerITSCluster(0),
47   fMaxCov11(0), fMaxCov22(0), fMaxCov33(0), fMaxCov44(0), fMaxCov55(0),
48   fMaxSigmaToVertex(0), fMaxSigmaToVertexTPC(0),
49   fMaxDCAXY(0), fMaxDCAXYTPC(0),
50   fMaxDCAZ(0), fMaxDCAZTPC(0),
51   fMaxConstrainChi2(0),
52   fMinTPCClustersFlag(kFALSE), fMinITSClustersFlag(kFALSE),
53   fMaxChi2PerTPCClusterFlag(kFALSE), fMaxChi2PerITSClusterFlag(kFALSE),
54   fMaxCov11Flag(kFALSE), fMaxCov22Flag(kFALSE), 
55   fMaxCov33Flag(kFALSE), fMaxCov44Flag(kFALSE), fMaxCov55Flag(kFALSE),
56   fMaxSigmaToVertexFlag(kFALSE), fMaxSigmaToVertexTPCFlag(kFALSE),
57   fMaxDCAXYFlag(kFALSE), fMaxDCAXYTPCFlag(kFALSE),
58   fMaxDCAZFlag(kFALSE), fMaxDCAZTPCFlag(kFALSE),
59   fMaxConstrainChi2Flag(kFALSE),
60   fITSRefitFlag(kFALSE), fTPCRefitFlag(kFALSE),
61   fESDpidFlag(kFALSE), fTPCpidFlag(kFALSE),
62   fPointOnITSLayer1Flag(0), fPointOnITSLayer2Flag(0),
63   fPointOnITSLayer3Flag(0), fPointOnITSLayer4Flag(0),
64   fPointOnITSLayer5Flag(0), fPointOnITSLayer6Flag(0),
65   fGlobalQAList(0), fQA2DList(0),
66   fQAPrimaryProtonsAcceptedList(0),
67   fQAPrimaryProtonsRejectedList(0),
68   fQASecondaryProtonsAcceptedList(0),
69   fQASecondaryProtonsRejectedList(0),
70   fQAPrimaryAntiProtonsAcceptedList(0),
71   fQAPrimaryAntiProtonsRejectedList(0),
72   fQASecondaryAntiProtonsAcceptedList(0),
73   fQASecondaryAntiProtonsRejectedList(0),
74   fFunctionProbabilityFlag(kFALSE), 
75   fElectronFunction(0), fMuonFunction(0),
76   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
77   fUseTPCOnly(kFALSE),
78   fPDGList(0), fMCProcessesList(0),
79   fRunMCAnalysis(kFALSE),
80   fMCProcessIdFlag(kFALSE), fMCProcessId(0),
81   fMotherParticlePDGCodeFlag(kFALSE), fMotherParticlePDGCode(0),
82   fAcceptedCutList(0), fRejectedCutList(0),
83   fAcceptedDCAList(0), fRejectedDCAList(0) {
84   //Default constructor
85   for(Int_t i = 0; i < 5; i++) fPartFrac[i] = 0.0;
86 }
87
88 //____________________________________________________________________//
89 AliProtonQAAnalysis::~AliProtonQAAnalysis() {
90   //Default destructor
91   if(fGlobalQAList) delete fGlobalQAList;
92   if(fQA2DList) delete fQA2DList;
93   if(fQAPrimaryProtonsAcceptedList) delete fQAPrimaryProtonsAcceptedList;
94   if(fQAPrimaryProtonsRejectedList) delete fQAPrimaryProtonsRejectedList;
95   if(fQASecondaryProtonsAcceptedList) delete fQASecondaryProtonsAcceptedList;
96   if(fQASecondaryProtonsRejectedList) delete fQASecondaryProtonsRejectedList;
97   if(fQAPrimaryAntiProtonsAcceptedList) 
98     delete fQAPrimaryAntiProtonsAcceptedList;
99   if(fQAPrimaryAntiProtonsRejectedList) 
100     delete fQAPrimaryAntiProtonsRejectedList;
101   if(fQASecondaryAntiProtonsAcceptedList) 
102     delete fQASecondaryAntiProtonsAcceptedList;
103   if(fQASecondaryAntiProtonsRejectedList) 
104     delete fQASecondaryAntiProtonsRejectedList; 
105
106   if(fPDGList) delete fPDGList;
107   if(fMCProcessesList) delete fMCProcessesList;
108   
109   if(fAcceptedCutList) delete fAcceptedCutList;
110   if(fRejectedCutList) delete fRejectedCutList;
111   if(fAcceptedDCAList) delete fAcceptedDCAList;
112   if(fRejectedDCAList) delete fRejectedDCAList;
113 }
114
115 //____________________________________________________________________//
116 Double_t AliProtonQAAnalysis::GetParticleFraction(Int_t i, Double_t p) {
117   Double_t partFrac=0;
118   if(fFunctionProbabilityFlag) {
119     if(i == 0) partFrac = fElectronFunction->Eval(p);
120     if(i == 1) partFrac = fMuonFunction->Eval(p);
121     if(i == 2) partFrac = fPionFunction->Eval(p);
122     if(i == 3) partFrac = fKaonFunction->Eval(p);
123     if(i == 4) partFrac = fProtonFunction->Eval(p);
124   }
125   else partFrac = fPartFrac[i];
126
127   return partFrac;
128 }
129
130 //____________________________________________________________________//
131 /*Bool_t AliProtonQAAnalysis::IsAccepted(AliESDtrack* track) {
132   // Checks if the track is excluded from the cuts
133   Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
134   if(fUseTPCOnly) {
135     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
136     if(!tpcTrack) {
137       Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
138     }
139     else {
140       Pt = tpcTrack->Pt();
141       Px = tpcTrack->Px();
142       Py = tpcTrack->Py();
143       Pz = tpcTrack->Pz();
144     }
145   }
146   else{
147     Pt = track->Pt();
148     Px = track->Px();
149     Py = track->Py();
150     Pz = track->Pz();
151   }
152      
153   Int_t  fIdxInt[200];
154   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
155   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
156
157   Float_t chi2PerClusterITS = -1;
158   if (nClustersITS!=0)
159     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
160   Float_t chi2PerClusterTPC = -1;
161   if (nClustersTPC!=0)
162     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
163
164   Double_t extCov[15];
165   track->GetExternalCovariance(extCov);
166
167   if(fPointOnITSLayer1Flag)
168     if(!track->HasPointOnITSLayer(0)) return kFALSE;
169   if(fPointOnITSLayer2Flag)
170     if(!track->HasPointOnITSLayer(1)) return kFALSE;
171   if(fPointOnITSLayer3Flag)
172     if(!track->HasPointOnITSLayer(2)) return kFALSE;
173   if(fPointOnITSLayer4Flag)
174     if(!track->HasPointOnITSLayer(3)) return kFALSE;
175   if(fPointOnITSLayer5Flag)
176     if(!track->HasPointOnITSLayer(4)) return kFALSE;
177   if(fPointOnITSLayer6Flag)
178     if(!track->HasPointOnITSLayer(5)) return kFALSE;
179   if(fMinITSClustersFlag)
180     if(nClustersITS < fMinITSClusters) return kFALSE;
181   if(fMaxChi2PerITSClusterFlag)
182     if(chi2PerClusterITS > fMaxChi2PerITSCluster) return kFALSE; 
183   if(fMinTPCClustersFlag)
184     if(nClustersTPC < fMinTPCClusters) return kFALSE;
185   if(fMaxChi2PerTPCClusterFlag)
186     if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) return kFALSE; 
187   if(fMaxCov11Flag)
188     if(extCov[0] > fMaxCov11) return kFALSE;
189   if(fMaxCov22Flag)
190     if(extCov[2] > fMaxCov22) return kFALSE;
191   if(fMaxCov33Flag)
192     if(extCov[5] > fMaxCov33) return kFALSE;
193   if(fMaxCov44Flag)
194     if(extCov[9] > fMaxCov44) return kFALSE;
195   if(fMaxCov55Flag)
196     if(extCov[14] > fMaxCov55) return kFALSE;
197   if(fMaxSigmaToVertexFlag)
198     if(GetSigmaToVertex(track) > fMaxSigmaToVertex) return kFALSE;
199   if(fMaxSigmaToVertexTPCFlag)
200     if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) return kFALSE;
201   if(fITSRefitFlag)
202     if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) return kFALSE;
203   if(fTPCRefitFlag)
204     if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) return kFALSE;
205   if(fESDpidFlag)
206     if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) return kFALSE;
207   if(fTPCpidFlag)
208     if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) return kFALSE;
209
210   if((Pt < fMinPt) || (Pt > fMaxPt)) return kFALSE;
211   if((Rapidity(Px,Py,Pz) < fMinY) || (Rapidity(Px,Py,Pz) > fMaxY)) 
212     return kFALSE;
213
214   return kTRUE;
215 }*/
216
217 //____________________________________________________________________//
218 Bool_t AliProtonQAAnalysis::IsAccepted(AliESDtrack* track) {
219   // Checks if the track is excluded from the cuts
220   Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
221   Float_t dcaXY = 0.0, dcaZ = 0.0;
222
223   if(fUseTPCOnly) {
224     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
225     if(!tpcTrack) {
226       Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
227       dcaXY = -100.0, dcaZ = -100.0;
228     }
229     else {
230       Pt = tpcTrack->Pt();
231       Px = tpcTrack->Px();
232       Py = tpcTrack->Py();
233       Pz = tpcTrack->Pz();
234       track->GetImpactParametersTPC(dcaXY,dcaZ);
235     }
236   }
237   else{
238     Pt = track->Pt();
239     Px = track->Px();
240     Py = track->Py();
241     Pz = track->Pz();
242     track->GetImpactParameters(dcaXY,dcaZ);
243   }
244      
245   Int_t  fIdxInt[200];
246   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
247   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
248
249   Float_t chi2PerClusterITS = -1;
250   if (nClustersITS!=0)
251     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
252   Float_t chi2PerClusterTPC = -1;
253   if (nClustersTPC!=0)
254     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
255
256   Double_t extCov[15];
257   track->GetExternalCovariance(extCov);
258
259   if(fPointOnITSLayer1Flag)
260     if(!track->HasPointOnITSLayer(0)) return kFALSE;
261   if(fPointOnITSLayer2Flag)
262     if(!track->HasPointOnITSLayer(1)) return kFALSE;
263   if(fPointOnITSLayer3Flag)
264     if(!track->HasPointOnITSLayer(2)) return kFALSE;
265   if(fPointOnITSLayer4Flag)
266     if(!track->HasPointOnITSLayer(3)) return kFALSE;
267   if(fPointOnITSLayer5Flag)
268     if(!track->HasPointOnITSLayer(4)) return kFALSE;
269   if(fPointOnITSLayer6Flag)
270     if(!track->HasPointOnITSLayer(5)) return kFALSE;
271   if(fMinITSClustersFlag)
272     if(nClustersITS < fMinITSClusters) return kFALSE;
273   if(fMaxChi2PerITSClusterFlag)
274     if(chi2PerClusterITS > fMaxChi2PerITSCluster) return kFALSE; 
275   if(fMinTPCClustersFlag)
276     if(nClustersTPC < fMinTPCClusters) return kFALSE;
277   if(fMaxChi2PerTPCClusterFlag)
278     if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) return kFALSE; 
279   if(fMaxCov11Flag)
280     if(extCov[0] > fMaxCov11) return kFALSE;
281   if(fMaxCov22Flag)
282     if(extCov[2] > fMaxCov22) return kFALSE;
283   if(fMaxCov33Flag)
284     if(extCov[5] > fMaxCov33) return kFALSE;
285   if(fMaxCov44Flag)
286     if(extCov[9] > fMaxCov44) return kFALSE;
287   if(fMaxCov55Flag)
288     if(extCov[14] > fMaxCov55) return kFALSE;
289   if(fMaxSigmaToVertexFlag)
290     if(GetSigmaToVertex(track) > fMaxSigmaToVertex) return kFALSE;
291   if(fMaxSigmaToVertexTPCFlag)
292     if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) return kFALSE;
293   if(fMaxDCAXYFlag) 
294     if(TMath::Abs(dcaXY) > fMaxDCAXY) return kFALSE;
295   if(fMaxDCAXYTPCFlag) 
296     if(TMath::Abs(dcaXY) > fMaxDCAXY) return kFALSE;
297     if(fMaxDCAZFlag) 
298     if(TMath::Abs(dcaZ) > fMaxDCAZ) return kFALSE;
299   if(fMaxDCAZTPCFlag) 
300     if(TMath::Abs(dcaZ) > fMaxDCAZ) return kFALSE;
301   if(fMaxConstrainChi2Flag) {
302     if(track->GetConstrainedChi2() > 0) 
303       if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) return kFALSE;
304   }
305   if(fITSRefitFlag)
306     if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) return kFALSE;
307   if(fTPCRefitFlag)
308     if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) return kFALSE;
309   if(fESDpidFlag)
310     if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) return kFALSE;
311   if(fTPCpidFlag)
312     if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) return kFALSE;
313
314   if((Pt < fMinPt) || (Pt > fMaxPt)) return kFALSE;
315   if((Rapidity(Px,Py,Pz) < fMinY) || (Rapidity(Px,Py,Pz) > fMaxY)) 
316     return kFALSE;
317
318   return kTRUE;
319 }
320
321 //____________________________________________________________________//
322 void AliProtonQAAnalysis::FillQA(AliESDtrack* track, AliStack *stack) {
323   // Checks if the track is excluded from the cuts
324   Int_t nPrimaries = stack->GetNprimary();
325   Int_t label = TMath::Abs(track->GetLabel());
326
327   Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
328   Float_t dcaXY = 0.0, dcaZ = 0.0;
329   if(fUseTPCOnly) {
330     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
331     if(!tpcTrack) {
332       Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
333       dcaXY = -100.0, dcaZ = -100.0;
334     }
335     else {
336       Pt = tpcTrack->Pt();
337       Px = tpcTrack->Px();
338       Py = tpcTrack->Py();
339       Pz = tpcTrack->Pz();
340       track->GetImpactParametersTPC(dcaXY,dcaZ);
341     }
342   }
343   else{
344     Pt = track->Pt();
345     Px = track->Px();
346     Py = track->Py();
347     Pz = track->Pz();
348     track->GetImpactParameters(dcaXY,dcaZ);
349   }
350      
351   Int_t  fIdxInt[200];
352   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
353   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
354
355   Float_t chi2PerClusterITS = -1;
356   if (nClustersITS!=0)
357     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
358   Float_t chi2PerClusterTPC = -1;
359   if (nClustersTPC!=0)
360     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
361
362   Double_t extCov[15];
363   track->GetExternalCovariance(extCov);
364   
365   //cout<<"Charge: "<<track->Charge()<<
366   //" - Label/Primaries: "<<label<<"/"<<nPrimaries<<
367   //" - TPC clusters: "<<nClustersTPC<<endl;
368   //protons
369   if(track->Charge() > 0) {
370     //Primaries
371     if(label <= nPrimaries) {
372       if(fMinITSClustersFlag) {
373         if(nClustersITS < fMinITSClusters) {
374           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
375           //status = kFALSE;
376         }
377         else if(nClustersITS >= fMinITSClusters) 
378           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
379       }//ITS clusters
380       if(fMaxChi2PerITSClusterFlag) {
381         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
382           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
383           //status = kFALSE;
384         }
385         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
386           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
387       }//chi2 per ITS cluster
388       if(fMinTPCClustersFlag) {
389         if(nClustersTPC < fMinTPCClusters) {
390           //cout<<"Primary proton rejected"<<endl;
391           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
392           //status = kFALSE;
393         }
394         else if(nClustersTPC >= fMinTPCClusters) {
395           //cout<<"Primary proton accepted"<<endl;
396           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
397         }
398       }//TPC clusters
399       if(fMaxChi2PerTPCClusterFlag) {
400         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
401           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
402           //status = kFALSE;
403         }
404         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
405           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
406       }//chi2 per TPC cluster
407       if(fMaxCov11Flag) {
408         if(extCov[0] > fMaxCov11) {
409           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
410           //status = kFALSE;
411         }
412         else if(extCov[0] <= fMaxCov11)
413           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
414       }//cov11
415       if(fMaxCov22Flag) {
416         if(extCov[2] > fMaxCov22) {
417           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
418           //status = kFALSE;
419         }
420         else if(extCov[2] <= fMaxCov22)
421           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
422       }//cov11
423       if(fMaxCov33Flag) {
424         if(extCov[5] > fMaxCov33) {
425           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
426           //status = kFALSE;
427         }
428         else if(extCov[5] <= fMaxCov33)
429           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
430       }//cov11
431       if(fMaxCov44Flag) {
432         if(extCov[9] > fMaxCov44) {
433           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
434           //status = kFALSE;
435         }
436         else if(extCov[9] <= fMaxCov44)
437           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
438       }//cov11
439       if(fMaxCov55Flag) {
440         if(extCov[14] > fMaxCov55) {
441           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
442           //status = kFALSE;
443         }
444         else if(extCov[14] <= fMaxCov55)
445           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
446       }//cov55
447       if(fMaxSigmaToVertexFlag) {
448         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
449           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
450           //status = kFALSE;
451         }
452         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
453           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
454       }//sigma to vertex
455       if(fMaxSigmaToVertexTPCFlag) {
456         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
457           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
458           //status = kFALSE;
459         }
460         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
461           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
462       }//sigma to vertex TPC
463       if(fMaxDCAXYFlag) {
464         if(dcaXY > fMaxDCAXY) {
465           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(11)))->Fill(dcaXY);
466           //status = kFALSE;
467         }
468         else if(dcaXY <= fMaxDCAXY)
469           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(11)))->Fill(dcaXY);
470       }//DCA xy global tracking
471       if(fMaxDCAXYTPCFlag) {
472         if(dcaXY > fMaxDCAXY) {
473           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(12)))->Fill(dcaXY);
474           //status = kFALSE;
475         }
476         else if(dcaXY <= fMaxDCAXY)
477           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(12)))->Fill(dcaXY);
478       }//DCA xy TPC tracking
479       if(fMaxDCAZFlag) {
480         if(dcaZ > fMaxDCAZ) {
481           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(13)))->Fill(dcaZ);
482           //status = kFALSE;
483         }
484         else if(dcaZ <= fMaxDCAZ)
485           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(13)))->Fill(dcaZ);
486       }//DCA z global tracking
487       if(fMaxDCAZTPCFlag) {
488         if(dcaZ > fMaxDCAZ) {
489           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(14)))->Fill(dcaZ);
490           //status = kFALSE;
491         }
492         else if(dcaZ <= fMaxDCAZ)
493           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(14)))->Fill(dcaZ);
494       }//DCA z TPC tracking
495       if(fMaxConstrainChi2Flag) {
496         if(track->GetConstrainedChi2() > 0) {
497           if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
498             ((TH1F *)(fQAPrimaryProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
499             //status = kFALSE;
500           }
501           else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
502             ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
503         }
504       }//constrain chi2 - vertex
505       if(fITSRefitFlag) {
506         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
507           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(16)))->Fill(0);
508         //status = kFALSE;
509         }
510         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
511           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(16)))->Fill(0);
512       }//ITS refit
513       if(fTPCRefitFlag) {
514         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
515           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(17)))->Fill(0);
516           //status = kFALSE;
517         }
518         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
519           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(17)))->Fill(0);
520       }//TPC refit
521       if(fESDpidFlag) {
522         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
523           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(18)))->Fill(0);
524           //status = kFALSE;
525         }
526         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
527           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(18)))->Fill(0);
528       }//ESD pid
529       if(fTPCpidFlag) {
530         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
531           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(19)))->Fill(0);
532           //status = kFALSE;
533         }
534         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
535           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(19)))->Fill(0);
536       }//TPC pid
537       if(fPointOnITSLayer1Flag) {
538         if(!track->HasPointOnITSLayer(0)) {
539           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(20)))->Fill(0);
540         }
541         else if(track->HasPointOnITSLayer(0))
542           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(20)))->Fill(0);
543       }//point on SPD1
544       if(fPointOnITSLayer2Flag) {
545         if(!track->HasPointOnITSLayer(1)) {
546           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(21)))->Fill(0);
547         }
548         else if(track->HasPointOnITSLayer(1))
549           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(21)))->Fill(0);
550       }//point on SPD2
551       if(fPointOnITSLayer3Flag) {
552         if(!track->HasPointOnITSLayer(2)) {
553           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(22)))->Fill(0);
554         }
555         else if(track->HasPointOnITSLayer(2))
556           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(22)))->Fill(0);
557       }//point on SDD1
558       if(fPointOnITSLayer4Flag) {
559         if(!track->HasPointOnITSLayer(3)) {
560           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(23)))->Fill(0);
561         }
562         else if(track->HasPointOnITSLayer(3))
563           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(23)))->Fill(0);
564       }//point on SDD2
565       if(fPointOnITSLayer5Flag) {
566         if(!track->HasPointOnITSLayer(4)) {
567           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(24)))->Fill(0);
568         }
569         else if(track->HasPointOnITSLayer(4))
570           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(24)))->Fill(0);
571       }//point on SSD1
572       if(fPointOnITSLayer6Flag) {
573         if(!track->HasPointOnITSLayer(5)) {
574           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(25)))->Fill(0);
575         }
576         else if(track->HasPointOnITSLayer(5))
577           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(25)))->Fill(0);
578       }//point on SSD2
579     }//primary particle cut
580
581     //Secondaries
582     if(label > nPrimaries) {
583       if(fMinITSClustersFlag) {
584         if(nClustersITS < fMinITSClusters) {
585           ((TH1F *)(fQASecondaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
586           //status = kFALSE;
587         }
588         else if(nClustersITS >= fMinITSClusters) 
589           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
590       }//ITS clusters
591       if(fMaxChi2PerITSClusterFlag) {
592         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
593           ((TH1F *)(fQASecondaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
594           //status = kFALSE;
595         }
596         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
597           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
598       }//chi2 per ITS cluster
599       if(fMinTPCClustersFlag) {
600         if(nClustersTPC < fMinTPCClusters) {
601           //cout<<"Secondary proton rejected"<<endl;
602           ((TH1F *)(fQASecondaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
603           //status = kFALSE;
604         }
605         else if(nClustersTPC >= fMinTPCClusters) {
606           //cout<<"Secondary proton accepted"<<endl;
607           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
608         }
609       }//TPC clusters
610       if(fMaxChi2PerTPCClusterFlag) {
611         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
612           ((TH1F *)(fQASecondaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
613           //status = kFALSE;
614         }
615         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
616           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
617       }//chi2 per TPC cluster
618       if(fMaxCov11Flag) {
619         if(extCov[0] > fMaxCov11) {
620           ((TH1F *)(fQASecondaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
621           //status = kFALSE;
622         }
623         else if(extCov[0] <= fMaxCov11)
624           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
625       }//cov11
626       if(fMaxCov22Flag) {
627         if(extCov[2] > fMaxCov22) {
628           ((TH1F *)(fQASecondaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
629           //status = kFALSE;
630         }
631         else if(extCov[2] <= fMaxCov22)
632           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
633       }//cov11
634       if(fMaxCov33Flag) {
635         if(extCov[5] > fMaxCov33) {
636           ((TH1F *)(fQASecondaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
637           //status = kFALSE;
638         }
639         else if(extCov[5] <= fMaxCov33)
640           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
641       }//cov11
642       if(fMaxCov44Flag) {
643         if(extCov[9] > fMaxCov44) {
644           ((TH1F *)(fQASecondaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
645           //status = kFALSE;
646         }
647         else if(extCov[9] <= fMaxCov44)
648           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
649       }//cov11
650       if(fMaxCov55Flag) {
651         if(extCov[14] > fMaxCov55) {
652           ((TH1F *)(fQASecondaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
653           //status = kFALSE;
654         }
655         else if(extCov[14] <= fMaxCov55)
656           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
657       }//cov55
658       if(fMaxSigmaToVertexFlag) {
659         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
660           ((TH1F *)(fQASecondaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
661           //status = kFALSE;
662         }
663         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
664           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
665       }//sigma to vertex
666       if(fMaxSigmaToVertexTPCFlag) {
667         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
668           ((TH1F *)(fQASecondaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
669           //status = kFALSE;
670         }
671         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
672           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
673       }//sigma to vertex TPC
674       if(fMaxDCAXYFlag) {
675         if(dcaXY > fMaxDCAXY) {
676           ((TH1F *)(fQASecondaryProtonsRejectedList->At(11)))->Fill(dcaXY);
677           //status = kFALSE;
678         }
679         else if(dcaXY <= fMaxDCAXY)
680           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(11)))->Fill(dcaXY);
681       }//DCA xy global tracking
682       if(fMaxDCAXYTPCFlag) {
683         if(dcaXY > fMaxDCAXY) {
684           ((TH1F *)(fQASecondaryProtonsRejectedList->At(12)))->Fill(dcaXY);
685           //status = kFALSE;
686         }
687         else if(dcaXY <= fMaxDCAXY)
688           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(12)))->Fill(dcaXY);
689       }//DCA xy TPC tracking
690       if(fMaxDCAZFlag) {
691         if(dcaZ > fMaxDCAZ) {
692           ((TH1F *)(fQASecondaryProtonsRejectedList->At(13)))->Fill(dcaZ);
693           //status = kFALSE;
694         }
695         else if(dcaZ <= fMaxDCAZ)
696           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(13)))->Fill(dcaZ);
697       }//DCA z global tracking
698       if(fMaxDCAZTPCFlag) {
699         if(dcaZ > fMaxDCAZ) {
700           ((TH1F *)(fQASecondaryProtonsRejectedList->At(14)))->Fill(dcaZ);
701           //status = kFALSE;
702         }
703         else if(dcaZ <= fMaxDCAZ)
704           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(14)))->Fill(dcaZ);
705       }//DCA z TPC tracking
706       if(fMaxConstrainChi2Flag) {
707         if(track->GetConstrainedChi2() > 0) {
708           if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
709             ((TH1F *)(fQASecondaryProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
710             //status = kFALSE;
711           }
712           else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
713             ((TH1F *)(fQASecondaryProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
714         }
715       }//constrain chi2 - vertex
716       if(fITSRefitFlag) {
717         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
718           ((TH1F *)(fQASecondaryProtonsRejectedList->At(16)))->Fill(0);
719         //status = kFALSE;
720         }
721         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
722           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(16)))->Fill(0);
723       }//ITS refit
724       if(fTPCRefitFlag) {
725         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
726           ((TH1F *)(fQASecondaryProtonsRejectedList->At(17)))->Fill(0);
727           //status = kFALSE;
728         }
729         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
730           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(17)))->Fill(0);
731       }//TPC refit
732       if(fESDpidFlag) {
733         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
734           ((TH1F *)(fQASecondaryProtonsRejectedList->At(18)))->Fill(0);
735           //status = kFALSE;
736         }
737         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
738           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(18)))->Fill(0);
739       }//ESD pid
740       if(fTPCpidFlag) {
741         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
742           ((TH1F *)(fQASecondaryProtonsRejectedList->At(19)))->Fill(0);
743           //status = kFALSE;
744         }
745         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
746           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(19)))->Fill(0);
747       }//TPC pid
748       if(fPointOnITSLayer1Flag) {
749         if(!track->HasPointOnITSLayer(0)) {
750           ((TH1F *)(fQASecondaryProtonsRejectedList->At(20)))->Fill(0);
751         }
752         else if(track->HasPointOnITSLayer(0))
753           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(20)))->Fill(0);
754       }//point on SPD1
755       if(fPointOnITSLayer2Flag) {
756         if(!track->HasPointOnITSLayer(1)) {
757           ((TH1F *)(fQASecondaryProtonsRejectedList->At(21)))->Fill(0);
758         }
759         else if(track->HasPointOnITSLayer(1))
760           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(21)))->Fill(0);
761       }//point on SPD2
762       if(fPointOnITSLayer3Flag) {
763         if(!track->HasPointOnITSLayer(2)) {
764           ((TH1F *)(fQASecondaryProtonsRejectedList->At(22)))->Fill(0);
765         }
766         else if(track->HasPointOnITSLayer(2))
767           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(22)))->Fill(0);
768       }//point on SDD1
769       if(fPointOnITSLayer4Flag) {
770         if(!track->HasPointOnITSLayer(3)) {
771           ((TH1F *)(fQASecondaryProtonsRejectedList->At(23)))->Fill(0);
772         }
773         else if(track->HasPointOnITSLayer(3))
774           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(23)))->Fill(0);
775       }//point on SDD2
776       if(fPointOnITSLayer5Flag) {
777         if(!track->HasPointOnITSLayer(4)) {
778           ((TH1F *)(fQASecondaryProtonsRejectedList->At(24)))->Fill(0);
779         }
780         else if(track->HasPointOnITSLayer(4))
781           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(24)))->Fill(0);
782       }//point on SSD1
783       if(fPointOnITSLayer6Flag) {
784         if(!track->HasPointOnITSLayer(5)) {
785           ((TH1F *)(fQASecondaryProtonsRejectedList->At(25)))->Fill(0);
786         }
787         else if(track->HasPointOnITSLayer(5))
788           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(25)))->Fill(0);
789       }//point on SSD2
790     }//secondary particle cut
791   }//protons
792
793   //antiprotons
794   if(track->Charge() < 0) {
795     //Primaries
796     if(label <= nPrimaries) {
797       if(fMinITSClustersFlag) {
798         if(nClustersITS < fMinITSClusters) {
799           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
800           //status = kFALSE;
801         }
802         else if(nClustersITS >= fMinITSClusters) 
803           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
804       }//ITS clusters
805       if(fMaxChi2PerITSClusterFlag) {
806         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
807           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
808           //status = kFALSE;
809         }
810         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
811           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
812       }//chi2 per ITS cluster
813       if(fMinTPCClustersFlag) {
814         if(nClustersTPC < fMinTPCClusters) {
815           //cout<<"Primary antiproton rejected"<<endl;
816           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
817           //status = kFALSE;
818         }
819         else if(nClustersTPC >= fMinTPCClusters) {
820           //cout<<"Primary antiproton accepted"<<endl;
821           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
822         }
823       }//TPC clusters
824       if(fMaxChi2PerTPCClusterFlag) {
825         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
826           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
827           //status = kFALSE;
828         }
829         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
830           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
831       }//chi2 per TPC cluster
832       if(fMaxCov11Flag) {
833         if(extCov[0] > fMaxCov11) {
834           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
835           //status = kFALSE;
836         }
837         else if(extCov[0] <= fMaxCov11)
838           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
839       }//cov11
840       if(fMaxCov22Flag) {
841         if(extCov[2] > fMaxCov22) {
842           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
843           //status = kFALSE;
844         }
845         else if(extCov[2] <= fMaxCov22)
846           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
847       }//cov11
848       if(fMaxCov33Flag) {
849         if(extCov[5] > fMaxCov33) {
850           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
851           //status = kFALSE;
852         }
853         else if(extCov[5] <= fMaxCov33)
854           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
855       }//cov11
856       if(fMaxCov44Flag) {
857         if(extCov[9] > fMaxCov44) {
858           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
859           //status = kFALSE;
860         }
861         else if(extCov[9] <= fMaxCov44)
862           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
863       }//cov11
864       if(fMaxCov55Flag) {
865         if(extCov[14] > fMaxCov55) {
866           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
867           //status = kFALSE;
868         }
869         else if(extCov[14] <= fMaxCov55)
870           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
871       }//cov55
872       if(fMaxSigmaToVertexFlag) {
873         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
874           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
875           //status = kFALSE;
876         }
877         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
878           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
879       }//sigma to vertex
880       if(fMaxSigmaToVertexTPCFlag) {
881         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
882           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
883           //status = kFALSE;
884         }
885         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
886           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
887       }//sigma to vertex TPC
888       if(fMaxDCAXYFlag) {
889         if(dcaXY > fMaxDCAXY) {
890           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(11)))->Fill(dcaXY);
891           //status = kFALSE;
892         }
893         else if(dcaXY <= fMaxDCAXY)
894           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(11)))->Fill(dcaXY);
895       }//DCA xy global tracking
896       if(fMaxDCAXYTPCFlag) {
897         if(dcaXY > fMaxDCAXY) {
898           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(12)))->Fill(dcaXY);
899           //status = kFALSE;
900         }
901         else if(dcaXY <= fMaxDCAXY)
902           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(12)))->Fill(dcaXY);
903       }//DCA xy TPC tracking
904       if(fMaxDCAZFlag) {
905         if(dcaZ > fMaxDCAZ) {
906           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(13)))->Fill(dcaZ);
907           //status = kFALSE;
908         }
909         else if(dcaZ <= fMaxDCAZ)
910           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(13)))->Fill(dcaZ);
911       }//DCA z global tracking
912       if(fMaxDCAZTPCFlag) {
913         if(dcaZ > fMaxDCAZ) {
914           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(14)))->Fill(dcaZ);
915           //status = kFALSE;
916         }
917         else if(dcaZ <= fMaxDCAZ)
918           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(14)))->Fill(dcaZ);
919       }//DCA z TPC tracking
920       if(fMaxConstrainChi2Flag) {
921         if(track->GetConstrainedChi2() > 0) {
922           if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
923             ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
924             //status = kFALSE;
925           }
926           else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
927             ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
928         }
929       }//constrain chi2 - vertex
930       if(fITSRefitFlag) {
931         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
932           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(16)))->Fill(0);
933         //status = kFALSE;
934         }
935         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
936           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(16)))->Fill(0);
937       }//ITS refit
938       if(fTPCRefitFlag) {
939         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
940           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(17)))->Fill(0);
941           //status = kFALSE;
942         }
943         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
944           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(17)))->Fill(0);
945       }//TPC refit
946       if(fESDpidFlag) {
947         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
948           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(18)))->Fill(0);
949           //status = kFALSE;
950         }
951         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
952           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(18)))->Fill(0);
953       }//ESD pid
954       if(fTPCpidFlag) {
955         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
956           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(19)))->Fill(0);
957           //status = kFALSE;
958         }
959         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
960           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(19)))->Fill(0);
961       }//TPC pid
962       if(fPointOnITSLayer1Flag) {
963         if(!track->HasPointOnITSLayer(0)) {
964           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(20)))->Fill(0);
965         }
966         else if(track->HasPointOnITSLayer(0))
967           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(20)))->Fill(0);
968       }//point on SPD1
969       if(fPointOnITSLayer2Flag) {
970         if(!track->HasPointOnITSLayer(1)) {
971           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(21)))->Fill(0);
972         }
973         else if(track->HasPointOnITSLayer(1))
974           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(21)))->Fill(0);
975       }//point on SPD2
976       if(fPointOnITSLayer3Flag) {
977         if(!track->HasPointOnITSLayer(2)) {
978           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(22)))->Fill(0);
979         }
980         else if(track->HasPointOnITSLayer(2))
981           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(22)))->Fill(0);
982       }//point on SDD1
983       if(fPointOnITSLayer4Flag) {
984         if(!track->HasPointOnITSLayer(3)) {
985           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(23)))->Fill(0);
986         }
987         else if(track->HasPointOnITSLayer(3))
988           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(23)))->Fill(0);
989       }//point on SDD2
990       if(fPointOnITSLayer5Flag) {
991         if(!track->HasPointOnITSLayer(4)) {
992           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(24)))->Fill(0);
993         }
994         else if(track->HasPointOnITSLayer(4))
995           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(24)))->Fill(0);
996       }//point on SSD1
997       if(fPointOnITSLayer6Flag) {
998         if(!track->HasPointOnITSLayer(5)) {
999           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(25)))->Fill(0);
1000         }
1001         else if(track->HasPointOnITSLayer(5))
1002           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(25)))->Fill(0);
1003       }//point on SSD2
1004     }//primary particle cut
1005
1006     //Secondaries
1007     if(label > nPrimaries) {
1008       if(fMinITSClustersFlag) {
1009         if(nClustersITS < fMinITSClusters) {
1010           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
1011           //status = kFALSE;
1012         }
1013         else if(nClustersITS >= fMinITSClusters) 
1014           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
1015       }//ITS clusters
1016       if(fMaxChi2PerITSClusterFlag) {
1017         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
1018           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
1019           //status = kFALSE;
1020         }
1021         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
1022           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
1023       }//chi2 per ITS cluster
1024       if(fMinTPCClustersFlag) {
1025         if(nClustersTPC < fMinTPCClusters) {
1026           //cout<<"Secondary antiproton rejected"<<endl;
1027           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
1028           //status = kFALSE;
1029         }
1030         else if(nClustersTPC >= fMinTPCClusters) {
1031           //cout<<"Secondary antiproton accepted"<<endl;
1032           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
1033         }
1034       }//TPC clusters
1035       if(fMaxChi2PerTPCClusterFlag) {
1036         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
1037           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
1038           //status = kFALSE;
1039         }
1040         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
1041           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
1042       }//chi2 per TPC cluster
1043       if(fMaxCov11Flag) {
1044         if(extCov[0] > fMaxCov11) {
1045           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
1046           //status = kFALSE;
1047         }
1048         else if(extCov[0] <= fMaxCov11)
1049           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
1050       }//cov11
1051       if(fMaxCov22Flag) {
1052         if(extCov[2] > fMaxCov22) {
1053           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
1054           //status = kFALSE;
1055         }
1056         else if(extCov[2] <= fMaxCov22)
1057           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
1058       }//cov11
1059       if(fMaxCov33Flag) {
1060         if(extCov[5] > fMaxCov33) {
1061           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
1062           //status = kFALSE;
1063         }
1064         else if(extCov[5] <= fMaxCov33)
1065           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
1066       }//cov11
1067       if(fMaxCov44Flag) {
1068         if(extCov[9] > fMaxCov44) {
1069           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
1070           //status = kFALSE;
1071         }
1072         else if(extCov[9] <= fMaxCov44)
1073           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
1074       }//cov11
1075       if(fMaxCov55Flag) {
1076         if(extCov[14] > fMaxCov55) {
1077           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
1078           //status = kFALSE;
1079         }
1080         else if(extCov[14] <= fMaxCov55)
1081           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
1082       }//cov55
1083       if(fMaxSigmaToVertexFlag) {
1084         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
1085           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
1086           //status = kFALSE;
1087         }
1088         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
1089           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
1090       }//sigma to vertex
1091       if(fMaxSigmaToVertexTPCFlag) {
1092         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
1093           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
1094           //status = kFALSE;
1095         }
1096         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
1097           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
1098       }//sigma to vertex TPC
1099       if(fMaxDCAXYFlag) {
1100         if(dcaXY > fMaxDCAXY) {
1101           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(11)))->Fill(dcaXY);
1102           //status = kFALSE;
1103         }
1104         else if(dcaXY <= fMaxDCAXY)
1105           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(11)))->Fill(dcaXY);
1106       }//DCA xy global tracking
1107       if(fMaxDCAXYTPCFlag) {
1108         if(dcaXY > fMaxDCAXY) {
1109           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(12)))->Fill(dcaXY);
1110           //status = kFALSE;
1111         }
1112         else if(dcaXY <= fMaxDCAXY)
1113           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(12)))->Fill(dcaXY);
1114       }//DCA xy TPC tracking
1115       if(fMaxDCAZFlag) {
1116         if(dcaZ > fMaxDCAZ) {
1117           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(13)))->Fill(dcaZ);
1118           //status = kFALSE;
1119         }
1120         else if(dcaZ <= fMaxDCAZ)
1121           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(13)))->Fill(dcaZ);
1122       }//DCA z global tracking
1123       if(fMaxDCAZTPCFlag) {
1124         if(dcaZ > fMaxDCAZ) {
1125           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(14)))->Fill(dcaZ);
1126           //status = kFALSE;
1127         }
1128         else if(dcaZ <= fMaxDCAZ)
1129           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(14)))->Fill(dcaZ);
1130       }//DCA z TPC tracking
1131       if(fMaxConstrainChi2Flag) {
1132         if(track->GetConstrainedChi2() > 0) {
1133           if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
1134             ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
1135             //status = kFALSE;
1136           }
1137           else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
1138             ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
1139         }
1140       }//constrain chi2 - vertex
1141       if(fITSRefitFlag) {
1142         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
1143           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(16)))->Fill(0);
1144         //status = kFALSE;
1145         }
1146         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
1147           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(16)))->Fill(0);
1148       }//ITS refit
1149       if(fTPCRefitFlag) {
1150         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
1151           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(17)))->Fill(0);
1152           //status = kFALSE;
1153         }
1154         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
1155           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(17)))->Fill(0);
1156       }//TPC refit
1157       if(fESDpidFlag) {
1158         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
1159           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(18)))->Fill(0);
1160           //status = kFALSE;
1161         }
1162         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
1163           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(18)))->Fill(0);
1164       }//ESD pid
1165       if(fTPCpidFlag) {
1166         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
1167           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(19)))->Fill(0);
1168           //status = kFALSE;
1169         }
1170         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
1171           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(19)))->Fill(0);
1172       }//TPC pid
1173       if(fPointOnITSLayer1Flag) {
1174         if(!track->HasPointOnITSLayer(0)) {
1175           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(20)))->Fill(0);
1176         }
1177         else if(track->HasPointOnITSLayer(0))
1178           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(20)))->Fill(0);
1179       }//point on SPD1
1180       if(fPointOnITSLayer2Flag) {
1181         if(!track->HasPointOnITSLayer(1)) {
1182           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(21)))->Fill(0);
1183         }
1184         else if(track->HasPointOnITSLayer(1))
1185           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(21)))->Fill(0);
1186       }//point on SPD2
1187       if(fPointOnITSLayer3Flag) {
1188         if(!track->HasPointOnITSLayer(2)) {
1189           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(22)))->Fill(0);
1190         }
1191         else if(track->HasPointOnITSLayer(2))
1192           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(22)))->Fill(0);
1193       }//point on SDD1
1194       if(fPointOnITSLayer4Flag) {
1195         if(!track->HasPointOnITSLayer(3)) {
1196           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(23)))->Fill(0);
1197         }
1198         else if(track->HasPointOnITSLayer(3))
1199           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(23)))->Fill(0);
1200       }//point on SDD2
1201       if(fPointOnITSLayer5Flag) {
1202         if(!track->HasPointOnITSLayer(4)) {
1203           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(24)))->Fill(0);
1204         }
1205         else if(track->HasPointOnITSLayer(4))
1206           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(24)))->Fill(0);
1207       }//point on SSD1
1208       if(fPointOnITSLayer6Flag) {
1209         if(!track->HasPointOnITSLayer(5)) {
1210           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(25)))->Fill(0);
1211         }
1212         else if(track->HasPointOnITSLayer(5))
1213           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(25)))->Fill(0);
1214       }//point on SSD2
1215     }//secondary particle cut
1216   }//antiprotons
1217 }
1218
1219 //____________________________________________________________________//
1220 Float_t AliProtonQAAnalysis::GetSigmaToVertex(AliESDtrack* esdTrack) {
1221   // Calculates the number of sigma to the vertex.
1222   
1223   Float_t b[2];
1224   Float_t bRes[2];
1225   Float_t bCov[3];
1226   if(fUseTPCOnly) 
1227     esdTrack->GetImpactParametersTPC(b,bCov);
1228   else
1229     esdTrack->GetImpactParameters(b,bCov);
1230   
1231   if (bCov[0]<=0 || bCov[2]<=0) {
1232     //AliDebug(1, "Estimated b resolution lower or equal zero!");
1233     bCov[0]=0; bCov[2]=0;
1234   }
1235   bRes[0] = TMath::Sqrt(bCov[0]);
1236   bRes[1] = TMath::Sqrt(bCov[2]);
1237   
1238   if (bRes[0] == 0 || bRes[1] ==0) return -1;
1239   
1240   Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
1241   
1242   if (TMath::Exp(-d * d / 2) < 1e-10) return 1000;
1243   
1244   d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
1245   
1246   return d;
1247 }
1248
1249 //____________________________________________________________________//
1250 Double_t AliProtonQAAnalysis::Rapidity(Double_t Px, Double_t Py, Double_t Pz) {
1251   //returns the rapidity of the proton - to be removed
1252   Double_t fMass = 9.38270000000000048e-01;
1253   
1254   Double_t P = TMath::Sqrt(TMath::Power(Px,2) + 
1255                            TMath::Power(Py,2) + 
1256                            TMath::Power(Pz,2));
1257   Double_t energy = TMath::Sqrt(P*P + fMass*fMass);
1258   Double_t y = -999;
1259   if(energy != Pz) 
1260     y = 0.5*TMath::Log((energy + Pz)/(energy - Pz));
1261
1262   return y;
1263 }
1264
1265 //____________________________________________________________________//
1266 void AliProtonQAAnalysis::SetQAOn() {
1267   //initializes the QA lists
1268   //fQAHistograms = kTRUE;
1269   fGlobalQAList = new TList();
1270   fQA2DList = new TList();
1271   fQA2DList->SetName("fQA2DList");
1272   fGlobalQAList->Add(fQA2DList);
1273   
1274   fQAPrimaryProtonsAcceptedList = new TList();
1275   fQAPrimaryProtonsAcceptedList->SetName("fQAPrimaryProtonsAcceptedList");
1276   fGlobalQAList->Add(fQAPrimaryProtonsAcceptedList);
1277   
1278   fQAPrimaryProtonsRejectedList = new TList();
1279   fQAPrimaryProtonsRejectedList->SetName("fQAPrimaryProtonsRejectedList");
1280   fGlobalQAList->Add(fQAPrimaryProtonsRejectedList);
1281   
1282   fQASecondaryProtonsAcceptedList = new TList();
1283   fQASecondaryProtonsAcceptedList->SetName("fQASecondaryProtonsAcceptedList");
1284   fGlobalQAList->Add(fQASecondaryProtonsAcceptedList);
1285   
1286   fQASecondaryProtonsRejectedList = new TList();
1287   fQASecondaryProtonsRejectedList->SetName("fQASecondaryProtonsRejectedList");
1288   fGlobalQAList->Add(fQASecondaryProtonsRejectedList);
1289   
1290   fQAPrimaryAntiProtonsAcceptedList = new TList();
1291   fQAPrimaryAntiProtonsAcceptedList->SetName("fQAPrimaryAntiProtonsAcceptedList");
1292   fGlobalQAList->Add(fQAPrimaryAntiProtonsAcceptedList);
1293   
1294   fQAPrimaryAntiProtonsRejectedList = new TList();
1295   fQAPrimaryAntiProtonsRejectedList->SetName("fQAPrimaryAntiProtonsRejectedList");
1296   fGlobalQAList->Add(fQAPrimaryAntiProtonsRejectedList);
1297   
1298   fQASecondaryAntiProtonsAcceptedList = new TList();
1299   fQASecondaryAntiProtonsAcceptedList->SetName("fQASecondaryAntiProtonsAcceptedList");
1300   fGlobalQAList->Add(fQASecondaryAntiProtonsAcceptedList);
1301   
1302   fQASecondaryAntiProtonsRejectedList = new TList();
1303   fQASecondaryAntiProtonsRejectedList->SetName("fQASecondaryAntiProtonsRejectedList");
1304   fGlobalQAList->Add(fQASecondaryAntiProtonsRejectedList);
1305 }
1306
1307 //____________________________________________________________________//
1308 void AliProtonQAAnalysis::SetQAYPtBins(Int_t nbinsY, Double_t minY, Double_t maxY,
1309                                       Int_t nbinsPt, Double_t minPt, Double_t maxPt) {
1310   //Initializes the QA binning
1311   fNBinsY = nbinsY;
1312   fMinY = minY; fMaxY = maxY;
1313   fNBinsPt = nbinsPt;
1314   fMinPt = minPt; fMaxPt = maxPt;
1315   InitQA();
1316   InitCutLists();
1317   if(fRunMCAnalysis) InitMCAnalysis();
1318 }
1319
1320 //____________________________________________________________________//
1321 void AliProtonQAAnalysis::InitCutLists() {
1322   //Initialization of the cut lists
1323   //Adding each monitored object in each list
1324
1325   //Accepted cut list
1326   fAcceptedCutList = new TList();
1327   TH1F *gPrimaryProtonsClustersOnITSLayers = new TH1F("gPrimaryProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
1328   fAcceptedCutList->Add(gPrimaryProtonsClustersOnITSLayers);
1329   TH1F *gPrimaryAntiProtonsClustersOnITSLayers = new TH1F("gPrimaryAntiProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
1330   fAcceptedCutList->Add(gPrimaryAntiProtonsClustersOnITSLayers);
1331   TH1F *gSecondaryProtonsClustersOnITSLayers = new TH1F("gSecondaryProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
1332   fAcceptedCutList->Add(gSecondaryProtonsClustersOnITSLayers);
1333   TH1F *gSecondaryAntiProtonsClustersOnITSLayers = new TH1F("gSecondaryAntiProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
1334   fAcceptedCutList->Add(gSecondaryAntiProtonsClustersOnITSLayers);
1335
1336   TH1F *gPrimaryProtonsNClustersITS = new TH1F("gPrimaryProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
1337   fAcceptedCutList->Add(gPrimaryProtonsNClustersITS);
1338   TH1F *gPrimaryAntiProtonsNClustersITS = new TH1F("gPrimaryAntiProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
1339   fAcceptedCutList->Add(gPrimaryAntiProtonsNClustersITS);
1340   TH1F *gSecondaryProtonsNClustersITS = new TH1F("gSecondaryProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
1341   fAcceptedCutList->Add(gSecondaryProtonsNClustersITS);
1342   TH1F *gSecondaryAntiProtonsNClustersITS = new TH1F("gSecondaryAntiProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
1343   fAcceptedCutList->Add(gSecondaryAntiProtonsNClustersITS);
1344
1345   TH1F *gPrimaryProtonsChi2PerClusterITS = new TH1F("gPrimaryProtonsChi2PerClusterITS",
1346                                                     ";x^{2}/N_{clusters} (ITS);Entries",
1347                                                     100,0,20);
1348   fAcceptedCutList->Add(gPrimaryProtonsChi2PerClusterITS);
1349   TH1F *gPrimaryAntiProtonsChi2PerClusterITS = new TH1F("gPrimaryAntiProtonsChi2PerClusterITS",
1350                                                         ";x^{2}/N_{clusters} (ITS);Entries",
1351                                                         100,0,20);
1352   fAcceptedCutList->Add(gPrimaryAntiProtonsChi2PerClusterITS);
1353   TH1F *gSecondaryProtonsChi2PerClusterITS = new TH1F("gSecondaryProtonsChi2PerClusterITS",
1354                                                       ";x^{2}/N_{clusters} (ITS);Entries",
1355                                                       100,0,20);
1356   fAcceptedCutList->Add(gSecondaryProtonsChi2PerClusterITS);
1357   TH1F *gSecondaryAntiProtonsChi2PerClusterITS = new TH1F("gSecondaryAntiProtonsChi2PerClusterITS",
1358                                                           ";x^{2}/N_{clusters} (ITS);Entries",
1359                                                           100,0,20);
1360   fAcceptedCutList->Add(gSecondaryAntiProtonsChi2PerClusterITS);
1361
1362   TH1F *gPrimaryProtonsConstrainChi2 = new TH1F("gPrimaryProtonsConstrainChi2",
1363                                                 ";Log_{10}(#chi^{2});Entries",
1364                                                 100,-10,10);
1365   fAcceptedCutList->Add(gPrimaryProtonsConstrainChi2);
1366   TH1F *gPrimaryAntiProtonsConstrainChi2 = new TH1F("gPrimaryAntiProtonsConstrainChi2",
1367                                                     ";Log_{10}(#chi^{2});Entries",
1368                                                     100,-10,10);
1369   fAcceptedCutList->Add(gPrimaryAntiProtonsConstrainChi2);
1370   TH1F *gSecondaryProtonsConstrainChi2 = new TH1F("gSecondaryProtonsConstrainChi2",
1371                                                   ";Log_{10}(#chi^{2});Entries",
1372                                                   100,-10,10);
1373   fAcceptedCutList->Add(gSecondaryProtonsConstrainChi2);
1374   TH1F *gSecondaryAntiProtonsConstrainChi2 = new TH1F("gSecondaryAntiProtonsConstrainChi2",
1375                                                       ";Log_{10}(#chi^{2});Entries",
1376                                                       100,-10,10);
1377   fAcceptedCutList->Add(gSecondaryAntiProtonsConstrainChi2);
1378
1379   TH1F *gPrimaryProtonsTPCClusters = new TH1F("gPrimaryProtonsTPCClusters",
1380                                               ";N_{clusters} (TPC);Entries",
1381                                               100,0,200);
1382   fAcceptedCutList->Add(gPrimaryProtonsTPCClusters);
1383   TH1F *gPrimaryAntiProtonsTPCClusters = new TH1F("gPrimaryAntiProtonsTPCClusters",
1384                                                   ";N_{clusters} (TPC);Entries",
1385                                                   100,0,200);
1386   fAcceptedCutList->Add(gPrimaryAntiProtonsTPCClusters);
1387   TH1F *gSecondaryProtonsTPCClusters = new TH1F("gSecondaryProtonsTPCClusters",
1388                                                 ";N_{clusters} (TPC);Entries",
1389                                                 100,0,200);
1390   fAcceptedCutList->Add(gSecondaryProtonsTPCClusters);
1391   TH1F *gSecondaryAntiProtonsTPCClusters = new TH1F("gSecondaryAntiProtonsTPCClusters",
1392                                                     ";N_{clusters} (TPC);Entries",
1393                                                     100,0,200);
1394   fAcceptedCutList->Add(gSecondaryAntiProtonsTPCClusters);
1395
1396   TH1F *gPrimaryProtonsChi2PerClusterTPC = new TH1F("gPrimaryProtonsChi2PerClusterTPC",
1397                                                     ";x^{2}/N_{clusters} (TPC);Entries",
1398                                                     100,0,4);
1399   fAcceptedCutList->Add(gPrimaryProtonsChi2PerClusterTPC);
1400   TH1F *gPrimaryAntiProtonsChi2PerClusterTPC = new TH1F("gPrimaryAntiProtonsChi2PerClusterTPC",
1401                                                         ";x^{2}/N_{clusters} (TPC);Entries",
1402                                                         100,0,4);
1403   fAcceptedCutList->Add(gPrimaryAntiProtonsChi2PerClusterTPC);
1404   TH1F *gSecondaryProtonsChi2PerClusterTPC = new TH1F("gSecondaryProtonsChi2PerClusterTPC",
1405                                                       ";x^{2}/N_{clusters} (TPC);Entries",
1406                                                       100,0,4);
1407   fAcceptedCutList->Add(gSecondaryProtonsChi2PerClusterTPC);
1408   TH1F *gSecondaryAntiProtonsChi2PerClusterTPC = new TH1F("gSecondaryAntiProtonsChi2PerClusterTPC",
1409                                                           ";x^{2}/N_{clusters} (TPC);Entries",
1410                                                           100,0,4);
1411   fAcceptedCutList->Add(gSecondaryAntiProtonsChi2PerClusterTPC);
1412
1413   TH1F *gPrimaryProtonsExtCov11 = new TH1F("gPrimaryProtonsExtCov11",
1414                                            ";#sigma_{y} [cm];Entries",
1415                                            100,0,4);
1416   fAcceptedCutList->Add(gPrimaryProtonsExtCov11);
1417   TH1F *gPrimaryAntiProtonsExtCov11 = new TH1F("gPrimaryAntiProtonsExtCov11",
1418                                                ";#sigma_{y} [cm];Entries",
1419                                                100,0,4);
1420   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov11);
1421   TH1F *gSecondaryProtonsExtCov11 = new TH1F("gSecondaryProtonsExtCov11",
1422                                              ";#sigma_{y} [cm];Entries",
1423                                              100,0,4);
1424   fAcceptedCutList->Add(gSecondaryProtonsExtCov11);
1425   TH1F *gSecondaryAntiProtonsExtCov11 = new TH1F("gSecondaryAntiProtonsExtCov11",
1426                                                  ";#sigma_{y} [cm];Entries",
1427                                                  100,0,4);
1428   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov11);
1429
1430
1431   TH1F *gPrimaryProtonsExtCov22 = new TH1F("gPrimaryProtonsExtCov22",
1432                                            ";#sigma_{z} [cm];Entries",
1433                                            100,0,4);
1434   fAcceptedCutList->Add(gPrimaryProtonsExtCov22);
1435   TH1F *gPrimaryAntiProtonsExtCov22 = new TH1F("gPrimaryAntiProtonsExtCov22",
1436                                                ";#sigma_{z} [cm];Entries",
1437                                                100,0,4);
1438   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov22);
1439   TH1F *gSecondaryProtonsExtCov22 = new TH1F("gSecondaryProtonsExtCov22",
1440                                              ";#sigma_{z} [cm];Entries",
1441                                              100,0,4);
1442   fAcceptedCutList->Add(gSecondaryProtonsExtCov22);
1443   TH1F *gSecondaryAntiProtonsExtCov22 = new TH1F("gSecondaryAntiProtonsExtCov22",
1444                                                  ";#sigma_{z} [cm];Entries",
1445                                                  100,0,4);
1446   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov22);
1447
1448
1449   TH1F *gPrimaryProtonsExtCov33 = new TH1F("gPrimaryProtonsExtCov33",
1450                                            ";#sigma_{sin(#phi)};Entries",
1451                                            100,0,4);
1452   fAcceptedCutList->Add(gPrimaryProtonsExtCov33);
1453   TH1F *gPrimaryAntiProtonsExtCov33 = new TH1F("gPrimaryAntiProtonsExtCov33",
1454                                                ";#sigma_{sin(#phi)};Entries",
1455                                                100,0,4);
1456   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov33);
1457   TH1F *gSecondaryProtonsExtCov33 = new TH1F("gSecondaryProtonsExtCov33",
1458                                              ";#sigma_{sin(#phi)};Entries",
1459                                              100,0,4);
1460   fAcceptedCutList->Add(gSecondaryProtonsExtCov33);
1461   TH1F *gSecondaryAntiProtonsExtCov33 = new TH1F("gSecondaryAntiProtonsExtCov33",
1462                                                  ";#sigma_{sin(#phi)};Entries",
1463                                                  100,0,4);
1464   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov33);
1465
1466
1467   TH1F *gPrimaryProtonsExtCov44 = new TH1F("gPrimaryProtonsExtCov44",
1468                                            ";#sigma_{tan(#lambda)};Entries",
1469                                            100,0,4);
1470   fAcceptedCutList->Add(gPrimaryProtonsExtCov44);
1471   TH1F *gPrimaryAntiProtonsExtCov44 = new TH1F("gPrimaryAntiProtonsExtCov44",
1472                                                ";#sigma_{tan(#lambda)};Entries",
1473                                                100,0,4);
1474   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov44);
1475   TH1F *gSecondaryProtonsExtCov44 = new TH1F("gSecondaryProtonsExtCov44",
1476                                              ";#sigma_{tan(#lambda)};Entries",
1477                                              100,0,4);
1478   fAcceptedCutList->Add(gSecondaryProtonsExtCov44);
1479   TH1F *gSecondaryAntiProtonsExtCov44 = new TH1F("gSecondaryAntiProtonsExtCov44",
1480                                                  ";#sigma_{tan(#lambda)};Entries",
1481                                                  100,0,4);
1482   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov44);
1483
1484
1485   TH1F *gPrimaryProtonsExtCov55 = new TH1F("gPrimaryProtonsExtCov55",
1486                                            ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1487                                            100,0,4);
1488   fAcceptedCutList->Add(gPrimaryProtonsExtCov55);
1489   TH1F *gPrimaryAntiProtonsExtCov55 = new TH1F("gPrimaryAntiProtonsExtCov55",
1490                                                ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1491                                                100,0,4);
1492   fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov55);
1493   TH1F *gSecondaryProtonsExtCov55 = new TH1F("gSecondaryProtonsExtCov55",
1494                                              ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1495                                              100,0,4);
1496   fAcceptedCutList->Add(gSecondaryProtonsExtCov55);
1497   TH1F *gSecondaryAntiProtonsExtCov55 = new TH1F("gSecondaryAntiProtonsExtCov55",
1498                                                  ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1499                                                  100,0,4);
1500   fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov55);
1501
1502   //DCA list
1503   fAcceptedDCAList = new TList();
1504   TH1F *gPrimaryProtonsDCAXY = new TH1F("gPrimaryProtonsDCAXY",
1505                                         ";DCA_{xy} [cm];Entries",
1506                                         100,0,20);
1507   fAcceptedDCAList->Add(gPrimaryProtonsDCAXY);
1508   TH1F *gPrimaryAntiProtonsDCAXY = new TH1F("gPrimaryAntiProtonsDCAXY",
1509                                             ";DCA_{xy} [cm];Entries",
1510                                             100,0,20);
1511   fAcceptedDCAList->Add(gPrimaryAntiProtonsDCAXY);
1512   TH1F *gSecondaryProtonsDCAXY = new TH1F("gSecondaryProtonsDCAXY",
1513                                           ";DCA_{xy} [cm];Entries",
1514                                           100,0,20);
1515   fAcceptedDCAList->Add(gSecondaryProtonsDCAXY);
1516   TH1F *gSecondaryAntiProtonsDCAXY = new TH1F("gSecondaryAntiProtonsDCAXY",
1517                                               ";DCA_{xy} [cm];Entries",
1518                                               100,0,20);
1519
1520   fAcceptedDCAList->Add(gSecondaryAntiProtonsDCAXY);
1521   TH1F *gPrimaryProtonsDCAZ = new TH1F("gPrimaryProtonsDCAZ",
1522                                        ";DCA_{z} [cm];Entries",
1523                                        100,0,20);
1524   fAcceptedDCAList->Add(gPrimaryProtonsDCAZ);
1525   TH1F *gPrimaryAntiProtonsDCAZ = new TH1F("gPrimaryAntiProtonsDCAZ",
1526                                            ";DCA_{z} [cm];Entries",
1527                                            100,0,20);
1528   fAcceptedDCAList->Add(gPrimaryAntiProtonsDCAZ);
1529   TH1F *gSecondaryProtonsDCAZ = new TH1F("gSecondaryProtonsDCAZ",
1530                                          ";DCA_{z} [cm];Entries",
1531                                          100,0,20);
1532   fAcceptedDCAList->Add(gSecondaryProtonsDCAZ);
1533   TH1F *gSecondaryAntiProtonsDCAZ = new TH1F("gSecondaryAntiProtonsDCAZ",
1534                                              ";DCA_{z} [cm];Entries",
1535                                              100,0,20);
1536   fAcceptedDCAList->Add(gSecondaryAntiProtonsDCAZ);
1537
1538   TH1F *gPrimaryProtonsSigmaToVertex = new TH1F("gPrimaryProtonsSigmaToVertex",
1539                                                 ";#sigma_{Vertex};Entries",
1540                                                 100,0,10);
1541   fAcceptedDCAList->Add(gPrimaryProtonsSigmaToVertex);
1542   TH1F *gPrimaryAntiProtonsSigmaToVertex = new TH1F("gPrimaryAntiProtonsSigmaToVertex",
1543                                                     ";#sigma_{Vertex};Entries",
1544                                                     100,0,10);
1545   fAcceptedDCAList->Add(gPrimaryAntiProtonsSigmaToVertex);
1546   TH1F *gSecondaryProtonsSigmaToVertex = new TH1F("gSecondaryProtonsSigmaToVertex",
1547                                                   ";#sigma_{Vertex};Entries",
1548                                                   100,0,10);
1549   fAcceptedDCAList->Add(gSecondaryProtonsSigmaToVertex);
1550   TH1F *gSecondaryAntiProtonsSigmaToVertex = new TH1F("gSecondaryAntiProtonsSigmaToVertex",
1551                                                       ";#sigma_{Vertex};Entries",
1552                                                       100,0,10);
1553   fAcceptedDCAList->Add(gSecondaryAntiProtonsSigmaToVertex);
1554
1555 }
1556
1557 //____________________________________________________________________//
1558 void AliProtonQAAnalysis::InitQA() {
1559   //Initializes the QA histograms and builds the directory structure
1560   //if(!fQAHistograms) 
1561   SetQAOn();
1562
1563   //2D histograms
1564   //TDirectory *dir2D = gDirectory->mkdir("2D");
1565   //fGlobalQAList->Add(dir2D); dir2D->cd();
1566   TH2D *gHistYPtPrimaryProtonsPass = new TH2D("gHistYPtPrimaryProtonsPass",
1567                                               ";y;P_{T} [GeV/c]",
1568                                               fNBinsY,fMinY,fMaxY,
1569                                               fNBinsPt,fMinPt,fMaxPt);
1570   gHistYPtPrimaryProtonsPass->SetStats(kTRUE);
1571   gHistYPtPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
1572   fQA2DList->Add(gHistYPtPrimaryProtonsPass);
1573   TH2D *gHistYPtPrimaryProtonsReject = new TH2D("gHistYPtPrimaryProtonsReject",
1574                                                 ";y;P_{T} [GeV/c]",
1575                                                 fNBinsY,fMinY,fMaxY,
1576                                                 fNBinsPt,fMinPt,fMaxPt);
1577   gHistYPtPrimaryProtonsReject->SetStats(kTRUE);
1578   gHistYPtPrimaryProtonsReject->GetXaxis()->SetTitleColor(1);
1579   fQA2DList->Add(gHistYPtPrimaryProtonsReject);
1580
1581   TH2D *gHistYPtSecondaryProtonsPass = new TH2D("gHistYPtSecondaryProtonsPass",
1582                                                 ";y;P_{T} [GeV/c]",
1583                                                 fNBinsY,fMinY,fMaxY,
1584                                                 fNBinsPt,fMinPt,fMaxPt);
1585   gHistYPtSecondaryProtonsPass->SetStats(kTRUE);
1586   gHistYPtSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
1587   fQA2DList->Add(gHistYPtSecondaryProtonsPass);
1588   TH2D *gHistYPtSecondaryProtonsReject = new TH2D("gHistYPtSecondaryProtonsReject",
1589                                                   ";y;P_{T} [GeV/c]",
1590                                                   fNBinsY,fMinY,fMaxY,
1591                                                   fNBinsPt,fMinPt,fMaxPt);
1592   gHistYPtSecondaryProtonsReject->SetStats(kTRUE);
1593   gHistYPtSecondaryProtonsReject->GetXaxis()->SetTitleColor(1);
1594   fQA2DList->Add(gHistYPtSecondaryProtonsReject);
1595
1596   TH2D *gHistYPtPrimaryAntiProtonsPass = new TH2D("gHistYPtPrimaryAntiProtonsPass",
1597                                                   ";y;P_{T} [GeV/c]",
1598                                                   fNBinsY,fMinY,fMaxY,
1599                                                   fNBinsPt,fMinPt,fMaxPt);
1600   gHistYPtPrimaryAntiProtonsPass->SetStats(kTRUE);
1601   gHistYPtPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
1602   fQA2DList->Add(gHistYPtPrimaryAntiProtonsPass);
1603   TH2D *gHistYPtPrimaryAntiProtonsReject = new TH2D("gHistYPtPrimaryAntiProtonsReject",
1604                                                   ";y;P_{T} [GeV/c]",
1605                                                   fNBinsY,fMinY,fMaxY,
1606                                                   fNBinsPt,fMinPt,fMaxPt);
1607   gHistYPtPrimaryAntiProtonsReject->SetStats(kTRUE);
1608   gHistYPtPrimaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
1609   fQA2DList->Add(gHistYPtPrimaryAntiProtonsReject);
1610
1611   TH2D *gHistYPtSecondaryAntiProtonsPass = new TH2D("gHistYPtSecondaryAntiProtonsPass",
1612                                                   ";y;P_{T} [GeV/c]",
1613                                                   fNBinsY,fMinY,fMaxY,
1614                                                   fNBinsPt,fMinPt,fMaxPt);
1615   gHistYPtSecondaryAntiProtonsPass->SetStats(kTRUE);
1616   gHistYPtSecondaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
1617   fQA2DList->Add(gHistYPtSecondaryAntiProtonsPass);
1618   TH2D *gHistYPtSecondaryAntiProtonsReject = new TH2D("gHistYPtSecondaryAntiProtonsReject",
1619                                                   ";y;P_{T} [GeV/c]",
1620                                                   fNBinsY,fMinY,fMaxY,
1621                                                   fNBinsPt,fMinPt,fMaxPt);
1622   gHistYPtSecondaryAntiProtonsReject->SetStats(kTRUE);
1623   gHistYPtSecondaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
1624   fQA2DList->Add(gHistYPtSecondaryAntiProtonsReject);
1625
1626   /*gDirectory->cd("../");
1627   //protons
1628   TDirectory *dirProtons = gDirectory->mkdir("Protons");
1629   fGlobalQAList->Add(dirProtons); dirProtons->cd();*/
1630   
1631   //________________________________________________________________//
1632   /*TDirectory *dirProtonsPrimary = gDirectory->mkdir("Primaries");
1633   dirProtonsPrimary->cd();
1634   TDirectory *dirProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
1635   dirProtonsPrimaryAccepted->cd();*/
1636
1637   //Accepted primary protons
1638   TH1F *gPrimaryProtonsITSClustersPass = new TH1F("gPrimaryProtonsITSClustersPass",
1639                                             ";N_{clusters} (ITS);Entries",
1640                                             7,0,7);
1641   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsITSClustersPass);
1642   TH1F *gPrimaryProtonsChi2PerClusterITSPass = new TH1F("gPrimaryProtonsChi2PerClusterITSPass",
1643                                                   ";x^{2}/N_{clusters} (ITS);Entries",
1644                                                   100,0,4);
1645   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsChi2PerClusterITSPass);
1646   TH1F *gPrimaryProtonsTPCClustersPass = new TH1F("gPrimaryProtonsTPCClustersPass",
1647                                             ";N_{clusters} (TPC);Entries",
1648                                             100,0,200);
1649   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsTPCClustersPass);
1650   TH1F *gPrimaryProtonsChi2PerClusterTPCPass = new TH1F("gPrimaryProtonsChi2PerClusterTPCPass",
1651                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1652                                                   100,0,4);
1653   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsChi2PerClusterTPCPass);
1654   TH1F *gPrimaryProtonsExtCov11Pass = new TH1F("gPrimaryProtonsExtCov11Pass",
1655                                          ";#sigma_{y} [cm];Entries",
1656                                          100,0,4);
1657   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov11Pass);
1658   TH1F *gPrimaryProtonsExtCov22Pass = new TH1F("gPrimaryProtonsExtCov22Pass",
1659                                          ";#sigma_{z} [cm];Entries",
1660                                          100,0,4);
1661   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov22Pass);
1662   TH1F *gPrimaryProtonsExtCov33Pass = new TH1F("gPrimaryProtonsExtCov33Pass",
1663                                          ";#sigma_{sin(#phi)};Entries",
1664                                          100,0,4);
1665   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov33Pass);
1666   TH1F *gPrimaryProtonsExtCov44Pass = new TH1F("gPrimaryProtonsExtCov44Pass",
1667                                          ";#sigma_{tan(#lambda)};Entries",
1668                                          100,0,4);
1669   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov44Pass);
1670   TH1F *gPrimaryProtonsExtCov55Pass = new TH1F("gPrimaryProtonsExtCov55Pass",
1671                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1672                                          100,0,4);
1673   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsExtCov55Pass);
1674   TH1F *gPrimaryProtonsSigmaToVertexPass = new TH1F("gPrimaryProtonsSigmaToVertexPass",
1675                                              ";#sigma_{Vertex};Entries",
1676                                              100,0,10);
1677   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsSigmaToVertexPass);
1678   TH1F *gPrimaryProtonsSigmaToVertexTPCPass = new TH1F("gPrimaryProtonsSigmaToVertexTPCPass",
1679                                              ";#sigma_{Vertex};Entries",
1680                                              100,0,10);
1681   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsSigmaToVertexTPCPass);
1682   TH1F *gPrimaryProtonsDCAXYPass = new TH1F("gPrimaryProtonsDCAXYPass",
1683                                              ";DCA_{xy} [cm];Entries",
1684                                              100,0,20);
1685   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAXYPass);
1686   TH1F *gPrimaryProtonsDCAXYTPCPass = new TH1F("gPrimaryProtonsDCAXYTPCPass",
1687                                                ";DCA_{xy} [cm];Entries",
1688                                                100,0,20);
1689   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAXYTPCPass);
1690   TH1F *gPrimaryProtonsDCAZPass = new TH1F("gPrimaryProtonsDCAZPass",
1691                                            ";DCA_{z} [cm];Entries",
1692                                            100,0,20);
1693   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAZPass);
1694   TH1F *gPrimaryProtonsDCAZTPCPass = new TH1F("gPrimaryProtonsDCAZTPCPass",
1695                                               ";DCA_{z} [cm];Entries",
1696                                               100,0,20);
1697   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsDCAZTPCPass);
1698   TH1F *gPrimaryProtonsConstrainChi2Pass = new TH1F("gPrimaryProtonsConstrainChi2Pass",
1699                                                     ";Log_{10}(#chi^{2});Entries",
1700                                                     100,-10,10);
1701   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsConstrainChi2Pass);
1702   TH1F *gPrimaryProtonsITSRefitPass = new TH1F("gPrimaryProtonsITSRefitPass",
1703                                                "",10,-1,1);
1704   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsITSRefitPass);
1705   TH1F *gPrimaryProtonsTPCRefitPass = new TH1F("gPrimaryProtonsTPCRefitPass",
1706                                                "",10,-1,1);
1707   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsTPCRefitPass);
1708   TH1F *gPrimaryProtonsESDpidPass = new TH1F("gPrimaryProtonsESDpidPass",
1709                                              "",10,-1,1);
1710   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsESDpidPass);
1711   TH1F *gPrimaryProtonsTPCpidPass = new TH1F("gPrimaryProtonsTPCpidPass",
1712                                              "",10,-1,1);
1713   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsTPCpidPass);
1714   TH1F *gPrimaryProtonsPointOnITSLayer1Pass = new TH1F("gPrimaryProtonsPointOnITSLayer1Pass",
1715                                              "",10,-1,1);
1716   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer1Pass);
1717   TH1F *gPrimaryProtonsPointOnITSLayer2Pass = new TH1F("gPrimaryProtonsPointOnITSLayer2Pass",
1718                                              "",10,-1,1);
1719   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer2Pass);
1720   TH1F *gPrimaryProtonsPointOnITSLayer3Pass = new TH1F("gPrimaryProtonsPointOnITSLayer3Pass",
1721                                              "",10,-1,1);
1722   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer3Pass);
1723   TH1F *gPrimaryProtonsPointOnITSLayer4Pass = new TH1F("gPrimaryProtonsPointOnITSLayer4Pass",
1724                                              "",10,-1,1);
1725   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer4Pass);
1726   TH1F *gPrimaryProtonsPointOnITSLayer5Pass = new TH1F("gPrimaryProtonsPointOnITSLayer5Pass",
1727                                              "",10,-1,1);
1728   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer5Pass);
1729   TH1F *gPrimaryProtonsPointOnITSLayer6Pass = new TH1F("gPrimaryProtonsPointOnITSLayer6Pass",
1730                                              "",10,-1,1);
1731   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer6Pass);
1732
1733   //Rejected primary protons
1734   /*gDirectory->cd("../");
1735   TDirectory *dirProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
1736   dirProtonsPrimaryRejected->cd();*/
1737
1738   TH1F *gPrimaryProtonsITSClustersReject = new TH1F("gPrimaryProtonsITSClustersReject",
1739                                                     ";N_{clusters} (ITS);Entries",
1740                                                     7,0,7);
1741   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsITSClustersReject);
1742   TH1F *gPrimaryProtonsChi2PerClusterITSReject = new TH1F("gPrimaryProtonsChi2PerClusterITSReject",
1743                                                           ";x^{2}/N_{clusters} (ITS);Entries",
1744                                                           100,0,4);
1745   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsChi2PerClusterITSReject);
1746   TH1F *gPrimaryProtonsTPCClustersReject = new TH1F("gPrimaryProtonsTPCClustersReject",
1747                                             ";N_{clusters} (TPC);Entries",
1748                                             100,0,200);
1749   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsTPCClustersReject);
1750   TH1F *gPrimaryProtonsChi2PerClusterTPCReject = new TH1F("gPrimaryProtonsChi2PerClusterTPCReject",
1751                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1752                                                   100,0,4);
1753   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsChi2PerClusterTPCReject);
1754   TH1F *gPrimaryProtonsExtCov11Reject = new TH1F("gPrimaryProtonsExtCov11Reject",
1755                                          ";#sigma_{y} [cm];Entries",
1756                                          100,0,4);
1757   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov11Reject);
1758   TH1F *gPrimaryProtonsExtCov22Reject = new TH1F("gPrimaryProtonsExtCov22Reject",
1759                                          ";#sigma_{z} [cm];Entries",
1760                                          100,0,4);
1761   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov22Reject);
1762   TH1F *gPrimaryProtonsExtCov33Reject = new TH1F("gPrimaryProtonsExtCov33Reject",
1763                                          ";#sigma_{sin(#phi)};Entries",
1764                                          100,0,4);
1765   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov33Reject);
1766   TH1F *gPrimaryProtonsExtCov44Reject = new TH1F("gPrimaryProtonsExtCov44Reject",
1767                                          ";#sigma_{tan(#lambda)};Entries",
1768                                          100,0,4);
1769   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov44Reject);
1770   TH1F *gPrimaryProtonsExtCov55Reject = new TH1F("gPrimaryProtonsExtCov55Reject",
1771                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1772                                          100,0,4);
1773   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsExtCov55Reject);
1774   TH1F *gPrimaryProtonsSigmaToVertexReject = new TH1F("gPrimaryProtonsSigmaToVertexReject",
1775                                              ";#sigma_{Vertex};Entries",
1776                                              100,0,10);
1777   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsSigmaToVertexReject);
1778   TH1F *gPrimaryProtonsSigmaToVertexTPCReject = new TH1F("gPrimaryProtonsSigmaToVertexTPCReject",
1779                                              ";#sigma_{Vertex};Entries",
1780                                              100,0,10);
1781   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsSigmaToVertexTPCReject);
1782   TH1F *gPrimaryProtonsDCAXYReject = new TH1F("gPrimaryProtonsDCAXYReject",
1783                                               ";DCA_{xy} [cm];Entries",
1784                                               100,0,20);
1785   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAXYReject);
1786   TH1F *gPrimaryProtonsDCAXYTPCReject = new TH1F("gPrimaryProtonsDCAXYTPCReject",
1787                                                  ";DCA_{xy} [cm];Entries",
1788                                                  100,0,20);
1789   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAXYTPCReject);
1790   TH1F *gPrimaryProtonsDCAZReject = new TH1F("gPrimaryProtonsDCAZReject",
1791                                              ";DCA_{z} [cm];Entries",
1792                                              100,0,20);
1793   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAZReject);
1794   TH1F *gPrimaryProtonsDCAZTPCReject = new TH1F("gPrimaryProtonsDCAZTPCReject",
1795                                                 ";DCA_{z} [cm];Entries",
1796                                                 100,0,20);
1797   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsDCAZTPCReject);
1798   TH1F *gPrimaryProtonsConstrainChi2Reject = new TH1F("gPrimaryProtonsConstrainChi2Reject",
1799                                                     ";Log_{10}(#chi^{2});Entries",
1800                                                     100,-10,10);
1801   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsConstrainChi2Reject);
1802   TH1F *gPrimaryProtonsITSRefitReject = new TH1F("gPrimaryProtonsITSRefitReject",
1803                                                  "",10,-1,1);
1804   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsITSRefitReject);
1805   TH1F *gPrimaryProtonsTPCRefitReject = new TH1F("gPrimaryProtonsTPCRefitReject",
1806                                                  "",10,-1,1);
1807   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsTPCRefitReject);
1808   TH1F *gPrimaryProtonsESDpidReject = new TH1F("gPrimaryProtonsESDpidReject",
1809                                                "",10,-1,1);
1810   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsESDpidReject);
1811   TH1F *gPrimaryProtonsTPCpidReject = new TH1F("gPrimaryProtonsTPCpidReject",
1812                                                "",10,-1,1);
1813   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsTPCpidReject);
1814   TH1F *gPrimaryProtonsPointOnITSLayer1Reject = new TH1F("gPrimaryProtonsPointOnITSLayer1Reject",
1815                                              "",10,-1,1);
1816   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer1Reject);
1817   TH1F *gPrimaryProtonsPointOnITSLayer2Reject = new TH1F("gPrimaryProtonsPointOnITSLayer2Reject",
1818                                              "",10,-1,1);
1819   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer2Reject);
1820   TH1F *gPrimaryProtonsPointOnITSLayer3Reject = new TH1F("gPrimaryProtonsPointOnITSLayer3Reject",
1821                                              "",10,-1,1);
1822   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer3Reject);
1823   TH1F *gPrimaryProtonsPointOnITSLayer4Reject = new TH1F("gPrimaryProtonsPointOnITSLayer4Reject",
1824                                              "",10,-1,1);
1825   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer4Reject);
1826   TH1F *gPrimaryProtonsPointOnITSLayer5Reject = new TH1F("gPrimaryProtonsPointOnITSLayer5Reject",
1827                                              "",10,-1,1);
1828   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer5Reject);
1829   TH1F *gPrimaryProtonsPointOnITSLayer6Reject = new TH1F("gPrimaryProtonsPointOnITSLayer6Reject",
1830                                              "",10,-1,1);
1831   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer6Reject);
1832
1833   //________________________________________________________________//
1834   /*gDirectory->cd("../../");
1835
1836   TDirectory *dirProtonsSecondary = gDirectory->mkdir("Secondaries");
1837   dirProtonsSecondary->cd();
1838   TDirectory *dirProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
1839   dirProtonsSecondaryAccepted->cd();*/
1840
1841   //Accepted secondary protons
1842   TH1F *gSecondaryProtonsITSClustersPass = new TH1F("gSecondaryProtonsITSClustersPass",
1843                                                     ";N_{clusters} (ITS);Entries",
1844                                                     7,0,7);
1845   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsITSClustersPass);
1846   TH1F *gSecondaryProtonsChi2PerClusterITSPass = new TH1F("gSecondaryProtonsChi2PerClusterITSPass",
1847                                                           ";x^{2}/N_{clusters} (ITS);Entries",
1848                                                           100,0,4);
1849   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsChi2PerClusterITSPass);
1850   TH1F *gSecondaryProtonsTPCClustersPass = new TH1F("gSecondaryProtonsTPCClustersPass",
1851                                             ";N_{clusters} (TPC);Entries",
1852                                             100,0,200);
1853   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsTPCClustersPass);
1854   TH1F *gSecondaryProtonsChi2PerClusterTPCPass = new TH1F("gSecondaryProtonsChi2PerClusterTPCPass",
1855                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1856                                                   100,0,4);
1857   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsChi2PerClusterTPCPass);
1858   TH1F *gSecondaryProtonsExtCov11Pass = new TH1F("gSecondaryProtonsExtCov11Pass",
1859                                          ";#sigma_{y} [cm];Entries",
1860                                          100,0,4);
1861   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov11Pass);
1862   TH1F *gSecondaryProtonsExtCov22Pass = new TH1F("gSecondaryProtonsExtCov22Pass",
1863                                          ";#sigma_{z} [cm];Entries",
1864                                          100,0,4);
1865   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov22Pass);
1866   TH1F *gSecondaryProtonsExtCov33Pass = new TH1F("gSecondaryProtonsExtCov33Pass",
1867                                          ";#sigma_{sin(#phi)};Entries",
1868                                          100,0,4);
1869   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov33Pass);
1870   TH1F *gSecondaryProtonsExtCov44Pass = new TH1F("gSecondaryProtonsExtCov44Pass",
1871                                          ";#sigma_{tan(#lambda)};Entries",
1872                                          100,0,4);
1873   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov44Pass);
1874   TH1F *gSecondaryProtonsExtCov55Pass = new TH1F("gSecondaryProtonsExtCov55Pass",
1875                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1876                                          100,0,4);
1877   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsExtCov55Pass);
1878   TH1F *gSecondaryProtonsSigmaToVertexPass = new TH1F("gSecondaryProtonsSigmaToVertexPass",
1879                                              ";#sigma_{Vertex};Entries",
1880                                              100,0,10);
1881   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsSigmaToVertexPass);
1882   TH1F *gSecondaryProtonsSigmaToVertexTPCPass = new TH1F("gSecondaryProtonsSigmaToVertexTPCPass",
1883                                              ";#sigma_{Vertex};Entries",
1884                                              100,0,10);
1885   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsSigmaToVertexTPCPass);
1886   TH1F *gSecondaryProtonsDCAXYPass = new TH1F("gSecondaryProtonsDCAXYPass",
1887                                               ";DCA_{xy} [cm];Entries",
1888                                               100,0,20);
1889   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAXYPass);
1890   TH1F *gSecondaryProtonsDCAXYTPCPass = new TH1F("gSecondaryProtonsDCAXYTPCPass",
1891                                                  ";DCA_{xy} [cm];Entries",
1892                                                  100,0,20);
1893   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAXYTPCPass);
1894   TH1F *gSecondaryProtonsDCAZPass = new TH1F("gSecondaryProtonsDCAZPass",
1895                                              ";DCA_{z} [cm];Entries",
1896                                              100,0,20);
1897   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAZPass);
1898   TH1F *gSecondaryProtonsDCAZTPCPass = new TH1F("gSecondaryProtonsDCAZTPCPass",
1899                                                 ";DCA_{z} [cm];Entries",
1900                                                 100,0,20);
1901   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsDCAZTPCPass);
1902   TH1F *gSecondaryProtonsConstrainChi2Pass = new TH1F("gSecondaryProtonsConstrainChi2Pass",
1903                                                     ";Log_{10}(#chi^{2});Entries",
1904                                                     100,-10,10);
1905   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsConstrainChi2Pass);
1906   TH1F *gSecondaryProtonsITSRefitPass = new TH1F("gSecondaryProtonsITSRefitPass",
1907                                                  "",10,-1,1);
1908   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsITSRefitPass);
1909   TH1F *gSecondaryProtonsTPCRefitPass = new TH1F("gSecondaryProtonsTPCRefitPass",
1910                                                  "",10,-1,1);
1911   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsTPCRefitPass);
1912   TH1F *gSecondaryProtonsESDpidPass = new TH1F("gSecondaryProtonsESDpidPass",
1913                                                "",10,-1,1);
1914   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsESDpidPass);
1915   TH1F *gSecondaryProtonsTPCpidPass = new TH1F("gSecondaryProtonsTPCpidPass",
1916                                                "",10,-1,1);
1917   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsTPCpidPass);
1918   TH1F *gSecondaryProtonsPointOnITSLayer1Pass = new TH1F("gSecondaryProtonsPointOnITSLayer1Pass",
1919                                                          "",10,-1,1);
1920   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer1Pass);
1921   TH1F *gSecondaryProtonsPointOnITSLayer2Pass = new TH1F("gSecondaryProtonsPointOnITSLayer2Pass",
1922                                                          "",10,-1,1);
1923   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer2Pass);
1924   TH1F *gSecondaryProtonsPointOnITSLayer3Pass = new TH1F("gSecondaryProtonsPointOnITSLayer3Pass",
1925                                                          "",10,-1,1);
1926   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer3Pass);
1927   TH1F *gSecondaryProtonsPointOnITSLayer4Pass = new TH1F("gSecondaryProtonsPointOnITSLayer4Pass",
1928                                                          "",10,-1,1);
1929   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer4Pass);
1930   TH1F *gSecondaryProtonsPointOnITSLayer5Pass = new TH1F("gSecondaryProtonsPointOnITSLayer5Pass",
1931                                                          "",10,-1,1);
1932   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer5Pass);
1933   TH1F *gSecondaryProtonsPointOnITSLayer6Pass = new TH1F("gSecondaryProtonsPointOnITSLayer6Pass",
1934                                                          "",10,-1,1);
1935   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer6Pass);
1936
1937   //Rejected secondary protons
1938   /*gDirectory->cd("../");
1939   TDirectory *dirProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
1940   dirProtonsSecondaryRejected->cd();*/
1941
1942   TH1F *gSecondaryProtonsITSClustersReject = new TH1F("gSecondaryProtonsITSClustersReject",
1943                                                       ";N_{clusters} (ITS);Entries",
1944                                                       7,0,7);
1945   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsITSClustersReject);
1946   TH1F *gSecondaryProtonsChi2PerClusterITSReject = new TH1F("gSecondaryProtonsChi2PerClusterITSReject",
1947                                                             ";x^{2}/N_{clusters} (ITS);Entries",
1948                                                             100,0,4);
1949   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsChi2PerClusterITSReject);
1950   TH1F *gSecondaryProtonsTPCClustersReject = new TH1F("gSecondaryProtonsTPCClustersReject",
1951                                             ";N_{clusters} (TPC);Entries",
1952                                             100,0,200);
1953   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsTPCClustersReject);
1954   TH1F *gSecondaryProtonsChi2PerClusterTPCReject = new TH1F("gSecondaryProtonsChi2PerClusterTPCReject",
1955                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1956                                                   100,0,4);
1957   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsChi2PerClusterTPCReject);
1958   TH1F *gSecondaryProtonsExtCov11Reject = new TH1F("gSecondaryProtonsExtCov11Reject",
1959                                          ";#sigma_{y} [cm];Entries",
1960                                          100,0,4);
1961   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov11Reject);
1962   TH1F *gSecondaryProtonsExtCov22Reject = new TH1F("gSecondaryProtonsExtCov22Reject",
1963                                          ";#sigma_{z} [cm];Entries",
1964                                          100,0,4);
1965   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov22Reject);
1966   TH1F *gSecondaryProtonsExtCov33Reject = new TH1F("gSecondaryProtonsExtCov33Reject",
1967                                          ";#sigma_{sin(#phi)};Entries",
1968                                          100,0,4);
1969   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov33Reject);
1970   TH1F *gSecondaryProtonsExtCov44Reject = new TH1F("gSecondaryProtonsExtCov44Reject",
1971                                          ";#sigma_{tan(#lambda)};Entries",
1972                                          100,0,4);
1973   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov44Reject);
1974   TH1F *gSecondaryProtonsExtCov55Reject = new TH1F("gSecondaryProtonsExtCov55Reject",
1975                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1976                                          100,0,4);
1977   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsExtCov55Reject);
1978   TH1F *gSecondaryProtonsSigmaToVertexReject = new TH1F("gSecondaryProtonsSigmaToVertexReject",
1979                                              ";#sigma_{Vertex};Entries",
1980                                              100,0,10);
1981   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsSigmaToVertexReject);
1982   TH1F *gSecondaryProtonsSigmaToVertexTPCReject = new TH1F("gSecondaryProtonsSigmaToVertexTPCReject",
1983                                                            ";#sigma_{Vertex};Entries",
1984                                                            100,0,10);
1985   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsSigmaToVertexTPCReject);
1986   TH1F *gSecondaryProtonsDCAXYReject = new TH1F("gSecondaryProtonsDCAXYReject",
1987                                                 ";DCA_{xy} [cm];Entries",
1988                                                 100,0,20);
1989   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAXYReject);
1990   TH1F *gSecondaryProtonsDCAXYTPCReject = new TH1F("gSecondaryProtonsDCAXYTPCReject",
1991                                                    ";DCA_{xy} [cm];Entries",
1992                                                    100,0,20);
1993   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAXYTPCReject);
1994   TH1F *gSecondaryProtonsDCAZReject = new TH1F("gSecondaryProtonsDCAZReject",
1995                                                ";DCA_{z} [cm];Entries",
1996                                                100,0,20);
1997   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAZReject);
1998   TH1F *gSecondaryProtonsDCAZTPCReject = new TH1F("gSecondaryProtonsDCAZTPCReject",
1999                                                   ";DCA_{z} [cm];Entries",
2000                                                   100,0,20);
2001   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsDCAZTPCReject);
2002   TH1F *gSecondaryProtonsConstrainChi2Reject = new TH1F("gSecondaryProtonsConstrainChi2Reject",
2003                                                         ";Log_{10}(#chi^{2});Entries",
2004                                                         100,-10,10);
2005   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsConstrainChi2Reject);
2006   TH1F *gSecondaryProtonsITSRefitReject = new TH1F("gSecondaryProtonsITSRefitReject",
2007                                                    "",10,-1,1);
2008   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsITSRefitReject);
2009   TH1F *gSecondaryProtonsTPCRefitReject = new TH1F("gSecondaryProtonsTPCRefitReject",
2010                                                    "",10,-1,1);
2011   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsTPCRefitReject);
2012   TH1F *gSecondaryProtonsESDpidReject = new TH1F("gSecondaryProtonsESDpidReject",
2013                                                  "",10,-1,1);
2014   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsESDpidReject);
2015   TH1F *gSecondaryProtonsTPCpidReject = new TH1F("gSecondaryProtonsTPCpidReject",
2016                                                  "",10,-1,1);
2017   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsTPCpidReject);
2018   TH1F *gSecondaryProtonsPointOnITSLayer1Reject = new TH1F("gSecondaryProtonsPointOnITSLayer1Reject",
2019                                                            "",10,-1,1);
2020   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer1Reject);
2021   TH1F *gSecondaryProtonsPointOnITSLayer2Reject = new TH1F("gSecondaryProtonsPointOnITSLayer2Reject",
2022                                                            "",10,-1,1);
2023   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer2Reject);
2024   TH1F *gSecondaryProtonsPointOnITSLayer3Reject = new TH1F("gSecondaryProtonsPointOnITSLayer3Reject",
2025                                                            "",10,-1,1);
2026   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer3Reject);
2027   TH1F *gSecondaryProtonsPointOnITSLayer4Reject = new TH1F("gSecondaryProtonsPointOnITSLayer4Reject",
2028                                                            "",10,-1,1);
2029   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer4Reject);
2030   TH1F *gSecondaryProtonsPointOnITSLayer5Reject = new TH1F("gSecondaryProtonsPointOnITSLayer5Reject",
2031                                                            "",10,-1,1);
2032   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer5Reject);
2033   TH1F *gSecondaryProtonsPointOnITSLayer6Reject = new TH1F("gSecondaryProtonsPointOnITSLayer6Reject",
2034                                                            "",10,-1,1);
2035   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer6Reject);
2036   
2037
2038   /*gDirectory->cd("../../../");
2039
2040   //antiprotons
2041   TDirectory *dirAntiProtons = gDirectory->mkdir("AntiProtons");
2042   fGlobalQAList->Add(dirAntiProtons); dirAntiProtons->cd();*/
2043   
2044   //________________________________________________________________//
2045   /*TDirectory *dirAntiProtonsPrimary = gDirectory->mkdir("Primaries");
2046   dirAntiProtonsPrimary->cd();
2047   TDirectory *dirAntiProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
2048   dirAntiProtonsPrimaryAccepted->cd();*/
2049   
2050   //Accepted primary antiprotons
2051   TH1F *gPrimaryAntiProtonsITSClustersPass = new TH1F("gPrimaryAntiProtonsITSClustersPass",
2052                                                       ";N_{clusters} (ITS);Entries",
2053                                                       7,0,7);
2054   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsITSClustersPass);
2055   TH1F *gPrimaryAntiProtonsChi2PerClusterITSPass = new TH1F("gPrimaryAntiProtonsChi2PerClusterITSPass",
2056                                                             ";x^{2}/N_{clusters} (ITS);Entries",
2057                                                             100,0,4);
2058   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsChi2PerClusterITSPass);
2059   TH1F *gPrimaryAntiProtonsTPCClustersPass = new TH1F("gPrimaryAntiProtonsTPCClustersPass",
2060                                                       ";N_{clusters} (TPC);Entries",
2061                                                       100,0,200);
2062   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsTPCClustersPass);
2063   TH1F *gPrimaryAntiProtonsChi2PerClusterTPCPass = new TH1F("gPrimaryAntiProtonsChi2PerClusterTPCPass",
2064                                                             ";x^{2}/N_{clusters} (TPC);Entries",
2065                                                             100,0,4);
2066   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsChi2PerClusterTPCPass);
2067   TH1F *gPrimaryAntiProtonsExtCov11Pass = new TH1F("gPrimaryAntiProtonsExtCov11Pass",
2068                                                    ";#sigma_{y} [cm];Entries",
2069                                                    100,0,4);
2070   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov11Pass);
2071   TH1F *gPrimaryAntiProtonsExtCov22Pass = new TH1F("gPrimaryAntiProtonsExtCov22Pass",
2072                                                    ";#sigma_{z} [cm];Entries",
2073                                                    100,0,4);
2074   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov22Pass);
2075   TH1F *gPrimaryAntiProtonsExtCov33Pass = new TH1F("gPrimaryAntiProtonsExtCov33Pass",
2076                                                    ";#sigma_{sin(#phi)};Entries",
2077                                                    100,0,4);
2078   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov33Pass);
2079   TH1F *gPrimaryAntiProtonsExtCov44Pass = new TH1F("gPrimaryAntiProtonsExtCov44Pass",
2080                                                    ";#sigma_{tan(#lambda)};Entries",
2081                                                    100,0,4);
2082   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov44Pass);
2083   TH1F *gPrimaryAntiProtonsExtCov55Pass = new TH1F("gPrimaryAntiProtonsExtCov55Pass",
2084                                                    ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2085                                                    100,0,4);
2086   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsExtCov55Pass);
2087   TH1F *gPrimaryAntiProtonsSigmaToVertexPass = new TH1F("gPrimaryAntiProtonsSigmaToVertexPass",
2088                                                         ";#sigma_{Vertex};Entries",
2089                                                         100,0,10);
2090   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsSigmaToVertexPass);
2091   TH1F *gPrimaryAntiProtonsSigmaToVertexTPCPass = new TH1F("gPrimaryAntiProtonsSigmaToVertexTPCPass",
2092                                                            ";#sigma_{Vertex};Entries",
2093                                                            100,0,10);
2094   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsSigmaToVertexTPCPass);
2095   TH1F *gPrimaryAntiProtonsDCAXYPass = new TH1F("gPrimaryAntiProtonsDCAXYPass",
2096                                                 ";DCA_{xy} [cm];Entries",
2097                                                 100,0,20);
2098   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAXYPass);
2099   TH1F *gPrimaryAntiProtonsDCAXYTPCPass = new TH1F("gPrimaryAntiProtonsDCAXYTPCPass",
2100                                                    ";DCA_{xy} [cm];Entries",
2101                                                    100,0,20);
2102   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAXYTPCPass);
2103   TH1F *gPrimaryAntiProtonsDCAZPass = new TH1F("gPrimaryAntiProtonsDCAZPass",
2104                                                ";DCA_{z} [cm];Entries",
2105                                                100,0,20);
2106   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAZPass);
2107   TH1F *gPrimaryAntiProtonsDCAZTPCPass = new TH1F("gPrimaryAntiProtonsDCAZTPCPass",
2108                                                   ";DCA_{z} [cm];Entries",
2109                                                   100,0,20);
2110   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsDCAZTPCPass);
2111   TH1F *gPrimaryAntiProtonsConstrainChi2Pass = new TH1F("gPrimaryAntiProtonsConstrainChi2Pass",
2112                                                         ";Log_{10}(#chi^{2});Entries",
2113                                                         100,-10,10);
2114   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsConstrainChi2Pass);
2115   TH1F *gPrimaryAntiProtonsITSRefitPass = new TH1F("gPrimaryAntiProtonsITSRefitPass",
2116                                                    "",10,-1,1);
2117   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsITSRefitPass);
2118   TH1F *gPrimaryAntiProtonsTPCRefitPass = new TH1F("gPrimaryAntiProtonsTPCRefitPass",
2119                                                    "",10,-1,1);
2120   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsTPCRefitPass);
2121   TH1F *gPrimaryAntiProtonsESDpidPass = new TH1F("gPrimaryAntiProtonsESDpidPass",
2122                                                  "",10,-1,1);
2123   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsESDpidPass);
2124   TH1F *gPrimaryAntiProtonsTPCpidPass = new TH1F("gPrimaryAntiProtonsTPCpidPass",
2125                                                  "",10,-1,1);
2126   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsTPCpidPass);
2127   TH1F *gPrimaryAntiProtonsPointOnITSLayer1Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer1Pass",
2128                                                            "",10,-1,1);
2129   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer1Pass);
2130   TH1F *gPrimaryAntiProtonsPointOnITSLayer2Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer2Pass",
2131                                                            "",10,-1,1);
2132   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer2Pass);
2133   TH1F *gPrimaryAntiProtonsPointOnITSLayer3Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer3Pass",
2134                                                            "",10,-1,1);
2135   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer3Pass);
2136   TH1F *gPrimaryAntiProtonsPointOnITSLayer4Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer4Pass",
2137                                                            "",10,-1,1);
2138   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer4Pass);
2139   TH1F *gPrimaryAntiProtonsPointOnITSLayer5Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer5Pass",
2140                                                            "",10,-1,1);
2141   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer5Pass);
2142   TH1F *gPrimaryAntiProtonsPointOnITSLayer6Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer6Pass",
2143                                                            "",10,-1,1);
2144   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer6Pass);
2145   
2146   //Rejected primary antiprotons
2147   /*gDirectory->cd("../");
2148   TDirectory *dirAntiProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
2149   dirAntiProtonsPrimaryRejected->cd();*/
2150   
2151   TH1F *gPrimaryAntiProtonsITSClustersReject = new TH1F("gPrimaryAntiProtonsITSClustersReject",
2152                                                         ";N_{clusters} (ITS);Entries",
2153                                                         7,0,7);
2154   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsITSClustersReject);
2155   TH1F *gPrimaryAntiProtonsChi2PerClusterITSReject = new TH1F("gPrimaryAntiProtonsChi2PerClusterITSReject",
2156                                                               ";x^{2}/N_{clusters} (ITS);Entries",
2157                                                               100,0,4);
2158   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsChi2PerClusterITSReject);
2159   TH1F *gPrimaryAntiProtonsTPCClustersReject = new TH1F("gPrimaryAntiProtonsTPCClustersReject",
2160                                                         ";N_{clusters} (TPC);Entries",
2161                                                         100,0,200);
2162   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsTPCClustersReject);
2163   TH1F *gPrimaryAntiProtonsChi2PerClusterTPCReject = new TH1F("gPrimaryAntiProtonsChi2PerClusterTPCReject",
2164                                                               ";x^{2}/N_{clusters} (TPC);Entries",
2165                                                               100,0,4);
2166   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsChi2PerClusterTPCReject);
2167   TH1F *gPrimaryAntiProtonsExtCov11Reject = new TH1F("gPrimaryAntiProtonsExtCov11Reject",
2168                                                      ";#sigma_{y} [cm];Entries",
2169                                                      100,0,4);
2170   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov11Reject);
2171   TH1F *gPrimaryAntiProtonsExtCov22Reject = new TH1F("gPrimaryAntiProtonsExtCov22Reject",
2172                                                      ";#sigma_{z} [cm];Entries",
2173                                                      100,0,4);
2174   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov22Reject);
2175   TH1F *gPrimaryAntiProtonsExtCov33Reject = new TH1F("gPrimaryAntiProtonsExtCov33Reject",
2176                                                      ";#sigma_{sin(#phi)};Entries",
2177                                                      100,0,4);
2178   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov33Reject);
2179   TH1F *gPrimaryAntiProtonsExtCov44Reject = new TH1F("gPrimaryAntiProtonsExtCov44Reject",
2180                                                      ";#sigma_{tan(#lambda)};Entries",
2181                                                      100,0,4);
2182   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov44Reject);
2183   TH1F *gPrimaryAntiProtonsExtCov55Reject = new TH1F("gPrimaryAntiProtonsExtCov55Reject",
2184                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2185                                                      100,0,4);
2186   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsExtCov55Reject);
2187   TH1F *gPrimaryAntiProtonsSigmaToVertexReject = new TH1F("gPrimaryAntiProtonsSigmaToVertexReject",
2188                                                           ";#sigma_{Vertex};Entries",
2189                                                           100,0,10);
2190   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsSigmaToVertexReject);
2191   TH1F *gPrimaryAntiProtonsSigmaToVertexTPCReject = new TH1F("gPrimaryAntiProtonsSigmaToVertexTPCReject",
2192                                                              ";#sigma_{Vertex};Entries",
2193                                                              100,0,10);
2194   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsSigmaToVertexTPCReject);
2195   TH1F *gPrimaryAntiProtonsDCAXYReject = new TH1F("gPrimaryAntiProtonsDCAXYReject",
2196                                                   ";DCA_{xy} [cm];Entries",
2197                                                   100,0,20);
2198   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAXYReject);
2199   TH1F *gPrimaryAntiProtonsDCAXYTPCReject = new TH1F("gPrimaryAntiProtonsDCAXYTPCReject",
2200                                                      ";DCA_{xy} [cm];Entries",
2201                                                      100,0,20);
2202   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAXYTPCReject);
2203   TH1F *gPrimaryAntiProtonsDCAZReject = new TH1F("gPrimaryAntiProtonsDCAZReject",
2204                                                  ";DCA_{z} [cm];Entries",
2205                                                  100,0,20);
2206   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAZReject);
2207   TH1F *gPrimaryAntiProtonsDCAZTPCReject = new TH1F("gPrimaryAntiProtonsDCAZTPCReject",
2208                                                     ";DCA_{z} [cm];Entries",
2209                                                     100,0,20);
2210   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsDCAZTPCReject);
2211   TH1F *gPrimaryAntiProtonsConstrainChi2Reject = new TH1F("gPrimaryAntiProtonsConstrainChi2Reject",
2212                                                           ";Log_{10}(#chi^{2});Entries",
2213                                                           100,-10,10);
2214   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsConstrainChi2Reject);
2215   TH1F *gPrimaryAntiProtonsITSRefitReject = new TH1F("gPrimaryAntiProtonsITSRefitReject",
2216                                                      "",10,-1,1);
2217   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsITSRefitReject);
2218   TH1F *gPrimaryAntiProtonsTPCRefitReject = new TH1F("gPrimaryAntiProtonsTPCRefitReject",
2219                                                      "",10,-1,1);
2220   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsTPCRefitReject);
2221   TH1F *gPrimaryAntiProtonsESDpidReject = new TH1F("gPrimaryAntiProtonsESDpidReject",
2222                                                    "",10,-1,1);
2223   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsESDpidReject);
2224   TH1F *gPrimaryAntiProtonsTPCpidReject = new TH1F("gPrimaryAntiProtonsTPCpidReject",
2225                                                    "",10,-1,1);
2226   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsTPCpidReject);
2227   TH1F *gPrimaryAntiProtonsPointOnITSLayer1Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer1Reject",
2228                                                              "",10,-1,1);
2229   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer1Reject);
2230   TH1F *gPrimaryAntiProtonsPointOnITSLayer2Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer2Reject",
2231                                                              "",10,-1,1);
2232   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer2Reject);
2233   TH1F *gPrimaryAntiProtonsPointOnITSLayer3Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer3Reject",
2234                                                              "",10,-1,1);
2235   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer3Reject);
2236   TH1F *gPrimaryAntiProtonsPointOnITSLayer4Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer4Reject",
2237                                                              "",10,-1,1);
2238   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer4Reject);
2239   TH1F *gPrimaryAntiProtonsPointOnITSLayer5Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer5Reject",
2240                                                              "",10,-1,1);
2241   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer5Reject);
2242   TH1F *gPrimaryAntiProtonsPointOnITSLayer6Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer6Reject",
2243                                                              "",10,-1,1);
2244   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer6Reject);
2245   
2246   //________________________________________________________________//
2247   /*gDirectory->cd("../../");
2248
2249   TDirectory *dirAntiProtonsSecondary = gDirectory->mkdir("Secondaries");
2250   dirAntiProtonsSecondary->cd();
2251   TDirectory *dirAntiProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
2252   dirAntiProtonsSecondaryAccepted->cd();*/
2253
2254   //Accepted secondary antiprotons
2255   TH1F *gSecondaryAntiProtonsITSClustersPass = new TH1F("gSecondaryAntiProtonsITSClustersPass",
2256                                                         ";N_{clusters} (ITS);Entries",
2257                                                         7,0,7);
2258   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsITSClustersPass);
2259   TH1F *gSecondaryAntiProtonsChi2PerClusterITSPass = new TH1F("gSecondaryAntiProtonsChi2PerClusterITSPass",
2260                                                               ";x^{2}/N_{clusters} (ITS);Entries",
2261                                                               100,0,4);
2262   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsChi2PerClusterITSPass);
2263   TH1F *gSecondaryAntiProtonsTPCClustersPass = new TH1F("gSecondaryAntiProtonsTPCClustersPass",
2264                                                         ";N_{clusters} (TPC);Entries",
2265                                                         100,0,200);
2266   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsTPCClustersPass);
2267   TH1F *gSecondaryAntiProtonsChi2PerClusterTPCPass = new TH1F("gSecondaryAntiProtonsChi2PerClusterTPCPass",
2268                                                               ";x^{2}/N_{clusters} (TPC);Entries",
2269                                                               100,0,4);
2270   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsChi2PerClusterTPCPass);
2271   TH1F *gSecondaryAntiProtonsExtCov11Pass = new TH1F("gSecondaryAntiProtonsExtCov11Pass",
2272                                                      ";#sigma_{y} [cm];Entries",
2273                                                      100,0,4);
2274   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov11Pass);
2275   TH1F *gSecondaryAntiProtonsExtCov22Pass = new TH1F("gSecondaryAntiProtonsExtCov22Pass",
2276                                                      ";#sigma_{z} [cm];Entries",
2277                                                      100,0,4);
2278   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov22Pass);
2279   TH1F *gSecondaryAntiProtonsExtCov33Pass = new TH1F("gSecondaryAntiProtonsExtCov33Pass",
2280                                                      ";#sigma_{sin(#phi)};Entries",
2281                                                      100,0,4);
2282   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov33Pass);
2283   TH1F *gSecondaryAntiProtonsExtCov44Pass = new TH1F("gSecondaryAntiProtonsExtCov44Pass",
2284                                                      ";#sigma_{tan(#lambda)};Entries",
2285                                                      100,0,4);
2286   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov44Pass);
2287   TH1F *gSecondaryAntiProtonsExtCov55Pass = new TH1F("gSecondaryAntiProtonsExtCov55Pass",
2288                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2289                                                      100,0,4);
2290   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsExtCov55Pass);
2291   TH1F *gSecondaryAntiProtonsSigmaToVertexPass = new TH1F("gSecondaryAntiProtonsSigmaToVertexPass",
2292                                                           ";#sigma_{Vertex};Entries",
2293                                                           100,0,10);
2294   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsSigmaToVertexPass);
2295   TH1F *gSecondaryAntiProtonsSigmaToVertexTPCPass = new TH1F("gSecondaryAntiProtonsSigmaToVertexTPCPass",
2296                                                              ";#sigma_{Vertex};Entries",
2297                                                              100,0,10);
2298   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsSigmaToVertexTPCPass);
2299   TH1F *gSecondaryAntiProtonsDCAXYPass = new TH1F("gSecondaryAntiProtonsDCAXYPass",
2300                                                   ";DCA_{xy} [cm];Entries",
2301                                                   100,0,20);
2302   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAXYPass);
2303   TH1F *gSecondaryAntiProtonsDCAXYTPCPass = new TH1F("gSecondaryAntiProtonsDCAXYTPCPass",
2304                                                      ";DCA_{xy} [cm];Entries",
2305                                                      100,0,20);
2306   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAXYTPCPass);
2307   TH1F *gSecondaryAntiProtonsDCAZPass = new TH1F("gSecondaryAntiProtonsDCAZPass",
2308                                                  ";DCA_{z} [cm];Entries",
2309                                                  100,0,20);
2310   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAZPass);
2311   TH1F *gSecondaryAntiProtonsDCAZTPCPass = new TH1F("gSecondaryAntiProtonsDCAZTPCPass",
2312                                                     ";DCA_{z} [cm];Entries",
2313                                                     100,0,20);
2314   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsDCAZTPCPass);
2315   TH1F *gSecondaryAntiProtonsConstrainChi2Pass = new TH1F("gSecondaryAntiProtonsConstrainChi2Pass",
2316                                                           ";Log_{10}(#chi^{2});Entries",
2317                                                           100,-10,10);
2318   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsConstrainChi2Pass);
2319   TH1F *gSecondaryAntiProtonsITSRefitPass = new TH1F("gSecondaryAntiProtonsITSRefitPass",
2320                                                      "",10,-1,1);
2321   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsITSRefitPass);
2322   TH1F *gSecondaryAntiProtonsTPCRefitPass = new TH1F("gSecondaryAntiProtonsTPCRefitPass",
2323                                                      "",10,-1,1);
2324   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsTPCRefitPass);
2325   TH1F *gSecondaryAntiProtonsESDpidPass = new TH1F("gSecondaryAntiProtonsESDpidPass",
2326                                                    "",10,-1,1);
2327   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsESDpidPass);
2328   TH1F *gSecondaryAntiProtonsTPCpidPass = new TH1F("gSecondaryAntiProtonsTPCpidPass",
2329                                                    "",10,-1,1);
2330   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsTPCpidPass);
2331   TH1F *gSecondaryAntiProtonsPointOnITSLayer1Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer1Pass",
2332                                                              "",10,-1,1);
2333   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer1Pass);
2334   TH1F *gSecondaryAntiProtonsPointOnITSLayer2Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer2Pass",
2335                                                              "",10,-1,1);
2336   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer2Pass);
2337   TH1F *gSecondaryAntiProtonsPointOnITSLayer3Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer3Pass",
2338                                                              "",10,-1,1);
2339   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer3Pass);
2340   TH1F *gSecondaryAntiProtonsPointOnITSLayer4Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer4Pass",
2341                                                              "",10,-1,1);
2342   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer4Pass);
2343   TH1F *gSecondaryAntiProtonsPointOnITSLayer5Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer5Pass",
2344                                                              "",10,-1,1);
2345   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer5Pass);
2346   TH1F *gSecondaryAntiProtonsPointOnITSLayer6Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer6Pass",
2347                                                              "",10,-1,1);
2348   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer6Pass);
2349   
2350   //Rejected secondary antiprotons
2351   /*gDirectory->cd("../");
2352   TDirectory *dirAntiProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
2353   dirAntiProtonsSecondaryRejected->cd();*/
2354
2355   TH1F *gSecondaryAntiProtonsITSClustersReject = new TH1F("gSecondaryAntiProtonsITSClustersReject",
2356                                                           ";N_{clusters} (ITS);Entries",
2357                                                           7,0,7);
2358   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsITSClustersReject);
2359   TH1F *gSecondaryAntiProtonsChi2PerClusterITSReject = new TH1F("gSecondaryAntiProtonsChi2PerClusterITSReject",
2360                                                                 ";x^{2}/N_{clusters} (ITS);Entries",
2361                                                                 100,0,4);
2362   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsChi2PerClusterITSReject);
2363   TH1F *gSecondaryAntiProtonsTPCClustersReject = new TH1F("gSecondaryAntiProtonsTPCClustersReject",
2364                                                           ";N_{clusters} (TPC);Entries",
2365                                                           100,0,200);
2366   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsTPCClustersReject);
2367   TH1F *gSecondaryAntiProtonsChi2PerClusterTPCReject = new TH1F("gSecondaryAntiProtonsChi2PerClusterTPCReject",
2368                                                                 ";x^{2}/N_{clusters} (TPC);Entries",
2369                                                                 100,0,4);
2370   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsChi2PerClusterTPCReject);
2371   TH1F *gSecondaryAntiProtonsExtCov11Reject = new TH1F("gSecondaryAntiProtonsExtCov11Reject",
2372                                                        ";#sigma_{y} [cm];Entries",
2373                                                        100,0,4);
2374   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov11Reject);
2375   TH1F *gSecondaryAntiProtonsExtCov22Reject = new TH1F("gSecondaryAntiProtonsExtCov22Reject",
2376                                                        ";#sigma_{z} [cm];Entries",
2377                                                        100,0,4);
2378   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov22Reject);
2379   TH1F *gSecondaryAntiProtonsExtCov33Reject = new TH1F("gSecondaryAntiProtonsExtCov33Reject",
2380                                                        ";#sigma_{sin(#phi)};Entries",
2381                                                        100,0,4);
2382   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov33Reject);
2383   TH1F *gSecondaryAntiProtonsExtCov44Reject = new TH1F("gSecondaryAntiProtonsExtCov44Reject",
2384                                                        ";#sigma_{tan(#lambda)};Entries",
2385                                                        100,0,4);
2386   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov44Reject);
2387   TH1F *gSecondaryAntiProtonsExtCov55Reject = new TH1F("gSecondaryAntiProtonsExtCov55Reject",
2388                                                        ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
2389                                                        100,0,4);
2390   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsExtCov55Reject);
2391   TH1F *gSecondaryAntiProtonsSigmaToVertexReject = new TH1F("gSecondaryAntiProtonsSigmaToVertexReject",
2392                                                             ";#sigma_{Vertex};Entries",
2393                                                             100,0,10);
2394   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsSigmaToVertexReject);
2395   TH1F *gSecondaryAntiProtonsSigmaToVertexTPCReject = new TH1F("gSecondaryAntiProtonsSigmaToVertexTPCReject",
2396                                                                ";#sigma_{Vertex};Entries",
2397                                                                100,0,10);
2398   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsSigmaToVertexTPCReject);
2399   TH1F *gSecondaryAntiProtonsDCAXYReject = new TH1F("gSecondaryAntiProtonsDCAXYReject",
2400                                                     ";DCA_{xy} [cm];Entries",
2401                                                     100,0,20);
2402   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAXYReject);
2403   TH1F *gSecondaryAntiProtonsDCAXYTPCReject = new TH1F("gSecondaryAntiProtonsDCAXYTPCReject",
2404                                                        ";DCA_{xy} [cm];Entries",
2405                                                        100,0,20);
2406   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAXYTPCReject);
2407   TH1F *gSecondaryAntiProtonsDCAZReject = new TH1F("gSecondaryAntiProtonsDCAZReject",
2408                                                    ";DCA_{z} [cm];Entries",
2409                                                    100,0,20);
2410   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAZReject);
2411   TH1F *gSecondaryAntiProtonsDCAZTPCReject = new TH1F("gSecondaryAntiProtonsDCAZTPCReject",
2412                                                       ";DCA_{z} [cm];Entries",
2413                                                       100,0,20);
2414   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsDCAZTPCReject);
2415   TH1F *gSecondaryAntiProtonsConstrainChi2Reject = new TH1F("gSecondaryAntiProtonsConstrainChi2Reject",
2416                                                             ";Log_{10}(#chi^{2});Entries",
2417                                                             100,-10,10);
2418   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsConstrainChi2Reject);
2419   TH1F *gSecondaryAntiProtonsITSRefitReject = new TH1F("gSecondaryAntiProtonsITSRefitReject",
2420                                                        "",10,-1,1);
2421   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsITSRefitReject);
2422   TH1F *gSecondaryAntiProtonsTPCRefitReject = new TH1F("gSecondaryAntiProtonsTPCRefitReject",
2423                                                        "",10,-1,1);
2424   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsTPCRefitReject);
2425   TH1F *gSecondaryAntiProtonsESDpidReject = new TH1F("gSecondaryAntiProtonsESDpidReject",
2426                                                      "",10,-1,1);
2427   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsESDpidReject);
2428   TH1F *gSecondaryAntiProtonsTPCpidReject = new TH1F("gSecondaryAntiProtonsTPCpidReject",
2429                                                      "",10,-1,1);
2430   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsTPCpidReject);
2431   TH1F *gSecondaryAntiProtonsPointOnITSLayer1Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer1Reject",
2432                                                              "",10,-1,1);
2433   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer1Reject);
2434   TH1F *gSecondaryAntiProtonsPointOnITSLayer2Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer2Reject",
2435                                                              "",10,-1,1);
2436   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer2Reject);
2437   TH1F *gSecondaryAntiProtonsPointOnITSLayer3Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer3Reject",
2438                                                              "",10,-1,1);
2439   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer3Reject);
2440   TH1F *gSecondaryAntiProtonsPointOnITSLayer4Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer4Reject",
2441                                                              "",10,-1,1);
2442   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer4Reject);
2443   TH1F *gSecondaryAntiProtonsPointOnITSLayer5Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer5Reject",
2444                                                              "",10,-1,1);
2445   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer5Reject);
2446   TH1F *gSecondaryAntiProtonsPointOnITSLayer6Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer6Reject",
2447                                                              "",10,-1,1);
2448   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer6Reject);
2449 }
2450
2451 //____________________________________________________________________//
2452 void AliProtonQAAnalysis::RunQA(AliStack *stack, AliESDEvent *fESD) {
2453   //Runs the QA code
2454   Int_t nGoodTracks = fESD->GetNumberOfTracks();
2455   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
2456     AliESDtrack* track = fESD->GetTrack(iTracks);
2457     Int_t label = TMath::Abs(track->GetLabel()); 
2458
2459     Double_t Pt = 0.0, P = 0.0;
2460     Double_t probability[5];
2461     Float_t dcaXY = 0.0, dcaZ = 0.0;
2462     Double_t nSigmaToVertex = GetSigmaToVertex(track);
2463     Int_t  fIdxInt[200];
2464     Int_t nClustersITS = track->GetITSclusters(fIdxInt);
2465     Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
2466
2467     Float_t chi2PerClusterITS = -1;
2468     if (nClustersITS!=0)
2469       chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
2470     Float_t chi2PerClusterTPC = -1;
2471     if (nClustersTPC!=0)
2472       chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
2473     Double_t chi2ConstrainVertex = TMath::Log(track->GetConstrainedChi2());    
2474     Double_t extCov[15];
2475     track->GetExternalCovariance(extCov);
2476
2477     //TPC only
2478     if(fUseTPCOnly) {
2479       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
2480       if(!tpcTrack) continue;
2481       Pt = tpcTrack->Pt();
2482       P = tpcTrack->P();
2483       track->GetImpactParametersTPC(dcaXY,dcaZ);
2484       
2485       //pid
2486       track->GetTPCpid(probability);
2487       Double_t rcc = 0.0;
2488       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
2489         rcc += probability[i]*GetParticleFraction(i,P);
2490       if(rcc == 0.0) continue;
2491       Double_t w[5];
2492       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
2493         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
2494       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
2495       if(fParticleType == 4) {
2496         FillQA(track, stack);
2497         if(IsAccepted(track)) {
2498           if(label <= stack->GetNprimary()) {
2499             if(track->Charge() > 0) {
2500               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2501                 if(track->HasPointOnITSLayer(iLayer))
2502                   ((TH1F *)(fAcceptedCutList->At(0)))->Fill(iLayer+1);
2503               }
2504               ((TH1F *)(fAcceptedCutList->At(4)))->Fill(nClustersITS);
2505               ((TH1F *)(fAcceptedCutList->At(8)))->Fill(chi2PerClusterITS);
2506               ((TH1F *)(fAcceptedCutList->At(12)))->Fill(chi2ConstrainVertex);
2507               ((TH1F *)(fAcceptedCutList->At(16)))->Fill(nClustersTPC);
2508               ((TH1F *)(fAcceptedCutList->At(20)))->Fill(chi2PerClusterTPC);
2509               ((TH1F *)(fAcceptedCutList->At(24)))->Fill(extCov[0]);
2510               ((TH1F *)(fAcceptedCutList->At(28)))->Fill(extCov[2]);
2511               ((TH1F *)(fAcceptedCutList->At(32)))->Fill(extCov[5]);
2512               ((TH1F *)(fAcceptedCutList->At(36)))->Fill(extCov[9]);
2513               ((TH1F *)(fAcceptedCutList->At(40)))->Fill(extCov[14]);
2514
2515               ((TH1F *)(fAcceptedDCAList->At(0)))->Fill(TMath::Abs(dcaXY));
2516               ((TH1F *)(fAcceptedDCAList->At(4)))->Fill(TMath::Abs(dcaZ));
2517               ((TH1F *)(fAcceptedDCAList->At(8)))->Fill(nSigmaToVertex);
2518               ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),
2519                                                           track->Py(),
2520                                                           track->Pz()),
2521                                                  Pt);
2522             }
2523             else if(track->Charge() < 0) {
2524               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2525                 if(track->HasPointOnITSLayer(iLayer))
2526                   ((TH1F *)(fAcceptedCutList->At(1)))->Fill(iLayer+1);
2527               }
2528               ((TH1F *)(fAcceptedCutList->At(5)))->Fill(nClustersITS);
2529               ((TH1F *)(fAcceptedCutList->At(9)))->Fill(chi2PerClusterITS);
2530               ((TH1F *)(fAcceptedCutList->At(13)))->Fill(chi2ConstrainVertex);
2531               ((TH1F *)(fAcceptedCutList->At(17)))->Fill(nClustersTPC);
2532               ((TH1F *)(fAcceptedCutList->At(21)))->Fill(chi2PerClusterTPC);
2533               ((TH1F *)(fAcceptedCutList->At(25)))->Fill(extCov[0]);
2534               ((TH1F *)(fAcceptedCutList->At(29)))->Fill(extCov[2]);
2535               ((TH1F *)(fAcceptedCutList->At(33)))->Fill(extCov[5]);
2536               ((TH1F *)(fAcceptedCutList->At(37)))->Fill(extCov[9]);
2537               ((TH1F *)(fAcceptedCutList->At(41)))->Fill(extCov[14]);
2538
2539               ((TH1F *)(fAcceptedDCAList->At(1)))->Fill(TMath::Abs(dcaXY));
2540               ((TH1F *)(fAcceptedDCAList->At(5)))->Fill(TMath::Abs(dcaZ));
2541               ((TH1F *)(fAcceptedDCAList->At(9)))->Fill(nSigmaToVertex);
2542               ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(track->Px(),
2543                                                           track->Py(),
2544                                                           track->Pz()),
2545                                                  Pt);
2546             }
2547           }//primary particles
2548           else if(label > stack->GetNprimary()) {
2549             TParticle *particle = stack->Particle(label);
2550             Int_t lPartMother = -1;
2551             Int_t motherPDGCode = -1;
2552             if(particle) {
2553               lPartMother = particle->GetFirstMother();
2554               TParticle *motherParticle = stack->Particle(lPartMother);
2555               if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
2556             }
2557
2558             if(fMCProcessIdFlag)
2559               if(particle->GetUniqueID() != fMCProcessId) continue;
2560             if(fMotherParticlePDGCodeFlag)
2561               if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
2562
2563             if(track->Charge() > 0) {
2564               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2565                 if(track->HasPointOnITSLayer(iLayer))
2566                   ((TH1F *)(fAcceptedCutList->At(2)))->Fill(iLayer+1);
2567               }
2568               ((TH1F *)(fAcceptedCutList->At(6)))->Fill(nClustersITS);
2569               ((TH1F *)(fAcceptedCutList->At(10)))->Fill(chi2PerClusterITS);
2570               ((TH1F *)(fAcceptedCutList->At(14)))->Fill(chi2ConstrainVertex);
2571               ((TH1F *)(fAcceptedCutList->At(18)))->Fill(nClustersTPC);
2572               ((TH1F *)(fAcceptedCutList->At(22)))->Fill(chi2PerClusterTPC);
2573               ((TH1F *)(fAcceptedCutList->At(26)))->Fill(extCov[0]);
2574               ((TH1F *)(fAcceptedCutList->At(30)))->Fill(extCov[2]);
2575               ((TH1F *)(fAcceptedCutList->At(34)))->Fill(extCov[5]);
2576               ((TH1F *)(fAcceptedCutList->At(38)))->Fill(extCov[9]);
2577               ((TH1F *)(fAcceptedCutList->At(42)))->Fill(extCov[14]);
2578
2579               ((TH1F *)(fAcceptedDCAList->At(2)))->Fill(TMath::Abs(dcaXY));
2580               ((TH1F *)(fAcceptedDCAList->At(6)))->Fill(TMath::Abs(dcaZ));
2581               ((TH1F *)(fAcceptedDCAList->At(10)))->Fill(nSigmaToVertex);
2582               ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),
2583                                                           track->Py(),
2584                                                           track->Pz()),
2585                                                  Pt);
2586             }
2587             else if(track->Charge() < 0) {
2588               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2589                 if(track->HasPointOnITSLayer(iLayer))
2590                   ((TH1F *)(fAcceptedCutList->At(3)))->Fill(iLayer+1);
2591               }
2592               ((TH1F *)(fAcceptedCutList->At(7)))->Fill(nClustersITS);
2593               ((TH1F *)(fAcceptedCutList->At(11)))->Fill(chi2PerClusterITS);
2594               ((TH1F *)(fAcceptedCutList->At(15)))->Fill(chi2ConstrainVertex);
2595               ((TH1F *)(fAcceptedCutList->At(19)))->Fill(nClustersTPC);
2596               ((TH1F *)(fAcceptedCutList->At(23)))->Fill(chi2PerClusterTPC);
2597               ((TH1F *)(fAcceptedCutList->At(27)))->Fill(extCov[0]);
2598               ((TH1F *)(fAcceptedCutList->At(31)))->Fill(extCov[2]);
2599               ((TH1F *)(fAcceptedCutList->At(35)))->Fill(extCov[5]);
2600               ((TH1F *)(fAcceptedCutList->At(39)))->Fill(extCov[9]);
2601               ((TH1F *)(fAcceptedCutList->At(43)))->Fill(extCov[14]);
2602
2603               ((TH1F *)(fAcceptedDCAList->At(3)))->Fill(TMath::Abs(dcaXY));
2604               ((TH1F *)(fAcceptedDCAList->At(7)))->Fill(TMath::Abs(dcaZ));
2605               ((TH1F *)(fAcceptedDCAList->At(11)))->Fill(nSigmaToVertex);
2606               ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(track->Px(),
2607                                                           track->Py(),
2608                                                           track->Pz()),
2609                                                  Pt);
2610             }
2611           }//secondary particles
2612         }//accepted - track cuts
2613         else if(!IsAccepted(track)) {
2614           if(label <= stack->GetNprimary()) {
2615             if(track->Charge() > 0)
2616               ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),
2617                                                           track->Py(),
2618                                                           track->Pz()),
2619                                                  Pt);
2620             else if(track->Charge() < 0)
2621               ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(track->Px(),
2622                                                           track->Py(),
2623                                                           track->Pz()),
2624                                                  Pt);
2625           }//primary particles
2626           else if(label > stack->GetNprimary()) {
2627             if(track->Charge() > 0)
2628               ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),
2629                                                           track->Py(),
2630                                                           track->Pz()),
2631                                                  Pt);
2632             else if(track->Charge() < 0)
2633               ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(track->Px(),
2634                                                           track->Py(),
2635                                                           track->Pz()),
2636                                                  Pt);
2637           }//secondary particles
2638         }//rejected - track cuts
2639       }//proton check
2640     }//TPC only tracks
2641     //combined tracking
2642     else if(!fUseTPCOnly) {
2643       Pt = track->Pt();
2644       P = track->P();
2645       track->GetImpactParameters(dcaXY,dcaZ);
2646
2647       //pid
2648       track->GetESDpid(probability);
2649       Double_t rcc = 0.0;
2650       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
2651         rcc += probability[i]*GetParticleFraction(i,P);
2652       if(rcc == 0.0) continue;
2653       Double_t w[5];
2654       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
2655         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
2656       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
2657       if(fParticleType == 4) {
2658         FillQA(track, stack);
2659         if(IsAccepted(track)) {
2660           if(label <= stack->GetNprimary()) {
2661             if(track->Charge() > 0) {
2662               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2663                 if(track->HasPointOnITSLayer(iLayer))
2664                   ((TH1F *)(fAcceptedCutList->At(0)))->Fill(iLayer+1);
2665               }
2666               ((TH1F *)(fAcceptedCutList->At(4)))->Fill(nClustersITS);
2667               ((TH1F *)(fAcceptedCutList->At(8)))->Fill(chi2PerClusterITS);
2668               ((TH1F *)(fAcceptedCutList->At(12)))->Fill(chi2ConstrainVertex);
2669               ((TH1F *)(fAcceptedCutList->At(16)))->Fill(nClustersTPC);
2670               ((TH1F *)(fAcceptedCutList->At(20)))->Fill(chi2PerClusterTPC);
2671               ((TH1F *)(fAcceptedCutList->At(24)))->Fill(extCov[0]);
2672               ((TH1F *)(fAcceptedCutList->At(28)))->Fill(extCov[2]);
2673               ((TH1F *)(fAcceptedCutList->At(32)))->Fill(extCov[5]);
2674               ((TH1F *)(fAcceptedCutList->At(36)))->Fill(extCov[9]);
2675               ((TH1F *)(fAcceptedCutList->At(40)))->Fill(extCov[14]);
2676
2677               ((TH1F *)(fAcceptedDCAList->At(0)))->Fill(TMath::Abs(dcaXY));
2678               ((TH1F *)(fAcceptedDCAList->At(4)))->Fill(TMath::Abs(dcaZ));
2679               ((TH1F *)(fAcceptedDCAList->At(8)))->Fill(nSigmaToVertex);
2680               ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),
2681                                                           track->Py(),
2682                                                           track->Pz()),
2683                                                  Pt);
2684             }
2685             else if(track->Charge() < 0) {
2686               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2687                 if(track->HasPointOnITSLayer(iLayer))
2688                   ((TH1F *)(fAcceptedCutList->At(1)))->Fill(iLayer+1);
2689               }
2690               ((TH1F *)(fAcceptedCutList->At(5)))->Fill(nClustersITS);
2691               ((TH1F *)(fAcceptedCutList->At(9)))->Fill(chi2PerClusterITS);
2692               ((TH1F *)(fAcceptedCutList->At(13)))->Fill(chi2ConstrainVertex);
2693               ((TH1F *)(fAcceptedCutList->At(17)))->Fill(nClustersTPC);
2694               ((TH1F *)(fAcceptedCutList->At(21)))->Fill(chi2PerClusterTPC);
2695               ((TH1F *)(fAcceptedCutList->At(25)))->Fill(extCov[0]);
2696               ((TH1F *)(fAcceptedCutList->At(29)))->Fill(extCov[2]);
2697               ((TH1F *)(fAcceptedCutList->At(33)))->Fill(extCov[5]);
2698               ((TH1F *)(fAcceptedCutList->At(37)))->Fill(extCov[9]);
2699               ((TH1F *)(fAcceptedCutList->At(41)))->Fill(extCov[14]);
2700
2701               ((TH1F *)(fAcceptedDCAList->At(1)))->Fill(TMath::Abs(dcaXY));
2702               ((TH1F *)(fAcceptedDCAList->At(5)))->Fill(TMath::Abs(dcaZ));
2703               ((TH1F *)(fAcceptedDCAList->At(9)))->Fill(nSigmaToVertex);
2704               ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(track->Px(),
2705                                                           track->Py(),
2706                                                           track->Pz()),
2707                                                  Pt);
2708             }
2709           }//primary particles
2710           else if(label > stack->GetNprimary()) {
2711             TParticle *particle = stack->Particle(label);
2712             Int_t lPartMother = -1;
2713             Int_t motherPDGCode = -1;
2714             if(particle) {
2715               lPartMother = particle->GetFirstMother();
2716               TParticle *motherParticle = stack->Particle(lPartMother);
2717               if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
2718             }
2719
2720             if(fMCProcessIdFlag)
2721               if(particle->GetUniqueID() != fMCProcessId) continue;
2722             if(fMotherParticlePDGCodeFlag)
2723               if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
2724
2725             if(track->Charge() > 0) {
2726               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2727                 if(track->HasPointOnITSLayer(iLayer))
2728                   ((TH1F *)(fAcceptedCutList->At(2)))->Fill(iLayer+1);
2729               }
2730               ((TH1F *)(fAcceptedCutList->At(6)))->Fill(nClustersITS);
2731               ((TH1F *)(fAcceptedCutList->At(10)))->Fill(chi2PerClusterITS);
2732               ((TH1F *)(fAcceptedCutList->At(14)))->Fill(chi2ConstrainVertex);
2733               ((TH1F *)(fAcceptedCutList->At(18)))->Fill(nClustersTPC);
2734               ((TH1F *)(fAcceptedCutList->At(22)))->Fill(chi2PerClusterTPC);
2735               ((TH1F *)(fAcceptedCutList->At(26)))->Fill(extCov[0]);
2736               ((TH1F *)(fAcceptedCutList->At(30)))->Fill(extCov[2]);
2737               ((TH1F *)(fAcceptedCutList->At(34)))->Fill(extCov[5]);
2738               ((TH1F *)(fAcceptedCutList->At(38)))->Fill(extCov[9]);
2739               ((TH1F *)(fAcceptedCutList->At(42)))->Fill(extCov[14]);
2740
2741               ((TH1F *)(fAcceptedDCAList->At(2)))->Fill(TMath::Abs(dcaXY));
2742               ((TH1F *)(fAcceptedDCAList->At(6)))->Fill(TMath::Abs(dcaZ));
2743               ((TH1F *)(fAcceptedDCAList->At(10)))->Fill(nSigmaToVertex);
2744               ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),
2745                                                           track->Py(),
2746                                                           track->Pz()),
2747                                                  Pt);
2748             }
2749             else if(track->Charge() < 0) {
2750               for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
2751                 if(track->HasPointOnITSLayer(iLayer))
2752                   ((TH1F *)(fAcceptedCutList->At(3)))->Fill(iLayer+1);
2753               }
2754               ((TH1F *)(fAcceptedCutList->At(7)))->Fill(nClustersITS);
2755               ((TH1F *)(fAcceptedCutList->At(11)))->Fill(chi2PerClusterITS);
2756               ((TH1F *)(fAcceptedCutList->At(15)))->Fill(chi2ConstrainVertex);
2757               ((TH1F *)(fAcceptedCutList->At(19)))->Fill(nClustersTPC);
2758               ((TH1F *)(fAcceptedCutList->At(23)))->Fill(chi2PerClusterTPC);
2759               ((TH1F *)(fAcceptedCutList->At(27)))->Fill(extCov[0]);
2760               ((TH1F *)(fAcceptedCutList->At(31)))->Fill(extCov[2]);
2761               ((TH1F *)(fAcceptedCutList->At(35)))->Fill(extCov[5]);
2762               ((TH1F *)(fAcceptedCutList->At(39)))->Fill(extCov[9]);
2763               ((TH1F *)(fAcceptedCutList->At(43)))->Fill(extCov[14]);
2764
2765               ((TH1F *)(fAcceptedDCAList->At(3)))->Fill(TMath::Abs(dcaXY));
2766               ((TH1F *)(fAcceptedDCAList->At(7)))->Fill(TMath::Abs(dcaZ));
2767               ((TH1F *)(fAcceptedDCAList->At(11)))->Fill(nSigmaToVertex);
2768               ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(track->Px(),
2769                                                           track->Py(),
2770                                                           track->Pz()),
2771                                                  Pt);
2772             }
2773           }//secondary particles
2774         }//accepted - track cuts
2775         else if(!IsAccepted(track)) {
2776           if(label <= stack->GetNprimary()) {
2777             if(track->Charge() > 0)
2778               ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),
2779                                                           track->Py(),
2780                                                           track->Pz()),
2781                                                  Pt);
2782             else if(track->Charge() < 0)
2783               ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(track->Px(),
2784                                                           track->Py(),
2785                                                           track->Pz()),
2786                                                  Pt);
2787           }//primary particles
2788           else if(label > stack->GetNprimary()) {
2789             if(track->Charge() > 0)
2790               ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),
2791                                                           track->Py(),
2792                                                           track->Pz()),
2793                                                  Pt);
2794             else if(track->Charge() < 0)
2795               ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(track->Px(),
2796                                                           track->Py(),
2797                                                           track->Pz()),
2798                                                  Pt);
2799           }//secondary particles
2800         }//rejected - track cuts
2801       }//proton check
2802     }//combined tracking
2803   }//track loop
2804     
2805 }
2806
2807 //____________________________________________________________________//
2808 void AliProtonQAAnalysis::InitMCAnalysis() {
2809   //MC analysis - 3D histograms: y-pT-pdg
2810   fPDGList = new TList();
2811   TH3F *gHistYPtPDGProtons = new TH3F("gHistYPtPDGProtons",
2812                                       ";y;P_{T} [GeV/c];PDG",
2813                                       fNBinsY,fMinY,fMaxY,
2814                                       fNBinsPt,fMinPt,fMaxPt,
2815                                       14,-0.5,13.5);
2816   fPDGList->Add(gHistYPtPDGProtons);
2817   TH3F *gHistYPtPDGAntiProtons = new TH3F("gHistYPtPDGAntiProtons",
2818                                           ";y;P_{T} [GeV/c];PDG",
2819                                           fNBinsY,fMinY,fMaxY,
2820                                           fNBinsPt,fMinPt,fMaxPt,
2821                                           14,-0.5,13.5);
2822   fPDGList->Add(gHistYPtPDGAntiProtons);
2823
2824   //MC processes
2825   fMCProcessesList = new TList();
2826   TH1F *gHistProtonsFromKLProcess = new TH1F("gHistProtonsFromKLProcess","",51,-0.5,50.5);
2827   fMCProcessesList->Add(gHistProtonsFromKLProcess);
2828   TH1F *gHistProtonsFromPionProcess = new TH1F("gHistProtonsFromPionProcess","",51,-0.5,50.5);
2829   fMCProcessesList->Add(gHistProtonsFromPionProcess);
2830   TH1F *gHistProtonsFromKSProcess = new TH1F("gHistProtonsFromKSProcess","",51,-0.5,50.5);
2831   fMCProcessesList->Add(gHistProtonsFromKSProcess);
2832   TH1F *gHistProtonsFromKaonProcess = new TH1F("gHistProtonsFromKaonProcess","",51,-0.5,50.5);
2833   fMCProcessesList->Add(gHistProtonsFromKaonProcess);
2834   TH1F *gHistProtonsFromNeutronProcess = new TH1F("gHistProtonsFromNeutronProcess","",51,-0.5,50.5);
2835   fMCProcessesList->Add(gHistProtonsFromNeutronProcess);
2836   TH1F *gHistProtonsFromProtonProcess = new TH1F("gHistProtonsFromProtonProcess","",51,-0.5,50.5);
2837   fMCProcessesList->Add(gHistProtonsFromProtonProcess);
2838   TH1F *gHistProtonsFromSigmaMinusProcess = new TH1F("gHistProtonsFromSigmaMinusProcess","",51,-0.5,50.5);
2839   fMCProcessesList->Add(gHistProtonsFromSigmaMinusProcess);
2840   TH1F *gHistProtonsFromLambda0Process = new TH1F("gHistProtonsFromLambda0Process","",51,-0.5,50.5);
2841   fMCProcessesList->Add(gHistProtonsFromLambda0Process);
2842   TH1F *gHistProtonsFromSigmaPlusProcess = new TH1F("gHistProtonsFromSigmaPlusProcess","",51,-0.5,50.5);
2843   fMCProcessesList->Add(gHistProtonsFromSigmaPlusProcess);
2844   TH1F *gHistProtonsFromXiMinusProcess = new TH1F("gHistProtonsFromXiMinusProcess","",51,-0.5,50.5);
2845   fMCProcessesList->Add(gHistProtonsFromXiMinusProcess);
2846   TH1F *gHistProtonsFromXi0Process = new TH1F("gHistProtonsFromXi0Process","",51,-0.5,50.5);                                        
2847   fMCProcessesList->Add(gHistProtonsFromXi0Process);
2848   TH1F *gHistProtonsFromOmegaProcess = new TH1F("gHistProtonsFromOmegaProcess","",51,-0.5,50.5); 
2849   fMCProcessesList->Add(gHistProtonsFromOmegaProcess);
2850
2851   TH1F *gHistAntiProtonsFromKLProcess = new TH1F("gHistAntiProtonsFromKLProcess","",51,-0.5,50.5); 
2852   fMCProcessesList->Add(gHistAntiProtonsFromKLProcess);
2853   TH1F *gHistAntiProtonsFromPionProcess = new TH1F("gHistAntiProtonsFromPionProcess","",51,-0.5,50.5); 
2854   fMCProcessesList->Add(gHistAntiProtonsFromPionProcess);
2855   TH1F *gHistAntiProtonsFromKSProcess = new TH1F("gHistAntiProtonsFromKSProcess","",51,-0.5,50.5); 
2856   fMCProcessesList->Add(gHistAntiProtonsFromKSProcess);
2857   TH1F *gHistAntiProtonsFromKaonProcess = new TH1F("gHistAntiProtonsFromKaonProcess","",51,-0.5,50.5); 
2858   fMCProcessesList->Add(gHistAntiProtonsFromKaonProcess);
2859   TH1F *gHistAntiProtonsFromNeutronProcess = new TH1F("gHistAntiProtonsFromNeutronProcess","",51,-0.5,50.5); 
2860   fMCProcessesList->Add(gHistAntiProtonsFromNeutronProcess);
2861   TH1F *gHistAntiProtonsFromProtonProcess = new TH1F("gHistAntiProtonsFromProtonProcess","",51,-0.5,50.5); 
2862   fMCProcessesList->Add(gHistAntiProtonsFromProtonProcess);
2863   TH1F *gHistAntiProtonsFromLambda0Process = new TH1F("gHistAntiProtonsFromLambda0Process","",51,-0.5,50.5); 
2864   fMCProcessesList->Add(gHistAntiProtonsFromLambda0Process);
2865   TH1F *gHistAntiProtonsFromSigmaPlusProcess = new TH1F("gHistAntiProtonsFromSigmaPlusProcess","",51,-0.5,50.5); 
2866   fMCProcessesList->Add(gHistAntiProtonsFromSigmaPlusProcess);
2867 }
2868
2869 //____________________________________________________________________//
2870 void AliProtonQAAnalysis::RunMCAnalysis(AliStack* stack) {
2871   //Main analysis part - MC 
2872   for(Int_t iParticle = 0; iParticle < stack->GetNtrack(); iParticle++) {
2873     TParticle *particle = stack->Particle(iParticle);
2874     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
2875     Int_t pdgcode = particle->GetPdgCode();
2876     if(pdgcode == 2212) {
2877       if(iParticle <= stack->GetNprimary()) 
2878         ((TH3F *)(fPDGList->At(0)))->Fill(Rapidity(particle->Px(),
2879                                                    particle->Py(),
2880                                                    particle->Pz()),
2881                                           particle->Pt(),0);
2882       else if(iParticle > stack->GetNprimary()) {
2883         Int_t lPartMother = particle->GetFirstMother();
2884         TParticle *motherParticle = stack->Particle(lPartMother);
2885         if(!motherParticle) continue;
2886         ((TH3F *)(fPDGList->At(0)))->Fill(Rapidity(particle->Px(),
2887                                                    particle->Py(),
2888                                                    particle->Pz()),
2889                                           particle->Pt(),
2890                                           ConvertPDGToInt(motherParticle->GetPdgCode()));
2891         //processes
2892         if(TMath::Abs(motherParticle->GetPdgCode()) == 130)
2893           ((TH1F *)(fMCProcessesList->At(0)))->Fill(particle->GetUniqueID());
2894         if(TMath::Abs(motherParticle->GetPdgCode()) == 211)
2895           ((TH1F *)(fMCProcessesList->At(1)))->Fill(particle->GetUniqueID());
2896         if(TMath::Abs(motherParticle->GetPdgCode()) == 310)
2897           ((TH1F *)(fMCProcessesList->At(2)))->Fill(particle->GetUniqueID());
2898         if(TMath::Abs(motherParticle->GetPdgCode()) == 321)
2899           ((TH1F *)(fMCProcessesList->At(3)))->Fill(particle->GetUniqueID());
2900         if(TMath::Abs(motherParticle->GetPdgCode()) == 2112)
2901           ((TH1F *)(fMCProcessesList->At(4)))->Fill(particle->GetUniqueID());
2902         if(TMath::Abs(motherParticle->GetPdgCode()) == 2212)
2903           ((TH1F *)(fMCProcessesList->At(5)))->Fill(particle->GetUniqueID());
2904         if(TMath::Abs(motherParticle->GetPdgCode()) == 3112)
2905           ((TH1F *)(fMCProcessesList->At(6)))->Fill(particle->GetUniqueID());
2906         if(TMath::Abs(motherParticle->GetPdgCode()) == 3122)
2907           ((TH1F *)(fMCProcessesList->At(7)))->Fill(particle->GetUniqueID());
2908         if(TMath::Abs(motherParticle->GetPdgCode()) == 3222)
2909           ((TH1F *)(fMCProcessesList->At(8)))->Fill(particle->GetUniqueID());
2910         if(TMath::Abs(motherParticle->GetPdgCode()) == 3312)
2911           ((TH1F *)(fMCProcessesList->At(9)))->Fill(particle->GetUniqueID());
2912         if(TMath::Abs(motherParticle->GetPdgCode()) == 3322)
2913           ((TH1F *)(fMCProcessesList->At(10)))->Fill(particle->GetUniqueID());
2914         if(TMath::Abs(motherParticle->GetPdgCode()) == 3334)
2915           ((TH1F *)(fMCProcessesList->At(11)))->Fill(particle->GetUniqueID());
2916       }//secondary proton
2917     }//pdgcode of proton
2918
2919     if(pdgcode == -2212) {
2920       if(iParticle <= stack->GetNprimary()) 
2921         ((TH3F *)(fPDGList->At(1)))->Fill(Rapidity(particle->Px(),
2922                                                    particle->Py(),
2923                                                    particle->Pz()),
2924                                           particle->Pt(),0);
2925       else if(iParticle > stack->GetNprimary()) {
2926         Int_t lPartMother = particle->GetFirstMother();
2927         TParticle *motherParticle = stack->Particle(lPartMother);
2928         if(!motherParticle) continue;
2929         ((TH3F *)(fPDGList->At(1)))->Fill(Rapidity(particle->Px(),
2930                                                    particle->Py(),
2931                                                    particle->Pz()),
2932                                           particle->Pt(),
2933                                           ConvertPDGToInt(motherParticle->GetPdgCode()));
2934
2935         //processes
2936         if(TMath::Abs(motherParticle->GetPdgCode()) == 130)
2937           ((TH1F *)(fMCProcessesList->At(12)))->Fill(particle->GetUniqueID());
2938         if(TMath::Abs(motherParticle->GetPdgCode()) == 211)
2939           ((TH1F *)(fMCProcessesList->At(13)))->Fill(particle->GetUniqueID());
2940         if(TMath::Abs(motherParticle->GetPdgCode()) == 310)
2941           ((TH1F *)(fMCProcessesList->At(14)))->Fill(particle->GetUniqueID());
2942         if(TMath::Abs(motherParticle->GetPdgCode()) == 321)
2943           ((TH1F *)(fMCProcessesList->At(15)))->Fill(particle->GetUniqueID());
2944         if(TMath::Abs(motherParticle->GetPdgCode()) == 2112)
2945           ((TH1F *)(fMCProcessesList->At(16)))->Fill(particle->GetUniqueID());
2946         if(TMath::Abs(motherParticle->GetPdgCode()) == 2212)
2947           ((TH1F *)(fMCProcessesList->At(17)))->Fill(particle->GetUniqueID());
2948         if(TMath::Abs(motherParticle->GetPdgCode()) == 3122)
2949           ((TH1F *)(fMCProcessesList->At(18)))->Fill(particle->GetUniqueID());
2950         if(TMath::Abs(motherParticle->GetPdgCode()) == 3222)
2951           ((TH1F *)(fMCProcessesList->At(19)))->Fill(particle->GetUniqueID());
2952       }//secondary antiproton
2953     }//pdgcode of antiproton
2954
2955   }//particle loop
2956 }
2957
2958 //____________________________________________________________________//
2959 Int_t AliProtonQAAnalysis::ConvertPDGToInt(Int_t pdgCode) {
2960   //Converts the pdg code to an int based on the following scheme:
2961   //1: PDG code: 130 - Name: K_L0
2962   //2: PDG code: 211 - Name: pi+
2963   //3: PDG code: 310 - Name: K_S0
2964   //4: PDG code: 321 - Name: K+
2965   //5: PDG code: 2112 - Name: neutron
2966   //6: PDG code: 2212 - Name: proton
2967   //7: PDG code: 3112 - Name: Sigma-
2968   //8: PDG code: 3122 - Name: Lambda0
2969   //9: PDG code: 3222 - Name: Sigma+
2970   //10: PDG code: 3312 - Name: Xi-
2971   //11: PDG code: 3322 - Name: Xi0
2972   //12: PDG code: 3334 - Name: Omega-
2973   Int_t code = -1;
2974   switch (TMath::Abs(pdgCode)) {
2975   case 130: {
2976     code = 1;
2977     break;
2978   }
2979   case 211: {
2980     code = 2;
2981     break;
2982   }
2983   case 310: {
2984     code = 3;
2985     break;
2986   }
2987   case 321: {
2988     code = 4;
2989     break;
2990   }
2991   case 2112: {
2992     code = 5;
2993     break;
2994   }
2995   case 2212: {
2996     code = 6;
2997     break;
2998   }
2999   case 3112: {
3000     code = 7;
3001     break;
3002   }
3003   case 3122: {
3004     code = 8;
3005     break;
3006   }
3007   case 3222: {
3008     code = 9;
3009     break;
3010   }
3011   case 3312: {
3012     code = 10;
3013     break;
3014   }
3015   case 3322: {
3016     code = 11;
3017     break;
3018   }
3019   case 3334: {
3020     code = 12;
3021     break;
3022   }
3023   default: {
3024     code = -1;
3025     break;
3026   }
3027   }//switch
3028
3029   return code;
3030 }
3031
3032
3033
3034
3035
3036
3037
3038