diff --git a/Core/src/Surfaces/CylinderBounds.cpp b/Core/src/Surfaces/CylinderBounds.cpp index 64d13bb688a..b66ecec9065 100644 --- a/Core/src/Surfaces/CylinderBounds.cpp +++ b/Core/src/Surfaces/CylinderBounds.cpp @@ -48,47 +48,49 @@ bool Acts::CylinderBounds::inside(const Vector2& lposition, double halfLengthZ = get(eHalfLengthZ); double halfPhi = get(eHalfPhiSector); - if (bevelMinZ != 0. && bevelMaxZ != 0.) { - double radius = get(eR); - // Beleved sides will unwrap to a trapezoid - /////////////////////////////////// - // ________ - // /| . . |\ r/phi - // \|______|/ r/phi - // -Z 0 Z - /////////////////////////////////// - float localx = - lposition[0] > radius ? 2 * radius - lposition[0] : lposition[0]; - Vector2 shiftedlposition = shifted(lposition); - if ((std::fabs(shiftedlposition[0]) <= halfPhi && - std::fabs(shiftedlposition[1]) <= halfLengthZ)) { - return true; - } else if ((lposition[1] >= - -(localx * std::tan(bevelMinZ) + halfLengthZ)) && - (lposition[1] <= (localx * std::tan(bevelMaxZ) + halfLengthZ))) { - return true; - } else { - // check within tolerance - auto boundaryCheck = bcheck.transformed(jacobian()); - - Vector2 lowerLeft = {-radius, -halfLengthZ}; - Vector2 middleLeft = {0., -(halfLengthZ + radius * std::tan(bevelMinZ))}; - Vector2 upperLeft = {radius, -halfLengthZ}; - Vector2 upperRight = {radius, halfLengthZ}; - Vector2 middleRight = {0., (halfLengthZ + radius * std::tan(bevelMaxZ))}; - Vector2 lowerRight = {-radius, halfLengthZ}; - Vector2 vertices[] = {lowerLeft, middleLeft, upperLeft, - upperRight, middleRight, lowerRight}; - Vector2 closestPoint = - boundaryCheck.computeClosestPointOnPolygon(lposition, vertices); - - return boundaryCheck.isTolerated(closestPoint - lposition); - } - } else { + + if (bevelMinZ == 0. || bevelMaxZ == 0.) { return bcheck.transformed(jacobian()) .isInside(shifted(lposition), Vector2(-halfPhi, -halfLengthZ), Vector2(halfPhi, halfLengthZ)); } + + double radius = get(eR); + // Beleved sides will unwrap to a trapezoid + /////////////////////////////////// + // ________ + // /| . . |\ r/phi + // \|______|/ r/phi + // -Z 0 Z + /////////////////////////////////// + float localx = + lposition[0] > radius ? 2 * radius - lposition[0] : lposition[0]; + Vector2 shiftedlposition = shifted(lposition); + if ((std::fabs(shiftedlposition[0]) <= halfPhi && + std::fabs(shiftedlposition[1]) <= halfLengthZ)) { + return true; + } + + if ((lposition[1] >= -(localx * std::tan(bevelMinZ) + halfLengthZ)) && + (lposition[1] <= (localx * std::tan(bevelMaxZ) + halfLengthZ))) { + return true; + } + + // check within tolerance + auto boundaryCheck = bcheck.transformed(jacobian()); + + Vector2 lowerLeft = {-radius, -halfLengthZ}; + Vector2 middleLeft = {0., -(halfLengthZ + radius * std::tan(bevelMinZ))}; + Vector2 upperLeft = {radius, -halfLengthZ}; + Vector2 upperRight = {radius, halfLengthZ}; + Vector2 middleRight = {0., (halfLengthZ + radius * std::tan(bevelMaxZ))}; + Vector2 lowerRight = {-radius, halfLengthZ}; + Vector2 vertices[] = {lowerLeft, middleLeft, upperLeft, + upperRight, middleRight, lowerRight}; + Vector2 closestPoint = + boundaryCheck.computeClosestPointOnPolygon(lposition, vertices); + + return boundaryCheck.isTolerated(closestPoint - lposition); } bool Acts::CylinderBounds::inside3D(const Vector3& position,