Skip to content

Commit

Permalink
refactor!: Rewrite BoundaryCheck; Rename to BoundaryTolerance and…
Browse files Browse the repository at this point in the history
… split out inside checks (#3170)

- Switch to a variant backend which holds different boundary tolerances
- Break parametrization and box/polygon check apart `BoundaryTolerance` vs `insideAlignedBox` vs `insidePolygon`
- Make tolerances explicitly cartesian or bound
- Implement absolute cartesian tolerance which allows us to extend surfaces by 1mm in the local axes for example
- Implement absolute euclidean tolerance which allows us to extend surfaces by 1mm in any direction for example
- Throw exceptions if requested boundary tolerance is not implemented

blocked by
- #3204
- #3205
- acts-project/machines#109
  • Loading branch information
andiwand authored Jul 6, 2024
1 parent cae58b3 commit 11b1172
Show file tree
Hide file tree
Showing 135 changed files with 1,713 additions and 1,243 deletions.
2 changes: 1 addition & 1 deletion Core/include/Acts/Detector/DetectorVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "Acts/Material/IVolumeMaterial.hpp"
#include "Acts/Navigation/NavigationDelegates.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/SurfaceVisitorConcept.hpp"
#include "Acts/Utilities/BoundingBox.hpp"
#include "Acts/Utilities/Concepts.hpp"
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Detector/Portal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Navigation/NavigationDelegates.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/RegularSurface.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Surfaces/SurfaceVisitorConcept.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class MultiComponentCurvilinearTrackParameters
// Project the position onto the surface, keep everything else as is
for (const auto& [w, pos4, dir, qop, cov] : curvi) {
Vector3 newPos = s->intersect(gctx, pos4.template segment<3>(eFreePos0),
dir, BoundaryCheck(false))
dir, BoundaryTolerance::Infinite())
.closest()
.position();

Expand Down
13 changes: 5 additions & 8 deletions Core/include/Acts/Geometry/ApproachDescriptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace Acts {

class Surface;
class Layer;
class BoundaryCheck;

/// @class ApproachDescriptor
///
Expand All @@ -42,17 +41,15 @@ class ApproachDescriptor {
/// @param gctx The current geometry context object, e.g. alignment
/// @param position is the position from start of the search
/// @param direction is the direction at the start of the search
/// @param bcheck is the boundary check directive
/// @param boundaryTolerance is the boundary check directive
/// @param nearLimit The minimum distance for an intersection to be considered
/// @param farLimit The maximum distance for an intersection to be considered
///
/// @return is a surface intersection
virtual SurfaceIntersection approachSurface(const GeometryContext& gctx,
const Vector3& position,
const Vector3& direction,
const BoundaryCheck& bcheck,
double nearLimit,
double farLimit) const = 0;
virtual SurfaceIntersection approachSurface(
const GeometryContext& gctx, const Vector3& position,
const Vector3& direction, const BoundaryTolerance& boundaryTolerance,
double nearLimit, double farLimit) const = 0;

/// Get all the contained surfaces
/// @return all contained surfaces of this approach descriptor
Expand Down
14 changes: 6 additions & 8 deletions Core/include/Acts/Geometry/GenericApproachDescriptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/ApproachDescriptor.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include "Acts/Utilities/Intersection.hpp"
Expand Down Expand Up @@ -56,17 +56,15 @@ class GenericApproachDescriptor : public ApproachDescriptor {
/// @param gctx The current geometry context object, e.g. alignment
/// @param position The global position to start the approach from
/// @param direction The momentum vector
/// @param bcheck The boundary check prescription
/// @param boundaryTolerance The boundary check prescription
/// @param nearLimit The minimum distance for an intersection to be considered
/// @param farLimit The maximum distance for an intersection to be considered
///
/// @return : a @c SurfaceIntersection
SurfaceIntersection approachSurface(const GeometryContext& gctx,
const Vector3& position,
const Vector3& direction,
const BoundaryCheck& bcheck,
double nearLimit,
double farLimit) const override;
SurfaceIntersection approachSurface(
const GeometryContext& gctx, const Vector3& position,
const Vector3& direction, const BoundaryTolerance& boundaryTolerance,
double nearLimit, double farLimit) const override;

/// return all contained surfaces of this approach descriptor
const std::vector<const Surface*>& containedSurfaces() const override;
Expand Down
10 changes: 5 additions & 5 deletions Core/include/Acts/Geometry/Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "Acts/Geometry/GeometryObject.hpp"
#include "Acts/Geometry/Volume.hpp"
#include "Acts/Material/IMaterialDecorator.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/SurfaceArray.hpp"
#include "Acts/Utilities/BinnedArray.hpp"
#include "Acts/Utilities/Intersection.hpp"
Expand Down Expand Up @@ -127,12 +127,12 @@ class Layer : public virtual GeometryObject {
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param position is the global position to be checked
/// @param bcheck is the boundary check directive
/// @param boundaryTolerance is the boundary check directive
///
/// @return boolean that indicates success of the operation
virtual bool isOnLayer(
const GeometryContext& gctx, const Vector3& position,
const BoundaryCheck& bcheck = BoundaryCheck(true)) const;
virtual bool isOnLayer(const GeometryContext& gctx, const Vector3& position,
const BoundaryTolerance& boundaryTolerance =
BoundaryTolerance::None()) const;

/// Return method for the approach descriptor, can be nullptr
const ApproachDescriptor* approachDescriptor() const;
Expand Down
15 changes: 8 additions & 7 deletions Core/include/Acts/Geometry/NavigationLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/Layer.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/BinningType.hpp"

Expand Down Expand Up @@ -72,11 +72,12 @@ class NavigationLayer : public Layer {
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param gp is the global position for the check
/// @param bcheck is the boundary check directive
/// @param boundaryTolerance is the boundary check directive
///
/// @return boolean that indicates if the position is on surface
bool isOnLayer(const GeometryContext& gctx, const Vector3& gp,
const BoundaryCheck& bcheck = BoundaryCheck(true)) const final;
const BoundaryTolerance& boundaryTolerance =
BoundaryTolerance::None()) const final;

/// Accept layer according to the following collection directives
///
Expand Down Expand Up @@ -121,11 +122,11 @@ inline Vector3 NavigationLayer::binningPosition(const GeometryContext& gctx,
return m_surfaceRepresentation->binningPosition(gctx, bValue);
}

inline bool NavigationLayer::isOnLayer(const GeometryContext& gctx,
const Vector3& gp,
const BoundaryCheck& bcheck) const {
inline bool NavigationLayer::isOnLayer(
const GeometryContext& gctx, const Vector3& gp,
const BoundaryTolerance& boundaryTolerance) const {
return m_surfaceRepresentation->isOnSurface(gctx, gp, Vector3::Zero(),
bcheck);
boundaryTolerance);
}

inline bool NavigationLayer::resolve(bool /*resolveSensitive*/,
Expand Down
1 change: 1 addition & 0 deletions Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Acts/Geometry/TrackingVolumeVisitorConcept.hpp"
#include "Acts/Geometry/Volume.hpp"
#include "Acts/Material/IVolumeMaterial.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Surfaces/SurfaceArray.hpp"
#include "Acts/Surfaces/SurfaceVisitorConcept.hpp"
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Geometry/detail/Layer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ inline bool Layer::resolve(bool resolveSensitive, bool resolveMaterial,

inline bool Layer::isOnLayer(const GeometryContext& gctx,
const Vector3& position,
const BoundaryCheck& bcheck) const {
const BoundaryTolerance& boundaryTolerance) const {
if (m_representingVolume != nullptr) {
return m_representingVolume->inside(position);
}
return (surfaceRepresentation())
.isOnSurface(gctx, position, Vector3::Zero(), bcheck);
return surfaceRepresentation().isOnSurface(gctx, position, Vector3::Zero(),
boundaryTolerance);
}

} // namespace Acts
10 changes: 5 additions & 5 deletions Core/include/Acts/Navigation/DetectorNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "Acts/Geometry/Layer.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Propagator/Propagator.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Logger.hpp"

Expand Down Expand Up @@ -231,10 +231,9 @@ class DetectorNavigator {
<< " (" << surface.center(state.geoContext).transpose()
<< ")");
// Estimate the surface status
bool boundaryCheck = c.boundaryCheck.isEnabled();
auto surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, c.objectIntersection.index(),
state.options.direction, BoundaryCheck(boundaryCheck),
state.options.direction, c.boundaryTolerance,
state.options.surfaceTolerance, logger());

ACTS_VERBOSE(volInfo(state) << posInfo(state, stepper)
Expand Down Expand Up @@ -285,7 +284,8 @@ class DetectorNavigator {
const Portal* nextPortal = nullptr;
const Surface* nextSurface = nullptr;
bool isPortal = false;
bool boundaryCheck = nState.surfaceCandidate().boundaryCheck.isEnabled();
BoundaryTolerance boundaryTolerance =
nState.surfaceCandidate().boundaryTolerance;

if (nState.surfaceCandidate().surface != nullptr) {
nextSurface = nState.surfaceCandidate().surface;
Expand All @@ -304,7 +304,7 @@ class DetectorNavigator {
auto surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, *nextSurface,
nState.surfaceCandidate().objectIntersection.index(),
state.options.direction, BoundaryCheck(boundaryCheck),
state.options.direction, boundaryTolerance,
state.options.surfaceTolerance, logger());

// Check if we are at a surface
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Navigation/NavigationState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Utilities/Delegate.hpp"
#include "Acts/Utilities/Intersection.hpp"

Expand Down Expand Up @@ -46,7 +46,7 @@ struct NavigationState {
const Portal* portal = nullptr;
/// The boundary check used for the candidate, boundary checks
/// can differ for sensitive surfaces and portals
BoundaryCheck boundaryCheck = BoundaryCheck(true);
BoundaryTolerance boundaryTolerance = BoundaryTolerance::None();
};

/// Surface candidate vector alias, this allows to use e.g. boost_small vector
Expand Down Expand Up @@ -85,7 +85,7 @@ struct NavigationState {
std::size_t surfaceCandidateIndex = 0;

/// Boundary directives for surfaces
BoundaryCheck surfaceBoundaryCheck = BoundaryCheck(true);
BoundaryTolerance surfaceBoundaryTolerance = BoundaryTolerance::None();

/// An overstep tolerance
ActsScalar overstepTolerance = -100 * UnitConstants::um;
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Navigation/NavigationStateFillers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Utilities/Intersection.hpp"

#include <vector>
Expand Down Expand Up @@ -52,7 +52,7 @@ struct SurfacesFiller {
std::for_each(surfaces.begin(), surfaces.end(), [&](const auto& s) {
nState.surfaceCandidates.push_back(NavigationState::SurfaceCandidate{
ObjectIntersection<Surface>::invalid(), s, nullptr,
nState.surfaceBoundaryCheck});
nState.surfaceBoundaryTolerance});
});
}
};
Expand All @@ -69,7 +69,7 @@ struct PortalsFiller {
std::for_each(portals.begin(), portals.end(), [&](const auto& p) {
nState.surfaceCandidates.push_back(NavigationState::SurfaceCandidate{
ObjectIntersection<Surface>::invalid(), nullptr, p,
BoundaryCheck(true)});
BoundaryTolerance::None()});
});
}
};
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Navigation/NavigationStateUpdaters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ inline void updateCandidates(const GeometryContext& gctx,

// Get the intersection @todo make a templated intersector
// TODO surface tolerance
auto sIntersection = sRep.intersect(gctx, position, direction,
c.boundaryCheck, s_onSurfaceTolerance);
auto sIntersection = sRep.intersect(
gctx, position, direction, c.boundaryTolerance, s_onSurfaceTolerance);
for (auto& si : sIntersection.split()) {
c.objectIntersection = si;
if (c.objectIntersection &&
Expand Down
7 changes: 4 additions & 3 deletions Core/include/Acts/Propagator/AtlasStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,17 @@ class AtlasStepper {
/// @param [in] surface The surface provided
/// @param [in] index The surface intersection index
/// @param [in] navDir The navigation direction
/// @param [in] bcheck The boundary check for this status update
/// @param [in] boundaryTolerance The boundary check for this status update
/// @param [in] surfaceTolerance Surface tolerance used for intersection
/// @param [in] logger Logger instance to use
Intersection3D::Status updateSurfaceStatus(
State& state, const Surface& surface, std::uint8_t index,
Direction navDir, const BoundaryCheck& bcheck,
Direction navDir, const BoundaryTolerance& boundaryTolerance,
ActsScalar surfaceTolerance = s_onSurfaceTolerance,
const Logger& logger = getDummyLogger()) const {
return detail::updateSingleSurfaceStatus<AtlasStepper>(
*this, state, surface, index, navDir, bcheck, surfaceTolerance, logger);
*this, state, surface, index, navDir, boundaryTolerance,
surfaceTolerance, logger);
}

/// Update step size
Expand Down
18 changes: 10 additions & 8 deletions Core/include/Acts/Propagator/DirectNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,13 @@ class DirectNavigator {
chooseIntersection(
state.geoContext, surface, stepper.position(state.stepping),
state.options.direction * stepper.direction(state.stepping),
BoundaryCheck(false), m_nearLimit, farLimit,
BoundaryTolerance::Infinite(), m_nearLimit, farLimit,
state.options.surfaceTolerance)
.index();
auto surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, index, state.options.direction,
BoundaryCheck(false), state.options.surfaceTolerance, *m_logger);
BoundaryTolerance::Infinite(), state.options.surfaceTolerance,
*m_logger);
if (surfaceStatus == Intersection3D::Status::unreachable) {
ACTS_VERBOSE(
"Surface not reachable anymore, switching to next one in "
Expand Down Expand Up @@ -285,12 +286,13 @@ class DirectNavigator {
chooseIntersection(
state.geoContext, surface, stepper.position(state.stepping),
state.options.direction * stepper.direction(state.stepping),
BoundaryCheck(false), m_nearLimit, farLimit,
BoundaryTolerance::Infinite(), m_nearLimit, farLimit,
state.options.surfaceTolerance)
.index();
auto surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, index, state.options.direction,
BoundaryCheck(false), state.options.surfaceTolerance, *m_logger);
BoundaryTolerance::Infinite(), state.options.surfaceTolerance,
*m_logger);
if (surfaceStatus == Intersection3D::Status::onSurface) {
// Set the current surface
state.navigation.currentSurface = *state.navigation.navSurfaceIter;
Expand Down Expand Up @@ -322,10 +324,10 @@ class DirectNavigator {
ObjectIntersection<Surface> chooseIntersection(
const GeometryContext& gctx, const Surface& surface,
const Vector3& position, const Vector3& direction,
const BoundaryCheck& bcheck, double nearLimit, double farLimit,
double tolerance) const {
auto intersections =
surface.intersect(gctx, position, direction, bcheck, tolerance);
const BoundaryTolerance& boundaryTolerance, double nearLimit,
double farLimit, double tolerance) const {
auto intersections = surface.intersect(gctx, position, direction,
boundaryTolerance, tolerance);

for (auto& intersection : intersections.split()) {
if (detail::checkIntersection(intersection, nearLimit, farLimit,
Expand Down
7 changes: 4 additions & 3 deletions Core/include/Acts/Propagator/EigenStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,17 @@ class EigenStepper {
/// @param [in] surface The surface provided
/// @param [in] index The surface intersection index
/// @param [in] navDir The navigation direction
/// @param [in] bcheck The boundary check for this status update
/// @param [in] boundaryTolerance The boundary check for this status update
/// @param [in] surfaceTolerance Surface tolerance used for intersection
/// @param [in] logger A @c Logger instance
Intersection3D::Status updateSurfaceStatus(
State& state, const Surface& surface, std::uint8_t index,
Direction navDir, const BoundaryCheck& bcheck,
Direction navDir, const BoundaryTolerance& boundaryTolerance,
ActsScalar surfaceTolerance = s_onSurfaceTolerance,
const Logger& logger = getDummyLogger()) const {
return detail::updateSingleSurfaceStatus<EigenStepper>(
*this, state, surface, index, navDir, bcheck, surfaceTolerance, logger);
*this, state, surface, index, navDir, boundaryTolerance,
surfaceTolerance, logger);
}

/// Update step size
Expand Down
Loading

0 comments on commit 11b1172

Please sign in to comment.