223 float &genericTime)
const
227 if ( ((distCenterToIP +
m_radius) < radius) || ((
m_radius + radius) < distCenterToIP) )
228 return STATUS_CODE_NOT_FOUND;
232 float phiStar(radius * radius + distCenterToIP * distCenterToIP -
m_radius *
m_radius);
233 phiStar = 0.5f * phiStar / std::max(1.e-20f, radius * distCenterToIP);
236 phiStar = 0.9999999f;
239 phiStar = -0.9999999f;
241 phiStar = std::acos(phiStar);
243 const float xx1(radius * std::cos(phiCentre + phiStar));
244 const float yy1(radius * std::sin(phiCentre + phiStar));
246 const float xx2(radius * std::cos(phiCentre-phiStar));
247 const float yy2(radius * std::sin(phiCentre-phiStar));
253 float dphi1(phi1 - phi0);
254 float dphi2(phi2 - phi0);
278 if ((tt1 < 0.) || (tt2 < 0.))
279 std::cout <<
"Helix:: GetPointOnCircle, warning - negative generic time, tt1 " << tt1 <<
", tt2 " << tt2 << std::endl;
293 return STATUS_CODE_SUCCESS;
350 float &helixDistance)
const
353 return STATUS_CODE_INVALID_PARAMETER;
364 const float distance(std::sqrt((x01-x02) * (x01-x02) + (y01-y02) * (y01-y02)));
366 bool singlePoint(
true);
367 float phi1(0.), phi2(0.);
369 if (rad1 + rad2 < distance)
371 phi1 = std::atan2(y02 - y01, x02 - x01);
372 phi2 = std::atan2(y01 - y02, x01 - x02);
374 else if (distance + rad2 < rad1)
376 phi1 = std::atan2(y02 - y01, x02 - x01);
379 else if (distance + rad1 < rad2)
381 phi1 = std::atan2(y01 - y02, x01 - x02);
386 if ((std::fabs(distance) < std::numeric_limits<float>::epsilon()) || (std::fabs(rad2) < std::numeric_limits<float>::epsilon()))
387 return STATUS_CODE_FAILURE;
390 float cosAlpha = 0.5f * (distance * distance + rad2 * rad2 - rad1 * rad1) / (distance * rad2);
391 float alpha = std::acos(cosAlpha);
392 float phi0 = std::atan2(y01 - y02, x01 - x02);
404 const float xSect1(x01 + rad1 * std::cos(phi1));
405 const float ySect1(y01 + rad1 * std::sin(phi1));
406 const float xSect2(x02 + rad2 * std::cos(phi2));
407 const float ySect2(y02 + rad2 * std::sin(phi2));
408 const float r1(std::sqrt(xSect1 * xSect1 + ySect1 * ySect1));
409 const float r2(std::sqrt(xSect2 * xSect2 + ySect2 * ySect2));
416 const float xSect1(x02 + rad2*std::cos(phi1));
417 const float ySect1(y02 + rad2*std::sin(phi1));
418 const float xSect2(x02 + rad2*std::cos(phi2));
419 const float ySect2(y02 + rad2*std::sin(phi2));
421 const float phiI2(std::atan2(referencePoint2.
GetY() - y02, referencePoint2.
GetX() - x02));
422 const float phiF21(std::atan2(ySect1 - y02, xSect1 - x02));
423 const float phiF22(std::atan2(ySect2 - y02, xSect2 - x02));
424 const float charge2(pHelix->
GetCharge());
426 float deltaPhi21(phiF21 - phiI2);
427 float deltaPhi22(phiF22 - phiI2);
429 if (deltaPhi21 < 0 && charge2 < 0)
433 else if (deltaPhi21 > 0 && charge2 > 0)
438 if (deltaPhi22 < 0 && charge2 < 0)
442 else if (deltaPhi22 > 0 && charge2 > 0)
447 const float pxy2(pHelix->
GetPxy());
448 const float genericTime21(-charge2 * deltaPhi21 * rad2 / pxy2);
449 const float genericTime22(-charge2 * deltaPhi22 * rad2 / pxy2);
452 const float Z21(referencePoint2.
GetZ() + genericTime21 * pz2);
453 const float Z22(referencePoint2.
GetZ() + genericTime22 * pz2);
458 const float phiI1(std::atan2(referencePoint1.
GetY() - y01, referencePoint1.
GetX() - x01));
459 const float phiF11(std::atan2(ySect1-y01,xSect1-x01));
460 const float phiF12(std::atan2(ySect2-y01,xSect2-x01));
463 float deltaPhi11(phiF11 - phiI1);
464 float deltaPhi12(phiF12 - phiI1);
466 if (deltaPhi11 < 0 && charge1 < 0)
470 else if (deltaPhi11 > 0 && charge1 > 0)
475 if (deltaPhi12 < 0 && charge1 < 0)
479 else if (deltaPhi12 > 0 && charge1 > 0)
484 const float pxy1(
m_pxy);
485 const float genericTime11(-charge1 * deltaPhi11 * rad1 / pxy1);
486 const float genericTime12(-charge1 * deltaPhi12 * rad1 / pxy1);
489 const float Z11(referencePoint1.
GetZ() + genericTime11 * pz1);
490 const float Z12(referencePoint1.
GetZ() + genericTime12 * pz1);
495 const float dist1((temp11 - temp21).GetMagnitudeSquared());
496 const float dist2((temp12 - temp22).GetMagnitudeSquared());
513 helixDistance = (position1 - position2).GetMagnitude();
514 positionOfClosestApproach = (position1 + position2) * 0.5;
515 v0momentum = momentum1 + momentum2;
517 return STATUS_CODE_SUCCESS;