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