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