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