]>
Commit | Line | Data |
---|---|---|
10d100d4 | 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 | ||
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" | |
24 | #include "AliLog.h" | |
a2c30af1 | 25 | #include "TF1.h" |
3cb11031 | 26 | #include "TH1F.h" |
27 | #include "TH1D.h" | |
28 | #include "TFile.h" | |
c53e310b | 29 | #include "TRandom.h" |
10d100d4 | 30 | |
31 | #include "AliTOFPIDResponse.h" | |
32 | ||
33 | ClassImp(AliTOFPIDResponse) | |
34 | ||
a2c30af1 | 35 | TF1 *AliTOFPIDResponse::fTOFtailResponse = NULL; // function to generate a TOF tail |
3cb11031 | 36 | TH1F *AliTOFPIDResponse::fHmismTOF = NULL; // TOF mismatch distribution |
37 | TH1D *AliTOFPIDResponse::fHchannelTOFdistr=NULL; // TOF channel distance distribution | |
a2c30af1 | 38 | |
10d100d4 | 39 | //_________________________________________________________________________ |
40 | AliTOFPIDResponse::AliTOFPIDResponse(): | |
41 | fSigma(0), | |
42 | fPmax(0), // zero at 0.5 GeV/c for pp | |
43 | fTime0(0) | |
44 | { | |
679de35e | 45 | fPar[0] = 0.008; |
46 | fPar[1] = 0.008; | |
47 | fPar[2] = 0.002; | |
48 | fPar[3] = 40.0; | |
95ad1018 | 49 | |
a2c30af1 | 50 | if(!fTOFtailResponse){ |
c5fb644a | 51 | fTOFtailResponse = new TF1("fTOFtail","[0]*TMath::Exp(-(x-[1])*(x-[1])/2/[2]/[2])* (x < [1]+[3]*[2]) + (x > [1]+[3]*[2])*[0]*TMath::Exp(-(x-[1]-[3]*[2]*0.5)*[3]/[2] * 0.0111)*0.018",-1000,1000); |
a2c30af1 | 52 | fTOFtailResponse->SetParameter(0,1); |
c5fb644a | 53 | fTOFtailResponse->SetParameter(1,-26); |
a2c30af1 | 54 | fTOFtailResponse->SetParameter(2,1); |
c5fb644a | 55 | fTOFtailResponse->SetParameter(3,0.89); |
a2c30af1 | 56 | fTOFtailResponse->SetNpx(10000); |
57 | } | |
58 | ||
59 | ||
6c68754e | 60 | // Reset T0 info |
61 | ResetT0info(); | |
62 | SetMomBoundary(); | |
10d100d4 | 63 | } |
64 | //_________________________________________________________________________ | |
65 | AliTOFPIDResponse::AliTOFPIDResponse(Double_t *param): | |
66 | fSigma(param[0]), | |
67 | fPmax(0), // zero at 0.5 GeV/c for pp | |
68 | fTime0(0) | |
69 | { | |
70 | // | |
71 | // The main constructor | |
72 | // | |
73 | // | |
74 | ||
75 | //fPmax=TMath::Exp(-0.5*3*3)/fSigma; // ~3 sigma at 0.5 GeV/c for PbPb | |
6c68754e | 76 | |
679de35e | 77 | fPar[0] = 0.008; |
78 | fPar[1] = 0.008; | |
79 | fPar[2] = 0.002; | |
80 | fPar[3] = 40.0; | |
95ad1018 | 81 | |
c5fb644a | 82 | if(!fTOFtailResponse){ |
83 | fTOFtailResponse = new TF1("fTOFtail","[0]*TMath::Exp(-(x-[1])*(x-[1])/2/[2]/[2])* (x < [1]+[3]*[2]) + (x > [1]+[3]*[2])*[0]*TMath::Exp(-(x-[1]-[3]*[2]*0.5)*[3]/[2] * 0.0111)*0.018",-1000,1000); | |
84 | fTOFtailResponse->SetParameter(0,1); | |
85 | fTOFtailResponse->SetParameter(1,-26); | |
86 | fTOFtailResponse->SetParameter(2,1); | |
87 | fTOFtailResponse->SetParameter(3,0.89); | |
88 | fTOFtailResponse->SetNpx(10000); | |
89 | } | |
90 | ||
6c68754e | 91 | // Reset T0 info |
92 | ResetT0info(); | |
93 | SetMomBoundary(); | |
10d100d4 | 94 | } |
95 | //_________________________________________________________________________ | |
b3f687a1 | 96 | void AliTOFPIDResponse::SetTOFtail(Float_t tail){ |
97 | if(!fTOFtailResponse){ | |
98 | fTOFtailResponse = new TF1("fTOFtail","[0]*TMath::Exp(-(x-[1])*(x-[1])/2/[2]/[2])* (x < [1]+[3]*[2]) + (x > [1]+[3]*[2])*[0]*TMath::Exp(-(x-[1]-[3]*[2]*0.5)*[3]/[2] * 0.0111)*0.018",-1000,1000); | |
99 | fTOFtailResponse->SetParameter(0,1); | |
100 | fTOFtailResponse->SetParameter(1,-26); | |
101 | fTOFtailResponse->SetParameter(2,1); | |
102 | fTOFtailResponse->SetParameter(3,tail); | |
103 | fTOFtailResponse->SetNpx(10000); | |
104 | } | |
105 | else{ | |
106 | fTOFtailResponse->SetParameter(3,tail); | |
107 | } | |
108 | } | |
42bef6c9 | 109 | void AliTOFPIDResponse::SetTOFtailAllPara(Float_t mean,Float_t tail){ |
110 | if(!fTOFtailResponse){ | |
111 | fTOFtailResponse = new TF1("fTOFtail","[0]*TMath::Exp(-(x-[1])*(x-[1])/2/[2]/[2])* (x < [1]+[3]*[2]) + (x > [1]+[3]*[2])*[0]*TMath::Exp(-(x-[1]-[3]*[2]*0.5)*[3]/[2] * 0.0111)*0.018",-1000,1000); | |
112 | fTOFtailResponse->SetParameter(0,1); | |
113 | fTOFtailResponse->SetParameter(1,mean); | |
114 | fTOFtailResponse->SetParameter(2,1); | |
115 | fTOFtailResponse->SetParameter(3,tail); | |
116 | fTOFtailResponse->SetNpx(10000); | |
117 | } | |
118 | else{ | |
119 | fTOFtailResponse->SetParameter(1,mean); | |
120 | fTOFtailResponse->SetParameter(3,tail); | |
121 | } | |
122 | } | |
123 | ||
b3f687a1 | 124 | //_________________________________________________________________________ |
10d100d4 | 125 | Double_t |
4fc0f532 | 126 | AliTOFPIDResponse::GetMismatchProbability(Double_t time,Double_t eta) const { |
127 | if(!fHmismTOF){ | |
128 | TFile *fmism = new TFile("$ALICE_ROOT/TOF/data/TOFmismatchDistr.root"); | |
129 | if(fmism) fHmismTOF = (TH1F *) fmism->Get("TOFmismDistr"); | |
130 | if(!fHmismTOF){ | |
131 | printf("I cannot retrive TOF mismatch histos... skipped!"); | |
132 | return 1E-4; | |
133 | } | |
134 | fHmismTOF->Scale(TMath::Sqrt(2*TMath::Pi())/(fHmismTOF->Integral(1,fHmismTOF->GetNbinsX()) * fHmismTOF->GetBinWidth(1))); | |
135 | ||
136 | TFile *fchDist = new TFile("$ALICE_ROOT/TOF/data/TOFchannelDist.root"); | |
137 | if(fchDist) fHchannelTOFdistr = (TH1D *) fchDist->Get("hTOFchanDist"); | |
138 | if(!fHchannelTOFdistr){ | |
139 | printf("I cannot retrive TOF channel distance distribution... skipped!"); | |
140 | return 1E-4; | |
141 | } | |
142 | } | |
10d100d4 | 143 | |
4fc0f532 | 144 | Float_t etaAbs = TMath::Abs(eta); |
145 | Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs); | |
146 | if(channel < 1 || etaAbs > 1) channel = 1; | |
147 | Float_t distIP = fHchannelTOFdistr->GetBinContent(channel); | |
148 | ||
149 | Double_t mismWeight = fHmismTOF->Interpolate(time - distIP*3.35655419905265973e+01); | |
10d100d4 | 150 | |
4fc0f532 | 151 | return mismWeight; |
10d100d4 | 152 | } |
153 | //_________________________________________________________________________ | |
154 | Double_t AliTOFPIDResponse::GetExpectedSigma(Float_t mom, Float_t time, Float_t mass) const { | |
155 | // | |
156 | // Return the expected sigma of the PID signal for the specified | |
67376d1d | 157 | // particle mass/Z. |
10d100d4 | 158 | // If the operation is not possible, return a negative value. |
159 | // | |
160 | ||
95ad1018 | 161 | Double_t dpp=fPar[0] + fPar[1]*mom + fPar[2]*mass/mom; //mean relative pt resolution; |
10d100d4 | 162 | |
163 | ||
164 | Double_t sigma = dpp*time/(1.+ mom*mom/(mass*mass)); | |
6c68754e | 165 | |
166 | Int_t index = GetMomBin(mom); | |
167 | ||
168 | Double_t t0res = fT0resolution[index]; | |
169 | ||
95ad1018 | 170 | return TMath::Sqrt(sigma*sigma + fPar[3]*fPar[3]/mom/mom + fSigma*fSigma + t0res*t0res); |
10d100d4 | 171 | |
10d100d4 | 172 | } |
6c68754e | 173 | //_________________________________________________________________________ |
67376d1d | 174 | Double_t AliTOFPIDResponse::GetExpectedSigma(Float_t mom, Float_t time, AliPID::EParticleType type) const { |
175 | // | |
176 | // Return the expected sigma of the PID signal for the specified | |
177 | // particle type. | |
178 | // If the operation is not possible, return a negative value. | |
179 | // | |
180 | ||
181 | Double_t mass = AliPID::ParticleMassZ(type); | |
182 | Double_t dpp=fPar[0] + fPar[1]*mom + fPar[2]*mass/mom; //mean relative pt resolution; | |
183 | ||
184 | ||
185 | Double_t sigma = dpp*time/(1.+ mom*mom/(mass*mass)); | |
186 | ||
187 | Int_t index = GetMomBin(mom); | |
188 | ||
189 | Double_t t0res = fT0resolution[index]; | |
190 | ||
191 | return TMath::Sqrt(sigma*sigma + fPar[3]*fPar[3]/mom/mom + fSigma*fSigma + t0res*t0res); | |
192 | ||
193 | } | |
194 | //_________________________________________________________________________ | |
195 | Double_t AliTOFPIDResponse::GetExpectedSignal(const AliVTrack* track,AliPID::EParticleType type) const { | |
196 | // | |
197 | // Return the expected signal of the PID signal for the particle type | |
198 | // If the operation is not possible, return a negative value. | |
199 | // | |
2ec09a5e | 200 | Double_t expt[AliPID::kSPECIESC]; |
fc9b31a7 | 201 | track->GetIntegratedTimes(expt,AliPID::kSPECIESC); |
67376d1d | 202 | if (type<=AliPID::kProton) return expt[type]; |
203 | else { | |
2ec09a5e RS |
204 | if (expt[type]<1.E-1) { |
205 | Double_t p = track->P(); | |
206 | Double_t massZ = AliPID::ParticleMassZ(type); | |
207 | return expt[0]/p*massZ*TMath::Sqrt(1.+p*p/massZ/massZ); | |
208 | } else return expt[type]; | |
67376d1d | 209 | } |
210 | } | |
211 | //_________________________________________________________________________ | |
6c68754e | 212 | Int_t AliTOFPIDResponse::GetMomBin(Float_t p) const{ |
f858b00e | 213 | // |
214 | // Returns the momentum bin index | |
215 | // | |
216 | ||
6c68754e | 217 | Int_t i=0; |
218 | while(p > fPCutMin[i] && i < fNmomBins) i++; | |
219 | if(i > 0) i--; | |
10d100d4 | 220 | |
6c68754e | 221 | return i; |
222 | } | |
223 | //_________________________________________________________________________ | |
224 | void AliTOFPIDResponse::SetMomBoundary(){ | |
f858b00e | 225 | // |
226 | // Set boundaries for momentum bins | |
227 | // | |
228 | ||
6c68754e | 229 | fPCutMin[0] = 0.3; |
230 | fPCutMin[1] = 0.5; | |
231 | fPCutMin[2] = 0.6; | |
232 | fPCutMin[3] = 0.7; | |
233 | fPCutMin[4] = 0.8; | |
234 | fPCutMin[5] = 0.9; | |
235 | fPCutMin[6] = 1; | |
236 | fPCutMin[7] = 1.2; | |
237 | fPCutMin[8] = 1.5; | |
238 | fPCutMin[9] = 2; | |
239 | fPCutMin[10] = 3; | |
240 | } | |
f858b00e | 241 | //_________________________________________________________________________ |
7170298c | 242 | Float_t AliTOFPIDResponse::GetStartTime(Float_t mom) const { |
f858b00e | 243 | // |
244 | // Returns event_time value as estimated by TOF combinatorial algorithm | |
245 | // | |
246 | ||
247 | Int_t ibin = GetMomBin(mom); | |
248 | return GetT0bin(ibin); | |
249 | ||
250 | } | |
251 | //_________________________________________________________________________ | |
7170298c | 252 | Float_t AliTOFPIDResponse::GetStartTimeRes(Float_t mom) const { |
f858b00e | 253 | // |
254 | // Returns event_time resolution as estimated by TOF combinatorial algorithm | |
255 | // | |
256 | ||
257 | Int_t ibin = GetMomBin(mom); | |
258 | return GetT0binRes(ibin); | |
259 | ||
260 | } | |
d4d15b21 | 261 | //_________________________________________________________________________ |
262 | Int_t AliTOFPIDResponse::GetStartTimeMask(Float_t mom) const { | |
263 | // | |
264 | // Returns event_time mask | |
265 | // | |
266 | ||
267 | Int_t ibin = GetMomBin(mom); | |
268 | return GetT0binMask(ibin); | |
269 | ||
270 | } | |
a2c30af1 | 271 | //_________________________________________________________________________ |
c53e310b | 272 | Double_t AliTOFPIDResponse::GetTailRandomValue(Float_t pt,Float_t eta,Float_t time,Float_t addmism) // generate a random value to add a tail to TOF time (for MC analyses) |
a2c30af1 | 273 | { |
c53e310b | 274 | |
275 | // To add mismatch | |
276 | Float_t mismAdd = addmism*0.01; | |
277 | if(pt>1.0) mismAdd /= pt; | |
278 | ||
279 | if(mismAdd > 0.01){ // apply additional mismatch | |
280 | if(gRandom->Rndm() < mismAdd){ | |
281 | return GetMismatchRandomValue(eta)-time; | |
282 | } | |
283 | } | |
284 | ||
a2c30af1 | 285 | if(fTOFtailResponse) |
286 | return fTOFtailResponse->GetRandom(); | |
287 | else | |
288 | return 0.0; | |
289 | } | |
3cb11031 | 290 | //_________________________________________________________________________ |
291 | Double_t AliTOFPIDResponse::GetMismatchRandomValue(Float_t eta) // generate a random value for mismatched tracks (for MC analyses) | |
292 | { | |
293 | if(!fHmismTOF){ | |
294 | TFile *fmism = new TFile("$ALICE_ROOT/TOF/data/TOFmismatchDistr.root"); | |
295 | if(fmism) fHmismTOF = (TH1F *) fmism->Get("TOFmismDistr"); | |
296 | if(!fHmismTOF){ | |
297 | printf("I cannot retrive TOF mismatch histos... skipped!"); | |
298 | return -10000.; | |
299 | } | |
4fc0f532 | 300 | fHmismTOF->Scale(TMath::Sqrt(2*TMath::Pi())/(fHmismTOF->Integral(1,fHmismTOF->GetNbinsX()) * fHmismTOF->GetBinWidth(1))); |
3cb11031 | 301 | |
302 | TFile *fchDist = new TFile("$ALICE_ROOT/TOF/data/TOFchannelDist.root"); | |
303 | if(fchDist) fHchannelTOFdistr = (TH1D *) fchDist->Get("hTOFchanDist"); | |
304 | if(!fHchannelTOFdistr){ | |
305 | printf("I cannot retrive TOF channel distance distribution... skipped!"); | |
306 | return -10000.; | |
307 | } | |
308 | } | |
309 | ||
310 | Float_t etaAbs = TMath::Abs(eta); | |
311 | Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs); | |
312 | if(channel < 1 || etaAbs > 1) channel = 1; | |
313 | Float_t distIP = fHchannelTOFdistr->GetBinContent(channel); | |
314 | ||
315 | return fHmismTOF->GetRandom() + distIP*3.35655419905265973e+01; | |
316 | } | |
c53e310b | 317 | //_________________________________________________________________________ |
318 | Int_t AliTOFPIDResponse::GetTOFchannel(AliVParticle *trk) const{ | |
319 | Float_t etaAbs = TMath::Abs(trk->Eta()); | |
320 | Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs); | |
321 | if(channel < 1 || etaAbs > 1) channel = 1; | |
322 | ||
323 | return channel; | |
324 | } |