diff --git a/Core/include/Acts/Navigation/NextNavigator.hpp b/Core/include/Acts/Navigation/NextNavigator.hpp index acad5308ee3..78d982742bb 100644 --- a/Core/include/Acts/Navigation/NextNavigator.hpp +++ b/Core/include/Acts/Navigation/NextNavigator.hpp @@ -411,7 +411,7 @@ class NextNavigator { NavigationState& nState) const { nState.position = stepper.position(state.stepping); nState.direction = stepper.direction(state.stepping); - nState.absMomentum = stepper.momentum(state.stepping); + nState.absMomentum = stepper.absoluteMomentum(state.stepping); auto fieldResult = stepper.getField(state.stepping, nState.position); if (!fieldResult.ok()) { ACTS_ERROR(volInfo(state) << posInfo(state, stepper) diff --git a/Core/include/Acts/Propagator/AtlasStepper.hpp b/Core/include/Acts/Propagator/AtlasStepper.hpp index 55e4746f140..bf1b0f782cd 100644 --- a/Core/include/Acts/Propagator/AtlasStepper.hpp +++ b/Core/include/Acts/Propagator/AtlasStepper.hpp @@ -353,14 +353,16 @@ class AtlasStepper { return Vector3(state.pVector[4], state.pVector[5], state.pVector[6]); } - double qop(const State& state) const { return state.pVector[7]; } + double qOverP(const State& state) const { return state.pVector[7]; } - double momentum(const State& state) const { - return 1. / std::abs(qop(state)); + double absoluteMomentum(const State& state) const { + return 1. / std::abs(qOverP(state)); } /// Charge access - double charge(const State& state) const { return qop(state) > 0. ? 1. : -1.; } + double charge(const State& state) const { + return qOverP(state) > 0. ? 1. : -1.; + } /// Overstep limit double overstepLimit(const State& /*state*/) const { return m_overstepLimit; } @@ -1248,7 +1250,7 @@ class AtlasStepper { // Evaluate the time propagation double dtds = - std::hypot(1, state.options.mass / momentum(state.stepping)); + std::hypot(1, state.options.mass / absoluteMomentum(state.stepping)); state.stepping.pVector[3] += h * dtds; state.stepping.pVector[59] = dtds; state.stepping.field = f; @@ -1257,7 +1259,7 @@ class AtlasStepper { if (Jac) { double dtdl = h * state.options.mass * state.options.mass * charge(state.stepping) / - (momentum(state.stepping) * dtds); + (absoluteMomentum(state.stepping) * dtds); state.stepping.pVector[43] += dtdl; // Jacobian calculation diff --git a/Core/include/Acts/Propagator/EigenStepper.hpp b/Core/include/Acts/Propagator/EigenStepper.hpp index fe8687cd5d0..b2d6b41e01b 100644 --- a/Core/include/Acts/Propagator/EigenStepper.hpp +++ b/Core/include/Acts/Propagator/EigenStepper.hpp @@ -216,21 +216,21 @@ class EigenStepper { /// QoP direction accessor /// /// @param state [in] The stepping state (thread-local cache) - double qop(const State& state) const { return state.pars[eFreeQOverP]; } + double qOverP(const State& state) const { return state.pars[eFreeQOverP]; } /// Absolute momentum accessor /// /// @param state [in] The stepping state (thread-local cache) - double momentum(const State& state) const { + double absoluteMomentum(const State& state) const { auto q = charge(state); - return std::abs((q == 0 ? 1 : q) / qop(state)); + return std::abs((q == 0 ? 1 : q) / qOverP(state)); } /// Charge access /// /// @param state [in] The stepping state (thread-local cache) double charge(const State& state) const { - return std::copysign(state.absCharge, qop(state)); + return std::copysign(state.absCharge, qOverP(state)); } /// Time access @@ -363,10 +363,10 @@ class EigenStepper { /// @param [in,out] state State object that will be updated /// @param [in] uposition the updated position /// @param [in] udirection the updated direction - /// @param [in] qop the updated qop value + /// @param [in] qOverP the updated qOverP value /// @param [in] time the updated time value void update(State& state, const Vector3& uposition, const Vector3& udirection, - double qop, double time) const; + double qOverP, double time) const; /// Method for on-demand transport of the covariance /// to a new curvilinear frame at current position, diff --git a/Core/include/Acts/Propagator/EigenStepper.ipp b/Core/include/Acts/Propagator/EigenStepper.ipp index 573942e71fd..e15f0982dae 100644 --- a/Core/include/Acts/Propagator/EigenStepper.ipp +++ b/Core/include/Acts/Propagator/EigenStepper.ipp @@ -84,12 +84,12 @@ void Acts::EigenStepper::update(State& state, template void Acts::EigenStepper::update(State& state, const Vector3& uposition, - const Vector3& udirection, double qop, + const Vector3& udirection, double qOverP, double time) const { state.pars.template segment<3>(eFreePos0) = uposition; state.pars.template segment<3>(eFreeDir0) = udirection; state.pars[eFreeTime] = time; - state.pars[eFreeQOverP] = qop; + state.pars[eFreeQOverP] = qOverP; } template diff --git a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp index bec68068086..97eafe0d370 100644 --- a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp +++ b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp @@ -66,7 +66,7 @@ struct WeightedComponentReducerLoop { // TODO: Maybe we can cache this value and only update it when the parameters // change template - static ActsScalar qop(const stepper_state_t& s) { + static ActsScalar qOverP(const stepper_state_t& s) { return std::accumulate( s.components.begin(), s.components.end(), ActsScalar{0.}, [](const auto& sum, const auto& cmp) -> ActsScalar { @@ -627,10 +627,17 @@ class MultiEigenStepperLoop return Reducer::direction(state); } + /// QoP access + /// + /// @param state [in] The stepping state (thread-local cache) + double qOverP(const State& state) const { return Reducer::qOverP(state); } + /// Absolute momentum accessor /// /// @param state [in] The stepping state (thread-local cache) - double momentum(const State& state) const { return Reducer::momentum(state); } + double absoluteMomentum(const State& state) const { + return Reducer::momentum(state); + } /// Charge access /// diff --git a/Core/include/Acts/Propagator/StandardAborters.hpp b/Core/include/Acts/Propagator/StandardAborters.hpp index 8cccd0ba495..b04cf66d532 100644 --- a/Core/include/Acts/Propagator/StandardAborters.hpp +++ b/Core/include/Acts/Propagator/StandardAborters.hpp @@ -224,7 +224,7 @@ struct ParticleStopped { bool operator()(propagator_state_t& state, const stepper_t& stepper, const navigator_t& navigator, const Logger& /*logger*/) const { - if (stepper.momentum(state.stepping) > 0) { + if (stepper.absoluteMomentum(state.stepping) > 0) { return false; } navigator.targetReached(state.navigation, true); diff --git a/Core/include/Acts/Propagator/StepperConcept.hpp b/Core/include/Acts/Propagator/StepperConcept.hpp index b494110962b..585f4599b34 100644 --- a/Core/include/Acts/Propagator/StepperConcept.hpp +++ b/Core/include/Acts/Propagator/StepperConcept.hpp @@ -40,7 +40,8 @@ METHOD_TRAIT(reset_state_t, resetState); METHOD_TRAIT(get_field_t, getField); METHOD_TRAIT(position_t, position); METHOD_TRAIT(direction_t, direction); -METHOD_TRAIT(momentum_t, momentum); +METHOD_TRAIT(qop_t, qOverP); +METHOD_TRAIT(absolute_momentum_t, absoluteMomentum); METHOD_TRAIT(charge_t, charge); METHOD_TRAIT(time_t, time); METHOD_TRAIT(overstep_t, overstepLimit); @@ -107,8 +108,10 @@ constexpr bool MultiStepperStateConcept= require< static_assert(position_exists, "position method not found"); constexpr static bool direction_exists = has_method; static_assert(direction_exists, "direction method not found"); - constexpr static bool momentum_exists = has_method; - static_assert(momentum_exists, "momentum method not found"); + constexpr static bool qop_exists = has_method; + static_assert(qop_exists, "qOverP method not found"); + constexpr static bool absolute_momentum_exists = has_method; + static_assert(absolute_momentum_exists, "absoluteMomentum method not found"); constexpr static bool charge_exists = has_method; static_assert(charge_exists, "charge method not found"); constexpr static bool time_exists = has_method; @@ -140,7 +143,8 @@ constexpr bool MultiStepperStateConcept= require< curvilinear_state_exists, position_exists, direction_exists, - momentum_exists, + qop_exists, + absolute_momentum_exists, charge_exists, time_exists, bound_state_method_exists, diff --git a/Core/include/Acts/Propagator/StraightLineStepper.hpp b/Core/include/Acts/Propagator/StraightLineStepper.hpp index d46b47ee637..40617b6ad78 100644 --- a/Core/include/Acts/Propagator/StraightLineStepper.hpp +++ b/Core/include/Acts/Propagator/StraightLineStepper.hpp @@ -196,21 +196,21 @@ class StraightLineStepper { /// QoP direction accessor /// /// @param state [in] The stepping state (thread-local cache) - double qop(const State& state) const { return state.pars[eFreeQOverP]; } + double qOverP(const State& state) const { return state.pars[eFreeQOverP]; } /// Absolute momentum accessor /// /// @param state [in] The stepping state (thread-local cache) - double momentum(const State& state) const { + double absoluteMomentum(const State& state) const { auto q = charge(state); - return std::abs((q == 0 ? 1 : q) / qop(state)); + return std::abs((q == 0 ? 1 : q) / qOverP(state)); } /// Charge access /// /// @param state [in] The stepping state (thread-local cache) double charge(const State& state) const { - return std::copysign(state.absCharge, qop(state)); + return std::copysign(state.absCharge, qOverP(state)); } /// Time access @@ -387,7 +387,7 @@ class StraightLineStepper { const navigator_t& /*navigator*/) const { // use the adjusted step size const auto h = state.stepping.stepSize.value(); - const double p = momentum(state.stepping); + const double p = absoluteMomentum(state.stepping); // time propagates along distance as 1/b = sqrt(1 + m²/p²) const auto dtds = std::hypot(1., state.options.mass / p); // Update the track parameters according to the equations of motion diff --git a/Core/include/Acts/Propagator/detail/GenericDefaultExtension.hpp b/Core/include/Acts/Propagator/detail/GenericDefaultExtension.hpp index 43e909ffb46..dcebeb3d1a8 100644 --- a/Core/include/Acts/Propagator/detail/GenericDefaultExtension.hpp +++ b/Core/include/Acts/Propagator/detail/GenericDefaultExtension.hpp @@ -62,7 +62,7 @@ struct GenericDefaultExtension { const navigator_t& /*navigator*/, ThisVector3& knew, const Vector3& bField, std::array& kQoP, const int i = 0, const double h = 0., const ThisVector3& kprev = ThisVector3::Zero()) { - auto qop = stepper.qop(state.stepping); + auto qop = stepper.qOverP(state.stepping); // First step does not rely on previous data if (i == 0) { knew = qop * stepper.direction(state.stepping).cross(bField); @@ -137,7 +137,7 @@ struct GenericDefaultExtension { /// = sqrt(m^2/p^2 + c^{-2}) with the mass m and the momentum p. using std::hypot; auto derivative = - hypot(1, state.options.mass / stepper.momentum(state.stepping)); + hypot(1, state.options.mass / stepper.absoluteMomentum(state.stepping)); state.stepping.pars[eFreeTime] += h * derivative; if (state.stepping.covTransport) { state.stepping.derivative(3) = derivative; @@ -182,7 +182,7 @@ struct GenericDefaultExtension { auto& sd = state.stepping.stepData; auto dir = stepper.direction(state.stepping); - auto qop = stepper.qop(state.stepping); + auto qop = stepper.qOverP(state.stepping); D = FreeMatrix::Identity(); @@ -241,10 +241,10 @@ struct GenericDefaultExtension { dGdL = h / 6. * (dk1dL + 2. * (dk2dL + dk3dL) + dk4dL); - D(3, 7) = - h * state.options.mass * state.options.mass * - stepper.qop(state.stepping) / - std::hypot(1., state.options.mass / stepper.momentum(state.stepping)); + D(3, 7) = h * state.options.mass * state.options.mass * + stepper.qOverP(state.stepping) / + std::hypot(1., state.options.mass / + stepper.absoluteMomentum(state.stepping)); return true; } }; diff --git a/Core/include/Acts/Propagator/detail/GenericDenseEnvironmentExtension.hpp b/Core/include/Acts/Propagator/detail/GenericDenseEnvironmentExtension.hpp index 47cc676cb80..b2b6b9a25df 100644 --- a/Core/include/Acts/Propagator/detail/GenericDenseEnvironmentExtension.hpp +++ b/Core/include/Acts/Propagator/detail/GenericDenseEnvironmentExtension.hpp @@ -79,7 +79,8 @@ struct GenericDenseEnvironmentExtension { const navigator_t& navigator) const { // Check for valid particle properties if (stepper.charge(state.stepping) == 0. || state.options.mass == 0. || - stepper.momentum(state.stepping) < state.options.momentumCutOff) { + stepper.absoluteMomentum(state.stepping) < + state.options.momentumCutOff) { return 0; } @@ -123,7 +124,7 @@ struct GenericDenseEnvironmentExtension { auto volumeMaterial = navigator.currentVolumeMaterial(state.navigation); ThisVector3 position = stepper.position(state.stepping); material = (volumeMaterial->material(position.template cast())); - initialMomentum = stepper.momentum(state.stepping); + initialMomentum = stepper.absoluteMomentum(state.stepping); currentMomentum = initialMomentum; qop[0] = q / initialMomentum; initializeEnergyLoss(state); @@ -173,7 +174,7 @@ struct GenericDenseEnvironmentExtension { const navigator_t& /*navigator*/, const double h) const { // Evaluate the new momentum auto newMomentum = - stepper.momentum(state.stepping) + + stepper.absoluteMomentum(state.stepping) + (h / 6.) * (dPds[0] + 2. * (dPds[1] + dPds[2]) + dPds[3]); // Break propagation if momentum becomes below cut-off diff --git a/Core/include/Acts/Propagator/detail/LoopProtection.hpp b/Core/include/Acts/Propagator/detail/LoopProtection.hpp index 8d5f1a4264a..ff8f365b992 100644 --- a/Core/include/Acts/Propagator/detail/LoopProtection.hpp +++ b/Core/include/Acts/Propagator/detail/LoopProtection.hpp @@ -39,7 +39,7 @@ void setupLoopProtection(propagator_state_t& state, const stepper_t& stepper, } // Transverse component at start is taken for the loop protection - const double p = stepper.momentum(state.stepping); + const double p = stepper.absoluteMomentum(state.stepping); // Calculate the full helix path const double helixPath = state.stepping.navDir * 2 * M_PI * p / B; // And set it as the loop limit if it overwrites the internal limit diff --git a/Core/include/Acts/Propagator/detail/PointwiseMaterialInteraction.hpp b/Core/include/Acts/Propagator/detail/PointwiseMaterialInteraction.hpp index ae5674fe46e..b7b9c5cfd2b 100644 --- a/Core/include/Acts/Propagator/detail/PointwiseMaterialInteraction.hpp +++ b/Core/include/Acts/Propagator/detail/PointwiseMaterialInteraction.hpp @@ -79,9 +79,9 @@ struct PointwiseMaterialInteraction { pos(stepper.position(state.stepping)), time(stepper.time(state.stepping)), dir(stepper.direction(state.stepping)), - qOverP(stepper.qop(state.stepping)), + qOverP(stepper.qOverP(state.stepping)), absQ(std::abs(stepper.charge(state.stepping))), - momentum(stepper.momentum(state.stepping)), + momentum(stepper.absoluteMomentum(state.stepping)), mass(state.options.mass), pdg(state.options.absPdgCode), performCovarianceTransport(state.stepping.covTransport), diff --git a/Core/include/Acts/Propagator/detail/SteppingLogger.hpp b/Core/include/Acts/Propagator/detail/SteppingLogger.hpp index 487e044c359..2d1467a3bfd 100644 --- a/Core/include/Acts/Propagator/detail/SteppingLogger.hpp +++ b/Core/include/Acts/Propagator/detail/SteppingLogger.hpp @@ -71,8 +71,8 @@ struct SteppingLogger { Step step; step.stepSize = state.stepping.stepSize; step.position = stepper.position(state.stepping); - step.momentum = - stepper.momentum(state.stepping) * stepper.direction(state.stepping); + step.momentum = stepper.absoluteMomentum(state.stepping) * + stepper.direction(state.stepping); if (navigator.currentSurface(state.navigation) != nullptr) { // hang on to surface diff --git a/Core/include/Acts/Propagator/detail/VolumeMaterialInteraction.hpp b/Core/include/Acts/Propagator/detail/VolumeMaterialInteraction.hpp index 46f81a0083f..6a954c506d5 100644 --- a/Core/include/Acts/Propagator/detail/VolumeMaterialInteraction.hpp +++ b/Core/include/Acts/Propagator/detail/VolumeMaterialInteraction.hpp @@ -63,9 +63,9 @@ struct VolumeMaterialInteraction { pos(stepper.position(state.stepping)), time(stepper.time(state.stepping)), dir(stepper.direction(state.stepping)), - qOverP(stepper.qop(state.stepping)), + qOverP(stepper.qOverP(state.stepping)), absQ(std::abs(stepper.charge(state.stepping))), - momentum(stepper.momentum(state.stepping)), + momentum(stepper.absoluteMomentum(state.stepping)), mass(state.options.mass), pdg(state.options.absPdgCode), performCovarianceTransport(state.stepping.covTransport), diff --git a/Core/include/Acts/TrackFitting/KalmanFitter.hpp b/Core/include/Acts/TrackFitting/KalmanFitter.hpp index b92d01d954b..cd9e547acaa 100644 --- a/Core/include/Acts/TrackFitting/KalmanFitter.hpp +++ b/Core/include/Acts/TrackFitting/KalmanFitter.hpp @@ -344,7 +344,8 @@ class KalmanFitter { ACTS_VERBOSE("KalmanFitter step at pos: " << stepper.position(state.stepping).transpose() << " dir: " << stepper.direction(state.stepping).transpose() - << " momentum: " << stepper.momentum(state.stepping)); + << " momentum: " + << stepper.absoluteMomentum(state.stepping)); // Add the measurement surface as external surface to navigator. // We will try to hit those surface by ignoring boundary checks. diff --git a/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp b/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp index 7e08e998ecb..35f9ca761bb 100644 --- a/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp +++ b/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp @@ -123,7 +123,7 @@ class ScopedGsfInfoPrinterAndChecker { : m_state(state), m_stepper(stepper), m_navigator(navigator), - m_p_initial(stepper.momentum(state.stepping)), + m_p_initial(stepper.absoluteMomentum(state.stepping)), m_logger{logger} { // Some initial printing checks(true); @@ -132,7 +132,7 @@ class ScopedGsfInfoPrinterAndChecker { << stepper.position(state.stepping).transpose() << " with direction " << stepper.direction(state.stepping).transpose() - << " and momentum " << stepper.momentum(state.stepping) + << " and momentum " << stepper.absoluteMomentum(state.stepping) << " and charge " << stepper.charge(state.stepping)); ACTS_VERBOSE("Propagation is in " << state.stepping.navDir << " mode"); print_component_stats(); @@ -140,7 +140,7 @@ class ScopedGsfInfoPrinterAndChecker { ~ScopedGsfInfoPrinterAndChecker() { if (m_navigator.currentSurface(m_state.navigation)) { - const auto p_final = m_stepper.momentum(m_state.stepping); + const auto p_final = m_stepper.absoluteMomentum(m_state.stepping); ACTS_VERBOSE("Component status at end of step:"); print_component_stats(); ACTS_VERBOSE("Delta Momentum = " << std::setprecision(5) diff --git a/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp b/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp index 66f3dc734e0..d63199ddf21 100644 --- a/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp +++ b/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp @@ -219,7 +219,7 @@ struct SimulationActor { return Particle(previous) .setPosition4(stepper.position(state), stepper.time(state)) .setDirection(stepper.direction(state)) - .setAbsoluteMomentum(stepper.momentum(state)) + .setAbsoluteMomentum(stepper.absoluteMomentum(state)) .setProperTime(properTime); } diff --git a/Plugins/Autodiff/include/Acts/Plugins/Autodiff/AutodiffExtensionWrapper.hpp b/Plugins/Autodiff/include/Acts/Plugins/Autodiff/AutodiffExtensionWrapper.hpp index d9c962d64e9..cf834d69a39 100644 --- a/Plugins/Autodiff/include/Acts/Plugins/Autodiff/AutodiffExtensionWrapper.hpp +++ b/Plugins/Autodiff/include/Acts/Plugins/Autodiff/AutodiffExtensionWrapper.hpp @@ -94,8 +94,8 @@ struct AutodiffExtensionWrapper { // A fake stepper struct FakeStepper { auto charge(const FakeStepperState& s) const { return s.q; } - auto qop(const FakeStepperState& s) const { return s.pars(eFreeQOverP); } - auto momentum(const FakeStepperState& s) const { + auto qOverP(const FakeStepperState& s) const { return s.pars(eFreeQOverP); } + auto absoluteMomentum(const FakeStepperState& s) const { return s.q / s.pars(eFreeQOverP); } auto direction(const FakeStepperState& s) const { @@ -128,7 +128,7 @@ struct AutodiffExtensionWrapper { initial_params.segment<3>(eFreeDir0) = stepper.direction(state.stepping); initial_params(eFreeQOverP) = (fstate.stepping.q != 0. ? fstate.stepping.q : 1.) / - stepper.momentum(state.stepping); + stepper.absoluteMomentum(state.stepping); const auto& sd = state.stepping.stepData; diff --git a/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp b/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp index 2f9c7669fd4..db56cf3db59 100644 --- a/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp @@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(Getters) { CHECK_CLOSE_ABS(stepper.position(state), pos, eps); CHECK_CLOSE_ABS(stepper.time(state), time, eps); CHECK_CLOSE_ABS(stepper.direction(state), unitDir, eps); - CHECK_CLOSE_ABS(stepper.momentum(state), absMom, eps); + CHECK_CLOSE_ABS(stepper.absoluteMomentum(state), absMom, eps); BOOST_CHECK_EQUAL(stepper.charge(state), charge); } @@ -200,7 +200,7 @@ BOOST_AUTO_TEST_CASE(UpdateFromBound) { CHECK_CLOSE_ABS(stepper.position(state), newPos, eps); CHECK_CLOSE_ABS(stepper.time(state), newTime, eps); CHECK_CLOSE_ABS(stepper.direction(state), newUnitDir, eps); - CHECK_CLOSE_ABS(stepper.momentum(state), newAbsMom, eps); + CHECK_CLOSE_ABS(stepper.absoluteMomentum(state), newAbsMom, eps); BOOST_CHECK_EQUAL(stepper.charge(state), charge); } @@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(UpdateFromComponents) { CHECK_CLOSE_ABS(stepper.position(state), newPos, eps); CHECK_CLOSE_ABS(stepper.time(state), newTime, eps); CHECK_CLOSE_ABS(stepper.direction(state), newUnitDir, eps); - CHECK_CLOSE_ABS(stepper.momentum(state), newAbsMom, eps); + CHECK_CLOSE_ABS(stepper.absoluteMomentum(state), newAbsMom, eps); BOOST_CHECK_EQUAL(stepper.charge(state), charge); } @@ -300,7 +300,7 @@ BOOST_AUTO_TEST_CASE(Step) { BOOST_CHECK_LT(projDir, 1); // momentum and charge should not change - CHECK_CLOSE_ABS(stepper.momentum(state.stepping), absMom, eps); + CHECK_CLOSE_ABS(stepper.absoluteMomentum(state.stepping), absMom, eps); BOOST_CHECK_EQUAL(stepper.charge(state.stepping), charge); } @@ -333,7 +333,7 @@ BOOST_AUTO_TEST_CASE(StepWithCovariance) { BOOST_CHECK_LT(projDir, 1); // momentum and charge should not change - CHECK_CLOSE_ABS(stepper.momentum(state.stepping), absMom, eps); + CHECK_CLOSE_ABS(stepper.absoluteMomentum(state.stepping), absMom, eps); BOOST_CHECK_EQUAL(stepper.charge(state.stepping), charge); stepper.transportCovarianceToCurvilinear(state.stepping); @@ -416,7 +416,7 @@ BOOST_AUTO_TEST_CASE(Reset) { freeParams.template segment<3>(eFreePos0)); BOOST_CHECK_EQUAL(stepper.direction(stateCopy), freeParams.template segment<3>(eFreeDir0).normalized()); - BOOST_CHECK_EQUAL(stepper.momentum(stateCopy), + BOOST_CHECK_EQUAL(stepper.absoluteMomentum(stateCopy), std::abs(1. / freeParams[eFreeQOverP])); BOOST_CHECK_EQUAL(stepper.charge(stateCopy), stepper.charge(state.stepping)); BOOST_CHECK_EQUAL(stepper.time(stateCopy), freeParams[eFreeTime]); @@ -438,7 +438,7 @@ BOOST_AUTO_TEST_CASE(Reset) { freeParams.template segment<3>(eFreePos0)); BOOST_CHECK_EQUAL(stepper.direction(stateCopy), freeParams.template segment<3>(eFreeDir0).normalized()); - BOOST_CHECK_EQUAL(stepper.momentum(stateCopy), + BOOST_CHECK_EQUAL(stepper.absoluteMomentum(stateCopy), std::abs(1. / freeParams[eFreeQOverP])); BOOST_CHECK_EQUAL(stepper.charge(stateCopy), stepper.charge(state.stepping)); BOOST_CHECK_EQUAL(stepper.time(stateCopy), freeParams[eFreeTime]); @@ -461,7 +461,7 @@ BOOST_AUTO_TEST_CASE(Reset) { freeParams.template segment<3>(eFreePos0)); BOOST_CHECK_EQUAL(stepper.direction(stateCopy), freeParams.template segment<3>(eFreeDir0).normalized()); - BOOST_CHECK_EQUAL(stepper.momentum(stateCopy), + BOOST_CHECK_EQUAL(stepper.absoluteMomentum(stateCopy), std::abs(1. / freeParams[eFreeQOverP])); BOOST_CHECK_EQUAL(stepper.charge(stateCopy), stepper.charge(state.stepping)); BOOST_CHECK_EQUAL(stepper.time(stateCopy), freeParams[eFreeTime]); diff --git a/Tests/UnitTests/Core/Propagator/LoopProtectionTests.cpp b/Tests/UnitTests/Core/Propagator/LoopProtectionTests.cpp index 1648efc4f61..981755e8a73 100644 --- a/Tests/UnitTests/Core/Propagator/LoopProtectionTests.cpp +++ b/Tests/UnitTests/Core/Propagator/LoopProtectionTests.cpp @@ -88,7 +88,7 @@ struct Stepper { Vector3 direction(const SteppingState& state) const { return state.dir; } /// Access method - momentum - double momentum(const SteppingState& state) const { return state.p; } + double absoluteMomentum(const SteppingState& state) const { return state.p; } }; /// @brief mockup of navigation state diff --git a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp index 31c8b013966..2baedb385f0 100644 --- a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp @@ -668,8 +668,9 @@ void test_single_component_interface_function() { BOOST_CHECK(sstepper.direction(sstepping) == cmp.pars().template segment<3>(eFreeDir0)); BOOST_CHECK(sstepper.time(sstepping) == cmp.pars()[eFreeTime]); - BOOST_CHECK_CLOSE(sstepper.charge(sstepping) / sstepper.momentum(sstepping), - cmp.pars()[eFreeQOverP], 1.e-8); + BOOST_CHECK_CLOSE( + sstepper.charge(sstepping) / sstepper.absoluteMomentum(sstepping), + cmp.pars()[eFreeQOverP], 1.e-8); }; for (const auto cmp : multi_stepper.constComponentIterable(multi_state)) { diff --git a/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp b/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp index cfb69842ae0..f808eef4bc9 100644 --- a/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp @@ -126,8 +126,12 @@ struct PropagatorState { /// Momentum direction accessor Vector3 direction(const State& state) const { return state.dir; } + double qOverP(const State& state) const { + return (state.q == 0 ? 1 : state.q) / state.p; + } + /// Momentum accessor - double momentum(const State& state) const { return state.p; } + double absoluteMomentum(const State& state) const { return state.p; } /// Charge access double charge(const State& state) const { return state.q; } diff --git a/Tests/UnitTests/Core/Propagator/StepperTests.cpp b/Tests/UnitTests/Core/Propagator/StepperTests.cpp index 77bd39ec451..0c55556e6fb 100644 --- a/Tests/UnitTests/Core/Propagator/StepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/StepperTests.cpp @@ -175,7 +175,7 @@ struct StepCollector { const navigator_t& /*navigator*/, result_type& result, const Logger& /*logger*/) const { result.position.push_back(stepper.position(state.stepping)); - result.momentum.push_back(stepper.momentum(state.stepping) * + result.momentum.push_back(stepper.absoluteMomentum(state.stepping) * stepper.direction(state.stepping)); } }; @@ -259,7 +259,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { // Test the getters CHECK_CLOSE_ABS(es.position(esState), pos, eps); CHECK_CLOSE_ABS(es.direction(esState), dir, eps); - CHECK_CLOSE_ABS(es.momentum(esState), absMom, eps); + CHECK_CLOSE_ABS(es.absoluteMomentum(esState), absMom, eps); CHECK_CLOSE_ABS(es.charge(esState), charge, eps); CHECK_CLOSE_ABS(es.time(esState), time, eps); //~ BOOST_CHECK_EQUAL(es.overstepLimit(esState), tolerance); @@ -298,7 +298,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { newTime); BOOST_CHECK_EQUAL(es.position(esState), newPos); BOOST_CHECK_EQUAL(es.direction(esState), newMom.normalized()); - BOOST_CHECK_EQUAL(es.momentum(esState), newMom.norm()); + BOOST_CHECK_EQUAL(es.absoluteMomentum(esState), newMom.norm()); BOOST_CHECK_EQUAL(es.charge(esState), charge); BOOST_CHECK_EQUAL(es.time(esState), newTime); @@ -395,7 +395,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { freeParams.template segment<3>(eFreePos0)); BOOST_CHECK_EQUAL(es.direction(esStateCopy), freeParams.template segment<3>(eFreeDir0).normalized()); - BOOST_CHECK_EQUAL(es.momentum(esStateCopy), + BOOST_CHECK_EQUAL(es.absoluteMomentum(esStateCopy), std::abs(1. / freeParams[eFreeQOverP])); BOOST_CHECK_EQUAL(es.charge(esStateCopy), -es.charge(ps.stepping)); BOOST_CHECK_EQUAL(es.time(esStateCopy), freeParams[eFreeTime]); @@ -420,7 +420,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { freeParams.template segment<3>(eFreePos0)); BOOST_CHECK_EQUAL(es.direction(esStateCopy), freeParams.template segment<3>(eFreeDir0).normalized()); - BOOST_CHECK_EQUAL(es.momentum(esStateCopy), + BOOST_CHECK_EQUAL(es.absoluteMomentum(esStateCopy), std::abs(1. / freeParams[eFreeQOverP])); BOOST_CHECK_EQUAL(es.charge(esStateCopy), -es.charge(ps.stepping)); BOOST_CHECK_EQUAL(es.time(esStateCopy), freeParams[eFreeTime]); @@ -446,7 +446,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { freeParams.template segment<3>(eFreePos0)); BOOST_CHECK_EQUAL(es.direction(esStateCopy), freeParams.template segment<3>(eFreeDir0).normalized()); - BOOST_CHECK_EQUAL(es.momentum(esStateCopy), + BOOST_CHECK_EQUAL(es.absoluteMomentum(esStateCopy), std::abs(1. / freeParams[eFreeQOverP])); BOOST_CHECK_EQUAL(es.charge(esStateCopy), -es.charge(ps.stepping)); BOOST_CHECK_EQUAL(es.time(esStateCopy), freeParams[eFreeTime]); @@ -519,7 +519,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { *plane); CHECK_CLOSE_OR_SMALL(es.position(esState), 2. * pos, eps, eps); CHECK_CLOSE_OR_SMALL(es.direction(esState), dir, eps, eps); - CHECK_CLOSE_REL(es.momentum(esState), 2 * absMom, eps); + CHECK_CLOSE_REL(es.absoluteMomentum(esState), 2 * absMom, eps); BOOST_CHECK_EQUAL(es.charge(esState), -1. * charge); CHECK_CLOSE_OR_SMALL(es.time(esState), 2. * time, eps, eps); CHECK_CLOSE_COVARIANCE(esState.cov, Covariance(2. * cov), eps); diff --git a/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp b/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp index ad0003c0a5b..e40ac172240 100644 --- a/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp @@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_state_test) { BOOST_CHECK_EQUAL(slsState.cov, Covariance::Zero()); CHECK_CLOSE_OR_SMALL(sls.position(slsState), pos, eps, eps); CHECK_CLOSE_OR_SMALL(sls.direction(slsState), dir.normalized(), eps, eps); - CHECK_CLOSE_REL(sls.momentum(slsState), absMom, eps); + CHECK_CLOSE_REL(sls.absoluteMomentum(slsState), absMom, eps); BOOST_CHECK_EQUAL(sls.charge(slsState), charge); CHECK_CLOSE_OR_SMALL(sls.time(slsState), time, eps, eps); BOOST_CHECK_EQUAL(slsState.navDir, navDir); @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { // Test the getters CHECK_CLOSE_ABS(sls.position(slsState), pos, 1e-6); CHECK_CLOSE_ABS(sls.direction(slsState), dir, 1e-6); - CHECK_CLOSE_ABS(sls.momentum(slsState), absMom, 1e-6); + CHECK_CLOSE_ABS(sls.absoluteMomentum(slsState), absMom, 1e-6); BOOST_CHECK_EQUAL(sls.charge(slsState), charge); BOOST_CHECK_EQUAL(sls.time(slsState), time); @@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { auto curvState = sls.curvilinearState(slsState); auto curvPars = std::get<0>(curvState); CHECK_CLOSE_ABS(curvPars.position(tgContext), cp.position(tgContext), 1e-6); - CHECK_CLOSE_ABS(curvPars.momentum(), cp.momentum(), 1e-6); + CHECK_CLOSE_ABS(curvPars.absoluteMomentum(), cp.absoluteMomentum(), 1e-6); CHECK_CLOSE_ABS(curvPars.charge(), cp.charge(), 1e-6); CHECK_CLOSE_ABS(curvPars.time(), cp.time(), 1e-6); BOOST_CHECK(curvPars.covariance().has_value()); @@ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { newTime); CHECK_CLOSE_ABS(sls.position(slsState), newPos, 1e-6); CHECK_CLOSE_ABS(sls.direction(slsState), newMom.normalized(), 1e-6); - CHECK_CLOSE_ABS(sls.momentum(slsState), newMom.norm(), 1e-6); + CHECK_CLOSE_ABS(sls.absoluteMomentum(slsState), newMom.norm(), 1e-6); BOOST_CHECK_EQUAL(sls.charge(slsState), charge); BOOST_CHECK_EQUAL(sls.time(slsState), newTime); @@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { CHECK_CLOSE_COVARIANCE(ps.stepping.cov, cov, 1e-6); BOOST_CHECK_GT(sls.position(ps.stepping).norm(), newPos.norm()); CHECK_CLOSE_ABS(sls.direction(ps.stepping), newMom.normalized(), 1e-6); - CHECK_CLOSE_ABS(sls.momentum(ps.stepping), newMom.norm(), 1e-6); + CHECK_CLOSE_ABS(sls.absoluteMomentum(ps.stepping), newMom.norm(), 1e-6); CHECK_CLOSE_ABS(sls.charge(ps.stepping), charge, 1e-6); BOOST_CHECK_LT(sls.time(ps.stepping), newTime); BOOST_CHECK_EQUAL(ps.stepping.derivative, FreeVector::Zero()); @@ -223,7 +223,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { CHECK_CLOSE_COVARIANCE(ps.stepping.cov, cov, 1e-6); BOOST_CHECK_GT(sls.position(ps.stepping).norm(), newPos.norm()); CHECK_CLOSE_ABS(sls.direction(ps.stepping), newMom.normalized(), 1e-6); - CHECK_CLOSE_ABS(sls.momentum(ps.stepping), newMom.norm(), 1e-6); + CHECK_CLOSE_ABS(sls.absoluteMomentum(ps.stepping), newMom.norm(), 1e-6); CHECK_CLOSE_ABS(sls.charge(ps.stepping), charge, 1e-6); BOOST_CHECK_LT(sls.time(ps.stepping), newTime); BOOST_CHECK_NE(ps.stepping.derivative, FreeVector::Zero()); @@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { freeParams.template segment<3>(eFreePos0), 1e-6); CHECK_CLOSE_ABS(sls.direction(slsStateCopy), freeParams.template segment<3>(eFreeDir0).normalized(), 1e-6); - CHECK_CLOSE_ABS(sls.momentum(slsStateCopy), + CHECK_CLOSE_ABS(sls.absoluteMomentum(slsStateCopy), std::abs(1. / freeParams[eFreeQOverP]), 1e-6); CHECK_CLOSE_ABS(sls.charge(slsStateCopy), -sls.charge(ps.stepping), 1e-6); CHECK_CLOSE_ABS(sls.time(slsStateCopy), freeParams[eFreeTime], 1e-6); @@ -286,7 +286,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { freeParams.template segment<3>(eFreePos0), 1e-6); CHECK_CLOSE_ABS(sls.direction(slsStateCopy), freeParams.template segment<3>(eFreeDir0), 1e-6); - CHECK_CLOSE_ABS(sls.momentum(slsStateCopy), + CHECK_CLOSE_ABS(sls.absoluteMomentum(slsStateCopy), std::abs(1. / freeParams[eFreeQOverP]), 1e-6); CHECK_CLOSE_ABS(sls.charge(slsStateCopy), -sls.charge(ps.stepping), 1e-6); CHECK_CLOSE_ABS(sls.time(slsStateCopy), freeParams[eFreeTime], 1e-6); @@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { freeParams.template segment<3>(eFreePos0), 1e-6); CHECK_CLOSE_ABS(sls.direction(slsStateCopy), freeParams.template segment<3>(eFreeDir0).normalized(), 1e-6); - CHECK_CLOSE_ABS(sls.momentum(slsStateCopy), + CHECK_CLOSE_ABS(sls.absoluteMomentum(slsStateCopy), std::abs(1. / freeParams[eFreeQOverP]), 1e-6); CHECK_CLOSE_ABS(sls.charge(slsStateCopy), -sls.charge(ps.stepping), 1e-6); CHECK_CLOSE_ABS(sls.time(slsStateCopy), freeParams[eFreeTime], 1e-6); diff --git a/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp b/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp index 51e21a084a1..1c4c6d21f29 100644 --- a/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp +++ b/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp @@ -61,9 +61,9 @@ struct Stepper { Vector3 direction(const StepperState& state) const { return state.dir; } - double qop(const StepperState& state) const { return state.q / state.p; } + double qOverP(const StepperState& state) const { return state.q / state.p; } - double momentum(const StepperState& state) const { return state.p; } + double absoluteMomentum(const StepperState& state) const { return state.p; } double charge(const StepperState& state) const { return state.q; }; }; @@ -105,9 +105,10 @@ BOOST_AUTO_TEST_CASE(volume_material_interaction_test) { BOOST_CHECK_EQUAL(volMatInt.pos, stepper.position(state.stepping)); BOOST_CHECK_EQUAL(volMatInt.time, stepper.time(state.stepping)); BOOST_CHECK_EQUAL(volMatInt.dir, stepper.direction(state.stepping)); - BOOST_CHECK_EQUAL(volMatInt.momentum, stepper.momentum(state.stepping)); + BOOST_CHECK_EQUAL(volMatInt.momentum, + stepper.absoluteMomentum(state.stepping)); BOOST_CHECK_EQUAL(volMatInt.absQ, std::abs(stepper.charge(state.stepping))); - CHECK_CLOSE_ABS(volMatInt.qOverP, stepper.qop(state.stepping), 1e-6); + CHECK_CLOSE_ABS(volMatInt.qOverP, stepper.qOverP(state.stepping), 1e-6); BOOST_CHECK_EQUAL(volMatInt.mass, state.options.mass); BOOST_CHECK_EQUAL(volMatInt.pdg, state.options.absPdgCode); BOOST_CHECK_EQUAL(volMatInt.performCovarianceTransport, diff --git a/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp b/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp index 2cb7ec767c8..1a7f7e6b71f 100644 --- a/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp +++ b/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp @@ -111,7 +111,7 @@ struct MockStepper { auto position(const State &state) const { return state.pos; } auto time(const State &state) const { return state.time; } auto direction(const State &state) const { return state.dir; } - auto momentum(const State &state) const { return state.p; } + auto absoluteMomentum(const State &state) const { return state.p; } void update(State &state, const Vector3 &pos, const Vector3 &dir, Scalar qop, Scalar time) { state.pos = pos;