From 1adb9be1e762c5028891b1fbcfc81735a79faef7 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 13 Dec 2024 17:29:36 +0100 Subject: [PATCH] fix navigator --- Core/include/Acts/Propagator/Navigator.hpp | 9 +++++++-- Tests/UnitTests/Core/Propagator/NavigatorTests.cpp | 12 ++++++++++++ .../SpacePointFormation/SpacePointBuilderTests.cpp | 9 ++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Core/include/Acts/Propagator/Navigator.hpp b/Core/include/Acts/Propagator/Navigator.hpp index c1cca9a0220..b409b85197a 100644 --- a/Core/include/Acts/Propagator/Navigator.hpp +++ b/Core/include/Acts/Propagator/Navigator.hpp @@ -188,6 +188,11 @@ class Navigator { NavigatorStatistics statistics; + void resetAfterLayerSwitch() { + navSurfaces.clear(); + navSurfaceIndex.reset(); + } + void resetAfterVolumeSwitch() { navSurfaces.clear(); navSurfaceIndex.reset(); @@ -522,8 +527,7 @@ class Navigator { state.navigationStage = Stage::surfaceTarget; // partial reset - state.navSurfaces.clear(); - state.navSurfaceIndex = -1; + state.resetAfterLayerSwitch(); return; } @@ -537,6 +541,7 @@ class Navigator { state.currentVolume = boundary->attachedVolume(state.options.geoContext, position, direction); + // partial reset state.resetAfterVolumeSwitch(); if (state.currentVolume != nullptr) { diff --git a/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp b/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp index 64f37fc426e..f540c560756 100644 --- a/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp @@ -261,6 +261,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { // Estimate the next target NavigationTarget target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); // A layer has been found BOOST_CHECK_EQUAL(state.navLayers.size(), 1u); // The index should points to the begin @@ -296,6 +297,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { // Estimate the next target target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); // Do the step towards the boundary step(position, direction, target); @@ -308,6 +310,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { // Estimate the next target target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); // Intersect the target targetIntersection = target.surface->intersect(tgContext, position, direction) .closestForward(); @@ -323,6 +326,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { // Estimate the next target target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); // Step through the surfaces on first layer for (std::size_t isf = 0; isf < 5; ++isf) { @@ -332,6 +336,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { navigator.handleSurfaceReached(state, position, direction, *target.surface); // ACTORS - ABORTERS - PRE STEP target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); ACTS_INFO("<<< Test 1e-1i >>> step within 1st layer at " << toString(position)); @@ -344,6 +349,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { navigator.handleSurfaceReached(state, position, direction, *target.surface); // ACTORS - ABORTERS - PRE STEP target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); ACTS_INFO("<<< Test 1j >>> step to 2nd layer at " << toString(position)); @@ -355,6 +361,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { navigator.handleSurfaceReached(state, position, direction, *target.surface); // ACTORS - ABORTERS - PRE STEP target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); ACTS_INFO("<<< Test 1k-1o >>> step within 2nd layer at " << toString(position)); @@ -367,6 +374,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { navigator.handleSurfaceReached(state, position, direction, *target.surface); // ACTORS - ABORTERS - PRE STEP target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); ACTS_INFO("<<< Test 1p >>> step to 3rd layer at " << toString(position)); @@ -378,6 +386,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { navigator.handleSurfaceReached(state, position, direction, *target.surface); // ACTORS - ABORTERS - PRE STEP target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); ACTS_INFO("<<< Test 1q-1s >>> step within 3rd layer at " << toString(position)); @@ -390,6 +399,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { navigator.handleSurfaceReached(state, position, direction, *target.surface); // ACTORS - ABORTERS - PRE STEP target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); ACTS_INFO("<<< Test 1t >>> step to 4th layer at " << toString(position)); @@ -401,6 +411,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { navigator.handleSurfaceReached(state, position, direction, *target.surface); // ACTORS - ABORTERS - PRE STEP target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(!target.isNone()); ACTS_INFO("<<< Test 1t-1v >>> step within 4th layer at " << toString(position)); @@ -413,6 +424,7 @@ BOOST_AUTO_TEST_CASE(Navigator_target_methods) { navigator.handleSurfaceReached(state, position, direction, *target.surface); // ACTORS - ABORTERS - PRE STEP target = navigator.nextTarget(state, position, direction); + BOOST_CHECK(target.isNone()); ACTS_INFO("<<< Test 1w >>> step to boundary at " << toString(position)); } diff --git a/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp b/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp index 6d043178320..d54645d6c87 100644 --- a/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp +++ b/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp @@ -10,10 +10,8 @@ #include #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/Direction.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Definitions/Units.hpp" -#include "Acts/EventData/GenericCurvilinearTrackParameters.hpp" #include "Acts/EventData/SourceLink.hpp" #include "Acts/EventData/TrackParameters.hpp" #include "Acts/EventData/detail/TestSourceLink.hpp" @@ -25,7 +23,6 @@ #include "Acts/Propagator/EigenStepper.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" -#include "Acts/Propagator/StraightLineStepper.hpp" #include "Acts/SpacePointFormation/SpacePointBuilder.hpp" #include "Acts/SpacePointFormation/SpacePointBuilderConfig.hpp" #include "Acts/SpacePointFormation/SpacePointBuilderOptions.hpp" @@ -34,10 +31,8 @@ #include "Acts/Tests/CommonHelpers/MeasurementsCreator.hpp" #include "Acts/Tests/CommonHelpers/TestSpacePoint.hpp" -#include #include #include -#include #include #include #include @@ -49,11 +44,11 @@ using namespace Acts::UnitLiterals; namespace Acts::Test { -using StraightPropagator = Propagator; using TestSourceLink = detail::Test::TestSourceLink; using ConstantFieldStepper = EigenStepper<>; using ConstantFieldPropagator = Propagator; -// Construct initial track parameters. + +/// Construct initial track parameters. CurvilinearTrackParameters makeParameters(double phi, double theta, double p, double q) { // create covariance matrix from reasonable standard deviations