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