Tracking in non-uniform nmagnetic field (Yu.Belikov)
[u/mrichter/AliRoot.git] / TRD / AliTRDtrack.cxx
CommitLineData
46d29e70 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
0fa7dfa7 16/* $Id$ */
46d29e70 17
a2cb5b3d 18#include <Riostream.h>
5443e65e 19#include <TObject.h>
46d29e70 20
46d29e70 21#include "AliTRDgeometry.h"
22#include "AliTRDcluster.h"
23#include "AliTRDtrack.h"
3c625a9b 24#include "AliTRDclusterCorrection.h"
b3a5a838 25
7ad19338 26ClassImp(AliTRDtracklet)
46d29e70 27ClassImp(AliTRDtrack)
28
7ad19338 29
30 AliTRDtracklet::AliTRDtracklet():fY(0),fX(0),fAlpha(0),fSigma2(0),fP0(0),fP1(0),fNFound(0),fNCross(0),fPlane(0),fExpectedSigma2(0),fChi2(0){
31}
32
46d29e70 33//_____________________________________________________________________________
34
a819a5f7 35AliTRDtrack::AliTRDtrack(const AliTRDcluster *c, UInt_t index,
5443e65e 36 const Double_t xx[5], const Double_t cc[15],
7ad19338 37 Double_t xref, Double_t alpha) : AliKalmanTrack() {
46d29e70 38 //-----------------------------------------------------------------
39 // This is the main track constructor.
40 //-----------------------------------------------------------------
5443e65e 41
42 fSeedLab = -1;
46d29e70 43
44 fAlpha=alpha;
5443e65e 45 if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
46 if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
47
46d29e70 48 fX=xref;
49
b3a5a838 50 fY=xx[0]; fZ=xx[1]; fE=xx[2]; fT=xx[3]; fC=xx[4];
c84a5e9e 51
52 SaveLocalConvConst();
46d29e70 53
54 fCyy=cc[0];
55 fCzy=cc[1]; fCzz=cc[2];
b3a5a838 56 fCey=cc[3]; fCez=cc[4]; fCee=cc[5];
57 fCty=cc[6]; fCtz=cc[7]; fCte=cc[8]; fCtt=cc[9];
b8dc2353 58 fCcy=cc[10]; fCcz=cc[11]; fCce=cc[12]; fCct=cc[13]; fCcc=cc[14];
59
5443e65e 60 fIndex[0]=index;
61 SetNumberOfClusters(1);
62
63 fdEdx=0.;
eab5961e 64 for (Int_t i=0;i<kNPlane;i++){
65 fdEdxPlane[i] = 0.;
66 fTimBinPlane[i] = -1;
67 }
a2b90f83 68
b3a5a838 69 fLhElectron = 0.0;
9c9d2487 70 fNWrong = 0;
71 fNRotate = 0;
3c625a9b 72 fStopped = 0;
4f1c04d3 73 fNCross =0;
74 fNLast =0;
75 fChi2Last=0;
76 fNExpected=0;
77 fNExpectedLast=0;
78 fNdedx=0;
5443e65e 79 Double_t q = TMath::Abs(c->GetQ());
a819a5f7 80 Double_t s = fX*fC - fE, t=fT;
5443e65e 81 if(s*s < 1) q *= TMath::Sqrt((1-s*s)/(1+t*t));
82
83 fdQdl[0] = q;
0d5b5c27 84
85 // initialisation [SR, GSI 18.02.2003] (i startd for 1)
7ad19338 86 for(UInt_t i=1; i<kMAX_CLUSTERS_PER_TRACK; i++) {
0d5b5c27 87 fdQdl[i] = 0;
88 fIndex[i] = 0;
46e2d86c 89 fIndexBackup[i] = 0; //bacup indexes MI
0d5b5c27 90 }
16d9fbba 91 fBackupTrack =0;
46d29e70 92}
93
94//_____________________________________________________________________________
5443e65e 95AliTRDtrack::AliTRDtrack(const AliTRDtrack& t) : AliKalmanTrack(t) {
46d29e70 96 //
97 // Copy constructor.
98 //
b8dc2353 99
5443e65e 100 SetLabel(t.GetLabel());
101 fSeedLab=t.GetSeedLabel();
46d29e70 102
5443e65e 103 SetChi2(t.GetChi2());
46d29e70 104 fdEdx=t.fdEdx;
eab5961e 105 for (Int_t i=0;i<kNPlane;i++){
106 fdEdxPlane[i] = t.fdEdxPlane[i];
107 fTimBinPlane[i] = t.fTimBinPlane[i];
108 }
46d29e70 109
b3a5a838 110 fLhElectron = 0.0;
9c9d2487 111 fNWrong = t.fNWrong;
112 fNRotate = t.fNRotate;
3c625a9b 113 fStopped = t.fStopped;
4f1c04d3 114 fNCross = t.fNCross;
115 fNExpected = t.fNExpected;
116 fNExpectedLast = t.fNExpectedLast;
117 fNdedx = t.fNdedx;
118 fNLast = t.fNLast;
119 fChi2Last = t.fChi2Last;
120 fBackupTrack =0;
46d29e70 121 fAlpha=t.fAlpha;
122 fX=t.fX;
123
4f1c04d3 124
b8dc2353 125 fY=t.fY; fZ=t.fZ; fE=t.fE; fT=t.fT; fC=t.fC;
46d29e70 126
127 fCyy=t.fCyy;
128 fCzy=t.fCzy; fCzz=t.fCzz;
b3a5a838 129 fCey=t.fCey; fCez=t.fCez; fCee=t.fCee;
130 fCty=t.fCty; fCtz=t.fCtz; fCte=t.fCte; fCtt=t.fCtt;
b8dc2353 131 fCcy=t.fCcy; fCcz=t.fCcz; fCce=t.fCce; fCct=t.fCct; fCcc=t.fCcc;
46d29e70 132
5443e65e 133 Int_t n=t.GetNumberOfClusters();
134 SetNumberOfClusters(n);
135 for (Int_t i=0; i<n; i++) {
a819a5f7 136 fIndex[i]=t.fIndex[i];
46e2d86c 137 fIndexBackup[i]=t.fIndex[i]; // MI - backup indexes
a819a5f7 138 fdQdl[i]=t.fdQdl[i];
139 }
b8dc2353 140
0d5b5c27 141 // initialisation (i starts from n) [SR, GSI, 18.02.2003]
7ad19338 142 for(UInt_t i=n; i<kMAX_CLUSTERS_PER_TRACK; i++) {
0d5b5c27 143 fdQdl[i] = 0;
144 fIndex[i] = 0;
46e2d86c 145 fIndexBackup[i] = 0; //MI backup indexes
0d5b5c27 146 }
5443e65e 147}
148
149//_____________________________________________________________________________
b3a5a838 150AliTRDtrack::AliTRDtrack(const AliKalmanTrack& t, Double_t alpha)
151 :AliKalmanTrack(t) {
5443e65e 152 //
153 // Constructor from AliTPCtrack or AliITStrack .
154 //
155
156 SetLabel(t.GetLabel());
157 SetChi2(0.);
b8dc2353 158 SetMass(t.GetMass());
5443e65e 159 SetNumberOfClusters(0);
160
bbc6cd2c 161 fdEdx=t.GetPIDsignal();
eab5961e 162 for (Int_t i=0;i<kNPlane;i++){
163 fdEdxPlane[i] = 0.0;
164 fTimBinPlane[i] = -1;
165 }
5443e65e 166
b3a5a838 167 fLhElectron = 0.0;
9c9d2487 168 fNWrong = 0;
169 fNRotate = 0;
3c625a9b 170 fStopped = 0;
4f1c04d3 171 fNExpected=0;
172 fNExpectedLast=0;
173 fNdedx =0;
174 fNCross =0;
175 fNLast =0;
176 fChi2Last =0;
177 fBackupTrack =0;
b3a5a838 178
5443e65e 179 fAlpha = alpha;
180 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
181 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
182
183 Double_t x, p[5]; t.GetExternalParameters(x,p);
184
185 fX=x;
186
b8dc2353 187 fY=p[0];
188 fZ=p[1];
c84a5e9e 189 fT=p[3]; x=GetLocalConvConst();
b3a5a838 190 fC=p[4]/x;
b8dc2353 191 fE=fC*fX - p[2];
5443e65e 192
193 //Conversion of the covariance matrix
194 Double_t c[15]; t.GetExternalCovariance(c);
79e94bf8 195
196 c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
197
198 Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
199 Double_t c32=fX*c[13] - c[8];
200 Double_t c20=fX*c[10] - c[3], c21=fX*c[11] - c[4], c42=fX*c[14] - c[12];
201
202 fCyy=c[0 ];
203 fCzy=c[1 ]; fCzz=c[2 ];
204 fCey=c20; fCez=c21; fCee=c22;
205 fCty=c[6 ]; fCtz=c[7 ]; fCte=c32; fCtt=c[9 ];
206 fCcy=c[10]; fCcz=c[11]; fCce=c42; fCct=c[13]; fCcc=c[14];
207
208 // Initialization [SR, GSI, 18.02.2003]
7ad19338 209 for(UInt_t i=0; i<kMAX_CLUSTERS_PER_TRACK; i++) {
79e94bf8 210 fdQdl[i] = 0;
211 fIndex[i] = 0;
46e2d86c 212 fIndexBackup[i] = 0; // MI backup indexes
79e94bf8 213 }
4f1c04d3 214
79e94bf8 215}
216//_____________________________________________________________________________
217AliTRDtrack::AliTRDtrack(const AliESDtrack& t)
218 :AliKalmanTrack() {
219 //
220 // Constructor from AliESDtrack
221 //
222
223 SetLabel(t.GetLabel());
224 SetChi2(0.);
225 SetMass(t.GetMass());
1e9bb598 226 SetNumberOfClusters(t.GetTRDclusters(fIndex));
46e2d86c 227 Int_t ncl = t.GetTRDclusters(fIndexBackup);
7ad19338 228 for (UInt_t i=ncl;i<kMAX_CLUSTERS_PER_TRACK;i++) {
46e2d86c 229 fIndexBackup[i]=0;
230 fIndex[i] = 0; //MI store indexes
231 }
c73b3eb3 232 fdEdx=t.GetTRDsignal();
eab5961e 233 for (Int_t i=0;i<kNPlane;i++){
234 fdEdxPlane[i] = t.GetTRDsignals(i);
235 fTimBinPlane[i] = t.GetTRDTimBin(i);
236 }
79e94bf8 237
238 fLhElectron = 0.0;
239 fNWrong = 0;
3c625a9b 240 fStopped = 0;
79e94bf8 241 fNRotate = 0;
4f1c04d3 242 fNExpected =0;
243 fNExpectedLast=0;
244 fNdedx = 0;
245 fNCross =0;
246 fNLast =0;
247 fChi2Last =0;
248 fBackupTrack =0;
79e94bf8 249
250 fAlpha = t.GetAlpha();
251 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
252 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
253
254 Double_t x, p[5]; t.GetExternalParameters(x,p);
c5a8e3df 255 //Conversion of the covariance matrix
256 Double_t c[15]; t.GetExternalCovariance(c);
25cde026 257 if (t.GetStatus()&AliESDtrack::kTRDbackup){
f4e9508c 258 t.GetTRDExternalParameters(x,fAlpha,p,c);
259 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
260 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
c5a8e3df 261 }
79e94bf8 262
263 fX=x;
264
79e94bf8 265 fY=p[0];
c84a5e9e 266 fZ=p[1]; SaveLocalConvConst();
267 fT=p[3]; x=GetLocalConvConst();
79e94bf8 268 fC=p[4]/x;
269 fE=fC*fX - p[2];
270
5443e65e 271
272 c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
273
274 Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
275 Double_t c32=fX*c[13] - c[8];
276 Double_t c20=fX*c[10] - c[3], c21=fX*c[11] - c[4], c42=fX*c[14] - c[12];
277
b8dc2353 278 fCyy=c[0 ];
279 fCzy=c[1 ]; fCzz=c[2 ];
280 fCey=c20; fCez=c21; fCee=c22;
281 fCty=c[6 ]; fCtz=c[7 ]; fCte=c32; fCtt=c[9 ];
282 fCcy=c[10]; fCcz=c[11]; fCce=c42; fCct=c[13]; fCcc=c[14];
5443e65e 283
0d5b5c27 284 // Initialization [SR, GSI, 18.02.2003]
7ad19338 285 for(UInt_t i=0; i<kMAX_CLUSTERS_PER_TRACK; i++) {
0d5b5c27 286 fdQdl[i] = 0;
46e2d86c 287 // fIndex[i] = 0; //MI store indexes
0d5b5c27 288 }
c630aafd 289
290 if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
291 StartTimeIntegral();
292 Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
293 SetIntegratedLength(t.GetIntegratedLength());
294
16d9fbba 295}
296
297AliTRDtrack::~AliTRDtrack()
298{
299 //
300 //
eab5961e 301
16d9fbba 302 if (fBackupTrack) delete fBackupTrack;
303 fBackupTrack=0;
eab5961e 304
16d9fbba 305}
9c9d2487 306
8206377c 307
7ad19338 308Float_t AliTRDtrack::StatusForTOF()
309{
4f1c04d3 310 Int_t status=0;
311 if (GetNumberOfClusters()<20) return 0; //
c84a5e9e 312 if (fN>110&&fChi2/(Float_t(fN))<3) return 3; //gold
313 if (fNLast>30&&fChi2Last/(Float_t(fNLast))<3) return 3; //gold
314 if (fNLast>20&&fChi2Last/(Float_t(fNLast))<2) return 3; //gold
315 if (fNLast/(fNExpectedLast+3.)>0.8 && fChi2Last/Float_t(fNLast)<5&&fNLast>20) return 2; //silber
316 if (fNLast>5 &&((fNLast+1.)/(fNExpectedLast+1.))>0.8&&fChi2Last/(fNLast-5.)<6) return 1;
317 //
4f1c04d3 318
319 return status;
320}
321
7ad19338 322
5443e65e 323//____________________________________________________________________________
324void AliTRDtrack::GetExternalParameters(Double_t& xr, Double_t x[5]) const {
325 //
326 // This function returns external TRD track representation
327 //
328 xr=fX;
329 x[0]=GetY();
330 x[1]=GetZ();
331 x[2]=GetSnp();
332 x[3]=GetTgl();
b8dc2353 333 x[4]=Get1Pt();
5443e65e 334}
335
336//_____________________________________________________________________________
337void AliTRDtrack::GetExternalCovariance(Double_t cc[15]) const {
338 //
339 // This function returns external representation of the covriance matrix.
340 //
c84a5e9e 341 Double_t a=GetLocalConvConst();
5443e65e 342
b3a5a838 343 Double_t c22=fX*fX*fCcc-2*fX*fCce+fCee;
344 Double_t c32=fX*fCct-fCte;
345 Double_t c20=fX*fCcy-fCey, c21=fX*fCcz-fCez, c42=fX*fCcc-fCce;
5443e65e 346
347 cc[0 ]=fCyy;
348 cc[1 ]=fCzy; cc[2 ]=fCzz;
349 cc[3 ]=c20; cc[4 ]=c21; cc[5 ]=c22;
350 cc[6 ]=fCty; cc[7 ]=fCtz; cc[8 ]=c32; cc[9 ]=fCtt;
b8dc2353 351 cc[10]=fCcy*a; cc[11]=fCcz*a; cc[12]=c42*a; cc[13]=fCct*a; cc[14]=fCcc*a*a;
352
5443e65e 353}
354
7ad19338 355
46d29e70 356//_____________________________________________________________________________
7ad19338 357void AliTRDtrack::GetCovariance(Double_t cc[15]) const {
b8dc2353 358
46d29e70 359 cc[0]=fCyy;
360 cc[1]=fCzy; cc[2]=fCzz;
b3a5a838 361 cc[3]=fCey; cc[4]=fCez; cc[5]=fCee;
362 cc[6]=fCcy; cc[7]=fCcz; cc[8]=fCce; cc[9]=fCcc;
363 cc[10]=fCty; cc[11]=fCtz; cc[12]=fCte; cc[13]=fCct; cc[14]=fCtt;
b8dc2353 364
46d29e70 365}
366
367//_____________________________________________________________________________
2a941f4e 368Int_t AliTRDtrack::Compare(const TObject *o) const {
46d29e70 369
5443e65e 370// Compares tracks according to their Y2 or curvature
46d29e70 371
372 AliTRDtrack *t=(AliTRDtrack*)o;
373 // Double_t co=t->GetSigmaY2();
374 // Double_t c =GetSigmaY2();
375
376 Double_t co=TMath::Abs(t->GetC());
377 Double_t c =TMath::Abs(GetC());
378
379 if (c>co) return 1;
380 else if (c<co) return -1;
381 return 0;
382}
383
384//_____________________________________________________________________________
a819a5f7 385void AliTRDtrack::CookdEdx(Double_t low, Double_t up) {
386 //-----------------------------------------------------------------
387 // Calculates dE/dX within the "low" and "up" cuts.
388 //-----------------------------------------------------------------
5443e65e 389
a819a5f7 390 Int_t i;
4f1c04d3 391 //Int_t nc=GetNumberOfClusters();
392 Int_t nc=fNdedx;
393 if (nc<10) {
394 SetdEdx(0);
395 return;
396 }
a819a5f7 397
7ad19338 398 Float_t sorted[kMAX_CLUSTERS_PER_TRACK];
5443e65e 399 for (i=0; i < nc; i++) {
c84a5e9e 400 sorted[i]=fdQdl[i];
5443e65e 401 }
c84a5e9e 402 /*
403 Int_t swap;
404
405 do {
406 swap=0;
407 for (i=0; i<nc-1; i++) {
408 if (sorted[i]<=sorted[i+1]) continue;
409 Float_t tmp=sorted[i];
410 sorted[i]=sorted[i+1]; sorted[i+1]=tmp;
411 swap++;
412 }
413 } while (swap);
414 */
a819a5f7 415 Int_t nl=Int_t(low*nc), nu=Int_t(up*nc);
416 Float_t dedx=0;
c84a5e9e 417 //for (i=nl; i<=nu; i++) dedx += sorted[i];
418 //dedx /= (nu-nl+1);
419 for (i=0; i<nc; i++) dedx += sorted[i]; // ADDED by PS
420 if((nu-nl)) dedx /= (nu-nl); // ADDED by PS
5443e65e 421
a819a5f7 422 SetdEdx(dedx);
423}
424
7ad19338 425
a819a5f7 426//_____________________________________________________________________________
b3a5a838 427Int_t AliTRDtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho)
46d29e70 428{
429 // Propagates a track of particle with mass=pm to a reference plane
430 // defined by x=xk through media of density=rho and radiationLength=x0
431
9c9d2487 432 if (xk == fX) return 1;
433
3c625a9b 434 if (TMath::Abs(fC*xk - fE) >= 0.90000) {
435 // Int_t n=GetNumberOfClusters();
436 //if (n>4) cerr << n << " AliTRDtrack: Propagation failed, \tPt = "
437 // << GetPt() << "\t" << GetLabel() << "\t" << GetMass() << endl;
46d29e70 438 return 0;
439 }
c84a5e9e 440 Double_t lcc=GetLocalConvConst();
46d29e70 441
0d5b5c27 442 // track Length measurement [SR, GSI, 17.02.2003]
443 Double_t oldX = fX, oldY = fY, oldZ = fZ;
444
46d29e70 445 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1, y1=fY, z1=fZ;
5443e65e 446 Double_t c1=fC*x1 - fE;
447 if((c1*c1) > 1) return 0;
448 Double_t r1=sqrt(1.- c1*c1);
b8dc2353 449 Double_t c2=fC*x2 - fE;
5443e65e 450 if((c2*c2) > 1) return 0;
451 Double_t r2=sqrt(1.- c2*c2);
46d29e70 452
453 fY += dx*(c1+c2)/(r1+r2);
454 fZ += dx*(c1+c2)/(c1*r2 + c2*r1)*fT;
455
456 //f = F - 1
457 Double_t rr=r1+r2, cc=c1+c2, xx=x1+x2;
b3a5a838 458 Double_t f02=-dx*(2*rr + cc*(c1/r1 + c2/r2))/(rr*rr);
459 Double_t f04= dx*(rr*xx + cc*(c1*x1/r1+c2*x2/r2))/(rr*rr);
46d29e70 460 Double_t cr=c1*r2+c2*r1;
b3a5a838 461 Double_t f12=-dx*fT*(2*cr + cc*(c2*c1/r1-r1 + c1*c2/r2-r2))/(cr*cr);
462 Double_t f13= dx*cc/cr;
b8dc2353 463 Double_t f14=dx*fT*(cr*xx-cc*(r1*x2-c2*c1*x1/r1+r2*x1-c1*c2*x2/r2))/(cr*cr);
46d29e70 464
465 //b = C*ft
b3a5a838 466 Double_t b00=f02*fCey + f04*fCcy, b01=f12*fCey + f14*fCcy + f13*fCty;
467 Double_t b10=f02*fCez + f04*fCcz, b11=f12*fCez + f14*fCcz + f13*fCtz;
468 Double_t b20=f02*fCee + f04*fCce, b21=f12*fCee + f14*fCce + f13*fCte;
469 Double_t b30=f02*fCte + f04*fCct, b31=f12*fCte + f14*fCct + f13*fCtt;
470 Double_t b40=f02*fCce + f04*fCcc, b41=f12*fCce + f14*fCcc + f13*fCct;
46d29e70 471
472 //a = f*b = f*C*ft
b3a5a838 473 Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a11=f12*b21+f14*b41+f13*b31;
46d29e70 474
475 //F*C*Ft = C + (a + b + bt)
476 fCyy += a00 + 2*b00;
477 fCzy += a01 + b01 + b10;
b3a5a838 478 fCey += b20;
479 fCty += b30;
480 fCcy += b40;
46d29e70 481 fCzz += a11 + 2*b11;
b3a5a838 482 fCez += b21;
483 fCtz += b31;
b8dc2353 484 fCcz += b41;
46d29e70 485
b8dc2353 486 fX=x2;
46d29e70 487
c84a5e9e 488 //Change of the magnetic field *************
489 SaveLocalConvConst();
490 cc=fC;
491 fC*=lcc/GetLocalConvConst();
492 fE+=fX*(fC-cc);
493
46d29e70 494 //Multiple scattering ******************
46d29e70 495 Double_t d=sqrt((x1-fX)*(x1-fX)+(y1-fY)*(y1-fY)+(z1-fZ)*(z1-fZ));
b8dc2353 496 Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
b3a5a838 497 Double_t beta2=p2/(p2 + GetMass()*GetMass());
b8dc2353 498 Double_t theta2=14.1*14.1/(beta2*p2*1e6)*d/x0*rho;
c84a5e9e 499
46d29e70 500 Double_t ey=fC*fX - fE, ez=fT;
501 Double_t xz=fC*ez, zz1=ez*ez+1, xy=fE+ey;
3c625a9b 502
46d29e70 503 fCee += (2*ey*ez*ez*fE+1-ey*ey+ez*ez+fE*fE*ez*ez)*theta2;
504 fCte += ez*zz1*xy*theta2;
505 fCtt += zz1*zz1*theta2;
b3a5a838 506 fCce += xz*ez*xy*theta2;
507 fCct += xz*zz1*theta2;
508 fCcc += xz*xz*theta2;
3c625a9b 509 /*
510 Double_t dc22 = (1-ey*ey+xz*xz*fX*fX)*theta2;
511 Double_t dc32 = (xz*fX*zz1)*theta2;
512 Double_t dc33 = (zz1*zz1)*theta2;
513 Double_t dc42 = (xz*fX*xz)*theta2;
514 Double_t dc43 = (zz1*xz)*theta2;
515 Double_t dc44 = (xz*xz)*theta2;
516 fCee += dc22;
517 fCte += dc32;
518 fCtt += dc33;
519 fCce += dc42;
520 fCct += dc43;
521 fCcc += dc44;
522 */
46d29e70 523 //Energy losses************************
b8dc2353 524 if((5940*beta2/(1-beta2+1e-10) - beta2) < 0) return 0;
5443e65e 525
c84a5e9e 526 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2+1e-10)) - beta2)*d*rho;
b8dc2353 527 if (x1 < x2) dE=-dE;
528 cc=fC;
b3a5a838 529 fC*=(1.- sqrt(p2+GetMass()*GetMass())/p2*dE);
b8dc2353 530 fE+=fX*(fC-cc);
c84a5e9e 531
0d5b5c27 532 // track time measurement [SR, GSI 17.02.2002]
0fa7dfa7 533 if (x1 < x2)
0d5b5c27 534 if (IsStartedTimeIntegral()) {
535 Double_t l2 = (fX-oldX)*(fX-oldX) + (fY-oldY)*(fY-oldY) + (fZ-oldZ)*(fZ-oldZ);
536 AddTimeStep(TMath::Sqrt(l2));
537 }
538
b8dc2353 539 return 1;
46d29e70 540}
541
7ad19338 542
46d29e70 543//_____________________________________________________________________________
fd621f36 544Int_t AliTRDtrack::Update(const AliTRDcluster *c, Double_t chisq, UInt_t index, Double_t h01)
46d29e70 545{
546 // Assignes found cluster to the track and updates track information
547
b8dc2353 548 Bool_t fNoTilt = kTRUE;
549 if(TMath::Abs(h01) > 0.003) fNoTilt = kFALSE;
46e2d86c 550 // add angular effect to the error contribution - MI
3c625a9b 551 Float_t tangent2 = (fC*fX-fE)*(fC*fX-fE);
552 if (tangent2 < 0.90000){
46e2d86c 553 tangent2 = tangent2/(1.-tangent2);
554 }
555 Float_t errang = tangent2*0.04; //
556 Float_t padlength = TMath::Sqrt(c->GetSigmaZ2()*12.);
fd621f36 557
46e2d86c 558 Double_t r00=c->GetSigmaY2() +errang, r01=0., r11=c->GetSigmaZ2()*100.;
b8dc2353 559 r00+=fCyy; r01+=fCzy; r11+=fCzz;
46d29e70 560 Double_t det=r00*r11 - r01*r01;
561 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
562
b8dc2353 563 Double_t k00=fCyy*r00+fCzy*r01, k01=fCyy*r01+fCzy*r11;
564 Double_t k10=fCzy*r00+fCzz*r01, k11=fCzy*r01+fCzz*r11;
565 Double_t k20=fCey*r00+fCez*r01, k21=fCey*r01+fCez*r11;
566 Double_t k30=fCty*r00+fCtz*r01, k31=fCty*r01+fCtz*r11;
567 Double_t k40=fCcy*r00+fCcz*r01, k41=fCcy*r01+fCcz*r11;
46d29e70 568
569 Double_t dy=c->GetY() - fY, dz=c->GetZ() - fZ;
b3a5a838 570 Double_t cur=fC + k40*dy + k41*dz, eta=fE + k20*dy + k21*dz;
fd621f36 571
46d29e70 572
b8dc2353 573 if(fNoTilt) {
3c625a9b 574 if (TMath::Abs(cur*fX-eta) >= 0.90000) {
575 // Int_t n=GetNumberOfClusters();
576 //if (n>4) cerr<<n<<" AliTRDtrack warning: Filtering failed !\n";
b8dc2353 577 return 0;
578 }
579 fY += k00*dy + k01*dz;
580 fZ += k10*dy + k11*dz;
581 fE = eta;
9c9d2487 582 //fT += k30*dy + k31*dz;
b8dc2353 583 fC = cur;
584 }
585 else {
7ad19338 586 Double_t xu_factor = 100.; // empirical factor set by C.Xu
b8dc2353 587 // in the first tilt version
46e2d86c 588 dy=c->GetY() - fY; dz=c->GetZ() - fZ;
589 dy=dy+h01*dz;
590 Float_t add=0;
591 if (TMath::Abs(dz)>padlength/2.){
3c625a9b 592 Float_t dy2 = c->GetY() - fY;
593 Float_t sign = (dz>0) ? -1.: 1.;
594 dy2+=h01*sign*padlength/2.;
595 dy = dy2;
596 add = 0;
46e2d86c 597 }
598
599
600
7ad19338 601 r00=c->GetSigmaY2()+errang+add, r01=0., r11=c->GetSigmaZ2()*xu_factor;
b8dc2353 602 r00+=(fCyy+2.0*h01*fCzy+h01*h01*fCzz);
46e2d86c 603
b8dc2353 604 r01+=(fCzy+h01*fCzz);
605 det=r00*r11 - r01*r01;
606 tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
607
608 k00=fCyy*r00+fCzy*(r01+h01*r00),k01=fCyy*r01+fCzy*(r11+h01*r01);
609 k10=fCzy*r00+fCzz*(r01+h01*r00),k11=fCzy*r01+fCzz*(r11+h01*r01);
610 k20=fCey*r00+fCez*(r01+h01*r00),k21=fCey*r01+fCez*(r11+h01*r01);
611 k30=fCty*r00+fCtz*(r01+h01*r00),k31=fCty*r01+fCtz*(r11+h01*r01);
612 k40=fCcy*r00+fCcz*(r01+h01*r00),k41=fCcy*r01+fCcz*(r11+h01*r01);
613
b8dc2353 614
615 cur=fC + k40*dy + k41*dz; eta=fE + k20*dy + k21*dz;
3c625a9b 616 if (TMath::Abs(cur*fX-eta) >= 0.90000) {
617 // Int_t n=GetNumberOfClusters();
618 //if (n>4) cerr<<n<<" AliTRDtrack warning: Filtering failed !\n";
b8dc2353 619 return 0;
620 }
621 fY += k00*dy + k01*dz;
622 fZ += k10*dy + k11*dz;
623 fE = eta;
46e2d86c 624 fT += k30*dy + k31*dz;
b8dc2353 625 fC = cur;
626
627 k01+=h01*k00;
628 k11+=h01*k10;
629 k21+=h01*k20;
630 k31+=h01*k30;
631 k41+=h01*k40;
46e2d86c 632
b8dc2353 633 }
46e2d86c 634 Double_t c01=fCzy, c02=fCey, c03=fCty, c04=fCcy;
635 Double_t c12=fCez, c13=fCtz, c14=fCcz;
636
b8dc2353 637
46d29e70 638 fCyy-=k00*fCyy+k01*fCzy; fCzy-=k00*c01+k01*fCzz;
b3a5a838 639 fCey-=k00*c02+k01*c12; fCty-=k00*c03+k01*c13;
640 fCcy-=k00*c04+k01*c14;
b8dc2353 641
46d29e70 642 fCzz-=k10*c01+k11*fCzz;
b3a5a838 643 fCez-=k10*c02+k11*c12; fCtz-=k10*c03+k11*c13;
644 fCcz-=k10*c04+k11*c14;
b8dc2353 645
b3a5a838 646 fCee-=k20*c02+k21*c12; fCte-=k20*c03+k21*c13;
647 fCce-=k20*c04+k21*c14;
b8dc2353 648
b3a5a838 649 fCtt-=k30*c03+k31*c13;
46e2d86c 650 fCct-=k40*c03+k41*c13;
651 //fCct-=k30*c04+k31*c14; // symmetric formula MI
b8dc2353 652
653 fCcc-=k40*c04+k41*c14;
46d29e70 654
b8dc2353 655 Int_t n=GetNumberOfClusters();
5443e65e 656 fIndex[n]=index;
b8dc2353 657 SetNumberOfClusters(n+1);
fd621f36 658
b8dc2353 659 SetChi2(GetChi2()+chisq);
46d29e70 660 // cerr<<"in update: fIndex["<<fN<<"] = "<<index<<endl;
5443e65e 661
b8dc2353 662 return 1;
46d29e70 663}
46e2d86c 664//_____________________________________________________________________________
3c625a9b 665Int_t AliTRDtrack::UpdateMI(const AliTRDcluster *c, Double_t chisq, UInt_t index, Double_t h01,
4f1c04d3 666 Int_t /*plane*/)
46e2d86c 667{
668 // Assignes found cluster to the track and updates track information
669
670 Bool_t fNoTilt = kTRUE;
671 if(TMath::Abs(h01) > 0.003) fNoTilt = kFALSE;
3c625a9b 672 // add angular effect to the error contribution and make correction - MI
c5a8e3df 673 //AliTRDclusterCorrection *corrector = AliTRDclusterCorrection::GetCorrection();
3c625a9b 674 //
675 Double_t tangent2 = (fC*fX-fE)*(fC*fX-fE);
676 if (tangent2 < 0.90000){
46e2d86c 677 tangent2 = tangent2/(1.-tangent2);
678 }
3c625a9b 679 Double_t tangent = TMath::Sqrt(tangent2);
680 if ((fC*fX-fE)<0) tangent*=-1;
c84a5e9e 681 // Double_t correction = 0*plane;
682 Double_t errang = tangent2*0.04; //
683 Double_t errsys =0.025*0.025*20; //systematic error part
684 Float_t extend =1;
685 if (c->GetNPads()==4) extend=2;
686 //if (c->GetNPads()==5) extend=3;
687 //if (c->GetNPads()==6) extend=3;
688 //if (c->GetQ()<15) return 1;
4f1c04d3 689
c5a8e3df 690 /*
3c625a9b 691 if (corrector!=0){
692 //if (0){
693 correction = corrector->GetCorrection(plane,c->GetLocalTimeBin(),tangent);
694 if (TMath::Abs(correction)>0){
695 //if we have info
696 errang = corrector->GetSigma(plane,c->GetLocalTimeBin(),tangent);
697 errang *= errang;
698 errang += tangent2*0.04;
699 }
700 }
c5a8e3df 701 */
3c625a9b 702 //
c84a5e9e 703 // Double_t padlength = TMath::Sqrt(c->GetSigmaZ2()*12.);
704
705 Double_t r00=(c->GetSigmaY2() +errang+errsys)*extend, r01=0., r11=c->GetSigmaZ2()*10000.;
46e2d86c 706 r00+=fCyy; r01+=fCzy; r11+=fCzz;
707 Double_t det=r00*r11 - r01*r01;
708 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
709
710 Double_t k00=fCyy*r00+fCzy*r01, k01=fCyy*r01+fCzy*r11;
711 Double_t k10=fCzy*r00+fCzz*r01, k11=fCzy*r01+fCzz*r11;
712 Double_t k20=fCey*r00+fCez*r01, k21=fCey*r01+fCez*r11;
713 Double_t k30=fCty*r00+fCtz*r01, k31=fCty*r01+fCtz*r11;
714 Double_t k40=fCcy*r00+fCcz*r01, k41=fCcy*r01+fCcz*r11;
715
716 Double_t dy=c->GetY() - fY, dz=c->GetZ() - fZ;
717 Double_t cur=fC + k40*dy + k41*dz, eta=fE + k20*dy + k21*dz;
718
719
720 if(fNoTilt) {
3c625a9b 721 if (TMath::Abs(cur*fX-eta) >= 0.90000) {
722 // Int_t n=GetNumberOfClusters();
723 //if (n>4) cerr<<n<<" AliTRDtrack warning: Filtering failed !\n";
46e2d86c 724 return 0;
725 }
726 fY += k00*dy + k01*dz;
727 fZ += k10*dy + k11*dz;
728 fE = eta;
729 //fT += k30*dy + k31*dz;
730 fC = cur;
731 }
732 else {
c84a5e9e 733 Double_t padlength = TMath::Sqrt(c->GetSigmaZ2()*12);
4f1c04d3 734
7ad19338 735 Double_t xu_factor = 1000.; // empirical factor set by C.Xu
46e2d86c 736 // in the first tilt version
737 dy=c->GetY() - fY; dz=c->GetZ() - fZ;
c84a5e9e 738 //dy=dy+h01*dz+correction;
4f1c04d3 739
740 Double_t tiltdz = dz;
c84a5e9e 741 if (TMath::Abs(tiltdz)>padlength/2.) {
742 tiltdz = TMath::Sign(padlength/2,dz);
743 }
744 // dy=dy+h01*dz;
4f1c04d3 745 dy=dy+h01*tiltdz;
746
c84a5e9e 747 Double_t add=0;
748 if (TMath::Abs(dz)>padlength/2.){
749 //Double_t dy2 = c->GetY() - fY;
750 //Double_t sign = (dz>0) ? -1.: 1.;
751 //dy2-=h01*sign*padlength/2.;
752 //dy = dy2;
753 add =1;
754 }
755 Double_t s00 = (c->GetSigmaY2()+errang)*extend+errsys+add; // error pad
7ad19338 756 Double_t s11 = c->GetSigmaZ2()*xu_factor; // error pad-row
46e2d86c 757 //
758 r00 = fCyy + 2*fCzy*h01 + fCzz*h01*h01+s00;
759 r01 = fCzy + fCzz*h01;
760 r11 = fCzz + s11;
761 det = r00*r11 - r01*r01;
762 // inverse matrix
763 tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
764
765 // K matrix
766 k00=fCyy*r00+fCzy*(r01+h01*r00),k01=fCyy*r01+fCzy*(r11+h01*r01);
767 k10=fCzy*r00+fCzz*(r01+h01*r00),k11=fCzy*r01+fCzz*(r11+h01*r01);
768 k20=fCey*r00+fCez*(r01+h01*r00),k21=fCey*r01+fCez*(r11+h01*r01);
769 k30=fCty*r00+fCtz*(r01+h01*r00),k31=fCty*r01+fCtz*(r11+h01*r01);
770 k40=fCcy*r00+fCcz*(r01+h01*r00),k41=fCcy*r01+fCcz*(r11+h01*r01);
771 //
772 //Update measurement
773 cur=fC + k40*dy + k41*dz; eta=fE + k20*dy + k21*dz;
3c625a9b 774 if (TMath::Abs(cur*fX-eta) >= 0.90000) {
775 //Int_t n=GetNumberOfClusters();
776 // if (n>4) cerr<<n<<" AliTRDtrack warning: Filtering failed !\n";
46e2d86c 777 return 0;
778 }
779 fY += k00*dy + k01*dz;
780 fZ += k10*dy + k11*dz;
781 fE = eta;
782 fT += k30*dy + k31*dz;
783 fC = cur;
784
785 k01+=h01*k00;
786 k11+=h01*k10;
787 k21+=h01*k20;
788 k31+=h01*k30;
789 k41+=h01*k40;
790
791 }
792 //Update covariance
793 //
794 //
795 Double_t oldyy = fCyy, oldzz = fCzz; //, oldee=fCee, oldcc =fCcc;
796 Double_t oldzy = fCzy, oldey = fCey, oldty=fCty, oldcy =fCcy;
797 Double_t oldez = fCez, oldtz = fCtz, oldcz=fCcz;
798 //Double_t oldte = fCte, oldce = fCce;
799 //Double_t oldct = fCct;
800
801 fCyy-=k00*oldyy+k01*oldzy;
802 fCzy-=k10*oldyy+k11*oldzy;
803 fCey-=k20*oldyy+k21*oldzy;
804 fCty-=k30*oldyy+k31*oldzy;
805 fCcy-=k40*oldyy+k41*oldzy;
806 //
807 fCzz-=k10*oldzy+k11*oldzz;
808 fCez-=k20*oldzy+k21*oldzz;
809 fCtz-=k30*oldzy+k31*oldzz;
810 fCcz-=k40*oldzy+k41*oldzz;
811 //
812 fCee-=k20*oldey+k21*oldez;
813 fCte-=k30*oldey+k31*oldez;
814 fCce-=k40*oldey+k41*oldez;
815 //
816 fCtt-=k30*oldty+k31*oldtz;
817 fCct-=k40*oldty+k41*oldtz;
818 //
819 fCcc-=k40*oldcy+k41*oldcz;
820 //
821
822 Int_t n=GetNumberOfClusters();
823 fIndex[n]=index;
824 SetNumberOfClusters(n+1);
825
826 SetChi2(GetChi2()+chisq);
827 // cerr<<"in update: fIndex["<<fN<<"] = "<<index<<endl;
828
829 return 1;
830}
46d29e70 831
7ad19338 832
833
7ad19338 834//_____________________________________________________________________________
835Int_t AliTRDtrack::UpdateMI(const AliTRDtracklet &tracklet)
836{
837 //
838 // Assignes found tracklet to the track and updates track information
839 //
840 //
841 Double_t r00=(tracklet.GetTrackletSigma2()), r01=0., r11= 10000.;
842 r00+=fCyy; r01+=fCzy; r11+=fCzz;
843 //
844 Double_t det=r00*r11 - r01*r01;
845 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
846 //
847
848 Double_t dy=tracklet.GetY() - fY, dz=tracklet.GetZ() - fZ;
849
850
851 Double_t s00 = tracklet.GetTrackletSigma2(); // error pad
852 Double_t s11 = 100000; // error pad-row
853 Float_t h01 = tracklet.GetTilt();
854 //
855 // r00 = fCyy + 2*fCzy*h01 + fCzz*h01*h01+s00;
856 r00 = fCyy + fCzz*h01*h01+s00;
857 // r01 = fCzy + fCzz*h01;
858 r01 = fCzy ;
859 r11 = fCzz + s11;
860 det = r00*r11 - r01*r01;
861 // inverse matrix
862 tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
863
864 Double_t k00=fCyy*r00+fCzy*r01, k01=fCyy*r01+fCzy*r11;
865 Double_t k10=fCzy*r00+fCzz*r01, k11=fCzy*r01+fCzz*r11;
866 Double_t k20=fCey*r00+fCez*r01, k21=fCey*r01+fCez*r11;
867 Double_t k30=fCty*r00+fCtz*r01, k31=fCty*r01+fCtz*r11;
868 Double_t k40=fCcy*r00+fCcz*r01, k41=fCcy*r01+fCcz*r11;
869
870 // K matrix
871// k00=fCyy*r00+fCzy*(r01+h01*r00),k01=fCyy*r01+fCzy*(r11+h01*r01);
872// k10=fCzy*r00+fCzz*(r01+h01*r00),k11=fCzy*r01+fCzz*(r11+h01*r01);
873// k20=fCey*r00+fCez*(r01+h01*r00),k21=fCey*r01+fCez*(r11+h01*r01);
874// k30=fCty*r00+fCtz*(r01+h01*r00),k31=fCty*r01+fCtz*(r11+h01*r01);
875// k40=fCcy*r00+fCcz*(r01+h01*r00),k41=fCcy*r01+fCcz*(r11+h01*r01);
876 //
877 //Update measurement
878 Double_t cur=fC + k40*dy + k41*dz, eta=fE + k20*dy + k21*dz;
879 // cur=fC + k40*dy + k41*dz; eta=fE + k20*dy + k21*dz;
880 if (TMath::Abs(cur*fX-eta) >= 0.90000) {
881 //Int_t n=GetNumberOfClusters();
882 // if (n>4) cerr<<n<<" AliTRDtrack warning: Filtering failed !\n";
883 return 0;
884 }
885// k01+=h01*k00;
886// k11+=h01*k10;
887// k21+=h01*k20;
888// k31+=h01*k30;
889// k41+=h01*k40;
890
891
892 fY += k00*dy + k01*dz;
893 fZ += k10*dy + k11*dz;
894 fE = eta;
895 fT += k30*dy + k31*dz;
896 fC = cur;
897
898
899 //Update covariance
900 //
901 //
902 Double_t oldyy = fCyy, oldzz = fCzz; //, oldee=fCee, oldcc =fCcc;
903 Double_t oldzy = fCzy, oldey = fCey, oldty=fCty, oldcy =fCcy;
904 Double_t oldez = fCez, oldtz = fCtz, oldcz=fCcz;
905 //Double_t oldte = fCte, oldce = fCce;
906 //Double_t oldct = fCct;
907
908 fCyy-=k00*oldyy+k01*oldzy;
909 fCzy-=k10*oldyy+k11*oldzy;
910 fCey-=k20*oldyy+k21*oldzy;
911 fCty-=k30*oldyy+k31*oldzy;
912 fCcy-=k40*oldyy+k41*oldzy;
913 //
914 fCzz-=k10*oldzy+k11*oldzz;
915 fCez-=k20*oldzy+k21*oldzz;
916 fCtz-=k30*oldzy+k31*oldzz;
917 fCcz-=k40*oldzy+k41*oldzz;
918 //
919 fCee-=k20*oldey+k21*oldez;
920 fCte-=k30*oldey+k31*oldez;
921 fCce-=k40*oldey+k41*oldez;
922 //
923 fCtt-=k30*oldty+k31*oldtz;
924 fCct-=k40*oldty+k41*oldtz;
925 //
926 fCcc-=k40*oldcy+k41*oldcz;
927 //
928 /*
929 Int_t n=GetNumberOfClusters();
930 fIndex[n]=index;
931 SetNumberOfClusters(n+1);
932
933 SetChi2(GetChi2()+chisq);
934 // cerr<<"in update: fIndex["<<fN<<"] = "<<index<<endl;
935 */
936 return 1;
937}
938
939
c84a5e9e 940
46d29e70 941//_____________________________________________________________________________
942Int_t AliTRDtrack::Rotate(Double_t alpha)
943{
944 // Rotates track parameters in R*phi plane
9c9d2487 945
946 fNRotate++;
46d29e70 947
948 fAlpha += alpha;
b3a5a838 949 if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
b8dc2353 950 if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
46d29e70 951
952 Double_t x1=fX, y1=fY;
953 Double_t ca=cos(alpha), sa=sin(alpha);
954 Double_t r1=fC*fX - fE;
955
956 fX = x1*ca + y1*sa;
b8dc2353 957 fY =-x1*sa + y1*ca;
958 if((r1*r1) > 1) return 0;
46d29e70 959 fE=fE*ca + (fC*y1 + sqrt(1.- r1*r1))*sa;
960
961 Double_t r2=fC*fX - fE;
3c625a9b 962 if (TMath::Abs(r2) >= 0.90000) {
b8dc2353 963 Int_t n=GetNumberOfClusters();
5443e65e 964 if (n>4) cerr<<n<<" AliTRDtrack warning: Rotation failed !\n";
46d29e70 965 return 0;
966 }
967
b8dc2353 968 if((r2*r2) > 1) return 0;
46d29e70 969 Double_t y0=fY + sqrt(1.- r2*r2)/fC;
970 if ((fY-y0)*fC >= 0.) {
b8dc2353 971 Int_t n=GetNumberOfClusters();
5443e65e 972 if (n>4) cerr<<n<<" AliTRDtrack warning: Rotation failed !!!\n";
46d29e70 973 return 0;
974 }
975
976 //f = F - 1
b3a5a838 977 Double_t f00=ca-1, f24=(y1 - r1*x1/sqrt(1.- r1*r1))*sa,
b8dc2353 978 f20=fC*sa, f22=(ca + sa*r1/sqrt(1.- r1*r1))-1;
46d29e70 979
980 //b = C*ft
b3a5a838 981 Double_t b00=fCyy*f00, b02=fCyy*f20+fCcy*f24+fCey*f22;
982 Double_t b10=fCzy*f00, b12=fCzy*f20+fCcz*f24+fCez*f22;
983 Double_t b20=fCey*f00, b22=fCey*f20+fCce*f24+fCee*f22;
984 Double_t b30=fCty*f00, b32=fCty*f20+fCct*f24+fCte*f22;
985 Double_t b40=fCcy*f00, b42=fCcy*f20+fCcc*f24+fCce*f22;
46d29e70 986
987 //a = f*b = f*C*ft
b3a5a838 988 Double_t a00=f00*b00, a02=f00*b02, a22=f20*b02+f24*b42+f22*b22;
46d29e70 989
46d29e70 990 //F*C*Ft = C + (a + b + bt)
991 fCyy += a00 + 2*b00;
992 fCzy += b10;
b3a5a838 993 fCey += a02+b20+b02;
994 fCty += b30;
995 fCcy += b40;
996 fCez += b12;
997 fCte += b32;
998 fCee += a22 + 2*b22;
999 fCce += b42;
46d29e70 1000
b8dc2353 1001 return 1;
46d29e70 1002}
1003
7ad19338 1004
46d29e70 1005//_____________________________________________________________________________
fd621f36 1006Double_t AliTRDtrack::GetPredictedChi2(const AliTRDcluster *c, Double_t h01) const
46d29e70 1007{
7ad19338 1008
b8dc2353 1009 Bool_t fNoTilt = kTRUE;
1010 if(TMath::Abs(h01) > 0.003) fNoTilt = kFALSE;
1011 Double_t chi2, dy, r00, r01, r11;
1012
1013 if(fNoTilt) {
1014 dy=c->GetY() - fY;
1015 r00=c->GetSigmaY2();
1016 chi2 = (dy*dy)/r00;
46d29e70 1017 }
b8dc2353 1018 else {
4f1c04d3 1019 Double_t padlength = TMath::Sqrt(c->GetSigmaZ2()*12);
1020 //
b8dc2353 1021 r00=c->GetSigmaY2(); r01=0.; r11=c->GetSigmaZ2();
1022 r00+=fCyy; r01+=fCzy; r11+=fCzz;
1023
1024 Double_t det=r00*r11 - r01*r01;
1025 if (TMath::Abs(det) < 1.e-10) {
1026 Int_t n=GetNumberOfClusters();
1027 if (n>4) cerr<<n<<" AliTRDtrack warning: Singular matrix !\n";
1028 return 1e10;
1029 }
1030 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
1031 Double_t dy=c->GetY() - fY, dz=c->GetZ() - fZ;
4f1c04d3 1032 Double_t tiltdz = dz;
1033 if (TMath::Abs(tiltdz)>padlength/2.) {
1034 tiltdz = TMath::Sign(padlength/2,dz);
1035 }
1036 // dy=dy+h01*dz;
1037 dy=dy+h01*tiltdz;
a819a5f7 1038
b8dc2353 1039 chi2 = (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
1040 }
1041 return chi2;
8206377c 1042}
46d29e70 1043
7ad19338 1044
46d29e70 1045//_________________________________________________________________________
1046void AliTRDtrack::GetPxPyPz(Double_t& px, Double_t& py, Double_t& pz) const
1047{
1048 // Returns reconstructed track momentum in the global system.
1049
1050 Double_t pt=TMath::Abs(GetPt()); // GeV/c
1051 Double_t r=fC*fX-fE;
5443e65e 1052
1053 Double_t y0;
1054 if(r > 1) { py = pt; px = 0; }
1055 else if(r < -1) { py = -pt; px = 0; }
1056 else {
1057 y0=fY + sqrt(1.- r*r)/fC;
1058 px=-pt*(fY-y0)*fC; //cos(phi);
1059 py=-pt*(fE-fX*fC); //sin(phi);
1060 }
46d29e70 1061 pz=pt*fT;
1062 Double_t tmp=px*TMath::Cos(fAlpha) - py*TMath::Sin(fAlpha);
1063 py=px*TMath::Sin(fAlpha) + py*TMath::Cos(fAlpha);
1064 px=tmp;
1065
1066}
1067
5443e65e 1068//_________________________________________________________________________
1069void AliTRDtrack::GetGlobalXYZ(Double_t& x, Double_t& y, Double_t& z) const
46d29e70 1070{
5443e65e 1071 // Returns reconstructed track coordinates in the global system.
1072
1073 x = fX; y = fY; z = fZ;
1074 Double_t tmp=x*TMath::Cos(fAlpha) - y*TMath::Sin(fAlpha);
1075 y=x*TMath::Sin(fAlpha) + y*TMath::Cos(fAlpha);
1076 x=tmp;
1077
1078}
3ab6f951 1079
5443e65e 1080//_________________________________________________________________________
1081void AliTRDtrack::ResetCovariance() {
1082 //
1083 // Resets covariance matrix
1084 //
46d29e70 1085
5443e65e 1086 fCyy*=10.;
b8dc2353 1087 fCzy=0.; fCzz*=10.;
1088 fCey=0.; fCez=0.; fCee*=10.;
1089 fCty=0.; fCtz=0.; fCte=0.; fCtt*=10.;
1090 fCcy=0.; fCcz=0.; fCce=0.; fCct=0.; fCcc*=10.;
5443e65e 1091}
b8dc2353 1092
46e2d86c 1093void AliTRDtrack::ResetCovariance(Float_t mult) {
1094 //
1095 // Resets covariance matrix
1096 //
1097
1098 fCyy*=mult;
4f1c04d3 1099 fCzy*=0.; fCzz*=1.;
3c625a9b 1100 fCey*=0.; fCez*=0.; fCee*=mult;
4f1c04d3 1101 fCty*=0.; fCtz*=0.; fCte*=0.; fCtt*=1.;
3c625a9b 1102 fCcy*=0.; fCcz*=0.; fCce*=0.; fCct*=0.; fCcc*=mult;
46e2d86c 1103}
16d9fbba 1104
7ad19338 1105
1106
1107
1108
16d9fbba 1109void AliTRDtrack::MakeBackupTrack()
1110{
1111 //
1112 //
1113 if (fBackupTrack) delete fBackupTrack;
1114 fBackupTrack = new AliTRDtrack(*this);
4f1c04d3 1115
1116}
1117
7ad19338 1118Int_t AliTRDtrack::GetProlongation(Double_t xk, Double_t &y, Double_t &z){
4f1c04d3 1119 //
1120 // Find prolongation at given x
1121 // return 0 if not exist
1122
1123 Double_t c1=fC*fX - fE;
c84a5e9e 1124 if (TMath::Abs(c1)>1.) return 0;
4f1c04d3 1125 Double_t r1=TMath::Sqrt(1.- c1*c1);
1126 Double_t c2=fC*xk - fE;
c84a5e9e 1127 if (TMath::Abs(c2)>1.) return 0;
4f1c04d3 1128 Double_t r2=TMath::Sqrt(1.- c2*c2);
1129 y =fY + (xk-fX)*(c1+c2)/(r1+r2);
1130 z =fZ + (xk-fX)*(c1+c2)/(c1*r2 + c2*r1)*fT;
1131
1132 return 1;
1133
16d9fbba 1134}