]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/FLOW/Tasks/AliAnalysisTaskPIDflowQA.cxx
addition vzero ep for phi and extension to higher pt
[u/mrichter/AliRoot.git] / PWG / FLOW / Tasks / AliAnalysisTaskPIDflowQA.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial pures is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any pure. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 // AliAnalysisTaskPIDflowQA:
19 // QA for pid
20 //
21 //origin: Marek Chojnacki, Marek.Chojnacki@cern.ch
22 //modified: Mikolaj Krzewicki, Mikolaj.Krzewicki@cern.ch
23
24 #include <stdio.h>
25
26 #include "AliAnalysisTaskPIDflowQA.h"
27 #include "AliAnalysisManager.h"
28 #include "AliESDEvent.h"
29 #include "AliStack.h"
30 #include "AliMCEvent.h"
31 #include "TH1F.h"
32 #include "TH2F.h"
33 #include "TProfile.h"
34 #include "TMath.h"
35 #include "AliVEvent.h"
36 #include "AliPID.h"
37 #include "AliCDBManager.h"
38 #include "AliFlowEventCuts.h"
39 #include "AliFlowTrackCuts.h"
40 #include "AliVEventHandler.h"
41 #include "AliInputEventHandler.h"
42 #include "TTree.h"
43 #include "TFile.h"
44
45 ClassImp( AliAnalysisTaskPIDflowQA)
46
47 //________________________________________________________________________
48 AliAnalysisTaskPIDflowQA:: AliAnalysisTaskPIDflowQA():
49   AliAnalysisTaskSE("AliAnalysisTaskPIDflowQA"),
50   fESD(NULL),
51   fCuts(NULL),
52   fEventCuts(NULL),
53   fESDpid(NULL),
54   fUseDebugFile(kFALSE),
55   fFile(NULL),
56   fTPCsignal(NULL),
57   fTPCsignalPi(NULL),
58   fTPCsignalK(NULL),
59   fTPCsignalP(NULL),
60   fTPCsignalPimc(NULL),
61   fTPCsignalKmc(NULL),
62   fTPCsignalPmc(NULL),
63   fTOFtime(NULL),
64   fTOFtimeE(NULL),
65   fTOFtimePi(NULL),
66   fTOFtimeK(NULL),
67   fTOFtimeP(NULL),
68   fTOFbeta(NULL),
69   fTOFbetaE(NULL),
70   fTOFbetaPi(NULL),
71   fTOFbetaK(NULL),
72   fTOFbetaP(NULL),
73   fTOFinvbeta(NULL),
74   fTOFinvbetaE(NULL),
75   fTOFinvbetaPi(NULL),
76   fTOFinvbetaK(NULL),
77   fTOFinvbetaP(NULL),
78   fTOFrawtime(NULL),
79   fTOFrawtimeE(NULL),
80   fTOFrawtimePi(NULL),
81   fTOFrawtimeK(NULL),
82   fTOFrawtimeP(NULL),
83   fTOFrawbeta(NULL),
84   fTOFrawbetaE(NULL),
85   fTOFrawbetaPi(NULL),
86   fTOFrawbetaK(NULL),
87   fTOFrawbetaP(NULL),
88   fTOFrawinvbeta(NULL),
89   fTOFrawinvbetaE(NULL),
90   fTOFrawinvbetaPi(NULL),
91   fTOFrawinvbetaK(NULL),
92   fTOFrawinvbetaP(NULL),
93   fPvsPt(NULL),
94   fMeanPvsP(NULL),
95   fTPCvsGlobalMult(NULL),
96   fStandardGlobalCuts(NULL),
97   fStandardTPCCuts(NULL),
98   fCutsTOFbetaElectrons(NULL),
99   fCutsTOFbetaPions(NULL),
100   fCutsTOFbetaKaons(NULL),
101   fCutsTOFbetaProtons(NULL),
102   fCutsTOFbetaSimpleElectrons(NULL),
103   fCutsTOFbetaSimplePions(NULL),
104   fCutsTOFbetaSimpleKaons(NULL),
105   fCutsTOFbetaSimpleProtons(NULL),
106   fCutsTOFbayesianElectrons(NULL),
107   fCutsTOFbayesianPions(NULL),
108   fCutsTOFbayesianKaons(NULL),
109   fCutsTOFbayesianProtons(NULL),
110   fCutsTPCdedxElectrons(NULL),
111   fCutsTPCdedxPions(NULL),
112   fCutsTPCdedxKaons(NULL),
113   fCutsTPCdedxProtons(NULL),
114   fCutsTPCpidElectrons(NULL),
115   fCutsTPCpidPions(NULL),
116   fCutsTPCpidKaons(NULL),
117   fCutsTPCpidProtons(NULL),
118   fCutsTPCbayesianElectrons(NULL),
119   fCutsTPCbayesianPions(NULL),
120   fCutsTPCbayesianKaons(NULL),
121   fCutsTPCbayesianProtons(NULL),
122   fCutsMCelectrons(NULL),
123   fCutsMCpions(NULL),
124   fCutsMCkaons(NULL),
125   fCutsMCprotons(NULL),
126   fCutsMCprimaryelectrons(NULL),
127   fCutsMCprimarypions(NULL),
128   fCutsMCprimarykaons(NULL),
129   fCutsMCprimaryprotons(NULL),
130   fOutputList(NULL)
131 {
132   //def ctor
133 }
134
135 //________________________________________________________________________
136 AliAnalysisTaskPIDflowQA:: AliAnalysisTaskPIDflowQA(const char *name):
137   AliAnalysisTaskSE(name),
138   fESD(NULL),
139   fCuts(NULL),
140   fEventCuts(NULL),
141   fESDpid(NULL),
142   fUseDebugFile(kFALSE),
143   fFile(NULL),
144   fTPCsignal(NULL),
145   fTPCsignalPi(NULL),
146   fTPCsignalK(NULL),
147   fTPCsignalP(NULL),
148   fTPCsignalPimc(NULL),
149   fTPCsignalKmc(NULL),
150   fTPCsignalPmc(NULL),
151   fTOFtime(NULL),
152   fTOFtimeE(NULL),
153   fTOFtimePi(NULL),
154   fTOFtimeK(NULL),
155   fTOFtimeP(NULL),
156   fTOFbeta(NULL),
157   fTOFbetaE(NULL),
158   fTOFbetaPi(NULL),
159   fTOFbetaK(NULL),
160   fTOFbetaP(NULL),
161   fTOFinvbeta(NULL),
162   fTOFinvbetaE(NULL),
163   fTOFinvbetaPi(NULL),
164   fTOFinvbetaK(NULL),
165   fTOFinvbetaP(NULL),
166   fTOFrawtime(NULL),
167   fTOFrawtimeE(NULL),
168   fTOFrawtimePi(NULL),
169   fTOFrawtimeK(NULL),
170   fTOFrawtimeP(NULL),
171   fTOFrawbeta(NULL),
172   fTOFrawbetaE(NULL),
173   fTOFrawbetaPi(NULL),
174   fTOFrawbetaK(NULL),
175   fTOFrawbetaP(NULL),
176   fTOFrawinvbeta(NULL),
177   fTOFrawinvbetaE(NULL),
178   fTOFrawinvbetaPi(NULL),
179   fTOFrawinvbetaK(NULL),
180   fTOFrawinvbetaP(NULL),
181   fPvsPt(NULL),
182   fMeanPvsP(NULL),
183   fTPCvsGlobalMult(NULL),
184   fStandardGlobalCuts(NULL),
185   fStandardTPCCuts(NULL),
186   fCutsTOFbetaElectrons(NULL),
187   fCutsTOFbetaPions(NULL),
188   fCutsTOFbetaKaons(NULL),
189   fCutsTOFbetaProtons(NULL),
190   fCutsTOFbetaSimpleElectrons(NULL),
191   fCutsTOFbetaSimplePions(NULL),
192   fCutsTOFbetaSimpleKaons(NULL),
193   fCutsTOFbetaSimpleProtons(NULL),
194   fCutsTOFbayesianElectrons(NULL),
195   fCutsTOFbayesianPions(NULL),
196   fCutsTOFbayesianKaons(NULL),
197   fCutsTOFbayesianProtons(NULL),
198   fCutsTPCdedxElectrons(NULL),
199   fCutsTPCdedxPions(NULL),
200   fCutsTPCdedxKaons(NULL),
201   fCutsTPCdedxProtons(NULL),
202   fCutsTPCpidElectrons(NULL),
203   fCutsTPCpidPions(NULL),
204   fCutsTPCpidKaons(NULL),
205   fCutsTPCpidProtons(NULL),
206   fCutsTPCbayesianElectrons(NULL),
207   fCutsTPCbayesianPions(NULL),
208   fCutsTPCbayesianKaons(NULL),
209   fCutsTPCbayesianProtons(NULL),
210   fCutsMCelectrons(NULL),
211   fCutsMCpions(NULL),
212   fCutsMCkaons(NULL),
213   fCutsMCprotons(NULL),
214   fCutsMCprimaryelectrons(NULL),
215   fCutsMCprimarypions(NULL),
216   fCutsMCprimarykaons(NULL),
217   fCutsMCprimaryprotons(NULL),
218   fOutputList(NULL)
219 {
220   //Constructor
221   fESDpid=new AliESDpid();
222
223   //old
224   fESDpid->GetTPCResponse().SetBetheBlochParameters(0.0283086,
225       2.63394e+01,
226       5.04114e-11,
227       2.12543e+00,
228       4.88663e+00 );
229   //new
230   //fESDpid->GetTPCResponse().SetBetheBlochParameters(1.28949/50.,
231   //                                                  2.74095e+01,
232   //                                                  TMath::Exp(-3.21763e+01),
233   //                                                  2.44026,
234   //                                                  6.58800);
235
236   DefineOutput(1, TList::Class());
237 }
238
239 //________________________________________________________________________
240 void  AliAnalysisTaskPIDflowQA::UserCreateOutputObjects()
241 {
242   //UserCreateOutputObject
243   if (fOutputList) fOutputList->Delete();
244   delete fOutputList;
245   fOutputList=new TList();
246   fOutputList->SetOwner(kTRUE);
247
248   const  Int_t ndec=2;
249   Int_t startvalue=-1;
250   const  Int_t npredec=50;
251   Double_t tabx[ndec*npredec+1];
252   for (Int_t i=0; i<ndec; i++)
253   {
254     for (Int_t j=0; j<npredec; j++)
255     {
256       tabx[npredec*i+j]=TMath::Power(10,((Double_t)i)+((Double_t)startvalue)+((Double_t)j)/((Double_t)npredec));
257     }
258   }
259   tabx[ndec*npredec]=TMath::Power(10,ndec+startvalue);
260
261   Int_t kPtBins=60;
262   Double_t binsPtDummy[kPtBins+1];
263   binsPtDummy[0]=0.0;
264   for(int i=1; i<=kPtBins+1; i++)
265   {
266     if(binsPtDummy[i-1]+0.05<1.01)
267       binsPtDummy[i]=binsPtDummy[i-1]+0.05;
268     else
269       binsPtDummy[i]=binsPtDummy[i-1]+0.1;
270   }
271
272   Int_t kPBins=60;
273   Double_t binsPDummy[kPBins+1];
274   binsPDummy[0]=0.0;
275   for(int i=1; i<=kPBins+1; i++)
276   {
277     if(binsPDummy[i-1]+0.05<1.01)
278       binsPDummy[i]=binsPDummy[i-1]+0.05;
279     else
280       binsPDummy[i]=binsPDummy[i-1]+0.1;
281   }
282
283   fTPCsignal=new TH2F("fTPCsignal",";p [GeV/c];dEdx",kPBins,binsPDummy,500,0,500);
284   fOutputList->Add(fTPCsignal);
285   fTPCsignalPi=new TH2F("fTPCsignalPi",";p [GeV/c];signal",kPBins,binsPDummy,500,-2,2);//TPC PID signal as function of p for pi+
286   fTPCsignalK=new TH2F("fTPCsignalK",";p [GeV/c];signal",kPBins,binsPDummy,500,-2,2);//TPC PID signal as function of p for K+
287   fTPCsignalP=new TH2F("fTPCsignalP",";p [GeV/c];signal",kPBins,binsPDummy,500,-2,2);//TPC PID signal as function of p for p
288   fOutputList->Add(fTPCsignalPi);
289   fOutputList->Add(fTPCsignalK);
290   fOutputList->Add(fTPCsignalP);
291
292   fTOFtime=new TH2F("fTOFtime",";p[GeV/c];#time",kPBins,binsPDummy,1000, 12000, 80000);//
293   fOutputList->Add(fTOFtime);
294   fTOFtimeE=new TH2F("fTOFtimeE",";p [GeV/c];#time-#time_{#pi}",kPBins,binsPDummy,1000, -8000, 8000);//
295   fTOFtimePi=new TH2F("fTOFtimePi",";p [GeV/c];#time-#time_{#pi}",kPBins,binsPDummy,1000, -8000, 8000);//
296   fTOFtimeK=new TH2F("fTOFtimeK",";p [GeV/c];#time-#time_{K}",kPBins,binsPDummy,1000, -8000, 8000);//
297   fTOFtimeP=new TH2F("fTOFtimeP",";p [GeV/c];#time-#time_{p}",kPBins,binsPDummy,1000, -8000, 8000);//
298   fOutputList->Add(fTOFtimeE);
299   fOutputList->Add(fTOFtimePi);
300   fOutputList->Add(fTOFtimeK);
301   fOutputList->Add(fTOFtimeP);
302
303   fTOFbeta=new TH2F("fTOFbeta",";p[GeV/c];#beta",kPBins,binsPDummy,1000, 0.4, 1.1);//
304   fOutputList->Add(fTOFbeta);
305   fTOFbetaE=new TH2F("fTOFbetaE",";p [GeV/c];#beta-#beta_{#pi}",kPBins,binsPDummy,1000, -0.25, 0.25);//
306   fTOFbetaPi=new TH2F("fTOFbetaPi",";p [GeV/c];#beta-#beta_{#pi}",kPBins,binsPDummy,1000, -0.25, 0.25);//
307   fTOFbetaK=new TH2F("fTOFbetaK",";p [GeV/c];#beta-#beta_{K}",kPBins,binsPDummy,1000, -0.25, 0.25);//
308   fTOFbetaP=new TH2F("fTOFbetaP",";p [GeV/c];#beta-#beta_{p}",kPBins,binsPDummy,1000, -0.25, 0.25);//
309   fOutputList->Add(fTOFbetaE);
310   fOutputList->Add(fTOFbetaPi);
311   fOutputList->Add(fTOFbetaK);
312   fOutputList->Add(fTOFbetaP);
313
314   fTOFinvbeta=new TH2F("fTOFinvbeta",";p[GeV/c];1/#beta",kPBins,binsPDummy,1000, 0.90, 2.5);//
315   fOutputList->Add(fTOFinvbeta);
316   fTOFinvbetaE=new TH2F("fTOFinvbetaE",";p [GeV/c];1/#beta-1/#beta_{#pi}",kPBins,binsPDummy,1000, -0.3, 0.3);//
317   fTOFinvbetaPi=new TH2F("fTOFinvbetaPi",";p [GeV/c];1/#beta-1/#beta_{#pi}",kPBins,binsPDummy,1000, -0.3, 0.3);//
318   fTOFinvbetaK=new TH2F("fTOFinvbetaK",";p [GeV/c];1/#beta-1/#beta_{K}",kPBins,binsPDummy,1000, -0.3, 0.3);//
319   fTOFinvbetaP=new TH2F("fTOFinvbetaP",";p [GeV/c];1/#beta-1/#beta_{p}",kPBins,binsPDummy,1000, -0.3, 0.3);//
320   fOutputList->Add(fTOFinvbetaE);
321   fOutputList->Add(fTOFinvbetaPi);
322   fOutputList->Add(fTOFinvbetaK);
323   fOutputList->Add(fTOFinvbetaP);
324
325   fTOFrawtime=new TH2F("fTOFrawtime",";p[GeV/c];#time",kPBins,binsPDummy,1000, 12000, 80000);//
326   fOutputList->Add(fTOFrawtime);
327   fTOFrawtimeE=new TH2F("fTOFrawtimeE",";p [GeV/c];#time-#time_{#pi}",kPBins,binsPDummy,1000, -8000, 8000);//
328   fTOFrawtimePi=new TH2F("fTOFrawtimePi",";p [GeV/c];#time-#time_{#pi}",kPBins,binsPDummy,1000, -8000, 8000);//
329   fTOFrawtimeK=new TH2F("fTOFrawtimeK",";p [GeV/c];#time-#time_{K}",kPBins,binsPDummy,1000, -8000, 8000);//
330   fTOFrawtimeP=new TH2F("fTOFrawtimeP",";p [GeV/c];#time-#time_{p}",kPBins,binsPDummy,1000, -8000, 8000);//
331   fOutputList->Add(fTOFrawtimeE);
332   fOutputList->Add(fTOFrawtimePi);
333   fOutputList->Add(fTOFrawtimeK);
334   fOutputList->Add(fTOFrawtimeP);
335
336   fTOFrawbeta=new TH2F("fTOFrawbeta",";p[GeV/c];#beta",kPBins,binsPDummy,1000, 0.4, 1.1);//
337   fOutputList->Add(fTOFrawbeta);
338   fTOFrawbetaE=new TH2F("fTOFrawbetaE",";p [GeV/c];#beta-#beta_{#pi}",kPBins,binsPDummy,1000, -0.25, 0.25);//
339   fTOFrawbetaPi=new TH2F("fTOFrawbetaPi",";p [GeV/c];#beta-#beta_{#pi}",kPBins,binsPDummy,1000, -0.25, 0.25);//
340   fTOFrawbetaK=new TH2F("fTOFrawbetaK",";p [GeV/c];#beta-#beta_{K}",kPBins,binsPDummy,1000, -0.25, 0.25);//
341   fTOFrawbetaP=new TH2F("fTOFrawbetaP",";p [GeV/c];#beta-#beta_{p}",kPBins,binsPDummy,1000, -0.25, 0.25);//
342   fOutputList->Add(fTOFrawbetaE);
343   fOutputList->Add(fTOFrawbetaPi);
344   fOutputList->Add(fTOFrawbetaK);
345   fOutputList->Add(fTOFrawbetaP);
346
347   fTOFrawinvbeta=new TH2F("fTOFrawinvbeta",";p[GeV/c];1/#beta",kPBins,binsPDummy,1000, 0.90, 2.5);//
348   fOutputList->Add(fTOFrawinvbeta);
349   fTOFrawinvbetaE=new TH2F("fTOFrawinvbetaE",";p [GeV/c];1/#beta-1/#beta_{#pi}",kPBins,binsPDummy,1000, -0.3, 0.3);//
350   fTOFrawinvbetaPi=new TH2F("fTOFrawinvbetaPi",";p [GeV/c];1/#beta-1/#beta_{#pi}",kPBins,binsPDummy,1000, -0.3, 0.3);//
351   fTOFrawinvbetaK=new TH2F("fTOFrawinvbetaK",";p [GeV/c];1/#beta-1/#beta_{K}",kPBins,binsPDummy,1000, -0.3, 0.3);//
352   fTOFrawinvbetaP=new TH2F("fTOFrawinvbetaP",";p [GeV/c];1/#beta-1/#beta_{p}",kPBins,binsPDummy,1000, -0.3, 0.3);//
353   fOutputList->Add(fTOFrawinvbetaE);
354   fOutputList->Add(fTOFrawinvbetaPi);
355   fOutputList->Add(fTOFrawinvbetaK);
356   fOutputList->Add(fTOFrawinvbetaP);
357
358   fPvsPt=new TH2F("fPvsPt","p vs p_{t};p [GeV/c];p_{t} [GeV/c]",kPBins,binsPDummy,kPtBins,binsPtDummy);
359   fOutputList->Add(fPvsPt);
360
361   fMeanPvsP = new TProfile("fMeanPvsP","Mean P vs P;p [Gev/c];<p> [GeV/c]",kPBins,binsPDummy);
362   fOutputList->Add(fMeanPvsP);
363
364   fTPCvsGlobalMult = new TH2F("fTPCvsGlobalMult","TPC only vs Global track multiplicity;global;TPC only",500,0,2500,500,0,3500);
365   fOutputList->Add(fTPCvsGlobalMult);
366
367   fStandardGlobalCuts = AliFlowTrackCuts::GetStandardGlobalTrackCuts2010();
368   fStandardTPCCuts = AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts2010();
369
370   fCutsTOFbetaElectrons = new AliFlowTrackCuts("TOFbeta e");
371   fCutsTOFbetaElectrons->SetPID(AliPID::kElectron, AliFlowTrackCuts::kTOFbeta);
372   fCutsTOFbetaElectrons->SetRequireStrictTOFTPCagreement();
373   fCutsTOFbetaElectrons->SetQA();
374   fCutsTOFbetaPions = new AliFlowTrackCuts("TOFbeta pi");
375   fCutsTOFbetaPions->SetPID(AliPID::kPion, AliFlowTrackCuts::kTOFbeta);
376   fCutsTOFbetaPions->SetRequireStrictTOFTPCagreement();
377   fCutsTOFbetaPions->SetQA();
378   fCutsTOFbetaKaons = new AliFlowTrackCuts("TOFbeta K");
379   fCutsTOFbetaKaons->SetPID(AliPID::kKaon, AliFlowTrackCuts::kTOFbeta);
380   fCutsTOFbetaKaons->SetRequireStrictTOFTPCagreement();
381   fCutsTOFbetaKaons->SetQA();
382   fCutsTOFbetaProtons = new AliFlowTrackCuts("TOFbeta p");
383   fCutsTOFbetaProtons->SetPID(AliPID::kProton, AliFlowTrackCuts::kTOFbeta);
384   fCutsTOFbetaProtons->SetRequireStrictTOFTPCagreement();
385   fCutsTOFbetaProtons->SetQA();
386
387   fCutsTOFbetaSimpleElectrons = new AliFlowTrackCuts("TOFbetaSimple e");
388   fCutsTOFbetaSimpleElectrons->SetPID(AliPID::kElectron, AliFlowTrackCuts::kTOFbetaSimple);
389   fCutsTOFbetaSimpleElectrons->SetRequireStrictTOFTPCagreement();
390   fCutsTOFbetaSimpleElectrons->SetQA();
391   fCutsTOFbetaSimplePions = new AliFlowTrackCuts("TOFbetaSimple pi");
392   fCutsTOFbetaSimplePions->SetPID(AliPID::kPion, AliFlowTrackCuts::kTOFbetaSimple);
393   fCutsTOFbetaSimplePions->SetRequireStrictTOFTPCagreement();
394   fCutsTOFbetaSimplePions->SetQA();
395   fCutsTOFbetaSimpleKaons = new AliFlowTrackCuts("TOFbetaSimple K");
396   fCutsTOFbetaSimpleKaons->SetPID(AliPID::kKaon, AliFlowTrackCuts::kTOFbetaSimple);
397   fCutsTOFbetaSimpleKaons->SetRequireStrictTOFTPCagreement();
398   fCutsTOFbetaSimpleKaons->SetQA();
399   fCutsTOFbetaSimpleProtons = new AliFlowTrackCuts("TOFbetaSimple p");
400   fCutsTOFbetaSimpleProtons->SetPID(AliPID::kProton, AliFlowTrackCuts::kTOFbetaSimple);
401   fCutsTOFbetaSimpleProtons->SetRequireStrictTOFTPCagreement();
402   fCutsTOFbetaSimpleProtons->SetQA();
403
404   fCutsTOFbayesianElectrons = new AliFlowTrackCuts("TOFbayesian e");
405   fCutsTOFbayesianElectrons->SetPID(AliPID::kElectron, AliFlowTrackCuts::kTOFbayesian);
406   fCutsTOFbayesianElectrons->SetRequireStrictTOFTPCagreement();
407   fCutsTOFbayesianElectrons->SetQA();
408   fCutsTOFbayesianPions = new AliFlowTrackCuts("TOFbayesian pi");
409   fCutsTOFbayesianPions->SetPID(AliPID::kPion, AliFlowTrackCuts::kTOFbayesian);
410   fCutsTOFbayesianPions->SetRequireStrictTOFTPCagreement();
411   fCutsTOFbayesianPions->SetQA();
412   fCutsTOFbayesianKaons = new AliFlowTrackCuts("TOFbayesian K");
413   fCutsTOFbayesianKaons->SetPID(AliPID::kKaon, AliFlowTrackCuts::kTOFbayesian);
414   fCutsTOFbayesianKaons->SetRequireStrictTOFTPCagreement();
415   fCutsTOFbayesianKaons->SetQA();
416   fCutsTOFbayesianProtons = new AliFlowTrackCuts("TOFbayesian p");
417   fCutsTOFbayesianProtons->SetPID(AliPID::kProton, AliFlowTrackCuts::kTOFbayesian);
418   fCutsTOFbayesianProtons->SetRequireStrictTOFTPCagreement();
419   fCutsTOFbayesianProtons->SetQA();
420
421   fCutsTPCdedxElectrons = new AliFlowTrackCuts("TPCdedx e");
422   fCutsTPCdedxElectrons->SetPID(AliPID::kElectron, AliFlowTrackCuts::kTPCdedx);
423   fCutsTPCdedxElectrons->SetQA();
424   fCutsTPCdedxPions = new AliFlowTrackCuts("TPCdedx pi");
425   fCutsTPCdedxPions->SetPID(AliPID::kPion, AliFlowTrackCuts::kTPCdedx);
426   fCutsTPCdedxPions->SetQA();
427   fCutsTPCdedxKaons = new AliFlowTrackCuts("TPCdedx K");
428   fCutsTPCdedxKaons->SetPID(AliPID::kKaon, AliFlowTrackCuts::kTPCdedx);
429   fCutsTPCdedxKaons->SetQA();
430   fCutsTPCdedxProtons = new AliFlowTrackCuts("TPCdedx p");
431   fCutsTPCdedxProtons->SetPID(AliPID::kProton, AliFlowTrackCuts::kTPCdedx);
432   fCutsTPCdedxProtons->SetQA();
433
434   fCutsTPCpidElectrons = new AliFlowTrackCuts("TPCpid e");
435   fCutsTPCpidElectrons->SetPID(AliPID::kElectron, AliFlowTrackCuts::kTPCpid);
436   fCutsTPCpidElectrons->SetQA();
437   fCutsTPCpidPions = new AliFlowTrackCuts("TPCpid pi");
438   fCutsTPCpidPions->SetPID(AliPID::kPion, AliFlowTrackCuts::kTPCpid);
439   fCutsTPCpidPions->SetQA();
440   fCutsTPCpidKaons = new AliFlowTrackCuts("TPCpid K");
441   fCutsTPCpidKaons->SetPID(AliPID::kKaon, AliFlowTrackCuts::kTPCpid);
442   fCutsTPCpidKaons->SetQA();
443   fCutsTPCpidProtons = new AliFlowTrackCuts("TPCpid p");
444   fCutsTPCpidProtons->SetPID(AliPID::kProton, AliFlowTrackCuts::kTPCpid);
445   fCutsTPCpidProtons->SetQA();
446
447   fCutsTPCbayesianElectrons = new AliFlowTrackCuts("TPCbayesian e");
448   fCutsTPCbayesianElectrons->SetPID(AliPID::kElectron, AliFlowTrackCuts::kTPCbayesian);
449   fCutsTPCbayesianElectrons->SetQA();
450   fCutsTPCbayesianPions = new AliFlowTrackCuts("TPCbayesian pi");
451   fCutsTPCbayesianPions->SetPID(AliPID::kPion, AliFlowTrackCuts::kTPCbayesian);
452   fCutsTPCbayesianPions->SetQA();
453   fCutsTPCbayesianKaons = new AliFlowTrackCuts("TPCbayesian K");
454   fCutsTPCbayesianKaons->SetPID(AliPID::kKaon, AliFlowTrackCuts::kTPCbayesian);
455   fCutsTPCbayesianKaons->SetQA();
456   fCutsTPCbayesianProtons = new AliFlowTrackCuts("TPCbayesian p");
457   fCutsTPCbayesianProtons->SetPID(AliPID::kProton, AliFlowTrackCuts::kTPCbayesian);
458   fCutsTPCbayesianProtons->SetQA();
459
460   fCutsMCelectrons=new AliFlowTrackCuts("MC e");
461   fCutsMCelectrons->SetMCPID(11);
462   fCutsMCelectrons->SetIgnoreSignInMCPID();
463   fCutsMCelectrons->SetQA();
464   fCutsMCpions=new AliFlowTrackCuts("MC pi");
465   fCutsMCpions->SetMCPID(211);
466   fCutsMCpions->SetIgnoreSignInMCPID();
467   fCutsMCpions->SetQA();
468   fCutsMCkaons=new AliFlowTrackCuts("MC K");
469   fCutsMCkaons->SetMCPID(321);
470   fCutsMCkaons->SetIgnoreSignInMCPID();
471   fCutsMCkaons->SetQA();
472   fCutsMCprotons=new AliFlowTrackCuts("MC p");
473   fCutsMCprotons->SetMCPID(2212);
474   fCutsMCprotons->SetIgnoreSignInMCPID();
475   fCutsMCprotons->SetQA();
476
477   fCutsMCprimaryelectrons=new AliFlowTrackCuts("MCprimary e");
478   fCutsMCprimaryelectrons->SetMCPID(11);
479   fCutsMCprimaryelectrons->SetIgnoreSignInMCPID();
480   fCutsMCprimaryelectrons->SetMCisPrimary();
481   fCutsMCprimaryelectrons->SetQA();
482   fCutsMCprimarypions=new AliFlowTrackCuts("MCprimary pi");
483   fCutsMCprimarypions->SetMCPID(211);
484   fCutsMCprimarypions->SetIgnoreSignInMCPID();
485   fCutsMCprimarypions->SetMCisPrimary();
486   fCutsMCprimarypions->SetQA();
487   fCutsMCprimarykaons=new AliFlowTrackCuts("MCprimary K");
488   fCutsMCprimarykaons->SetMCPID(321);
489   fCutsMCprimarykaons->SetIgnoreSignInMCPID();
490   fCutsMCprimarykaons->SetMCisPrimary();
491   fCutsMCprimarykaons->SetQA();
492   fCutsMCprimaryprotons=new AliFlowTrackCuts("MCprimary p");
493   fCutsMCprimaryprotons->SetMCPID(2212);
494   fCutsMCprimaryprotons->SetIgnoreSignInMCPID();
495   fCutsMCprimaryprotons->SetMCisPrimary();
496   fCutsMCprimaryprotons->SetQA();
497
498   //fOutputList->Add(fESDpid);
499
500   fOutputList->Add(fCutsTPCdedxElectrons->GetQA());
501   fOutputList->Add(fCutsTPCdedxPions->GetQA());
502   fOutputList->Add(fCutsTPCdedxKaons->GetQA());
503   fOutputList->Add(fCutsTPCdedxProtons->GetQA());
504   fOutputList->Add(fCutsTPCpidElectrons->GetQA());
505   fOutputList->Add(fCutsTPCpidPions->GetQA());
506   fOutputList->Add(fCutsTPCpidKaons->GetQA());
507   fOutputList->Add(fCutsTPCpidProtons->GetQA());
508   fOutputList->Add(fCutsTPCbayesianElectrons->GetQA());
509   fOutputList->Add(fCutsTPCbayesianPions->GetQA());
510   fOutputList->Add(fCutsTPCbayesianKaons->GetQA());
511   fOutputList->Add(fCutsTPCbayesianProtons->GetQA());
512   fOutputList->Add(fCutsTOFbetaElectrons->GetQA());
513   fOutputList->Add(fCutsTOFbetaPions->GetQA());
514   fOutputList->Add(fCutsTOFbetaKaons->GetQA());
515   fOutputList->Add(fCutsTOFbetaProtons->GetQA());
516   fOutputList->Add(fCutsTOFbetaSimpleElectrons->GetQA());
517   fOutputList->Add(fCutsTOFbetaSimplePions->GetQA());
518   fOutputList->Add(fCutsTOFbetaSimpleKaons->GetQA());
519   fOutputList->Add(fCutsTOFbetaSimpleProtons->GetQA());
520   fOutputList->Add(fCutsTOFbayesianElectrons->GetQA());
521   fOutputList->Add(fCutsTOFbayesianPions->GetQA());
522   fOutputList->Add(fCutsTOFbayesianKaons->GetQA());
523   fOutputList->Add(fCutsTOFbayesianProtons->GetQA());
524   fOutputList->Add(fCutsMCelectrons->GetQA());
525   fOutputList->Add(fCutsMCpions->GetQA());
526   fOutputList->Add(fCutsMCkaons->GetQA());
527   fOutputList->Add(fCutsMCprotons->GetQA());
528   fOutputList->Add(fCutsMCprimaryelectrons->GetQA());
529   fOutputList->Add(fCutsMCprimarypions->GetQA());
530   fOutputList->Add(fCutsMCprimarykaons->GetQA());
531   fOutputList->Add(fCutsMCprimaryprotons->GetQA());
532
533   if (fUseDebugFile) fFile = fopen("debug.txt","w");
534
535   PostData(1,  fOutputList);
536 }
537
538 //________________________________________________________________________
539 void  AliAnalysisTaskPIDflowQA::UserExec(Option_t *)
540 {
541   //user exec
542   fESD = dynamic_cast<AliESDEvent*> (InputEvent());
543   if (!fESD) return;
544
545   //do the calibration bit
546   fESDpid->SetTOFResponse(fESD,AliESDpid::kTOF_T0); // to use T0-TOF 
547   fESDpid->MakePID(fESD,kFALSE);
548
549   if(!fCuts || !fEventCuts)
550   {
551     Printf("No CUTS Defined.........\n");
552     PostData(1,  fOutputList);
553     return;
554   }
555
556   if (!(fEventCuts->IsSelected(fESD)))
557   {
558     return;
559   }
560
561   AliStack* stack=NULL;
562   AliMCEvent* mcEvent = MCEvent();
563   if (mcEvent) stack = mcEvent->Stack();
564   if (mcEvent) Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
565
566   Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
567   Int_t nTracks=fESD->GetNumberOfTracks();
568
569   AliESDtrack *trackESD=0;
570
571   fCuts->SetEvent(fESD,mcEvent);
572   fCutsTPCdedxElectrons->SetEvent(fESD,mcEvent);
573   fCutsTPCdedxPions->SetEvent(fESD,mcEvent);
574   fCutsTPCdedxKaons->SetEvent(fESD,mcEvent);
575   fCutsTPCdedxProtons->SetEvent(fESD,mcEvent);
576   fCutsTPCpidElectrons->SetEvent(fESD,mcEvent);
577   fCutsTPCpidPions->SetEvent(fESD,mcEvent);
578   fCutsTPCpidKaons->SetEvent(fESD,mcEvent);
579   fCutsTPCpidProtons->SetEvent(fESD,mcEvent);
580   fCutsTPCbayesianElectrons->SetEvent(fESD,mcEvent);
581   fCutsTPCbayesianPions->SetEvent(fESD,mcEvent);
582   fCutsTPCbayesianKaons->SetEvent(fESD,mcEvent);
583   fCutsTPCbayesianProtons->SetEvent(fESD,mcEvent);
584   fCutsTOFbetaElectrons->SetEvent(fESD,mcEvent);
585   fCutsTOFbetaPions->SetEvent(fESD,mcEvent);
586   fCutsTOFbetaKaons->SetEvent(fESD,mcEvent);
587   fCutsTOFbetaProtons->SetEvent(fESD,mcEvent);
588   fCutsTOFbetaSimpleElectrons->SetEvent(fESD,mcEvent);
589   fCutsTOFbetaSimplePions->SetEvent(fESD,mcEvent);
590   fCutsTOFbetaSimpleKaons->SetEvent(fESD,mcEvent);
591   fCutsTOFbetaSimpleProtons->SetEvent(fESD,mcEvent);
592   fCutsTOFbayesianElectrons->SetEvent(fESD,mcEvent);
593   fCutsTOFbayesianPions->SetEvent(fESD,mcEvent);
594   fCutsTOFbayesianKaons->SetEvent(fESD,mcEvent);
595   fCutsTOFbayesianProtons->SetEvent(fESD,mcEvent);
596   fCutsMCelectrons->SetEvent(fESD,mcEvent);
597   fCutsMCpions->SetEvent(fESD,mcEvent);
598   fCutsMCkaons->SetEvent(fESD,mcEvent);
599   fCutsMCprotons->SetEvent(fESD,mcEvent);
600   fCutsMCprimaryelectrons->SetEvent(fESD,mcEvent);
601   fCutsMCprimarypions->SetEvent(fESD,mcEvent);
602   fCutsMCprimarykaons->SetEvent(fESD,mcEvent);
603   fCutsMCprimaryprotons->SetEvent(fESD,mcEvent);
604
605   for(int tr1=0; tr1<nTracks; tr1++)
606   {
607     trackESD=fESD->GetTrack(tr1);
608     if (!trackESD) continue;
609
610     Double_t p=trackESD->GetP();
611     Double_t pt=trackESD->Pt();
612
613     if(!(fCuts->IsSelected(trackESD))) continue;
614
615     Int_t label=-1;
616     if(mcEvent) label=trackESD->GetLabel();
617
618     Int_t pdgcode=0;
619     if(stack)
620     {
621       TParticle* particle2 = stack->Particle(TMath::Abs(label));
622       pdgcode=particle2->GetPdgCode();
623     }
624
625     fPvsPt->Fill(p,pt);
626     fMeanPvsP->Fill(p,p);
627
628     PidTPC(trackESD,pdgcode);
629     PidTOF(trackESD,pdgcode);
630   }
631
632   //for (Int_t imc=0; imc<(mcEvent!=NULL)?mcEvent->GetNumberOfTracks():0;imc++)
633   if (mcEvent)
634   {
635     for (Int_t imc=0; imc<mcEvent->GetNumberOfTracks();imc++)
636     {
637       printf("imc: %i label:%i\n",imc,mcEvent->GetTrack(imc)->GetLabel());
638       fCutsMCelectrons->IsSelected(mcEvent->GetTrack(imc));
639       fCutsMCpions->IsSelected(mcEvent->GetTrack(imc));
640       fCutsMCkaons->IsSelected(mcEvent->GetTrack(imc));
641       fCutsMCprotons->IsSelected(mcEvent->GetTrack(imc));
642       fCutsMCprimaryelectrons->IsSelected(mcEvent->GetTrack(imc));
643       fCutsMCprimarypions->IsSelected(mcEvent->GetTrack(imc));
644       fCutsMCprimarykaons->IsSelected(mcEvent->GetTrack(imc));
645       fCutsMCprimaryprotons->IsSelected(mcEvent->GetTrack(imc));
646     }
647   }
648
649   //check the correlation between the global and TPConly number of tracks
650   fStandardGlobalCuts->SetEvent(fESD);
651   fStandardTPCCuts->SetEvent(fESD);
652   Int_t multGlobal = fStandardGlobalCuts->Count();
653   Int_t multTPC = fStandardTPCCuts->Count();
654   fTPCvsGlobalMult->Fill(multGlobal,multTPC);
655
656   if (fFile)
657   {
658     const AliESDVertex* pvtx = fESD->GetPrimaryVertex();
659     const AliESDVertex* tpcvtx = fESD->GetPrimaryVertexTPC();
660     const AliESDVertex* spdvtx = fESD->GetPrimaryVertexSPD();
661     AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
662     AliVEventHandler* handler = mgr->GetInputEventHandler();
663     TTree* tree = handler->GetTree();
664     TFile* file = tree->GetCurrentFile();
665     if (multTPC>(23+1.216*multGlobal) || multTPC<(-20+1.087*multGlobal))
666     {
667       fprintf(fFile, "%i %i %s %i\n",multTPC,multGlobal,file->GetName(),fESD->GetEventNumberInFile());
668       fprintf(fFile, "  primary vertex: x: %.2f, y: %.2f, z: %.2f, n: %i\n", pvtx->GetX(), pvtx->GetY(), pvtx->GetZ(), pvtx->GetNContributors());
669       fprintf(fFile, "      SPD vertex: x: %.2f, y: %.2f, z: %.2f, n: %i\n", spdvtx->GetX(), spdvtx->GetY(), spdvtx->GetZ(), spdvtx->GetNContributors());
670       fprintf(fFile, "      TPC vertex: x: %.2f, y: %.2f, z: %.2f, n: %i\n", tpcvtx->GetX(), tpcvtx->GetY(), tpcvtx->GetZ(), tpcvtx->GetNContributors());
671     }
672   }
673 }
674
675 //________________________________________________________________________
676 void  AliAnalysisTaskPIDflowQA::Terminate(Option_t *)
677 {
678   //Terminate
679   if(fCuts)
680     fCuts->Dump();
681
682   Printf("AliAnalysisTaskPIDflowQA: end of Terminate");
683 }
684
685
686 //________________________________________________________________________
687 void AliAnalysisTaskPIDflowQA::PidTPC(AliESDtrack* t, Int_t)
688 {
689   //do TPC pid
690   const AliExternalTrackParam* innerParam = t->GetInnerParam();
691   if (!innerParam) return;
692   Double_t pinTPCglobal=innerParam->GetP();
693   Double_t tpcSignal =t->GetTPCsignal();
694   Float_t p=innerParam->P();
695   Float_t sigPion     = fESDpid->GetTPCResponse().GetExpectedSignal(pinTPCglobal, AliPID::kPion);
696   Float_t sigKaon     = fESDpid->GetTPCResponse().GetExpectedSignal(pinTPCglobal, AliPID::kKaon);
697   Float_t sigProton   = fESDpid->GetTPCResponse().GetExpectedSignal(pinTPCglobal, AliPID::kProton);
698   if(!(sigPion>0.0&&sigKaon>0.0&&sigProton>0.0))
699     return;
700
701   fTPCsignal->Fill(pinTPCglobal,tpcSignal);
702
703   fTPCsignalPi->Fill(p,(tpcSignal-sigPion)/sigPion);
704   fTPCsignalK->Fill(p,(tpcSignal-sigKaon)/sigKaon);
705   fTPCsignalP->Fill(p,(tpcSignal-sigProton)/sigProton);
706
707   fCutsTPCdedxElectrons->IsSelected(t);
708   fCutsTPCdedxPions->IsSelected(t);
709   fCutsTPCdedxKaons->IsSelected(t);
710   fCutsTPCdedxProtons->IsSelected(t);
711   fCutsTPCpidElectrons->IsSelected(t);
712   fCutsTPCpidPions->IsSelected(t);
713   fCutsTPCpidKaons->IsSelected(t);
714   fCutsTPCpidProtons->IsSelected(t);
715   fCutsTPCbayesianElectrons->IsSelected(t);
716   fCutsTPCbayesianPions->IsSelected(t);
717   fCutsTPCbayesianKaons->IsSelected(t);
718   fCutsTPCbayesianProtons->IsSelected(t);
719 }
720
721 //______________________________________________________________________________
722 void AliAnalysisTaskPIDflowQA::PidTOF(AliESDtrack* track, Int_t)
723 {
724   //do TOF pid
725   Bool_t goodtrack = (track) &&
726                      (track->GetStatus() & AliESDtrack::kTOFpid) &&
727                      (track->GetTOFsignal() > 12000) &&
728                      (track->GetTOFsignal() < 100000) &&
729                      (track->GetIntegratedLength() > 365);
730   
731   if (!goodtrack) return;
732
733   const Float_t c = 2.99792457999999984e-02;  
734   Float_t p = track->GetP();
735   Float_t l = track->GetIntegratedLength();  
736   Float_t trackT0 = fESDpid->GetTOFResponse().GetStartTime(p);
737   //time
738   Float_t timeTOF = track->GetTOFsignal()- trackT0; 
739   Double_t integratedTimes[5] = {-1.0,-1.0,-1.0,-1.0,-1.0};
740   track->GetIntegratedTimes(integratedTimes);
741   //beta
742   Float_t beta = l/timeTOF/c;
743   Float_t betaHypothesis[5] = {0.0,0.0,0.0,0.0,0.0};
744   Float_t betadiff[5] = {0.0,0.0,0.0,0.0,0.0};
745   for (Int_t i=0;i<5;i++)
746   {
747     betaHypothesis[i] = l/integratedTimes[i]/c;
748     betadiff[i] = beta-betaHypothesis[i];
749   }
750   //inverse beta
751   Float_t invbeta = 1/beta;
752   Float_t invbetaHypothesis[5] = {0.0,0.0,0.0,0.0,0.0};
753   Float_t invbetadiff[5] = {0.0,0.0,0.0,0.0,0.0};
754   for (Int_t i=0;i<5;i++)
755   {
756     invbetaHypothesis[i] = 1/betaHypothesis[i];
757     invbetadiff[i] = invbeta-invbetaHypothesis[i];
758   }
759
760   Double_t tpcpid[AliPID::kSPECIES];
761   track->GetTPCpid(tpcpid);
762
763   //base hists
764   fTOFrawtime->Fill(p,timeTOF);
765   fTOFrawtimeE->Fill(p,timeTOF-integratedTimes[0]);
766   fTOFrawtimePi->Fill(p,timeTOF-integratedTimes[2]);
767   fTOFrawtimeK->Fill(p,timeTOF-integratedTimes[3]);
768   fTOFrawtimeP->Fill(p,timeTOF-integratedTimes[4]);
769
770   fTOFrawbeta->Fill(p,beta);
771   fTOFrawbetaE->Fill(p,betadiff[0]);
772   fTOFrawbetaPi->Fill(p,betadiff[2]);
773   fTOFrawbetaK->Fill(p,betadiff[3]);
774   fTOFrawbetaP->Fill(p,betadiff[4]);
775
776   fTOFrawinvbeta->Fill(p,invbeta);
777   fTOFrawinvbetaE->Fill(p,invbetadiff[0]);
778   fTOFrawinvbetaPi->Fill(p,invbetadiff[2]);
779   fTOFrawinvbetaK->Fill(p,invbetadiff[3]);
780   fTOFrawinvbetaP->Fill(p,invbetadiff[4]);
781
782   //cleanup with TPC
783   if (track->GetStatus() & AliESDtrack::kTOFmismatch) return;
784   if (!TPCTOFagree(track)) return;
785
786   //responses
787   fTOFtime->Fill(p,timeTOF);
788   fTOFtimeE->Fill(p,timeTOF-integratedTimes[0]);
789   fTOFtimePi->Fill(p,timeTOF-integratedTimes[2]);
790   fTOFtimeK->Fill(p,timeTOF-integratedTimes[3]);
791   fTOFtimeP->Fill(p,timeTOF-integratedTimes[4]);
792
793   fTOFbeta->Fill(p,beta);
794   fTOFbetaE->Fill(p,betadiff[0]);
795   fTOFbetaPi->Fill(p,betadiff[2]);
796   fTOFbetaK->Fill(p,betadiff[3]);
797   fTOFbetaP->Fill(p,betadiff[4]);
798
799   fTOFinvbeta->Fill(p,invbeta);
800   fTOFinvbetaE->Fill(p,invbetadiff[0]);
801   fTOFinvbetaPi->Fill(p,invbetadiff[2]);
802   fTOFinvbetaK->Fill(p,invbetadiff[3]);
803   fTOFinvbetaP->Fill(p,invbetadiff[4]);
804
805   fCutsTOFbetaElectrons->IsSelected(track);
806   fCutsTOFbetaPions->IsSelected(track);
807   fCutsTOFbetaKaons->IsSelected(track);
808   fCutsTOFbetaProtons->IsSelected(track);
809   fCutsTOFbetaSimpleElectrons->IsSelected(track);
810   fCutsTOFbetaSimplePions->IsSelected(track);
811   fCutsTOFbetaSimpleKaons->IsSelected(track);
812   fCutsTOFbetaSimpleProtons->IsSelected(track);
813   fCutsTOFbayesianElectrons->IsSelected(track);
814   fCutsTOFbayesianPions->IsSelected(track);
815   fCutsTOFbayesianKaons->IsSelected(track);
816   fCutsTOFbayesianProtons->IsSelected(track);
817 }
818
819 //______________________________________________________________________________
820 Float_t AliAnalysisTaskPIDflowQA::Beta(Float_t m, Float_t p) 
821 {
822   //get theoretical beta
823   return TMath::Sqrt(1. / (1. + m * m / (p * p)));
824 }
825
826 //---------------------------------------------------------------//
827 Bool_t AliAnalysisTaskPIDflowQA::TPCTOFagree(const AliESDtrack *track)
828 {
829   //check agreement between TOF and TPC pid
830   Bool_t status = kFALSE;
831   
832   Float_t mass[5] = {5.10998909999999971e-04,1.05658000000000002e-01,1.39570000000000000e-01,4.93676999999999977e-01,9.38271999999999995e-01};
833   
834
835   Double_t exptimes[5];
836   track->GetIntegratedTimes(exptimes);
837   
838   Float_t dedx = track->GetTPCsignal();
839
840   Float_t p = track->P();
841   Float_t time = track->GetTOFsignal()- fESDpid->GetTOFResponse().GetStartTime(p);
842   Float_t tl = track->GetIntegratedLength();
843
844   Float_t betagammares =  fESDpid->GetTOFResponse().GetExpectedSigma(p, exptimes[4], mass[4]);
845
846   Float_t betagamma1 = tl/(time-5 *betagammares) * 33.3564095198152043;
847
848 //  printf("betagamma1 = %f\n",betagamma1);
849
850   if(betagamma1 < 0.1) betagamma1 = 0.1;
851
852   if(betagamma1 < 0.99999) betagamma1 /= TMath::Sqrt(1-betagamma1*betagamma1);
853   else betagamma1 = 100;
854
855   Float_t betagamma2 = tl/(time+5 *betagammares) * 33.3564095198152043;
856 //  printf("betagamma2 = %f\n",betagamma2);
857
858   if(betagamma2 < 0.1) betagamma2 = 0.1;
859
860   if(betagamma2 < 0.99999) betagamma2 /= TMath::Sqrt(1-betagamma2*betagamma2);
861   else betagamma2 = 100;
862
863
864   Double_t ptpc[3];
865   track->GetInnerPxPyPz(ptpc);
866   Float_t momtpc=TMath::Sqrt(ptpc[0]*ptpc[0] + ptpc[1]*ptpc[1] + ptpc[2]*ptpc[2]);
867  
868   for(Int_t i=0;i < 5;i++){
869     Float_t resolutionTOF =  fESDpid->GetTOFResponse().GetExpectedSigma(p, exptimes[i], mass[i]);
870     if(TMath::Abs(exptimes[i] - time) < 5 * resolutionTOF){
871       Float_t dedxExp = 0;
872       if(i==0) dedxExp =  fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kElectron);
873       else if(i==1) dedxExp =  fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kMuon);
874       else if(i==2) dedxExp =  fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kPion);
875       else if(i==3) dedxExp =  fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kKaon);
876       else if(i==4) dedxExp =  fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kProton);
877
878       Float_t resolutionTPC = 2;
879       if(i==0) resolutionTPC =   fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kElectron); 
880       else if(i==1) resolutionTPC =   fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kMuon);
881       else if(i==2) resolutionTPC =   fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kPion);
882       else if(i==3) resolutionTPC =   fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kKaon);
883       else if(i==4) resolutionTPC =   fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kProton);
884
885       if(TMath::Abs(dedx - dedxExp) < 3 * resolutionTPC){
886         status = kTRUE;
887       }
888     }
889   }
890
891   Float_t bb1 =  fESDpid->GetTPCResponse().Bethe(betagamma1);
892   Float_t bb2 =  fESDpid->GetTPCResponse().Bethe(betagamma2);
893   Float_t bbM =  fESDpid->GetTPCResponse().Bethe((betagamma1+betagamma2)*0.5);
894
895
896   //  status = kFALSE;
897   // for nuclei
898   Float_t resolutionTOFpr =   fESDpid->GetTOFResponse().GetExpectedSigma(p, exptimes[4], mass[4]);
899   Float_t resolutionTPCpr =   fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kProton);
900   if(TMath::Abs(dedx-bb1) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
901      status = kTRUE;
902   }
903   else if(TMath::Abs(dedx-bb2) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
904      status = kTRUE;
905   }
906   else if(TMath::Abs(dedx-bbM) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
907      status = kTRUE;
908   }
909   
910   return status;
911 }
912