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 "AliTRDPIDResponse.h"
27 #include "AliTRDrecoParam.h"
29 ClassImp(AliTRDtrackV1)
31 ///////////////////////////////////////////////////////////////////////////////
33 // Represents a reconstructed TRD track //
34 // Local TRD Kalman track //
37 // Alex Bercuci <A.Bercuci@gsi.de> //
38 // Markus Fasel <M.Fasel@gsi.de> //
40 ///////////////////////////////////////////////////////////////////////////////
42 //_______________________________________________________________
43 AliTRDtrackV1::AliTRDtrackV1() : AliKalmanTrack()
47 ,fkReconstructor(NULL)
53 // Default constructor
55 //printf("AliTRDtrackV1::AliTRDtrackV1()\n");
57 for(int i =0; i<3; i++) fBudget[i] = 0.;
59 Float_t pid = 1./AliPID::kSPECIES;
60 for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
62 for(int ip=0; ip<kNplane; ip++){
63 fTrackletIndex[ip] = -1;
68 //_______________________________________________________________
69 AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &ref) : AliKalmanTrack(ref)
73 ,fkReconstructor(ref.fkReconstructor)
82 //printf("AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &)\n");
83 SetBit(kOwner, kFALSE);
84 for(int ip=0; ip<kNplane; ip++){
85 fTrackletIndex[ip] = ref.fTrackletIndex[ip];
86 fTracklet[ip] = ref.fTracklet[ip];
88 if(ref.fTrackLow) fTrackLow = new AliExternalTrackParam(*ref.fTrackLow);
89 if(ref.fTrackHigh) fTrackHigh = new AliExternalTrackParam(*ref.fTrackHigh);
91 for (Int_t i = 0; i < 3;i++) fBudget[i] = ref.fBudget[i];
93 for(Int_t is = 0; is<AliPID::kSPECIES; is++) fPID[is] = ref.fPID[is];
95 AliKalmanTrack::SetNumberOfClusters(ref.GetNumberOfClusters());
98 //_______________________________________________________________
99 AliTRDtrackV1::AliTRDtrackV1(const AliESDtrack &t) : AliKalmanTrack()
103 ,fkReconstructor(NULL)
109 // Constructor from AliESDtrack
113 SetLabel(t.GetLabel());
116 SetMass(t.GetMass()/*0.000510*/);
117 AliKalmanTrack::SetNumberOfClusters(t.GetTRDncls());
118 Int_t ti[]={-1, -1, -1, -1, -1, -1}; t.GetTRDtracklets(&ti[0]);
119 for(int ip=0; ip<kNplane; ip++){
120 fTrackletIndex[ip] = ti[ip];
121 fTracklet[ip] = NULL;
123 for(int i =0; i<3; i++) fBudget[i] = 0.;
125 Float_t pid = 1./AliPID::kSPECIES;
126 for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
128 const AliExternalTrackParam *par = &t;
129 if (t.GetStatus() & AliESDtrack::kTRDbackup) {
130 par = t.GetOuterParam();
132 AliError("No backup info!");
139 ,par->GetCovariance());
141 if(t.GetStatus() & AliESDtrack::kTIME) {
144 t.GetIntegratedTimes(times);
145 SetIntegratedTimes(times);
146 SetIntegratedLength(t.GetIntegratedLength());
150 //_______________________________________________________________
151 AliTRDtrackV1::AliTRDtrackV1(AliTRDseedV1 * const trklts, const Double_t p[5], const Double_t cov[15]
152 , Double_t x, Double_t alpha) : AliKalmanTrack()
156 ,fkReconstructor(NULL)
162 // The stand alone tracking constructor
163 // TEMPORARY !!!!!!!!!!!
165 // 1. covariance matrix
166 // 2. dQdl calculation
170 Double_t cnv = (TMath::Abs(b) < 1.e-5) ? 1.e5 : 1./GetBz()/kB2C;
172 Double_t pp[5] = { p[0]
178 Double_t c22 = x*x*cov[14] - 2*x*cov[12] + cov[ 5];
179 Double_t c32 = x*cov[13] - cov[ 8];
180 Double_t c20 = x*cov[10] - cov[ 3];
181 Double_t c21 = x*cov[11] - cov[ 4];
182 Double_t c42 = x*cov[14] - cov[12];
184 Double_t cc[15] = { cov[ 0]
187 , cov[ 6], cov[ 7], c32, cov[ 9]
188 , cov[10]*cnv, cov[11]*cnv, c42*cnv, cov[13]*cnv, cov[14]*cnv*cnv };
190 Double_t mostProbablePt=AliExternalTrackParam::GetMostProbablePt();
191 Double_t p0=TMath::Sign(1/mostProbablePt,pp[4]);
192 Double_t w0=cc[14]/(cc[14] + p0*p0), w1=p0*p0/(cc[14] + p0*p0);
193 AliDebug(3, Form("Pt mixing : w0[%4.2f] pt0[%5.3f] w1[%4.2f] pt[%5.3f]", w0, 1./p0, w1, 1./pp[4]));
195 pp[4] = w0*p0 + w1*pp[4];
196 cc[10]*=w1; cc[11]*=w1; cc[12]*=w1; cc[13]*=w1; cc[14]*=w1;
198 AliDebug(2, Form("Init @ x[%6.2f] pt[%5.3f]", x, 1./pp[4]));
200 for(int iplane=0; iplane<kNplane; iplane++){
201 fTrackletIndex[iplane] = -1;
202 if(!trklts[iplane].IsOK()) fTracklet[iplane] = NULL;
204 fTracklet[iplane] = &trklts[iplane];
205 ncls += fTracklet[iplane]->GetN();
208 AliKalmanTrack::SetNumberOfClusters(ncls);
209 for(int i =0; i<3; i++) fBudget[i] = 0.;
211 Float_t pid = 1./AliPID::kSPECIES;
212 for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
215 //_______________________________________________________________
216 AliTRDtrackV1::~AliTRDtrackV1()
218 // Clean up all objects allocated by the track during its lifetime.
219 AliDebug(2, Form("Deleting track[%d]\n fBackupTrack[%p] fTrackLow[%p] fTrackHigh[%p] Owner[%c].", fESDid, (void*)fBackupTrack, (void*)fTrackLow, (void*)fTrackHigh, TestBit(kOwner)?'y':'n'));
221 if(fBackupTrack) delete fBackupTrack; fBackupTrack = NULL;
223 if(fTrackLow) delete fTrackLow; fTrackLow = NULL;
224 if(fTrackHigh) delete fTrackHigh; fTrackHigh = NULL;
226 for(Int_t ip=0; ip<kNplane; ip++){
227 if(TestBit(kOwner) && fTracklet[ip]) delete fTracklet[ip];
228 fTracklet[ip] = NULL;
229 fTrackletIndex[ip] = -1;
233 //_______________________________________________________________
234 AliTRDtrackV1 &AliTRDtrackV1::operator=(const AliTRDtrackV1 &t)
237 // Assignment operator
241 ((AliTRDtrackV1 &) t).Copy(*this);
248 //_____________________________________________________________________________
249 void AliTRDtrackV1::Copy(TObject &t) const
255 ((AliTRDtrackV1 &) t).fStatus = fStatus;
256 ((AliTRDtrackV1 &) t).fESDid = fESDid;
257 ((AliTRDtrackV1 &) t).fDE = fDE;
258 ((AliTRDtrackV1 &) t).fkReconstructor = fkReconstructor;
259 ((AliTRDtrackV1 &) t).fBackupTrack = 0x0;
260 ((AliTRDtrackV1 &) t).fTrackLow = 0x0;
261 ((AliTRDtrackV1 &) t).fTrackHigh = 0x0;
263 for(Int_t ip = 0; ip < kNplane; ip++) {
264 ((AliTRDtrackV1 &) t).fTrackletIndex[ip] = fTrackletIndex[ip];
265 ((AliTRDtrackV1 &) t).fTracklet[ip] = fTracklet[ip];
268 ((AliTRDtrackV1 &) t).fTrackLow = new AliExternalTrackParam(*fTrackLow);
271 ((AliTRDtrackV1 &) t).fTrackHigh = new AliExternalTrackParam(*fTrackHigh);
274 for (Int_t i = 0; i < 3; i++) {
275 ((AliTRDtrackV1 &) t).fBudget[i] = fBudget[i];
277 for (Int_t is = 0; is < AliPID::kSPECIES; is++) {
278 ((AliTRDtrackV1 &) t).fPID[is] = fPID[is];
283 //_______________________________________________________________
284 Bool_t AliTRDtrackV1::CookLabel(Float_t wrong)
286 // set MC label for this track
287 if(!GetNumberOfClusters()) return kFALSE;
289 Int_t s[kMAXCLUSTERSPERTRACK][2];
290 for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
297 AliTRDcluster *c = NULL;
298 for (Int_t ip = 0; ip < kNplane; ip++) {
299 if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
300 for (Int_t ic = 0; ic < AliTRDseedV1::kNclusters; ic++) {
301 if(!(c = fTracklet[ip]->GetClusters(ic))) continue;
302 for (Int_t k = 0; k < 3; k++) {
303 label = c->GetLabel(k);
307 while ((!labelAdded) && (j < kMAXCLUSTERSPERTRACK)) {
308 if ((s[j][0] == label) ||
323 for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
324 if (s[i][1] <= max) continue;
328 if ((1. - Float_t(max)/GetNumberOfClusters()) > wrong) label = -label;
335 //_______________________________________________________________
336 Bool_t AliTRDtrackV1::CookPID()
339 // Cook the PID information for the track by delegating the omonim function of the tracklets.
340 // Computes the number of tracklets used. The tracklet information are considered independent.
341 // For the moment no global track measurement of PID is performed as for example to estimate
342 // bremsstrahlung probability based on global chi2 of the track.
344 // The status bit AliESDtrack::kTRDpid is set during the call of AliTRDtrackV1::UpdateESDtrack().The PID performance of the
345 //TRD for tracks with 6 tacklets is displayed below.
347 //<img src="TRD/trackPID.gif">
350 const AliTRDPIDResponse *pidResponse = AliTRDcalibDB::Instance()->GetPIDResponse(fkReconstructor->GetRecoParam()->GetPIDmethod());
352 AliError("PID Response not available");
355 Int_t nslices = pidResponse->GetNumberOfSlices();
356 Double_t dEdx[kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN];
357 Float_t trackletP[kNplane];
358 memset(dEdx, 0, sizeof(Double_t) * kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN);
359 memset(trackletP, 0, sizeof(Float_t)*kNplane);
360 for(Int_t iseed = 0; iseed < kNplane; iseed++){
361 if(!fTracklet[iseed]) continue;
362 trackletP[iseed] = fTracklet[iseed]->GetMomentum();
363 fTracklet[iseed]->CookdEdx(nslices);
364 fTracklet[iseed]->SetPID();
365 if(pidResponse->GetPIDmethod() == AliTRDPIDResponse::kLQ1D){
366 dEdx[iseed] = fTracklet[iseed]->GetdQdl();
368 const Float_t *trackletdEdx = fTracklet[iseed]->GetdEdx();
369 for(Int_t islice = 0; islice < nslices; islice++){
370 dEdx[iseed*nslices + islice] = trackletdEdx[islice];
374 pidResponse->GetResponse(nslices, dEdx, trackletP, fPID);
378 //___________________________________________________________
379 UChar_t AliTRDtrackV1::GetNumberOfTrackletsPID() const
381 // Retrieve number of tracklets used for PID calculation.
384 for(int ip=0; ip<kNplane; ip++){
385 if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
386 if(!fTracklet[ip]->IsOK()) continue;
393 //_______________________________________________________________
394 AliTRDcluster* AliTRDtrackV1::GetCluster(Int_t id)
396 // Get the cluster at a certain position in the track
398 for(Int_t ip=0; ip<kNplane; ip++){
399 if(!fTracklet[ip]) continue;
400 if(n+fTracklet[ip]->GetN() <= id){
401 n+=fTracklet[ip]->GetN();
404 AliTRDcluster *c = NULL;
405 for(Int_t ic=AliTRDseedV1::kNclusters; ic--;){
406 if(!(c = fTracklet[ip]->GetClusters(ic))) continue;
408 if(n<id){n++; continue;}
415 //_______________________________________________________________
416 Int_t AliTRDtrackV1::GetClusterIndex(Int_t id) const
418 // Get the cluster index at a certain position in the track
420 for(Int_t ip=0; ip<kNplane; ip++){
421 if(!fTracklet[ip]) continue;
422 if(n+fTracklet[ip]->GetN() <= id){
423 n+=fTracklet[ip]->GetN();
426 for(Int_t ic=AliTRDseedV1::kNclusters; ic--;){
427 if(!(fTracklet[ip]->GetClusters(ic))) continue;
428 if(n<id){n++; continue;}
429 return fTracklet[ip]->GetIndexes(ic);
435 //_______________________________________________________________
436 Double_t AliTRDtrackV1::GetPredictedChi2(const AliTRDseedV1 *trklt, Double_t *cov) const
438 // Compute chi2 between tracklet and track. The value is calculated at the radial position of the track
439 // equal to the reference radial position of the tracklet (see AliTRDseedV1)
441 // The chi2 estimator is computed according to the following formula
443 // #chi^{2}=(X_{trklt}-X_{track})(C_{trklt}+C_{track})^{-1}(X_{trklt}-X_{track})^{T}
445 // where X=(y z), the position of the track/tracklet in the yz plane
448 Double_t p[2] = { trklt->GetY(), trklt->GetZ()};
449 trklt->GetCovAt(trklt->GetX(), cov);
450 return AliExternalTrackParam::GetPredictedChi2(p, cov);
453 //_______________________________________________________________
454 Int_t AliTRDtrackV1::GetSector() const
456 return Int_t(GetAlpha()/AliTRDgeometry::GetAlpha() + (GetAlpha()>0. ? 0 : AliTRDgeometry::kNsector));
459 //_______________________________________________________________
460 Bool_t AliTRDtrackV1::IsEqual(const TObject *o) const
462 // Checks whether two tracks are equal
463 if (!o) return kFALSE;
464 const AliTRDtrackV1 *inTrack = dynamic_cast<const AliTRDtrackV1*>(o);
465 if (!inTrack) return kFALSE;
467 //if ( fPIDquality != inTrack->GetPIDquality() ) return kFALSE;
469 if(memcmp(fPID, inTrack->fPID, AliPID::kSPECIES*sizeof(Double32_t))) return kFALSE;
470 if(memcmp(fBudget, inTrack->fBudget, 3*sizeof(Double32_t))) return kFALSE;
471 if(memcmp(&fDE, &inTrack->fDE, sizeof(Double32_t))) return kFALSE;
472 if(memcmp(&fFakeRatio, &inTrack->fFakeRatio, sizeof(Double32_t))) return kFALSE;
473 if(memcmp(&fChi2, &inTrack->fChi2, sizeof(Double32_t))) return kFALSE;
474 if(memcmp(&fMass, &inTrack->fMass, sizeof(Double32_t))) return kFALSE;
475 if( fLab != inTrack->fLab ) return kFALSE;
476 if( fN != inTrack->fN ) return kFALSE;
477 Double32_t l(0.), in(0.);
478 l = GetIntegratedLength(); in = inTrack->GetIntegratedLength();
479 if(memcmp(&l, &in, sizeof(Double32_t))) return kFALSE;
480 l=GetX(); in=inTrack->GetX();
481 if(memcmp(&l, &in, sizeof(Double32_t))) return kFALSE;
482 l = GetAlpha(); in = inTrack->GetAlpha();
483 if(memcmp(&l, &in, sizeof(Double32_t))) return kFALSE;
484 if(memcmp(GetParameter(), inTrack->GetParameter(), 5*sizeof(Double32_t))) return kFALSE;
485 if(memcmp(GetCovariance(), inTrack->GetCovariance(), 15*sizeof(Double32_t))) return kFALSE;
487 for (Int_t iTracklet = 0; iTracklet < kNplane; iTracklet++){
488 AliTRDseedV1 *curTracklet = fTracklet[iTracklet];
489 AliTRDseedV1 *inTracklet = inTrack->GetTracklet(iTracklet);
490 if (curTracklet && inTracklet){
491 if (! curTracklet->IsEqual(inTracklet) ) {
492 curTracklet->Print();
497 // if one tracklet exists, and corresponding
498 // in other track doesn't - return kFALSE
499 if(inTracklet || curTracklet) return kFALSE;
506 //_______________________________________________________________
507 Bool_t AliTRDtrackV1::IsElectron() const
509 if(GetPID(0) > fkReconstructor->GetRecoParam()->GetPIDThreshold(GetP())) return kTRUE;
514 //_____________________________________________________________________________
515 Int_t AliTRDtrackV1::MakeBackupTrack()
518 // Creates a backup track
519 // TO DO update quality check of the track.
522 Float_t occupancy(0.); Int_t n(0), ncls(0);
523 for(Int_t il(AliTRDgeometry::kNlayer); il--;){
524 if(!fTracklet[il]) continue;
526 occupancy+=fTracklet[il]->GetOccupancyTB();
527 ncls += fTracklet[il]->GetN();
532 //Float_t ratio1 = Float_t(t.GetNumberOfClusters()+1) / Float_t(t.GetNExpected()+1);
534 Int_t failedCutId(0);
535 if(GetChi2()/n > 5.0) failedCutId=1;
536 if(occupancy < 0.7) failedCutId=2;
537 //if(ratio1 > 0.6) &&
538 //if(ratio0+ratio1 > 1.5) &&
539 if(GetNCross() != 0) failedCutId=3;
540 if(TMath::Abs(GetSnp()) > 0.85) failedCutId=4;
541 if(ncls < 20) failedCutId=5;
544 AliDebug(2, Form("\n"
545 "chi2/tracklet < 5.0 [%c] %5.2f\n"
546 "occupancy > 0.7 [%c] %4.2f\n"
547 "NCross == 0 [%c] %d\n"
548 "Abs(snp) < 0.85 [%c] %4.2f\n"
549 "NClusters > 20 [%c] %d"
550 ,(GetChi2()/n<5.0)?'y':'n', GetChi2()/n
551 ,(occupancy>0.7)?'y':'n', occupancy
552 ,(GetNCross()==0)?'y':'n', GetNCross()
553 ,(TMath::Abs(GetSnp())<0.85)?'y':'n', TMath::Abs(GetSnp())
554 ,(ncls>20)?'y':'n', ncls
560 fBackupTrack->~AliTRDtrackV1();
561 new(fBackupTrack) AliTRDtrackV1((AliTRDtrackV1&)(*this));
564 fBackupTrack = new AliTRDtrackV1((AliTRDtrackV1&)(*this));
568 //_____________________________________________________________________________
569 Int_t AliTRDtrackV1::GetProlongation(Double_t xk, Double_t &y, Double_t &z) const
572 // Find a prolongation at given x
573 // Return -1 if it does not exist
576 Double_t bz = GetBz();
577 if (!AliExternalTrackParam::GetYAt(xk,bz,y)) return -1;
578 if (!AliExternalTrackParam::GetZAt(xk,bz,z)) return -1;
584 //_____________________________________________________________________________
585 Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho)
588 // Propagates this track to a reference plane defined by "xk" [cm]
589 // correcting for the mean crossed material.
591 // "xx0" - thickness/rad.length [units of the radiation length]
592 // "xrho" - thickness*density [g/cm^2]
595 if (TMath::Abs(xk - GetX())<AliTRDReconstructor::GetEpsilon()*0.1) return kTRUE; // 10% of the tracker precision
597 Double_t xyz0[3] = {GetX(), GetY(), GetZ()}, // track position BEFORE propagation
598 b[3]; // magnetic field
600 if(!AliExternalTrackParam::PropagateToBxByBz(xk,b)) return kFALSE;
602 // local track position AFTER propagation
603 Double_t xyz1[3] = {GetX(), GetY(), GetZ()};
606 if (IsStartedTimeIntegral()) {
607 Double_t l2 = TMath::Sqrt((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0])
608 + (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1])
609 + (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2]));
610 Double_t crv = AliExternalTrackParam::GetC(b[2]);
611 if (TMath::Abs(l2*crv) > 0.0001) {
612 // Make correction for curvature if neccesary
613 l2 = 0.5 * TMath::Sqrt((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0])
614 + (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1]));
615 l2 = 2.0 * TMath::ASin(l2 * crv) / crv;
616 l2 = TMath::Sqrt(l2*l2 + (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2]));
622 if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0, xrho, GetMass())) return kFALSE;
628 Double_t p2 = (1.0 + GetTgl()*GetTgl()) / (GetSigned1Pt()*GetSigned1Pt());
629 Double_t beta2 = p2 / (p2 + GetMass()*GetMass());
630 if ((beta2 < 1.0e-10) ||
631 ((5940.0 * beta2/(1.0 - beta2 + 1.0e-10) - beta2) < 0.0)) {
635 Double_t dE = 0.153e-3 / beta2
636 * (TMath::Log(5940.0 * beta2/(1.0 - beta2 + 1.0e-10)) - beta2)
641 // Suspicious part - think about it ?
642 Double_t kinE = TMath::Sqrt(p2);
643 if (dE > 0.8*kinE) dE = 0.8 * kinE; //
644 if (dE < 0) dE = 0.0; // Not valid region for Bethe bloch
651 Double_t sigmade = 0.07 * TMath::Sqrt(TMath::Abs(dE)); // Energy loss fluctuation
652 Double_t sigmac2 = sigmade*sigmade*fC*fC*(p2+GetMass()*GetMass())/(p2*p2);
654 fCee += fX*fX * sigmac2;
662 //_____________________________________________________________________________
663 Int_t AliTRDtrackV1::PropagateToR(Double_t r,Double_t step)
666 // Propagate track to the radial position
667 // Rotation always connected to the last track position
675 Double_t radius = TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
677 Double_t dir = (radius > r) ? -1.0 : 1.0;
679 for (Double_t x = radius+dir*step; dir*x < dir*r; x += dir*step) {
682 Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]);
685 if(GetProlongation(x,y,z)<0) return -1;
686 xyz1[0] = x * TMath::Cos(alpha) + y * TMath::Sin(alpha);
687 xyz1[1] = x * TMath::Sin(alpha) - y * TMath::Cos(alpha);
690 if(AliTracker::MeanMaterialBudget(xyz0,xyz1,param)<=0.) return -1;
692 param[1] = 100000000;
694 PropagateTo(x,param[1],param[0]*param[4]);
699 Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]);
702 if(GetProlongation(r,y,z)<0) return -1;
703 xyz1[0] = r * TMath::Cos(alpha) + y * TMath::Sin(alpha);
704 xyz1[1] = r * TMath::Sin(alpha) - y * TMath::Cos(alpha);
707 if(AliTracker::MeanMaterialBudget(xyz0,xyz1,param) <= 0.) return -1;
710 param[1] = 100000000;
712 PropagateTo(r,param[1],param[0]*param[4]);
718 //_____________________________________________________________________________
719 void AliTRDtrackV1::Print(Option_t *o) const
721 // Print track status
722 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]));
723 AliInfo(Form("Material[%5.2f %5.2f %5.2f]", fBudget[0], fBudget[1], fBudget[2]));
725 AliInfo(Form("x[%7.2f] t[%7.4f] alpha[%f] mass[%f]", GetX(), GetIntegratedLength(), GetAlpha(), fMass));
726 AliInfo(Form("Ntr[%1d] NtrPID[%1d] Ncl[%3d] lab[%3d]", GetNumberOfTracklets(), GetNumberOfTrackletsPID(), fN, fLab));
729 const Double_t *curP = GetParameter();
730 for (Int_t i = 0; i < 5; i++) printf("%7.2f ", curP[i]);
734 const Double_t *curC = GetCovariance();
735 for (Int_t i = 0, j=4, k=0; i<15; i++, k++){
736 printf("%7.2f ", curC[i]);
742 if(strcmp(o, "a")!=0) return;
744 for(Int_t ip=0; ip<kNplane; ip++){
745 if(!fTracklet[ip]) continue;
746 fTracklet[ip]->Print(o);
751 //_____________________________________________________________________________
752 Bool_t AliTRDtrackV1::Rotate(Double_t alpha, Bool_t absolute)
755 // Rotates track parameters in R*phi plane
756 // if absolute rotation alpha is in global system
757 // otherwise alpha rotation is relative to the current rotation angle
760 if (absolute) alpha -= GetAlpha();
763 return AliExternalTrackParam::Rotate(GetAlpha()+alpha);
766 //___________________________________________________________
767 void AliTRDtrackV1::SetNumberOfClusters()
769 // Calculate the number of clusters attached to this track
772 for(int ip=0; ip<kNplane; ip++){
773 if(fTracklet[ip] && fTrackletIndex[ip] >= 0) ncls += fTracklet[ip]->GetN();
775 AliKalmanTrack::SetNumberOfClusters(ncls);
779 //_______________________________________________________________
780 void AliTRDtrackV1::SetOwner()
783 // Toggle ownership of tracklets
786 if(TestBit(kOwner)) return;
787 for (Int_t ip = 0; ip < kNplane; ip++) {
788 if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
789 fTracklet[ip] = new AliTRDseedV1(*fTracklet[ip]);
790 fTracklet[ip]->SetOwner();
795 //_______________________________________________________________
796 void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *const trklt, Int_t index)
801 Int_t plane = trklt->GetPlane();
803 fTracklet[plane] = trklt;
804 fTrackletIndex[plane] = index;
807 //_______________________________________________________________
808 void AliTRDtrackV1::SetTrackIn()
810 // Save location of birth for the TRD track
811 // If the pointer is not valid allocate memory
813 const AliExternalTrackParam *op = dynamic_cast<const AliExternalTrackParam*>(this);
815 //printf("SetTrackIn() : fTrackLow[%p]\n", (void*)fTrackLow);
817 fTrackLow->~AliExternalTrackParam();
818 new(fTrackLow) AliExternalTrackParam(*op);
819 } else fTrackLow = new AliExternalTrackParam(*op);
822 //_______________________________________________________________
823 void AliTRDtrackV1::SetTrackOut(const AliExternalTrackParam *op)
825 // Save location of death for the TRD track
826 // If the pointer is not valid allocate memory
828 if(!op) op = dynamic_cast<const AliExternalTrackParam*>(this);
830 fTrackHigh->~AliExternalTrackParam();
831 new(fTrackHigh) AliExternalTrackParam(*op);
832 } else fTrackHigh = new AliExternalTrackParam(*op);
835 //_______________________________________________________________
836 void AliTRDtrackV1::UnsetTracklet(Int_t plane)
839 fTrackletIndex[plane] = -1;
840 fTracklet[plane] = NULL;
844 //_______________________________________________________________
845 void AliTRDtrackV1::UpdateChi2(Float_t chi2)
847 // Update chi2/track with one tracklet contribution
848 SetChi2(GetChi2() + chi2);
851 //_______________________________________________________________
852 void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track)
855 // Update the TRD PID information in the ESD track
858 Int_t nslices = AliTRDcalibDB::Instance()->GetPIDResponse(fkReconstructor->GetRecoParam()->GetPIDmethod())->GetNumberOfSlices();
859 // number of tracklets used for PID calculation
860 UChar_t nPID = GetNumberOfTrackletsPID();
861 // number of tracklets attached to the track
862 UChar_t nTrk = GetNumberOfTracklets();
863 // pack the two numbers together and store them in the ESD
864 track->SetTRDntracklets(nPID | (nTrk<<3));
865 // allocate space to store raw PID signals dEdx & momentum
866 track->SetNumberOfTRDslices((nslices+3)*AliTRDgeometry::kNlayer);
868 Float_t p, sp; Double_t spd;
869 for (Int_t ip = 0; ip < kNplane; ip++) {
870 if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
871 if(!fTracklet[ip]->HasPID()) continue;
872 const Float_t *dedx = fTracklet[ip]->GetdEdx();
873 for (Int_t js = 0; js < nslices; js++, dedx++) track->SetTRDslice(*dedx, ip, js+1);
874 p = fTracklet[ip]->GetMomentum(&sp);
875 // 04.01.11 A.Bercuci
876 // store global dQdl per tracklet instead of momentum error
878 track->SetTRDmomentum(p, ip, &spd);
879 track->SetTRDslice(fTracklet[ip]->GetdQdl(), ip, 0); // Set Summed dEdx into the first slice
881 // store PID probabilities
882 track->SetTRDpid(fPID);