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