AliPhysics  db95e02 (db95e02)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskPIDflowQA.cxx
Go to the documentation of this file.
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 
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 
46 
47 //________________________________________________________________________
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 //________________________________________________________________________
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 //________________________________________________________________________
241 {
242  //UserCreateOutputObject
243  if (fOutputList) fOutputList->Delete();
244  delete fOutputList;
245  fOutputList=new TList();
246  fOutputList->SetOwner(kTRUE);
247 
248 /* COMMENTED OUT ON 04122014 to squash unused variable warning
249  const Int_t ndec=2;
250  Int_t startvalue=-1;
251  const Int_t npredec=50;
252  Double_t tabx[ndec*npredec+1];
253  for (Int_t i=0; i<ndec; i++)
254  {
255  for (Int_t j=0; j<npredec; j++)
256  {
257  tabx[npredec*i+j]=TMath::Power(10,((Double_t)i)+((Double_t)startvalue)+((Double_t)j)/((Double_t)npredec));
258  }
259  }
260  tabx[ndec*npredec]=TMath::Power(10,ndec+startvalue);
261 */
262  Int_t kPtBins=60;
263  Double_t binsPtDummy[kPtBins+1];
264  binsPtDummy[0]=0.0;
265  for(int i=1; i<=kPtBins+1; i++)
266  {
267  if(binsPtDummy[i-1]+0.05<1.01)
268  binsPtDummy[i]=binsPtDummy[i-1]+0.05;
269  else
270  binsPtDummy[i]=binsPtDummy[i-1]+0.1;
271  }
272 
273  Int_t kPBins=60;
274  Double_t binsPDummy[kPBins+1];
275  binsPDummy[0]=0.0;
276  for(int i=1; i<=kPBins+1; i++)
277  {
278  if(binsPDummy[i-1]+0.05<1.01)
279  binsPDummy[i]=binsPDummy[i-1]+0.05;
280  else
281  binsPDummy[i]=binsPDummy[i-1]+0.1;
282  }
283 
284  fTPCsignal=new TH2F("fTPCsignal",";p [GeV/c];dEdx",kPBins,binsPDummy,500,0,500);
285  fOutputList->Add(fTPCsignal);
286  fTPCsignalPi=new TH2F("fTPCsignalPi",";p [GeV/c];signal",kPBins,binsPDummy,500,-2,2);//TPC PID signal as function of p for pi+
287  fTPCsignalK=new TH2F("fTPCsignalK",";p [GeV/c];signal",kPBins,binsPDummy,500,-2,2);//TPC PID signal as function of p for K+
288  fTPCsignalP=new TH2F("fTPCsignalP",";p [GeV/c];signal",kPBins,binsPDummy,500,-2,2);//TPC PID signal as function of p for p
290  fOutputList->Add(fTPCsignalK);
291  fOutputList->Add(fTPCsignalP);
292 
293  fTOFtime=new TH2F("fTOFtime",";p[GeV/c];#time",kPBins,binsPDummy,1000, 12000, 80000);//
294  fOutputList->Add(fTOFtime);
295  fTOFtimeE=new TH2F("fTOFtimeE",";p [GeV/c];#time-#time_{#pi}",kPBins,binsPDummy,1000, -8000, 8000);//
296  fTOFtimePi=new TH2F("fTOFtimePi",";p [GeV/c];#time-#time_{#pi}",kPBins,binsPDummy,1000, -8000, 8000);//
297  fTOFtimeK=new TH2F("fTOFtimeK",";p [GeV/c];#time-#time_{K}",kPBins,binsPDummy,1000, -8000, 8000);//
298  fTOFtimeP=new TH2F("fTOFtimeP",";p [GeV/c];#time-#time_{p}",kPBins,binsPDummy,1000, -8000, 8000);//
299  fOutputList->Add(fTOFtimeE);
300  fOutputList->Add(fTOFtimePi);
301  fOutputList->Add(fTOFtimeK);
302  fOutputList->Add(fTOFtimeP);
303 
304  fTOFbeta=new TH2F("fTOFbeta",";p[GeV/c];#beta",kPBins,binsPDummy,1000, 0.4, 1.1);//
305  fOutputList->Add(fTOFbeta);
306  fTOFbetaE=new TH2F("fTOFbetaE",";p [GeV/c];#beta-#beta_{#pi}",kPBins,binsPDummy,1000, -0.25, 0.25);//
307  fTOFbetaPi=new TH2F("fTOFbetaPi",";p [GeV/c];#beta-#beta_{#pi}",kPBins,binsPDummy,1000, -0.25, 0.25);//
308  fTOFbetaK=new TH2F("fTOFbetaK",";p [GeV/c];#beta-#beta_{K}",kPBins,binsPDummy,1000, -0.25, 0.25);//
309  fTOFbetaP=new TH2F("fTOFbetaP",";p [GeV/c];#beta-#beta_{p}",kPBins,binsPDummy,1000, -0.25, 0.25);//
310  fOutputList->Add(fTOFbetaE);
311  fOutputList->Add(fTOFbetaPi);
312  fOutputList->Add(fTOFbetaK);
313  fOutputList->Add(fTOFbetaP);
314 
315  fTOFinvbeta=new TH2F("fTOFinvbeta",";p[GeV/c];1/#beta",kPBins,binsPDummy,1000, 0.90, 2.5);//
316  fOutputList->Add(fTOFinvbeta);
317  fTOFinvbetaE=new TH2F("fTOFinvbetaE",";p [GeV/c];1/#beta-1/#beta_{#pi}",kPBins,binsPDummy,1000, -0.3, 0.3);//
318  fTOFinvbetaPi=new TH2F("fTOFinvbetaPi",";p [GeV/c];1/#beta-1/#beta_{#pi}",kPBins,binsPDummy,1000, -0.3, 0.3);//
319  fTOFinvbetaK=new TH2F("fTOFinvbetaK",";p [GeV/c];1/#beta-1/#beta_{K}",kPBins,binsPDummy,1000, -0.3, 0.3);//
320  fTOFinvbetaP=new TH2F("fTOFinvbetaP",";p [GeV/c];1/#beta-1/#beta_{p}",kPBins,binsPDummy,1000, -0.3, 0.3);//
325 
326  fTOFrawtime=new TH2F("fTOFrawtime",";p[GeV/c];#time",kPBins,binsPDummy,1000, 12000, 80000);//
327  fOutputList->Add(fTOFrawtime);
328  fTOFrawtimeE=new TH2F("fTOFrawtimeE",";p [GeV/c];#time-#time_{#pi}",kPBins,binsPDummy,1000, -8000, 8000);//
329  fTOFrawtimePi=new TH2F("fTOFrawtimePi",";p [GeV/c];#time-#time_{#pi}",kPBins,binsPDummy,1000, -8000, 8000);//
330  fTOFrawtimeK=new TH2F("fTOFrawtimeK",";p [GeV/c];#time-#time_{K}",kPBins,binsPDummy,1000, -8000, 8000);//
331  fTOFrawtimeP=new TH2F("fTOFrawtimeP",";p [GeV/c];#time-#time_{p}",kPBins,binsPDummy,1000, -8000, 8000);//
336 
337  fTOFrawbeta=new TH2F("fTOFrawbeta",";p[GeV/c];#beta",kPBins,binsPDummy,1000, 0.4, 1.1);//
338  fOutputList->Add(fTOFrawbeta);
339  fTOFrawbetaE=new TH2F("fTOFrawbetaE",";p [GeV/c];#beta-#beta_{#pi}",kPBins,binsPDummy,1000, -0.25, 0.25);//
340  fTOFrawbetaPi=new TH2F("fTOFrawbetaPi",";p [GeV/c];#beta-#beta_{#pi}",kPBins,binsPDummy,1000, -0.25, 0.25);//
341  fTOFrawbetaK=new TH2F("fTOFrawbetaK",";p [GeV/c];#beta-#beta_{K}",kPBins,binsPDummy,1000, -0.25, 0.25);//
342  fTOFrawbetaP=new TH2F("fTOFrawbetaP",";p [GeV/c];#beta-#beta_{p}",kPBins,binsPDummy,1000, -0.25, 0.25);//
347 
348  fTOFrawinvbeta=new TH2F("fTOFrawinvbeta",";p[GeV/c];1/#beta",kPBins,binsPDummy,1000, 0.90, 2.5);//
350  fTOFrawinvbetaE=new TH2F("fTOFrawinvbetaE",";p [GeV/c];1/#beta-1/#beta_{#pi}",kPBins,binsPDummy,1000, -0.3, 0.3);//
351  fTOFrawinvbetaPi=new TH2F("fTOFrawinvbetaPi",";p [GeV/c];1/#beta-1/#beta_{#pi}",kPBins,binsPDummy,1000, -0.3, 0.3);//
352  fTOFrawinvbetaK=new TH2F("fTOFrawinvbetaK",";p [GeV/c];1/#beta-1/#beta_{K}",kPBins,binsPDummy,1000, -0.3, 0.3);//
353  fTOFrawinvbetaP=new TH2F("fTOFrawinvbetaP",";p [GeV/c];1/#beta-1/#beta_{p}",kPBins,binsPDummy,1000, -0.3, 0.3);//
358 
359  fPvsPt=new TH2F("fPvsPt","p vs p_{t};p [GeV/c];p_{t} [GeV/c]",kPBins,binsPDummy,kPtBins,binsPtDummy);
360  fOutputList->Add(fPvsPt);
361 
362  fMeanPvsP = new TProfile("fMeanPvsP","Mean P vs P;p [Gev/c];<p> [GeV/c]",kPBins,binsPDummy);
363  fOutputList->Add(fMeanPvsP);
364 
365  fTPCvsGlobalMult = new TH2F("fTPCvsGlobalMult","TPC only vs Global track multiplicity;global;TPC only",500,0,2500,500,0,3500);
367 
370 
371  fCutsTOFbetaElectrons = new AliFlowTrackCuts("TOFbeta e");
375  fCutsTOFbetaPions = new AliFlowTrackCuts("TOFbeta pi");
379  fCutsTOFbetaKaons = new AliFlowTrackCuts("TOFbeta K");
383  fCutsTOFbetaProtons = new AliFlowTrackCuts("TOFbeta p");
387 
388  fCutsTOFbetaSimpleElectrons = new AliFlowTrackCuts("TOFbetaSimple e");
392  fCutsTOFbetaSimplePions = new AliFlowTrackCuts("TOFbetaSimple pi");
396  fCutsTOFbetaSimpleKaons = new AliFlowTrackCuts("TOFbetaSimple K");
400  fCutsTOFbetaSimpleProtons = new AliFlowTrackCuts("TOFbetaSimple p");
404 
405  fCutsTOFbayesianElectrons = new AliFlowTrackCuts("TOFbayesian e");
409  fCutsTOFbayesianPions = new AliFlowTrackCuts("TOFbayesian pi");
413  fCutsTOFbayesianKaons = new AliFlowTrackCuts("TOFbayesian K");
417  fCutsTOFbayesianProtons = new AliFlowTrackCuts("TOFbayesian p");
421 
422  fCutsTPCdedxElectrons = new AliFlowTrackCuts("TPCdedx e");
425  fCutsTPCdedxPions = new AliFlowTrackCuts("TPCdedx pi");
428  fCutsTPCdedxKaons = new AliFlowTrackCuts("TPCdedx K");
431  fCutsTPCdedxProtons = new AliFlowTrackCuts("TPCdedx p");
434 
435  fCutsTPCpidElectrons = new AliFlowTrackCuts("TPCpid e");
438  fCutsTPCpidPions = new AliFlowTrackCuts("TPCpid pi");
441  fCutsTPCpidKaons = new AliFlowTrackCuts("TPCpid K");
444  fCutsTPCpidProtons = new AliFlowTrackCuts("TPCpid p");
447 
448  fCutsTPCbayesianElectrons = new AliFlowTrackCuts("TPCbayesian e");
451  fCutsTPCbayesianPions = new AliFlowTrackCuts("TPCbayesian pi");
454  fCutsTPCbayesianKaons = new AliFlowTrackCuts("TPCbayesian K");
457  fCutsTPCbayesianProtons = new AliFlowTrackCuts("TPCbayesian p");
460 
465  fCutsMCpions=new AliFlowTrackCuts("MC pi");
466  fCutsMCpions->SetMCPID(211);
468  fCutsMCpions->SetQA();
469  fCutsMCkaons=new AliFlowTrackCuts("MC K");
470  fCutsMCkaons->SetMCPID(321);
472  fCutsMCkaons->SetQA();
473  fCutsMCprotons=new AliFlowTrackCuts("MC p");
474  fCutsMCprotons->SetMCPID(2212);
477 
478  fCutsMCprimaryelectrons=new AliFlowTrackCuts("MCprimary e");
483  fCutsMCprimarypions=new AliFlowTrackCuts("MCprimary pi");
488  fCutsMCprimarykaons=new AliFlowTrackCuts("MCprimary K");
493  fCutsMCprimaryprotons=new AliFlowTrackCuts("MCprimary p");
498 
499  //fOutputList->Add(fESDpid);
500 
526  fOutputList->Add(fCutsMCpions->GetQA());
527  fOutputList->Add(fCutsMCkaons->GetQA());
533 
534  if (fUseDebugFile) fFile = fopen("debug.txt","w");
535 
536  PostData(1, fOutputList);
537 }
538 
539 //________________________________________________________________________
541 {
542  //user exec
543  fESD = dynamic_cast<AliESDEvent*> (InputEvent());
544  if (!fESD) return;
545 
546  //do the calibration bit
547  fESDpid->SetTOFResponse(fESD,AliESDpid::kTOF_T0); // to use T0-TOF
548  fESDpid->MakePID(fESD,kFALSE);
549 
550  if(!fCuts || !fEventCuts)
551  {
552  Printf("No CUTS Defined.........\n");
553  PostData(1, fOutputList);
554  return;
555  }
556 
557  if (!(fEventCuts->IsSelected(fESD,0x0)))
558  {
559  return;
560  }
561 
562  AliStack* stack=NULL;
563  AliMCEvent* mcEvent = MCEvent();
564  if (mcEvent) stack = mcEvent->Stack();
565  if (mcEvent) Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
566 
567  Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
568  Int_t nTracks=fESD->GetNumberOfTracks();
569 
570  AliESDtrack *trackESD=0;
571 
572  fCuts->SetEvent(fESD,mcEvent);
574  fCutsTPCdedxPions->SetEvent(fESD,mcEvent);
575  fCutsTPCdedxKaons->SetEvent(fESD,mcEvent);
578  fCutsTPCpidPions->SetEvent(fESD,mcEvent);
579  fCutsTPCpidKaons->SetEvent(fESD,mcEvent);
580  fCutsTPCpidProtons->SetEvent(fESD,mcEvent);
586  fCutsTOFbetaPions->SetEvent(fESD,mcEvent);
587  fCutsTOFbetaKaons->SetEvent(fESD,mcEvent);
597  fCutsMCelectrons->SetEvent(fESD,mcEvent);
598  fCutsMCpions->SetEvent(fESD,mcEvent);
599  fCutsMCkaons->SetEvent(fESD,mcEvent);
600  fCutsMCprotons->SetEvent(fESD,mcEvent);
605 
606  for(int tr1=0; tr1<nTracks; tr1++)
607  {
608  trackESD=fESD->GetTrack(tr1);
609  if (!trackESD) continue;
610 
611  Double_t p=trackESD->GetP();
612  Double_t pt=trackESD->Pt();
613 
614  if(!(fCuts->IsSelected(trackESD))) continue;
615 
616  Int_t label=-1;
617  if(mcEvent) label=trackESD->GetLabel();
618 
619  Int_t pdgcode=0;
620  if(stack)
621  {
622  TParticle* particle2 = stack->Particle(TMath::Abs(label));
623  pdgcode=particle2->GetPdgCode();
624  }
625 
626  fPvsPt->Fill(p,pt);
627  fMeanPvsP->Fill(p,p);
628 
629  PidTPC(trackESD,pdgcode);
630  PidTOF(trackESD,pdgcode);
631  }
632 
633  //for (Int_t imc=0; imc<(mcEvent!=NULL)?mcEvent->GetNumberOfTracks():0;imc++)
634  if (mcEvent)
635  {
636  for (Int_t imc=0; imc<mcEvent->GetNumberOfTracks();imc++)
637  {
638  printf("imc: %i label:%i\n",imc,mcEvent->GetTrack(imc)->GetLabel());
639  fCutsMCelectrons->IsSelected(mcEvent->GetTrack(imc));
640  fCutsMCpions->IsSelected(mcEvent->GetTrack(imc));
641  fCutsMCkaons->IsSelected(mcEvent->GetTrack(imc));
642  fCutsMCprotons->IsSelected(mcEvent->GetTrack(imc));
643  fCutsMCprimaryelectrons->IsSelected(mcEvent->GetTrack(imc));
644  fCutsMCprimarypions->IsSelected(mcEvent->GetTrack(imc));
645  fCutsMCprimarykaons->IsSelected(mcEvent->GetTrack(imc));
646  fCutsMCprimaryprotons->IsSelected(mcEvent->GetTrack(imc));
647  }
648  }
649 
650  //check the correlation between the global and TPConly number of tracks
653  Int_t multGlobal = fStandardGlobalCuts->Count();
654  Int_t multTPC = fStandardTPCCuts->Count();
655  fTPCvsGlobalMult->Fill(multGlobal,multTPC);
656 
657  if (fFile)
658  {
659  const AliESDVertex* pvtx = fESD->GetPrimaryVertex();
660  const AliESDVertex* tpcvtx = fESD->GetPrimaryVertexTPC();
661  const AliESDVertex* spdvtx = fESD->GetPrimaryVertexSPD();
662  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
663  AliVEventHandler* handler = mgr->GetInputEventHandler();
664  TTree* tree = handler->GetTree();
665  TFile* file = tree->GetCurrentFile();
666  if (multTPC>(23+1.216*multGlobal) || multTPC<(-20+1.087*multGlobal))
667  {
668  fprintf(fFile, "%i %i %s %i\n",multTPC,multGlobal,file->GetName(),fESD->GetEventNumberInFile());
669  fprintf(fFile, " primary vertex: x: %.2f, y: %.2f, z: %.2f, n: %i\n", pvtx->GetX(), pvtx->GetY(), pvtx->GetZ(), pvtx->GetNContributors());
670  fprintf(fFile, " SPD vertex: x: %.2f, y: %.2f, z: %.2f, n: %i\n", spdvtx->GetX(), spdvtx->GetY(), spdvtx->GetZ(), spdvtx->GetNContributors());
671  fprintf(fFile, " TPC vertex: x: %.2f, y: %.2f, z: %.2f, n: %i\n", tpcvtx->GetX(), tpcvtx->GetY(), tpcvtx->GetZ(), tpcvtx->GetNContributors());
672  }
673  }
674 }
675 
676 //________________________________________________________________________
678 {
679  //Terminate
680  if(fCuts)
681  fCuts->Dump();
682 
683  Printf("AliAnalysisTaskPIDflowQA: end of Terminate");
684 }
685 
686 
687 //________________________________________________________________________
689 {
690  //do TPC pid
691  const AliExternalTrackParam* innerParam = t->GetInnerParam();
692  if (!innerParam) return;
693  Double_t pinTPCglobal=innerParam->GetP();
694  Double_t tpcSignal =t->GetTPCsignal();
695  Float_t p=innerParam->P();
696  Float_t sigPion = fESDpid->GetTPCResponse().GetExpectedSignal(pinTPCglobal, AliPID::kPion);
697  Float_t sigKaon = fESDpid->GetTPCResponse().GetExpectedSignal(pinTPCglobal, AliPID::kKaon);
698  Float_t sigProton = fESDpid->GetTPCResponse().GetExpectedSignal(pinTPCglobal, AliPID::kProton);
699  if(!(sigPion>0.0&&sigKaon>0.0&&sigProton>0.0))
700  return;
701 
702  fTPCsignal->Fill(pinTPCglobal,tpcSignal);
703 
704  fTPCsignalPi->Fill(p,(tpcSignal-sigPion)/sigPion);
705  fTPCsignalK->Fill(p,(tpcSignal-sigKaon)/sigKaon);
706  fTPCsignalP->Fill(p,(tpcSignal-sigProton)/sigProton);
707 
720 }
721 
722 //______________________________________________________________________________
723 void AliAnalysisTaskPIDflowQA::PidTOF(AliESDtrack* track, Int_t)
724 {
725  //do TOF pid
726  Bool_t goodtrack = (track) &&
727  (track->GetStatus() & AliESDtrack::kTOFpid) &&
728  (track->GetTOFsignal() > 12000) &&
729  (track->GetTOFsignal() < 100000) &&
730  (track->GetIntegratedLength() > 365);
731 
732  if (!goodtrack) return;
733 
734  const Float_t c = 2.99792457999999984e-02;
735  Float_t p = track->GetP();
736  Float_t l = track->GetIntegratedLength();
737  Float_t trackT0 = fESDpid->GetTOFResponse().GetStartTime(p);
738  //time
739  Float_t timeTOF = track->GetTOFsignal()- trackT0;
740  Double_t integratedTimes[5] = {-1.0,-1.0,-1.0,-1.0,-1.0};
741  track->GetIntegratedTimes(integratedTimes);
742  //beta
743  Float_t beta = l/timeTOF/c;
744  Float_t betaHypothesis[5] = {0.0,0.0,0.0,0.0,0.0};
745  Float_t betadiff[5] = {0.0,0.0,0.0,0.0,0.0};
746  for (Int_t i=0;i<5;i++)
747  {
748  betaHypothesis[i] = l/integratedTimes[i]/c;
749  betadiff[i] = beta-betaHypothesis[i];
750  }
751  //inverse beta
752  Float_t invbeta = 1/beta;
753  Float_t invbetaHypothesis[5] = {0.0,0.0,0.0,0.0,0.0};
754  Float_t invbetadiff[5] = {0.0,0.0,0.0,0.0,0.0};
755  for (Int_t i=0;i<5;i++)
756  {
757  invbetaHypothesis[i] = 1/betaHypothesis[i];
758  invbetadiff[i] = invbeta-invbetaHypothesis[i];
759  }
760 
761  Double_t tpcpid[AliPID::kSPECIES];
762  track->GetTPCpid(tpcpid);
763 
764  //base hists
765  fTOFrawtime->Fill(p,timeTOF);
766  fTOFrawtimeE->Fill(p,timeTOF-integratedTimes[0]);
767  fTOFrawtimePi->Fill(p,timeTOF-integratedTimes[2]);
768  fTOFrawtimeK->Fill(p,timeTOF-integratedTimes[3]);
769  fTOFrawtimeP->Fill(p,timeTOF-integratedTimes[4]);
770 
771  fTOFrawbeta->Fill(p,beta);
772  fTOFrawbetaE->Fill(p,betadiff[0]);
773  fTOFrawbetaPi->Fill(p,betadiff[2]);
774  fTOFrawbetaK->Fill(p,betadiff[3]);
775  fTOFrawbetaP->Fill(p,betadiff[4]);
776 
777  fTOFrawinvbeta->Fill(p,invbeta);
778  fTOFrawinvbetaE->Fill(p,invbetadiff[0]);
779  fTOFrawinvbetaPi->Fill(p,invbetadiff[2]);
780  fTOFrawinvbetaK->Fill(p,invbetadiff[3]);
781  fTOFrawinvbetaP->Fill(p,invbetadiff[4]);
782 
783  //cleanup with TPC
784  if (track->GetStatus() & AliESDtrack::kTOFmismatch) return;
785  if (!TPCTOFagree(track)) return;
786 
787  //responses
788  fTOFtime->Fill(p,timeTOF);
789  fTOFtimeE->Fill(p,timeTOF-integratedTimes[0]);
790  fTOFtimePi->Fill(p,timeTOF-integratedTimes[2]);
791  fTOFtimeK->Fill(p,timeTOF-integratedTimes[3]);
792  fTOFtimeP->Fill(p,timeTOF-integratedTimes[4]);
793 
794  fTOFbeta->Fill(p,beta);
795  fTOFbetaE->Fill(p,betadiff[0]);
796  fTOFbetaPi->Fill(p,betadiff[2]);
797  fTOFbetaK->Fill(p,betadiff[3]);
798  fTOFbetaP->Fill(p,betadiff[4]);
799 
800  fTOFinvbeta->Fill(p,invbeta);
801  fTOFinvbetaE->Fill(p,invbetadiff[0]);
802  fTOFinvbetaPi->Fill(p,invbetadiff[2]);
803  fTOFinvbetaK->Fill(p,invbetadiff[3]);
804  fTOFinvbetaP->Fill(p,invbetadiff[4]);
805 
818 }
819 
820 //______________________________________________________________________________
822 {
823  //get theoretical beta
824  return TMath::Sqrt(1. / (1. + m * m / (p * p)));
825 }
826 
827 //---------------------------------------------------------------//
829 {
830  //check agreement between TOF and TPC pid
831  Bool_t status = kFALSE;
832 
833  Float_t mass[5] = {5.10998909999999971e-04,1.05658000000000002e-01,1.39570000000000000e-01,4.93676999999999977e-01,9.38271999999999995e-01};
834 
835 
836  Double_t exptimes[5];
837  track->GetIntegratedTimes(exptimes);
838 
839  Float_t dedx = track->GetTPCsignal();
840 
841  Float_t p = track->P();
842  Float_t time = track->GetTOFsignal()- fESDpid->GetTOFResponse().GetStartTime(p);
843  Float_t tl = track->GetIntegratedLength();
844 
845  Float_t betagammares = fESDpid->GetTOFResponse().GetExpectedSigma(p, exptimes[4], mass[4]);
846 
847  Float_t betagamma1 = tl/(time-5 *betagammares) * 33.3564095198152043;
848 
849 // printf("betagamma1 = %f\n",betagamma1);
850 
851  if(betagamma1 < 0.1) betagamma1 = 0.1;
852 
853  if(betagamma1 < 0.99999) betagamma1 /= TMath::Sqrt(1-betagamma1*betagamma1);
854  else betagamma1 = 100;
855 
856  Float_t betagamma2 = tl/(time+5 *betagammares) * 33.3564095198152043;
857 // printf("betagamma2 = %f\n",betagamma2);
858 
859  if(betagamma2 < 0.1) betagamma2 = 0.1;
860 
861  if(betagamma2 < 0.99999) betagamma2 /= TMath::Sqrt(1-betagamma2*betagamma2);
862  else betagamma2 = 100;
863 
864 
865  Double_t ptpc[3];
866  track->GetInnerPxPyPz(ptpc);
867  Float_t momtpc=TMath::Sqrt(ptpc[0]*ptpc[0] + ptpc[1]*ptpc[1] + ptpc[2]*ptpc[2]);
868 
869  for(Int_t i=0;i < 5;i++){
870  Float_t resolutionTOF = fESDpid->GetTOFResponse().GetExpectedSigma(p, exptimes[i], mass[i]);
871  if(TMath::Abs(exptimes[i] - time) < 5 * resolutionTOF){
872  Float_t dedxExp = 0;
873  if(i==0) dedxExp = fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kElectron);
874  else if(i==1) dedxExp = fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kMuon);
875  else if(i==2) dedxExp = fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kPion);
876  else if(i==3) dedxExp = fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kKaon);
877  else if(i==4) dedxExp = fESDpid->GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kProton);
878 
879  Float_t resolutionTPC = 2;
880  if(i==0) resolutionTPC = fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kElectron);
881  else if(i==1) resolutionTPC = fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kMuon);
882  else if(i==2) resolutionTPC = fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kPion);
883  else if(i==3) resolutionTPC = fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kKaon);
884  else if(i==4) resolutionTPC = fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kProton);
885 
886  if(TMath::Abs(dedx - dedxExp) < 3 * resolutionTPC){
887  status = kTRUE;
888  }
889  }
890  }
891 
892  Float_t bb1 = fESDpid->GetTPCResponse().Bethe(betagamma1);
893  Float_t bb2 = fESDpid->GetTPCResponse().Bethe(betagamma2);
894  Float_t bbM = fESDpid->GetTPCResponse().Bethe((betagamma1+betagamma2)*0.5);
895 
896 
897  // status = kFALSE;
898  // for nuclei
899  Float_t resolutionTOFpr = fESDpid->GetTOFResponse().GetExpectedSigma(p, exptimes[4], mass[4]);
900  Float_t resolutionTPCpr = fESDpid->GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kProton);
901  if(TMath::Abs(dedx-bb1) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
902  status = kTRUE;
903  }
904  else if(TMath::Abs(dedx-bb2) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
905  status = kTRUE;
906  }
907  else if(TMath::Abs(dedx-bbM) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
908  status = kTRUE;
909  }
910 
911  return status;
912 }
913 
double Double_t
Definition: External.C:58
AliFlowTrackCuts * fCutsTOFbetaSimpleKaons
AliFlowTrackCuts * fCutsTOFbetaPions
TProfile * fMeanPvsP
P vs Pt yield.
Definition: External.C:236
void SetMCisPrimary(Bool_t b=kTRUE)
AliFlowTrackCuts * fCutsTPCbayesianPions
AliFlowTrackCuts * fCutsTPCdedxProtons
void SetPID(AliPID::EParticleType pid, PIDsource s=kTOFpid, Double_t prob=0.9)
TH2F * fTPCsignalP
TPC PID signal as function of p for K+.
AliFlowTrackCuts * fCutsTPCbayesianProtons
AliFlowTrackCuts * fCutsTOFbetaProtons
Double_t mass
static AliFlowTrackCuts * GetStandardGlobalTrackCuts2010()
TCanvas * c
Definition: TestFitELoss.C:172
ClassImp(AliAnalysisTaskPIDflowQA) AliAnalysisTaskPIDflowQA
Int_t Count(AliVEvent *event=NULL)
virtual Bool_t IsSelected(TObject *obj, Int_t id=-666)
AliFlowTrackCuts * fCutsTPCbayesianKaons
void PidTOF(AliESDtrack *t, Int_t pdgcode)
AliFlowTrackCuts * fCutsTOFbetaKaons
AliFlowTrackCuts * fCutsMCprimarykaons
AliFlowTrackCuts * fStandardGlobalCuts
correlation tpc only tracks vs global tracks
AliFlowTrackCuts * fCutsTOFbetaSimpleElectrons
TList * GetQA() const
AliFlowTrackCuts * fCutsTOFbetaElectrons
cuts
AliFlowTrackCuts * fCutsTOFbayesianKaons
int Int_t
Definition: External.C:63
AliFlowTrackCuts * fCutsMCprimaryprotons
float Float_t
Definition: External.C:68
static AliFlowTrackCuts * GetStandardTPCStandaloneTrackCuts2010()
virtual void UserExec(Option_t *option)
AliFlowTrackCuts * fCutsTPCpidElectrons
void SetIgnoreSignInMCPID(Bool_t b=kTRUE)
Bool_t TPCTOFagree(const AliESDtrack *track)
void PidTPC(AliESDtrack *t, Int_t pdgcode)
AliFlowTrackCuts * fCutsMCprimarypions
AliFlowTrackCuts * fCuts
ESD object.
AliFlowTrackCuts * fCutsTOFbayesianPions
void SetEvent(AliVEvent *event, AliMCEvent *mcEvent=NULL)
AliFlowTrackCuts * fStandardTPCCuts
cuts
void SetQA(Bool_t b=kTRUE)
Float_t Beta(Float_t m, Float_t p)
TH2F * fTPCvsGlobalMult
mean p per bin
AliFlowTrackCuts * fCutsTPCdedxElectrons
virtual void Terminate(Option_t *)
AliFlowTrackCuts * fCutsMCprimaryelectrons
TFile * file
AliFlowTrackCuts * fCutsTOFbayesianProtons
void SetRequireStrictTOFTPCagreement(Bool_t b=kTRUE)
const char Option_t
Definition: External.C:48
TH2F * fTPCsignalPi
TPC signal as function of p.
TH2F * fTOFtime
TPC PID signal as function of p for p.
bool Bool_t
Definition: External.C:53
AliFlowTrackCuts * fCutsTOFbayesianElectrons
virtual Bool_t IsSelected(TObject *obj, TObject *objmc)
AliFlowTrackCuts * fCutsTPCbayesianElectrons
TH2F * fTPCsignalK
TPC PID signal as function of p for pi+.
AliFlowTrackCuts * fCutsTOFbetaSimpleProtons
AliFlowTrackCuts * fCutsTOFbetaSimplePions
void SetMCPID(Int_t pid)