]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCTrack.cxx
- version HLT-v0-4 ready
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCTrack.cxx
1 // @(#) $Id$
2 // Original: AliL3Track.cxx,v 1.32 2005/06/14 10:55:21 cvetan 
3
4 // Author: Anders Vestbo <mailto:vestbo$fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no>
5 //*-- Copyright &copy ALICE HLT Group
6
7 #include "AliHLTTPCLogging.h"
8 #include "AliHLTTPCTrack.h"
9 #include "AliHLTTPCTransform.h"
10 #include "AliHLTTPCVertex.h"
11 #include "AliHLTTPCSpacePointData.h"
12
13 #if __GNUC__ >= 3
14 using namespace std;
15 #endif
16
17 /** \class AliHLTTPCTrack
18 //<pre>
19 //_____________________________________________________________
20 // AliHLTTPCTrack
21 //
22 // Track base class
23 //Begin_Html
24 //<img src="track_coordinates.gif">
25 //End_Html
26 </pre>
27 */
28
29 ClassImp(AliHLTTPCTrack)
30
31
32 AliHLTTPCTrack::AliHLTTPCTrack()
33 {
34   //Constructor
35   fNHits = 0;
36   fMCid = -1;
37   fKappa=0;
38   fRadius=0;
39   fCenterX=0;
40   fCenterY=0;
41   ComesFromMainVertex(false);
42   fQ = 0;
43   fPhi0=0;
44   fPsi=0;
45   fR0=0;
46   fTanl=0;
47   fZ0=0;
48   fPt=0;
49   fLength=0;
50   fIsLocal=true;
51   fRowRange[0]=0;
52   fRowRange[1]=0;
53   SetFirstPoint(0,0,0);
54   SetLastPoint(0,0,0);
55   memset(fHitNumbers,0,159*sizeof(UInt_t));
56   fPID = 0;
57
58   fSector=0;
59   fPterr=0;
60   fPsierr=0;
61   fZ0err=0;
62   fTanlerr=0;
63   fPoint[0]=fPoint[1]=fPoint[2]=0;
64   fPointPsi=0;
65 }
66
67 void AliHLTTPCTrack::Set(AliHLTTPCTrack *tpt)
68 {
69   //setter
70   SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
71   SetPhi0(tpt->GetPhi0());
72   SetKappa(tpt->GetKappa());
73   SetNHits(tpt->GetNHits());
74   SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
75   SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
76   SetPt(tpt->GetPt());
77   SetPsi(tpt->GetPsi());
78   SetTgl(tpt->GetTgl());
79   SetPterr(tpt->GetPterr());
80   SetPsierr(tpt->GetPsierr());
81   SetTglerr(tpt->GetTglerr());
82   SetCharge(tpt->GetCharge());
83   SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers());
84 #ifdef do_mc
85   SetMCid(tpt->GetMCid());
86 #endif
87   SetPID(tpt->GetPID());
88   SetSector(tpt->GetSector());
89 }
90
91 Int_t AliHLTTPCTrack::Compare(const AliHLTTPCTrack *track) const
92 {
93   // compare tracks
94   if(track->GetNHits() < GetNHits()) return 1;
95   if(track->GetNHits() > GetNHits()) return -1;
96   return 0;
97 }
98
99 AliHLTTPCTrack::~AliHLTTPCTrack()
100 {
101   //Nothing to do
102 }
103
104 Double_t AliHLTTPCTrack::GetP() const
105 {
106   // Returns total momentum.  
107   return fabs(GetPt())*sqrt(1. + GetTgl()*GetTgl());
108 }
109
110 Double_t AliHLTTPCTrack::GetPseudoRapidity() const
111 { //get pseudo rap
112   return 0.5 * log((GetP() + GetPz()) / (GetP() - GetPz()));
113 }
114
115 /*
116 Double_t AliHLTTPCTrack::GetEta() const
117 {
118   return GetPseudoRapidity();
119 }
120 */
121
122 Double_t AliHLTTPCTrack::GetRapidity() const
123
124   //get rap
125   const Double_t kmpi = 0.13957;
126   return 0.5 * log((kmpi + GetPz()) / (kmpi - GetPz()));
127 }
128
129 void AliHLTTPCTrack::Rotate(Int_t slice,Bool_t tolocal)
130 {
131   //Rotate track to global parameters
132   //If flag tolocal is set, the track is rotated
133   //to local coordinates.
134
135   Float_t psi[1] = {GetPsi()};
136   if(!tolocal)
137     AliHLTTPCTransform::Local2GlobalAngle(psi,slice);
138   else
139     AliHLTTPCTransform::Global2LocalAngle(psi,slice);
140   SetPsi(psi[0]);
141   Float_t first[3];
142   first[0] = GetFirstPointX();
143   first[1] = GetFirstPointY();
144   first[2] = GetFirstPointZ();
145   if(!tolocal)
146     AliHLTTPCTransform::Local2Global(first,slice);
147   else
148     AliHLTTPCTransform::Global2LocHLT(first,slice);
149   //AliHLTTPCTransform::Global2Local(first,slice,kTRUE);
150   
151   SetFirstPoint(first[0],first[1],first[2]);
152   Float_t last[3];
153   last[0] = GetLastPointX();
154   last[1] = GetLastPointY();
155   last[2] = GetLastPointZ();
156   if(!tolocal)
157     AliHLTTPCTransform::Local2Global(last,slice);
158   else
159     AliHLTTPCTransform::Global2LocHLT(last,slice);    
160   //AliHLTTPCTransform::Global2Local(last,slice,kTRUE);
161   SetLastPoint(last[0],last[1],last[2]);
162   
163   Float_t center[3] = {GetCenterX(),GetCenterY(),0};
164   if(!tolocal)
165     AliHLTTPCTransform::Local2Global(center,slice);
166   else
167     AliHLTTPCTransform::Global2LocHLT(center,slice);
168   //AliHLTTPCTransform::Global2Local(center,slice,kTRUE);
169   SetCenterX(center[0]);
170   SetCenterY(center[1]);
171   
172   SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
173   SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
174   
175   if(!tolocal)
176     fIsLocal=kFALSE;
177   else
178     fIsLocal=kTRUE;
179 }
180
181 void AliHLTTPCTrack::CalculateHelix()
182 {
183 // #### -B0-CHANGE-START == JMT
184     // for straight line fit
185     if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
186         fRadius = 999999;  //just zero
187
188         SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
189         SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
190     }
191     // for helix fit
192     else { 
193 // #### -B0-UNCHANGED-START == JMT
194         //Calculate Radius, CenterX and CenterY from Psi, X0, Y0
195         fRadius = fPt / (AliHLTTPCTransform::GetBFieldValue());
196         if(fRadius) fKappa = -fQ*1./fRadius;
197         else fRadius = 999999;  //just zero
198         Double_t trackPhi0 = fPsi + fQ * AliHLTTPCTransform::PiHalf();
199         
200         fCenterX = fFirstPoint[0] - fRadius *  cos(trackPhi0);
201         fCenterY = fFirstPoint[1] - fRadius *  sin(trackPhi0);
202         
203         SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
204         SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
205 // #### -B0-UNCHANGED-END == JMT
206     }
207 // #### -B0-CHANGE-END == JMT
208 }
209
210 Double_t AliHLTTPCTrack::GetCrossingAngle(Int_t padrow,Int_t slice) 
211 {
212   //Calculate the crossing angle between track and given padrow.
213   //Take the dot product of the tangent vector of the track, and
214   //vector perpendicular to the padrow.
215   //In order to do this, we need the tangent vector to the track at the
216   //point. This is done by rotating the radius vector by 90 degrees;
217   //rotation matrix: (  0  1 )
218   //                 ( -1  0 )
219
220   Float_t angle=0;//Angle perpendicular to the padrow in local coordinates
221   if(slice>=0)//Global coordinates
222     {
223       AliHLTTPCTransform::Local2GlobalAngle(&angle,slice);
224       if(!CalculateReferencePoint(angle,AliHLTTPCTransform::Row2X(padrow)))
225         cerr<<"AliHLTTPCTrack::GetCrossingAngle : Track does not cross line in slice "<<slice<<" row "<<padrow<<endl;
226     }
227   else //should be in local coordinates
228     {
229       Float_t xyz[3];
230       GetCrossingPoint(padrow,xyz);
231       fPoint[0] = xyz[0];
232       fPoint[1] = xyz[1];
233       fPoint[2] = xyz[2];
234     }
235     
236   Double_t tangent[2];
237   
238   tangent[0] = (fPoint[1] - GetCenterY())/GetRadius();
239   tangent[1] = -1.*(fPoint[0] - GetCenterX())/GetRadius();
240
241   Double_t perppadrow[2] = {cos(angle),sin(angle)}; 
242   Double_t cosbeta = fabs(tangent[0]*perppadrow[0] + tangent[1]*perppadrow[1]);
243   if(cosbeta > 1) cosbeta=1;
244   return acos(cosbeta);
245 }
246
247 Bool_t AliHLTTPCTrack::GetCrossingPoint(Int_t padrow,Float_t *xyz)
248 {
249   //Assumes the track is given in local coordinates
250   if(!IsLocal())
251     {
252       cerr<<"GetCrossingPoint: Track is given on global coordinates"<<endl;
253       return false;
254     }
255   
256   Double_t xHit = AliHLTTPCTransform::Row2X(padrow);
257
258 // BEGINN ############################################## MODIFIY JMT
259 //if (xHit < xyz[0]){
260 //    LOG(AliHLTTPCLog::kError,"AliHLTTPCTRACK::GetCrossingPoint","")<< "Track doesn't cross padrow " 
261 //                              << padrow <<"(x=" << xHit << "). Smallest x=" << xyz[0] << ENDLOG;
262 //      return false;
263 //}
264 // END ################################################# MODIFIY JMT
265
266 // #### -B0-CHANGE-START == JMT
267   // for straight line fit
268     if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
269
270         Double_t yHit = GetFirstPointY() + (Double_t) tan( GetPsi() ) * (xHit - GetFirstPointX());   
271         
272         Double_t s = (xHit - GetFirstPointX())*(xHit - GetFirstPointX()) + (yHit - GetFirstPointY())*(yHit - GetFirstPointY()); 
273         
274         Double_t zHit = GetFirstPointZ() + s * GetTgl();
275
276         xyz[0] = xHit;
277         xyz[1] = yHit;
278         xyz[2] = zHit;
279     }
280     // for helix fit
281     else { 
282 // #### -B0-UNCHANGED-START == JMT
283         xyz[0] = xHit;
284         Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX());
285         Double_t r2 = GetRadius()*GetRadius();
286         if(aa > r2)
287             return false;
288         
289         Double_t aa2 = sqrt(r2 - aa);
290         Double_t y1 = GetCenterY() + aa2;
291         Double_t y2 = GetCenterY() - aa2;
292         xyz[1] = y1;
293         if(fabs(y2) < fabs(y1)) xyz[1] = y2;
294         
295         Double_t yHit = xyz[1];
296         Double_t angle1 = atan2((yHit - GetCenterY()),(xHit - GetCenterX()));
297         if(angle1 < 0) angle1 += 2.*AliHLTTPCTransform::Pi();
298         Double_t angle2 = atan2((GetFirstPointY() - GetCenterY()),(GetFirstPointX() - GetCenterX()));
299         if(angle2 < 0) angle2 += AliHLTTPCTransform::TwoPi();
300         
301         Double_t diffangle = angle1 - angle2;
302         diffangle = fmod(diffangle,AliHLTTPCTransform::TwoPi());
303         if((GetCharge()*diffangle) > 0) diffangle = diffangle - GetCharge()*AliHLTTPCTransform::TwoPi();
304         
305         Double_t stot = fabs(diffangle)*GetRadius();
306         
307         Double_t zHit = GetFirstPointZ() + stot*GetTgl();
308         
309         xyz[2] = zHit;
310 // #### -B0-UNCHANGED-END == JMT
311     }
312 // #### -B0-CHANGE-END == JMT
313
314     return true;
315 }
316
317 Bool_t AliHLTTPCTrack::CalculateReferencePoint(Double_t angle,Double_t radius)
318 {
319   // Global coordinate: crossing point with y = ax+ b; 
320   // a=tan(angle-AliHLTTPCTransform::PiHalf());
321   //
322   const Double_t krr=radius; //position of reference plane
323   const Double_t kxr = cos(angle) * krr;
324   const Double_t kyr = sin(angle) * krr;
325   
326   Double_t a = tan(angle-AliHLTTPCTransform::PiHalf());
327   Double_t b = kyr - a * kxr;
328
329   Double_t pp=(fCenterX+a*fCenterY-a*b)/(1+pow(a,2));
330   Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-2*fCenterY*b+pow(b,2)-pow(fRadius,2))/(1+pow(a,2));
331
332   Double_t racine = pp*pp-qq;
333   if(racine<0) return IsPoint(kFALSE);      //no Point
334
335   Double_t rootRacine = sqrt(racine);
336   Double_t x0 = pp+rootRacine;
337   Double_t x1 = pp-rootRacine;
338   Double_t y0 = a*x0 + b;
339   Double_t y1 = a*x1 + b;
340
341   Double_t diff0 = sqrt(pow(x0-kxr,2)+pow(y0-kyr,2));
342   Double_t diff1 = sqrt(pow(x1-kxr,2)+pow(y1-kyr,2));
343  
344   if(diff0<diff1){
345     fPoint[0]=x0;
346     fPoint[1]=y0;
347   }
348   else{
349     fPoint[0]=x1;
350     fPoint[1]=y1;
351   }
352
353   Double_t pointPhi0  = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
354   Double_t trackPhi0  = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
355   if(fabs(trackPhi0-pointPhi0)>AliHLTTPCTransform::Pi()){
356     if(trackPhi0<pointPhi0) trackPhi0 += AliHLTTPCTransform::TwoPi();
357     else                    pointPhi0 += AliHLTTPCTransform::TwoPi();
358   }
359   Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
360   fPoint[2]   = fFirstPoint[2] + stot * fTanl;
361
362   fPointPsi = pointPhi0 - fQ * AliHLTTPCTransform::PiHalf();
363   if(fPointPsi<0.)  fPointPsi+= AliHLTTPCTransform::TwoPi();
364   fPointPsi = fmod(fPointPsi, AliHLTTPCTransform::TwoPi());
365
366   return IsPoint(kTRUE);
367 }
368
369 Bool_t AliHLTTPCTrack::CalculateEdgePoint(Double_t angle)
370 {
371   // Global coordinate: crossing point with y = ax; a=tan(angle);
372   //
373   Double_t rmin=AliHLTTPCTransform::Row2X(AliHLTTPCTransform::GetFirstRow(-1));  //min Radius of TPC
374   Double_t rmax=AliHLTTPCTransform::Row2X(AliHLTTPCTransform::GetLastRow(-1)); //max Radius of TPC
375
376   Double_t a = tan(angle);
377   Double_t pp=(fCenterX+a*fCenterY)/(1+pow(a,2));
378   Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-pow(fRadius,2))/(1+pow(a,2));
379   Double_t racine = pp*pp-qq;
380   if(racine<0) return IsPoint(kFALSE);     //no Point
381   Double_t rootRacine = sqrt(racine);
382   Double_t x0 = pp+rootRacine;
383   Double_t x1 = pp-rootRacine;
384   Double_t y0 = a*x0;
385   Double_t y1 = a*x1;
386
387   Double_t r0 = sqrt(pow(x0,2)+pow(y0,2));
388   Double_t r1 = sqrt(pow(x1,2)+pow(y1,2)); 
389   //find the right crossing point:
390   //inside the TPC modules
391   Bool_t ok0 = kFALSE;
392   Bool_t ok1 = kFALSE;
393
394   if(r0>rmin&&r0<rmax){
395     Double_t da=atan2(y0,x0);
396     if(da<0) da+=AliHLTTPCTransform::TwoPi();
397     if(fabs(da-angle)<0.5)
398       ok0 = kTRUE;
399   }
400   if(r1>rmin&&r1<rmax){
401     Double_t da=atan2(y1,x1);
402     if(da<0) da+=AliHLTTPCTransform::TwoPi();
403     if(fabs(da-angle)<0.5)
404       ok1 = kTRUE;
405   }
406   if(!(ok0||ok1)) return IsPoint(kFALSE);   //no Point
407   
408   if(ok0&&ok1){
409     Double_t diff0 = sqrt(pow(fFirstPoint[0]-x0,2)+pow(fFirstPoint[1]-y0,2));
410     Double_t diff1 = sqrt(pow(fFirstPoint[0]-x1,2)+pow(fFirstPoint[1]-y1,2));
411     if(diff0<diff1) ok1 = kFALSE; //use ok0
412     else ok0 = kFALSE;            //use ok1
413   }
414   if(ok0){fPoint[0]=x0; fPoint[1]=y0;}
415   else   {fPoint[0]=x1; fPoint[1]=y1;}
416
417   Double_t pointPhi0  = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
418   Double_t trackPhi0  = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
419   if(fabs(trackPhi0-pointPhi0)>AliHLTTPCTransform::Pi()){
420     if(trackPhi0<pointPhi0) trackPhi0 += AliHLTTPCTransform::TwoPi();
421     else                    pointPhi0 += AliHLTTPCTransform::TwoPi();
422   }
423   Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
424   fPoint[2]   = fFirstPoint[2] + stot * fTanl;
425
426   fPointPsi = pointPhi0 - fQ * AliHLTTPCTransform::PiHalf();
427   if(fPointPsi<0.)  fPointPsi+= AliHLTTPCTransform::TwoPi();
428   fPointPsi = fmod(fPointPsi, AliHLTTPCTransform::TwoPi());
429
430   return IsPoint(kTRUE);
431 }
432
433 Bool_t AliHLTTPCTrack::CalculatePoint(Double_t xplane)
434 {
435   // Local coordinate: crossing point with x plane
436   //
437   Double_t racine = pow(fRadius,2)-pow(xplane-fCenterX,2);
438   if(racine<0) return IsPoint(kFALSE);
439   Double_t rootRacine = sqrt(racine);
440
441   Double_t y0 = fCenterY + rootRacine;
442   Double_t y1 = fCenterY - rootRacine;
443   //Double_t diff0 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y0));
444   //Double_t diff1 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y1));
445   Double_t diff0 = fabs(y0-fFirstPoint[1]);
446   Double_t diff1 = fabs(y1-fFirstPoint[1]);
447
448   fPoint[0]=xplane;
449   if(diff0<diff1) fPoint[1]=y0;
450   else            fPoint[1]=y1;
451
452   Double_t pointPhi0  = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
453   Double_t trackPhi0  = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
454   if(fabs(trackPhi0-pointPhi0)>AliHLTTPCTransform::Pi()){
455     if(trackPhi0<pointPhi0) trackPhi0 += AliHLTTPCTransform::TwoPi();
456     else                    pointPhi0 += AliHLTTPCTransform::TwoPi();
457   }
458   Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;  
459   fPoint[2]   = fFirstPoint[2] + stot * fTanl;
460
461   fPointPsi = pointPhi0 - fQ * AliHLTTPCTransform::PiHalf();
462   if(fPointPsi<0.)  fPointPsi+= AliHLTTPCTransform::TwoPi();
463   fPointPsi = fmod(fPointPsi, AliHLTTPCTransform::TwoPi());
464
465   return IsPoint(kTRUE);
466 }
467
468 void AliHLTTPCTrack::UpdateToFirstPoint()
469 {
470   //Update track parameters to the innermost point on the track.
471   //This means that the parameters of the track will be given in the point
472   //of closest approach to the first innermost point, i.e. the point 
473   //lying on the track fit (and not the coordinates of the innermost point itself).
474   //This function assumes that fFirstPoint is already set to the coordinates of the innermost
475   //assigned cluster.
476   //
477   //During the helix-fit, the first point on the track is set to the coordinates
478   //of the innermost assigned cluster. This may be ok, if you just want a fast
479   //estimate of the "global" track parameters; such as the momentum etc.
480   //However, if you later on want to do more precise local calculations, such
481   //as impact parameter, residuals etc, you need to give the track parameters
482   //according to the actual fit.
483 // #### -B0-CHANGE-START == JMT
484     // for straight line fit
485     if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
486         Double_t xc = GetCenterX() - GetFirstPointX();
487         Double_t yc = GetCenterY() - GetFirstPointY();
488
489         Double_t xn = (Double_t) sin( GetPsi() );
490         Double_t yn = -1. * (Double_t) cos( GetPsi() );
491
492         Double_t d = xc*xn + yc*yn;
493
494         Double_t distx = d * xn;
495         Double_t disty = d * yn;
496
497         Double_t point[2];
498
499         point[0] = distx + GetFirstPointX();
500         point[1] = disty + GetFirstPointY();
501
502         //Update the track parameters
503         SetR0(sqrt(point[0]*point[0]+point[1]*point[1]));
504         SetPhi0(atan2(point[1],point[0]));
505         SetFirstPoint(point[0],point[1],GetZ0());
506     }
507     // for helix fit
508     else { 
509 // #### -B0-UNCHANGED-START == JMT
510         Double_t xc = GetCenterX() - GetFirstPointX();
511         Double_t yc = GetCenterY() - GetFirstPointY();
512         
513         Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
514         Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
515         Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1);
516         
517         Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
518         Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
519         Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2);
520         
521         //Choose the closest:
522         Double_t point[2];
523         if(distance1 < distance2)
524         {
525             point[0] = distx1 + GetFirstPointX();
526             point[1] = disty1 + GetFirstPointY();
527         }
528         else
529         {
530             point[0] = distx2 + GetFirstPointX();
531             point[1] = disty2 + GetFirstPointY();
532         }
533
534         Double_t pointpsi = atan2(point[1]-GetCenterY(),point[0]-GetCenterX());
535         pointpsi -= GetCharge()*AliHLTTPCTransform::PiHalf();
536         if(pointpsi < 0) pointpsi += AliHLTTPCTransform::TwoPi();
537         
538         //Update the track parameters
539         SetR0(sqrt(point[0]*point[0]+point[1]*point[1]));
540         SetPhi0(atan2(point[1],point[0]));
541         SetFirstPoint(point[0],point[1],GetZ0());
542         SetPsi(pointpsi);
543 // #### -B0-UNCHANGED-END == JMT
544     }
545 // #### -B0-CHANGE-END == JMT
546 }
547
548 void AliHLTTPCTrack::GetClosestPoint(AliHLTTPCVertex *vertex,Double_t &closestx,Double_t &closesty,Double_t &closestz)
549 {
550   //Calculate the point of closest approach to the vertex
551   //This function calculates the minimum distance from the helix to the vertex, and choose 
552   //the corresponding point lying on the helix as the point of closest approach.
553   
554   Double_t xc = GetCenterX() - vertex->GetX();
555   Double_t yc = GetCenterY() - vertex->GetY();
556   
557   Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
558   Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
559   Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1);
560   
561   Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
562   Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
563   Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2);
564   
565   //Choose the closest:
566   if(distance1 < distance2)
567     {
568       closestx = distx1 + vertex->GetX();
569       closesty = disty1 + vertex->GetY();
570     }
571   else
572     {
573       closestx = distx2 + vertex->GetX();
574       closesty = disty2 + vertex->GetY();
575     }
576   
577   //Get the z coordinate:
578   Double_t angle1 = atan2((closesty-GetCenterY()),(closestx-GetCenterX()));
579   if(angle1 < 0) angle1 = angle1 + AliHLTTPCTransform::TwoPi();
580  
581   Double_t angle2 = atan2((GetFirstPointY()-GetCenterY()),(GetFirstPointX()-GetCenterX()));
582   if(angle2 < 0) angle2 = angle2 + AliHLTTPCTransform::TwoPi();
583   
584   Double_t diff_angle = angle1 - angle2;
585   diff_angle = fmod(diff_angle,AliHLTTPCTransform::TwoPi());
586   
587   if((GetCharge()*diff_angle) < 0) diff_angle = diff_angle + GetCharge()*AliHLTTPCTransform::TwoPi();
588   Double_t stot = fabs(diff_angle)*GetRadius();
589   closestz = GetFirstPointZ() - stot*GetTgl();
590 }
591
592 void AliHLTTPCTrack::Print() const
593 { //print out parameters of track
594 // BEGINN ############################################## MODIFIY JMT
595
596 #if 1
597  LOG(AliHLTTPCLog::kInformational,"AliHLTTPCTrack::Print","Print values")
598     <<"NH="<<fNHits<<" "<<fMCid<<" K="<<fKappa<<" R="<<fRadius<<" Cx="<<fCenterX<<" Cy="<<fCenterY<<" MVT="
599     <<fFromMainVertex<<" Row0="<<fRowRange[0]<<" Row1="<<fRowRange[1]<<" Sector="<<fSector<<" Q="<<fQ<<" TgLam="
600     <<fTanl<<" psi="<<fPsi<<" pt="<<fPt<<" L="<<fLength<<" "<<fPterr<<" "<<fPsierr<<" "<<fZ0err<<" "
601     <<fTanlerr<<" phi0="<<fPhi0<<" R0="<<fR0<<" Z0"<<fZ0<<" X0"<<fFirstPoint[0]<<" Y0"<<fFirstPoint[1]<<" Z0"
602     <<fFirstPoint[2]<<" XL"<<fLastPoint[0]<<" YL"<<fLastPoint[1]<<" ZL"<<fLastPoint[2]<<" "
603     <<fPoint[0]<<" "<<fPoint[1]<<" "<<fPoint[2]<<" "<<fPointPsi<<" "<<fIsPoint<<" local="
604     <<fIsLocal<<" "<<fPID<<ENDLOG; 
605
606
607
608 #else
609   LOG(AliHLTTPCLog::kInformational,"AliHLTTPCTrack::Print","Print values")
610     <<fNHits<<" "<<fMCid<<" "<<fKappa<<" "<<fRadius<<" "<<fCenterX<<" "<<fCenterY<<" "
611     <<fFromMainVertex<<" "<<fRowRange[0]<<" "<<fRowRange[1]<<" "<<fSector<<" "<<fQ<<" "
612     <<fTanl<<" "<<fPsi<<" "<<fPt<<" "<<fLength<<" "<<fPterr<<" "<<fPsierr<<" "<<fZ0err<<" "
613     <<fTanlerr<<" "<<fPhi0<<" "<<fR0<<" "<<fZ0<<" "<<fFirstPoint[0]<<" "<<fFirstPoint[1]<<" "
614     <<fFirstPoint[2]<<" "<<fLastPoint[0]<<" "<<fLastPoint[1]<<" "<<fLastPoint[2]<<" "
615     <<fPoint[0]<<" "<<fPoint[1]<<" "<<fPoint[2]<<" "<<fPointPsi<<" "<<fIsPoint<<" "
616     <<fIsLocal<<" "<<fPID<<ENDLOG; 
617 #endif
618
619 // END ################################################# MODIFIY JMT
620 }