Skip to content

Commit

Permalink
refactor!: Single type/alias for intersection status (#3898)
Browse files Browse the repository at this point in the history
Seems more concise and consistent
  • Loading branch information
andiwand authored Nov 23, 2024
1 parent cafee58 commit 195dca3
Show file tree
Hide file tree
Showing 33 changed files with 169 additions and 207 deletions.
4 changes: 2 additions & 2 deletions Core/include/Acts/Navigation/DetectorNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class DetectorNavigator {
ACTS_VERBOSE(volInfo(state) << posInfo(state, stepper)
<< "surface status is " << surfaceStatus);

if (surfaceStatus == Intersection3D::Status::reachable) {
if (surfaceStatus == IntersectionStatus::reachable) {
ACTS_VERBOSE(volInfo(state)
<< posInfo(state, stepper) << "surface "
<< surface.center(state.geoContext).transpose()
Expand Down Expand Up @@ -292,7 +292,7 @@ class DetectorNavigator {
state.options.surfaceTolerance, logger());

// Check if we are at a surface
if (surfaceStatus == Intersection3D::Status::onSurface) {
if (surfaceStatus == IntersectionStatus::onSurface) {
ACTS_VERBOSE(volInfo(state)
<< posInfo(state, stepper) << "landed on surface");

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 @@ -9,13 +9,13 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Tolerance.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/Portal.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Utilities/Intersection.hpp"

#include <span>
#include <tuple>
#include <vector>

namespace Acts {
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/AtlasStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class AtlasStepper {
/// @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(
IntersectionStatus updateSurfaceStatus(
State& state, const Surface& surface, std::uint8_t index,
Direction navDir, const BoundaryTolerance& boundaryTolerance,
ActsScalar surfaceTolerance = s_onSurfaceTolerance,
Expand Down
12 changes: 5 additions & 7 deletions Core/include/Acts/Propagator/DirectNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
#pragma once

#include "Acts/Definitions/Direction.hpp"
#include "Acts/Geometry/BoundarySurfaceT.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/Geometry/Layer.hpp"
#include "Acts/Geometry/TrackingGeometry.hpp"
#include "Acts/Geometry/TrackingVolume.hpp"
#include "Acts/Propagator/ConstrainedStep.hpp"
#include "Acts/Propagator/NavigatorOptions.hpp"
#include "Acts/Propagator/NavigatorStatistics.hpp"
#include "Acts/Propagator/Propagator.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Intersection.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <algorithm>
#include <iterator>
#include <limits>
#include <memory>
#include <vector>
Expand Down Expand Up @@ -259,7 +257,7 @@ class DirectNavigator {
state.stepping, surface, index, state.options.direction,
BoundaryTolerance::Infinite(), state.options.surfaceTolerance,
*m_logger);
if (surfaceStatus == Intersection3D::Status::unreachable) {
if (surfaceStatus == IntersectionStatus::unreachable) {
ACTS_VERBOSE(
"Surface not reachable anymore, switching to next one in "
"sequence");
Expand Down Expand Up @@ -313,7 +311,7 @@ class DirectNavigator {
state.stepping, surface, index, state.options.direction,
BoundaryTolerance::Infinite(), state.options.surfaceTolerance,
*m_logger);
if (surfaceStatus == Intersection3D::Status::onSurface) {
if (surfaceStatus == IntersectionStatus::onSurface) {
// Set the current surface
state.navigation.currentSurface = state.navigation.navSurface();
ACTS_VERBOSE("Current surface set to "
Expand All @@ -326,7 +324,7 @@ class DirectNavigator {
.at(state.navigation.surfaceIndex)
->geometryId());
}
} else if (surfaceStatus == Intersection3D::Status::reachable) {
} else if (surfaceStatus == IntersectionStatus::reachable) {
ACTS_VERBOSE("Next surface reachable at distance "
<< stepper.outputStepSize(state.stepping));
}
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/EigenStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class EigenStepper {
/// @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(
IntersectionStatus updateSurfaceStatus(
State& state, const Surface& surface, std::uint8_t index,
Direction navDir, const BoundaryTolerance& boundaryTolerance,
ActsScalar surfaceTolerance = s_onSurfaceTolerance,
Expand Down
12 changes: 6 additions & 6 deletions Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class MultiEigenStepperLoop : public EigenStepper<extension_t> {
struct Component {
SingleState state;
ActsScalar weight;
Intersection3D::Status status;
IntersectionStatus status;
};

/// Particle hypothesis
Expand Down Expand Up @@ -255,7 +255,7 @@ class MultiEigenStepperLoop : public EigenStepper<extension_t> {
const auto& [weight, singlePars] = multipars[i];
components.push_back(
{SingleState(gctx, bfield->makeCache(mctx), singlePars, ssize),
weight, Intersection3D::Status::onSurface});
weight, IntersectionStatus::onSurface});
}

if (std::get<2>(multipars.components().front())) {
Expand Down Expand Up @@ -398,7 +398,7 @@ class MultiEigenStepperLoop : public EigenStepper<extension_t> {
void removeMissedComponents(State& state) const {
auto new_end = std::remove_if(
state.components.begin(), state.components.end(), [](const auto& cmp) {
return cmp.status == Intersection3D::Status::missed;
return cmp.status == IntersectionStatus::missed;
});

state.components.erase(new_end, state.components.end());
Expand Down Expand Up @@ -441,7 +441,7 @@ class MultiEigenStepperLoop : public EigenStepper<extension_t> {
{SingleState(state.geoContext,
SingleStepper::m_bField->makeCache(state.magContext),
pars),
weight, Intersection3D::Status::onSurface});
weight, IntersectionStatus::onSurface});

return ComponentProxy{state.components.back(), state};
}
Expand Down Expand Up @@ -520,12 +520,12 @@ class MultiEigenStepperLoop : public EigenStepper<extension_t> {
/// @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(
IntersectionStatus updateSurfaceStatus(
State& state, const Surface& surface, std::uint8_t index,
Direction navDir, const BoundaryTolerance& boundaryTolerance,
ActsScalar surfaceTolerance = s_onSurfaceTolerance,
const Logger& logger = getDummyLogger()) const {
using Status = Intersection3D::Status;
using Status = IntersectionStatus;

std::array<int, 3> counts = {0, 0, 0};

Expand Down
9 changes: 4 additions & 5 deletions Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ template <typename E, typename R>
template <typename propagator_state_t, typename navigator_t>
Result<double> MultiEigenStepperLoop<E, R>::step(
propagator_state_t& state, const navigator_t& navigator) const {
using Status = Acts::Intersection3D::Status;
using Status = Acts::IntersectionStatus;

State& stepping = state.stepping;
auto& components = stepping.components;
Expand Down Expand Up @@ -137,10 +137,9 @@ Result<double> MultiEigenStepperLoop<E, R>::step(
// If at least one component is on a surface, we can remove all missed
// components before the step. If not, we must keep them for the case that all
// components miss and we need to retarget
const auto cmpsOnSurface =
std::count_if(components.cbegin(), components.cend(), [&](auto& cmp) {
return cmp.status == Intersection3D::Status::onSurface;
});
const auto cmpsOnSurface = std::count_if(
components.cbegin(), components.cend(),
[&](auto& cmp) { return cmp.status == IntersectionStatus::onSurface; });

if (cmpsOnSurface > 0) {
removeMissedComponents(stepping);
Expand Down
8 changes: 4 additions & 4 deletions Core/include/Acts/Propagator/MultiStepperAborters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ struct MultiStepperSurfaceReached : public SurfaceReached {
averageOnSurfaceTolerance)
.closest();

if (sIntersection.status() == Intersection3D::Status::onSurface) {
if (sIntersection.status() == IntersectionStatus::onSurface) {
ACTS_VERBOSE(
"MultiStepperSurfaceReached aborter | "
"Reached target in average mode");
for (auto cmp : stepper.componentIterable(state.stepping)) {
cmp.status() = Intersection3D::Status::onSurface;
cmp.status() = IntersectionStatus::onSurface;
}

return true;
Expand All @@ -84,10 +84,10 @@ struct MultiStepperSurfaceReached : public SurfaceReached {

if (!SurfaceReached::checkAbort(singleState, singleStepper, navigator,
logger)) {
cmp.status() = Acts::Intersection3D::Status::reachable;
cmp.status() = Acts::IntersectionStatus::reachable;
reached = false;
} else {
cmp.status() = Acts::Intersection3D::Status::onSurface;
cmp.status() = Acts::IntersectionStatus::onSurface;
}
}

Expand Down
10 changes: 5 additions & 5 deletions Core/include/Acts/Propagator/Navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ class Navigator {
auto surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, *surface, intersection.index(), state.options.direction,
BoundaryTolerance::None(), state.options.surfaceTolerance, logger());
if (surfaceStatus == Intersection3D::Status::onSurface) {
if (surfaceStatus == IntersectionStatus::onSurface) {
ACTS_VERBOSE(volInfo(state)
<< "Status Surface successfully hit, storing it.");
// Set in navigation state, so actors and aborters can access it
Expand Down Expand Up @@ -725,7 +725,7 @@ class Navigator {
state.stepping, *surface, intersection.index(),
state.options.direction, boundaryTolerance,
state.options.surfaceTolerance, logger());
if (surfaceStatus == Intersection3D::Status::reachable) {
if (surfaceStatus == IntersectionStatus::reachable) {
ACTS_VERBOSE(volInfo(state)
<< "Surface reachable, step size updated to "
<< stepper.outputStepSize(state.stepping));
Expand Down Expand Up @@ -815,7 +815,7 @@ class Navigator {
state.stepping, *layerSurface, intersection.index(),
state.options.direction, BoundaryTolerance::None(),
state.options.surfaceTolerance, logger());
if (layerStatus == Intersection3D::Status::reachable) {
if (layerStatus == IntersectionStatus::reachable) {
ACTS_VERBOSE(volInfo(state) << "Layer reachable, step size updated to "
<< stepper.outputStepSize(state.stepping));
return true;
Expand Down Expand Up @@ -937,7 +937,7 @@ class Navigator {
state.stepping, *boundarySurface, intersection.index(),
state.options.direction, BoundaryTolerance::None(),
state.options.surfaceTolerance, logger());
if (boundaryStatus == Intersection3D::Status::reachable) {
if (boundaryStatus == IntersectionStatus::reachable) {
ACTS_VERBOSE(volInfo(state)
<< "Boundary reachable, step size updated to "
<< stepper.outputStepSize(state.stepping));
Expand Down Expand Up @@ -1160,7 +1160,7 @@ class Navigator {
state.options.direction, BoundaryTolerance::None(),
state.options.surfaceTolerance, logger());
// the only advance could have been to the target
if (targetStatus == Intersection3D::Status::onSurface) {
if (targetStatus == IntersectionStatus::onSurface) {
// set the target surface
state.navigation.currentSurface = state.navigation.targetSurface;
ACTS_VERBOSE(volInfo(state)
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 @@ -118,7 +118,7 @@ struct SurfaceReached {

bool reached = false;

if (closest.status() == Intersection3D::Status::onSurface) {
if (closest.status() == IntersectionStatus::onSurface) {
const double distance = closest.pathLength();
ACTS_VERBOSE(
"SurfaceReached aborter | "
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/StraightLineStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class StraightLineStepper {
/// @param [in] boundaryTolerance The boundary check for this status update
/// @param [in] surfaceTolerance Surface tolerance used for intersection
/// @param [in] logger A logger instance
Intersection3D::Status updateSurfaceStatus(
IntersectionStatus updateSurfaceStatus(
State& state, const Surface& surface, std::uint8_t index,
Direction navDir, const BoundaryTolerance& boundaryTolerance,
ActsScalar surfaceTolerance = s_onSurfaceTolerance,
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Propagator/SympyStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class SympyStepper {
/// @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(
IntersectionStatus updateSurfaceStatus(
State& state, const Surface& surface, std::uint8_t index,
Direction navDir, const BoundaryTolerance& boundaryTolerance,
ActsScalar surfaceTolerance = s_onSurfaceTolerance,
Expand Down
8 changes: 4 additions & 4 deletions Core/include/Acts/Propagator/TryAllNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class TryAllNavigator : public TryAllNavigatorBase {
const auto& intersection = candidate.intersection;
const Surface& surface = *intersection.object();

Intersection3D::Status surfaceStatus = stepper.updateSurfaceStatus(
IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, intersection.index(),
state.options.direction, BoundaryTolerance::Infinite(),
state.options.surfaceTolerance, logger());
Expand Down Expand Up @@ -463,7 +463,7 @@ class TryAllNavigator : public TryAllNavigatorBase {
const auto& intersection = candidate.intersection;
const Surface& surface = *intersection.object();

Intersection3D::Status surfaceStatus = stepper.updateSurfaceStatus(
IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, intersection.index(),
state.options.direction, BoundaryTolerance::None(),
state.options.surfaceTolerance, logger());
Expand Down Expand Up @@ -788,7 +788,7 @@ class TryAllOverstepNavigator : public TryAllNavigatorBase {
const auto& intersection = candidate.intersection;
const Surface& surface = *intersection.object();

Intersection3D::Status surfaceStatus = stepper.updateSurfaceStatus(
IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, intersection.index(),
state.options.direction, BoundaryTolerance::Infinite(),
state.options.surfaceTolerance, logger());
Expand All @@ -815,7 +815,7 @@ class TryAllOverstepNavigator : public TryAllNavigatorBase {
const auto& intersection = candidate.intersection;
const Surface& surface = *intersection.object();

Intersection3D::Status surfaceStatus = stepper.updateSurfaceStatus(
IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus(
state.stepping, surface, intersection.index(),
state.options.direction, BoundaryTolerance::None(),
state.options.surfaceTolerance, logger());
Expand Down
10 changes: 5 additions & 5 deletions Core/include/Acts/Propagator/detail/SteppingHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Acts::detail {
/// @param surface [in] The surface provided
/// @param boundaryTolerance [in] The boundary check for this status update
template <typename stepper_t>
Acts::Intersection3D::Status updateSingleSurfaceStatus(
Acts::IntersectionStatus updateSingleSurfaceStatus(
const stepper_t& stepper, typename stepper_t::State& state,
const Surface& surface, std::uint8_t index, Direction navDir,
const BoundaryTolerance& boundaryTolerance, ActsScalar surfaceTolerance,
Expand All @@ -46,11 +46,11 @@ Acts::Intersection3D::Status updateSingleSurfaceStatus(
surfaceTolerance)[index];

// The intersection is on surface already
if (sIntersection.status() == Intersection3D::Status::onSurface) {
if (sIntersection.status() == IntersectionStatus::onSurface) {
// Release navigation step size
state.stepSize.release(ConstrainedStep::actor);
ACTS_VERBOSE("Intersection: state is ON SURFACE");
return Intersection3D::Status::onSurface;
return IntersectionStatus::onSurface;
}

const double nearLimit = std::numeric_limits<double>::lowest();
Expand All @@ -62,11 +62,11 @@ Acts::Intersection3D::Status updateSingleSurfaceStatus(
ACTS_VERBOSE("Surface is reachable");
stepper.updateStepSize(state, sIntersection.pathLength(),
ConstrainedStep::actor);
return Intersection3D::Status::reachable;
return IntersectionStatus::reachable;
}

ACTS_VERBOSE("Surface is NOT reachable");
return Intersection3D::Status::unreachable;
return IntersectionStatus::unreachable;
}

/// Update the Step size - single component
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Surfaces/detail/PlanarHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ inline Intersection3D intersect(const Transform3& transform,
// Translate that into a path
ActsScalar path = (pnormal.dot((pcenter - position))) / (denom);
// Is valid hence either on surface or reachable
Intersection3D::Status status = std::abs(path) < std::abs(tolerance)
? Intersection3D::Status::onSurface
: Intersection3D::Status::reachable;
IntersectionStatus status = std::abs(path) < std::abs(tolerance)
? IntersectionStatus::onSurface
: IntersectionStatus::reachable;
// Return the intersection
return Intersection3D{(position + path * direction), path, status};
}
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/TrackFitting/GaussianSumFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "Acts/Propagator/Navigator.hpp"
#include "Acts/Propagator/StandardAborters.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/TrackFitting/GsfError.hpp"
#include "Acts/TrackFitting/GsfOptions.hpp"
#include "Acts/TrackFitting/detail/GsfActor.hpp"
#include "Acts/Utilities/Helpers.hpp"
Expand Down Expand Up @@ -217,7 +218,7 @@ struct GaussianSumFitter {
.closest()
.status();

if (intersectionStatusStartSurface != Intersection3D::Status::onSurface) {
if (intersectionStatusStartSurface != IntersectionStatus::onSurface) {
ACTS_DEBUG(
"Surface intersection of start parameters WITH bound-check failed");
}
Expand Down
Loading

0 comments on commit 195dca3

Please sign in to comment.