Skip to content

Commit

Permalink
Compute correct curvilinear covariance matrix also for a zero step pr…
Browse files Browse the repository at this point in the history
…opagation.
  • Loading branch information
Goetz Gaycken committed Jan 30, 2024
1 parent fb92e4c commit ce61bd7
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Core/include/Acts/Propagator/Propagator.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,34 @@ auto Acts::Propagator<S, N>::makeState(
return state;
}

namespace {
// helper templates to detect whether a type has a member stepData
template <typename T_Stepping>
using stepData_t = decltype(std::declval<T_Stepping>().stepData);

// template being used for types that do not have a member stepData
template <typename T_Stepping, typename = std::void_t<>>
struct has_stepData : std::false_type {};

// template being used for types that have the member stepData
template <typename T_Stepping>
struct has_stepData<T_Stepping, std::void_t<stepData_t<T_Stepping>>>
: std::true_type {};

// helper templates to detect whether a type has a member extension
template <typename T_Stepping>
using extension_t = decltype(std::declval<T_Stepping>().extension);

// template being used for types that do not have a member extension
template <typename T_Stepping, typename = std::void_t<>>
struct has_extension : std::false_type {};

// template being used for types that have the member extension
template <typename T_Stepping>
struct has_extension<T_Stepping, std::void_t<extension_t<T_Stepping>>>
: std::true_type {};
} // namespace

template <typename S, typename N>
template <typename propagator_state_t, typename propagator_options_t>
auto Acts::Propagator<S, N>::makeResult(propagator_state_t state,
Expand Down Expand Up @@ -256,6 +284,36 @@ auto Acts::Propagator<S, N>::makeResult(propagator_state_t state,
moveStateToResult(state, result);

if (makeCurvilinear) {
if constexpr (has_extension<decltype(state.stepping)>::value &&
has_stepData<decltype(state.stepping)>::value) {
if (state.stepping.pathAccumulated <= 0.) {
// if no step was executed the path lenght derivates have not been
// computed but are needed to compute the curvilinear covariance. The
// derivates are given by k1 for a zero step width.
if (state.stepping.extension.validExtensionForStep(state, m_stepper,
m_navigator)) {
// First Runge-Kutta point (at current position)
auto& sd = state.stepping.stepData;
auto pos = m_stepper.position(state.stepping);
auto fieldRes = m_stepper.getField(state.stepping, pos);
if (fieldRes.ok()) {
sd.B_first = *fieldRes;
if (state.stepping.extension.k1(state, m_stepper, m_navigator,
sd.k1, sd.B_first, sd.kQoP)) {
// dr/ds :
state.stepping.derivative.template head<3>() =
state.stepping.pars.template segment<3>(eFreeDir0);
// d (dr/ds) / ds :
state.stepping.derivative.template segment<3>(4) = sd.k1;
// to set dt/ds :
state.stepping.extension.finalize(state, m_stepper, m_navigator,
state.stepping.pathAccumulated);
}
}
}
}
}

/// Convert into return type and fill the result object
auto curvState = m_stepper.curvilinearState(state.stepping);
// Fill the end parameters
Expand Down

0 comments on commit ce61bd7

Please sign in to comment.