]>
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" | |
f37d970d | 25 | #include "AliLog.h" |
87594435 | 26 | |
27 | ClassImp(AliKalmanTrack) | |
28 | ||
90e48c0c | 29 | Double_t AliKalmanTrack::fgConvConst = 0; |
9b280d80 | 30 | |
e2afb3b6 | 31 | //_______________________________________________________________________ |
32 | AliKalmanTrack::AliKalmanTrack(): | |
90e48c0c | 33 | TObject(), |
e2afb3b6 | 34 | fLab(-3141593), |
68b8060b | 35 | fFakeRatio(0), |
e2afb3b6 | 36 | fChi2(0), |
304864ab | 37 | fMass(AliPID::ParticleMass(AliPID::kPion)), |
90e48c0c | 38 | fN(0), |
39 | fStartTimeIntegral(kFALSE), | |
40 | fIntegratedLength(0) | |
e2afb3b6 | 41 | { |
116cbefd | 42 | // |
43 | // Default constructor | |
44 | // | |
8de97894 | 45 | if (fgConvConst==0) { |
f37d970d | 46 | AliFatal("The magnetic field has not been set!"); |
8de97894 | 47 | } |
74f9526e | 48 | |
74f9526e | 49 | for(Int_t i=0; i<5; i++) fIntegratedTime[i] = 0; |
e2afb3b6 | 50 | } |
51 | ||
52 | //_______________________________________________________________________ | |
53 | AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t): | |
54 | TObject(t), | |
55 | fLab(t.fLab), | |
babd135a | 56 | fFakeRatio(t.fFakeRatio), |
e2afb3b6 | 57 | fChi2(t.fChi2), |
58 | fMass(t.fMass), | |
90e48c0c | 59 | fN(t.fN), |
60 | fStartTimeIntegral(t.fStartTimeIntegral), | |
61 | fIntegratedLength(t.fIntegratedLength) | |
e2afb3b6 | 62 | { |
116cbefd | 63 | // |
64 | // Copy constructor | |
65 | // | |
8de97894 | 66 | if (fgConvConst==0) { |
f37d970d | 67 | AliFatal("The magnetic field has not been set!"); |
8de97894 | 68 | } |
74f9526e | 69 | |
74f9526e | 70 | |
71 | for (Int_t i=0; i<5; i++) | |
72 | fIntegratedTime[i] = t.fIntegratedTime[i]; | |
73 | } | |
c5507f6d | 74 | |
74f9526e | 75 | //_______________________________________________________________________ |
76 | void AliKalmanTrack::StartTimeIntegral() | |
77 | { | |
49a7a79a | 78 | // Sylwester Radomski, GSI |
79 | // S.Radomski@gsi.de | |
74f9526e | 80 | // |
81 | // Start time integration | |
82 | // To be called at Vertex by ITS tracker | |
83 | // | |
84 | ||
85 | //if (fStartTimeIntegral) | |
f37d970d | 86 | // AliWarning("Reseting Recorded Time."); |
74f9526e | 87 | |
88 | fStartTimeIntegral = kTRUE; | |
304864ab | 89 | for(Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i] = 0; |
74f9526e | 90 | fIntegratedLength = 0; |
91 | } | |
92 | //_______________________________________________________________________ | |
93 | void AliKalmanTrack:: AddTimeStep(Double_t length) | |
94 | { | |
95 | // | |
96 | // Add step to integrated time | |
97 | // this method should be called by a sublasses at the end | |
98 | // of the PropagateTo function or by a tracker | |
99 | // each time step is made. | |
100 | // | |
101 | // If integration not started function does nothing | |
102 | // | |
103 | // Formula | |
104 | // dt = dl * sqrt(p^2 + m^2) / p | |
105 | // p = pT * (1 + tg^2 (lambda) ) | |
106 | // | |
107 | // pt = 1/external parameter [4] | |
108 | // tg lambda = external parameter [3] | |
109 | // | |
110 | // | |
111 | // Sylwester Radomski, GSI | |
112 | // S.Radomski@gsi.de | |
113 | // | |
114 | ||
5d8718b8 | 115 | static const Double_t kcc = 2.99792458e-2; |
74f9526e | 116 | |
117 | if (!fStartTimeIntegral) return; | |
118 | ||
119 | fIntegratedLength += length; | |
120 | ||
74f9526e | 121 | Double_t xr, param[5]; |
122 | Double_t pt, tgl; | |
123 | ||
124 | GetExternalParameters(xr, param); | |
125 | pt = 1/param[4] ; | |
126 | tgl = param[3]; | |
127 | ||
128 | Double_t p = TMath::Abs(pt * TMath::Sqrt(1+tgl*tgl)); | |
129 | ||
130 | if (length > 100) return; | |
131 | ||
304864ab | 132 | for (Int_t i=0; i<AliPID::kSPECIES; i++) { |
74f9526e | 133 | |
304864ab | 134 | Double_t mass = AliPID::ParticleMass(i); |
74f9526e | 135 | Double_t correction = TMath::Sqrt( pt*pt * (1 + tgl*tgl) + mass * mass ) / p; |
5d8718b8 | 136 | Double_t time = length * correction / kcc; |
74f9526e | 137 | |
74f9526e | 138 | fIntegratedTime[i] += time; |
139 | } | |
e2afb3b6 | 140 | } |
141 | ||
74f9526e | 142 | //_______________________________________________________________________ |
143 | ||
144 | Double_t AliKalmanTrack::GetIntegratedTime(Int_t pdg) const | |
145 | { | |
49a7a79a | 146 | // Sylwester Radomski, GSI |
147 | // S.Radomski@gsi.de | |
74f9526e | 148 | // |
149 | // Return integrated time hypothesis for a given particle | |
150 | // type assumption. | |
151 | // | |
152 | // Input parameter: | |
153 | // pdg - Pdg code of a particle type | |
154 | // | |
155 | ||
156 | ||
157 | if (!fStartTimeIntegral) { | |
f37d970d | 158 | AliWarning("Time integration not started"); |
74f9526e | 159 | return 0.; |
160 | } | |
161 | ||
304864ab | 162 | for (Int_t i=0; i<AliPID::kSPECIES; i++) |
163 | if (AliPID::ParticleCode(i) == TMath::Abs(pdg)) return fIntegratedTime[i]; | |
74f9526e | 164 | |
f37d970d | 165 | AliWarning(Form("Particle type [%d] not found", pdg)); |
74f9526e | 166 | return 0; |
167 | } | |
ae982df3 | 168 | |
169 | void AliKalmanTrack::GetIntegratedTimes(Double_t *times) const { | |
304864ab | 170 | for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fIntegratedTime[i]; |
ae982df3 | 171 | } |
172 | ||
173 | void AliKalmanTrack::SetIntegratedTimes(const Double_t *times) { | |
304864ab | 174 | for (Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i]=times[i]; |
ae982df3 | 175 | } |
176 | ||
74f9526e | 177 | //_______________________________________________________________________ |
178 | ||
179 | void AliKalmanTrack::PrintTime() const | |
180 | { | |
49a7a79a | 181 | // Sylwester Radomski, GSI |
182 | // S.Radomski@gsi.de | |
183 | // | |
74f9526e | 184 | // For testing |
185 | // Prints time for all hypothesis | |
186 | // | |
187 | ||
304864ab | 188 | for (Int_t i=0; i<AliPID::kSPECIES; i++) |
189 | printf("%d: %.2f ", AliPID::ParticleCode(i), fIntegratedTime[i]); | |
74f9526e | 190 | printf("\n"); |
191 | } | |
192 | ||
49a7a79a | 193 | static void External2Helix(const AliKalmanTrack *t, Double_t helix[6]) { |
194 | //-------------------------------------------------------------------- | |
195 | // External track parameters -> helix parameters | |
196 | //-------------------------------------------------------------------- | |
197 | Double_t alpha,x,cs,sn; | |
198 | t->GetExternalParameters(x,helix); alpha=t->GetAlpha(); | |
199 | ||
200 | cs=TMath::Cos(alpha); sn=TMath::Sin(alpha); | |
201 | helix[5]=x*cs - helix[0]*sn; // x0 | |
202 | helix[0]=x*sn + helix[0]*cs; // y0 | |
203 | //helix[1]= // z0 | |
204 | helix[2]=TMath::ASin(helix[2]) + alpha; // phi0 | |
205 | //helix[3]= // tgl | |
206 | helix[4]=helix[4]/t->GetConvConst(); // C | |
207 | } | |
208 | ||
209 | static void Evaluate(const Double_t *h, Double_t t, | |
210 | Double_t r[3], //radius vector | |
211 | Double_t g[3], //first defivatives | |
212 | Double_t gg[3]) //second derivatives | |
213 | { | |
214 | //-------------------------------------------------------------------- | |
215 | // Calculate position of a point on a track and some derivatives | |
216 | //-------------------------------------------------------------------- | |
217 | Double_t phase=h[4]*t+h[2]; | |
218 | Double_t sn=TMath::Sin(phase), cs=TMath::Cos(phase); | |
219 | ||
220 | r[0] = h[5] + (sn - h[6])/h[4]; | |
221 | r[1] = h[0] - (cs - h[7])/h[4]; | |
222 | r[2] = h[1] + h[3]*t; | |
223 | ||
224 | g[0] = cs; g[1]=sn; g[2]=h[3]; | |
225 | ||
226 | gg[0]=-h[4]*sn; gg[1]=h[4]*cs; gg[2]=0.; | |
227 | } | |
228 | ||
229 | Double_t AliKalmanTrack:: | |
230 | GetDCA(const AliKalmanTrack *p, Double_t &xthis, Double_t &xp) const { | |
231 | //------------------------------------------------------------ | |
232 | // Returns the (weighed !) distance of closest approach between | |
233 | // this track and the track passed as the argument. | |
234 | // Other returned values: | |
235 | // xthis, xt - coordinates of tracks' reference planes at the DCA | |
236 | //----------------------------------------------------------- | |
237 | Double_t dy2=GetSigmaY2() + p->GetSigmaY2(); | |
238 | Double_t dz2=GetSigmaZ2() + p->GetSigmaZ2(); | |
239 | Double_t dx2=dy2; | |
240 | ||
241 | //dx2=dy2=dz2=1.; | |
242 | ||
243 | Double_t p1[8]; External2Helix(this,p1); | |
244 | p1[6]=TMath::Sin(p1[2]); p1[7]=TMath::Cos(p1[2]); | |
245 | Double_t p2[8]; External2Helix(p,p2); | |
246 | p2[6]=TMath::Sin(p2[2]); p2[7]=TMath::Cos(p2[2]); | |
247 | ||
248 | ||
249 | Double_t r1[3],g1[3],gg1[3]; Double_t t1=0.; | |
250 | Evaluate(p1,t1,r1,g1,gg1); | |
251 | Double_t r2[3],g2[3],gg2[3]; Double_t t2=0.; | |
252 | Evaluate(p2,t2,r2,g2,gg2); | |
74f9526e | 253 | |
49a7a79a | 254 | Double_t dx=r2[0]-r1[0], dy=r2[1]-r1[1], dz=r2[2]-r1[2]; |
255 | Double_t dm=dx*dx/dx2 + dy*dy/dy2 + dz*dz/dz2; | |
256 | ||
257 | Int_t max=27; | |
258 | while (max--) { | |
259 | Double_t gt1=-(dx*g1[0]/dx2 + dy*g1[1]/dy2 + dz*g1[2]/dz2); | |
260 | Double_t gt2=+(dx*g2[0]/dx2 + dy*g2[1]/dy2 + dz*g2[2]/dz2); | |
261 | Double_t h11=(g1[0]*g1[0] - dx*gg1[0])/dx2 + | |
262 | (g1[1]*g1[1] - dy*gg1[1])/dy2 + | |
263 | (g1[2]*g1[2] - dz*gg1[2])/dz2; | |
264 | Double_t h22=(g2[0]*g2[0] + dx*gg2[0])/dx2 + | |
265 | (g2[1]*g2[1] + dy*gg2[1])/dy2 + | |
266 | (g2[2]*g2[2] + dz*gg2[2])/dz2; | |
267 | Double_t h12=-(g1[0]*g2[0]/dx2 + g1[1]*g2[1]/dy2 + g1[2]*g2[2]/dz2); | |
268 | ||
269 | Double_t det=h11*h22-h12*h12; | |
270 | ||
271 | Double_t dt1,dt2; | |
272 | if (TMath::Abs(det)<1.e-33) { | |
273 | //(quasi)singular Hessian | |
274 | dt1=-gt1; dt2=-gt2; | |
275 | } else { | |
276 | dt1=-(gt1*h22 - gt2*h12)/det; | |
277 | dt2=-(h11*gt2 - h12*gt1)/det; | |
278 | } | |
279 | ||
280 | if ((dt1*gt1+dt2*gt2)>0) {dt1=-dt1; dt2=-dt2;} | |
281 | ||
282 | //check delta(phase1) ? | |
283 | //check delta(phase2) ? | |
284 | ||
285 | if (TMath::Abs(dt1)/(TMath::Abs(t1)+1.e-3) < 1.e-4) | |
286 | if (TMath::Abs(dt2)/(TMath::Abs(t2)+1.e-3) < 1.e-4) { | |
287 | if ((gt1*gt1+gt2*gt2) > 1.e-4/dy2/dy2) | |
f37d970d | 288 | AliWarning(" stopped at not a stationary point !"); |
49a7a79a | 289 | Double_t lmb=h11+h22; lmb=lmb-TMath::Sqrt(lmb*lmb-4*det); |
290 | if (lmb < 0.) | |
f37d970d | 291 | AliWarning(" stopped at not a minimum !"); |
49a7a79a | 292 | break; |
293 | } | |
294 | ||
295 | Double_t dd=dm; | |
296 | for (Int_t div=1 ; ; div*=2) { | |
297 | Evaluate(p1,t1+dt1,r1,g1,gg1); | |
298 | Evaluate(p2,t2+dt2,r2,g2,gg2); | |
299 | dx=r2[0]-r1[0]; dy=r2[1]-r1[1]; dz=r2[2]-r1[2]; | |
300 | dd=dx*dx/dx2 + dy*dy/dy2 + dz*dz/dz2; | |
301 | if (dd<dm) break; | |
302 | dt1*=0.5; dt2*=0.5; | |
303 | if (div>512) { | |
f37d970d | 304 | AliWarning(" overshoot !"); break; |
49a7a79a | 305 | } |
306 | } | |
307 | dm=dd; | |
308 | ||
309 | t1+=dt1; | |
310 | t2+=dt2; | |
311 | ||
312 | } | |
313 | ||
f37d970d | 314 | if (max<=0) AliWarning(" too many iterations !"); |
49a7a79a | 315 | |
316 | Double_t cs=TMath::Cos(GetAlpha()); | |
317 | Double_t sn=TMath::Sin(GetAlpha()); | |
318 | xthis=r1[0]*cs + r1[1]*sn; | |
319 | ||
320 | cs=TMath::Cos(p->GetAlpha()); | |
321 | sn=TMath::Sin(p->GetAlpha()); | |
322 | xp=r2[0]*cs + r2[1]*sn; | |
323 | ||
324 | return TMath::Sqrt(dm*TMath::Sqrt(dy2*dz2)); | |
325 | } | |
326 | ||
327 | Double_t AliKalmanTrack:: | |
328 | PropagateToDCA(AliKalmanTrack *p, Double_t d, Double_t x0) { | |
329 | //-------------------------------------------------------------- | |
330 | // Propagates this track and the argument track to the position of the | |
331 | // distance of closest approach. | |
332 | // Returns the (weighed !) distance of closest approach. | |
333 | //-------------------------------------------------------------- | |
334 | Double_t xthis,xp; | |
335 | Double_t dca=GetDCA(p,xthis,xp); | |
336 | ||
337 | if (!PropagateTo(xthis,d,x0)) { | |
f37d970d | 338 | //AliWarning(" propagation failed !"); |
49a7a79a | 339 | return 1e+33; |
340 | } | |
341 | ||
342 | if (!p->PropagateTo(xp,d,x0)) { | |
f37d970d | 343 | //AliWarning(" propagation failed !"; |
49a7a79a | 344 | return 1e+33; |
345 | } | |
346 | ||
347 | return dca; | |
348 | } |