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