]>
Commit | Line | Data |
---|---|---|
87594435 | 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 | ||
acd84897 | 16 | /* $Id$ */ |
fb17acd4 | 17 | |
87594435 | 18 | //------------------------------------------------------------------------- |
19 | // Implementation of the AliKalmanTrack class | |
066782e8 | 20 | // that is the base for AliTPCtrack, AliITStrackV2 and AliTRDtrack |
87594435 | 21 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch |
22 | //------------------------------------------------------------------------- | |
23 | ||
24 | #include "AliKalmanTrack.h" | |
74f9526e | 25 | #include "AliPDG.h" |
26 | #include "TPDGCode.h" | |
27 | #include "TDatabasePDG.h" | |
87594435 | 28 | |
29 | ClassImp(AliKalmanTrack) | |
30 | ||
116cbefd | 31 | Double_t AliKalmanTrack::fgConvConst; |
9b280d80 | 32 | |
e2afb3b6 | 33 | //_______________________________________________________________________ |
34 | AliKalmanTrack::AliKalmanTrack(): | |
35 | fLab(-3141593), | |
36 | fChi2(0), | |
37 | fMass(0.13957), | |
38 | fN(0) | |
39 | { | |
116cbefd | 40 | // |
41 | // Default constructor | |
42 | // | |
43 | if (fgConvConst==0) | |
e2afb3b6 | 44 | Fatal("AliKalmanTrack()","The magnetic field has not been set !\n"); |
74f9526e | 45 | |
46 | fStartTimeIntegral = kFALSE; | |
47 | fIntegratedLength = 0; | |
48 | for(Int_t i=0; i<5; i++) fIntegratedTime[i] = 0; | |
e2afb3b6 | 49 | } |
50 | ||
51 | //_______________________________________________________________________ | |
52 | AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t): | |
53 | TObject(t), | |
54 | fLab(t.fLab), | |
55 | fChi2(t.fChi2), | |
56 | fMass(t.fMass), | |
57 | fN(t.fN) | |
58 | { | |
116cbefd | 59 | // |
60 | // Copy constructor | |
61 | // | |
62 | if (fgConvConst==0) | |
e2afb3b6 | 63 | Fatal("AliKalmanTrack(const AliKalmanTrack&)", |
64 | "The magnetic field has not been set !\n"); | |
74f9526e | 65 | |
66 | fStartTimeIntegral = t.fStartTimeIntegral; | |
67 | fIntegratedLength = t.fIntegratedLength; | |
68 | ||
69 | for (Int_t i=0; i<5; i++) | |
70 | fIntegratedTime[i] = t.fIntegratedTime[i]; | |
71 | } | |
c5507f6d | 72 | |
73 | //_______________________________________________________________________ | |
74 | Double_t AliKalmanTrack::GetX() const | |
75 | { | |
76 | Warning("GetX()","Method must be overloaded !\n"); | |
77 | return 0.; | |
78 | } | |
79 | //_______________________________________________________________________ | |
80 | Double_t AliKalmanTrack::GetdEdx() const | |
81 | { | |
82 | Warning("GetdEdx()","Method must be overloaded !\n"); | |
83 | return 0.; | |
84 | } | |
85 | ||
86 | //_______________________________________________________________________ | |
87 | Double_t AliKalmanTrack::GetY() const | |
88 | { | |
89 | Double_t par[5]; | |
90 | Double_t localX = GetX(); | |
91 | GetExternalParameters(localX, par); | |
92 | return par[0]; | |
93 | } | |
94 | //_______________________________________________________________________ | |
95 | Double_t AliKalmanTrack::GetZ() const | |
96 | { | |
97 | Double_t par[5]; | |
98 | Double_t localX = GetX(); | |
99 | GetExternalParameters(localX, par); | |
100 | return par[1]; | |
101 | } | |
102 | //_______________________________________________________________________ | |
103 | Double_t AliKalmanTrack::GetSnp() const | |
104 | { | |
105 | Double_t par[5]; | |
106 | Double_t localX = GetX(); | |
107 | GetExternalParameters(localX, par); | |
108 | return par[2]; | |
109 | } | |
110 | //_______________________________________________________________________ | |
111 | Double_t AliKalmanTrack::GetTgl() const | |
112 | { | |
113 | Double_t par[5]; | |
114 | Double_t localX = GetX(); | |
115 | GetExternalParameters(localX, par); | |
116 | return par[3]; | |
117 | } | |
118 | //_______________________________________________________________________ | |
119 | Double_t AliKalmanTrack::Get1Pt() const | |
120 | { | |
121 | Double_t par[5]; | |
122 | Double_t localX = GetX(); | |
123 | GetExternalParameters(localX, par); | |
124 | return par[4]; | |
125 | } | |
126 | ||
127 | //_______________________________________________________________________ | |
128 | Double_t AliKalmanTrack::Phi() const | |
129 | { | |
130 | // return global phi of track | |
131 | ||
132 | Double_t par[5]; | |
133 | Double_t localX = GetX(); | |
134 | GetExternalParameters(localX, par); | |
135 | Double_t phi = TMath::ASin(par[2]) + GetAlpha(); | |
136 | while (phi < 0) phi += TMath::TwoPi(); | |
137 | while (phi > TMath::TwoPi()) phi -= TMath::TwoPi(); | |
138 | return phi; | |
139 | } | |
140 | //_______________________________________________________________________ | |
141 | Double_t AliKalmanTrack::SigmaPhi() const | |
142 | { | |
143 | // return error of global phi of track | |
144 | ||
145 | Double_t par[5]; | |
146 | Double_t cov[15]; | |
147 | Double_t localX = GetX(); | |
148 | GetExternalParameters(localX, par); | |
149 | GetExternalCovariance(cov); | |
150 | return TMath::Sqrt(TMath::Abs(cov[5] / (1. - par[2]*par[2]))); | |
151 | } | |
152 | //_______________________________________________________________________ | |
153 | Double_t AliKalmanTrack::Theta() const | |
154 | { | |
155 | // return global theta of track | |
156 | ||
157 | Double_t par[5]; | |
158 | Double_t localX = GetX(); | |
159 | GetExternalParameters(localX, par); | |
160 | return TMath::Pi()/2. - TMath::ATan(par[3]); | |
161 | } | |
162 | //_______________________________________________________________________ | |
163 | Double_t AliKalmanTrack::SigmaTheta() const | |
164 | { | |
165 | // return error of global theta of track | |
166 | ||
167 | Double_t par[5]; | |
168 | Double_t cov[15]; | |
169 | Double_t localX = GetX(); | |
170 | GetExternalParameters(localX, par); | |
171 | GetExternalCovariance(cov); | |
172 | return TMath::Sqrt(TMath::Abs(cov[5])) / (1. + par[3]*par[3]); | |
173 | } | |
174 | //_______________________________________________________________________ | |
175 | Double_t AliKalmanTrack::Px() const | |
176 | { | |
177 | // return x component of track momentum | |
178 | ||
179 | Double_t par[5]; | |
180 | Double_t localX = GetX(); | |
181 | GetExternalParameters(localX, par); | |
182 | Double_t phi = TMath::ASin(par[2]) + GetAlpha(); | |
183 | return TMath::Cos(phi) / TMath::Abs(par[4]); | |
184 | } | |
185 | //_______________________________________________________________________ | |
186 | Double_t AliKalmanTrack::Py() const | |
187 | { | |
188 | // return y component of track momentum | |
189 | ||
190 | Double_t par[5]; | |
191 | Double_t localX = GetX(); | |
192 | GetExternalParameters(localX, par); | |
193 | Double_t phi = TMath::ASin(par[2]) + GetAlpha(); | |
194 | return TMath::Sin(phi) / TMath::Abs(par[4]); | |
195 | } | |
196 | //_______________________________________________________________________ | |
197 | Double_t AliKalmanTrack::Pz() const | |
198 | { | |
199 | // return z component of track momentum | |
200 | ||
201 | Double_t par[5]; | |
202 | Double_t localX = GetX(); | |
203 | GetExternalParameters(localX, par); | |
204 | return par[3] / TMath::Abs(par[4]); | |
205 | } | |
206 | //_______________________________________________________________________ | |
207 | Double_t AliKalmanTrack::Pt() const | |
208 | { | |
209 | // return transverse component of track momentum | |
210 | ||
211 | Double_t par[5]; | |
212 | Double_t localX = GetX(); | |
213 | GetExternalParameters(localX, par); | |
214 | return 1. / TMath::Abs(par[4]); | |
215 | } | |
216 | //_______________________________________________________________________ | |
217 | Double_t AliKalmanTrack::SigmaPt() const | |
218 | { | |
219 | // return error of transverse component of track momentum | |
220 | ||
221 | Double_t par[5]; | |
222 | Double_t cov[15]; | |
223 | Double_t localX = GetX(); | |
224 | GetExternalParameters(localX, par); | |
225 | GetExternalCovariance(cov); | |
226 | return TMath::Sqrt(cov[14]) / TMath::Abs(par[4]); | |
227 | } | |
228 | //_______________________________________________________________________ | |
229 | Double_t AliKalmanTrack::P() const | |
230 | { | |
231 | // return total track momentum | |
232 | ||
233 | Double_t par[5]; | |
234 | Double_t localX = GetX(); | |
235 | GetExternalParameters(localX, par); | |
236 | return 1. / TMath::Abs(par[4] * TMath::Sin(TMath::ATan(par[3]))); | |
237 | } | |
238 | //_______________________________________________________________________ | |
239 | TVector3 AliKalmanTrack::Momentum() const | |
240 | { | |
241 | // return track momentum vector | |
242 | ||
243 | Double_t par[5]; | |
244 | Double_t localX = GetX(); | |
245 | GetExternalParameters(localX, par); | |
246 | Double_t phi = TMath::ASin(par[2]) + GetAlpha(); | |
247 | return TVector3(TMath::Cos(phi) / TMath::Abs(par[4]), | |
248 | TMath::Sin(phi) / TMath::Abs(par[4]), | |
249 | par[3] / TMath::Abs(par[4])); | |
250 | } | |
251 | ||
74f9526e | 252 | //_______________________________________________________________________ |
253 | void AliKalmanTrack::StartTimeIntegral() | |
254 | { | |
49a7a79a | 255 | // Sylwester Radomski, GSI |
256 | // S.Radomski@gsi.de | |
74f9526e | 257 | // |
258 | // Start time integration | |
259 | // To be called at Vertex by ITS tracker | |
260 | // | |
261 | ||
262 | //if (fStartTimeIntegral) | |
263 | // Warning("StartTimeIntegral", "Reseting Recorded Time."); | |
264 | ||
265 | fStartTimeIntegral = kTRUE; | |
5d8718b8 | 266 | for(Int_t i=0; i<fgkTypes; i++) fIntegratedTime[i] = 0; |
74f9526e | 267 | fIntegratedLength = 0; |
268 | } | |
269 | //_______________________________________________________________________ | |
270 | void AliKalmanTrack:: AddTimeStep(Double_t length) | |
271 | { | |
272 | // | |
273 | // Add step to integrated time | |
274 | // this method should be called by a sublasses at the end | |
275 | // of the PropagateTo function or by a tracker | |
276 | // each time step is made. | |
277 | // | |
278 | // If integration not started function does nothing | |
279 | // | |
280 | // Formula | |
281 | // dt = dl * sqrt(p^2 + m^2) / p | |
282 | // p = pT * (1 + tg^2 (lambda) ) | |
283 | // | |
284 | // pt = 1/external parameter [4] | |
285 | // tg lambda = external parameter [3] | |
286 | // | |
287 | // | |
288 | // Sylwester Radomski, GSI | |
289 | // S.Radomski@gsi.de | |
290 | // | |
291 | ||
5d8718b8 | 292 | static const Double_t kcc = 2.99792458e-2; |
74f9526e | 293 | |
294 | if (!fStartTimeIntegral) return; | |
295 | ||
296 | fIntegratedLength += length; | |
297 | ||
5d8718b8 | 298 | static Int_t pdgCode[fgkTypes] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; |
74f9526e | 299 | TDatabasePDG *db = TDatabasePDG::Instance(); |
300 | ||
301 | Double_t xr, param[5]; | |
302 | Double_t pt, tgl; | |
303 | ||
304 | GetExternalParameters(xr, param); | |
305 | pt = 1/param[4] ; | |
306 | tgl = param[3]; | |
307 | ||
308 | Double_t p = TMath::Abs(pt * TMath::Sqrt(1+tgl*tgl)); | |
309 | ||
310 | if (length > 100) return; | |
311 | ||
5d8718b8 | 312 | for (Int_t i=0; i<fgkTypes; i++) { |
74f9526e | 313 | |
314 | Double_t mass = db->GetParticle(pdgCode[i])->Mass(); | |
315 | Double_t correction = TMath::Sqrt( pt*pt * (1 + tgl*tgl) + mass * mass ) / p; | |
5d8718b8 | 316 | Double_t time = length * correction / kcc; |
74f9526e | 317 | |
318 | //cout << mass << "\t" << pt << "\t" << p << "\t" | |
319 | // << correction << endl; | |
320 | ||
321 | fIntegratedTime[i] += time; | |
322 | } | |
e2afb3b6 | 323 | } |
324 | ||
74f9526e | 325 | //_______________________________________________________________________ |
326 | ||
327 | Double_t AliKalmanTrack::GetIntegratedTime(Int_t pdg) const | |
328 | { | |
49a7a79a | 329 | // Sylwester Radomski, GSI |
330 | // S.Radomski@gsi.de | |
74f9526e | 331 | // |
332 | // Return integrated time hypothesis for a given particle | |
333 | // type assumption. | |
334 | // | |
335 | // Input parameter: | |
336 | // pdg - Pdg code of a particle type | |
337 | // | |
338 | ||
339 | ||
340 | if (!fStartTimeIntegral) { | |
341 | Warning("GetIntegratedTime","Time integration not started"); | |
342 | return 0.; | |
343 | } | |
344 | ||
5d8718b8 | 345 | static Int_t pdgCode[fgkTypes] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; |
74f9526e | 346 | |
5d8718b8 | 347 | for (Int_t i=0; i<fgkTypes; i++) |
74f9526e | 348 | if (pdgCode[i] == TMath::Abs(pdg)) return fIntegratedTime[i]; |
349 | ||
350 | Warning(":GetIntegratedTime","Particle type [%d] not found", pdg); | |
351 | return 0; | |
352 | } | |
353 | //_______________________________________________________________________ | |
354 | ||
355 | void AliKalmanTrack::PrintTime() const | |
356 | { | |
49a7a79a | 357 | // Sylwester Radomski, GSI |
358 | // S.Radomski@gsi.de | |
359 | // | |
74f9526e | 360 | // For testing |
361 | // Prints time for all hypothesis | |
362 | // | |
363 | ||
5d8718b8 | 364 | static Int_t pdgCode[fgkTypes] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; |
74f9526e | 365 | |
5d8718b8 | 366 | for (Int_t i=0; i<fgkTypes; i++) |
74f9526e | 367 | printf("%d: %.2f ", pdgCode[i], fIntegratedTime[i]); |
368 | printf("\n"); | |
369 | } | |
370 | ||
49a7a79a | 371 | static void External2Helix(const AliKalmanTrack *t, Double_t helix[6]) { |
372 | //-------------------------------------------------------------------- | |
373 | // External track parameters -> helix parameters | |
374 | //-------------------------------------------------------------------- | |
375 | Double_t alpha,x,cs,sn; | |
376 | t->GetExternalParameters(x,helix); alpha=t->GetAlpha(); | |
377 | ||
378 | cs=TMath::Cos(alpha); sn=TMath::Sin(alpha); | |
379 | helix[5]=x*cs - helix[0]*sn; // x0 | |
380 | helix[0]=x*sn + helix[0]*cs; // y0 | |
381 | //helix[1]= // z0 | |
382 | helix[2]=TMath::ASin(helix[2]) + alpha; // phi0 | |
383 | //helix[3]= // tgl | |
384 | helix[4]=helix[4]/t->GetConvConst(); // C | |
385 | } | |
386 | ||
387 | static void Evaluate(const Double_t *h, Double_t t, | |
388 | Double_t r[3], //radius vector | |
389 | Double_t g[3], //first defivatives | |
390 | Double_t gg[3]) //second derivatives | |
391 | { | |
392 | //-------------------------------------------------------------------- | |
393 | // Calculate position of a point on a track and some derivatives | |
394 | //-------------------------------------------------------------------- | |
395 | Double_t phase=h[4]*t+h[2]; | |
396 | Double_t sn=TMath::Sin(phase), cs=TMath::Cos(phase); | |
397 | ||
398 | r[0] = h[5] + (sn - h[6])/h[4]; | |
399 | r[1] = h[0] - (cs - h[7])/h[4]; | |
400 | r[2] = h[1] + h[3]*t; | |
401 | ||
402 | g[0] = cs; g[1]=sn; g[2]=h[3]; | |
403 | ||
404 | gg[0]=-h[4]*sn; gg[1]=h[4]*cs; gg[2]=0.; | |
405 | } | |
406 | ||
407 | Double_t AliKalmanTrack:: | |
408 | GetDCA(const AliKalmanTrack *p, Double_t &xthis, Double_t &xp) const { | |
409 | //------------------------------------------------------------ | |
410 | // Returns the (weighed !) distance of closest approach between | |
411 | // this track and the track passed as the argument. | |
412 | // Other returned values: | |
413 | // xthis, xt - coordinates of tracks' reference planes at the DCA | |
414 | //----------------------------------------------------------- | |
415 | Double_t dy2=GetSigmaY2() + p->GetSigmaY2(); | |
416 | Double_t dz2=GetSigmaZ2() + p->GetSigmaZ2(); | |
417 | Double_t dx2=dy2; | |
418 | ||
419 | //dx2=dy2=dz2=1.; | |
420 | ||
421 | Double_t p1[8]; External2Helix(this,p1); | |
422 | p1[6]=TMath::Sin(p1[2]); p1[7]=TMath::Cos(p1[2]); | |
423 | Double_t p2[8]; External2Helix(p,p2); | |
424 | p2[6]=TMath::Sin(p2[2]); p2[7]=TMath::Cos(p2[2]); | |
425 | ||
426 | ||
427 | Double_t r1[3],g1[3],gg1[3]; Double_t t1=0.; | |
428 | Evaluate(p1,t1,r1,g1,gg1); | |
429 | Double_t r2[3],g2[3],gg2[3]; Double_t t2=0.; | |
430 | Evaluate(p2,t2,r2,g2,gg2); | |
74f9526e | 431 | |
49a7a79a | 432 | Double_t dx=r2[0]-r1[0], dy=r2[1]-r1[1], dz=r2[2]-r1[2]; |
433 | Double_t dm=dx*dx/dx2 + dy*dy/dy2 + dz*dz/dz2; | |
434 | ||
435 | Int_t max=27; | |
436 | while (max--) { | |
437 | Double_t gt1=-(dx*g1[0]/dx2 + dy*g1[1]/dy2 + dz*g1[2]/dz2); | |
438 | Double_t gt2=+(dx*g2[0]/dx2 + dy*g2[1]/dy2 + dz*g2[2]/dz2); | |
439 | Double_t h11=(g1[0]*g1[0] - dx*gg1[0])/dx2 + | |
440 | (g1[1]*g1[1] - dy*gg1[1])/dy2 + | |
441 | (g1[2]*g1[2] - dz*gg1[2])/dz2; | |
442 | Double_t h22=(g2[0]*g2[0] + dx*gg2[0])/dx2 + | |
443 | (g2[1]*g2[1] + dy*gg2[1])/dy2 + | |
444 | (g2[2]*g2[2] + dz*gg2[2])/dz2; | |
445 | Double_t h12=-(g1[0]*g2[0]/dx2 + g1[1]*g2[1]/dy2 + g1[2]*g2[2]/dz2); | |
446 | ||
447 | Double_t det=h11*h22-h12*h12; | |
448 | ||
449 | Double_t dt1,dt2; | |
450 | if (TMath::Abs(det)<1.e-33) { | |
451 | //(quasi)singular Hessian | |
452 | dt1=-gt1; dt2=-gt2; | |
453 | } else { | |
454 | dt1=-(gt1*h22 - gt2*h12)/det; | |
455 | dt2=-(h11*gt2 - h12*gt1)/det; | |
456 | } | |
457 | ||
458 | if ((dt1*gt1+dt2*gt2)>0) {dt1=-dt1; dt2=-dt2;} | |
459 | ||
460 | //check delta(phase1) ? | |
461 | //check delta(phase2) ? | |
462 | ||
463 | if (TMath::Abs(dt1)/(TMath::Abs(t1)+1.e-3) < 1.e-4) | |
464 | if (TMath::Abs(dt2)/(TMath::Abs(t2)+1.e-3) < 1.e-4) { | |
465 | if ((gt1*gt1+gt2*gt2) > 1.e-4/dy2/dy2) | |
466 | Warning("GetDCA"," stopped at not a stationary point !\n"); | |
467 | Double_t lmb=h11+h22; lmb=lmb-TMath::Sqrt(lmb*lmb-4*det); | |
468 | if (lmb < 0.) | |
469 | Warning("GetDCA"," stopped at not a minimum !\n"); | |
470 | break; | |
471 | } | |
472 | ||
473 | Double_t dd=dm; | |
474 | for (Int_t div=1 ; ; div*=2) { | |
475 | Evaluate(p1,t1+dt1,r1,g1,gg1); | |
476 | Evaluate(p2,t2+dt2,r2,g2,gg2); | |
477 | dx=r2[0]-r1[0]; dy=r2[1]-r1[1]; dz=r2[2]-r1[2]; | |
478 | dd=dx*dx/dx2 + dy*dy/dy2 + dz*dz/dz2; | |
479 | if (dd<dm) break; | |
480 | dt1*=0.5; dt2*=0.5; | |
481 | if (div>512) { | |
482 | Warning("GetDCA"," overshoot !\n"); break; | |
483 | } | |
484 | } | |
485 | dm=dd; | |
486 | ||
487 | t1+=dt1; | |
488 | t2+=dt2; | |
489 | ||
490 | } | |
491 | ||
492 | if (max<=0) Warning("GetDCA"," too many iterations !\n"); | |
493 | ||
494 | Double_t cs=TMath::Cos(GetAlpha()); | |
495 | Double_t sn=TMath::Sin(GetAlpha()); | |
496 | xthis=r1[0]*cs + r1[1]*sn; | |
497 | ||
498 | cs=TMath::Cos(p->GetAlpha()); | |
499 | sn=TMath::Sin(p->GetAlpha()); | |
500 | xp=r2[0]*cs + r2[1]*sn; | |
501 | ||
502 | return TMath::Sqrt(dm*TMath::Sqrt(dy2*dz2)); | |
503 | } | |
504 | ||
505 | Double_t AliKalmanTrack:: | |
506 | PropagateToDCA(AliKalmanTrack *p, Double_t d, Double_t x0) { | |
507 | //-------------------------------------------------------------- | |
508 | // Propagates this track and the argument track to the position of the | |
509 | // distance of closest approach. | |
510 | // Returns the (weighed !) distance of closest approach. | |
511 | //-------------------------------------------------------------- | |
512 | Double_t xthis,xp; | |
513 | Double_t dca=GetDCA(p,xthis,xp); | |
514 | ||
515 | if (!PropagateTo(xthis,d,x0)) { | |
516 | //Warning("PropagateToDCA"," propagation failed !\n"); | |
517 | return 1e+33; | |
518 | } | |
519 | ||
520 | if (!p->PropagateTo(xp,d,x0)) { | |
521 | //Warning("PropagateToDCA"," propagation failed !\n"; | |
522 | return 1e+33; | |
523 | } | |
524 | ||
525 | return dca; | |
526 | } |