2 // Original: AliHLTTrack.cxx,v 1.32 2005/06/14 10:55:21 cvetan
4 /**************************************************************************
5 * This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
8 * Primary Authors: Anders Vestbo, Uli Frankenfeld, maintained by *
9 * Matthias Richter <Matthias.Richter@ift.uib.no> *
10 * for The ALICE HLT Project. *
12 * Permission to use, copy, modify and distribute this software and its *
13 * documentation strictly for non-commercial purposes is hereby granted *
14 * without fee, provided that the above copyright notice appears in all *
15 * copies and that both the copyright notice and this permission notice *
16 * appear in the supporting documentation. The authors make no claims *
17 * about the suitability of this software for any purpose. It is *
18 * provided "as is" without express or implied warranty. *
19 **************************************************************************/
21 /** @file AliHLTTPCTrack.cxx
22 @author Anders Vestbo, Uli Frankenfeld, maintained by Matthias Richter
24 @brief HLT TPC track implementation (conformal mapping) */
27 #include "AliHLTTPCLogging.h"
28 #include "AliHLTTPCTrack.h"
29 #include "AliHLTTPCTransform.h"
30 #include "AliHLTTPCVertex.h"
31 #include "AliHLTTPCSpacePointData.h"
37 ClassImp(AliHLTTPCTrack)
40 AliHLTTPCTrack::AliHLTTPCTrack()
86 memset(fHitNumbers,0,fgkHitArraySize*sizeof(UInt_t));
89 void AliHLTTPCTrack::Copy(AliHLTTPCTrack *tpt)
92 SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
93 SetPhi0(tpt->GetPhi0());
94 SetKappa(tpt->GetKappa());
95 SetNHits(tpt->GetNHits());
96 SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
97 SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
99 SetPsi(tpt->GetPsi());
100 SetTgl(tpt->GetTgl());
101 SetPterr(tpt->GetPterr());
102 SetPsierr(tpt->GetPsierr());
103 SetTglerr(tpt->GetTglerr());
104 SetZ0err(tpt->GetZ0err());
105 SetY0err(tpt->GetY0err());
106 SetCharge(tpt->GetCharge());
107 SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers());
108 SetMCid(tpt->GetMCid());
109 SetPID(tpt->GetPID());
110 SetSector(tpt->GetSector());
111 SetId( tpt->GetId());
114 Int_t AliHLTTPCTrack::Compare(const AliHLTTPCTrack *track) const
117 if(track->GetNHits() < GetNHits()) return 1;
118 if(track->GetNHits() > GetNHits()) return -1;
122 AliHLTTPCTrack::~AliHLTTPCTrack()
127 Double_t AliHLTTPCTrack::GetP() const
129 // Returns total momentum.
130 return fabs(GetPt())*sqrt(1. + GetTgl()*GetTgl());
133 Double_t AliHLTTPCTrack::GetPseudoRapidity() const
135 return 0.5 * log((GetP() + GetPz()) / (GetP() - GetPz()));
138 Double_t AliHLTTPCTrack::GetRapidity() const
141 const Double_t kmpi = 0.13957;
142 return 0.5 * log((kmpi + GetPz()) / (kmpi - GetPz()));
145 void AliHLTTPCTrack::Rotate(Int_t slice,Bool_t tolocal)
147 //Rotate track to global parameters
148 //If flag tolocal is set, the track is rotated
149 //to local coordinates.
151 Float_t psi[1] = {GetPsi()};
153 AliHLTTPCTransform::Local2GlobalAngle(psi,slice);
155 AliHLTTPCTransform::Global2LocalAngle(psi,slice);
158 first[0] = GetFirstPointX();
159 first[1] = GetFirstPointY();
160 first[2] = GetFirstPointZ();
162 AliHLTTPCTransform::Local2Global(first,slice);
164 AliHLTTPCTransform::Global2LocHLT(first,slice);
165 //AliHLTTPCTransform::Global2Local(first,slice,kTRUE);
167 SetFirstPoint(first[0],first[1],first[2]);
169 last[0] = GetLastPointX();
170 last[1] = GetLastPointY();
171 last[2] = GetLastPointZ();
173 AliHLTTPCTransform::Local2Global(last,slice);
175 AliHLTTPCTransform::Global2LocHLT(last,slice);
176 //AliHLTTPCTransform::Global2Local(last,slice,kTRUE);
177 SetLastPoint(last[0],last[1],last[2]);
179 Float_t center[3] = {GetCenterX(),GetCenterY(),0};
181 AliHLTTPCTransform::Local2Global(center,slice);
183 AliHLTTPCTransform::Global2LocHLT(center,slice);
184 //AliHLTTPCTransform::Global2Local(center,slice,kTRUE);
185 SetCenterX(center[0]);
186 SetCenterY(center[1]);
188 SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
189 SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
197 void AliHLTTPCTrack::CalculateHelix()
199 // fit assigned clusters to helix
200 // for straight line fit
201 if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
202 fRadius = 999999; //just zero
204 SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
205 SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
209 //Calculate Radius, CenterX and CenterY from Psi, X0, Y0
210 fRadius = fPt / (AliHLTTPCTransform::GetBFieldValue());
211 if(fRadius) fKappa = -fQ*1./fRadius;
212 else fRadius = 999999; //just zero
213 Double_t trackPhi0 = fPsi + fQ * AliHLTTPCTransform::PiHalf();
215 fCenterX = fFirstPoint[0] - fRadius * cos(trackPhi0);
216 fCenterY = fFirstPoint[1] - fRadius * sin(trackPhi0);
218 SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
219 SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
223 Double_t AliHLTTPCTrack::GetCrossingAngle(Int_t padrow,Int_t slice)
225 //Calculate the crossing angle between track and given padrow.
226 //Take the dot product of the tangent vector of the track, and
227 //vector perpendicular to the padrow.
228 //In order to do this, we need the tangent vector to the track at the
229 //point. This is done by rotating the radius vector by 90 degrees;
230 //rotation matrix: ( 0 1 )
233 Float_t angle=0;//Angle perpendicular to the padrow in local coordinates
234 if(slice>=0)//Global coordinates
236 AliHLTTPCTransform::Local2GlobalAngle(&angle,slice);
237 if(!CalculateReferencePoint(angle,AliHLTTPCTransform::Row2X(padrow)))
238 cerr<<"AliHLTTPCTrack::GetCrossingAngle : Track does not cross line in slice "<<slice<<" row "<<padrow<<endl;
240 else //should be in local coordinates
243 GetCrossingPoint(padrow,xyz);
251 tangent[0] = (fPoint[1] - GetCenterY())/GetRadius();
252 tangent[1] = -1.*(fPoint[0] - GetCenterX())/GetRadius();
254 Double_t perppadrow[2] = {cos(angle),sin(angle)};
255 Double_t cosbeta = fabs(tangent[0]*perppadrow[0] + tangent[1]*perppadrow[1]);
256 if(cosbeta > 1) cosbeta=1;
257 return acos(cosbeta);
260 Bool_t AliHLTTPCTrack::GetCrossingPoint(Int_t padrow,Float_t *xyz)
262 //Assumes the track is given in local coordinates
265 cerr<<"GetCrossingPoint: Track is given on global coordinates"<<endl;
269 Double_t xHit = AliHLTTPCTransform::Row2X(padrow);
271 //if (xHit < xyz[0]){
272 // LOG(AliHLTTPCLog::kError,"AliHLTTPCTRACK::GetCrossingPoint","")<< "Track doesn't cross padrow "
273 // << padrow <<"(x=" << xHit << "). Smallest x=" << xyz[0] << ENDLOG;
277 // for straight line fit
278 if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
280 Double_t yHit = GetFirstPointY() + (Double_t) tan( GetPsi() ) * (xHit - GetFirstPointX());
282 Double_t s = (xHit - GetFirstPointX())*(xHit - GetFirstPointX()) + (yHit - GetFirstPointY())*(yHit - GetFirstPointY());
284 Double_t zHit = GetFirstPointZ() + s * GetTgl();
293 Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX());
294 Double_t r2 = GetRadius()*GetRadius();
298 Double_t aa2 = sqrt(r2 - aa);
299 Double_t y1 = GetCenterY() + aa2;
300 Double_t y2 = GetCenterY() - aa2;
302 if(fabs(y2) < fabs(y1)) xyz[1] = y2;
304 Double_t yHit = xyz[1];
305 Double_t angle1 = atan2((yHit - GetCenterY()),(xHit - GetCenterX()));
306 if(angle1 < 0) angle1 += 2.*AliHLTTPCTransform::Pi();
307 Double_t angle2 = atan2((GetFirstPointY() - GetCenterY()),(GetFirstPointX() - GetCenterX()));
308 if(angle2 < 0) angle2 += AliHLTTPCTransform::TwoPi();
310 Double_t diffangle = angle1 - angle2;
311 diffangle = fmod(diffangle,AliHLTTPCTransform::TwoPi());
312 if((GetCharge()*diffangle) > 0) diffangle = diffangle - GetCharge()*AliHLTTPCTransform::TwoPi();
314 Double_t stot = fabs(diffangle)*GetRadius();
316 Double_t zHit = GetFirstPointZ() + stot*GetTgl();
324 Bool_t AliHLTTPCTrack::CalculateReferencePoint(Double_t angle,Double_t radius)
326 // Global coordinate: crossing point with y = ax+ b;
327 // a=tan(angle-AliHLTTPCTransform::PiHalf());
329 const Double_t krr=radius; //position of reference plane
330 const Double_t kxr = cos(angle) * krr;
331 const Double_t kyr = sin(angle) * krr;
333 Double_t a = tan(angle-AliHLTTPCTransform::PiHalf());
334 Double_t b = kyr - a * kxr;
336 Double_t pp=(fCenterX+a*fCenterY-a*b)/(1+pow(a,2));
337 Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-2*fCenterY*b+pow(b,2)-pow(fRadius,2))/(1+pow(a,2));
339 Double_t racine = pp*pp-qq;
340 if(racine<0) return IsPoint(kFALSE); //no Point
342 Double_t rootRacine = sqrt(racine);
343 Double_t x0 = pp+rootRacine;
344 Double_t x1 = pp-rootRacine;
345 Double_t y0 = a*x0 + b;
346 Double_t y1 = a*x1 + b;
348 Double_t diff0 = sqrt(pow(x0-kxr,2)+pow(y0-kyr,2));
349 Double_t diff1 = sqrt(pow(x1-kxr,2)+pow(y1-kyr,2));
360 Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
361 Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
362 if(fabs(trackPhi0-pointPhi0)>AliHLTTPCTransform::Pi()){
363 if(trackPhi0<pointPhi0) trackPhi0 += AliHLTTPCTransform::TwoPi();
364 else pointPhi0 += AliHLTTPCTransform::TwoPi();
366 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
367 fPoint[2] = fFirstPoint[2] + stot * fTanl;
369 fPointPsi = pointPhi0 - fQ * AliHLTTPCTransform::PiHalf();
370 if(fPointPsi<0.) fPointPsi+= AliHLTTPCTransform::TwoPi();
371 fPointPsi = fmod(fPointPsi, AliHLTTPCTransform::TwoPi());
373 return IsPoint(kTRUE);
376 Bool_t AliHLTTPCTrack::CalculateEdgePoint(Double_t angle)
378 // Global coordinate: crossing point with y = ax; a=tan(angle);
380 Double_t rmin=AliHLTTPCTransform::Row2X(AliHLTTPCTransform::GetFirstRow(-1)); //min Radius of TPC
381 Double_t rmax=AliHLTTPCTransform::Row2X(AliHLTTPCTransform::GetLastRow(-1)); //max Radius of TPC
383 Double_t a = tan(angle);
384 Double_t pp=(fCenterX+a*fCenterY)/(1+pow(a,2));
385 Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-pow(fRadius,2))/(1+pow(a,2));
386 Double_t racine = pp*pp-qq;
387 if(racine<0) return IsPoint(kFALSE); //no Point
388 Double_t rootRacine = sqrt(racine);
389 Double_t x0 = pp+rootRacine;
390 Double_t x1 = pp-rootRacine;
394 Double_t r0 = sqrt(pow(x0,2)+pow(y0,2));
395 Double_t r1 = sqrt(pow(x1,2)+pow(y1,2));
396 //find the right crossing point:
397 //inside the TPC modules
401 if(r0>rmin&&r0<rmax){
402 Double_t da=atan2(y0,x0);
403 if(da<0) da+=AliHLTTPCTransform::TwoPi();
404 if(fabs(da-angle)<0.5)
407 if(r1>rmin&&r1<rmax){
408 Double_t da=atan2(y1,x1);
409 if(da<0) da+=AliHLTTPCTransform::TwoPi();
410 if(fabs(da-angle)<0.5)
413 if(!(ok0||ok1)) return IsPoint(kFALSE); //no Point
416 Double_t diff0 = sqrt(pow(fFirstPoint[0]-x0,2)+pow(fFirstPoint[1]-y0,2));
417 Double_t diff1 = sqrt(pow(fFirstPoint[0]-x1,2)+pow(fFirstPoint[1]-y1,2));
418 if(diff0<diff1) ok1 = kFALSE; //use ok0
419 else ok0 = kFALSE; //use ok1
421 if(ok0){fPoint[0]=x0; fPoint[1]=y0;}
422 else {fPoint[0]=x1; fPoint[1]=y1;}
424 Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
425 Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
426 if(fabs(trackPhi0-pointPhi0)>AliHLTTPCTransform::Pi()){
427 if(trackPhi0<pointPhi0) trackPhi0 += AliHLTTPCTransform::TwoPi();
428 else pointPhi0 += AliHLTTPCTransform::TwoPi();
430 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
431 fPoint[2] = fFirstPoint[2] + stot * fTanl;
433 fPointPsi = pointPhi0 - fQ * AliHLTTPCTransform::PiHalf();
434 if(fPointPsi<0.) fPointPsi+= AliHLTTPCTransform::TwoPi();
435 fPointPsi = fmod(fPointPsi, AliHLTTPCTransform::TwoPi());
437 return IsPoint(kTRUE);
440 Bool_t AliHLTTPCTrack::CalculatePoint(Double_t xplane)
442 // Local coordinate: crossing point with x plane
444 Double_t racine = pow(fRadius,2)-pow(xplane-fCenterX,2);
445 if(racine<0) return IsPoint(kFALSE);
446 Double_t rootRacine = sqrt(racine);
448 Double_t y0 = fCenterY + rootRacine;
449 Double_t y1 = fCenterY - rootRacine;
450 //Double_t diff0 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y0));
451 //Double_t diff1 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y1));
452 Double_t diff0 = fabs(y0-fFirstPoint[1]);
453 Double_t diff1 = fabs(y1-fFirstPoint[1]);
456 if(diff0<diff1) fPoint[1]=y0;
459 Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
460 Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
461 if(fabs(trackPhi0-pointPhi0)>AliHLTTPCTransform::Pi()){
462 if(trackPhi0<pointPhi0) trackPhi0 += AliHLTTPCTransform::TwoPi();
463 else pointPhi0 += AliHLTTPCTransform::TwoPi();
465 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
466 fPoint[2] = fFirstPoint[2] + stot * fTanl;
468 fPointPsi = pointPhi0 - fQ * AliHLTTPCTransform::PiHalf();
469 if(fPointPsi<0.) fPointPsi+= AliHLTTPCTransform::TwoPi();
470 fPointPsi = fmod(fPointPsi, AliHLTTPCTransform::TwoPi());
472 return IsPoint(kTRUE);
475 void AliHLTTPCTrack::UpdateToFirstPoint()
477 //Update track parameters to the innermost point on the track.
478 //This means that the parameters of the track will be given in the point
479 //of closest approach to the first innermost point, i.e. the point
480 //lying on the track fit (and not the coordinates of the innermost point itself).
481 //This function assumes that fFirstPoint is already set to the coordinates of the innermost
484 //During the helix-fit, the first point on the track is set to the coordinates
485 //of the innermost assigned cluster. This may be ok, if you just want a fast
486 //estimate of the "global" track parameters; such as the momentum etc.
487 //However, if you later on want to do more precise local calculations, such
488 //as impact parameter, residuals etc, you need to give the track parameters
489 //according to the actual fit.
490 // for straight line fit
491 if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
492 Double_t xc = GetCenterX() - GetFirstPointX();
493 Double_t yc = GetCenterY() - GetFirstPointY();
495 Double_t xn = (Double_t) sin( GetPsi() );
496 Double_t yn = -1. * (Double_t) cos( GetPsi() );
498 Double_t d = xc*xn + yc*yn;
500 Double_t distx = d * xn;
501 Double_t disty = d * yn;
505 point[0] = distx + GetFirstPointX();
506 point[1] = disty + GetFirstPointY();
508 //Update the track parameters
509 SetR0(sqrt(point[0]*point[0]+point[1]*point[1]));
510 SetPhi0(atan2(point[1],point[0]));
511 SetFirstPoint(point[0],point[1],GetZ0());
515 Double_t xc = GetCenterX() - GetFirstPointX();
516 Double_t yc = GetCenterY() - GetFirstPointY();
518 Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
519 Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
520 Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1);
522 Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
523 Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
524 Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2);
526 //Choose the closest:
528 if(distance1 < distance2)
530 point[0] = distx1 + GetFirstPointX();
531 point[1] = disty1 + GetFirstPointY();
535 point[0] = distx2 + GetFirstPointX();
536 point[1] = disty2 + GetFirstPointY();
539 Double_t pointpsi = atan2(point[1]-GetCenterY(),point[0]-GetCenterX());
540 pointpsi -= GetCharge()*AliHLTTPCTransform::PiHalf();
541 if(pointpsi < 0) pointpsi += AliHLTTPCTransform::TwoPi();
543 //Update the track parameters
544 SetR0(sqrt(point[0]*point[0]+point[1]*point[1]));
545 SetPhi0(atan2(point[1],point[0]));
546 SetFirstPoint(point[0],point[1],GetZ0());
551 void AliHLTTPCTrack::GetClosestPoint(AliHLTTPCVertex *vertex,Double_t &closestX,Double_t &closestY,Double_t &closestZ)
553 //Calculate the point of closest approach to the vertex
554 //This function calculates the minimum distance from the helix to the vertex, and choose
555 //the corresponding point lying on the helix as the point of closest approach.
557 Double_t xc = GetCenterX() - vertex->GetX();
558 Double_t yc = GetCenterY() - vertex->GetY();
560 Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
561 Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
562 Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1);
564 Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
565 Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
566 Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2);
568 //Choose the closest:
569 if(distance1 < distance2)
571 closestX = distx1 + vertex->GetX();
572 closestY = disty1 + vertex->GetY();
576 closestX = distx2 + vertex->GetX();
577 closestY = disty2 + vertex->GetY();
580 //Get the z coordinate:
581 Double_t angle1 = atan2((closestY-GetCenterY()),(closestX-GetCenterX()));
582 if(angle1 < 0) angle1 = angle1 + AliHLTTPCTransform::TwoPi();
584 Double_t angle2 = atan2((GetFirstPointY()-GetCenterY()),(GetFirstPointX()-GetCenterX()));
585 if(angle2 < 0) angle2 = angle2 + AliHLTTPCTransform::TwoPi();
587 Double_t diffAngle = angle1 - angle2;
588 diffAngle = fmod(diffAngle,AliHLTTPCTransform::TwoPi());
590 if((GetCharge()*diffAngle) < 0) diffAngle = diffAngle + GetCharge()*AliHLTTPCTransform::TwoPi();
591 Double_t stot = fabs(diffAngle)*GetRadius();
592 closestZ = GetFirstPointZ() - stot*GetTgl();
595 void AliHLTTPCTrack::Print(Option_t* /*option*/) const
597 //print out parameters of track
599 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCTrack::Print","Print values")
600 <<"NH="<<fNHits<<" "<<fMCid<<" K="<<fKappa<<" R="<<fRadius<<" Cx="<<fCenterX<<" Cy="<<fCenterY<<" MVT="
601 <<fFromMainVertex<<" Row0="<<fRowRange[0]<<" Row1="<<fRowRange[1]<<" Sector="<<fSector<<" Q="<<fQ<<" TgLam="
602 <<fTanl<<" psi="<<fPsi<<" pt="<<fPt<<" L="<<fLength<<" "<<fPterr<<" "<<fPsierr<<" "<<fZ0err<<" "
603 <<fTanlerr<<" phi0="<<fPhi0<<" R0="<<fR0<<" Z0="<<fZ0<<" X0="<<fFirstPoint[0]<<" Y0="<<fFirstPoint[1]<<" Z0="
604 <<fFirstPoint[2]<<" XL="<<fLastPoint[0]<<" YL="<<fLastPoint[1]<<" ZL="<<fLastPoint[2]<<" "
605 <<fPoint[0]<<" "<<fPoint[1]<<" "<<fPoint[2]<<" "<<fPointPsi<<" "<<fIsPoint<<" local="
606 <<fIsLocal<<" "<<fPID<<ENDLOG;
610 int AliHLTTPCTrack::Convert2AliKalmanTrack()
612 // The method has been copied from AliHLTHoughKalmanTrack and adapted
613 // to the TPC conformal mapping track parametrization
616 // sector A00 starts at 3 o'clock, sectors are counted counterclockwise
617 // median of sector 00 is at 10 degrees, median of sector A04 at 90
620 Double_t charge=(double) GetCharge();
622 param[1] = GetFirstPointZ();
624 param[4] = charge*(1.0/GetPt());
626 Double_t alpha, phi, xl, yl;
628 // rotate to local coordinates if necessary
630 if(GetSector() == -1){ // track in global coordinates
632 alpha = TMath::ATan2(GetFirstPointY(),GetFirstPointX());
633 double sinAlpha = TMath::Sin(alpha);
634 double cosAlpha = TMath::Cos(alpha);
636 phi = GetPsi() - alpha;
637 xl = GetFirstPointX()*cosAlpha + GetFirstPointY()*sinAlpha;
638 yl = -GetFirstPointX()*sinAlpha + GetFirstPointY()*cosAlpha;
640 } else{ // track in local coordinates
642 alpha = (GetSector()+0.5)*(TMath::TwoPi()/18);
644 xl = GetFirstPointX();
645 yl = GetFirstPointY();
647 // normalize alpha to [-Pi,+Pi]
649 alpha = alpha - TMath::TwoPi() * TMath::Floor( alpha /TMath::TwoPi()+.5);
652 // extra rotation to keep phi in the range (-Pi/2,+Pi/2)
654 const Double_t kMaxPhi = TMath::PiOver2() - 10./180.*TMath::Pi();
656 // normalize phi to [-Pi,+Pi]
658 phi = phi - TMath::TwoPi() * TMath::Floor( phi /TMath::TwoPi()+.5);
662 alpha += TMath::PiOver2();
663 phi -= TMath::PiOver2();
668 else if( phi <= -kMaxPhi )
670 alpha += -TMath::PiOver2();
671 phi -= -TMath::PiOver2();
679 param[2] = TMath::Sin(phi);
683 GetY0err(), //Error in Y (Y and X are the same)
684 0., GetZ0err(), //Error in Z
685 0., 0., GetPsierr(), //Error for Psi
686 0., 0., 0., GetTglerr(), //Error for Tgl
687 0., 0., 0., 0., GetPterr() //Error for Pt
690 Int_t nCluster = GetNHits();
693 // the Set function was not available in earlier versions, check done
694 // during configure; for the AliRoot build, by default ON
695 #ifdef EXTERNALTRACKPARAM_V1
696 #warning track conversion to ESD format needs AliRoot version > v4-05-04
697 //TODO (Feb 07): make this a real warning when logging system is adapted
698 //HLTWarning("track conversion to ESD format needs AliRoot version > v4-05-04");
700 Set(xl,alpha,param,cov);
701 SetNumberOfClusters(nCluster);
710 void AliHLTTPCTrack::SetHits(Int_t nhits,UInt_t *hits)
714 if (nhits>fgkHitArraySize) {
715 LOG(AliHLTTPCLog::kWarning,"AliHLTTPCTrack::SetHits","too many hits")
716 << "too many hits (" << nhits << ") for hit array of size " << fgkHitArraySize << ENDLOG;
717 SetNHits(fgkHitArraySize);
721 memcpy(fHitNumbers,hits,fNHits*sizeof(UInt_t));
724 Double_t AliHLTTPCTrack::GetLengthXY() const
726 //calculates the length of the arc in XY-plane. This is the length of the track in XY-plane.
727 //Using a^2 = b^2 + c^2 - 2bc * cosA for finding the angle between first and last point.
728 //Length of arc is arc = r*A. Where A is the angle between first and last point.
730 Double_t dx = GetLastPointX()-GetFirstPointX();
731 Double_t dy = GetLastPointY()-GetFirstPointY();
732 Double_t a = TMath::Sqrt((dx*dx)+(dy*dy));
733 Double_t r = GetRadius();
736 Double_t A = TMath::ACos((r2+r2-(a*a))/(2*r2));
741 Double_t AliHLTTPCTrack::GetLengthTot() const
743 //Calculates the length of the track in 3D
753 int AliHLTTPCTrack::CheckConsistency()
755 // Check consistency of all members
757 if (CheckDoubleMember(&fPterr, 0., "fPterr")<0) iResult=-EDOM;
758 if (CheckDoubleMember(&fPsierr, 0., "fPsierr")<0) iResult=-EDOM;
759 if (CheckDoubleMember(&fZ0err, 0., "fZ0err")<0) iResult=-EDOM;
760 if (CheckDoubleMember(&fY0err, 0., "fY0err")<0) iResult=-EDOM;
761 if (CheckDoubleMember(&fTanlerr, 0., "fTanlerr")<0) iResult=-EDOM;
765 int AliHLTTPCTrack::CheckDoubleMember(double* pMember, double def, const char* name) const
767 // Check consistency of a Double member
768 if (!pMember) return -EINVAL;
769 if (TMath::Abs(*pMember)>kVeryBig) {
770 LOG(AliHLTTPCLog::kWarning,"AliHLTTPCTrack","member consistency")
771 << "invalid Double number %f" << *pMember << " in member " << name << ENDLOG;