Skip to content

Commit

Permalink
refactor: Combine GSF actor and aborter (#3984)
Browse files Browse the repository at this point in the history
Currently the GSF actor communicates the abort flag via the navigation break which is not ideal. I want to remove setting this flag from outside in #3449. The GSF can carry this flag by itself and after the actor+aborter refactor we do not need a separate aborter anymore.

pulled out of #3449

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

- **New Features**
	- Introduced a new method to check if navigation should be aborted based on processed measurements.
- **Improvements**
	- Updated navigation handling in the fitting process by removing the `NavigationBreakAborter` struct.
	- Refined geo context management in multiple methods for better clarity and consistency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
andiwand authored Dec 16, 2024
1 parent 9a2b74d commit 1960d7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
19 changes: 2 additions & 17 deletions Core/include/Acts/TrackFitting/GaussianSumFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,6 @@ struct GaussianSumFitter {
/// The actor type
using GsfActor = detail::GsfActor<bethe_heitler_approx_t, traj_t>;

/// This allows to break the propagation by setting the navigationBreak
/// TODO refactor once we can do this more elegantly
struct NavigationBreakAborter {
NavigationBreakAborter() = default;

template <typename propagator_state_t, typename stepper_t,
typename navigator_t>
bool checkAbort(propagator_state_t& state, const stepper_t& /*stepper*/,
const navigator_t& navigator,
const Logger& /*logger*/) const {
return navigator.navigationBreak(state.navigation);
}
};

/// @brief The fit function for the Direct navigator
template <typename source_link_it_t, typename start_parameters_t,
TrackContainerFrontend track_container_t>
Expand All @@ -105,7 +91,7 @@ struct GaussianSumFitter {

// Initialize the forward propagation with the DirectNavigator
auto fwdPropInitializer = [&sSequence, this](const auto& opts) {
using Actors = ActorList<GsfActor, NavigationBreakAborter>;
using Actors = ActorList<GsfActor>;
using PropagatorOptions = typename propagator_t::template Options<Actors>;

PropagatorOptions propOptions(opts.geoContext, opts.magFieldContext);
Expand Down Expand Up @@ -151,8 +137,7 @@ struct GaussianSumFitter {

// Initialize the forward propagation with the DirectNavigator
auto fwdPropInitializer = [this](const auto& opts) {
using Actors =
ActorList<GsfActor, EndOfWorldReached, NavigationBreakAborter>;
using Actors = ActorList<GsfActor, EndOfWorldReached>;
using PropagatorOptions = typename propagator_t::template Options<Actors>;

PropagatorOptions propOptions(opts.geoContext, opts.magFieldContext);
Expand Down
11 changes: 9 additions & 2 deletions Core/include/Acts/TrackFitting/detail/GsfActor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,20 @@ struct GsfActor {
applyMultipleScattering(state, stepper, navigator,
MaterialUpdateStage::PostUpdate);
}
}

// Break the navigation if we found all measurements
template <typename propagator_state_t, typename stepper_t,
typename navigator_t>
bool checkAbort(propagator_state_t& /*state*/, const stepper_t& /*stepper*/,
const navigator_t& /*navigator*/, const result_type& result,
const Logger& /*logger*/) const {
if (m_cfg.numberMeasurements &&
result.measurementStates == m_cfg.numberMeasurements) {
ACTS_VERBOSE("Stop navigation because all measurements are found");
navigator.navigationBreak(state.navigation, true);
return true;
}

return false;
}

template <typename propagator_state_t, typename stepper_t,
Expand Down

0 comments on commit 1960d7a

Please sign in to comment.