AliTPCBuffer160 renamed to AliAltroBuffer and method WriteChannel added, new utility...
[u/mrichter/AliRoot.git] / HLT / src / AliL3Track.cxx
CommitLineData
3e87ef69 1// @(#) $Id$
6d4f1901 2
2d04dcbf 3// Author: Anders Vestbo <mailto:vestbo$fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no>
3e87ef69 4//*-- Copyright &copy ALICE HLT Group
108615fc 5
118c26c3 6#include "AliL3StandardIncludes.h"
14e76e91 7#include "AliL3RootTypes.h"
108615fc 8#include "AliL3RootTypes.h"
108615fc 9#include "AliL3Logging.h"
10#include "AliL3Track.h"
0391971c 11#include "AliL3Transform.h"
6d4f1901 12#include "AliL3Vertex.h"
de3c3890 13#include "AliL3SpacePointData.h"
118c26c3 14
0bd0c1ef 15#if __GNUC__ == 3
3e87ef69 16using namespace std;
17#endif
108615fc 18
3e87ef69 19/** \class AliL3Track
20//<pre>
2d04dcbf 21//_____________________________________________________________
22// AliL3Track
23//
24// Track base class
02cb36b2 25//Begin_Html
3e87ef69 26//<img src="track_coordinates.gif">
02cb36b2 27//End_Html
3e87ef69 28</pre>
29*/
0391971c 30
108615fc 31ClassImp(AliL3Track)
32
108615fc 33
34AliL3Track::AliL3Track()
35{
36 //Constructor
37
38 fNHits = 0;
39 fMCid = -1;
40 fKappa=0;
41 fRadius=0;
42 fCenterX=0;
43 fCenterY=0;
44 ComesFromMainVertex(false);
45 fQ = 0;
46 fPhi0=0;
47 fPsi=0;
48 fR0=0;
49 fTanl=0;
50 fZ0=0;
51 fPt=0;
52 fLength=0;
53 fIsLocal=true;
54 fRowRange[0]=0;
55 fRowRange[1]=0;
3e87ef69 56 SetFirstPoint(0,0,0);
57 SetLastPoint(0,0,0);
68a27388 58 memset(fHitNumbers,0,159*sizeof(UInt_t));
de3c3890 59 fPID = 0;
108615fc 60}
61
b1ed0288 62void AliL3Track::Set(AliL3Track *tpt)
63{
64 //setter
3a735e00 65 SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
66 SetPhi0(tpt->GetPhi0());
67 SetKappa(tpt->GetKappa());
68 SetNHits(tpt->GetNHits());
69 SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
70 SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
71 SetPt(tpt->GetPt());
72 SetPsi(tpt->GetPsi());
73 SetTgl(tpt->GetTgl());
74 SetCharge(tpt->GetCharge());
75 SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers());
4a0bee4e 76#ifdef do_mc
77 SetMCid(tpt->GetMCid());
78#endif
de3c3890 79 SetPID(tpt->GetPID());
80 SetSector(tpt->GetSector());
108615fc 81}
82
203925a9 83Int_t AliL3Track::Compare(const AliL3Track *track) const
84{
b1ed0288 85 // compare tracks
203925a9 86 if(track->GetNHits() < GetNHits()) return 1;
87 if(track->GetNHits() > GetNHits()) return -1;
88 return 0;
89}
108615fc 90
91AliL3Track::~AliL3Track()
92{
203925a9 93 //Nothing to do
108615fc 94}
95
96Double_t AliL3Track::GetP() const
97{
203925a9 98 // Returns total momentum.
108615fc 99 return fabs(GetPt())*sqrt(1. + GetTgl()*GetTgl());
108615fc 100}
101
102Double_t AliL3Track::GetPseudoRapidity() const
b1ed0288 103{ //get pseudo rap
108615fc 104 return 0.5 * log((GetP() + GetPz()) / (GetP() - GetPz()));
105}
eeddc64d 106
203925a9 107/*
108615fc 108Double_t AliL3Track::GetEta() const
109{
110 return GetPseudoRapidity();
111}
203925a9 112*/
eeddc64d 113
108615fc 114Double_t AliL3Track::GetRapidity() const
b1ed0288 115{
116 //get rap
14e76e91 117 const Double_t kmpi = 0.13957;
118 return 0.5 * log((kmpi + GetPz()) / (kmpi - GetPz()));
108615fc 119}
120
203925a9 121void AliL3Track::Rotate(Int_t slice,Bool_t tolocal)
0391971c 122{
0391971c 123 //Rotate track to global parameters
203925a9 124 //If flag tolocal is set, the track is rotated
125 //to local coordinates.
0391971c 126
0391971c 127 Float_t psi[1] = {GetPsi()};
203925a9 128 if(!tolocal)
494fad94 129 AliL3Transform::Local2GlobalAngle(psi,slice);
203925a9 130 else
494fad94 131 AliL3Transform::Global2LocalAngle(psi,slice);
0391971c 132 SetPsi(psi[0]);
133 Float_t first[3];
134 first[0] = GetFirstPointX();
135 first[1] = GetFirstPointY();
136 first[2] = GetFirstPointZ();
203925a9 137 if(!tolocal)
494fad94 138 AliL3Transform::Local2Global(first,slice);
203925a9 139 else
5a31e9df 140 AliL3Transform::Global2LocHLT(first,slice);
141 //AliL3Transform::Global2Local(first,slice,kTRUE);
203925a9 142
0391971c 143 SetFirstPoint(first[0],first[1],first[2]);
144 Float_t last[3];
145 last[0] = GetLastPointX();
146 last[1] = GetLastPointY();
147 last[2] = GetLastPointZ();
203925a9 148 if(!tolocal)
494fad94 149 AliL3Transform::Local2Global(last,slice);
203925a9 150 else
5a31e9df 151 AliL3Transform::Global2LocHLT(last,slice);
152 //AliL3Transform::Global2Local(last,slice,kTRUE);
0391971c 153 SetLastPoint(last[0],last[1],last[2]);
203925a9 154
6d4f1901 155 Float_t center[3] = {GetCenterX(),GetCenterY(),0};
156 if(!tolocal)
494fad94 157 AliL3Transform::Local2Global(center,slice);
6d4f1901 158 else
5a31e9df 159 AliL3Transform::Global2LocHLT(center,slice);
160 //AliL3Transform::Global2Local(center,slice,kTRUE);
6d4f1901 161 SetCenterX(center[0]);
162 SetCenterY(center[1]);
163
3e87ef69 164 SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
165 SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
166
203925a9 167 if(!tolocal)
168 fIsLocal=kFALSE;
169 else
170 fIsLocal=kTRUE;
0391971c 171}
172
b1ed0288 173void AliL3Track::CalculateHelix()
174{
eeddc64d 175 //Calculate Radius, CenterX and CenterY from Psi, X0, Y0
5a31e9df 176 fRadius = fPt / (AliL3Transform::GetBFieldValue());
3ceb3fe1 177 if(fRadius) fKappa = -fQ*1./fRadius;
108615fc 178 else fRadius = 999999; //just zero
5a31e9df 179 Double_t trackPhi0 = fPsi + fQ * AliL3Transform::PiHalf();
108615fc 180
181 fCenterX = fFirstPoint[0] - fRadius * cos(trackPhi0);
182 fCenterY = fFirstPoint[1] - fRadius * sin(trackPhi0);
3e87ef69 183
184 SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
185 SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
108615fc 186}
187
3e87ef69 188Double_t AliL3Track::GetCrossingAngle(Int_t padrow,Int_t slice)
0391971c 189{
190 //Calculate the crossing angle between track and given padrow.
0391971c 191 //Take the dot product of the tangent vector of the track, and
192 //vector perpendicular to the padrow.
dab230b2 193 //In order to do this, we need the tangent vector to the track at the
194 //point. This is done by rotating the radius vector by 90 degrees;
195 //rotation matrix: ( 0 1 )
196 // ( -1 0 )
3e87ef69 197
198 Float_t angle=0;//Angle perpendicular to the padrow in local coordinates
199 if(slice>=0)//Global coordinates
200 {
201 AliL3Transform::Local2GlobalAngle(&angle,slice);
202 if(!CalculateReferencePoint(angle,AliL3Transform::Row2X(padrow)))
203 cerr<<"AliL3Track::GetCrossingAngle : Track does not cross line in slice "<<slice<<" row "<<padrow<<endl;
204 }
205 else //should be in local coordinates
206 {
207 Float_t xyz[3];
208 GetCrossingPoint(padrow,xyz);
209 fPoint[0] = xyz[0];
210 fPoint[1] = xyz[1];
211 fPoint[2] = xyz[2];
212 }
213
0391971c 214 Double_t tangent[2];
dab230b2 215
3e87ef69 216 tangent[0] = (fPoint[1] - GetCenterY())/GetRadius();
217 tangent[1] = -1.*(fPoint[0] - GetCenterX())/GetRadius();
218
14e76e91 219 Double_t perppadrow[2] = {cos(angle),sin(angle)};
220 Double_t cosbeta = fabs(tangent[0]*perppadrow[0] + tangent[1]*perppadrow[1]);
221 if(cosbeta > 1) cosbeta=1;
222 return acos(cosbeta);
0391971c 223}
224
3e87ef69 225Bool_t AliL3Track::GetCrossingPoint(Int_t padrow,Float_t *xyz)
0391971c 226{
227 //Assumes the track is given in local coordinates
3e87ef69 228
0391971c 229 if(!IsLocal())
230 {
3e87ef69 231 cerr<<"GetCrossingPoint: Track is given on global coordinates"<<endl;
0391971c 232 return false;
233 }
234
494fad94 235 Double_t xHit = AliL3Transform::Row2X(padrow);
0391971c 236
237 xyz[0] = xHit;
238 Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX());
239 Double_t r2 = GetRadius()*GetRadius();
240 if(aa > r2)
241 return false;
242
243 Double_t aa2 = sqrt(r2 - aa);
244 Double_t y1 = GetCenterY() + aa2;
245 Double_t y2 = GetCenterY() - aa2;
246 xyz[1] = y1;
247 if(fabs(y2) < fabs(y1)) xyz[1] = y2;
3e87ef69 248
0391971c 249 Double_t yHit = xyz[1];
250 Double_t angle1 = atan2((yHit - GetCenterY()),(xHit - GetCenterX()));
9ca67380 251 if(angle1 < 0) angle1 += 2.*AliL3Transform::Pi();
0391971c 252 Double_t angle2 = atan2((GetFirstPointY() - GetCenterY()),(GetFirstPointX() - GetCenterX()));
5a31e9df 253 if(angle2 < 0) angle2 += AliL3Transform::TwoPi();
14e76e91 254 Double_t diffangle = angle1 - angle2;
255 diffangle = fmod(diffangle,AliL3Transform::TwoPi());
256 if((GetCharge()*diffangle) > 0) diffangle = diffangle - GetCharge()*AliL3Transform::TwoPi();
257 Double_t stot = fabs(diffangle)*GetRadius();
258 Double_t zHit = GetFirstPointZ() + stot*GetTgl();
0391971c 259 xyz[2] = zHit;
3e87ef69 260
0391971c 261 return true;
3e87ef69 262
0391971c 263}
264
b1ed0288 265Bool_t AliL3Track::CalculateReferencePoint(Double_t angle,Double_t radius)
266{
5a31e9df 267 // Global coordinate: crossing point with y = ax+ b;
268 // a=tan(angle-AliL3Transform::PiHalf());
108615fc 269 //
14e76e91 270 const Double_t krr=radius; //position of reference plane
271 const Double_t kxr = cos(angle) * krr;
272 const Double_t kyr = sin(angle) * krr;
6d4f1901 273
5a31e9df 274 Double_t a = tan(angle-AliL3Transform::PiHalf());
14e76e91 275 Double_t b = kyr - a * kxr;
108615fc 276
277 Double_t pp=(fCenterX+a*fCenterY-a*b)/(1+pow(a,2));
278 Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-2*fCenterY*b+pow(b,2)-pow(fRadius,2))/(1+pow(a,2));
279
280 Double_t racine = pp*pp-qq;
281 if(racine<0) return IsPoint(kFALSE); //no Point
282
283 Double_t rootRacine = sqrt(racine);
284 Double_t x0 = pp+rootRacine;
285 Double_t x1 = pp-rootRacine;
286 Double_t y0 = a*x0 + b;
287 Double_t y1 = a*x1 + b;
288
14e76e91 289 Double_t diff0 = sqrt(pow(x0-kxr,2)+pow(y0-kyr,2));
290 Double_t diff1 = sqrt(pow(x1-kxr,2)+pow(y1-kyr,2));
108615fc 291
292 if(diff0<diff1){
293 fPoint[0]=x0;
294 fPoint[1]=y0;
295 }
296 else{
297 fPoint[0]=x1;
298 fPoint[1]=y1;
299 }
300
301 Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
302 Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
5a31e9df 303 if(fabs(trackPhi0-pointPhi0)>AliL3Transform::Pi()){
304 if(trackPhi0<pointPhi0) trackPhi0 += AliL3Transform::TwoPi();
305 else pointPhi0 += AliL3Transform::TwoPi();
108615fc 306 }
307 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
308 fPoint[2] = fFirstPoint[2] + stot * fTanl;
309
5a31e9df 310 fPointPsi = pointPhi0 - fQ * AliL3Transform::PiHalf();
311 if(fPointPsi<0.) fPointPsi+= AliL3Transform::TwoPi();
312 fPointPsi = fmod(fPointPsi, AliL3Transform::TwoPi());
108615fc 313
314 return IsPoint(kTRUE);
315}
316
b1ed0288 317Bool_t AliL3Track::CalculateEdgePoint(Double_t angle)
318{
108615fc 319 // Global coordinate: crossing point with y = ax; a=tan(angle);
320 //
4a0bee4e 321 Double_t rmin=AliL3Transform::Row2X(AliL3Transform::GetFirstRow(-1)); //min Radius of TPC
322 Double_t rmax=AliL3Transform::Row2X(AliL3Transform::GetLastRow(-1)); //max Radius of TPC
108615fc 323
324 Double_t a = tan(angle);
325 Double_t pp=(fCenterX+a*fCenterY)/(1+pow(a,2));
326 Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-pow(fRadius,2))/(1+pow(a,2));
327 Double_t racine = pp*pp-qq;
328 if(racine<0) return IsPoint(kFALSE); //no Point
329 Double_t rootRacine = sqrt(racine);
330 Double_t x0 = pp+rootRacine;
331 Double_t x1 = pp-rootRacine;
332 Double_t y0 = a*x0;
333 Double_t y1 = a*x1;
334
335 Double_t r0 = sqrt(pow(x0,2)+pow(y0,2));
336 Double_t r1 = sqrt(pow(x1,2)+pow(y1,2));
337 //find the right crossing point:
338 //inside the TPC modules
339 Bool_t ok0 = kFALSE;
340 Bool_t ok1 = kFALSE;
472d9e24 341
108615fc 342 if(r0>rmin&&r0<rmax){
343 Double_t da=atan2(y0,x0);
5a31e9df 344 if(da<0) da+=AliL3Transform::TwoPi();
108615fc 345 if(fabs(da-angle)<0.5)
346 ok0 = kTRUE;
347 }
348 if(r1>rmin&&r1<rmax){
472d9e24 349 Double_t da=atan2(y1,x1);
5a31e9df 350 if(da<0) da+=AliL3Transform::TwoPi();
108615fc 351 if(fabs(da-angle)<0.5)
352 ok1 = kTRUE;
353 }
354 if(!(ok0||ok1)) return IsPoint(kFALSE); //no Point
355
356 if(ok0&&ok1){
357 Double_t diff0 = sqrt(pow(fFirstPoint[0]-x0,2)+pow(fFirstPoint[1]-y0,2));
358 Double_t diff1 = sqrt(pow(fFirstPoint[0]-x1,2)+pow(fFirstPoint[1]-y1,2));
359 if(diff0<diff1) ok1 = kFALSE; //use ok0
360 else ok0 = kFALSE; //use ok1
361 }
362 if(ok0){fPoint[0]=x0; fPoint[1]=y0;}
363 else {fPoint[0]=x1; fPoint[1]=y1;}
364
365 Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
366 Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
5a31e9df 367 if(fabs(trackPhi0-pointPhi0)>AliL3Transform::Pi()){
368 if(trackPhi0<pointPhi0) trackPhi0 += AliL3Transform::TwoPi();
369 else pointPhi0 += AliL3Transform::TwoPi();
108615fc 370 }
371 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
372 fPoint[2] = fFirstPoint[2] + stot * fTanl;
373
5a31e9df 374 fPointPsi = pointPhi0 - fQ * AliL3Transform::PiHalf();
375 if(fPointPsi<0.) fPointPsi+= AliL3Transform::TwoPi();
376 fPointPsi = fmod(fPointPsi, AliL3Transform::TwoPi());
108615fc 377
378 return IsPoint(kTRUE);
379}
380
b1ed0288 381Bool_t AliL3Track::CalculatePoint(Double_t xplane)
382{
108615fc 383 // Local coordinate: crossing point with x plane
384 //
385 Double_t racine = pow(fRadius,2)-pow(xplane-fCenterX,2);
386 if(racine<0) return IsPoint(kFALSE);
387 Double_t rootRacine = sqrt(racine);
388
389 Double_t y0 = fCenterY + rootRacine;
390 Double_t y1 = fCenterY - rootRacine;
391 //Double_t diff0 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y0));
392 //Double_t diff1 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y1));
393 Double_t diff0 = fabs(y0-fFirstPoint[1]);
394 Double_t diff1 = fabs(y1-fFirstPoint[1]);
395
396 fPoint[0]=xplane;
397 if(diff0<diff1) fPoint[1]=y0;
398 else fPoint[1]=y1;
399
400 Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
401 Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
5a31e9df 402 if(fabs(trackPhi0-pointPhi0)>AliL3Transform::Pi()){
403 if(trackPhi0<pointPhi0) trackPhi0 += AliL3Transform::TwoPi();
404 else pointPhi0 += AliL3Transform::TwoPi();
108615fc 405 }
406 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
407 fPoint[2] = fFirstPoint[2] + stot * fTanl;
408
5a31e9df 409 fPointPsi = pointPhi0 - fQ * AliL3Transform::PiHalf();
410 if(fPointPsi<0.) fPointPsi+= AliL3Transform::TwoPi();
411 fPointPsi = fmod(fPointPsi, AliL3Transform::TwoPi());
108615fc 412
413 return IsPoint(kTRUE);
414}
415
3e87ef69 416void AliL3Track::UpdateToFirstPoint()
417{
418 //Update track parameters to the innermost point on the track.
1f1942b8 419 //This means that the parameters of the track will be given in the point
420 //of closest approach to the first innermost point, i.e. the point
421 //lying on the track fit (and not the coordinates of the innermost point itself).
422 //This function assumes that fFirstPoint is already set to the coordinates of the innermost
423 //assigned cluster.
424 //
425 //During the helix-fit, the first point on the track is set to the coordinates
426 //of the innermost assigned cluster. This may be ok, if you just want a fast
427 //estimate of the "global" track parameters; such as the momentum etc.
428 //However, if you later on want to do more precise local calculations, such
429 //as impact parameter, residuals etc, you need to give the track parameters
430 //according to the actual fit.
3e87ef69 431
1f1942b8 432 Double_t xc = GetCenterX() - GetFirstPointX();
433 Double_t yc = GetCenterY() - GetFirstPointY();
3e87ef69 434
14e76e91 435 Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
436 Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
437 Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1);
3e87ef69 438
14e76e91 439 Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
440 Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
441 Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2);
3e87ef69 442
1f1942b8 443 //Choose the closest:
444 Double_t point[2];
445 if(distance1 < distance2)
446 {
14e76e91 447 point[0] = distx1 + GetFirstPointX();
448 point[1] = disty1 + GetFirstPointY();
1f1942b8 449 }
450 else
451 {
14e76e91 452 point[0] = distx2 + GetFirstPointX();
453 point[1] = disty2 + GetFirstPointY();
1f1942b8 454 }
455
456 Double_t pointpsi = atan2(point[1]-GetCenterY(),point[0]-GetCenterX());
5a31e9df 457 pointpsi -= GetCharge()*AliL3Transform::PiHalf();
458 if(pointpsi < 0) pointpsi += AliL3Transform::TwoPi();
3e87ef69 459
1f1942b8 460 //Update the track parameters
461 SetR0(sqrt(point[0]*point[0]+point[1]*point[1]));
462 SetPhi0(atan2(point[1],point[0]));
463 SetFirstPoint(point[0],point[1],GetZ0());
464 SetPsi(pointpsi);
3e87ef69 465
3e87ef69 466}
467
14e76e91 468void AliL3Track::GetClosestPoint(AliL3Vertex *vertex,Double_t &closestx,Double_t &closesty,Double_t &closestz)
6d4f1901 469{
470 //Calculate the point of closest approach to the vertex
1f1942b8 471 //This function calculates the minimum distance from the helix to the vertex, and choose
472 //the corresponding point lying on the helix as the point of closest approach.
6d4f1901 473
1f1942b8 474 Double_t xc = GetCenterX() - vertex->GetX();
6d4f1901 475 Double_t yc = GetCenterY() - vertex->GetY();
476
14e76e91 477 Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
478 Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
479 Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1);
6d4f1901 480
14e76e91 481 Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
482 Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
483 Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2);
6d4f1901 484
485 //Choose the closest:
486 if(distance1 < distance2)
487 {
14e76e91 488 closestx = distx1 + vertex->GetX();
489 closesty = disty1 + vertex->GetY();
6d4f1901 490 }
491 else
492 {
14e76e91 493 closestx = distx2 + vertex->GetX();
494 closesty = disty2 + vertex->GetY();
6d4f1901 495 }
496
497 //Get the z coordinate:
14e76e91 498 Double_t angle1 = atan2((closesty-GetCenterY()),(closestx-GetCenterX()));
5a31e9df 499 if(angle1 < 0) angle1 = angle1 + AliL3Transform::TwoPi();
6d4f1901 500
501 Double_t angle2 = atan2((GetFirstPointY()-GetCenterY()),(GetFirstPointX()-GetCenterX()));
5a31e9df 502 if(angle2 < 0) angle2 = angle2 + AliL3Transform::TwoPi();
6d4f1901 503
504 Double_t diff_angle = angle1 - angle2;
5a31e9df 505 diff_angle = fmod(diff_angle,AliL3Transform::TwoPi());
6d4f1901 506
5a31e9df 507 if((GetCharge()*diff_angle) < 0) diff_angle = diff_angle + GetCharge()*AliL3Transform::TwoPi();
14e76e91 508 Double_t stot = fabs(diff_angle)*GetRadius();
509 closestz = GetFirstPointZ() - stot*GetTgl();
6d4f1901 510}