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