Skip to content

Commit

Permalink
refactor: Drop SympyStepper::stepImpl (#4103)
Browse files Browse the repository at this point in the history
After getting rid of the templated `step` function there is no reason to have a separate `stepImpl` function anymore. This PR is merging `stepImpl` into `step` and drops former.

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

## Summary by CodeRabbit

- **Refactor**
	- Streamlined the stepping process by centralizing configuration parameters within the system's state.
	- Improved error handling and step size scaling to maintain consistent performance.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
andiwand authored Feb 20, 2025
1 parent 31ebcaf commit 9cfe189
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
5 changes: 0 additions & 5 deletions Core/include/Acts/Propagator/SympyStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,6 @@ class SympyStepper {
protected:
/// Magnetic field inside of the detector
std::shared_ptr<const MagneticFieldProvider> m_bField;

private:
Result<double> stepImpl(State& state, Direction propDir, double stepTolerance,
double stepSizeCutOff,
std::size_t maxRungeKuttaStepTrials) const;
};

template <>
Expand Down
16 changes: 5 additions & 11 deletions Core/src/Propagator/SympyStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,7 @@ void SympyStepper::transportCovarianceToBound(
Result<double> SympyStepper::step(State& state, Direction propDir,
const IVolumeMaterial* material) const {
(void)material;
return stepImpl(state, propDir, state.options.stepTolerance,
state.options.stepSizeCutOff,
state.options.maxRungeKuttaStepTrials);
}

Result<double> SympyStepper::stepImpl(
State& state, Direction propDir, double stepTolerance,
double stepSizeCutOff, std::size_t maxRungeKuttaStepTrials) const {
auto pos = position(state);
auto dir = direction(state);
double t = time(state);
Expand All @@ -155,7 +148,7 @@ Result<double> SympyStepper::stepImpl(
// This is given by the order of the Runge-Kutta method
constexpr double exponent = 0.25;

double x = stepTolerance / errorEstimate_;
double x = state.options.stepTolerance / errorEstimate_;

if constexpr (exponent == 0.25) {
// This is 3x faster than std::pow
Expand All @@ -179,7 +172,8 @@ Result<double> SympyStepper::stepImpl(
// For details about the factor 4 see ATL-SOFT-PUB-2009-001
Result<bool> res =
rk4(pos.data(), dir.data(), t, h, qop, m, p_abs, getB, &errorEstimate,
4 * stepTolerance, state.pars.template segment<3>(eFreePos0).data(),
4 * state.options.stepTolerance,
state.pars.template segment<3>(eFreePos0).data(),
state.pars.template segment<3>(eFreeDir0).data(),
state.pars.template segment<1>(eFreeTime).data(),
state.derivative.data(),
Expand All @@ -201,14 +195,14 @@ Result<double> SympyStepper::stepImpl(

// If step size becomes too small the particle remains at the initial
// place
if (std::abs(h) < std::abs(stepSizeCutOff)) {
if (std::abs(h) < std::abs(state.options.stepSizeCutOff)) {
// Not moving due to too low momentum needs an aborter
return EigenStepperError::StepSizeStalled;
}

// If the parameter is off track too much or given stepSize is not
// appropriate
if (nStepTrials > maxRungeKuttaStepTrials) {
if (nStepTrials > state.options.maxRungeKuttaStepTrials) {
// Too many trials, have to abort
return EigenStepperError::StepSizeAdjustmentFailed;
}
Expand Down

0 comments on commit 9cfe189

Please sign in to comment.