Shuttle debugging line removed.
[u/mrichter/AliRoot.git] / TOF / AliTOFpidESD.cxx
CommitLineData
c630aafd 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 purposes 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 purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
0e46b9ae 16//-----------------------------------------------------------------//
17// //
18// Implementation of the TOF PID class //
19// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch //
20// //
21//-----------------------------------------------------------------//
22
23#include "TMath.h"
02cdc6ac 24#include "AliLog.h"
0e46b9ae 25
c630aafd 26#include "AliESDtrack.h"
af885e0f 27#include "AliESDEvent.h"
c630aafd 28
0e46b9ae 29#include "AliTOFpidESD.h"
30
c630aafd 31ClassImp(AliTOFpidESD)
32
0f4a7374 33//_________________________________________________________________________
7a8614f3 34AliTOFpidESD::AliTOFpidESD():
655e379f 35 fSigma(0),
7a8614f3 36 fRange(0),
37 fPmax(0) // zero at 0.5 GeV/c for pp
655e379f 38{
39}
40//_________________________________________________________________________
41AliTOFpidESD::AliTOFpidESD(Double_t *param):
7a8614f3 42 fSigma(param[0]),
43 fRange(param[1]),
44 fPmax(0) // zero at 0.5 GeV/c for pp
45{
0f4a7374 46 //
47 // The main constructor
48 //
7a8614f3 49 //
50
51 //fPmax=TMath::Exp(-0.5*3*3)/fSigma; // ~3 sigma at 0.5 GeV/c for PbPb
52}
53
54Double_t
55AliTOFpidESD::GetMismatchProbability(Double_t p, Double_t mass) const {
56 //
57 // Returns the probability of mismatching
58 // assuming 1/(p*beta)^2 scaling
59 //
62bdc654 60 const Double_t km=0.5; // "reference" momentum (GeV/c)
7a8614f3 61
62bdc654 62 Double_t ref2=km*km*km*km/(km*km + mass*mass);// "reference" (p*beta)^2
7a8614f3 63 Double_t p2beta2=p*p*p*p/(p*p + mass*mass);
0f4a7374 64
7a8614f3 65 return fPmax*ref2/p2beta2;
0f4a7374 66}
67
0f4a7374 68//_________________________________________________________________________
af885e0f 69Int_t AliTOFpidESD::MakePID(AliESDEvent *event, Double_t timeZero)
bc9f08da 70{
71 //
72 // This function calculates the "detector response" PID probabilities
73 // Just for a bare hint...
74
02cdc6ac 75 AliDebug(1,Form("TOF PID Parameters: Sigma (ps)= %f, Range= %f",fSigma,fRange));
76 AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
7a8614f3 77
bc9f08da 78 Int_t ntrk=event->GetNumberOfTracks();
79 AliESDtrack **tracks=new AliESDtrack*[ntrk];
80
81 Int_t i;
82 for (i=0; i<ntrk; i++) {
83 AliESDtrack *t=event->GetTrack(i);
84 tracks[i]=t;
85 }
86
87 for (i=0; i<ntrk; i++) {
88 AliESDtrack *t=tracks[i];
89 if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
90 if ((t->GetStatus()&AliESDtrack::kTIME)==0) continue;
91 Double_t tof=t->GetTOFsignal()-timeZero;
92 Double_t time[10]; t->GetIntegratedTimes(time);
93 Double_t p[10];
94 Double_t mom=t->GetP();
7a8614f3 95 Bool_t mismatch=kTRUE, heavy=kTRUE;
bc9f08da 96 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
97 Double_t mass=AliPID::ParticleMass(j);
98 Double_t dpp=0.01; //mean relative pt resolution;
99 if (mom>0.5) dpp=0.01*mom;
100 Double_t sigma=dpp*time[j]/(1.+ mom*mom/(mass*mass));
101 sigma=TMath::Sqrt(sigma*sigma + fSigma*fSigma);
102 if (TMath::Abs(tof-time[j]) > fRange*sigma) {
103 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
7a8614f3 104 } else
105 p[j]=TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sigma*sigma))/sigma;
106
107 // Check the mismatching
108 Double_t pm=GetMismatchProbability(mom,mass);
109 if (p[j]>pm) mismatch=kFALSE;
110
111 // Check for particles heavier than (AliPID::kSPECIES - 1)
112 if (tof < (time[j] + fRange*sigma)) heavy=kFALSE;
113
bc9f08da 114 }
7a8614f3 115
116 if (mismatch)
117 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
118
bc9f08da 119 t->SetTOFpid(p);
7a8614f3 120
121 if (heavy) t->ResetStatus(AliESDtrack::kTOFpid);
122
bc9f08da 123 }
124
125 delete[] tracks;
126
127 return 0;
128}
129
130//_________________________________________________________________________
af885e0f 131Int_t AliTOFpidESD::MakePID(AliESDEvent *event)
c630aafd 132{
133 //
134 // This function calculates the "detector response" PID probabilities
135 // Just for a bare hint...
136
c630aafd 137 Int_t ntrk=event->GetNumberOfTracks();
3f83f224 138 AliESDtrack **tracks=new AliESDtrack*[ntrk];
139
140 Int_t i;
141 for (i=0; i<ntrk; i++) {
c630aafd 142 AliESDtrack *t=event->GetTrack(i);
3f83f224 143 tracks[i]=t;
144 }
3f83f224 145
3f83f224 146 for (i=0; i<ntrk; i++) {
147 AliESDtrack *t=tracks[i];
74ea065c 148 if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
3f83f224 149 if ((t->GetStatus()&AliESDtrack::kTIME)==0) continue;
74ea065c 150 Double_t tof=t->GetTOFsignal();
151 Double_t time[10]; t->GetIntegratedTimes(time);
c630aafd 152 Double_t p[10];
153 Double_t mom=t->GetP();
7a8614f3 154 Bool_t mismatch=kTRUE, heavy=kTRUE;
304864ab 155 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
156 Double_t mass=AliPID::ParticleMass(j);
3f83f224 157 Double_t dpp=0.01; //mean relative pt resolution;
158 if (mom>0.5) dpp=0.01*mom;
159 Double_t sigma=dpp*time[j]/(1.+ mom*mom/(mass*mass));
c630aafd 160 sigma=TMath::Sqrt(sigma*sigma + fSigma*fSigma);
161 if (TMath::Abs(tof-time[j]) > fRange*sigma) {
431be10d 162 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
7a8614f3 163 } else
164 p[j]=TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sigma*sigma))/sigma;
165
166 // Check the mismatching
167 Double_t pm=GetMismatchProbability(mom,mass);
168 if (p[j]>pm) mismatch=kFALSE;
169
170 // Check for particles heavier than (AliPID::kSPECIES - 1)
171 if (tof < (time[j] + fRange*sigma)) heavy=kFALSE;
172
c630aafd 173 }
7a8614f3 174
175 if (mismatch)
176 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
177
c630aafd 178 t->SetTOFpid(p);
7a8614f3 179
180 if (heavy) t->ResetStatus(AliESDtrack::kTOFpid);
181
c630aafd 182 }
183
3f83f224 184 delete[] tracks;
74ea065c 185
c630aafd 186 return 0;
187}
0f4a7374 188