Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Explicit BoundaryTolerance constructors #3974

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,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, BoundaryTolerance::Infinite())
dir, BoundaryTolerance::infinite())
.closest()
.position();

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/GridPortalLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ class GridPortalLinkT : public GridPortalLink {
Result<const TrackingVolume*> resolveVolume(
const GeometryContext& /*gctx*/, const Vector2& position,
double /*tolerance*/ = s_onSurfaceTolerance) const override {
assert(surface().insideBounds(position, BoundaryTolerance::None()));
assert(surface().insideBounds(position, BoundaryTolerance::none()));
return m_grid.atPosition(m_projection(position));
}

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Layer : public virtual GeometryObject {
/// @return boolean that indicates success of the operation
virtual bool isOnLayer(const GeometryContext& gctx, const Vector3& position,
const BoundaryTolerance& boundaryTolerance =
BoundaryTolerance::None()) const;
BoundaryTolerance::none()) const;

/// Return method for the approach descriptor, can be nullptr
const ApproachDescriptor* approachDescriptor() const;
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/NavigationLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class NavigationLayer : public Layer {
/// @return boolean that indicates if the position is on surface
bool isOnLayer(const GeometryContext& gctx, const Vector3& gp,
const BoundaryTolerance& boundaryTolerance =
BoundaryTolerance::None()) const final;
BoundaryTolerance::none()) const final;

/// Accept layer according to the following collection directives
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Navigation/NavigationDelegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct NavigationArguments {
Vector3 position;
Vector3 direction;

BoundaryTolerance tolerance = BoundaryTolerance::None();
BoundaryTolerance tolerance = BoundaryTolerance::none();
};

/// Central alias for the navigation delegate. This type is owning to support
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Navigation/NavigationState.hpp
Original file line number Diff line number Diff line change
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
BoundaryTolerance boundaryTolerance = BoundaryTolerance::None();
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
BoundaryTolerance surfaceBoundaryTolerance = BoundaryTolerance::None();
BoundaryTolerance surfaceBoundaryTolerance = BoundaryTolerance::none();

/// An overstep tolerance
double overstepTolerance = -100 * UnitConstants::um;
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Navigation/NavigationStateFillers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
BoundaryTolerance::None()});
BoundaryTolerance::none()});
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Navigation/NavigationStateUpdaters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ inline void intitializeCandidates(const GeometryContext& gctx,
sc.portal != nullptr ? s_onSurfaceTolerance : nState.overstepTolerance;
// Boundary tolerance is forced to 0 for portals
BoundaryTolerance boundaryTolerance =
sc.portal != nullptr ? BoundaryTolerance::None() : sc.boundaryTolerance;
sc.portal != nullptr ? BoundaryTolerance::none() : sc.boundaryTolerance;
// Check the surface intersection
auto sIntersection = surface.intersect(
gctx, position, direction, boundaryTolerance, s_onSurfaceTolerance);
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Navigation/NavigationStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class NavigationStream {
const Acts::Experimental::Portal* gen2Portal = nullptr;
const Portal* portal = nullptr;
/// The boundary tolerance
BoundaryTolerance bTolerance = BoundaryTolerance::None();
BoundaryTolerance bTolerance = BoundaryTolerance::none();
/// Convenience access to surface
const Surface& surface() const { return *intersection.object(); }
/// Cinvencience access to the path length
Expand Down
8 changes: 4 additions & 4 deletions Core/include/Acts/Propagator/DirectNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ class DirectNavigator {
chooseIntersection(
state.geoContext, surface, stepper.position(state.stepping),
state.options.direction * stepper.direction(state.stepping),
BoundaryTolerance::Infinite(), state.navigation.options.nearLimit,
BoundaryTolerance::infinite(), state.navigation.options.nearLimit,
farLimit, state.options.surfaceTolerance)
.index();
auto surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, index, state.options.direction,
BoundaryTolerance::Infinite(), state.options.surfaceTolerance,
BoundaryTolerance::infinite(), state.options.surfaceTolerance,
*m_logger);
if (surfaceStatus == IntersectionStatus::unreachable) {
ACTS_VERBOSE(
Expand Down Expand Up @@ -304,12 +304,12 @@ class DirectNavigator {
chooseIntersection(
state.geoContext, surface, stepper.position(state.stepping),
state.options.direction * stepper.direction(state.stepping),
BoundaryTolerance::Infinite(), state.navigation.options.nearLimit,
BoundaryTolerance::infinite(), state.navigation.options.nearLimit,
farLimit, state.options.surfaceTolerance)
.index();
auto surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, index, state.options.direction,
BoundaryTolerance::Infinite(), state.options.surfaceTolerance,
BoundaryTolerance::infinite(), state.options.surfaceTolerance,
*m_logger);
if (surfaceStatus == IntersectionStatus::onSurface) {
// Set the current surface
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ class MultiEigenStepperLoop : public EigenStepper<extension_t> {
auto intersection = surface.intersect(
component.state.geoContext, SingleStepper::position(component.state),
direction * SingleStepper::direction(component.state),
BoundaryTolerance::None())[oIntersection.index()];
BoundaryTolerance::none())[oIntersection.index()];

SingleStepper::updateStepSize(component.state, intersection, direction,
release);
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ auto MultiEigenStepperLoop<E, R>::boundState(
.intersect(state.geoContext,
cmpState.pars.template segment<3>(eFreePos0),
cmpState.pars.template segment<3>(eFreeDir0),
BoundaryTolerance::Infinite())
BoundaryTolerance::infinite())
.closest()
.position();

Expand Down
18 changes: 9 additions & 9 deletions Core/include/Acts/Propagator/Navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Acts {
template <typename object_t>
struct NavigationOptions {
/// The boundary check directive
BoundaryTolerance boundaryTolerance = BoundaryTolerance::None();
BoundaryTolerance boundaryTolerance = BoundaryTolerance::none();

// How to resolve the geometry
/// Always look for sensitive
Expand Down Expand Up @@ -367,7 +367,7 @@ class Navigator {
assert(state.navigation.currentSurface->isOnSurface(
state.geoContext, stepper.position(state.stepping),
stepper.direction(state.stepping),
BoundaryTolerance::Infinite(),
BoundaryTolerance::infinite(),
state.options.surfaceTolerance) &&
"Stepper not on surface");
}
Expand Down Expand Up @@ -596,7 +596,7 @@ class Navigator {
assert(state.navigation.currentSurface->isOnSurface(
state.geoContext, stepper.position(state.stepping),
stepper.direction(state.stepping),
BoundaryTolerance::Infinite(),
BoundaryTolerance::infinite(),
state.options.surfaceTolerance) &&
"Stepper not on surface");
}
Expand Down Expand Up @@ -648,7 +648,7 @@ class Navigator {
// it the current one to pass it to the other actors
auto surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, *surface, intersection.index(), state.options.direction,
BoundaryTolerance::None(), state.options.surfaceTolerance, logger());
BoundaryTolerance::none(), state.options.surfaceTolerance, logger());
if (surfaceStatus == IntersectionStatus::onSurface) {
ACTS_VERBOSE(volInfo(state)
<< "Status Surface successfully hit, storing it.");
Expand Down Expand Up @@ -713,11 +713,11 @@ class Navigator {
ACTS_VERBOSE(volInfo(state) << "Next surface candidate will be "
<< surface->geometryId());
// Estimate the surface status
BoundaryTolerance boundaryTolerance = BoundaryTolerance::None();
BoundaryTolerance boundaryTolerance = BoundaryTolerance::none();
for (auto it = externalSurfaceRange.first;
it != externalSurfaceRange.second; it++) {
if (surface->geometryId() == it->second) {
boundaryTolerance = BoundaryTolerance::Infinite();
boundaryTolerance = BoundaryTolerance::infinite();
break;
}
}
Expand Down Expand Up @@ -813,7 +813,7 @@ class Navigator {
// Try to step towards it
auto layerStatus = stepper.updateSurfaceStatus(
state.stepping, *layerSurface, intersection.index(),
state.options.direction, BoundaryTolerance::None(),
state.options.direction, BoundaryTolerance::none(),
state.options.surfaceTolerance, logger());
if (layerStatus == IntersectionStatus::reachable) {
ACTS_VERBOSE(volInfo(state) << "Layer reachable, step size updated to "
Expand Down Expand Up @@ -935,7 +935,7 @@ class Navigator {
// Step towards the boundary surfrace
auto boundaryStatus = stepper.updateSurfaceStatus(
state.stepping, *boundarySurface, intersection.index(),
state.options.direction, BoundaryTolerance::None(),
state.options.direction, BoundaryTolerance::none(),
state.options.surfaceTolerance, logger());
if (boundaryStatus == IntersectionStatus::reachable) {
ACTS_VERBOSE(volInfo(state)
Expand Down Expand Up @@ -1157,7 +1157,7 @@ class Navigator {
// TODO we do not know the intersection index - passing 0
auto targetStatus = stepper.updateSurfaceStatus(
state.stepping, *state.navigation.targetSurface, 0,
state.options.direction, BoundaryTolerance::None(),
state.options.direction, BoundaryTolerance::none(),
state.options.surfaceTolerance, logger());
// the only advance could have been to the target
if (targetStatus == IntersectionStatus::onSurface) {
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/StandardAborters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct PathLimitReached {
/// propagation abort
struct SurfaceReached {
const Surface* surface = nullptr;
BoundaryTolerance boundaryTolerance = BoundaryTolerance::None();
BoundaryTolerance boundaryTolerance = BoundaryTolerance::none();

// TODO https://github.com/acts-project/acts/issues/2738
/// Distance limit to discard intersections "behind us"
Expand Down
10 changes: 5 additions & 5 deletions Core/include/Acts/Propagator/TryAllNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TryAllNavigatorBase {

/// Which boundary checks to perform for surface approach
BoundaryTolerance boundaryToleranceSurfaceApproach =
BoundaryTolerance::None();
BoundaryTolerance::none();
};

struct Options : public NavigatorPlainOptions {
Expand Down Expand Up @@ -436,7 +436,7 @@ class TryAllNavigator : public TryAllNavigatorBase {

IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, intersection.index(),
state.options.direction, BoundaryTolerance::Infinite(),
state.options.direction, BoundaryTolerance::infinite(),
state.options.surfaceTolerance, logger());

if (surfaceStatus != IntersectionStatus::onSurface) {
Expand Down Expand Up @@ -465,7 +465,7 @@ class TryAllNavigator : public TryAllNavigatorBase {

IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, intersection.index(),
state.options.direction, BoundaryTolerance::None(),
state.options.direction, BoundaryTolerance::none(),
state.options.surfaceTolerance, logger());

if (surfaceStatus != IntersectionStatus::onSurface) {
Expand Down Expand Up @@ -790,7 +790,7 @@ class TryAllOverstepNavigator : public TryAllNavigatorBase {

IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, intersection.index(),
state.options.direction, BoundaryTolerance::Infinite(),
state.options.direction, BoundaryTolerance::infinite(),
state.options.surfaceTolerance, logger());

if (surfaceStatus != IntersectionStatus::onSurface) {
Expand All @@ -817,7 +817,7 @@ class TryAllOverstepNavigator : public TryAllNavigatorBase {

IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, intersection.index(),
state.options.direction, BoundaryTolerance::None(),
state.options.direction, BoundaryTolerance::none(),
state.options.surfaceTolerance, logger());

if (surfaceStatus != IntersectionStatus::onSurface) {
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Propagator/detail/NavigationHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ inline void emplaceAllVolumeCandidates(

for (const auto& boundary : boundaries) {
addCandidate(boundary.get(), &boundary->surfaceRepresentation(),
BoundaryTolerance::None());
BoundaryTolerance::none());
}
}

Expand All @@ -134,15 +134,15 @@ inline void emplaceAllVolumeCandidates(
if (!resolveSensitive ||
layer->surfaceRepresentation().surfaceMaterial() != nullptr) {
addCandidate(layer.get(), &layer->surfaceRepresentation(),
BoundaryTolerance::None());
BoundaryTolerance::none());
}

if (layer->approachDescriptor() != nullptr) {
const auto& approaches =
layer->approachDescriptor()->containedSurfaces();

for (const auto& approach : approaches) {
addCandidate(layer.get(), approach, BoundaryTolerance::None());
addCandidate(layer.get(), approach, BoundaryTolerance::none());
}
}

Expand Down
38 changes: 31 additions & 7 deletions Core/include/Acts/Surfaces/BoundaryTolerance.hpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can move the structs to the private section and have public factory functions with uppercase like Infinite(). Maybe we name the structs like InfiniteParams or something like that?

Personally I would spell the parameters out to ease IDE guidance and compiler errors.

Copy link
Member Author

@paulgessinger paulgessinger Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we can try this. I can spell the parameters out

Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ class BoundaryTolerance {
/// Infinite tolerance i.e. no boundary check
struct Infinite {};

static auto infinite() { return BoundaryTolerance{Infinite{}}; }

/// No tolerance i.e. exact boundary check
struct None {};

static auto none() { return BoundaryTolerance{None{}}; }

/// Absolute tolerance in bound coordinates
struct AbsoluteBound {
double tolerance0{};
Expand All @@ -73,6 +77,11 @@ class BoundaryTolerance {
: tolerance0(tolerance0_), tolerance1(tolerance1_) {}
};

template <typename... Ts>
static auto absoluteBound(Ts&&... args) {
return BoundaryTolerance{AbsoluteBound{std::forward<Ts>(args)...}};
}

/// Absolute tolerance in Cartesian coordinates
struct AbsoluteCartesian {
double tolerance0{};
Expand All @@ -83,6 +92,11 @@ class BoundaryTolerance {
: tolerance0(tolerance0_), tolerance1(tolerance1_) {}
};

template <typename... Ts>
static auto absoluteCartesian(Ts&&... args) {
return BoundaryTolerance{AbsoluteCartesian{std::forward<Ts>(args)...}};
}

/// Absolute tolerance in Euclidean distance
struct AbsoluteEuclidean {
double tolerance{};
Expand All @@ -91,6 +105,11 @@ class BoundaryTolerance {
explicit AbsoluteEuclidean(double tolerance_) : tolerance(tolerance_) {}
};

template <typename... Ts>
static auto absoluteEuclidean(Ts&&... args) {
return BoundaryTolerance{AbsoluteEuclidean{std::forward<Ts>(args)...}};
}

/// Chi2 tolerance in bound coordinates
struct Chi2Bound {
double maxChi2{};
Expand All @@ -101,25 +120,30 @@ class BoundaryTolerance {
: maxChi2(maxChi2_), weight(weight_) {}
};

template <typename... Ts>
static auto chi2Bound(Ts&&... args) {
return BoundaryTolerance{Chi2Bound{std::forward<Ts>(args)...}};
}

/// Underlying variant type
using Variant = std::variant<Infinite, None, AbsoluteBound, AbsoluteCartesian,
AbsoluteEuclidean, Chi2Bound>;

/// Construct with infinite tolerance.
BoundaryTolerance(const Infinite& infinite);
explicit BoundaryTolerance(const Infinite& infinite);
/// Construct with no tolerance.
BoundaryTolerance(const None& none);
explicit BoundaryTolerance(const None& none);
/// Construct with absolute tolerance in bound coordinates.
BoundaryTolerance(const AbsoluteBound& AbsoluteBound);
explicit BoundaryTolerance(const AbsoluteBound& AbsoluteBound);
/// Construct with absolute tolerance in Cartesian coordinates.
BoundaryTolerance(const AbsoluteCartesian& absoluteCartesian);
explicit BoundaryTolerance(const AbsoluteCartesian& absoluteCartesian);
/// Construct with absolute tolerance in Euclidean distance.
BoundaryTolerance(const AbsoluteEuclidean& absoluteEuclidean);
explicit BoundaryTolerance(const AbsoluteEuclidean& absoluteEuclidean);
/// Construct with chi2 tolerance in bound coordinates.
BoundaryTolerance(const Chi2Bound& Chi2Bound);
explicit BoundaryTolerance(const Chi2Bound& Chi2Bound);

/// Construct from variant
BoundaryTolerance(Variant variant);
explicit BoundaryTolerance(Variant variant);

/// Check if the tolerance is infinite.
bool isInfinite() const;
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/ConeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class ConeBounds : public SurfaceBounds {
/// @return is a boolean indicating if the position is inside
bool inside(const Vector2& lposition,
const BoundaryTolerance& boundaryTolerance =
BoundaryTolerance::None()) const final;
BoundaryTolerance::none()) const final;

/// Output Method for std::ostream
///
Expand Down
Loading
Loading