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