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