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