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