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