]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/AliProtonAnalysis.cxx
Adding the files to be used for the QA of the proton analysis
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliProtonAnalysis.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$ */
15
16 //-----------------------------------------------------------------
17 //                 AliProtonAnalysis 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 <TH2F.h>
26 #include <TH1D.h>
27 #include <TH1I.h>
28 #include <TParticle.h>
29
30 #include "AliProtonAnalysis.h"
31
32 #include <AliExternalTrackParam.h>
33 #include <AliAODEvent.h>
34 #include <AliESDEvent.h>
35 #include <AliLog.h>
36 #include <AliPID.h>
37 #include <AliStack.h>
38 #include <AliCFContainer.h>
39 #include <AliCFEffGrid.h>
40 #include <AliCFEffGrid.h>
41
42 ClassImp(AliProtonAnalysis)
43
44 //____________________________________________________________________//
45 AliProtonAnalysis::AliProtonAnalysis() : 
46   TObject(), 
47   fNBinsY(0), fMinY(0), fMaxY(0),
48   fNBinsPt(0), fMinPt(0), fMaxPt(0),
49   fMinTPCClusters(0), fMinITSClusters(0),
50   fMaxChi2PerTPCCluster(0), fMaxChi2PerITSCluster(0),
51   fMaxCov11(0), fMaxCov22(0), fMaxCov33(0), fMaxCov44(0), fMaxCov55(0),
52   fMaxSigmaToVertex(0), fMaxSigmaToVertexTPC(0),
53   fMinTPCClustersFlag(kFALSE), fMinITSClustersFlag(kFALSE),
54   fMaxChi2PerTPCClusterFlag(kFALSE), fMaxChi2PerITSClusterFlag(kFALSE),
55   fMaxCov11Flag(kFALSE), fMaxCov22Flag(kFALSE), fMaxCov33Flag(kFALSE), fMaxCov44Flag(kFALSE), fMaxCov55Flag(kFALSE),
56   fMaxSigmaToVertexFlag(kFALSE), fMaxSigmaToVertexTPCFlag(kFALSE),
57   fITSRefitFlag(kFALSE), fTPCRefitFlag(kFALSE),
58   fESDpidFlag(kFALSE), fTPCpidFlag(kFALSE),
59   fQAHistograms(kFALSE),
60   fGlobalQAList(0), fQA2DList(0),
61   fQAPrimaryProtonsAcceptedList(0),
62   fQAPrimaryProtonsRejectedList(0),
63   fQASecondaryProtonsAcceptedList(0),
64   fQASecondaryProtonsRejectedList(0),
65   fQAPrimaryAntiProtonsAcceptedList(0),
66   fQAPrimaryAntiProtonsRejectedList(0),
67   fQASecondaryAntiProtonsAcceptedList(0),
68   fQASecondaryAntiProtonsRejectedList(0),
69   fFunctionProbabilityFlag(kFALSE), 
70   fElectronFunction(0), fMuonFunction(0),
71   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
72   fUseTPCOnly(kFALSE), fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0),
73   fCorrectionList2D(0), fEfficiencyList1D(0), fCorrectionList1D(0) {
74   //Default constructor
75   for(Int_t i = 0; i < 5; i++) fPartFrac[i] = 0.0;
76   fCorrectionList2D = new TList(); 
77   fEfficiencyList1D = new TList(); 
78   fCorrectionList1D = new TList();
79 }
80
81 //____________________________________________________________________//
82 AliProtonAnalysis::AliProtonAnalysis(Int_t nbinsY, Float_t fLowY, Float_t fHighY,Int_t nbinsPt, Float_t fLowPt, Float_t fHighPt) : 
83   TObject(),
84   fNBinsY(nbinsY), fMinY(fLowY), fMaxY(fHighY),
85   fNBinsPt(nbinsPt), fMinPt(fLowPt), fMaxPt(fHighPt),
86   fMinTPCClusters(0), fMinITSClusters(0),
87   fMaxChi2PerTPCCluster(0), fMaxChi2PerITSCluster(0),
88   fMaxCov11(0), fMaxCov22(0), fMaxCov33(0), fMaxCov44(0), fMaxCov55(0),
89   fMaxSigmaToVertex(0), fMaxSigmaToVertexTPC(0),
90   fMinTPCClustersFlag(kFALSE), fMinITSClustersFlag(kFALSE),
91   fMaxChi2PerTPCClusterFlag(kFALSE), fMaxChi2PerITSClusterFlag(kFALSE),
92   fMaxCov11Flag(kFALSE), fMaxCov22Flag(kFALSE), fMaxCov33Flag(kFALSE), fMaxCov44Flag(kFALSE), fMaxCov55Flag(kFALSE),
93   fMaxSigmaToVertexFlag(kFALSE), fMaxSigmaToVertexTPCFlag(kFALSE),
94   fITSRefitFlag(kFALSE), fTPCRefitFlag(kFALSE),
95   fESDpidFlag(kFALSE), fTPCpidFlag(kFALSE),
96   fQAHistograms(kFALSE), 
97   fGlobalQAList(0), fQA2DList(0),
98   fQAPrimaryProtonsAcceptedList(0),
99   fQAPrimaryProtonsRejectedList(0),
100   fQASecondaryProtonsAcceptedList(0),
101   fQASecondaryProtonsRejectedList(0),
102   fQAPrimaryAntiProtonsAcceptedList(0),
103   fQAPrimaryAntiProtonsRejectedList(0),
104   fQASecondaryAntiProtonsAcceptedList(0),
105   fQASecondaryAntiProtonsRejectedList(0),
106   fFunctionProbabilityFlag(kFALSE), 
107   fElectronFunction(0), fMuonFunction(0),
108   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
109   fUseTPCOnly(kFALSE), fHistEvents(0), fHistYPtProtons(0), fHistYPtAntiProtons(0),
110   fCorrectionList2D(0), fEfficiencyList1D(0), fCorrectionList1D(0) {
111   //Default constructor
112
113   fHistEvents = new TH1I("fHistEvents","Analyzed events",1,0,1);
114
115   fHistYPtProtons = new TH2F("fHistYPtProtons","y-Pt Protons",fNBinsY,fMinY,fMaxY,fNBinsPt,fMinPt,fMaxPt);
116   fHistYPtProtons->SetStats(kTRUE);
117   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV]");
118   fHistYPtProtons->GetXaxis()->SetTitle("y");
119   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
120
121   fHistYPtAntiProtons = new TH2F("fHistYPtAntiProtons","y-Pt Antiprotons",fNBinsY,fMinY,fMaxY,fNBinsPt,fMinPt,fMaxPt);
122   fHistYPtAntiProtons->SetStats(kTRUE);
123   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV]");
124   fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
125   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
126
127
128 //____________________________________________________________________//
129 AliProtonAnalysis::~AliProtonAnalysis() {
130   //Default destructor
131   if(fHistEvents) delete fHistEvents;
132   if(fHistYPtProtons) delete fHistYPtProtons;
133   if(fHistYPtAntiProtons) delete fHistYPtAntiProtons;
134   if(fCorrectionList2D) delete fCorrectionList2D;
135   if(fEfficiencyList1D) delete fEfficiencyList1D;
136   if(fCorrectionList1D) delete fCorrectionList1D;
137   if(fGlobalQAList) delete fGlobalQAList;
138   if(fQA2DList) delete fQA2DList;
139   if(fQAPrimaryProtonsAcceptedList) delete fQAPrimaryProtonsAcceptedList;
140   if(fQAPrimaryProtonsRejectedList) delete fQAPrimaryProtonsRejectedList;
141   if(fQASecondaryProtonsAcceptedList) delete fQASecondaryProtonsAcceptedList;
142   if(fQASecondaryProtonsRejectedList) delete fQASecondaryProtonsRejectedList;
143   if(fQAPrimaryAntiProtonsAcceptedList) delete fQAPrimaryAntiProtonsAcceptedList;
144   if(fQAPrimaryAntiProtonsRejectedList) delete fQAPrimaryAntiProtonsRejectedList;
145   if(fQASecondaryAntiProtonsAcceptedList) delete fQASecondaryAntiProtonsAcceptedList;
146   if(fQASecondaryAntiProtonsRejectedList) delete fQASecondaryAntiProtonsRejectedList; 
147 }
148
149 //____________________________________________________________________//
150 void AliProtonAnalysis::InitAnalysisHistograms(Int_t nbinsY, Float_t fLowY, Float_t fHighY, 
151                                                Int_t nbinsPt, Float_t fLowPt, Float_t fHighPt) {
152   fNBinsY = nbinsY;
153   fMinY = fLowY;
154   fMaxY = fHighY;
155   fNBinsPt = nbinsPt;
156   fMinPt = fLowPt;
157   fMaxPt = fHighPt;
158
159   fHistEvents = new TH1I("fHistEvents","Anallyzed events",1,0,1);
160
161   fHistYPtProtons = new TH2F("fHistYPtProtons","y-Pt Protons",fNBinsY,fMinY,fMaxY,fNBinsPt,fMinPt,fMaxPt);
162   fHistYPtProtons->SetStats(kTRUE);
163   fHistYPtProtons->GetYaxis()->SetTitle("P_{T} [GeV]");
164   fHistYPtProtons->GetXaxis()->SetTitle("y");
165   fHistYPtProtons->GetXaxis()->SetTitleColor(1);
166
167   fHistYPtAntiProtons = new TH2F("fHistYPtAntiProtons","y-Pt Antiprotons",fNBinsY,fMinY,fMaxY,fNBinsPt,fMinPt,fMaxPt);
168   fHistYPtAntiProtons->SetStats(kTRUE);
169   fHistYPtAntiProtons->GetYaxis()->SetTitle("P_{T} [GeV]");
170   fHistYPtAntiProtons->GetXaxis()->SetTitle("y");
171   fHistYPtAntiProtons->GetXaxis()->SetTitleColor(1);
172 }
173
174 //____________________________________________________________________//
175 Bool_t AliProtonAnalysis::ReadFromFile(const char* filename) {
176   Bool_t status = kTRUE;
177
178   TFile *file = TFile::Open(filename);
179   if(!file) {
180     cout<<"Could not find the input file "<<filename<<endl;
181     status = kFALSE;
182   }
183
184   TList *list = (TList *)file->Get("outputList1");
185   if(list) {
186     cout<<"Retrieving objects from the list "<<list->GetName()<<"..."<<endl; 
187     fHistYPtProtons = (TH2F *)list->At(0);
188     fHistYPtAntiProtons = (TH2F *)list->At(1);
189     fHistEvents = (TH1I *)list->At(2);
190   }
191   else if(!list) {
192     cout<<"Retrieving objects from the file... "<<endl;
193     fHistYPtProtons = (TH2F *)file->Get("fHistYPtProtons");
194     fHistYPtAntiProtons = (TH2F *)file->Get("fHistYPtAntiProtons");
195     fHistEvents = (TH1I *)file->Get("fHistEvents");
196   }
197   if((!fHistYPtProtons)||(!fHistYPtAntiProtons)||(!fHistEvents)) {
198     cout<<"Input containers were not found!!!"<<endl;
199     status = kFALSE;
200   }
201   else {
202     fHistYPtProtons->Sumw2();
203     fHistYPtAntiProtons->Sumw2();
204   }
205
206   return status;
207 }
208
209 //____________________________________________________________________//
210 TH1D *AliProtonAnalysis::GetProtonYHistogram() {
211   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
212   TH1D *fYProtons = (TH1D *)fHistYPtProtons->ProjectionX("fYProtons",0,fHistYPtProtons->GetYaxis()->GetNbins(),"e"); 
213   fYProtons->SetStats(kFALSE);
214   fYProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
215   fYProtons->SetTitle("dN/dy protons");
216   fYProtons->SetMarkerStyle(kFullCircle);
217   fYProtons->SetMarkerColor(4);
218   if(nAnalyzedEvents > 0)
219     fYProtons->Scale(1./nAnalyzedEvents);
220
221   return fYProtons;
222 }
223
224 //____________________________________________________________________//
225 TH1D *AliProtonAnalysis::GetAntiProtonYHistogram() {
226   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
227   TH1D *fYAntiProtons = (TH1D *)fHistYPtAntiProtons->ProjectionX("fYAntiProtons",0,fHistYPtAntiProtons->GetYaxis()->GetNbins(),"e"); 
228   fYAntiProtons->SetStats(kFALSE);
229   fYAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dy)");
230   fYAntiProtons->SetTitle("dN/dy antiprotons");
231   fYAntiProtons->SetMarkerStyle(kFullCircle);
232   fYAntiProtons->SetMarkerColor(4);
233   if(nAnalyzedEvents > 0)
234     fYAntiProtons->Scale(1./nAnalyzedEvents);
235
236   return fYAntiProtons;
237 }
238
239 //____________________________________________________________________//
240 TH1D *AliProtonAnalysis::GetProtonPtHistogram() {
241   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
242   TH1D *fPtProtons = (TH1D *)fHistYPtProtons->ProjectionY("fPtProtons",0,fHistYPtProtons->GetXaxis()->GetNbins(),"e"); 
243   fPtProtons->SetStats(kFALSE);
244   fPtProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
245   fPtProtons->SetTitle("dN/dPt protons");
246   fPtProtons->SetMarkerStyle(kFullCircle);
247   fPtProtons->SetMarkerColor(4);
248   if(nAnalyzedEvents > 0)
249     fPtProtons->Scale(1./nAnalyzedEvents);
250
251   return fPtProtons;
252 }
253
254 //____________________________________________________________________//
255 TH1D *AliProtonAnalysis::GetAntiProtonPtHistogram() {
256   Int_t nAnalyzedEvents = GetNumberOfAnalyzedEvents();
257   TH1D *fPtAntiProtons = (TH1D *)fHistYPtAntiProtons->ProjectionY("fPtAntiProtons",0,fHistYPtProtons->GetXaxis()->GetNbins(),"e"); 
258   fPtAntiProtons->SetStats(kFALSE);
259   fPtAntiProtons->GetYaxis()->SetTitle("(1/N_{events})(dN/dP_{T})");
260   fPtAntiProtons->SetTitle("dN/dPt antiprotons");
261   fPtAntiProtons->SetMarkerStyle(kFullCircle);
262   fPtAntiProtons->SetMarkerColor(4);
263   if(nAnalyzedEvents > 0)
264     fPtAntiProtons->Scale(1./nAnalyzedEvents);
265
266   return fPtAntiProtons;
267 }
268
269 //____________________________________________________________________//
270 TH1D *AliProtonAnalysis::GetYRatioHistogram() {
271   TH1D *fYProtons = GetProtonYHistogram();
272   TH1D *fYAntiProtons = GetAntiProtonYHistogram();
273   
274   TH1D *hRatioY = new TH1D("hRatioY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
275   hRatioY->Divide(fYAntiProtons,fYProtons,1.0,1.0);
276   hRatioY->SetMarkerStyle(kFullCircle);
277   hRatioY->SetMarkerColor(4);
278   hRatioY->GetYaxis()->SetTitle("#bar{p}/p");
279   hRatioY->GetYaxis()->SetTitleOffset(1.4);
280   hRatioY->GetXaxis()->SetTitle("y");
281   hRatioY->GetXaxis()->SetTitleColor(1);
282   hRatioY->SetStats(kFALSE);
283
284   return hRatioY;
285 }
286
287 //____________________________________________________________________//
288 TH1D *AliProtonAnalysis::GetPtRatioHistogram() {
289   TH1D *fPtProtons = GetProtonPtHistogram();
290   TH1D *fPtAntiProtons = GetAntiProtonPtHistogram();
291   
292   TH1D *hRatioPt = new TH1D("hRatioPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
293   hRatioPt->Divide(fPtAntiProtons,fPtProtons,1.0,1.0);
294   hRatioPt->SetMarkerStyle(kFullCircle);
295   hRatioPt->SetMarkerColor(4);
296   hRatioPt->GetYaxis()->SetTitle("#bar{p}/p");
297   hRatioPt->GetYaxis()->SetTitleOffset(1.4);
298   hRatioPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
299   hRatioPt->GetXaxis()->SetTitleColor(1);
300   hRatioPt->SetStats(kFALSE);
301
302   return hRatioPt;
303 }
304
305 //____________________________________________________________________//
306 TH1D *AliProtonAnalysis::GetYAsymmetryHistogram() {
307   TH1D *fYProtons = GetProtonYHistogram();
308   TH1D *fYAntiProtons = GetAntiProtonYHistogram();
309   
310   TH1D *hsum = new TH1D("hsumY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
311   hsum->Add(fYProtons,fYAntiProtons,1.0,1.0);
312
313   TH1D *hdiff = new TH1D("hdiffY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
314   hdiff->Add(fYProtons,fYAntiProtons,1.0,-1.0);
315
316   TH1D *hAsymmetryY = new TH1D("hAsymmetryY","",fYProtons->GetNbinsX(),fYProtons->GetXaxis()->GetXmin(),fYProtons->GetXaxis()->GetXmax());
317   hAsymmetryY->Divide(hdiff,hsum,2.0,1.);
318   hAsymmetryY->SetMarkerStyle(kFullCircle);
319   hAsymmetryY->SetMarkerColor(4);
320   hAsymmetryY->GetYaxis()->SetTitle("A_{p}");
321   hAsymmetryY->GetYaxis()->SetTitleOffset(1.4);
322   hAsymmetryY->GetXaxis()->SetTitle("y");
323   hAsymmetryY->GetXaxis()->SetTitleColor(1);
324   hAsymmetryY->SetStats(kFALSE);
325
326   return hAsymmetryY;
327 }
328
329 //____________________________________________________________________//
330 TH1D *AliProtonAnalysis::GetPtAsymmetryHistogram() {
331   TH1D *fPtProtons = GetProtonPtHistogram();
332   TH1D *fPtAntiProtons = GetAntiProtonPtHistogram();
333   
334   TH1D *hsum = new TH1D("hsumPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
335   hsum->Add(fPtProtons,fPtAntiProtons,1.0,1.0);
336
337   TH1D *hdiff = new TH1D("hdiffPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
338   hdiff->Add(fPtProtons,fPtAntiProtons,1.0,-1.0);
339
340   TH1D *hAsymmetryPt = new TH1D("hAsymmetryPt","",fPtProtons->GetNbinsX(),fPtProtons->GetXaxis()->GetXmin(),fPtProtons->GetXaxis()->GetXmax());
341   hAsymmetryPt->Divide(hdiff,hsum,2.0,1.);
342   hAsymmetryPt->SetMarkerStyle(kFullCircle);
343   hAsymmetryPt->SetMarkerColor(4);
344   hAsymmetryPt->GetYaxis()->SetTitle("A_{p}");
345   hAsymmetryPt->GetYaxis()->SetTitleOffset(1.4);
346   hAsymmetryPt->GetXaxis()->SetTitle("P_{T} [GeV/c]");
347   hAsymmetryPt->GetXaxis()->SetTitleColor(1);
348   hAsymmetryPt->SetStats(kFALSE);
349
350   return hAsymmetryPt;
351 }
352
353 //____________________________________________________________________//
354 Double_t AliProtonAnalysis::GetParticleFraction(Int_t i, Double_t p) {
355   Double_t partFrac=0;
356   if(fFunctionProbabilityFlag) {
357     if(i == 0) partFrac = fElectronFunction->Eval(p);
358     if(i == 1) partFrac = fMuonFunction->Eval(p);
359     if(i == 2) partFrac = fPionFunction->Eval(p);
360     if(i == 3) partFrac = fKaonFunction->Eval(p);
361     if(i == 4) partFrac = fProtonFunction->Eval(p);
362   }
363   else partFrac = fPartFrac[i];
364
365   return partFrac;
366 }
367
368 //____________________________________________________________________//
369 void AliProtonAnalysis::Analyze(AliESDEvent* fESD) {
370   //Main analysis part - ESD
371   fHistEvents->Fill(0); //number of analyzed events
372   Double_t Pt = 0.0, P = 0.0;
373   Int_t nGoodTracks = fESD->GetNumberOfTracks();
374   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
375     AliESDtrack* track = fESD->GetTrack(iTracks);
376     Double_t probability[5];
377
378     if(IsAccepted(track)) {     
379       if(fUseTPCOnly) {
380         AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
381         if(!tpcTrack) continue;
382         Pt = tpcTrack->Pt();
383         P = tpcTrack->P();
384         
385         //pid
386         track->GetTPCpid(probability);
387         Double_t rcc = 0.0;
388         for(Int_t i = 0; i < AliPID::kSPECIES; i++) 
389           rcc += probability[i]*GetParticleFraction(i,P);
390         if(rcc == 0.0) continue;
391         Double_t w[5];
392         for(Int_t i = 0; i < AliPID::kSPECIES; i++) 
393           w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
394         Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
395         if(fParticleType == 4) {
396           if(tpcTrack->Charge() > 0) 
397             fHistYPtProtons->Fill(Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),Pt);
398           else if(tpcTrack->Charge() < 0) 
399             fHistYPtAntiProtons->Fill(Rapidity(tpcTrack->Px(),tpcTrack->Py(),tpcTrack->Pz()),Pt);
400         }//proton check
401       }//TPC only tracks
402       else if(!fUseTPCOnly) {
403         Pt = track->Pt();
404         P = track->P();
405         
406         //pid
407         track->GetESDpid(probability);
408         Double_t rcc = 0.0;
409         for(Int_t i = 0; i < AliPID::kSPECIES; i++) 
410           rcc += probability[i]*GetParticleFraction(i,P);
411         if(rcc == 0.0) continue;
412         Double_t w[5];
413         for(Int_t i = 0; i < AliPID::kSPECIES; i++) 
414           w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
415         Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
416         if(fParticleType == 4) {
417           //cout<<"(Anti)protons found..."<<endl;
418           if(track->Charge() > 0) 
419             fHistYPtProtons->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
420           else if(track->Charge() < 0) 
421             fHistYPtAntiProtons->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
422         }//proton check 
423       }//combined tracking
424     }//cuts
425   }//track loop 
426 }
427
428 //____________________________________________________________________//
429 void AliProtonAnalysis::Analyze(AliAODEvent* fAOD) {
430   //Main analysis part - AOD
431   fHistEvents->Fill(0); //number of analyzed events
432   Int_t nGoodTracks = fAOD->GetNumberOfTracks();
433   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
434     AliAODTrack* track = fAOD->GetTrack(iTracks);
435     Double_t Pt = track->Pt();
436     Double_t P = track->P();
437     
438     //pid
439     Double_t probability[10];
440     track->GetPID(probability);
441     Double_t rcc = 0.0;
442     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) rcc += probability[i]*GetParticleFraction(i,P);
443     if(rcc == 0.0) continue;
444     Double_t w[10];
445     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
446     Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIESN,w);
447     if(fParticleType == 4) {
448       if(track->Charge() > 0) fHistYPtProtons->Fill(track->Y(fParticleType),Pt);
449       else if(track->Charge() < 0) fHistYPtAntiProtons->Fill(track->Y(fParticleType),Pt);
450     }//proton check
451   }//track loop 
452 }
453
454 //____________________________________________________________________//
455 void AliProtonAnalysis::Analyze(AliStack* stack) {
456   //Main analysis part - MC
457   fHistEvents->Fill(0); //number of analyzed events
458   for(Int_t i = 0; i < stack->GetNprimary(); i++) {
459     TParticle *particle = stack->Particle(i);
460     if(particle->Pt() < 0.1) continue;
461     if(TMath::Abs(particle->Eta()) > 1.0) continue;
462     Int_t pdgcode = particle->GetPdgCode();
463     if(pdgcode == 2212) fHistYPtProtons->Fill(Rapidity(particle->Px(),
464                                                        particle->Py(),
465                                                        particle->Pz()),
466                                               particle->Pt());
467     if(pdgcode == -2212) fHistYPtAntiProtons->Fill(Rapidity(particle->Px(),
468                                                             particle->Py(),
469                                                             particle->Pz()),
470                                                    particle->Pt());
471   }//particle loop                                                                  
472 }
473
474 //____________________________________________________________________//
475 Bool_t AliProtonAnalysis::IsAccepted(AliESDtrack* track) {
476   // Checks if the track is excluded from the cuts
477   Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
478   if(fUseTPCOnly) {
479     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
480     if(!tpcTrack) {
481       Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
482     }
483     else {
484       Pt = tpcTrack->Pt();
485       Px = tpcTrack->Px();
486       Py = tpcTrack->Py();
487       Pz = tpcTrack->Pz();
488     }
489   }
490   else{
491     Pt = track->Pt();
492     Px = track->Px();
493     Py = track->Py();
494     Pz = track->Pz();
495   }
496      
497   Int_t  fIdxInt[200];
498   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
499   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
500
501   Float_t chi2PerClusterITS = -1;
502   if (nClustersITS!=0)
503     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
504   Float_t chi2PerClusterTPC = -1;
505   if (nClustersTPC!=0)
506     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
507
508   Double_t extCov[15];
509   track->GetExternalCovariance(extCov);
510
511   if(fMinITSClustersFlag)
512     if(nClustersITS < fMinITSClusters) return kFALSE;
513   if(fMaxChi2PerITSClusterFlag)
514     if(chi2PerClusterITS > fMaxChi2PerITSCluster) return kFALSE; 
515   if(fMinTPCClustersFlag)
516     if(nClustersTPC < fMinTPCClusters) return kFALSE;
517   if(fMaxChi2PerTPCClusterFlag)
518     if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) return kFALSE; 
519   if(fMaxCov11Flag)
520     if(extCov[0] > fMaxCov11) return kFALSE;
521   if(fMaxCov22Flag)
522     if(extCov[2] > fMaxCov22) return kFALSE;
523   if(fMaxCov33Flag)
524     if(extCov[5] > fMaxCov33) return kFALSE;
525   if(fMaxCov44Flag)
526     if(extCov[9] > fMaxCov44) return kFALSE;
527   if(fMaxCov55Flag)
528     if(extCov[14] > fMaxCov55) return kFALSE;
529   if(fMaxSigmaToVertexFlag)
530     if(GetSigmaToVertex(track) > fMaxSigmaToVertex) return kFALSE;
531   if(fMaxSigmaToVertexTPCFlag)
532     if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) return kFALSE;
533   if(fITSRefitFlag)
534     if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) return kFALSE;
535   if(fTPCRefitFlag)
536     if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) return kFALSE;
537   if(fESDpidFlag)
538     if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) return kFALSE;
539   if(fTPCpidFlag)
540     if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) return kFALSE;
541
542   if((Pt < fMinPt) || (Pt > fMaxPt)) return kFALSE;
543   if((Rapidity(Px,Py,Pz) < fMinY) || (Rapidity(Px,Py,Pz) > fMaxY)) return kFALSE;
544
545   return kTRUE;
546 }
547
548 //____________________________________________________________________//
549 Bool_t AliProtonAnalysis::IsAccepted(AliESDtrack* track, AliStack *stack) {
550   // Checks if the track is excluded from the cuts
551   Bool_t status = kTRUE;
552   Int_t nPrimaries = stack->GetNprimary();
553   Int_t label = TMath::Abs(track->GetLabel());
554
555   Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
556   if(fUseTPCOnly) {
557     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
558     if(!tpcTrack) {
559       Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
560     }
561     else {
562       Pt = tpcTrack->Pt();
563       Px = tpcTrack->Px();
564       Py = tpcTrack->Py();
565       Pz = tpcTrack->Pz();
566     }
567   }
568   else{
569     Pt = track->Pt();
570     Px = track->Px();
571     Py = track->Py();
572     Pz = track->Pz();
573   }
574      
575   Int_t  fIdxInt[200];
576   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
577   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
578
579   Float_t chi2PerClusterITS = -1;
580   if (nClustersITS!=0)
581     chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
582   Float_t chi2PerClusterTPC = -1;
583   if (nClustersTPC!=0)
584     chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
585
586   Double_t extCov[15];
587   track->GetExternalCovariance(extCov);
588   
589   //protons
590   if(track->Charge() > 0) {
591     //Primaries
592     if(label <= nPrimaries) {
593       if(fMinITSClustersFlag) {
594         if(nClustersITS < fMinITSClusters) {
595           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
596           status = kFALSE;
597         }
598         else if(nClustersITS >= fMinITSClusters) 
599           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
600       }//ITS clusters
601       if(fMaxChi2PerITSClusterFlag) {
602         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
603           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
604           status = kFALSE;
605         }
606         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
607           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
608       }//chi2 per ITS cluster
609       if(fMinTPCClustersFlag) {
610         if(nClustersTPC < fMinTPCClusters) {
611           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
612           status = kFALSE;
613         }
614         else if(nClustersTPC >= fMinTPCClusters)
615           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
616       }//TPC clusters
617       if(fMaxChi2PerTPCClusterFlag) {
618         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
619           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
620           status = kFALSE;
621         }
622         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
623           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
624       }//chi2 per TPC cluster
625       if(fMaxCov11Flag) {
626         if(extCov[0] > fMaxCov11) {
627           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
628           status = kFALSE;
629         }
630         else if(extCov[0] <= fMaxCov11)
631           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
632       }//cov11
633       if(fMaxCov22Flag) {
634         if(extCov[2] > fMaxCov22) {
635           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
636           status = kFALSE;
637         }
638         else if(extCov[2] <= fMaxCov22)
639           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
640       }//cov11
641       if(fMaxCov33Flag) {
642         if(extCov[5] > fMaxCov33) {
643           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
644           status = kFALSE;
645         }
646         else if(extCov[5] <= fMaxCov33)
647           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
648       }//cov11
649       if(fMaxCov44Flag) {
650         if(extCov[9] > fMaxCov44) {
651           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
652           status = kFALSE;
653         }
654         else if(extCov[9] <= fMaxCov44)
655           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
656       }//cov11
657       if(fMaxCov55Flag) {
658         if(extCov[14] > fMaxCov55) {
659           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
660           status = kFALSE;
661         }
662         else if(extCov[14] <= fMaxCov55)
663           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
664       }//cov55
665       if(fMaxSigmaToVertexFlag) {
666         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
667           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
668           status = kFALSE;
669         }
670         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
671           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
672       }//sigma to vertex
673       if(fMaxSigmaToVertexTPCFlag) {
674         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
675           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
676           status = kFALSE;
677         }
678         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
679           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
680       }//sigma to vertex TPC
681       if(fITSRefitFlag) {
682         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
683           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(11)))->Fill(0);
684         status = kFALSE;
685         }
686         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
687           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(11)))->Fill(0);
688       }//ITS refit
689       if(fTPCRefitFlag) {
690         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
691           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(12)))->Fill(0);
692           status = kFALSE;
693         }
694         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
695           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(12)))->Fill(0);
696       }//TPC refit
697       if(fESDpidFlag) {
698         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
699           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(13)))->Fill(0);
700           status = kFALSE;
701         }
702         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
703           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(13)))->Fill(0);
704       }//ESD pid
705       if(fTPCpidFlag) {
706         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
707           ((TH1F *)(fQAPrimaryProtonsRejectedList->At(13)))->Fill(0);
708           status = kFALSE;
709         }
710         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
711           ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(13)))->Fill(0);
712       }//TPC pid
713     }//primary particle cut
714
715     //Secondaries
716     if(label > nPrimaries) {
717       if(fMinITSClustersFlag) {
718         if(nClustersITS < fMinITSClusters) {
719           ((TH1F *)(fQASecondaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
720           status = kFALSE;
721         }
722         else if(nClustersITS >= fMinITSClusters) 
723           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
724       }//ITS clusters
725       if(fMaxChi2PerITSClusterFlag) {
726         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
727           ((TH1F *)(fQASecondaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
728           status = kFALSE;
729         }
730         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
731           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
732       }//chi2 per ITS cluster
733       if(fMinTPCClustersFlag) {
734         if(nClustersTPC < fMinTPCClusters) {
735           ((TH1F *)(fQASecondaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
736           status = kFALSE;
737         }
738         else if(nClustersTPC >= fMinTPCClusters)
739           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
740       }//TPC clusters
741       if(fMaxChi2PerTPCClusterFlag) {
742         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
743           ((TH1F *)(fQASecondaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
744           status = kFALSE;
745         }
746         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
747           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
748       }//chi2 per TPC cluster
749       if(fMaxCov11Flag) {
750         if(extCov[0] > fMaxCov11) {
751           ((TH1F *)(fQASecondaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
752           status = kFALSE;
753         }
754         else if(extCov[0] <= fMaxCov11)
755           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
756       }//cov11
757       if(fMaxCov22Flag) {
758         if(extCov[2] > fMaxCov22) {
759           ((TH1F *)(fQASecondaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
760           status = kFALSE;
761         }
762         else if(extCov[2] <= fMaxCov22)
763           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
764       }//cov11
765       if(fMaxCov33Flag) {
766         if(extCov[5] > fMaxCov33) {
767           ((TH1F *)(fQASecondaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
768           status = kFALSE;
769         }
770         else if(extCov[5] <= fMaxCov33)
771           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
772       }//cov11
773       if(fMaxCov44Flag) {
774         if(extCov[9] > fMaxCov44) {
775           ((TH1F *)(fQASecondaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
776           status = kFALSE;
777         }
778         else if(extCov[9] <= fMaxCov44)
779           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
780       }//cov11
781       if(fMaxCov55Flag) {
782         if(extCov[14] > fMaxCov55) {
783           ((TH1F *)(fQASecondaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
784           status = kFALSE;
785         }
786         else if(extCov[14] <= fMaxCov55)
787           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
788       }//cov55
789       if(fMaxSigmaToVertexFlag) {
790         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
791           ((TH1F *)(fQASecondaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
792           status = kFALSE;
793         }
794         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
795           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
796       }//sigma to vertex
797       if(fMaxSigmaToVertexTPCFlag) {
798         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
799           ((TH1F *)(fQASecondaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
800           status = kFALSE;
801         }
802         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
803           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
804       }//sigma to vertex TPC
805       if(fITSRefitFlag) {
806         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
807           ((TH1F *)(fQASecondaryProtonsRejectedList->At(11)))->Fill(0);
808         status = kFALSE;
809         }
810         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
811           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(11)))->Fill(0);
812       }//ITS refit
813       if(fTPCRefitFlag) {
814         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
815           ((TH1F *)(fQASecondaryProtonsRejectedList->At(12)))->Fill(0);
816           status = kFALSE;
817         }
818         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
819           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(12)))->Fill(0);
820       }//TPC refit
821       if(fESDpidFlag) {
822         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
823           ((TH1F *)(fQASecondaryProtonsRejectedList->At(13)))->Fill(0);
824           status = kFALSE;
825         }
826         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
827           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(13)))->Fill(0);
828       }//ESD pid
829       if(fTPCpidFlag) {
830         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
831           ((TH1F *)(fQASecondaryProtonsRejectedList->At(13)))->Fill(0);
832           status = kFALSE;
833         }
834         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
835           ((TH1F *)(fQASecondaryProtonsAcceptedList->At(13)))->Fill(0);
836       }//TPC pid
837     }//secondary particle cut
838   }//protons
839
840   //antiprotons
841   if(track->Charge() < 0) {
842     //Primaries
843     if(label <= nPrimaries) {
844       if(fMinITSClustersFlag) {
845         if(nClustersITS < fMinITSClusters) {
846           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
847           status = kFALSE;
848         }
849         else if(nClustersITS >= fMinITSClusters) 
850           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
851       }//ITS clusters
852       if(fMaxChi2PerITSClusterFlag) {
853         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
854           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
855           status = kFALSE;
856         }
857         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
858           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
859       }//chi2 per ITS cluster
860       if(fMinTPCClustersFlag) {
861         if(nClustersTPC < fMinTPCClusters) {
862           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
863           status = kFALSE;
864         }
865         else if(nClustersTPC >= fMinTPCClusters)
866           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
867       }//TPC clusters
868       if(fMaxChi2PerTPCClusterFlag) {
869         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
870           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
871           status = kFALSE;
872         }
873         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
874           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
875       }//chi2 per TPC cluster
876       if(fMaxCov11Flag) {
877         if(extCov[0] > fMaxCov11) {
878           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
879           status = kFALSE;
880         }
881         else if(extCov[0] <= fMaxCov11)
882           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
883       }//cov11
884       if(fMaxCov22Flag) {
885         if(extCov[2] > fMaxCov22) {
886           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
887           status = kFALSE;
888         }
889         else if(extCov[2] <= fMaxCov22)
890           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
891       }//cov11
892       if(fMaxCov33Flag) {
893         if(extCov[5] > fMaxCov33) {
894           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
895           status = kFALSE;
896         }
897         else if(extCov[5] <= fMaxCov33)
898           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
899       }//cov11
900       if(fMaxCov44Flag) {
901         if(extCov[9] > fMaxCov44) {
902           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
903           status = kFALSE;
904         }
905         else if(extCov[9] <= fMaxCov44)
906           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
907       }//cov11
908       if(fMaxCov55Flag) {
909         if(extCov[14] > fMaxCov55) {
910           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
911           status = kFALSE;
912         }
913         else if(extCov[14] <= fMaxCov55)
914           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
915       }//cov55
916       if(fMaxSigmaToVertexFlag) {
917         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
918           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
919           status = kFALSE;
920         }
921         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
922           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
923       }//sigma to vertex
924       if(fMaxSigmaToVertexTPCFlag) {
925         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
926           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
927           status = kFALSE;
928         }
929         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
930           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
931       }//sigma to vertex TPC
932       if(fITSRefitFlag) {
933         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
934           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(11)))->Fill(0);
935         status = kFALSE;
936         }
937         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
938           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(11)))->Fill(0);
939       }//ITS refit
940       if(fTPCRefitFlag) {
941         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
942           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(12)))->Fill(0);
943           status = kFALSE;
944         }
945         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
946           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(12)))->Fill(0);
947       }//TPC refit
948       if(fESDpidFlag) {
949         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
950           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(13)))->Fill(0);
951           status = kFALSE;
952         }
953         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
954           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(13)))->Fill(0);
955       }//ESD pid
956       if(fTPCpidFlag) {
957         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
958           ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(13)))->Fill(0);
959           status = kFALSE;
960         }
961         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
962           ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(13)))->Fill(0);
963       }//TPC pid
964     }//primary particle cut
965
966     //Secondaries
967     if(label > nPrimaries) {
968       if(fMinITSClustersFlag) {
969         if(nClustersITS < fMinITSClusters) {
970           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
971           status = kFALSE;
972         }
973         else if(nClustersITS >= fMinITSClusters) 
974           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
975       }//ITS clusters
976       if(fMaxChi2PerITSClusterFlag) {
977         if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
978           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
979           status = kFALSE;
980         }
981         else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
982           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
983       }//chi2 per ITS cluster
984       if(fMinTPCClustersFlag) {
985         if(nClustersTPC < fMinTPCClusters) {
986           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
987           status = kFALSE;
988         }
989         else if(nClustersTPC >= fMinTPCClusters)
990           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
991       }//TPC clusters
992       if(fMaxChi2PerTPCClusterFlag) {
993         if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
994           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
995           status = kFALSE;
996         }
997         else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
998           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
999       }//chi2 per TPC cluster
1000       if(fMaxCov11Flag) {
1001         if(extCov[0] > fMaxCov11) {
1002           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
1003           status = kFALSE;
1004         }
1005         else if(extCov[0] <= fMaxCov11)
1006           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
1007       }//cov11
1008       if(fMaxCov22Flag) {
1009         if(extCov[2] > fMaxCov22) {
1010           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
1011           status = kFALSE;
1012         }
1013         else if(extCov[2] <= fMaxCov22)
1014           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
1015       }//cov11
1016       if(fMaxCov33Flag) {
1017         if(extCov[5] > fMaxCov33) {
1018           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
1019           status = kFALSE;
1020         }
1021         else if(extCov[5] <= fMaxCov33)
1022           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
1023       }//cov11
1024       if(fMaxCov44Flag) {
1025         if(extCov[9] > fMaxCov44) {
1026           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
1027           status = kFALSE;
1028         }
1029         else if(extCov[9] <= fMaxCov44)
1030           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
1031       }//cov11
1032       if(fMaxCov55Flag) {
1033         if(extCov[14] > fMaxCov55) {
1034           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
1035           status = kFALSE;
1036         }
1037         else if(extCov[14] <= fMaxCov55)
1038           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
1039       }//cov55
1040       if(fMaxSigmaToVertexFlag) {
1041         if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
1042           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
1043           status = kFALSE;
1044         }
1045         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
1046           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
1047       }//sigma to vertex
1048       if(fMaxSigmaToVertexTPCFlag) {
1049         if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
1050           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
1051           status = kFALSE;
1052         }
1053         else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
1054           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
1055       }//sigma to vertex TPC
1056       if(fITSRefitFlag) {
1057         if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
1058           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(11)))->Fill(0);
1059         status = kFALSE;
1060         }
1061         else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
1062           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(11)))->Fill(0);
1063       }//ITS refit
1064       if(fTPCRefitFlag) {
1065         if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
1066           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(12)))->Fill(0);
1067           status = kFALSE;
1068         }
1069         else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
1070           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(12)))->Fill(0);
1071       }//TPC refit
1072       if(fESDpidFlag) {
1073         if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
1074           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(13)))->Fill(0);
1075           status = kFALSE;
1076         }
1077         else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
1078           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(13)))->Fill(0);
1079       }//ESD pid
1080       if(fTPCpidFlag) {
1081         if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
1082           ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(13)))->Fill(0);
1083           status = kFALSE;
1084         }
1085         else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
1086           ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(13)))->Fill(0);
1087       }//TPC pid
1088     }//secondary particle cut
1089   }//antiprotons
1090
1091   if((Pt < fMinPt) || (Pt > fMaxPt)) status = kFALSE;
1092   if((Rapidity(Px,Py,Pz) < fMinY) || (Rapidity(Px,Py,Pz) > fMaxY)) status = kFALSE;
1093
1094   return status;
1095 }
1096
1097 //____________________________________________________________________//
1098 Float_t AliProtonAnalysis::GetSigmaToVertex(AliESDtrack* esdTrack) {
1099   // Calculates the number of sigma to the vertex.
1100   
1101   Float_t b[2];
1102   Float_t bRes[2];
1103   Float_t bCov[3];
1104   if(fUseTPCOnly) 
1105     esdTrack->GetImpactParametersTPC(b,bCov);
1106   else
1107     esdTrack->GetImpactParameters(b,bCov);
1108   
1109   if (bCov[0]<=0 || bCov[2]<=0) {
1110     //AliDebug(1, "Estimated b resolution lower or equal zero!");
1111     bCov[0]=0; bCov[2]=0;
1112   }
1113   bRes[0] = TMath::Sqrt(bCov[0]);
1114   bRes[1] = TMath::Sqrt(bCov[2]);
1115   
1116   if (bRes[0] == 0 || bRes[1] ==0) return -1;
1117   
1118   Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
1119   
1120   if (TMath::Exp(-d * d / 2) < 1e-10) return 1000;
1121   
1122   d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
1123   
1124   return d;
1125 }
1126
1127 //____________________________________________________________________//
1128 Double_t AliProtonAnalysis::Rapidity(Double_t Px, Double_t Py, Double_t Pz) {
1129   //returns the rapidity of the proton - to be removed
1130   Double_t fMass = 9.38270000000000048e-01;
1131   
1132   Double_t P = TMath::Sqrt(TMath::Power(Px,2) + 
1133                            TMath::Power(Py,2) + 
1134                            TMath::Power(Pz,2));
1135   Double_t energy = TMath::Sqrt(P*P + fMass*fMass);
1136   Double_t y = -999;
1137   if(energy != Pz) 
1138     y = 0.5*TMath::Log((energy + Pz)/(energy - Pz));
1139
1140   return y;
1141 }
1142
1143 //____________________________________________________________________//
1144 Bool_t AliProtonAnalysis::PrintMean(TH1 *hist, Double_t edge) {
1145   //calculates the mean value of the ratio/asymmetry within \pm edge
1146   Double_t sum = 0.0;
1147   Int_t nentries = 0;
1148   //calculate the mean
1149   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1150     Double_t x = hist->GetBinCenter(i+1);
1151     Double_t y = hist->GetBinContent(i+1);
1152     if(TMath::Abs(x) < edge) {
1153       sum += y;
1154       nentries += 1;
1155     }
1156   }
1157   Double_t mean = 0.0;
1158   if(nentries != 0)
1159     mean = sum/nentries;
1160
1161   //calculate the error
1162   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1163     Double_t x = hist->GetBinCenter(i+1);
1164     Double_t y = hist->GetBinContent(i+1);
1165     if(TMath::Abs(x) < edge) {
1166       sum += TMath::Power((mean - y),2);
1167       nentries += 1;
1168     }
1169   }
1170
1171   Double_t error = 0.0;
1172   if(nentries != 0)
1173     error =  TMath::Sqrt(sum)/nentries;
1174
1175   cout<<"========================================="<<endl;
1176   cout<<"Input distribution: "<<hist->GetName()<<endl;
1177   cout<<"Interval used: -"<<edge<<" -> "<<edge<<endl;
1178   cout<<"Mean value :"<<mean<<endl;
1179   cout<<"Error: "<<error<<endl;
1180   cout<<"========================================="<<endl;
1181
1182   return 0;
1183 }
1184
1185 //____________________________________________________________________//
1186 Bool_t AliProtonAnalysis::PrintYields(TH1 *hist, Double_t edge) {
1187   //calculates the (anti)proton yields within the \pm edge
1188   Double_t sum = 0.0, sumerror = 0.0;
1189   Double_t error = 0.0;
1190   for(Int_t i = 0; i < hist->GetXaxis()->GetNbins(); i++) {
1191     Double_t x = hist->GetBinCenter(i+1);
1192     Double_t y = hist->GetBinContent(i+1);
1193     if(TMath::Abs(x) < edge) {
1194       sum += y;
1195       sumerror += TMath::Power(hist->GetBinError(i+1),2); 
1196     }
1197   }
1198
1199   error = TMath::Sqrt(sumerror);
1200
1201   cout<<"========================================="<<endl;
1202   cout<<"Input distribution: "<<hist->GetName()<<endl;
1203   cout<<"Interval used: -"<<edge<<" -> "<<edge<<endl;
1204   cout<<"Yields :"<<sum<<endl;
1205   cout<<"Error: "<<error<<endl;
1206   cout<<"========================================="<<endl;
1207
1208   return 0;
1209 }
1210
1211 //____________________________________________________________________//
1212 Bool_t AliProtonAnalysis::ReadCorrectionContainer(const char* filename) {
1213   // Reads the outout of the correction framework task
1214   // Creates the correction maps
1215   // Puts the results in the different TList objects
1216   Bool_t status = kTRUE;
1217
1218   TFile *file = TFile::Open(filename);
1219   if(!file) {
1220     cout<<"Could not find the input CORRFW file "<<filename<<endl;
1221     status = kFALSE;
1222   }
1223
1224   AliCFContainer *corrfwContainer = (AliCFContainer*) (file->Get("container"));
1225   if(!corrfwContainer) {
1226     cout<<"CORRFW container not found!"<<endl;
1227     status = kFALSE;
1228   }
1229   
1230   Int_t nSteps = corrfwContainer->GetNStep();
1231   TH2D *gYPt[4];
1232   //currently the GRID is formed by the y-pT parameters
1233   //Add Vz as a next step
1234   Int_t iRap = 0, iPt = 1;
1235   for(Int_t iStep = 0; iStep < nSteps; iStep++) {
1236     gYPt[iStep] = corrfwContainer->ShowProjection(iRap,iPt,iStep);
1237     //fCorrectionList2D->Add(gYPt[iStep]);
1238   }
1239
1240   //construct the efficiency grid from the data container                                           
1241   TString gTitle = 0;
1242   AliCFEffGrid *efficiency[3]; //The efficiency array has nStep-1 entries!!!
1243   TH1D *gEfficiency[2][3]; //efficiency as a function of pT and of y (raws - [2]) 
1244   TH1D *gCorrection[2][3]; //efficiency as a function of pT and of y (raws - [2]) 
1245
1246   //Get the 2D efficiency maps
1247   for(Int_t iStep = 1; iStep < nSteps; iStep++) { 
1248     gTitle = "Efficiency_Step0_Step"; gTitle += iStep; 
1249     efficiency[iStep] = new AliCFEffGrid(gTitle.Data(),
1250                                          gTitle.Data(),*corrfwContainer);
1251     efficiency[iStep]->CalculateEfficiency(iStep,0); //eff= step[i]/step0
1252     fCorrectionList2D->Add(efficiency[iStep]);  
1253   }
1254   //Get the projection of the efficiency maps
1255   for(Int_t iParameter = 0; iParameter < 2; iParameter++) { 
1256     for(Int_t iStep = 1; iStep < nSteps; iStep++) { 
1257       gEfficiency[iParameter][iStep-1] = efficiency[iStep]->Project(iParameter);
1258       fEfficiencyList1D->Add(gEfficiency[iParameter][iStep-1]);  
1259       gTitle = "Correction_Parameter"; gTitle += iParameter+1;
1260       gTitle += "_Step0_Step"; gTitle += iStep; 
1261       gCorrection[iParameter][iStep-1] = new TH1D(gTitle.Data(),
1262                                                    gTitle.Data(),
1263                                                    gEfficiency[iParameter][iStep-1]->GetNbinsX(),
1264                                                    gEfficiency[iParameter][iStep-1]->GetXaxis()->GetXmin(),
1265                                                    gEfficiency[iParameter][iStep-1]->GetXaxis()->GetXmax());
1266       //initialisation of the correction
1267       for(Int_t iBin = 1; iBin <= gEfficiency[iParameter][iStep-1]->GetNbinsX(); iBin++)
1268         gCorrection[iParameter][iStep-1]->SetBinContent(iBin,1.0);
1269     }//step loop
1270   }//parameter loop
1271   //Calculate the 1D correction parameters as a function of y and pT
1272   for(Int_t iParameter = 0; iParameter < 2; iParameter++) { 
1273     for(Int_t iStep = 1; iStep < nSteps; iStep++) { 
1274       gCorrection[iParameter][iStep-1]->Divide(gEfficiency[iParameter][iStep-1]);
1275       fCorrectionList1D->Add(gCorrection[iParameter][iStep-1]);  
1276     }
1277   }
1278
1279   return status;
1280 }
1281
1282 //____________________________________________________________________//
1283 void AliProtonAnalysis::InitQA() {
1284   //Initializes the QA histograms and builds the directory structure
1285   if(!fQAHistograms) SetQAOn();
1286
1287   //2D histograms
1288   TDirectory *dir2D = gDirectory->mkdir("2D");
1289   fGlobalQAList->Add(dir2D); dir2D->cd();
1290   TH2F *gHistYPtPrimaryProtonsPass = new TH2F("gHistYPtPrimaryProtonsPass",
1291                                               ";y;P_{T} [GeV/c]",
1292                                               fNBinsY,fMinY,fMaxY,
1293                                               fNBinsPt,fMinPt,fMaxPt);
1294   gHistYPtPrimaryProtonsPass->SetStats(kTRUE);
1295   gHistYPtPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
1296   fQA2DList->Add(gHistYPtPrimaryProtonsPass);
1297   TH2F *gHistYPtPrimaryAntiProtonsPass = new TH2F("gHistYPtAntiPrimaryProtonsPass",
1298                                                   ";y;P_{T} [GeV/c]",
1299                                                   fNBinsY,fMinY,fMaxY,
1300                                                   fNBinsPt,fMinPt,fMaxPt);
1301   gHistYPtPrimaryAntiProtonsPass->SetStats(kTRUE);
1302   gHistYPtPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
1303   fQA2DList->Add(gHistYPtPrimaryAntiProtonsPass);
1304   TH2F *gHistYPtSecondaryProtonsPass = new TH2F("gHistYPtSecondaryAntiProtonsPass",
1305                                                 ";y;P_{T} [GeV/c]",
1306                                                 fNBinsY,fMinY,fMaxY,
1307                                                 fNBinsPt,fMinPt,fMaxPt);
1308   gHistYPtSecondaryProtonsPass->SetStats(kTRUE);
1309   gHistYPtSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
1310   fQA2DList->Add(gHistYPtSecondaryProtonsPass);
1311   TH2F *gHistYPtSecondaryAntiAntiProtonsPass = new TH2F("gHistYPtAntiSecondaryAntiProtonsPass",
1312                                                         ";y;P_{T} [GeV/c]",
1313                                                         fNBinsY,fMinY,fMaxY,
1314                                                         fNBinsPt,fMinPt,fMaxPt);
1315   gHistYPtSecondaryAntiAntiProtonsPass->SetStats(kTRUE);
1316   gHistYPtSecondaryAntiAntiProtonsPass->GetXaxis()->SetTitleColor(1);
1317   fQA2DList->Add(gHistYPtSecondaryAntiAntiProtonsPass);
1318   
1319   gDirectory->cd("../");
1320   //protons
1321   TDirectory *dirProtons = gDirectory->mkdir("Protons");
1322   fGlobalQAList->Add(dirProtons); dirProtons->cd();
1323   
1324   //________________________________________________________________//
1325   TDirectory *dirProtonsPrimary = gDirectory->mkdir("Primaries");
1326   dirProtonsPrimary->cd();
1327   TDirectory *dirProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
1328   dirProtonsPrimaryAccepted->cd();
1329
1330   //Accepted primary protons
1331   TH1F *fPrimaryProtonsITSClustersPass = new TH1F("fPrimaryProtonsITSClustersPass",
1332                                             ";N_{clusters} (ITS);Entries",
1333                                             7,0,7);
1334   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsITSClustersPass);
1335   TH1F *fPrimaryProtonsChi2PerClusterITSPass = new TH1F("fPrimaryProtonsChi2PerClusterITSPass",
1336                                                   ";x^{2}/N_{clusters} (ITS);Entries",
1337                                                   100,0,4);
1338   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsChi2PerClusterITSPass);
1339   TH1F *fPrimaryProtonsTPCClustersPass = new TH1F("fPrimaryProtonsTPCClustersPass",
1340                                             ";N_{clusters} (TPC);Entries",
1341                                             100,0,200);
1342   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsTPCClustersPass);
1343   TH1F *fPrimaryProtonsChi2PerClusterTPCPass = new TH1F("fPrimaryProtonsChi2PerClusterTPCPass",
1344                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1345                                                   100,0,4);
1346   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsChi2PerClusterTPCPass);
1347   TH1F *fPrimaryProtonsExtCov11Pass = new TH1F("fPrimaryProtonsExtCov11Pass",
1348                                          ";#sigma_{y} [cm];Entries",
1349                                          100,0,4);
1350   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov11Pass);
1351   TH1F *fPrimaryProtonsExtCov22Pass = new TH1F("fPrimaryProtonsExtCov22Pass",
1352                                          ";#sigma_{z} [cm];Entries",
1353                                          100,0,4);
1354   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov22Pass);
1355   TH1F *fPrimaryProtonsExtCov33Pass = new TH1F("fPrimaryProtonsExtCov33Pass",
1356                                          ";#sigma_{sin(#phi)};Entries",
1357                                          100,0,4);
1358   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov33Pass);
1359   TH1F *fPrimaryProtonsExtCov44Pass = new TH1F("fPrimaryProtonsExtCov44Pass",
1360                                          ";#sigma_{tan(#lambda)};Entries",
1361                                          100,0,4);
1362   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov44Pass);
1363   TH1F *fPrimaryProtonsExtCov55Pass = new TH1F("fPrimaryProtonsExtCov55Pass",
1364                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1365                                          100,0,4);
1366   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsExtCov55Pass);
1367   TH1F *fPrimaryProtonsSigmaToVertexPass = new TH1F("fPrimaryProtonsSigmaToVertexPass",
1368                                              ";#sigma_{Vertex};Entries",
1369                                              100,0,10);
1370   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsSigmaToVertexPass);
1371   TH1F *fPrimaryProtonsSigmaToVertexTPCPass = new TH1F("fPrimaryProtonsSigmaToVertexTPCPass",
1372                                              ";#sigma_{Vertex};Entries",
1373                                              100,0,10);
1374   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsSigmaToVertexTPCPass);
1375   TH1F *fPrimaryProtonsITSRefitPass = new TH1F("fPrimaryProtonsITSRefitPass",
1376                                          "",10,-1,1);
1377   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsITSRefitPass);
1378   TH1F *fPrimaryProtonsTPCRefitPass = new TH1F("fPrimaryProtonsTPCRefitPass",
1379                                          "",10,-1,1);
1380   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsTPCRefitPass);
1381   TH1F *fPrimaryProtonsESDpidPass = new TH1F("fPrimaryProtonsESDpidPass",
1382                                        "",10,-1,1);
1383   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsESDpidPass);
1384   TH1F *fPrimaryProtonsTPCpidPass = new TH1F("fPrimaryProtonsTPCpidPass",
1385                                        "",10,-1,1);
1386   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsTPCpidPass);
1387
1388   //Rejected primary protons
1389   gDirectory->cd("../");
1390   TDirectory *dirProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
1391   dirProtonsPrimaryRejected->cd();
1392
1393   TH1F *fPrimaryProtonsITSClustersReject = new TH1F("fPrimaryProtonsITSClustersReject",
1394                                                     ";N_{clusters} (ITS);Entries",
1395                                                     7,0,7);
1396   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsITSClustersReject);
1397   TH1F *fPrimaryProtonsChi2PerClusterITSReject = new TH1F("fPrimaryProtonsChi2PerClusterITSReject",
1398                                                           ";x^{2}/N_{clusters} (ITS);Entries",
1399                                                           100,0,4);
1400   fQAPrimaryProtonsAcceptedList->Add(fPrimaryProtonsChi2PerClusterITSReject);
1401   TH1F *fPrimaryProtonsTPCClustersReject = new TH1F("fPrimaryProtonsTPCClustersReject",
1402                                             ";N_{clusters} (TPC);Entries",
1403                                             100,0,200);
1404   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsTPCClustersReject);
1405   TH1F *fPrimaryProtonsChi2PerClusterTPCReject = new TH1F("fPrimaryProtonsChi2PerClusterTPCReject",
1406                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1407                                                   100,0,4);
1408   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsChi2PerClusterTPCReject);
1409   TH1F *fPrimaryProtonsExtCov11Reject = new TH1F("fPrimaryProtonsExtCov11Reject",
1410                                          ";#sigma_{y} [cm];Entries",
1411                                          100,0,4);
1412   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov11Reject);
1413   TH1F *fPrimaryProtonsExtCov22Reject = new TH1F("fPrimaryProtonsExtCov22Reject",
1414                                          ";#sigma_{z} [cm];Entries",
1415                                          100,0,4);
1416   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov22Reject);
1417   TH1F *fPrimaryProtonsExtCov33Reject = new TH1F("fPrimaryProtonsExtCov33Reject",
1418                                          ";#sigma_{sin(#phi)};Entries",
1419                                          100,0,4);
1420   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov33Reject);
1421   TH1F *fPrimaryProtonsExtCov44Reject = new TH1F("fPrimaryProtonsExtCov44Reject",
1422                                          ";#sigma_{tan(#lambda)};Entries",
1423                                          100,0,4);
1424   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov44Reject);
1425   TH1F *fPrimaryProtonsExtCov55Reject = new TH1F("fPrimaryProtonsExtCov55Reject",
1426                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1427                                          100,0,4);
1428   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsExtCov55Reject);
1429   TH1F *fPrimaryProtonsSigmaToVertexReject = new TH1F("fPrimaryProtonsSigmaToVertexReject",
1430                                              ";#sigma_{Vertex};Entries",
1431                                              100,0,10);
1432   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsSigmaToVertexReject);
1433   TH1F *fPrimaryProtonsSigmaToVertexTPCReject = new TH1F("fPrimaryProtonsSigmaToVertexTPCReject",
1434                                              ";#sigma_{Vertex};Entries",
1435                                              100,0,10);
1436   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsSigmaToVertexTPCReject);
1437   TH1F *fPrimaryProtonsITSRefitReject = new TH1F("fPrimaryProtonsITSRefitReject",
1438                                          "",10,-1,1);
1439   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsITSRefitReject);
1440   TH1F *fPrimaryProtonsTPCRefitReject = new TH1F("fPrimaryProtonsTPCRefitReject",
1441                                          "",10,-1,1);
1442   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsTPCRefitReject);
1443   TH1F *fPrimaryProtonsESDpidReject = new TH1F("fPrimaryProtonsESDpidReject",
1444                                        "",10,-1,1);
1445   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsESDpidReject);
1446   TH1F *fPrimaryProtonsTPCpidReject = new TH1F("fPrimaryProtonsTPCpidReject",
1447                                        "",10,-1,1);
1448   fQAPrimaryProtonsRejectedList->Add(fPrimaryProtonsTPCpidReject);
1449
1450   //________________________________________________________________//
1451   gDirectory->cd("../../");
1452
1453   TDirectory *dirProtonsSecondary = gDirectory->mkdir("Secondaries");
1454   dirProtonsSecondary->cd();
1455   TDirectory *dirProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
1456   dirProtonsSecondaryAccepted->cd();
1457
1458   //Accepted secondary protons
1459   TH1F *fSecondaryProtonsITSClustersPass = new TH1F("fSecondaryProtonsITSClustersPass",
1460                                                     ";N_{clusters} (ITS);Entries",
1461                                                     7,0,7);
1462   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsITSClustersPass);
1463   TH1F *fSecondaryProtonsChi2PerClusterITSPass = new TH1F("fSecondaryProtonsChi2PerClusterITSPass",
1464                                                           ";x^{2}/N_{clusters} (ITS);Entries",
1465                                                           100,0,4);
1466   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsChi2PerClusterITSPass);
1467   TH1F *fSecondaryProtonsTPCClustersPass = new TH1F("fSecondaryProtonsTPCClustersPass",
1468                                             ";N_{clusters} (TPC);Entries",
1469                                             100,0,200);
1470   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsTPCClustersPass);
1471   TH1F *fSecondaryProtonsChi2PerClusterTPCPass = new TH1F("fSecondaryProtonsChi2PerClusterTPCPass",
1472                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1473                                                   100,0,4);
1474   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsChi2PerClusterTPCPass);
1475   TH1F *fSecondaryProtonsExtCov11Pass = new TH1F("fSecondaryProtonsExtCov11Pass",
1476                                          ";#sigma_{y} [cm];Entries",
1477                                          100,0,4);
1478   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov11Pass);
1479   TH1F *fSecondaryProtonsExtCov22Pass = new TH1F("fSecondaryProtonsExtCov22Pass",
1480                                          ";#sigma_{z} [cm];Entries",
1481                                          100,0,4);
1482   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov22Pass);
1483   TH1F *fSecondaryProtonsExtCov33Pass = new TH1F("fSecondaryProtonsExtCov33Pass",
1484                                          ";#sigma_{sin(#phi)};Entries",
1485                                          100,0,4);
1486   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov33Pass);
1487   TH1F *fSecondaryProtonsExtCov44Pass = new TH1F("fSecondaryProtonsExtCov44Pass",
1488                                          ";#sigma_{tan(#lambda)};Entries",
1489                                          100,0,4);
1490   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov44Pass);
1491   TH1F *fSecondaryProtonsExtCov55Pass = new TH1F("fSecondaryProtonsExtCov55Pass",
1492                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1493                                          100,0,4);
1494   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsExtCov55Pass);
1495   TH1F *fSecondaryProtonsSigmaToVertexPass = new TH1F("fSecondaryProtonsSigmaToVertexPass",
1496                                              ";#sigma_{Vertex};Entries",
1497                                              100,0,10);
1498   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsSigmaToVertexPass);
1499   TH1F *fSecondaryProtonsSigmaToVertexTPCPass = new TH1F("fSecondaryProtonsSigmaToVertexTPCPass",
1500                                              ";#sigma_{Vertex};Entries",
1501                                              100,0,10);
1502   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsSigmaToVertexTPCPass);
1503   TH1F *fSecondaryProtonsITSRefitPass = new TH1F("fSecondaryProtonsITSRefitPass",
1504                                          "",10,-1,1);
1505   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsITSRefitPass);
1506   TH1F *fSecondaryProtonsTPCRefitPass = new TH1F("fSecondaryProtonsTPCRefitPass",
1507                                          "",10,-1,1);
1508   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsTPCRefitPass);
1509   TH1F *fSecondaryProtonsESDpidPass = new TH1F("fSecondaryProtonsESDpidPass",
1510                                        "",10,-1,1);
1511   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsESDpidPass);
1512   TH1F *fSecondaryProtonsTPCpidPass = new TH1F("fSecondaryProtonsTPCpidPass",
1513                                        "",10,-1,1);
1514   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsTPCpidPass);
1515
1516   //Rejected secondary protons
1517   gDirectory->cd("../");
1518   TDirectory *dirProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
1519   dirProtonsSecondaryRejected->cd();
1520
1521   TH1F *fSecondaryProtonsITSClustersReject = new TH1F("fSecondaryProtonsITSClustersReject",
1522                                                       ";N_{clusters} (ITS);Entries",
1523                                                       7,0,7);
1524   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsITSClustersReject);
1525   TH1F *fSecondaryProtonsChi2PerClusterITSReject = new TH1F("fSecondaryProtonsChi2PerClusterITSReject",
1526                                                             ";x^{2}/N_{clusters} (ITS);Entries",
1527                                                             100,0,4);
1528   fQASecondaryProtonsAcceptedList->Add(fSecondaryProtonsChi2PerClusterITSReject);
1529   TH1F *fSecondaryProtonsTPCClustersReject = new TH1F("fSecondaryProtonsTPCClustersReject",
1530                                             ";N_{clusters} (TPC);Entries",
1531                                             100,0,200);
1532   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsTPCClustersReject);
1533   TH1F *fSecondaryProtonsChi2PerClusterTPCReject = new TH1F("fSecondaryProtonsChi2PerClusterTPCReject",
1534                                                   ";x^{2}/N_{clusters} (TPC);Entries",
1535                                                   100,0,4);
1536   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsChi2PerClusterTPCReject);
1537   TH1F *fSecondaryProtonsExtCov11Reject = new TH1F("fSecondaryProtonsExtCov11Reject",
1538                                          ";#sigma_{y} [cm];Entries",
1539                                          100,0,4);
1540   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov11Reject);
1541   TH1F *fSecondaryProtonsExtCov22Reject = new TH1F("fSecondaryProtonsExtCov22Reject",
1542                                          ";#sigma_{z} [cm];Entries",
1543                                          100,0,4);
1544   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov22Reject);
1545   TH1F *fSecondaryProtonsExtCov33Reject = new TH1F("fSecondaryProtonsExtCov33Reject",
1546                                          ";#sigma_{sin(#phi)};Entries",
1547                                          100,0,4);
1548   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov33Reject);
1549   TH1F *fSecondaryProtonsExtCov44Reject = new TH1F("fSecondaryProtonsExtCov44Reject",
1550                                          ";#sigma_{tan(#lambda)};Entries",
1551                                          100,0,4);
1552   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov44Reject);
1553   TH1F *fSecondaryProtonsExtCov55Reject = new TH1F("fSecondaryProtonsExtCov55Reject",
1554                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1555                                          100,0,4);
1556   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsExtCov55Reject);
1557   TH1F *fSecondaryProtonsSigmaToVertexReject = new TH1F("fSecondaryProtonsSigmaToVertexReject",
1558                                              ";#sigma_{Vertex};Entries",
1559                                              100,0,10);
1560   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsSigmaToVertexReject);
1561   TH1F *fSecondaryProtonsSigmaToVertexTPCReject = new TH1F("fSecondaryProtonsSigmaToVertexTPCReject",
1562                                              ";#sigma_{Vertex};Entries",
1563                                              100,0,10);
1564   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsSigmaToVertexTPCReject);
1565   TH1F *fSecondaryProtonsITSRefitReject = new TH1F("fSecondaryProtonsITSRefitReject",
1566                                          "",10,-1,1);
1567   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsITSRefitReject);
1568   TH1F *fSecondaryProtonsTPCRefitReject = new TH1F("fSecondaryProtonsTPCRefitReject",
1569                                          "",10,-1,1);
1570   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsTPCRefitReject);
1571   TH1F *fSecondaryProtonsESDpidReject = new TH1F("fSecondaryProtonsESDpidReject",
1572                                        "",10,-1,1);
1573   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsESDpidReject);
1574   TH1F *fSecondaryProtonsTPCpidReject = new TH1F("fSecondaryProtonsTPCpidReject",
1575                                        "",10,-1,1);
1576   fQASecondaryProtonsRejectedList->Add(fSecondaryProtonsTPCpidReject);
1577
1578
1579   gDirectory->cd("../../../");
1580
1581   //antiprotons
1582   TDirectory *dirAntiProtons = gDirectory->mkdir("AntiProtons");
1583   fGlobalQAList->Add(dirAntiProtons); dirAntiProtons->cd();
1584   
1585   //________________________________________________________________//
1586   TDirectory *dirAntiProtonsPrimary = gDirectory->mkdir("Primaries");
1587   dirAntiProtonsPrimary->cd();
1588   TDirectory *dirAntiProtonsPrimaryAccepted = gDirectory->mkdir("Accepted");
1589   dirAntiProtonsPrimaryAccepted->cd();
1590   
1591   //Accepted primary antiprotons
1592   TH1F *fPrimaryAntiProtonsITSClustersPass = new TH1F("fPrimaryAntiProtonsITSClustersPass",
1593                                                       ";N_{clusters} (ITS);Entries",
1594                                                       7,0,7);
1595   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsITSClustersPass);
1596   TH1F *fPrimaryAntiProtonsChi2PerClusterITSPass = new TH1F("fPrimaryAntiProtonsChi2PerClusterITSPass",
1597                                                             ";x^{2}/N_{clusters} (ITS);Entries",
1598                                                             100,0,4);
1599   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsChi2PerClusterITSPass);
1600   TH1F *fPrimaryAntiProtonsTPCClustersPass = new TH1F("fPrimaryAntiProtonsTPCClustersPass",
1601                                                       ";N_{clusters} (TPC);Entries",
1602                                                       100,0,200);
1603   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsTPCClustersPass);
1604   TH1F *fPrimaryAntiProtonsChi2PerClusterTPCPass = new TH1F("fPrimaryAntiProtonsChi2PerClusterTPCPass",
1605                                                             ";x^{2}/N_{clusters} (TPC);Entries",
1606                                                             100,0,4);
1607   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsChi2PerClusterTPCPass);
1608   TH1F *fPrimaryAntiProtonsExtCov11Pass = new TH1F("fPrimaryAntiProtonsExtCov11Pass",
1609                                                    ";#sigma_{y} [cm];Entries",
1610                                                    100,0,4);
1611   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov11Pass);
1612   TH1F *fPrimaryAntiProtonsExtCov22Pass = new TH1F("fPrimaryAntiProtonsExtCov22Pass",
1613                                                    ";#sigma_{z} [cm];Entries",
1614                                                    100,0,4);
1615   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov22Pass);
1616   TH1F *fPrimaryAntiProtonsExtCov33Pass = new TH1F("fPrimaryAntiProtonsExtCov33Pass",
1617                                                    ";#sigma_{sin(#phi)};Entries",
1618                                                    100,0,4);
1619   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov33Pass);
1620   TH1F *fPrimaryAntiProtonsExtCov44Pass = new TH1F("fPrimaryAntiProtonsExtCov44Pass",
1621                                                    ";#sigma_{tan(#lambda)};Entries",
1622                                                    100,0,4);
1623   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov44Pass);
1624   TH1F *fPrimaryAntiProtonsExtCov55Pass = new TH1F("fPrimaryAntiProtonsExtCov55Pass",
1625                                                    ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1626                                                    100,0,4);
1627   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsExtCov55Pass);
1628   TH1F *fPrimaryAntiProtonsSigmaToVertexPass = new TH1F("fPrimaryAntiProtonsSigmaToVertexPass",
1629                                                         ";#sigma_{Vertex};Entries",
1630                                                         100,0,10);
1631   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsSigmaToVertexPass);
1632   TH1F *fPrimaryAntiProtonsSigmaToVertexTPCPass = new TH1F("fPrimaryAntiProtonsSigmaToVertexTPCPass",
1633                                                            ";#sigma_{Vertex};Entries",
1634                                                            100,0,10);
1635   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsSigmaToVertexTPCPass);
1636   TH1F *fPrimaryAntiProtonsITSRefitPass = new TH1F("fPrimaryAntiProtonsITSRefitPass",
1637                                                    "",10,-1,1);
1638   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsITSRefitPass);
1639   TH1F *fPrimaryAntiProtonsTPCRefitPass = new TH1F("fPrimaryAntiProtonsTPCRefitPass",
1640                                                    "",10,-1,1);
1641   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsTPCRefitPass);
1642   TH1F *fPrimaryAntiProtonsESDpidPass = new TH1F("fPrimaryAntiProtonsESDpidPass",
1643                                                  "",10,-1,1);
1644   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsESDpidPass);
1645   TH1F *fPrimaryAntiProtonsTPCpidPass = new TH1F("fPrimaryAntiProtonsTPCpidPass",
1646                                                  "",10,-1,1);
1647   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsTPCpidPass);
1648   
1649   //Rejected primary antiprotons
1650   gDirectory->cd("../");
1651   TDirectory *dirAntiProtonsPrimaryRejected = gDirectory->mkdir("Rejected");
1652   dirAntiProtonsPrimaryRejected->cd();
1653   
1654   TH1F *fPrimaryAntiProtonsITSClustersReject = new TH1F("fPrimaryAntiProtonsITSClustersReject",
1655                                                         ";N_{clusters} (ITS);Entries",
1656                                                         7,0,7);
1657   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsITSClustersReject);
1658   TH1F *fPrimaryAntiProtonsChi2PerClusterITSReject = new TH1F("fPrimaryAntiProtonsChi2PerClusterITSReject",
1659                                                               ";x^{2}/N_{clusters} (ITS);Entries",
1660                                                               100,0,4);
1661   fQAPrimaryAntiProtonsAcceptedList->Add(fPrimaryAntiProtonsChi2PerClusterITSReject);
1662   TH1F *fPrimaryAntiProtonsTPCClustersReject = new TH1F("fPrimaryAntiProtonsTPCClustersReject",
1663                                                         ";N_{clusters} (TPC);Entries",
1664                                                         100,0,200);
1665   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsTPCClustersReject);
1666   TH1F *fPrimaryAntiProtonsChi2PerClusterTPCReject = new TH1F("fPrimaryAntiProtonsChi2PerClusterTPCReject",
1667                                                               ";x^{2}/N_{clusters} (TPC);Entries",
1668                                                               100,0,4);
1669   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsChi2PerClusterTPCReject);
1670   TH1F *fPrimaryAntiProtonsExtCov11Reject = new TH1F("fPrimaryAntiProtonsExtCov11Reject",
1671                                                      ";#sigma_{y} [cm];Entries",
1672                                                      100,0,4);
1673   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov11Reject);
1674   TH1F *fPrimaryAntiProtonsExtCov22Reject = new TH1F("fPrimaryAntiProtonsExtCov22Reject",
1675                                                      ";#sigma_{z} [cm];Entries",
1676                                                      100,0,4);
1677   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov22Reject);
1678   TH1F *fPrimaryAntiProtonsExtCov33Reject = new TH1F("fPrimaryAntiProtonsExtCov33Reject",
1679                                                      ";#sigma_{sin(#phi)};Entries",
1680                                                      100,0,4);
1681   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov33Reject);
1682   TH1F *fPrimaryAntiProtonsExtCov44Reject = new TH1F("fPrimaryAntiProtonsExtCov44Reject",
1683                                                      ";#sigma_{tan(#lambda)};Entries",
1684                                                      100,0,4);
1685   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov44Reject);
1686   TH1F *fPrimaryAntiProtonsExtCov55Reject = new TH1F("fPrimaryAntiProtonsExtCov55Reject",
1687                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1688                                                      100,0,4);
1689   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsExtCov55Reject);
1690   TH1F *fPrimaryAntiProtonsSigmaToVertexReject = new TH1F("fPrimaryAntiProtonsSigmaToVertexReject",
1691                                                           ";#sigma_{Vertex};Entries",
1692                                                           100,0,10);
1693   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsSigmaToVertexReject);
1694   TH1F *fPrimaryAntiProtonsSigmaToVertexTPCReject = new TH1F("fPrimaryAntiProtonsSigmaToVertexTPCReject",
1695                                                              ";#sigma_{Vertex};Entries",
1696                                                              100,0,10);
1697   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsSigmaToVertexTPCReject);
1698   TH1F *fPrimaryAntiProtonsITSRefitReject = new TH1F("fPrimaryAntiProtonsITSRefitReject",
1699                                                      "",10,-1,1);
1700   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsITSRefitReject);
1701   TH1F *fPrimaryAntiProtonsTPCRefitReject = new TH1F("fPrimaryAntiProtonsTPCRefitReject",
1702                                                      "",10,-1,1);
1703   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsTPCRefitReject);
1704   TH1F *fPrimaryAntiProtonsESDpidReject = new TH1F("fPrimaryAntiProtonsESDpidReject",
1705                                                    "",10,-1,1);
1706   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsESDpidReject);
1707   TH1F *fPrimaryAntiProtonsTPCpidReject = new TH1F("fPrimaryAntiProtonsTPCpidReject",
1708                                                    "",10,-1,1);
1709   fQAPrimaryAntiProtonsRejectedList->Add(fPrimaryAntiProtonsTPCpidReject);
1710   
1711   //________________________________________________________________//
1712   gDirectory->cd("../../");
1713
1714   TDirectory *dirAntiProtonsSecondary = gDirectory->mkdir("Secondaries");
1715   dirAntiProtonsSecondary->cd();
1716   TDirectory *dirAntiProtonsSecondaryAccepted = gDirectory->mkdir("Accepted");
1717   dirAntiProtonsSecondaryAccepted->cd();
1718
1719   //Accepted secondary antiprotons
1720   TH1F *fSecondaryAntiProtonsITSClustersPass = new TH1F("fSecondaryAntiProtonsITSClustersPass",
1721                                                         ";N_{clusters} (ITS);Entries",
1722                                                         7,0,7);
1723   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsITSClustersPass);
1724   TH1F *fSecondaryAntiProtonsChi2PerClusterITSPass = new TH1F("fSecondaryAntiProtonsChi2PerClusterITSPass",
1725                                                               ";x^{2}/N_{clusters} (ITS);Entries",
1726                                                               100,0,4);
1727   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsChi2PerClusterITSPass);
1728   TH1F *fSecondaryAntiProtonsTPCClustersPass = new TH1F("fSecondaryAntiProtonsTPCClustersPass",
1729                                                         ";N_{clusters} (TPC);Entries",
1730                                                         100,0,200);
1731   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsTPCClustersPass);
1732   TH1F *fSecondaryAntiProtonsChi2PerClusterTPCPass = new TH1F("fSecondaryAntiProtonsChi2PerClusterTPCPass",
1733                                                               ";x^{2}/N_{clusters} (TPC);Entries",
1734                                                               100,0,4);
1735   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsChi2PerClusterTPCPass);
1736   TH1F *fSecondaryAntiProtonsExtCov11Pass = new TH1F("fSecondaryAntiProtonsExtCov11Pass",
1737                                                      ";#sigma_{y} [cm];Entries",
1738                                                      100,0,4);
1739   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov11Pass);
1740   TH1F *fSecondaryAntiProtonsExtCov22Pass = new TH1F("fSecondaryAntiProtonsExtCov22Pass",
1741                                                      ";#sigma_{z} [cm];Entries",
1742                                                      100,0,4);
1743   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov22Pass);
1744   TH1F *fSecondaryAntiProtonsExtCov33Pass = new TH1F("fSecondaryAntiProtonsExtCov33Pass",
1745                                                      ";#sigma_{sin(#phi)};Entries",
1746                                                      100,0,4);
1747   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov33Pass);
1748   TH1F *fSecondaryAntiProtonsExtCov44Pass = new TH1F("fSecondaryAntiProtonsExtCov44Pass",
1749                                                      ";#sigma_{tan(#lambda)};Entries",
1750                                                      100,0,4);
1751   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov44Pass);
1752   TH1F *fSecondaryAntiProtonsExtCov55Pass = new TH1F("fSecondaryAntiProtonsExtCov55Pass",
1753                                                      ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1754                                                      100,0,4);
1755   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsExtCov55Pass);
1756   TH1F *fSecondaryAntiProtonsSigmaToVertexPass = new TH1F("fSecondaryAntiProtonsSigmaToVertexPass",
1757                                                           ";#sigma_{Vertex};Entries",
1758                                                           100,0,10);
1759   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsSigmaToVertexPass);
1760   TH1F *fSecondaryAntiProtonsSigmaToVertexTPCPass = new TH1F("fSecondaryAntiProtonsSigmaToVertexTPCPass",
1761                                                              ";#sigma_{Vertex};Entries",
1762                                                              100,0,10);
1763   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsSigmaToVertexTPCPass);
1764   TH1F *fSecondaryAntiProtonsITSRefitPass = new TH1F("fSecondaryAntiProtonsITSRefitPass",
1765                                                      "",10,-1,1);
1766   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsITSRefitPass);
1767   TH1F *fSecondaryAntiProtonsTPCRefitPass = new TH1F("fSecondaryAntiProtonsTPCRefitPass",
1768                                                      "",10,-1,1);
1769   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsTPCRefitPass);
1770   TH1F *fSecondaryAntiProtonsESDpidPass = new TH1F("fSecondaryAntiProtonsESDpidPass",
1771                                                    "",10,-1,1);
1772   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsESDpidPass);
1773   TH1F *fSecondaryAntiProtonsTPCpidPass = new TH1F("fSecondaryAntiProtonsTPCpidPass",
1774                                                    "",10,-1,1);
1775   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsTPCpidPass);
1776   
1777   //Rejected secondary antiprotons
1778   gDirectory->cd("../");
1779   TDirectory *dirAntiProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
1780   dirAntiProtonsSecondaryRejected->cd();
1781
1782   TH1F *fSecondaryAntiProtonsITSClustersReject = new TH1F("fSecondaryAntiProtonsITSClustersReject",
1783                                                           ";N_{clusters} (ITS);Entries",
1784                                                           7,0,7);
1785   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsITSClustersReject);
1786   TH1F *fSecondaryAntiProtonsChi2PerClusterITSReject = new TH1F("fSecondaryAntiProtonsChi2PerClusterITSReject",
1787                                                                 ";x^{2}/N_{clusters} (ITS);Entries",
1788                                                                 100,0,4);
1789   fQASecondaryAntiProtonsAcceptedList->Add(fSecondaryAntiProtonsChi2PerClusterITSReject);
1790   TH1F *fSecondaryAntiProtonsTPCClustersReject = new TH1F("fSecondaryAntiProtonsTPCClustersReject",
1791                                                           ";N_{clusters} (TPC);Entries",
1792                                                           100,0,200);
1793   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsTPCClustersReject);
1794   TH1F *fSecondaryAntiProtonsChi2PerClusterTPCReject = new TH1F("fSecondaryAntiProtonsChi2PerClusterTPCReject",
1795                                                                 ";x^{2}/N_{clusters} (TPC);Entries",
1796                                                                 100,0,4);
1797   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsChi2PerClusterTPCReject);
1798   TH1F *fSecondaryAntiProtonsExtCov11Reject = new TH1F("fSecondaryAntiProtonsExtCov11Reject",
1799                                                        ";#sigma_{y} [cm];Entries",
1800                                                        100,0,4);
1801   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov11Reject);
1802   TH1F *fSecondaryAntiProtonsExtCov22Reject = new TH1F("fSecondaryAntiProtonsExtCov22Reject",
1803                                                        ";#sigma_{z} [cm];Entries",
1804                                                        100,0,4);
1805   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov22Reject);
1806   TH1F *fSecondaryAntiProtonsExtCov33Reject = new TH1F("fSecondaryAntiProtonsExtCov33Reject",
1807                                                        ";#sigma_{sin(#phi)};Entries",
1808                                                        100,0,4);
1809   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov33Reject);
1810   TH1F *fSecondaryAntiProtonsExtCov44Reject = new TH1F("fSecondaryAntiProtonsExtCov44Reject",
1811                                                        ";#sigma_{tan(#lambda)};Entries",
1812                                                        100,0,4);
1813   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov44Reject);
1814   TH1F *fSecondaryAntiProtonsExtCov55Reject = new TH1F("fSecondaryAntiProtonsExtCov55Reject",
1815                                                        ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
1816                                                        100,0,4);
1817   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsExtCov55Reject);
1818   TH1F *fSecondaryAntiProtonsSigmaToVertexReject = new TH1F("fSecondaryAntiProtonsSigmaToVertexReject",
1819                                                             ";#sigma_{Vertex};Entries",
1820                                                             100,0,10);
1821   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsSigmaToVertexReject);
1822   TH1F *fSecondaryAntiProtonsSigmaToVertexTPCReject = new TH1F("fSecondaryAntiProtonsSigmaToVertexTPCReject",
1823                                                                ";#sigma_{Vertex};Entries",
1824                                                                100,0,10);
1825   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsSigmaToVertexTPCReject);
1826   TH1F *fSecondaryAntiProtonsITSRefitReject = new TH1F("fSecondaryAntiProtonsITSRefitReject",
1827                                                        "",10,-1,1);
1828   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsITSRefitReject);
1829   TH1F *fSecondaryAntiProtonsTPCRefitReject = new TH1F("fSecondaryAntiProtonsTPCRefitReject",
1830                                                        "",10,-1,1);
1831   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsTPCRefitReject);
1832   TH1F *fSecondaryAntiProtonsESDpidReject = new TH1F("fSecondaryAntiProtonsESDpidReject",
1833                                                      "",10,-1,1);
1834   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsESDpidReject);
1835   TH1F *fSecondaryAntiProtonsTPCpidReject = new TH1F("fSecondaryAntiProtonsTPCpidReject",
1836                                                      "",10,-1,1);
1837   fQASecondaryAntiProtonsRejectedList->Add(fSecondaryAntiProtonsTPCpidReject);
1838   
1839 }
1840
1841 //____________________________________________________________________//
1842 void AliProtonAnalysis::RunQA(AliStack *stack, AliESDEvent *fESD) {
1843   //Runs the QA code
1844   Int_t nGoodTracks = fESD->GetNumberOfTracks();
1845   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
1846     AliESDtrack* track = fESD->GetTrack(iTracks);
1847     Int_t label = TMath::Abs(track->GetLabel()); 
1848     Double_t Pt = 0.0, P = 0.0;
1849     Double_t probability[5];
1850
1851     if(fUseTPCOnly) {
1852       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
1853       if(!tpcTrack) continue;
1854       Pt = tpcTrack->Pt();
1855       P = tpcTrack->P();
1856       
1857       //pid
1858       track->GetTPCpid(probability);
1859       Double_t rcc = 0.0;
1860       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
1861         rcc += probability[i]*GetParticleFraction(i,P);
1862       if(rcc == 0.0) continue;
1863       Double_t w[5];
1864       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
1865         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
1866       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
1867       if(fParticleType == 4) {
1868         if(IsAccepted(track, stack)) {
1869           if(label <= stack->GetNprimary()) {
1870             if(track->Charge() > 0)
1871               ((TH2F *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
1872             else if(track->Charge() < 0)
1873               ((TH2F *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
1874           }//primary particles
1875           else if(label > stack->GetNprimary()) {
1876             if(track->Charge() > 0)
1877               ((TH2F *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
1878             else if(track->Charge() < 0)
1879               ((TH2F *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
1880           }//secondary particles
1881         }//cuts
1882       }//proton check
1883     }//TPC only tracks
1884     else if(!fUseTPCOnly) {
1885       Pt = track->Pt();
1886       P = track->P();
1887       
1888       //pid
1889       track->GetESDpid(probability);
1890       Double_t rcc = 0.0;
1891       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
1892         rcc += probability[i]*GetParticleFraction(i,P);
1893       if(rcc == 0.0) continue;
1894       Double_t w[5];
1895       for(Int_t i = 0; i < AliPID::kSPECIES; i++)
1896         w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
1897       Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
1898       if(fParticleType == 4) {
1899         if(IsAccepted(track, stack)) {
1900           if(label <= stack->GetNprimary()) {
1901             if(track->Charge() > 0)
1902               ((TH2F *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
1903             else if(track->Charge() < 0)
1904               ((TH2F *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
1905           }//primary particles
1906           else if(label > stack->GetNprimary()) {
1907             if(track->Charge() > 0)
1908               ((TH2F *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
1909             else if(track->Charge() < 0)
1910               ((TH2F *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),track->Py(),track->Pz()),Pt);
1911           }//secondary particles
1912         }//cuts
1913       }//proton check
1914     }//combined tracking
1915   }//track loop
1916     
1917 }
1918
1919
1920
1921
1922
1923
1924
1925
1926