1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 #include "AliESDtrack.h"
20 #include "AliTracker.h"
22 #include "AliTRDtrackV1.h"
23 #include "AliTRDcluster.h"
24 #include "AliTRDcalibDB.h"
25 #include "AliTRDReconstructor.h"
26 #include "AliTRDrecoParam.h"
28 ClassImp(AliTRDtrackV1)
30 ///////////////////////////////////////////////////////////////////////////////
32 // Represents a reconstructed TRD track //
33 // Local TRD Kalman track //
36 // Alex Bercuci <A.Bercuci@gsi.de> //
37 // Markus Fasel <M.Fasel@gsi.de> //
39 ///////////////////////////////////////////////////////////////////////////////
41 //_______________________________________________________________
42 AliTRDtrackV1::AliTRDtrackV1() : AliKalmanTrack()
46 ,fkReconstructor(NULL)
52 // Default constructor
54 //printf("AliTRDtrackV1::AliTRDtrackV1()\n");
56 for(int i =0; i<3; i++) fBudget[i] = 0.;
58 Float_t pid = 1./AliPID::kSPECIES;
59 for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
61 for(int ip=0; ip<kNplane; ip++){
62 fTrackletIndex[ip] = -1;
67 //_______________________________________________________________
68 AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &ref) : AliKalmanTrack(ref)
72 ,fkReconstructor(ref.fkReconstructor)
81 //printf("AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &)\n");
82 SetBit(kOwner, kFALSE);
83 for(int ip=0; ip<kNplane; ip++){
84 fTrackletIndex[ip] = ref.fTrackletIndex[ip];
85 fTracklet[ip] = ref.fTracklet[ip];
87 if(ref.fTrackLow) fTrackLow = new AliExternalTrackParam(*ref.fTrackLow);
88 if(ref.fTrackHigh) fTrackHigh = new AliExternalTrackParam(*ref.fTrackHigh);
90 for (Int_t i = 0; i < 3;i++) fBudget[i] = ref.fBudget[i];
92 for(Int_t is = 0; is<AliPID::kSPECIES; is++) fPID[is] = ref.fPID[is];
94 AliKalmanTrack::SetNumberOfClusters(ref.GetNumberOfClusters());
97 //_______________________________________________________________
98 AliTRDtrackV1::AliTRDtrackV1(const AliESDtrack &t) : AliKalmanTrack()
102 ,fkReconstructor(NULL)
108 // Constructor from AliESDtrack
112 SetLabel(t.GetLabel());
115 SetMass(t.GetMass()/*0.000510*/);
116 AliKalmanTrack::SetNumberOfClusters(t.GetTRDncls());
117 Int_t ti[]={-1, -1, -1, -1, -1, -1}; t.GetTRDtracklets(&ti[0]);
118 for(int ip=0; ip<kNplane; ip++){
119 fTrackletIndex[ip] = ti[ip];
120 fTracklet[ip] = NULL;
122 for(int i =0; i<3; i++) fBudget[i] = 0.;
124 Float_t pid = 1./AliPID::kSPECIES;
125 for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
127 const AliExternalTrackParam *par = &t;
128 if (t.GetStatus() & AliESDtrack::kTRDbackup) {
129 par = t.GetOuterParam();
131 AliError("No backup info!");
138 ,par->GetCovariance());
140 if(t.GetStatus() & AliESDtrack::kTIME) {
143 t.GetIntegratedTimes(times);
144 SetIntegratedTimes(times);
145 SetIntegratedLength(t.GetIntegratedLength());
149 //_______________________________________________________________
150 AliTRDtrackV1::AliTRDtrackV1(AliTRDseedV1 * const trklts, const Double_t p[5], const Double_t cov[15]
151 , Double_t x, Double_t alpha) : AliKalmanTrack()
155 ,fkReconstructor(NULL)
161 // The stand alone tracking constructor
162 // TEMPORARY !!!!!!!!!!!
164 // 1. covariance matrix
165 // 2. dQdl calculation
168 Double_t cnv = GetBz() < 1.e-5 ? 1.e5 : 1.0 / (GetBz() * kB2C);
169 // Double_t cnv = 1.0 / (GetBz() * kB2C);
171 Double_t pp[5] = { p[0]
177 Double_t c22 = x*x*cov[14] - 2*x*cov[12] + cov[ 5];
178 Double_t c32 = x*cov[13] - cov[ 8];
179 Double_t c20 = x*cov[10] - cov[ 3];
180 Double_t c21 = x*cov[11] - cov[ 4];
181 Double_t c42 = x*cov[14] - cov[12];
183 Double_t cc[15] = { cov[ 0]
186 , cov[ 6], cov[ 7], c32, cov[ 9]
187 , cov[10]*cnv, cov[11]*cnv, c42*cnv, cov[13]*cnv, cov[14]*cnv*cnv };
189 Double_t mostProbablePt=AliExternalTrackParam::GetMostProbablePt();
190 Double_t p0=TMath::Sign(1/mostProbablePt,pp[4]);
191 Double_t w0=cc[14]/(cc[14] + p0*p0), w1=p0*p0/(cc[14] + p0*p0);
192 AliDebug(2, Form("Pt mixing : w0[%4.2f] pt0[%5.3f] w1[%4.2f] pt[%5.3f]", w0, 1./p0, w1, 1./pp[4]));
193 pp[4] = w0*p0 + w1*pp[4];
196 cc[10]*=w1; cc[11]*=w1; cc[12]*=w1; cc[13]*=w1; cc[14]*=w1;
199 AliDebug(2, Form("Init @ x[%6.2f] pt[%5.3f]", x, 1./pp[4]));
201 for(int iplane=0; iplane<kNplane; iplane++){
202 fTrackletIndex[iplane] = -1;
203 if(!trklts[iplane].IsOK()) fTracklet[iplane] = NULL;
205 fTracklet[iplane] = &trklts[iplane];
206 ncls += fTracklet[iplane]->GetN();
209 AliKalmanTrack::SetNumberOfClusters(ncls);
210 for(int i =0; i<3; i++) fBudget[i] = 0.;
212 Float_t pid = 1./AliPID::kSPECIES;
213 for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
217 //_______________________________________________________________
218 AliTRDtrackV1::~AliTRDtrackV1()
221 //printf("I-AliTRDtrackV1::~AliTRDtrackV1() : Owner[%s]\n", TestBit(kOwner)?"YES":"NO");
223 if(fBackupTrack) delete fBackupTrack; fBackupTrack = NULL;
225 if(fTrackLow) delete fTrackLow; fTrackLow = NULL;
226 if(fTrackHigh) delete fTrackHigh; fTrackHigh = NULL;
228 for(Int_t ip=0; ip<kNplane; ip++){
229 if(TestBit(kOwner) && fTracklet[ip]) delete fTracklet[ip];
230 fTracklet[ip] = NULL;
231 fTrackletIndex[ip] = -1;
235 //_______________________________________________________________
236 Bool_t AliTRDtrackV1::CookLabel(Float_t wrong)
238 // set MC label for this track
239 if(!GetNumberOfClusters()) return kFALSE;
241 Int_t s[kMAXCLUSTERSPERTRACK][2];
242 for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
249 AliTRDcluster *c = NULL;
250 for (Int_t ip = 0; ip < kNplane; ip++) {
251 if(fTrackletIndex[ip] == -1) continue;
252 for (Int_t ic = 0; ic < AliTRDseedV1::kNclusters; ic++) {
253 if(!(c = fTracklet[ip]->GetClusters(ic))) continue;
254 for (Int_t k = 0; k < 3; k++) {
255 label = c->GetLabel(k);
259 while ((!labelAdded) && (j < kMAXCLUSTERSPERTRACK)) {
260 if ((s[j][0] == label) ||
275 for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
276 if (s[i][1] <= max) continue;
280 if ((1. - Float_t(max)/GetNumberOfClusters()) > wrong) label = -label;
287 //_______________________________________________________________
288 Bool_t AliTRDtrackV1::CookPID()
291 // Cook the PID information for the track by delegating the omonim function of the tracklets.
292 // Computes the number of tracklets used. The tracklet information are considered independent.
293 // For the moment no global track measurement of PID is performed as for example to estimate
294 // bremsstrahlung probability based on global chi2 of the track.
296 // The status bit AliESDtrack::kTRDpid is set during the call of AliTRDtrackV1::UpdateESDtrack().The PID performance of the
297 //TRD for tracks with 6 tacklets is displayed below.
299 //<img src="TRD/trackPID.gif">
303 /*Reset the a priori probabilities*/
304 Double_t pid = 1. / AliPID::kSPECIES;
305 for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fPID[ispec] = pid;
307 UChar_t fPIDquality = SetNumberOfTrackletsPID(kTRUE);
308 // no tracklet found for PID calculations
309 if(!fPIDquality) return kFALSE;
311 // slot for PID calculation @ track level for bremsstrahlung TODO
313 // normalize probabilities
314 Double_t probTotal = 0.0;
315 for (Int_t is = 0; is < AliPID::kSPECIES; is++) probTotal += fPID[is];
318 if (probTotal <= 0.0) {
319 AliWarning("The total probability over all species <= 0. This may be caused by some error in the reference data.");
323 for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) fPID[iSpecies] /= probTotal;
328 //___________________________________________________________
329 UChar_t AliTRDtrackV1::GetNumberOfTrackletsPID() const
331 // Retrieve number of tracklets used for PID calculation.
334 Float_t *prob = NULL;
335 for(int ip=0; ip<kNplane; ip++){
336 if(fTrackletIndex[ip] == -1) continue;
337 if(!fTracklet[ip]->IsOK()) continue;
338 if(!(prob = fTracklet[ip]->GetProbability(kFALSE))) continue;
340 Int_t nspec = 0; // quality check of tracklet dEdx
341 for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){
342 if(prob[ispec] < 0.) continue;
347 fTracklet[ip]->SetPID();
353 //___________________________________________________________
354 UChar_t AliTRDtrackV1::SetNumberOfTrackletsPID(Bool_t recalc)
356 // Retrieve number of tracklets used for PID calculation. // Recalculated PID at tracklet level by quering the PID DB.
358 UChar_t fPIDquality = 0;
360 // steer PID calculation @ tracklet level
361 Float_t *prob = NULL;
362 for(int ip=0; ip<kNplane; ip++){
363 if(fTrackletIndex[ip] == -1) continue;
364 if(!fTracklet[ip]->IsOK()) continue;
365 if(!(prob = fTracklet[ip]->GetProbability(recalc))) return 0;
367 Int_t nspec = 0; // quality check of tracklet dEdx
368 for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){
369 if(prob[ispec] < 0.) continue;
370 fPID[ispec] *= prob[ispec];
380 //_______________________________________________________________
381 AliTRDcluster* AliTRDtrackV1::GetCluster(Int_t id)
383 // Get the cluster at a certain position in the track
385 for(Int_t ip=0; ip<kNplane; ip++){
386 if(!fTracklet[ip]) continue;
387 if(n+fTracklet[ip]->GetN() <= id){
388 n+=fTracklet[ip]->GetN();
391 AliTRDcluster *c = NULL;
392 for(Int_t ic=AliTRDseedV1::kNclusters; ic--;){
393 if(!(c = fTracklet[ip]->GetClusters(ic))) continue;
395 if(n<id){n++; continue;}
402 //_______________________________________________________________
403 Int_t AliTRDtrackV1::GetClusterIndex(Int_t id) const
405 // Get the cluster index at a certain position in the track
407 for(Int_t ip=0; ip<kNplane; ip++){
408 if(!fTracklet[ip]) continue;
409 if(n+fTracklet[ip]->GetN() <= id){
410 n+=fTracklet[ip]->GetN();
413 AliTRDcluster *c = NULL;
414 for(Int_t ic=AliTRDseedV1::kNclusters; ic--;){
415 if(!(c = fTracklet[ip]->GetClusters(ic))) continue;
417 if(n<id){n++; continue;}
418 return fTracklet[ip]->GetIndexes(ic);
424 //_______________________________________________________________
425 Double_t AliTRDtrackV1::GetPredictedChi2(const AliTRDseedV1 *trklt, Double_t *cov) const
427 // Compute chi2 between tracklet and track. The value is calculated at the radial position of the track
428 // equal to the reference radial position of the tracklet (see AliTRDseedV1)
430 // The chi2 estimator is computed according to the following formula
432 // #chi^{2}=(X_{trklt}-X_{track})(C_{trklt}+C_{track})^{-1}(X_{trklt}-X_{track})^{T}
434 // where X=(y z), the position of the track/tracklet in the yz plane
437 Double_t p[2] = { trklt->GetY(), trklt->GetZ()};
438 trklt->GetCovAt(trklt->GetX(), cov);
439 return AliExternalTrackParam::GetPredictedChi2(p, cov);
442 //_______________________________________________________________
443 Int_t AliTRDtrackV1::GetSector() const
445 return Int_t(GetAlpha()/AliTRDgeometry::GetAlpha() + (GetAlpha()>0. ? 0 : AliTRDgeometry::kNsector));
448 //_______________________________________________________________
449 Bool_t AliTRDtrackV1::IsEqual(const TObject *o) const
451 // Checks whether two tracks are equal
452 if (!o) return kFALSE;
453 const AliTRDtrackV1 *inTrack = dynamic_cast<const AliTRDtrackV1*>(o);
454 if (!inTrack) return kFALSE;
456 //if ( fPIDquality != inTrack->GetPIDquality() ) return kFALSE;
458 for(Int_t i = 0; i < AliPID::kSPECIES; i++){
459 if ( fPID[i] != inTrack->GetPID(i) ) return kFALSE;
462 for (Int_t i = 0; i < 3; i++){
463 if ( fBudget[i] != inTrack->GetBudget(i) ) return kFALSE;
465 if ( fDE != inTrack->GetEdep() ) return kFALSE;
466 if ( fFakeRatio != inTrack->GetFakeRatio() ) return kFALSE;
467 if ( fChi2 != inTrack->GetChi2() ) return kFALSE;
468 if ( fMass != inTrack->GetMass() ) return kFALSE;
469 if ( fLab != inTrack->GetLabel() ) return kFALSE;
470 if ( fN != inTrack->GetNumberOfClusters() ) return kFALSE;
471 if ( AliKalmanTrack::GetIntegratedLength() != inTrack->GetIntegratedLength() ) return kFALSE;
473 if ( GetX() != inTrack->GetX() ) return kFALSE;
474 if ( GetAlpha() != inTrack->GetAlpha() ) return kFALSE;
475 const Double_t *inP = inTrack->GetParameter();
476 const Double_t *curP = GetParameter();
477 for (Int_t i = 0; i < 5; i++){
478 if ( curP[i] != inP[i]) return kFALSE;
480 const Double_t *inC = inTrack->GetCovariance();
481 const Double_t *curC = GetCovariance();
482 for (Int_t i = 0; i < 15; i++){
483 if ( curC[i] != inC[i]) return kFALSE;
486 for (Int_t iTracklet = 0; iTracklet < kNplane; iTracklet++){
487 AliTRDseedV1 *curTracklet = fTracklet[iTracklet];
488 AliTRDseedV1 *inTracklet = inTrack->GetTracklet(iTracklet);
489 if (curTracklet && inTracklet){
490 if (! curTracklet->IsEqual(inTracklet) ) {
491 curTracklet->Print();
496 // if one tracklet exists, and corresponding
497 // in other track doesn't - return kFALSE
498 if(inTracklet || curTracklet) return kFALSE;
505 //_______________________________________________________________
506 Bool_t AliTRDtrackV1::IsElectron() const
508 if(GetPID(0) > fkReconstructor->GetRecoParam()->GetPIDThreshold(GetP())) return kTRUE;
513 //_____________________________________________________________________________
514 Int_t AliTRDtrackV1::MakeBackupTrack()
517 // Creates a backup track
518 // TO DO update quality check of the track.
521 Float_t occupancy(0.); Int_t n(0), ncls(0);
522 for(Int_t il(AliTRDgeometry::kNlayer); il--;){
523 if(!fTracklet[il]) continue;
525 occupancy+=fTracklet[il]->GetOccupancyTB();
526 ncls += fTracklet[il]->GetN();
531 //Float_t ratio1 = Float_t(t.GetNumberOfClusters()+1) / Float_t(t.GetNExpected()+1);
533 Int_t failedCutId(0);
534 if(GetChi2()/n > 5.0) failedCutId=1;
535 if(occupancy < 0.7) failedCutId=2;
536 //if(ratio1 > 0.6) &&
537 //if(ratio0+ratio1 > 1.5) &&
538 if(GetNCross() != 0) failedCutId=3;
539 if(TMath::Abs(GetSnp()) > 0.85) failedCutId=4;
540 if(ncls < 20) failedCutId=5;
543 AliDebug(2, Form("\n"
544 "chi2/tracklet < 5.0 [%c] %5.2f\n"
545 "occupancy > 0.7 [%c] %4.2f\n"
546 "NCross == 0 [%c] %d\n"
547 "Abs(snp) < 0.85 [%c] %4.2f\n"
548 "NClusters > 20 [%c] %d"
549 ,(GetChi2()/n<5.0)?'y':'n', GetChi2()/n
550 ,(occupancy>0.7)?'y':'n', occupancy
551 ,(GetNCross()==0)?'y':'n', GetNCross()
552 ,(TMath::Abs(GetSnp())<0.85)?'y':'n', TMath::Abs(GetSnp())
553 ,(ncls>20)?'y':'n', ncls
559 fBackupTrack->~AliTRDtrackV1();
560 new(fBackupTrack) AliTRDtrackV1((AliTRDtrackV1&)(*this));
563 fBackupTrack = new AliTRDtrackV1((AliTRDtrackV1&)(*this));
567 //_____________________________________________________________________________
568 Int_t AliTRDtrackV1::GetProlongation(Double_t xk, Double_t &y, Double_t &z)
571 // Find a prolongation at given x
572 // Return -1 if it does not exist
575 Double_t bz = GetBz();
576 if (!AliExternalTrackParam::GetYAt(xk,bz,y)) return -1;
577 if (!AliExternalTrackParam::GetZAt(xk,bz,z)) return -1;
583 //_____________________________________________________________________________
584 Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho)
587 // Propagates this track to a reference plane defined by "xk" [cm]
588 // correcting for the mean crossed material.
590 // "xx0" - thickness/rad.length [units of the radiation length]
591 // "xrho" - thickness*density [g/cm^2]
594 if (xk == GetX()) return kTRUE;
596 Double_t xyz0[3] = {GetX(), GetY(), GetZ()}, // track position BEFORE propagation
597 b[3]; // magnetic field
599 if(!AliExternalTrackParam::PropagateToBxByBz(xk,b)) return kFALSE;
601 // local track position AFTER propagation
602 Double_t xyz1[3] = {GetX(), GetY(), GetZ()};
605 if (IsStartedTimeIntegral()) {
606 Double_t l2 = TMath::Sqrt((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0])
607 + (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1])
608 + (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2]));
609 Double_t crv = AliExternalTrackParam::GetC(b[2]);
610 if (TMath::Abs(l2*crv) > 0.0001) {
611 // Make correction for curvature if neccesary
612 l2 = 0.5 * TMath::Sqrt((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0])
613 + (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1]));
614 l2 = 2.0 * TMath::ASin(l2 * crv) / crv;
615 l2 = TMath::Sqrt(l2*l2 + (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2]));
621 if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0, xrho, GetMass())) return kFALSE;
627 Double_t p2 = (1.0 + GetTgl()*GetTgl()) / (GetSigned1Pt()*GetSigned1Pt());
628 Double_t beta2 = p2 / (p2 + GetMass()*GetMass());
629 if ((beta2 < 1.0e-10) ||
630 ((5940.0 * beta2/(1.0 - beta2 + 1.0e-10) - beta2) < 0.0)) {
634 Double_t dE = 0.153e-3 / beta2
635 * (TMath::Log(5940.0 * beta2/(1.0 - beta2 + 1.0e-10)) - beta2)
640 // Suspicious part - think about it ?
641 Double_t kinE = TMath::Sqrt(p2);
642 if (dE > 0.8*kinE) dE = 0.8 * kinE; //
643 if (dE < 0) dE = 0.0; // Not valid region for Bethe bloch
650 Double_t sigmade = 0.07 * TMath::Sqrt(TMath::Abs(dE)); // Energy loss fluctuation
651 Double_t sigmac2 = sigmade*sigmade*fC*fC*(p2+GetMass()*GetMass())/(p2*p2);
653 fCee += fX*fX * sigmac2;
661 //_____________________________________________________________________________
662 Int_t AliTRDtrackV1::PropagateToR(Double_t r,Double_t step)
665 // Propagate track to the radial position
666 // Rotation always connected to the last track position
674 Double_t radius = TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
676 Double_t dir = (radius > r) ? -1.0 : 1.0;
678 for (Double_t x = radius+dir*step; dir*x < dir*r; x += dir*step) {
681 Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]);
684 if(GetProlongation(x,y,z)<0) return -1;
685 xyz1[0] = x * TMath::Cos(alpha) + y * TMath::Sin(alpha);
686 xyz1[1] = x * TMath::Sin(alpha) - y * TMath::Cos(alpha);
689 if(AliTracker::MeanMaterialBudget(xyz0,xyz1,param)<=0.) return -1;
691 param[1] = 100000000;
693 PropagateTo(x,param[1],param[0]*param[4]);
698 Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]);
701 if(GetProlongation(r,y,z)<0) return -1;
702 xyz1[0] = r * TMath::Cos(alpha) + y * TMath::Sin(alpha);
703 xyz1[1] = r * TMath::Sin(alpha) - y * TMath::Cos(alpha);
706 if(AliTracker::MeanMaterialBudget(xyz0,xyz1,param) <= 0.) return -1;
709 param[1] = 100000000;
711 PropagateTo(r,param[1],param[0]*param[4]);
717 //_____________________________________________________________________________
718 void AliTRDtrackV1::Print(Option_t *o) const
720 // Print track status
721 AliInfo(Form("PID [%4.1f %4.1f %4.1f %4.1f %4.1f]", 1.E2*fPID[0], 1.E2*fPID[1], 1.E2*fPID[2], 1.E2*fPID[3], 1.E2*fPID[4]));
722 AliInfo(Form("Material[%5.2f %5.2f %5.2f]", fBudget[0], fBudget[1], fBudget[2]));
724 AliInfo(Form("x[%7.2f] t[%7.4f] alpha[%f] mass[%f]", GetX(), GetIntegratedLength(), GetAlpha(), fMass));
725 AliInfo(Form("Ntr[%1d] NtrPID[%1d] Ncl[%3d] lab[%3d]", GetNumberOfTracklets(), GetNumberOfTrackletsPID(), fN, fLab));
728 const Double_t *curP = GetParameter();
729 for (Int_t i = 0; i < 5; i++) printf("%7.2f ", curP[i]);
733 const Double_t *curC = GetCovariance();
734 for (Int_t i = 0, j=4, k=0; i<15; i++, k++){
735 printf("%7.2f ", curC[i]);
741 if(strcmp(o, "a")!=0) return;
743 for(Int_t ip=0; ip<kNplane; ip++){
744 if(!fTracklet[ip]) continue;
745 fTracklet[ip]->Print(o);
750 //_____________________________________________________________________________
751 Bool_t AliTRDtrackV1::Rotate(Double_t alpha, Bool_t absolute)
754 // Rotates track parameters in R*phi plane
755 // if absolute rotation alpha is in global system
756 // otherwise alpha rotation is relative to the current rotation angle
759 if (absolute) alpha -= GetAlpha();
762 return AliExternalTrackParam::Rotate(GetAlpha()+alpha);
765 //___________________________________________________________
766 void AliTRDtrackV1::SetNumberOfClusters()
768 // Calculate the number of clusters attached to this track
771 for(int ip=0; ip<kNplane; ip++){
772 if(fTracklet[ip] && fTrackletIndex[ip] != -1) ncls += fTracklet[ip]->GetN();
774 AliKalmanTrack::SetNumberOfClusters(ncls);
778 //_______________________________________________________________
779 void AliTRDtrackV1::SetOwner()
782 // Toggle ownership of tracklets
785 if(TestBit(kOwner)) return;
786 for (Int_t ip = 0; ip < kNplane; ip++) {
787 if(fTrackletIndex[ip] == -1) continue;
788 fTracklet[ip] = new AliTRDseedV1(*fTracklet[ip]);
789 fTracklet[ip]->SetOwner();
794 //_______________________________________________________________
795 void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *const trklt, Int_t index)
800 Int_t plane = trklt->GetPlane();
802 fTracklet[plane] = trklt;
803 fTrackletIndex[plane] = index;
806 //_______________________________________________________________
807 void AliTRDtrackV1::SetTrackLow()
809 const AliExternalTrackParam *op = dynamic_cast<const AliExternalTrackParam*>(this);
810 fTrackLow = fTrackLow ? new(fTrackLow) AliExternalTrackParam(*op) : new AliExternalTrackParam(*op);
813 //_______________________________________________________________
814 void AliTRDtrackV1::SetTrackHigh(const AliExternalTrackParam *op)
816 if(!op) op = dynamic_cast<const AliExternalTrackParam*>(this);
817 fTrackHigh = fTrackHigh ? new(fTrackHigh) AliExternalTrackParam(*op) : new AliExternalTrackParam(*op);
820 //_______________________________________________________________
821 void AliTRDtrackV1::UnsetTracklet(Int_t plane)
823 if(plane<0 && plane >= kNplane) return;
824 fTrackletIndex[plane] = -1;
825 fTracklet[plane] = NULL;
829 //_______________________________________________________________
830 Bool_t AliTRDtrackV1::Update(Double_t *p, Double_t *cov, Double_t chi2, Bool_t use)
835 AliDebug(2, Form("Point:\n p=[%6.2f %6.2f]\n V=[%6.2f %6.2f]\n [%6.2f %6.2f]", p[0], p[1], cov[0], cov[1], cov[1], cov[2]));
836 if(use && !AliExternalTrackParam::Update(p, cov)) return kFALSE;
838 // Register info to track
839 SetNumberOfClusters();
840 SetChi2(GetChi2() + chi2);
844 //_______________________________________________________________
845 void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track)
848 // Update the TRD PID information in the ESD track
851 Int_t nslices = fkReconstructor->GetRecoParam()->IsEightSlices() ? (Int_t)AliTRDpidUtil::kNNslices : (Int_t)AliTRDpidUtil::kLQslices;
852 // number of tracklets used for PID calculation
853 UChar_t nPID = GetNumberOfTrackletsPID();
854 // number of tracklets attached to the track
855 UChar_t nTrk = GetNumberOfTracklets();
856 // pack the two numbers together and store them in the ESD
857 track->SetTRDntracklets(nPID | (nTrk<<3));
858 // allocate space to store raw PID signals dEdx & momentum
859 track->SetNumberOfTRDslices((nslices+2)*AliTRDgeometry::kNlayer);
861 Float_t p, sp; Double_t spd;
862 for (Int_t ip = 0; ip < kNplane; ip++) {
863 if(fTrackletIndex[ip] == -1) continue;
864 if(!fTracklet[ip]->HasPID()) continue;
865 const Float_t *dedx = fTracklet[ip]->GetdEdx();
866 for (Int_t js = 0; js < nslices; js++, dedx++) track->SetTRDslice(*dedx, ip, js);
867 p = fTracklet[ip]->GetMomentum(&sp); spd = sp;
868 track->SetTRDmomentum(p, ip, &spd);
870 // store PID probabilities
871 track->SetTRDpid(fPID);