Skip to content

Commit

Permalink
refactor: Clean navigator state creation (#4070)
Browse files Browse the repository at this point in the history
Minor change - cleans out the navigator state creation a bit

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Streamlined the navigation state initialization by consolidating how certain key attributes are set. This update improves consistency and clarity in the navigation process.
  
- **Tests**
  - Updated unit tests to align with the revised state initialization, ensuring reliable verification of navigation behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
andiwand authored Feb 6, 2025
1 parent 19a4a04 commit b94ecd1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Core/include/Acts/Propagator/Navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ class Navigator {

State makeState(const Options& options) const {
State state(options);
state.startSurface = options.startSurface;
state.targetSurface = options.targetSurface;
return state;
}

Expand Down Expand Up @@ -279,6 +277,9 @@ class Navigator {

state.reset();

state.startSurface = state.options.startSurface;
state.targetSurface = state.options.targetSurface;

// Fast Navigation initialization for start condition:
// - short-cut through object association, saves navigation in the
// - geometry and volume tree search for the lowest volume
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Propagator/TryAllNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class TryAllNavigatorBase {

ACTS_VERBOSE("initialize");

state.startSurface = state.options.startSurface;
state.targetSurface = state.options.targetSurface;

const TrackingVolume* startVolume = nullptr;

if (state.startSurface != nullptr &&
Expand Down Expand Up @@ -261,9 +264,6 @@ class TryAllNavigator : public TryAllNavigatorBase {

State makeState(const Options& options) const {
State state(options);
state.startSurface = options.startSurface;
state.targetSurface = options.targetSurface;

return state;
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests/Core/Propagator/NavigatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ BOOST_AUTO_TEST_CASE(Navigator_status_methods) {
const TrackingVolume* startVol =
tGeometry->lowestTrackingVolume(tgContext, position);
const Layer* startLay = startVol->associatedLayer(tgContext, position);
state.startSurface = startSurf;
state.targetSurface = startSurf;
state.options.startSurface = startSurf;
state.options.targetSurface = startSurf;
navigator.initialize(state, position, direction, Direction::Forward());
BOOST_CHECK(testNavigatorStateVectors(state, 0u, 0u, 0u));
BOOST_CHECK(testNavigatorStatePointers(state, startVol, startLay, startSurf,
Expand All @@ -208,7 +208,7 @@ BOOST_AUTO_TEST_CASE(Navigator_status_methods) {

ACTS_INFO(" b) Initialise having a start surface");
state = navigator.makeState(options);
state.startSurface = startSurf;
state.options.startSurface = startSurf;
navigator.initialize(state, position, direction, Direction::Forward());
BOOST_CHECK(testNavigatorStateVectors(state, 0u, 0u, 0u));
BOOST_CHECK(testNavigatorStatePointers(state, startVol, startLay, startSurf,
Expand Down

0 comments on commit b94ecd1

Please sign in to comment.