]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDtrackV1.cxx
Include informations from rstate module
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackV1.cxx
CommitLineData
d9950a5a 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
eb38ed55 18#include "AliESDtrack.h"
41880fac 19#include "AliTracker.h"
eb38ed55 20
d9950a5a 21#include "AliTRDtrackV1.h"
22#include "AliTRDcluster.h"
23#include "AliTRDcalibDB.h"
3afdab72 24#include "AliTRDReconstructor.h"
d9950a5a 25#include "AliTRDrecoParam.h"
26
d9950a5a 27ClassImp(AliTRDtrackV1)
28
0906e73e 29///////////////////////////////////////////////////////////////////////////////
30// //
31// Represents a reconstructed TRD track //
32// Local TRD Kalman track //
33// //
34// Authors: //
35// Alex Bercuci <A.Bercuci@gsi.de> //
36// Markus Fasel <M.Fasel@gsi.de> //
37// //
38///////////////////////////////////////////////////////////////////////////////
d9950a5a 39
40//_______________________________________________________________
3b57a3f7 41AliTRDtrackV1::AliTRDtrackV1() : AliKalmanTrack()
42 ,fPIDquality(0)
43 ,fDE(0.)
44 ,fBackupTrack(0x0)
0906e73e 45{
d9950a5a 46 //
47 // Default constructor
48 //
6e49cfdb 49 //printf("AliTRDtrackV1::AliTRDtrackV1()\n");
e44586fb 50
3b57a3f7 51 for(int i =0; i<3; i++) fBudget[i] = 0.;
52
53 Float_t pid = 1./AliPID::kSPECIES;
54 for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
55
56 for(int ip=0; ip<kNplane; ip++){
57 fTrackletIndex[ip] = 0xffff;
58 fTracklet[ip] = 0x0;
59 }
d9950a5a 60}
61
62//_______________________________________________________________
3b57a3f7 63AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &ref) : AliKalmanTrack(ref)
64 ,fPIDquality(ref.fPIDquality)
65 ,fDE(ref.fDE)
66 ,fBackupTrack(0x0)
d9950a5a 67{
68 //
3b57a3f7 69 // Copy constructor
d9950a5a 70 //
71
6e49cfdb 72 //printf("AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &)\n");
29b87567 73 SetBit(kOwner, kFALSE);
3b57a3f7 74 for(int ip=0; ip<kNplane; ip++){
75 fTrackletIndex[ip] = ref.fTrackletIndex[ip];
76 fTracklet[ip] = ref.fTracklet[ip];
77 }
78
79 for (Int_t i = 0; i < 3;i++) fBudget[i] = ref.fBudget[i];
80
81 for(Int_t is = 0; is<AliPID::kSPECIES; is++) fPID[is] = ref.fPID[is];
82
83 AliKalmanTrack::SetNumberOfClusters(ref.GetNumberOfClusters());
d9950a5a 84}
85
86//_______________________________________________________________
3b57a3f7 87AliTRDtrackV1::AliTRDtrackV1(const AliESDtrack &t) : AliKalmanTrack()
88 ,fPIDquality(0)
89 ,fDE(0.)
90 ,fBackupTrack(0x0)
d9950a5a 91{
92 //
3b57a3f7 93 // Constructor from AliESDtrack
d9950a5a 94 //
95
3b57a3f7 96 SetLabel(t.GetLabel());
97 SetChi2(0.0);
98 SetMass(t.GetMass());
99 AliKalmanTrack::SetNumberOfClusters(t.GetTRDncls());
100 Int_t ti[kNplane]; t.GetTRDtracklets(&ti[0]);
101 for(int ip=0; ip<kNplane; ip++){
102 fTrackletIndex[ip] = ti[ip] < 0 ? 0xffff : ti[ip];
103 fTracklet[ip] = 0x0;
104 }
105 for(int i =0; i<3; i++) fBudget[i] = 0.;
106
107 Float_t pid = 1./AliPID::kSPECIES;
108 for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
109
110 const AliExternalTrackParam *par = &t;
111 if (t.GetStatus() & AliESDtrack::kTRDbackup) {
112 par = t.GetOuterParam();
113 if (!par) {
114 AliError("No backup info!");
115 par = &t;
116 }
117 }
118 Set(par->GetX()
119 ,par->GetAlpha()
120 ,par->GetParameter()
121 ,par->GetCovariance());
122
123 if(t.GetStatus() & AliESDtrack::kTIME) {
124 StartTimeIntegral();
125 Double_t times[10];
126 t.GetIntegratedTimes(times);
127 SetIntegratedTimes(times);
128 SetIntegratedLength(t.GetIntegratedLength());
129 }
d9950a5a 130}
131
d9950a5a 132//_______________________________________________________________
eb38ed55 133AliTRDtrackV1::AliTRDtrackV1(AliTRDseedV1 *trklts, const Double_t p[5], const Double_t cov[15]
3b57a3f7 134 , Double_t x, Double_t alpha) : AliKalmanTrack()
135 ,fPIDquality(0)
136 ,fDE(0.)
137 ,fBackupTrack(0x0)
d9950a5a 138{
0906e73e 139 //
140 // The stand alone tracking constructor
141 // TEMPORARY !!!!!!!!!!!
142 // to check :
143 // 1. covariance matrix
144 // 2. dQdl calculation
145 //
d9950a5a 146
fb17de1f 147 Double_t cnv = GetBz() < 1.e-5 ? 1.e5 : 1.0 / (GetBz() * kB2C);
148 // Double_t cnv = 1.0 / (GetBz() * kB2C);
d9950a5a 149
150 Double_t pp[5] = { p[0]
151 , p[1]
93f695a3 152 , p[2]
d9950a5a 153 , p[3]
154 , p[4]*cnv };
155
156 Double_t c22 = x*x*cov[14] - 2*x*cov[12] + cov[ 5];
157 Double_t c32 = x*cov[13] - cov[ 8];
158 Double_t c20 = x*cov[10] - cov[ 3];
159 Double_t c21 = x*cov[11] - cov[ 4];
160 Double_t c42 = x*cov[14] - cov[12];
161
162 Double_t cc[15] = { cov[ 0]
163 , cov[ 1], cov[ 2]
164 , c20, c21, c22
165 , cov[ 6], cov[ 7], c32, cov[ 9]
166 , cov[10]*cnv, cov[11]*cnv, c42*cnv, cov[13]*cnv, cov[14]*cnv*cnv };
ae3fbe1f 167
168 Double_t mostProbablePt=AliExternalTrackParam::GetMostProbablePt();
169 Double_t p0=TMath::Sign(1/mostProbablePt,pp[4]);
170 Double_t w0=cc[14]/(cc[14] + p0*p0), w1=p0*p0/(cc[14] + p0*p0);
171 pp[4] = w0*p0 + w1*pp[4];
172 cc[10]*=w1; cc[11]*=w1; cc[12]*=w1; cc[13]*=w1; cc[14]*=w1;
173
d9950a5a 174 Set(x,alpha,pp,cc);
41702fec 175 Int_t ncls = 0;
3b57a3f7 176 for(int iplane=0; iplane<kNplane; iplane++){
41702fec 177 fTrackletIndex[iplane] = 0xffff;
178 if(!trklts[iplane].IsOK()) fTracklet[iplane] = 0x0;
179 else{
76b60503 180 fTracklet[iplane] = &trklts[iplane];
41702fec 181 ncls += fTracklet[iplane]->GetN();
182 }
d9950a5a 183 }
41702fec 184 AliKalmanTrack::SetNumberOfClusters(ncls);
185 for(int i =0; i<3; i++) fBudget[i] = 0.;
186
187 Float_t pid = 1./AliPID::kSPECIES;
188 for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
189
d9950a5a 190}
191
bb56afff 192//_______________________________________________________________
3b57a3f7 193AliTRDtrackV1::~AliTRDtrackV1()
bb56afff 194{
e44586fb 195 //AliInfo("");
6e49cfdb 196 //printf("I-AliTRDtrackV1::~AliTRDtrackV1() : Owner[%s]\n", TestBit(kOwner)?"YES":"NO");
76b60503 197
198 if(fBackupTrack) delete fBackupTrack;
3b57a3f7 199 fBackupTrack = 0x0;
bb56afff 200
76b60503 201 for(Int_t ip=0; ip<kNplane; ip++){
202 if(TestBit(kOwner) && fTracklet[ip]) delete fTracklet[ip];
203 fTracklet[ip] = 0x0;
204 fTrackletIndex[ip] = 0xffff;
3b57a3f7 205 }
206}
207
208//_______________________________________________________________
209Bool_t AliTRDtrackV1::CookLabel(Float_t wrong)
210{
211 // set MC label for this track
212
bb56afff 213 Int_t s[kMAXCLUSTERSPERTRACK][2];
214 for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
215 s[i][0] = -1;
216 s[i][1] = 0;
217 }
3b57a3f7 218
bb56afff 219 Bool_t labelAdded;
3b57a3f7 220 Int_t label;
221 AliTRDcluster *c = 0x0;
222 for (Int_t ip = 0; ip < kNplane; ip++) {
223 if(fTrackletIndex[ip] == 0xffff) continue;
224 for (Int_t ic = 0; ic < AliTRDseed::knTimebins; ic++) {
225 if(!(c = fTracklet[ip]->GetClusters(ic))) continue;
226 for (Int_t k = 0; k < 3; k++) {
227 label = c->GetLabel(k);
228 labelAdded = kFALSE;
229 Int_t j = 0;
230 if (label >= 0) {
231 while ((!labelAdded) && (j < kMAXCLUSTERSPERTRACK)) {
232 if ((s[j][0] == label) ||
233 (s[j][1] == 0)) {
234 s[j][0] = label;
235 s[j][1]++;
236 labelAdded = kTRUE;
237 }
238 j++;
239 }
240 }
241 }
242 }
243 }
244
bb56afff 245 Int_t max = 0;
246 label = -123456789;
247 for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
248 if (s[i][1] <= max) continue;
3b57a3f7 249 max = s[i][1];
250 label = s[i][0];
bb56afff 251 }
3b57a3f7 252
bb56afff 253 if ((1. - Float_t(max)/GetNumberOfClusters()) > wrong) label = -label;
3b57a3f7 254
bb56afff 255 SetLabel(label);
3b57a3f7 256
257 return kTRUE;
bb56afff 258}
259
d9950a5a 260//_______________________________________________________________
261Bool_t AliTRDtrackV1::CookPID()
262{
0906e73e 263 //
264 // Cook the PID information
265 //
3b57a3f7 266
267 // Reset the a priori probabilities
268 Double_t pid = 1. / AliPID::kSPECIES;
0906e73e 269 for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) {
3b57a3f7 270 fPID[ispec] = pid;
271 }
272 fPIDquality = 0;
273
274 // steer PID calculation @ tracklet level
275 Double_t *prob = 0x0;
276 for(int ip=0; ip<kNplane; ip++){
277 if(fTrackletIndex[ip] == 0xffff) continue;
278 if(!fTracklet[ip]->IsOK()) continue;
279 if(!(prob = fTracklet[ip]->GetProbability())) return kFALSE;
280
281 Int_t nspec = 0; // quality check of tracklet dEdx
282 for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){
283 if(prob[ispec] < 0.) continue;
284 fPID[ispec] *= prob[ispec];
285 nspec++;
286 }
287 if(!nspec) continue;
288
289 fPIDquality++;
0906e73e 290 }
0906e73e 291
292 // no tracklet found for PID calculations
293 if(!fPIDquality) return kTRUE;
3b57a3f7 294
295 // slot for PID calculation @ track level
296
297
0906e73e 298 // normalize probabilities
299 Double_t probTotal = 0.0;
300 for (Int_t is = 0; is < AliPID::kSPECIES; is++) probTotal += fPID[is];
3b57a3f7 301
302
0906e73e 303 if (probTotal <= 0.0) {
304 AliWarning("The total probability over all species <= 0. This may be caused by some error in the reference data.");
d9950a5a 305 return kFALSE;
306 }
3b57a3f7 307
0906e73e 308 for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) fPID[iSpecies] /= probTotal;
3b57a3f7 309
0906e73e 310 return kTRUE;
d9950a5a 311}
312
3b57a3f7 313//_____________________________________________________________________________
314Double_t AliTRDtrackV1::GetBz() const
0906e73e 315{
316 //
3b57a3f7 317 // Returns Bz component of the magnetic field (kG)
0906e73e 318 //
319
3b57a3f7 320 if (AliTracker::UniformField()) return AliTracker::GetBz();
321
322 Double_t r[3];
323 GetXYZ(r);
324 return AliTracker::GetBz(r);
325}
326
0349cc67 327//_______________________________________________________________
328AliTRDcluster* AliTRDtrackV1::GetCluster(Int_t id)
329{
330 Int_t n = 0;
331 for(Int_t ip=0; ip<kNplane; ip++){
332 if(!fTracklet[ip]) continue;
333 if(n+fTracklet[ip]->GetN() <= id){
334 n+=fTracklet[ip]->GetN();
335 continue;
336 }
337 AliTRDcluster *c = 0x0;
338 for(Int_t ic=AliTRDseed::knTimebins-1; ic>=0; ic--){
339 if(!(c = fTracklet[ip]->GetClusters(ic))) continue;
340
341 if(n<id){n++; continue;}
342 return c;
343 }
344 }
345 return 0x0;
346}
347
3b57a3f7 348//_______________________________________________________________
349Int_t AliTRDtrackV1::GetClusterIndex(Int_t id) const
350{
351 Int_t n = 0;
352 for(Int_t ip=0; ip<kNplane; ip++){
353 if(!fTracklet[ip]) continue;
76b60503 354 if(n+fTracklet[ip]->GetN() <= id){
3b57a3f7 355 n+=fTracklet[ip]->GetN();
356 continue;
357 }
76b60503 358 AliTRDcluster *c = 0x0;
359 for(Int_t ic=AliTRDseed::knTimebins-1; ic>=0; ic--){
360 if(!(c = fTracklet[ip]->GetClusters(ic))) continue;
361
362 if(n<id){n++; continue;}
3b57a3f7 363 return fTracklet[ip]->GetIndexes(ic);
364 }
365 }
366 return -1;
0906e73e 367}
d9950a5a 368
369//_______________________________________________________________
370Double_t AliTRDtrackV1::GetPredictedChi2(const AliTRDseedV1 *trklt) const
371{
372 //
0906e73e 373 // Get the predicted chi2
d9950a5a 374 //
3b57a3f7 375
d9950a5a 376 Double_t x = trklt->GetX0();
377 Double_t p[2] = { trklt->GetYat(x)
378 , trklt->GetZat(x) };
379 Double_t cov[3];
3b57a3f7 380 trklt->GetCovAt(x, cov);
381
d9950a5a 382 return AliExternalTrackParam::GetPredictedChi2(p, cov);
3b57a3f7 383}
d9950a5a 384
22a4ab0c 385//_______________________________________________________________
386Bool_t AliTRDtrackV1::IsElectron() const
387{
388/* reco = fReconstructor->GetRecoParam();
389 if(GetPID(0) > reco->GetPIDThreshold(GetP())) return kTRUE;*/
390 return kFALSE;
391}
392
3b57a3f7 393
394//_____________________________________________________________________________
395void AliTRDtrackV1::MakeBackupTrack()
396{
397 //
398 // Creates a backup track
399 //
400
401 if(fBackupTrack) {
402 fBackupTrack->~AliTRDtrackV1();
403 new(fBackupTrack) AliTRDtrackV1((AliTRDtrackV1&)(*this));
592fdd48 404 return;
3b57a3f7 405 }
406 fBackupTrack = new AliTRDtrackV1((AliTRDtrackV1&)(*this));
d9950a5a 407}
408
3b57a3f7 409//_____________________________________________________________________________
410Int_t AliTRDtrackV1::GetProlongation(Double_t xk, Double_t &y, Double_t &z)
411{
412 //
413 // Find a prolongation at given x
414 // Return 0 if it does not exist
415 //
416
417 Double_t bz = GetBz();
418 if (!AliExternalTrackParam::GetYAt(xk,bz,y)) return 0;
419 if (!AliExternalTrackParam::GetZAt(xk,bz,z)) return 0;
420
421 return 1;
422
423}
424
425//_____________________________________________________________________________
426Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho)
0906e73e 427{
428 //
3b57a3f7 429 // Propagates this track to a reference plane defined by "xk" [cm]
430 // correcting for the mean crossed material.
0906e73e 431 //
3b57a3f7 432 // "xx0" - thickness/rad.length [units of the radiation length]
433 // "xrho" - thickness*density [g/cm^2]
434 //
0906e73e 435
3b57a3f7 436 if (xk == GetX()) {
437 return kTRUE;
438 }
439
440 Double_t oldX = GetX();
441 Double_t oldY = GetY();
442 Double_t oldZ = GetZ();
443
444 Double_t bz = GetBz();
445
446 if (!AliExternalTrackParam::PropagateTo(xk,bz)) {
447 return kFALSE;
448 }
449
450 Double_t x = GetX();
451 Double_t y = GetY();
452 Double_t z = GetZ();
453
454 if (oldX < xk) {
455 xrho = -xrho;
456 if (IsStartedTimeIntegral()) {
457 Double_t l2 = TMath::Sqrt((x-oldX)*(x-oldX)
458 + (y-oldY)*(y-oldY)
459 + (z-oldZ)*(z-oldZ));
460 Double_t crv = AliExternalTrackParam::GetC(bz);
461 if (TMath::Abs(l2*crv) > 0.0001) {
462 // Make correction for curvature if neccesary
463 l2 = 0.5 * TMath::Sqrt((x-oldX)*(x-oldX)
464 + (y-oldY)*(y-oldY));
465 l2 = 2.0 * TMath::ASin(l2 * crv) / crv;
466 l2 = TMath::Sqrt(l2*l2 + (z-oldZ)*(z-oldZ));
467 }
468 AddTimeStep(l2);
469 }
470 }
471
472 if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0,xrho,GetMass())) {
473 return kFALSE;
474 }
475
476 {
477
478 // Energy losses
479 Double_t p2 = (1.0 + GetTgl()*GetTgl()) / (GetSigned1Pt()*GetSigned1Pt());
480 Double_t beta2 = p2 / (p2 + GetMass()*GetMass());
481 if ((beta2 < 1.0e-10) ||
482 ((5940.0 * beta2/(1.0 - beta2 + 1.0e-10) - beta2) < 0.0)) {
483 return kFALSE;
484 }
485
486 Double_t dE = 0.153e-3 / beta2
487 * (TMath::Log(5940.0 * beta2/(1.0 - beta2 + 1.0e-10)) - beta2)
488 * xrho;
489 fBudget[0] += xrho;
490
491 /*
492 // Suspicious part - think about it ?
493 Double_t kinE = TMath::Sqrt(p2);
494 if (dE > 0.8*kinE) dE = 0.8 * kinE; //
495 if (dE < 0) dE = 0.0; // Not valid region for Bethe bloch
496 */
497
498 fDE += dE;
499
500 /*
501 // Suspicious ! I.B.
502 Double_t sigmade = 0.07 * TMath::Sqrt(TMath::Abs(dE)); // Energy loss fluctuation
503 Double_t sigmac2 = sigmade*sigmade*fC*fC*(p2+GetMass()*GetMass())/(p2*p2);
504 fCcc += sigmac2;
505 fCee += fX*fX * sigmac2;
506 */
507
508 }
509
510 return kTRUE;
0906e73e 511}
3b57a3f7 512
87a7fa94 513//_____________________________________________________________________________
3b57a3f7 514Int_t AliTRDtrackV1::PropagateToR(Double_t r,Double_t step)
87a7fa94 515{
516 //
3b57a3f7 517 // Propagate track to the radial position
518 // Rotation always connected to the last track position
87a7fa94 519 //
520
3b57a3f7 521 Double_t xyz0[3];
522 Double_t xyz1[3];
523 Double_t y;
524 Double_t z;
525
526 Double_t radius = TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
527 // Direction +-
528 Double_t dir = (radius > r) ? -1.0 : 1.0;
529
530 for (Double_t x = radius+dir*step; dir*x < dir*r; x += dir*step) {
531
532 GetXYZ(xyz0);
533 Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]);
534 Rotate(alpha,kTRUE);
535 GetXYZ(xyz0);
536 GetProlongation(x,y,z);
537 xyz1[0] = x * TMath::Cos(alpha) + y * TMath::Sin(alpha);
538 xyz1[1] = x * TMath::Sin(alpha) - y * TMath::Cos(alpha);
539 xyz1[2] = z;
540 Double_t param[7];
541 AliTracker::MeanMaterialBudget(xyz0,xyz1,param);
542 if (param[1] <= 0) {
543 param[1] = 100000000;
544 }
545 PropagateTo(x,param[1],param[0]*param[4]);
546
547 }
548
549 GetXYZ(xyz0);
550 Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]);
551 Rotate(alpha,kTRUE);
552 GetXYZ(xyz0);
553 GetProlongation(r,y,z);
554 xyz1[0] = r * TMath::Cos(alpha) + y * TMath::Sin(alpha);
555 xyz1[1] = r * TMath::Sin(alpha) - y * TMath::Cos(alpha);
556 xyz1[2] = z;
557 Double_t param[7];
558 AliTracker::MeanMaterialBudget(xyz0,xyz1,param);
559
560 if (param[1] <= 0) {
561 param[1] = 100000000;
87a7fa94 562 }
3b57a3f7 563 PropagateTo(r,param[1],param[0]*param[4]);
564
565 return 0;
566
87a7fa94 567}
568
3b57a3f7 569//_____________________________________________________________________________
570Bool_t AliTRDtrackV1::Rotate(Double_t alpha, Bool_t absolute)
571{
572 //
573 // Rotates track parameters in R*phi plane
574 // if absolute rotation alpha is in global system
575 // otherwise alpha rotation is relative to the current rotation angle
576 //
577
578 if (absolute) alpha -= GetAlpha();
579 //else fNRotate++;
580
581 return AliExternalTrackParam::Rotate(GetAlpha()+alpha);
582}
87a7fa94 583
eb38ed55 584//___________________________________________________________
585void AliTRDtrackV1::SetNumberOfClusters()
586{
587// Calculate the number of clusters attached to this track
588
3b57a3f7 589 Int_t ncls = 0;
590 for(int ip=0; ip<kNplane; ip++){
591 if(fTracklet[ip] && fTrackletIndex[ip] != 0xffff) ncls += fTracklet[ip]->GetN();
592 }
593 AliKalmanTrack::SetNumberOfClusters(ncls);
eb38ed55 594}
595
596
0906e73e 597//_______________________________________________________________
3b57a3f7 598void AliTRDtrackV1::SetOwner()
0906e73e 599{
600 //
601 // Toggle ownership of tracklets
602 //
603
e44586fb 604 if(TestBit(kOwner)) return;
3b57a3f7 605 for (Int_t ip = 0; ip < kNplane; ip++) {
606 if(fTrackletIndex[ip] == 0xffff) continue;
607 fTracklet[ip] = new AliTRDseedV1(*fTracklet[ip]);
608 fTracklet[ip]->SetOwner();
609 }
e44586fb 610 SetBit(kOwner);
0906e73e 611}
612
d9950a5a 613//_______________________________________________________________
3b57a3f7 614void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *trklt, Int_t index)
d9950a5a 615{
616 //
0906e73e 617 // Set the tracklets
d9950a5a 618 //
3b57a3f7 619 Int_t plane = trklt->GetPlane();
76b60503 620
3b57a3f7 621 fTracklet[plane] = trklt;
622 fTrackletIndex[plane] = index;
d9950a5a 623}
624
181d2c97 625//_______________________________________________________________
626void AliTRDtrackV1::UnsetTracklet(Int_t plane)
627{
628 if(plane<0 && plane >= kNplane) return;
629 fTrackletIndex[plane] = 0xffff;
630 fTracklet[plane] = 0x0;
631}
632
633
d9950a5a 634//_______________________________________________________________
0906e73e 635Bool_t AliTRDtrackV1::Update(AliTRDseedV1 *trklt, Double_t chisq)
d9950a5a 636{
637 //
3b57a3f7 638 // Update track and tracklet parameters
d9950a5a 639 //
3b57a3f7 640
0906e73e 641 Double_t x = trklt->GetX0();
d9950a5a 642 Double_t p[2] = { trklt->GetYat(x)
643 , trklt->GetZat(x) };
644 Double_t cov[3];
3b57a3f7 645 trklt->GetCovAt(x, cov);
646
d9950a5a 647 if(!AliExternalTrackParam::Update(p, cov)) return kFALSE;
3b57a3f7 648
649 AliTRDcluster *c = 0x0;
650 Int_t ic = 0; while(!(c = trklt->GetClusters(ic))) ic++;
651 AliTracker::FillResiduals(this, p, cov, c->GetVolumeId());
652
653
d9950a5a 654 // Register info to track
3b57a3f7 655 SetNumberOfClusters();
d9950a5a 656 SetChi2(GetChi2() + chisq);
3b57a3f7 657
658 // update tracklet
659 trklt->SetMomentum(GetP());
660 trklt->SetSnp(GetSnp());
661 trklt->SetTgl(GetTgl());
662 return kTRUE;
d9950a5a 663}
664
665//_______________________________________________________________
0906e73e 666void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track)
d9950a5a 667{
668 //
6984f7c1 669 // Update the TRD PID information in the ESD track
d9950a5a 670 //
6984f7c1 671
672 track->SetNumberOfTRDslices(kNslice);
3b57a3f7 673
6984f7c1 674 for (Int_t ip = 0; ip < kNplane; ip++) {
3b57a3f7 675 if(fTrackletIndex[ip] == 0xffff) continue;
2b436dfa 676 if(!fTracklet[ip]->IsOK()) continue;
3b57a3f7 677 fTracklet[ip]->CookdEdx(kNslice);
678 Float_t *dedx = fTracklet[ip]->GetdEdx();
679 for (Int_t js = 0; js < kNslice; js++) track->SetTRDslice(dedx[js], ip, js);
6984f7c1 680 }
0906e73e 681
6984f7c1 682 // copy PID to ESD
c04438f1 683 if(!fPIDquality) return;
6984f7c1 684 track->SetTRDpid(fPID);
685 track->SetTRDpidQuality(fPIDquality);
d9950a5a 686}