]>
Commit | Line | Data |
---|---|---|
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 | * * | |
7 | * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | * Timm Steinbeck <timm@kip.uni-heidelberg.de> * | |
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 | |
21 | @author Anders Vestbo, Uli Frankenfeld, Matthias Richter | |
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 | |
33 | using namespace std; | |
34 | #endif | |
35 | ||
a6c02c85 | 36 | ClassImp(AliHLTTPCTrack) |
37 | ||
38 | ||
39 | AliHLTTPCTrack::AliHLTTPCTrack() | |
40 | { | |
41 | //Constructor | |
42 | fNHits = 0; | |
43 | fMCid = -1; | |
44 | fKappa=0; | |
45 | fRadius=0; | |
46 | fCenterX=0; | |
47 | fCenterY=0; | |
48 | ComesFromMainVertex(false); | |
49 | fQ = 0; | |
50 | fPhi0=0; | |
51 | fPsi=0; | |
52 | fR0=0; | |
53 | fTanl=0; | |
54 | fZ0=0; | |
55 | fPt=0; | |
56 | fLength=0; | |
57 | fIsLocal=true; | |
58 | fRowRange[0]=0; | |
59 | fRowRange[1]=0; | |
60 | SetFirstPoint(0,0,0); | |
61 | SetLastPoint(0,0,0); | |
62 | memset(fHitNumbers,0,159*sizeof(UInt_t)); | |
63 | fPID = 0; | |
64 | ||
65 | fSector=0; | |
66 | fPterr=0; | |
67 | fPsierr=0; | |
68 | fZ0err=0; | |
69 | fTanlerr=0; | |
70 | fPoint[0]=fPoint[1]=fPoint[2]=0; | |
71 | fPointPsi=0; | |
72 | } | |
73 | ||
3cde846d | 74 | void AliHLTTPCTrack::Copy(AliHLTTPCTrack *tpt) |
a6c02c85 | 75 | { |
76 | //setter | |
77 | SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow()); | |
78 | SetPhi0(tpt->GetPhi0()); | |
79 | SetKappa(tpt->GetKappa()); | |
80 | SetNHits(tpt->GetNHits()); | |
81 | SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ()); | |
82 | SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ()); | |
83 | SetPt(tpt->GetPt()); | |
84 | SetPsi(tpt->GetPsi()); | |
85 | SetTgl(tpt->GetTgl()); | |
86 | SetPterr(tpt->GetPterr()); | |
87 | SetPsierr(tpt->GetPsierr()); | |
88 | SetTglerr(tpt->GetTglerr()); | |
89 | SetCharge(tpt->GetCharge()); | |
90 | SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers()); | |
91 | #ifdef do_mc | |
92 | SetMCid(tpt->GetMCid()); | |
93 | #endif | |
94 | SetPID(tpt->GetPID()); | |
95 | SetSector(tpt->GetSector()); | |
96 | } | |
97 | ||
98 | Int_t AliHLTTPCTrack::Compare(const AliHLTTPCTrack *track) const | |
99 | { | |
100 | // compare tracks | |
101 | if(track->GetNHits() < GetNHits()) return 1; | |
102 | if(track->GetNHits() > GetNHits()) return -1; | |
103 | return 0; | |
104 | } | |
105 | ||
106 | AliHLTTPCTrack::~AliHLTTPCTrack() | |
107 | { | |
108 | //Nothing to do | |
109 | } | |
110 | ||
111 | Double_t AliHLTTPCTrack::GetP() const | |
112 | { | |
113 | // Returns total momentum. | |
114 | return fabs(GetPt())*sqrt(1. + GetTgl()*GetTgl()); | |
115 | } | |
116 | ||
117 | Double_t AliHLTTPCTrack::GetPseudoRapidity() const | |
118 | { //get pseudo rap | |
119 | return 0.5 * log((GetP() + GetPz()) / (GetP() - GetPz())); | |
120 | } | |
121 | ||
122 | /* | |
123 | Double_t AliHLTTPCTrack::GetEta() const | |
124 | { | |
125 | return GetPseudoRapidity(); | |
126 | } | |
127 | */ | |
128 | ||
129 | Double_t AliHLTTPCTrack::GetRapidity() const | |
130 | { | |
131 | //get rap | |
132 | const Double_t kmpi = 0.13957; | |
133 | return 0.5 * log((kmpi + GetPz()) / (kmpi - GetPz())); | |
134 | } | |
135 | ||
136 | void AliHLTTPCTrack::Rotate(Int_t slice,Bool_t tolocal) | |
137 | { | |
138 | //Rotate track to global parameters | |
139 | //If flag tolocal is set, the track is rotated | |
140 | //to local coordinates. | |
141 | ||
142 | Float_t psi[1] = {GetPsi()}; | |
143 | if(!tolocal) | |
144 | AliHLTTPCTransform::Local2GlobalAngle(psi,slice); | |
145 | else | |
146 | AliHLTTPCTransform::Global2LocalAngle(psi,slice); | |
147 | SetPsi(psi[0]); | |
148 | Float_t first[3]; | |
149 | first[0] = GetFirstPointX(); | |
150 | first[1] = GetFirstPointY(); | |
151 | first[2] = GetFirstPointZ(); | |
152 | if(!tolocal) | |
153 | AliHLTTPCTransform::Local2Global(first,slice); | |
154 | else | |
155 | AliHLTTPCTransform::Global2LocHLT(first,slice); | |
156 | //AliHLTTPCTransform::Global2Local(first,slice,kTRUE); | |
157 | ||
158 | SetFirstPoint(first[0],first[1],first[2]); | |
159 | Float_t last[3]; | |
160 | last[0] = GetLastPointX(); | |
161 | last[1] = GetLastPointY(); | |
162 | last[2] = GetLastPointZ(); | |
163 | if(!tolocal) | |
164 | AliHLTTPCTransform::Local2Global(last,slice); | |
165 | else | |
166 | AliHLTTPCTransform::Global2LocHLT(last,slice); | |
167 | //AliHLTTPCTransform::Global2Local(last,slice,kTRUE); | |
168 | SetLastPoint(last[0],last[1],last[2]); | |
169 | ||
170 | Float_t center[3] = {GetCenterX(),GetCenterY(),0}; | |
171 | if(!tolocal) | |
172 | AliHLTTPCTransform::Local2Global(center,slice); | |
173 | else | |
174 | AliHLTTPCTransform::Global2LocHLT(center,slice); | |
175 | //AliHLTTPCTransform::Global2Local(center,slice,kTRUE); | |
176 | SetCenterX(center[0]); | |
177 | SetCenterY(center[1]); | |
178 | ||
179 | SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0])); | |
180 | SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1])); | |
181 | ||
182 | if(!tolocal) | |
183 | fIsLocal=kFALSE; | |
184 | else | |
185 | fIsLocal=kTRUE; | |
186 | } | |
187 | ||
188 | void AliHLTTPCTrack::CalculateHelix() | |
189 | { | |
db16520a | 190 | // #### -B0-CHANGE-START == JMT |
191 | // for straight line fit | |
192 | if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){ | |
193 | fRadius = 999999; //just zero | |
194 | ||
195 | SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0])); | |
196 | SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1])); | |
197 | } | |
198 | // for helix fit | |
199 | else { | |
200 | // #### -B0-UNCHANGED-START == JMT | |
201 | //Calculate Radius, CenterX and CenterY from Psi, X0, Y0 | |
202 | fRadius = fPt / (AliHLTTPCTransform::GetBFieldValue()); | |
203 | if(fRadius) fKappa = -fQ*1./fRadius; | |
204 | else fRadius = 999999; //just zero | |
205 | Double_t trackPhi0 = fPsi + fQ * AliHLTTPCTransform::PiHalf(); | |
206 | ||
207 | fCenterX = fFirstPoint[0] - fRadius * cos(trackPhi0); | |
208 | fCenterY = fFirstPoint[1] - fRadius * sin(trackPhi0); | |
209 | ||
210 | SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0])); | |
211 | SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1])); | |
212 | // #### -B0-UNCHANGED-END == JMT | |
213 | } | |
214 | // #### -B0-CHANGE-END == JMT | |
a6c02c85 | 215 | } |
216 | ||
217 | Double_t AliHLTTPCTrack::GetCrossingAngle(Int_t padrow,Int_t slice) | |
218 | { | |
219 | //Calculate the crossing angle between track and given padrow. | |
220 | //Take the dot product of the tangent vector of the track, and | |
221 | //vector perpendicular to the padrow. | |
222 | //In order to do this, we need the tangent vector to the track at the | |
223 | //point. This is done by rotating the radius vector by 90 degrees; | |
224 | //rotation matrix: ( 0 1 ) | |
225 | // ( -1 0 ) | |
226 | ||
227 | Float_t angle=0;//Angle perpendicular to the padrow in local coordinates | |
228 | if(slice>=0)//Global coordinates | |
229 | { | |
230 | AliHLTTPCTransform::Local2GlobalAngle(&angle,slice); | |
231 | if(!CalculateReferencePoint(angle,AliHLTTPCTransform::Row2X(padrow))) | |
232 | cerr<<"AliHLTTPCTrack::GetCrossingAngle : Track does not cross line in slice "<<slice<<" row "<<padrow<<endl; | |
233 | } | |
234 | else //should be in local coordinates | |
235 | { | |
236 | Float_t xyz[3]; | |
237 | GetCrossingPoint(padrow,xyz); | |
238 | fPoint[0] = xyz[0]; | |
239 | fPoint[1] = xyz[1]; | |
240 | fPoint[2] = xyz[2]; | |
241 | } | |
242 | ||
243 | Double_t tangent[2]; | |
244 | ||
245 | tangent[0] = (fPoint[1] - GetCenterY())/GetRadius(); | |
246 | tangent[1] = -1.*(fPoint[0] - GetCenterX())/GetRadius(); | |
247 | ||
248 | Double_t perppadrow[2] = {cos(angle),sin(angle)}; | |
249 | Double_t cosbeta = fabs(tangent[0]*perppadrow[0] + tangent[1]*perppadrow[1]); | |
250 | if(cosbeta > 1) cosbeta=1; | |
251 | return acos(cosbeta); | |
252 | } | |
253 | ||
254 | Bool_t AliHLTTPCTrack::GetCrossingPoint(Int_t padrow,Float_t *xyz) | |
255 | { | |
256 | //Assumes the track is given in local coordinates | |
a6c02c85 | 257 | if(!IsLocal()) |
258 | { | |
259 | cerr<<"GetCrossingPoint: Track is given on global coordinates"<<endl; | |
260 | return false; | |
261 | } | |
262 | ||
263 | Double_t xHit = AliHLTTPCTransform::Row2X(padrow); | |
264 | ||
738c049f | 265 | // BEGINN ############################################## MODIFIY JMT |
db16520a | 266 | //if (xHit < xyz[0]){ |
267 | // LOG(AliHLTTPCLog::kError,"AliHLTTPCTRACK::GetCrossingPoint","")<< "Track doesn't cross padrow " | |
268 | // << padrow <<"(x=" << xHit << "). Smallest x=" << xyz[0] << ENDLOG; | |
269 | // return false; | |
270 | //} | |
738c049f | 271 | // END ################################################# MODIFIY JMT |
272 | ||
db16520a | 273 | // #### -B0-CHANGE-START == JMT |
274 | // for straight line fit | |
275 | if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){ | |
738c049f | 276 | |
db16520a | 277 | Double_t yHit = GetFirstPointY() + (Double_t) tan( GetPsi() ) * (xHit - GetFirstPointX()); |
278 | ||
279 | Double_t s = (xHit - GetFirstPointX())*(xHit - GetFirstPointX()) + (yHit - GetFirstPointY())*(yHit - GetFirstPointY()); | |
280 | ||
281 | Double_t zHit = GetFirstPointZ() + s * GetTgl(); | |
738c049f | 282 | |
db16520a | 283 | xyz[0] = xHit; |
284 | xyz[1] = yHit; | |
285 | xyz[2] = zHit; | |
286 | } | |
287 | // for helix fit | |
288 | else { | |
289 | // #### -B0-UNCHANGED-START == JMT | |
290 | xyz[0] = xHit; | |
291 | Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX()); | |
292 | Double_t r2 = GetRadius()*GetRadius(); | |
293 | if(aa > r2) | |
294 | return false; | |
295 | ||
296 | Double_t aa2 = sqrt(r2 - aa); | |
297 | Double_t y1 = GetCenterY() + aa2; | |
298 | Double_t y2 = GetCenterY() - aa2; | |
299 | xyz[1] = y1; | |
300 | if(fabs(y2) < fabs(y1)) xyz[1] = y2; | |
301 | ||
302 | Double_t yHit = xyz[1]; | |
303 | Double_t angle1 = atan2((yHit - GetCenterY()),(xHit - GetCenterX())); | |
304 | if(angle1 < 0) angle1 += 2.*AliHLTTPCTransform::Pi(); | |
305 | Double_t angle2 = atan2((GetFirstPointY() - GetCenterY()),(GetFirstPointX() - GetCenterX())); | |
306 | if(angle2 < 0) angle2 += AliHLTTPCTransform::TwoPi(); | |
307 | ||
308 | Double_t diffangle = angle1 - angle2; | |
309 | diffangle = fmod(diffangle,AliHLTTPCTransform::TwoPi()); | |
310 | if((GetCharge()*diffangle) > 0) diffangle = diffangle - GetCharge()*AliHLTTPCTransform::TwoPi(); | |
311 | ||
312 | Double_t stot = fabs(diffangle)*GetRadius(); | |
313 | ||
314 | Double_t zHit = GetFirstPointZ() + stot*GetTgl(); | |
315 | ||
316 | xyz[2] = zHit; | |
317 | // #### -B0-UNCHANGED-END == JMT | |
318 | } | |
319 | // #### -B0-CHANGE-END == JMT | |
a6c02c85 | 320 | |
db16520a | 321 | return true; |
a6c02c85 | 322 | } |
323 | ||
324 | Bool_t AliHLTTPCTrack::CalculateReferencePoint(Double_t angle,Double_t radius) | |
325 | { | |
326 | // Global coordinate: crossing point with y = ax+ b; | |
327 | // a=tan(angle-AliHLTTPCTransform::PiHalf()); | |
328 | // | |
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; | |
332 | ||
333 | Double_t a = tan(angle-AliHLTTPCTransform::PiHalf()); | |
334 | Double_t b = kyr - a * kxr; | |
335 | ||
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)); | |
338 | ||
339 | Double_t racine = pp*pp-qq; | |
340 | if(racine<0) return IsPoint(kFALSE); //no Point | |
341 | ||
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; | |
347 | ||
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)); | |
350 | ||
351 | if(diff0<diff1){ | |
352 | fPoint[0]=x0; | |
353 | fPoint[1]=y0; | |
354 | } | |
355 | else{ | |
356 | fPoint[0]=x1; | |
357 | fPoint[1]=y1; | |
358 | } | |
359 | ||
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(); | |
365 | } | |
366 | Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ; | |
367 | fPoint[2] = fFirstPoint[2] + stot * fTanl; | |
368 | ||
369 | fPointPsi = pointPhi0 - fQ * AliHLTTPCTransform::PiHalf(); | |
370 | if(fPointPsi<0.) fPointPsi+= AliHLTTPCTransform::TwoPi(); | |
371 | fPointPsi = fmod(fPointPsi, AliHLTTPCTransform::TwoPi()); | |
372 | ||
373 | return IsPoint(kTRUE); | |
374 | } | |
375 | ||
376 | Bool_t AliHLTTPCTrack::CalculateEdgePoint(Double_t angle) | |
377 | { | |
378 | // Global coordinate: crossing point with y = ax; a=tan(angle); | |
379 | // | |
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 | |
382 | ||
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; | |
391 | Double_t y0 = a*x0; | |
392 | Double_t y1 = a*x1; | |
393 | ||
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 | |
398 | Bool_t ok0 = kFALSE; | |
399 | Bool_t ok1 = kFALSE; | |
400 | ||
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) | |
405 | ok0 = kTRUE; | |
406 | } | |
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) | |
411 | ok1 = kTRUE; | |
412 | } | |
413 | if(!(ok0||ok1)) return IsPoint(kFALSE); //no Point | |
414 | ||
415 | if(ok0&&ok1){ | |
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 | |
420 | } | |
421 | if(ok0){fPoint[0]=x0; fPoint[1]=y0;} | |
422 | else {fPoint[0]=x1; fPoint[1]=y1;} | |
423 | ||
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(); | |
429 | } | |
430 | Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ; | |
431 | fPoint[2] = fFirstPoint[2] + stot * fTanl; | |
432 | ||
433 | fPointPsi = pointPhi0 - fQ * AliHLTTPCTransform::PiHalf(); | |
434 | if(fPointPsi<0.) fPointPsi+= AliHLTTPCTransform::TwoPi(); | |
435 | fPointPsi = fmod(fPointPsi, AliHLTTPCTransform::TwoPi()); | |
436 | ||
437 | return IsPoint(kTRUE); | |
438 | } | |
439 | ||
440 | Bool_t AliHLTTPCTrack::CalculatePoint(Double_t xplane) | |
441 | { | |
442 | // Local coordinate: crossing point with x plane | |
443 | // | |
444 | Double_t racine = pow(fRadius,2)-pow(xplane-fCenterX,2); | |
445 | if(racine<0) return IsPoint(kFALSE); | |
446 | Double_t rootRacine = sqrt(racine); | |
447 | ||
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]); | |
454 | ||
455 | fPoint[0]=xplane; | |
456 | if(diff0<diff1) fPoint[1]=y0; | |
457 | else fPoint[1]=y1; | |
458 | ||
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(); | |
464 | } | |
465 | Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ; | |
466 | fPoint[2] = fFirstPoint[2] + stot * fTanl; | |
467 | ||
468 | fPointPsi = pointPhi0 - fQ * AliHLTTPCTransform::PiHalf(); | |
469 | if(fPointPsi<0.) fPointPsi+= AliHLTTPCTransform::TwoPi(); | |
470 | fPointPsi = fmod(fPointPsi, AliHLTTPCTransform::TwoPi()); | |
471 | ||
472 | return IsPoint(kTRUE); | |
473 | } | |
474 | ||
475 | void AliHLTTPCTrack::UpdateToFirstPoint() | |
476 | { | |
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 | |
482 | //assigned cluster. | |
483 | // | |
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. | |
db16520a | 490 | // #### -B0-CHANGE-START == JMT |
491 | // for straight line fit | |
492 | if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){ | |
493 | Double_t xc = GetCenterX() - GetFirstPointX(); | |
494 | Double_t yc = GetCenterY() - GetFirstPointY(); | |
495 | ||
496 | Double_t xn = (Double_t) sin( GetPsi() ); | |
497 | Double_t yn = -1. * (Double_t) cos( GetPsi() ); | |
498 | ||
499 | Double_t d = xc*xn + yc*yn; | |
500 | ||
501 | Double_t distx = d * xn; | |
502 | Double_t disty = d * yn; | |
503 | ||
504 | Double_t point[2]; | |
505 | ||
506 | point[0] = distx + GetFirstPointX(); | |
507 | point[1] = disty + GetFirstPointY(); | |
508 | ||
509 | //Update the track parameters | |
510 | SetR0(sqrt(point[0]*point[0]+point[1]*point[1])); | |
511 | SetPhi0(atan2(point[1],point[0])); | |
512 | SetFirstPoint(point[0],point[1],GetZ0()); | |
a6c02c85 | 513 | } |
db16520a | 514 | // for helix fit |
515 | else { | |
516 | // #### -B0-UNCHANGED-START == JMT | |
517 | Double_t xc = GetCenterX() - GetFirstPointX(); | |
518 | Double_t yc = GetCenterY() - GetFirstPointY(); | |
519 | ||
520 | Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc)); | |
521 | Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc)); | |
522 | Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1); | |
523 | ||
524 | Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc)); | |
525 | Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc)); | |
526 | Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2); | |
527 | ||
528 | //Choose the closest: | |
529 | Double_t point[2]; | |
530 | if(distance1 < distance2) | |
531 | { | |
532 | point[0] = distx1 + GetFirstPointX(); | |
533 | point[1] = disty1 + GetFirstPointY(); | |
534 | } | |
535 | else | |
536 | { | |
537 | point[0] = distx2 + GetFirstPointX(); | |
538 | point[1] = disty2 + GetFirstPointY(); | |
539 | } | |
540 | ||
541 | Double_t pointpsi = atan2(point[1]-GetCenterY(),point[0]-GetCenterX()); | |
542 | pointpsi -= GetCharge()*AliHLTTPCTransform::PiHalf(); | |
543 | if(pointpsi < 0) pointpsi += AliHLTTPCTransform::TwoPi(); | |
544 | ||
545 | //Update the track parameters | |
546 | SetR0(sqrt(point[0]*point[0]+point[1]*point[1])); | |
547 | SetPhi0(atan2(point[1],point[0])); | |
548 | SetFirstPoint(point[0],point[1],GetZ0()); | |
549 | SetPsi(pointpsi); | |
550 | // #### -B0-UNCHANGED-END == JMT | |
a6c02c85 | 551 | } |
db16520a | 552 | // #### -B0-CHANGE-END == JMT |
a6c02c85 | 553 | } |
554 | ||
555 | void AliHLTTPCTrack::GetClosestPoint(AliHLTTPCVertex *vertex,Double_t &closestx,Double_t &closesty,Double_t &closestz) | |
556 | { | |
557 | //Calculate the point of closest approach to the vertex | |
558 | //This function calculates the minimum distance from the helix to the vertex, and choose | |
559 | //the corresponding point lying on the helix as the point of closest approach. | |
560 | ||
561 | Double_t xc = GetCenterX() - vertex->GetX(); | |
562 | Double_t yc = GetCenterY() - vertex->GetY(); | |
563 | ||
564 | Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc)); | |
565 | Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc)); | |
566 | Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1); | |
567 | ||
568 | Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc)); | |
569 | Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc)); | |
570 | Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2); | |
571 | ||
572 | //Choose the closest: | |
573 | if(distance1 < distance2) | |
574 | { | |
575 | closestx = distx1 + vertex->GetX(); | |
576 | closesty = disty1 + vertex->GetY(); | |
577 | } | |
578 | else | |
579 | { | |
580 | closestx = distx2 + vertex->GetX(); | |
581 | closesty = disty2 + vertex->GetY(); | |
582 | } | |
583 | ||
584 | //Get the z coordinate: | |
585 | Double_t angle1 = atan2((closesty-GetCenterY()),(closestx-GetCenterX())); | |
586 | if(angle1 < 0) angle1 = angle1 + AliHLTTPCTransform::TwoPi(); | |
587 | ||
588 | Double_t angle2 = atan2((GetFirstPointY()-GetCenterY()),(GetFirstPointX()-GetCenterX())); | |
589 | if(angle2 < 0) angle2 = angle2 + AliHLTTPCTransform::TwoPi(); | |
590 | ||
591 | Double_t diff_angle = angle1 - angle2; | |
592 | diff_angle = fmod(diff_angle,AliHLTTPCTransform::TwoPi()); | |
593 | ||
594 | if((GetCharge()*diff_angle) < 0) diff_angle = diff_angle + GetCharge()*AliHLTTPCTransform::TwoPi(); | |
595 | Double_t stot = fabs(diff_angle)*GetRadius(); | |
596 | closestz = GetFirstPointZ() - stot*GetTgl(); | |
597 | } | |
598 | ||
599 | void AliHLTTPCTrack::Print() const | |
600 | { //print out parameters of track | |
738c049f | 601 | // BEGINN ############################################## MODIFIY JMT |
602 | ||
603 | #if 1 | |
604 | LOG(AliHLTTPCLog::kInformational,"AliHLTTPCTrack::Print","Print values") | |
605 | <<"NH="<<fNHits<<" "<<fMCid<<" K="<<fKappa<<" R="<<fRadius<<" Cx="<<fCenterX<<" Cy="<<fCenterY<<" MVT=" | |
606 | <<fFromMainVertex<<" Row0="<<fRowRange[0]<<" Row1="<<fRowRange[1]<<" Sector="<<fSector<<" Q="<<fQ<<" TgLam=" | |
607 | <<fTanl<<" psi="<<fPsi<<" pt="<<fPt<<" L="<<fLength<<" "<<fPterr<<" "<<fPsierr<<" "<<fZ0err<<" " | |
608 | <<fTanlerr<<" phi0="<<fPhi0<<" R0="<<fR0<<" Z0"<<fZ0<<" X0"<<fFirstPoint[0]<<" Y0"<<fFirstPoint[1]<<" Z0" | |
609 | <<fFirstPoint[2]<<" XL"<<fLastPoint[0]<<" YL"<<fLastPoint[1]<<" ZL"<<fLastPoint[2]<<" " | |
610 | <<fPoint[0]<<" "<<fPoint[1]<<" "<<fPoint[2]<<" "<<fPointPsi<<" "<<fIsPoint<<" local=" | |
611 | <<fIsLocal<<" "<<fPID<<ENDLOG; | |
612 | ||
613 | ||
614 | ||
615 | #else | |
a6c02c85 | 616 | LOG(AliHLTTPCLog::kInformational,"AliHLTTPCTrack::Print","Print values") |
617 | <<fNHits<<" "<<fMCid<<" "<<fKappa<<" "<<fRadius<<" "<<fCenterX<<" "<<fCenterY<<" " | |
618 | <<fFromMainVertex<<" "<<fRowRange[0]<<" "<<fRowRange[1]<<" "<<fSector<<" "<<fQ<<" " | |
619 | <<fTanl<<" "<<fPsi<<" "<<fPt<<" "<<fLength<<" "<<fPterr<<" "<<fPsierr<<" "<<fZ0err<<" " | |
620 | <<fTanlerr<<" "<<fPhi0<<" "<<fR0<<" "<<fZ0<<" "<<fFirstPoint[0]<<" "<<fFirstPoint[1]<<" " | |
621 | <<fFirstPoint[2]<<" "<<fLastPoint[0]<<" "<<fLastPoint[1]<<" "<<fLastPoint[2]<<" " | |
622 | <<fPoint[0]<<" "<<fPoint[1]<<" "<<fPoint[2]<<" "<<fPointPsi<<" "<<fIsPoint<<" " | |
623 | <<fIsLocal<<" "<<fPID<<ENDLOG; | |
738c049f | 624 | #endif |
625 | ||
626 | // END ################################################# MODIFIY JMT | |
a6c02c85 | 627 | } |
3cde846d | 628 | |
629 | int AliHLTTPCTrack::Convert2AliKalmanTrack() | |
630 | { | |
631 | int iResult=0; | |
632 | // The method has been copied from AliHLTHoughKalmanTrack and adapted | |
633 | // to the TPC conformal mapping track parametrization | |
634 | ||
04dbc9e4 | 635 | // SetChi2(0.); |
636 | // SetNumberOfClusters(GetLastRow()-GetFirstRow()); | |
637 | // SetLabel(GetMCid()); | |
638 | // SetFakeRatio(0.); | |
639 | // SetMass(0.13957); // just a guess | |
3cde846d | 640 | |
04dbc9e4 | 641 | // fdEdx=0; |
3cde846d | 642 | Double_t alpha = fmod((GetSector()+0.5)*(2*TMath::Pi()/18),2*TMath::Pi()); |
643 | if (alpha < -TMath::Pi()) alpha += 2*TMath::Pi(); | |
644 | else if (alpha >= TMath::Pi()) alpha -= 2*TMath::Pi(); | |
645 | ||
04dbc9e4 | 646 | // Double_t xhit=GetFirstPointX(); |
647 | // Double_t yhit=GetFirstPointY(); | |
648 | // Double_t zhit=GetFirstPointZ(); | |
649 | // Double_t psi = GetPsi(); | |
650 | // Double_t kappa = GetKappa(); | |
651 | // Double_t radius = GetRadius(); | |
652 | // Double_t centerx = GetCenterX(); | |
3cde846d | 653 | |
04dbc9e4 | 654 | // Double_t tanl = GetTgl(); |
3cde846d | 655 | |
04dbc9e4 | 656 | // Double_t cnv=1.; |
3cde846d | 657 | // TODO: think about how to get the magnetic field |
658 | //Double_t cnv=1./(GetBz()*kB2C); | |
659 | ||
660 | //covariance matrix | |
661 | Double_t cov[15]={ | |
662 | 0., | |
663 | 0., 0., | |
664 | 0., 0., 0., | |
665 | 0., 0., 0., 0., | |
666 | 0., 0., 0., 0., 0. | |
667 | }; | |
668 | ||
04dbc9e4 | 669 | const Double_t xhit = 82.97; |
3cde846d | 670 | Double_t xx[5]; |
04dbc9e4 | 671 | xx[0] = GetFirstPointY(); |
672 | xx[1] = GetFirstPointZ(); | |
673 | xx[2] = GetPsi(); | |
674 | xx[3] = GetTgl(); | |
675 | xx[4] = GetPt(); | |
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 | } |