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