HIJING parameterisation including baryons, first commit.
[u/mrichter/AliRoot.git] / ITS / AliITStrackV2.cxx
CommitLineData
006b5f7f 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// Implementation of the ITS track class
18//
19// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
20//-------------------------------------------------------------------------
21
22#include <TMatrixD.h>
23
24#include <TMath.h>
25#include <iostream.h>
26
27#include "AliCluster.h"
517b130f 28#include "AliTPCtrack.h"
006b5f7f 29#include "AliITStrackV2.h"
30
31ClassImp(AliITStrackV2)
32
7f6ddf58 33const Int_t kWARN=5;
006b5f7f 34
35//____________________________________________________________________________
36AliITStrackV2::AliITStrackV2(const AliTPCtrack& t) throw (const Char_t *) {
37 //------------------------------------------------------------------
9b280d80 38 //Conversion TPC track -> ITS track
006b5f7f 39 //------------------------------------------------------------------
40 SetLabel(t.GetLabel());
41 SetChi2(0.);
42 SetNumberOfClusters(0);
14825d5a 43 //SetConvConst(t.GetConvConst());
44
7f6ddf58 45 fdEdx = t.GetdEdx();
46 SetMass(t.GetMass());
47
006b5f7f 48 fAlpha = t.GetAlpha();
49 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
50 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
51
9b280d80 52 //Conversion of the track parameters
006b5f7f 53 Double_t x,p[5]; t.GetExternalParameters(x,p);
9b280d80 54 fX=x; x=GetConvConst();
006b5f7f 55 fP0=p[0];
56 fP1=p[1];
57 fP2=p[2];
58 fP3=p[3];
59 fP4=p[4]/x;
60
9b280d80 61 //Conversion of the covariance matrix
006b5f7f 62 Double_t c[15]; t.GetExternalCovariance(c);
63
64 fC00=c[0 ];
65 fC10=c[1 ]; fC11=c[2 ];
66 fC20=c[3 ]; fC21=c[4 ]; fC22=c[5 ];
67 fC30=c[6 ]; fC31=c[7 ]; fC32=c[8 ]; fC33=c[9 ];
68 fC40=c[10]/x; fC41=c[11]/x; fC42=c[12]/x; fC43=c[13]/x; fC44=c[14]/x/x;
69
70 if (!Invariant()) throw "AliITStrackV2: conversion failed !\n";
71}
72
73//____________________________________________________________________________
74AliITStrackV2::AliITStrackV2(const AliITStrackV2& t) : AliKalmanTrack(t) {
75 //------------------------------------------------------------------
76 //Copy constructor
77 //------------------------------------------------------------------
78 fX=t.fX;
79 fAlpha=t.fAlpha;
80 fdEdx=t.fdEdx;
81
82 fP0=t.fP0; fP1=t.fP1; fP2=t.fP2; fP3=t.fP3; fP4=t.fP4;
83
84 fC00=t.fC00;
85 fC10=t.fC10; fC11=t.fC11;
86 fC20=t.fC20; fC21=t.fC21; fC22=t.fC22;
87 fC30=t.fC30; fC31=t.fC31; fC32=t.fC32; fC33=t.fC33;
88 fC40=t.fC40; fC41=t.fC41; fC42=t.fC42; fC43=t.fC43; fC44=t.fC44;
89
90 Int_t n=GetNumberOfClusters();
91 for (Int_t i=0; i<n; i++) fIndex[i]=t.fIndex[i];
92}
7f6ddf58 93/*
006b5f7f 94//_____________________________________________________________________________
95Int_t AliITStrackV2::Compare(const TObject *o) const {
96 //-----------------------------------------------------------------
97 // This function compares tracks according to the their curvature
98 //-----------------------------------------------------------------
7f6ddf58 99 AliITStrackV2 *t=(AliITStrackV2*)o;
006b5f7f 100 Double_t co=TMath::Abs(t->Get1Pt());
101 Double_t c =TMath::Abs(Get1Pt());
102 if (c>co) return 1;
103 else if (c<co) return -1;
104 return 0;
105}
7f6ddf58 106*/
107//_____________________________________________________________________________
108Int_t AliITStrackV2::Compare(const TObject *o) const {
109 //-----------------------------------------------------------------
110 // This function compares tracks according to the their curvature
111 //-----------------------------------------------------------------
112 AliITStrackV2 *t=(AliITStrackV2*)o;
113
114 Double_t p2=1./(Get1Pt()*Get1Pt());
115 Double_t b2=p2/(p2 + GetMass()*GetMass());
116 Double_t po2=1./(t->Get1Pt()*t->Get1Pt());
117 Double_t bo2=po2/(po2 + t->GetMass()*t->GetMass());
118 if (p2*b2>po2*bo2) return -1;
119 else if (p2*b2<po2*bo2) return 1;
120 return 0;
121}
006b5f7f 122
123//_____________________________________________________________________________
124void AliITStrackV2::GetExternalCovariance(Double_t cc[15]) const {
125 //-------------------------------------------------------------------------
126 // This function returns an external representation of the covriance matrix.
127 // (See comments in AliTPCtrack.h about external track representation)
128 //-------------------------------------------------------------------------
9b280d80 129 Double_t a=GetConvConst();
006b5f7f 130
131 cc[0 ]=fC00;
132 cc[1 ]=fC10; cc[2 ]=fC11;
133 cc[3 ]=fC20; cc[4 ]=fC21; cc[5 ]=fC22;
134 cc[6 ]=fC30; cc[7 ]=fC31; cc[8 ]=fC32; cc[9 ]=fC33;
135 cc[10]=fC40*a; cc[11]=fC41*a; cc[12]=fC42*a; cc[13]=fC43*a; cc[14]=fC44*a*a;
136}
137
138//____________________________________________________________________________
7f6ddf58 139Int_t AliITStrackV2::PropagateToVertex(Double_t x0,Double_t rho) {
006b5f7f 140 //------------------------------------------------------------------
141 //This function propagates a track to the minimal distance from the origin
142 //------------------------------------------------------------------
143 Double_t xv=fP2*(fX*fP2 - fP0*TMath::Sqrt(1.- fP2*fP2)); //linear approxim.
7f6ddf58 144 Propagate(fAlpha,xv,0.,0.);
006b5f7f 145 return 0;
146}
147
148//____________________________________________________________________________
149Int_t AliITStrackV2::
150GetGlobalXYZat(Double_t xk, Double_t &x, Double_t &y, Double_t &z) const {
151 //------------------------------------------------------------------
152 //This function returns a track position in the global system
153 //------------------------------------------------------------------
154 Double_t dx=xk-fX;
155 Double_t f1=fP2, f2=f1 + fP4*dx;
156 if (TMath::Abs(f2) >= 0.99999) {
7f6ddf58 157 Int_t n=GetNumberOfClusters();
158 if (n>kWARN)
159 cerr<<n<<" AliITStrackV2::GetGlobalXYZat: Propagation failed !\n";
006b5f7f 160 return 0;
161 }
162
163 Double_t r1=sqrt(1.- f1*f1), r2=sqrt(1.- f2*f2);
164
165 Double_t yk = fP0 + dx*(f1+f2)/(r1+r2);
166 Double_t zk = fP1 + dx*(f1+f2)/(f1*r2 + f2*r1)*fP3;
167
168 Double_t cs=TMath::Cos(fAlpha), sn=TMath::Sin(fAlpha);
169 x = xk*cs - yk*sn;
170 y = xk*sn + yk*cs;
171 z = zk;
172
173 return 1;
174}
175
176//_____________________________________________________________________________
177Double_t AliITStrackV2::GetPredictedChi2(const AliCluster *c) const
178{
179 //-----------------------------------------------------------------
180 // This function calculates a predicted chi2 increment.
181 //-----------------------------------------------------------------
182 Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
183 r00+=fC00; r01+=fC10; r11+=fC11;
184
185 Double_t det=r00*r11 - r01*r01;
7f6ddf58 186 if (TMath::Abs(det) < 1.e-30) {
006b5f7f 187 Int_t n=GetNumberOfClusters();
7f6ddf58 188 if (n>kWARN)
189 cerr<<n<<" AliKalmanTrack::GetPredictedChi2: Singular matrix !\n";
006b5f7f 190 return 1e10;
191 }
192 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
193
194 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
195
196 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
197}
198
199//_____________________________________________________________________________
200Double_t AliITStrackV2::GetPredictedChi2(const AliCluster *c,Double_t *m,
7f6ddf58 201Double_t x0) const {
006b5f7f 202 //-----------------------------------------------------------------
203 // This function calculates a chi2 increment with a vertex contraint
204 //-----------------------------------------------------------------
205 TVectorD x(5); x(0)=fP0; x(1)=fP1; x(2)=fP2; x(3)=fP3; x(4)=fP4;
206 TMatrixD C(5,5);
207 C(0,0)=fC00;
208 C(1,0)=fC10; C(1,1)=fC11;
209 C(2,0)=fC20; C(2,1)=fC21; C(2,2)=fC22;
210 C(3,0)=fC30; C(3,1)=fC31; C(3,2)=fC32; C(3,3)=fC33;
211 C(4,0)=fC40; C(4,1)=fC41; C(4,2)=fC42; C(4,3)=fC43; C(4,4)=fC44;
212
213 C(0,1)=C(1,0);
214 C(0,2)=C(2,0); C(1,2)=C(2,1);
215 C(0,3)=C(3,0); C(1,3)=C(3,1); C(2,3)=C(3,2);
216 C(0,4)=C(4,0); C(1,4)=C(4,1); C(2,4)=C(4,2); C(3,4)=C(4,3);
217
218 TMatrixD H(4,5); H.UnitMatrix();
219 Double_t dy=(c->GetY() - m[0]), dz=(c->GetZ() - m[1]);
220
221 Double_t dr=TMath::Sqrt(fX*fX + dy*dy);
222 Double_t r =TMath::Sqrt(4/dr/dr - fP4*fP4);
223 Double_t sn=0.5*(fP4*fX + dy*r);
224 Double_t tg=0.5*fP4*dz/TMath::ASin(0.5*fP4*dr);
225 TVectorD mm(4);
226 mm(0)=m[0]=c->GetY(); mm(1)=m[1]=c->GetZ(); mm(2)=m[2]=sn; mm(3)=m[3]=tg;
227
228 Double_t v22=0.,v33=0.;
229 //x0=0.;
230 if (x0!=0.) {
231 Double_t pp2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
7f6ddf58 232 Double_t beta2=pp2/(pp2 + GetMass()*GetMass());
006b5f7f 233 x0*=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(1.- GetSnp()*GetSnp()));
234 Double_t theta2=14.1*14.1/(beta2*pp2*1e6)*x0;
235 v22 = theta2*(1.- GetSnp()*GetSnp())*(1. + GetTgl()*GetTgl());
236 v33 = theta2*(1.+ GetTgl()*GetTgl())*(1. + GetTgl()*GetTgl());
237 }
238 Double_t sy2=c->GetSigmaY2(), sz2=c->GetSigmaZ2();
239 v22+=kSigmaYV*kSigmaYV/dr/dr;
240 v22+=sy2/dr/dr;
241 Double_t v20=sy2/dr;
242
243 v33+=kSigmaZV*kSigmaZV/dr/dr;
244 v33+=sz2/dr/dr;
245 Double_t v31=sz2/dr;
246
247 TMatrixD V(4,4);
248 V(0,0)=m[4 ]=sy2; V(0,1)=m[5 ]=0.; V(0,2)=m[6 ]=v20; V(0,3)=m[7 ]=0.;
249 V(1,0)=m[8 ]=0.; V(1,1)=m[9 ]=sz2; V(1,2)=m[10]=0.; V(1,3)=m[11]=v31;
250 V(2,0)=m[12]=v20; V(2,1)=m[13]=0.; V(2,2)=m[14]=v22; V(2,3)=m[15]=0.;
251 V(3,0)=m[16]=0.; V(3,1)=m[17]=v31; V(3,2)=m[18]=0.; V(3,3)=m[19]=v33;
252
253 TVectorD res=x; res*=H; res-=mm; //res*=-1;
254 TMatrixD tmp(H,TMatrixD::kMult,C);
255 TMatrixD R(tmp,TMatrixD::kMult,TMatrixD(TMatrixD::kTransposed,H)); R+=V;
256
257 Double_t det=R.Determinant();
7f6ddf58 258 if (TMath::Abs(det) < 1.e-30) {
006b5f7f 259 Int_t n=GetNumberOfClusters();
7f6ddf58 260 if (n>kWARN)
261 cerr<<n<<" AliITStrackV2::GetPredictedChi2: Singular matrix !\n";
006b5f7f 262 return 1e10;
263 }
264
265 R.Invert();
266
267 TVectorD rs=res;
268 res*=R;
269 return rs*res;
270}
271
272//____________________________________________________________________________
273Int_t
7f6ddf58 274AliITStrackV2::PropagateTo(Double_t xk,Double_t x0,Double_t rho) {
006b5f7f 275 //------------------------------------------------------------------
276 //This function propagates a track
277 //------------------------------------------------------------------
278 Double_t x1=fX, x2=xk, dx=x2-x1;
279 Double_t f1=fP2, f2=f1 + fP4*dx;
280 if (TMath::Abs(f2) >= 0.99999) {
281 Int_t n=GetNumberOfClusters();
7f6ddf58 282 if (n>kWARN)
283 cerr<<n<<" AliITStrackV2::PropagateTo: Propagation failed !\n";
006b5f7f 284 return 0;
285 }
286
287 Double_t r1=sqrt(1.- f1*f1), r2=sqrt(1.- f2*f2);
288
289 fP0 += dx*(f1+f2)/(r1+r2);
290 fP1 += dx*(f1+f2)/(f1*r2 + f2*r1)*fP3;
291 fP2 += dx*fP4;
292
293 //f = F - 1
294
295 Double_t f02= dx/(r1*r1*r1);
296 Double_t f04=0.5*dx*dx/(r1*r1*r1);
297 Double_t f12= dx*fP3*f1/(r1*r1*r1);
298 Double_t f14=0.5*dx*dx*fP3*f1/(r1*r1*r1);
299 Double_t f13= dx/r1;
300 Double_t f24= dx;
301
302 //b = C*ft
303 Double_t b00=f02*fC20 + f04*fC40, b01=f12*fC20 + f14*fC40 + f13*fC30;
304 Double_t b02=f24*fC40;
305 Double_t b10=f02*fC21 + f04*fC41, b11=f12*fC21 + f14*fC41 + f13*fC31;
306 Double_t b12=f24*fC41;
307 Double_t b20=f02*fC22 + f04*fC42, b21=f12*fC22 + f14*fC42 + f13*fC32;
308 Double_t b22=f24*fC42;
309 Double_t b40=f02*fC42 + f04*fC44, b41=f12*fC42 + f14*fC44 + f13*fC43;
310 Double_t b42=f24*fC44;
311 Double_t b30=f02*fC32 + f04*fC43, b31=f12*fC32 + f14*fC43 + f13*fC33;
312 Double_t b32=f24*fC43;
313
314 //a = f*b = f*C*ft
315 Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a02=f02*b22+f04*b42;
316 Double_t a11=f12*b21+f14*b41+f13*b31,a12=f12*b22+f14*b42+f13*b32;
317 Double_t a22=f24*b42;
318
319 //F*C*Ft = C + (b + bt + a)
320 fC00 += b00 + b00 + a00;
321 fC10 += b10 + b01 + a01;
322 fC20 += b20 + b02 + a02;
323 fC30 += b30;
324 fC40 += b40;
325 fC11 += b11 + b11 + a11;
326 fC21 += b21 + b12 + a12;
327 fC31 += b31;
328 fC41 += b41;
329 fC22 += b22 + b22 + a22;
330 fC32 += b32;
331 fC42 += b42;
332
333 fX=x2;
334
335 Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
7f6ddf58 336 Double_t beta2=p2/(p2 + GetMass()*GetMass());
006b5f7f 337
338 //Multiple scattering******************
339 //x0=0.;
340 if (x0!=0) {
341 x0*=TMath::Sqrt((1.+ fP3*fP3)/(1.- fP2*fP2));
342 Double_t theta2=14.1*14.1/(beta2*p2*1e6)*x0;
343 fC22 += theta2*(1.- fP2*fP2)*(1. + fP3*fP3);
344 fC33 += theta2*(1. + fP3*fP3)*(1. + fP3*fP3);
345 fC43 += theta2*fP3*fP4*(1. + fP3*fP3);
346 fC44 += theta2*fP3*fP4*fP3*fP4;
347 }
348
349 //Energy losses************************
350 if (rho!=0.) {
351 rho*=TMath::Sqrt((1.+ fP3*fP3)/(1.- fP2*fP2));
352 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2)) - beta2)*rho;
353 if (x1 < x2) dE=-dE;
7f6ddf58 354 fP4*=(1.- sqrt(p2+GetMass()*GetMass())/p2*dE);
006b5f7f 355 }
356
357 if (!Invariant()) {cout<<"Propagate !\n"; return 0;}
358
359 return 1;
360}
361
362//____________________________________________________________________________
363Int_t AliITStrackV2::Update(const AliCluster* c, Double_t chi2, UInt_t index) {
364 //------------------------------------------------------------------
365 //This function updates track parameters
366 //------------------------------------------------------------------
367 Double_t p0=fP0,p1=fP1,p2=fP2,p3=fP3,p4=fP4;
368 Double_t c00=fC00;
369 Double_t c10=fC10, c11=fC11;
370 Double_t c20=fC20, c21=fC21, c22=fC22;
371 Double_t c30=fC30, c31=fC31, c32=fC32, c33=fC33;
372 Double_t c40=fC40, c41=fC41, c42=fC42, c43=fC43, c44=fC44;
373
374
375 Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
376 r00+=fC00; r01+=fC10; r11+=fC11;
377 Double_t det=r00*r11 - r01*r01;
378 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
379
380 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
381 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
382 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
383 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
384 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
385
386 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
387 Double_t sf=fP2 + k20*dy + k21*dz;
7f6ddf58 388
006b5f7f 389 fP0 += k00*dy + k01*dz;
390 fP1 += k10*dy + k11*dz;
391 fP2 = sf;
392 fP3 += k30*dy + k31*dz;
393 fP4 += k40*dy + k41*dz;
394
395 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
396 Double_t c12=fC21, c13=fC31, c14=fC41;
397
398 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
399 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
400 fC40-=k00*c04+k01*c14;
401
402 fC11-=k10*c01+k11*fC11;
403 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
404 fC41-=k10*c04+k11*c14;
405
406 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
407 fC42-=k20*c04+k21*c14;
408
409 fC33-=k30*c03+k31*c13;
410 fC43-=k30*c04+k31*c14;
411
412 fC44-=k40*c04+k41*c14;
413
414 if (!Invariant()) {
415 fP0=p0; fP1=p1; fP2=p2; fP3=p3; fP4=p4;
416 fC00=c00;
417 fC10=c10; fC11=c11;
418 fC20=c20; fC21=c21; fC22=c22;
419 fC30=c30; fC31=c31; fC32=c32; fC33=c33;
420 fC40=c40; fC41=c41; fC42=c42; fC43=c43; fC44=c44;
421 return 0;
422 }
423
424 Int_t n=GetNumberOfClusters();
425 fIndex[n]=index;
426 SetNumberOfClusters(n+1);
427 SetChi2(GetChi2()+chi2);
428
429 return 1;
430}
431
432
433//____________________________________________________________________________
434Int_t AliITStrackV2::Update(const Double_t* m, Double_t chi2, UInt_t index) {
435 //------------------------------------------------------------------
436 //This function updates track parameters with a vertex constraint
437 //------------------------------------------------------------------
438 Double_t p0=fP0,p1=fP1,p2=fP2,p3=fP3,p4=fP4;
439 Double_t c00=fC00;
440 Double_t c10=fC10, c11=fC11;
441 Double_t c20=fC20, c21=fC21, c22=fC22;
442 Double_t c30=fC30, c31=fC31, c32=fC32, c33=fC33;
443 Double_t c40=fC40, c41=fC41, c42=fC42, c43=fC43, c44=fC44;
444
445
446 TVectorD x(5); x(0)=fP0; x(1)=fP1; x(2)=fP2; x(3)=fP3; x(4)=fP4;
447 TMatrixD C(5,5);
448 C(0,0)=fC00;
449 C(1,0)=fC10; C(1,1)=fC11;
450 C(2,0)=fC20; C(2,1)=fC21; C(2,2)=fC22;
451 C(3,0)=fC30; C(3,1)=fC31; C(3,2)=fC32; C(3,3)=fC33;
452 C(4,0)=fC40; C(4,1)=fC41; C(4,2)=fC42; C(4,3)=fC43; C(4,4)=fC44;
453
454 C(0,1)=C(1,0);
455 C(0,2)=C(2,0); C(1,2)=C(2,1);
456 C(0,3)=C(3,0); C(1,3)=C(3,1); C(2,3)=C(3,2);
457 C(0,4)=C(4,0); C(1,4)=C(4,1); C(2,4)=C(4,2); C(3,4)=C(4,3);
458
459 TMatrixD H(4,5); H.UnitMatrix();
460 TMatrixD Ht(TMatrixD::kTransposed,H);
461 TVectorD mm(4); mm(0)=m[0]; mm(1)=m[1]; mm(2)=m[2]; mm(3)=m[3];
462 TMatrixD V(4,4);
463 V(0,0)=m[4 ]; V(0,1)=m[5 ]; V(0,2)=m[6 ]; V(0,3)=m[7 ];
464 V(1,0)=m[8 ]; V(1,1)=m[9 ]; V(1,2)=m[10]; V(1,3)=m[11];
465 V(2,0)=m[12]; V(2,1)=m[13]; V(2,2)=m[14]; V(2,3)=m[15];
466 V(3,0)=m[16]; V(3,1)=m[17]; V(3,2)=m[18]; V(3,3)=m[19];
467
468 TMatrixD tmp(H,TMatrixD::kMult,C);
469 TMatrixD R(tmp,TMatrixD::kMult,Ht); R+=V;
470
471 R.Invert();
472
473 TMatrixD K(C,TMatrixD::kMult,Ht); K*=R;
474
475 TVectorD savex=x;
476 x*=H; x-=mm; x*=-1; x*=K; x+=savex;
477
478 TMatrixD saveC=C;
479 C.Mult(K,tmp); C-=saveC; C*=-1;
480
481 fP0=x(0); fP1=x(1); fP2=x(2); fP3=x(3); fP4=x(4);
482 fC00=C(0,0);
483 fC10=C(1,0); fC11=C(1,1);
484 fC20=C(2,0); fC21=C(2,1); fC22=C(2,2);
485 fC30=C(3,0); fC31=C(3,1); fC32=C(3,2); fC33=C(3,3);
486 fC40=C(4,0); fC41=C(4,1); fC42=C(4,2); fC43=C(4,3); fC44=C(4,4);
487
488
489 if (!Invariant()) {
490 fP0=p0; fP1=p1; fP2=p2; fP3=p3; fP4=p4;
491 fC00=c00;
492 fC10=c10; fC11=c11;
493 fC20=c20; fC21=c21; fC22=c22;
494 fC30=c30; fC31=c31; fC32=c32; fC33=c33;
495 fC40=c40; fC41=c41; fC42=c42; fC43=c43; fC44=c44;
496 return 0;
497 }
498
499 Int_t n=GetNumberOfClusters();
500 fIndex[n]=index;
501 SetNumberOfClusters(n+1);
502 SetChi2(GetChi2()+chi2);
503
504 return 1;
505}
506
507Int_t AliITStrackV2::Invariant() const {
508 //------------------------------------------------------------------
509 // This function is for debugging purpose only
510 //------------------------------------------------------------------
7f6ddf58 511 Int_t n=GetNumberOfClusters();
512
006b5f7f 513 //if (TMath::Abs(fP1)>11.5)
7f6ddf58 514 //if (fP1*fP4<0) {
515 // if (n>kWARN) cout<<"fP1*fP4="<<fP1*fP4<<' '<<fP1<<endl; return 0;}
516
517 if (TMath::Abs(fP2)>=1) {if (n>kWARN) cout<<"fP2="<<fP2<<endl; return 0;}
518
519 if (fC00<=0) {if (n>kWARN) cout<<"fC00="<<fC00<<endl; return 0;}
520 if (fC11<=0) {if (n>kWARN) cout<<"fC11="<<fC11<<endl; return 0;}
521 if (fC22<=0) {if (n>kWARN) cout<<"fC22="<<fC22<<endl; return 0;}
522 if (fC33<=0) {if (n>kWARN) cout<<"fC33="<<fC33<<endl; return 0;}
523 if (fC44<=0) {if (n>kWARN) cout<<"fC44="<<fC44<<endl; return 0;}
14825d5a 524 /*
525 TMatrixD m(5,5);
526 m(0,0)=fC00;
527 m(1,0)=fC10; m(1,1)=fC11;
528 m(2,0)=fC20; m(2,1)=fC21; m(2,2)=fC22;
529 m(3,0)=fC30; m(3,1)=fC31; m(3,2)=fC32; m(3,3)=fC33;
530 m(4,0)=fC40; m(4,1)=fC41; m(4,2)=fC42; m(4,3)=fC43; m(4,4)=fC44;
531
532 m(0,1)=m(1,0);
533 m(0,2)=m(2,0); m(1,2)=m(2,1);
534 m(0,3)=m(3,0); m(1,3)=m(3,1); m(2,3)=m(3,2);
535 m(0,4)=m(4,0); m(1,4)=m(4,1); m(2,4)=m(4,2); m(3,4)=m(4,3);
536
537 Double_t det=m.Determinant();
538
539 if (det <= 0) {
7f6ddf58 540 if (n>kWARN) { cout<<" bad determinant "<<det<<endl; m.Print(); }
14825d5a 541 return 0;
542 }
543 */
544 return 1;
006b5f7f 545}
546
547//____________________________________________________________________________
7f6ddf58 548Int_t
549AliITStrackV2::Propagate(Double_t alp,Double_t xk,Double_t x0,Double_t rho) {
006b5f7f 550 //------------------------------------------------------------------
551 //This function propagates a track
552 //------------------------------------------------------------------
553 Double_t p0=fP0,p1=fP1,p2=fP2,p3=fP3,p4=fP4;
554 Double_t c00=fC00;
555 Double_t c10=fC10, c11=fC11;
556 Double_t c20=fC20, c21=fC21, c22=fC22;
557 Double_t c30=fC30, c31=fC31, c32=fC32, c33=fC33;
558 Double_t c40=fC40, c41=fC41, c42=fC42, c43=fC43, c44=fC44;
559
560
561 Double_t dalp=alp-fAlpha;
562
563 Double_t ca=TMath::Cos(dalp), sa=TMath::Sin(dalp);
564 Double_t sf=fP2, cf=TMath::Sqrt(1.- fP2*fP2);
565
566 Double_t pp2=fP2*ca - cf*sa;
567 if (TMath::Abs(pp2) >= 0.99999) {
568 Int_t n=GetNumberOfClusters();
7f6ddf58 569 if (n>kWARN)
570 cerr<<n<<" AliITStrackV2::Propagate: Rotation failed !\n";
006b5f7f 571 return 0;
572 }
573
574 fAlpha = alp;
575 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
576 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
577
578 Double_t x1=fX, y1=fP0;
579
580 fX = x1*ca + y1*sa;
581 fP0=-x1*sa + y1*ca;
582 fP2 = pp2;
583
584 cf=ca + sf*sa/cf;
585
586 if (!Invariant()) {cout<<dalp<<" Rotate !\n"; return 0;}
587
588 x1=fX; Double_t x2=xk, dx=x2-x1;
589 Double_t f1=fP2, f2=f1 + fP4*dx;
590 if (TMath::Abs(f2) >= 0.99999) {
591 Int_t n=GetNumberOfClusters();
7f6ddf58 592 if (n>kWARN)
593 cerr<<n<<" AliITStrackV2::Propagate: Propagation failed !\n";
006b5f7f 594 return 0;
595 }
596
597 Double_t r1=sqrt(1.- f1*f1), r2=sqrt(1.- f2*f2);
598
599 fP0 += dx*(f1+f2)/(r1+r2);
600 fP1 += dx*(f1+f2)/(f1*r2 + f2*r1)*fP3;
601 fP2 += dx*fP4;
602
603 //f = F - 1
604 Double_t f02= dx/(r1*r1*r1);
605 Double_t f04=0.5*dx*dx/(r1*r1*r1);
606 Double_t f12= dx*fP3*f1/(r1*r1*r1);
607 Double_t f14=0.5*dx*dx*fP3*f1/(r1*r1*r1);
608 Double_t f13= dx/r1;
609 Double_t f24= dx;
610 /*
611 //b = C*ft
612 Double_t b00=f02*fC20 + f03*fC30, b01=f12*fC20 + f13*fC30 + f14*fC40;
613 Double_t b02=f23*fC30;
614 Double_t b10=f02*fC21 + f03*fC31, b11=f12*fC21 + f13*fC31 + f14*fC41;
615 Double_t b12=f23*fC31;
616 Double_t b20=f02*fC22 + f03*fC32, b21=f12*fC22 + f13*fC32 + f14*fC42;
617 Double_t b22=f23*fC32;
618 Double_t b30=f02*fC32 + f03*fC33, b31=f12*fC32 + f13*fC33 + f14*fC43;
619 Double_t b32=f23*fC33;
620 Double_t b40=f02*fC42 + f03*fC43, b41=f12*fC42 + f13*fC43 + f14*fC44;
621 Double_t b42=f23*fC43;
622
623 //a = f*b = f*C*ft
624 Double_t a00=f02*b20+f03*b30,a01=f02*b21+f03*b31,a02=f02*b22+f03*b32;
625 Double_t a11=f12*b21+f13*b31+f14*b41,a12=f12*b22+f13*b32+f14*b42;
626 Double_t a22=f23*b32;
627
628 //F*C*Ft = C + (b + bt + a)
629 fC00 += b00 + b00 + a00;
630 fC10 += b10 + b01 + a01;
631 fC20 += b20 + b02 + a02;
632 fC30 += b30;
633 fC40 += b40;
634 fC11 += b11 + b11 + a11;
635 fC21 += b21 + b12 + a12;
636 fC31 += b31;
637 fC41 += b41;
638 fC22 += b22 + b22 + a22;
639 fC32 += b32;
640 fC42 += b42;
641*/
642
643 TMatrixD F(5,5); F.UnitMatrix();
644 F(0,0)=-(f1+f2)/(r1+r2)*sa + ca; F(0,2)=f02*cf; F(0,4)=f04;
645 F(1,0)=-(f1+f2)/(f1*r2 + f2*r1)*fP3*sa; F(1,2)=f12*cf; F(1,4)=f14; F(1,3)=f13;
646 F(2,0)=-fP4*sa; F(2,2)=cf; F(2,4)=f24;
647
648 TMatrixD C(5,5);
649 C(0,0)=fC00;
650 C(1,0)=fC10; C(1,1)=fC11;
651 C(2,0)=fC20; C(2,1)=fC21; C(2,2)=fC22;
652 C(3,0)=fC30; C(3,1)=fC31; C(3,2)=fC32; C(3,3)=fC33;
653 C(4,0)=fC40; C(4,1)=fC41; C(4,2)=fC42; C(4,3)=fC43; C(4,4)=fC44;
654
655 C(0,1)=C(1,0);
656 C(0,2)=C(2,0); C(1,2)=C(2,1);
657 C(0,3)=C(3,0); C(1,3)=C(3,1); C(2,3)=C(3,2);
658 C(0,4)=C(4,0); C(1,4)=C(4,1); C(2,4)=C(4,2); C(3,4)=C(4,3);
659
660 TMatrixD tmp(C,TMatrixD::kMult,TMatrixD(TMatrixD::kTransposed, F));
661 C.Mult(F,tmp);
662
663 fC00=C(0,0);
664 fC10=C(1,0); fC11=C(1,1);
665 fC20=C(2,0); fC21=C(2,1); fC22=C(2,2);
666 fC30=C(3,0); fC31=C(3,1); fC32=C(3,2); fC33=C(3,3);
667 fC40=C(4,0); fC41=C(4,1); fC42=C(4,2); fC43=C(4,3); fC44=C(4,4);
668
669 pp2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
7f6ddf58 670 Double_t beta2=pp2/(pp2 + GetMass()*GetMass());
006b5f7f 671
672 //Multiple scattering******************
673 //x0=0.;
674 if (x0!=0.) {
675 x0*=TMath::Sqrt((1.+ fP3*fP3)/(1.- fP2*fP2));
676 Double_t theta2=14.1*14.1/(beta2*pp2*1e6)*x0;
677 fC22 += theta2*(1.- fP2*fP2)*(1. + fP3*fP3);
678 fC33 += theta2*(1. + fP3*fP3)*(1. + fP3*fP3);
679 fC43 += theta2*fP3*fP4*(1. + fP3*fP3);
680 fC44 += theta2*fP3*fP4*fP3*fP4;
681 }
682
683 //Energy losses************************
684 if (rho!=0.) {
685 rho*=TMath::Sqrt((1.+ fP3*fP3)/(1.- fP2*fP2));
686 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2)) - beta2)*rho;
687 if (x1 < x2) dE=-dE;
7f6ddf58 688 fP4*=(1.- sqrt(pp2+GetMass()*GetMass())/pp2*dE);
006b5f7f 689 }
690
691 if (!Invariant()) {
692 fP0=p0; fP1=p1; fP2=p2; fP3=p3; fP4=p4;
693 fC00=c00;
694 fC10=c10; fC11=c11;
695 fC20=c20; fC21=c21; fC22=c22;
696 fC30=c30; fC31=c31; fC32=c32; fC33=c33;
697 fC40=c40; fC41=c41; fC42=c42; fC43=c43; fC44=c44;
698 return 0;
699 }
700
701 fX=x2;
702
703 return 1;
704}
705
706Double_t AliITStrackV2::GetD() const {
707 //------------------------------------------------------------------
708 //This function calculates the transverse impact parameter
709 //------------------------------------------------------------------
710 Double_t sn=fP4*fX - fP2, cs=fP4*fP0 + TMath::Sqrt(1.- fP2*fP2);
711 Double_t a=2*(fX*fP2 - fP0*TMath::Sqrt(1.- fP2*fP2))-fP4*(fX*fX + fP0*fP0);
712 if (fP4<0) a=-a;
713 return a/(1 + TMath::Sqrt(sn*sn + cs*cs));
714}
715
716
717Int_t AliITStrackV2::Improve(Double_t x0,Double_t yv,Double_t zv) {
718 //------------------------------------------------------------------
719 //This function improves angular track parameters
720 //------------------------------------------------------------------
721 Double_t dy=fP0-yv, dz=fP1-zv;
722 Double_t r2=fX*fX+dy*dy;
723 Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
7f6ddf58 724 Double_t beta2=p2/(p2 + GetMass()*GetMass());
006b5f7f 725 x0*=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(1.- GetSnp()*GetSnp()));
726 Double_t theta2=14.1*14.1/(beta2*p2*1e6)*x0;
727
728 Double_t par=0.5*(fP4*fX + dy*TMath::Sqrt(4/r2-fP4*fP4));
729 Double_t sigma2 = theta2*(1.- GetSnp()*GetSnp())*(1. + GetTgl()*GetTgl());
730 sigma2 += fC00/r2*(1.- dy*dy/r2)*(1.- dy*dy/r2);
731 sigma2 += kSigmaYV*kSigmaYV/r2;
732 sigma2 += 0.25*fC44*fX*fX;
733 Double_t eps2=sigma2/(fC22+sigma2), eps=TMath::Sqrt(eps2);
734 if (10*r2*fC44<fC22) {
735 fP2 = eps2*fP2 + (1-eps2)*par;
736 fC22*=eps2; fC21*=eps; fC20*=eps; fC32*=eps; fC42*=eps;
737 }
738
739 par=0.5*fP4*dz/TMath::ASin(0.5*fP4*TMath::Sqrt(r2));
740 sigma2=theta2;
741 sigma2 += fC11/r2+fC00*dy*dy*dz*dz/(r2*r2*r2);
742 sigma2 += kSigmaZV*kSigmaZV/r2;
743 eps2=sigma2/(fC33+sigma2); eps=TMath::Sqrt(eps2);
744 Double_t tgl=fP3;
745 fP3 = eps2*fP3 + (1-eps2)*par;
746 fC33*=eps2; fC32*=eps; fC31*=eps; fC30*=eps; fC43*=eps;
747
748 eps=TMath::Sqrt((1+fP3*fP3)/(1+tgl*tgl));
749 fP4*=eps;
750 fC44*=eps*eps; fC43*=eps;fC42*=eps; fC41*=eps; fC40*=eps;
751
752 if (!Invariant()) return 0;
753 return 1;
754}
755
756/*
757Int_t AliITStrackV2::Improve(Double_t x0,Double_t xv,Double_t yv) {
758 //------------------------------------------------------------------
759 //This function improves angular track parameters
760 //------------------------------------------------------------------
761 TMatrixD I(5,5);
762 TVectorD v(5); v(0)=fP0; v(1)=fP1; v(2)=fP2; v(3)=fP3; v(4)=fP4;
763
764 Double_t r2=fX*fX+fP0*fP0;
765 Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
7f6ddf58 766 Double_t beta2=p2/(p2 + GetMass()*GetMass());
006b5f7f 767 x0*=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(1.- GetSnp()*GetSnp()));
768 Double_t theta2=14.1*14.1/(beta2*p2*1e6)*x0;
769
770 v(2)=0.5*(fP4*fX + fP0*TMath::Sqrt(4/r2-fP4*fP4));
771 Double_t sigma2 = theta2*(1.- GetSnp()*GetSnp())*(1. + GetTgl()*GetTgl());
772 sigma2 += fC00/r2*(1.- fP0*fP0/r2)*(1.- fP0*fP0/r2);
773 sigma2 += kSigmaYV*kSigmaYV/r2;
774 I(2,2)=1/sigma2;
775
776 v(3)=0.5*fP4*fP1/TMath::ASin(0.5*fP4*TMath::Sqrt(r2));
777 sigma2=theta2;
778 sigma2 += fC11/r2+fC00*fP0*fP0*fP1*fP1/(r2*r2*r2);
779 sigma2 += kSigmaZV*kSigmaZV/r2;
780 I(3,3)=1/sigma2;
781
782 Double_t tgl=fP3;
783
784 TVectorD x(5); x(0)=fP0; x(1)=fP1; x(2)=fP2; x(3)=fP3; x(4)=fP4;
785 TMatrixD C(5,5);
786 C(0,0)=fC00;
787 C(1,0)=fC10; C(1,1)=fC11;
788 C(2,0)=fC20; C(2,1)=fC21; C(2,2)=fC22;
789 C(3,0)=fC30; C(3,1)=fC31; C(3,2)=fC32; C(3,3)=fC33;
790 C(4,0)=fC40; C(4,1)=fC41; C(4,2)=fC42; C(4,3)=fC43; C(4,4)=fC44;
791
792 C(0,1)=C(1,0);
793 C(0,2)=C(2,0); C(1,2)=C(2,1);
794 C(0,3)=C(3,0); C(1,3)=C(3,1); C(2,3)=C(3,2);
795 C(0,4)=C(4,0); C(1,4)=C(4,1); C(2,4)=C(4,2); C(3,4)=C(4,3);
796
797 TMatrixD tmp(I,TMatrixD::kMult,C),U(5,5); U.UnitMatrix();
798 U+=tmp;
799 U.Invert();
800 TMatrixD W1(U);
801 TMatrixD W2(tmp,TMatrixD::kMult,W1);
802
803 v*=W2; x*=W1; x+=v;
804
805 C*=W1;
806
807
808 fP0=x(0); fP1=x(1); fP2=x(2); fP3=x(3); fP4=x(4);
809 fC00=C(0,0);
810 fC10=C(1,0); fC11=C(1,1);
811 fC20=C(2,0); fC21=C(2,1); fC22=C(2,2);
812 fC30=C(3,0); fC31=C(3,1); fC32=C(3,2); fC33=C(3,3);
813 fC40=C(4,0); fC41=C(4,1); fC42=C(4,2); fC43=C(4,3); fC44=C(4,4);
814
815 eps=TMath::Sqrt((1+fP3*fP3)/(1+tgl*tgl));
816 fP4*=eps;
817 fC44*=eps*eps; fC43*=eps;fC42*=eps; fC41*=eps; fC40*=eps;
818
819 if (!Invariant()) return 0;
820 return 1;
821}
822*/
823
14825d5a 824void AliITStrackV2::ResetCovariance() {
825 //------------------------------------------------------------------
826 //This function makes a track forget its history :)
827 //------------------------------------------------------------------
828
829 fC00*=10.;
830 fC10=0.; fC11*=10.;
831 fC20=0.; fC21=0.; fC22*=10.;
832 fC30=0.; fC31=0.; fC32=0.; fC33*=10.;
833 fC40=0.; fC41=0.; fC42=0.; fC43=0.; fC44*=10.;
834
835}