1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //-----------------------------------------------------------------//
18 // Implementation of the TOF PID class //
19 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch //
21 //-----------------------------------------------------------------//
26 #include "AliESDtrack.h"
27 #include "AliESDEvent.h"
29 #include "AliTOFpidESD.h"
31 ClassImp(AliTOFpidESD)
33 //_________________________________________________________________________
34 AliTOFpidESD::AliTOFpidESD():
37 fPmax(0), // zero at 0.5 GeV/c for pp
41 //_________________________________________________________________________
42 AliTOFpidESD::AliTOFpidESD(Double_t *param):
45 fPmax(0), // zero at 0.5 GeV/c for pp
49 // The main constructor
53 //fPmax=TMath::Exp(-0.5*3*3)/fSigma; // ~3 sigma at 0.5 GeV/c for PbPb
56 //_________________________________________________________________________
58 AliTOFpidESD::GetMismatchProbability(Double_t p, Double_t mass) const {
60 // Returns the probability of mismatching
61 // assuming 1/(p*beta)^2 scaling
63 const Double_t km=0.5; // "reference" momentum (GeV/c)
65 Double_t ref2=km*km*km*km/(km*km + mass*mass);// "reference" (p*beta)^2
66 Double_t p2beta2=p*p*p*p/(p*p + mass*mass);
68 return fPmax*ref2/p2beta2;
71 //_________________________________________________________________________
72 Int_t AliTOFpidESD::MakePID(AliESDEvent *event, Double_t timeZero)
75 // This function calculates the "detector response" PID probabilities
76 // Just for a bare hint...
78 AliDebug(1,Form("TOF PID Parameters: Sigma (ps)= %f, Range= %f",fSigma,fRange));
79 AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
82 return MakePID(event);
85 //_________________________________________________________________________
86 Int_t AliTOFpidESD::MakePID(AliESDEvent *event)
89 // This function calculates the "detector response" PID probabilities
90 // Just for a bare hint...
92 Int_t ntrk=event->GetNumberOfTracks();
93 AliESDtrack **tracks=new AliESDtrack*[ntrk];
96 for (i=0; i<ntrk; i++) {
97 AliESDtrack *t=event->GetTrack(i);
101 for (i=0; i<ntrk; i++) {
102 AliESDtrack *t=tracks[i];
103 if ((t->GetStatus()&AliESDtrack::kTOFout)==0) continue;
104 if ((t->GetStatus()&AliESDtrack::kTIME)==0) continue;
106 Double_t time[AliPID::kSPECIES];
107 if (!ExpectedSignals(t,time,AliPID::kSPECIES)) continue;
108 Double_t sigma[AliPID::kSPECIES];
109 if (!ExpectedSigmas(t,sigma,AliPID::kSPECIES)) continue;
111 AliDebug(2,Form("Expected TOF signals [ps]: %f %f %f %f %f",
112 GetExpectedSignal(t,AliPID::kElectron),
113 GetExpectedSignal(t,AliPID::kMuon),
114 GetExpectedSignal(t,AliPID::kPion),
115 GetExpectedSignal(t,AliPID::kKaon),
116 GetExpectedSignal(t,AliPID::kProton)
119 AliDebug(2,Form("Expected TOF std deviations [ps]: %f %f %f %f %f",
120 GetExpectedSigma(t,AliPID::kElectron),
121 GetExpectedSigma(t,AliPID::kMuon),
122 GetExpectedSigma(t,AliPID::kPion),
123 GetExpectedSigma(t,AliPID::kKaon),
124 GetExpectedSigma(t,AliPID::kProton)
127 AliDebug(2,Form("Expected TOF std deviations [number of expected sigmas]: %f %f %f %f %f",
128 GetNumberOfSigmas(t,AliPID::kElectron),
129 GetNumberOfSigmas(t,AliPID::kMuon),
130 GetNumberOfSigmas(t,AliPID::kPion),
131 GetNumberOfSigmas(t,AliPID::kKaon),
132 GetNumberOfSigmas(t,AliPID::kProton)
135 Double_t tof = t->GetTOFsignal() - fTime0;
137 Double_t p[AliPID::kSPECIES];
138 Bool_t mismatch = kTRUE, heavy = kTRUE;
139 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
140 Double_t sig = sigma[j];
141 if (TMath::Abs(tof-time[j]) > fRange*sig) {
142 p[j] = TMath::Exp(-0.5*fRange*fRange)/sig;
144 p[j] = TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sig*sig))/sig;
146 // Check the mismatching
147 Double_t mass = AliPID::ParticleMass(j);
148 Double_t pm = GetMismatchProbability(t->GetP(),mass);
149 if (p[j]>pm) mismatch = kFALSE;
151 // Check for particles heavier than (AliPID::kSPECIES - 1)
152 if (tof < (time[j] + fRange*sig)) heavy=kFALSE;
157 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
161 if (heavy) t->ResetStatus(AliESDtrack::kTOFpid);
170 //_________________________________________________________________________
171 Bool_t AliTOFpidESD::ExpectedSignals(const AliESDtrack *t,
172 Double_t s[],Int_t n) const
175 // Return the expected PID signals for the involved particle species
178 if (n > AliPID::kSPECIESN) return kFALSE;
179 if ( !t->IsOn(AliESDtrack::kTIME) ) return kFALSE;
181 Double_t time[AliPID::kSPECIESN];
182 t->GetIntegratedTimes(time);
183 for (Int_t i=0; i<n; i++) s[i]=time[i];
187 //_________________________________________________________________________
188 Bool_t AliTOFpidESD::ExpectedSigmas(const AliESDtrack *t,
189 Double_t s[],Int_t n) const
192 // Return the expected sigma of PID signals for the involved
194 // This approximate (but reasonable) formula takes into account the
195 // relative momentum resolution.
198 Double_t time[AliPID::kSPECIESN];
199 if ( !ExpectedSignals(t,time,n) ) return kFALSE;
201 Double_t mom = t->GetP();
202 Double_t dpp = 0.01; //mean relative pt resolution;
203 if (mom>0.5) dpp = 0.01*mom;
204 for (Int_t i=0; i<n; i++) {
205 Double_t mass = AliPID::ParticleMass(i);
206 Double_t sigma = dpp*time[i]/(1.+ mom*mom/(mass*mass));
207 s[i] = TMath::Sqrt(sigma*sigma + fSigma*fSigma);
212 //_________________________________________________________________________
213 Bool_t AliTOFpidESD::NumberOfSigmas(const AliESDtrack *t,
214 Double_t s[],Int_t n) const
217 // Returns the deviation of the actual PID signal from the expected
218 // signal, in units of expected sigmas.
221 Double_t time[AliPID::kSPECIESN];
222 if ( !ExpectedSignals(t,time,n) ) return kFALSE;
224 if ( !ExpectedSigmas(t,s,n) ) return kFALSE;
226 Double_t tof = t->GetTOFsignal() - fTime0;
227 for (Int_t i=0; i<n; i++) s[i] = (time[i]-tof)/s[i];
232 //_________________________________________________________________________
233 Double_t AliTOFpidESD::GetExpectedSignal(const AliESDtrack *t,
234 AliPID::EParticleType n) const
237 // Return the expected PID signal for the specified particle type.
238 // If the operation is not possible, return a negative value.
241 if (Int_t(n) >= AliPID::kSPECIESN) return -1.;
242 if ( !t->IsOn(AliESDtrack::kTIME) ) return -1.;
244 Double_t time[AliPID::kSPECIESN];
245 t->GetIntegratedTimes(time);
250 //_________________________________________________________________________
251 Double_t AliTOFpidESD::GetExpectedSigma(const AliESDtrack *t,
252 AliPID::EParticleType n) const
255 // Return the expected sigma of the PID signal for the specified
257 // If the operation is not possible, return a negative value.
260 Double_t time[AliPID::kSPECIESN];
261 if ( !ExpectedSignals(t,time,AliPID::kSPECIESN) ) return -1.;
263 Double_t mom = t->GetP();
264 Double_t dpp = 0.01; //mean relative pt resolution;
265 if (mom>0.5) dpp = 0.01*mom;
267 Double_t mass = AliPID::ParticleMass(n);
268 Double_t sigma = dpp*time[n]/(1.+ mom*mom/(mass*mass));
270 return TMath::Sqrt(sigma*sigma + fSigma*fSigma);
273 //_________________________________________________________________________
274 Double_t AliTOFpidESD::GetNumberOfSigmas(const AliESDtrack *t,
275 AliPID::EParticleType n) const
278 // Returns the deviation of the actual PID signal from the expected
279 // signal for the specified particle type, in units of expected
281 // If the operation is not possible, return a negative value.
284 Double_t time=GetExpectedSignal(t,n);;
285 if (time < 0.) return -1.;
287 Double_t sigma=GetExpectedSigma(t,n);
288 if (sigma < 0.) return -1;
290 Double_t tof=t->GetTOFsignal() - fTime0;
291 return (time-tof)/sigma;