diff --git a/core/include/detray/propagator/actor_chain.hpp b/core/include/detray/propagator/actor_chain.hpp index 810d0e59a..b80ce5a4d 100644 --- a/core/include/detray/propagator/actor_chain.hpp +++ b/core/include/detray/propagator/actor_chain.hpp @@ -1,19 +1,24 @@ /** Detray library, part of the ACTS project (R&D line) * - * (c) 2022 CERN for the benefit of the ACTS project + * (c) 2022-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ #pragma once -#include -#include - +// Project include(s) #include "detray/definitions/detail/containers.hpp" #include "detray/definitions/detail/qualifiers.hpp" +#include "detray/propagator/base_actor.hpp" #include "detray/utils/tuple_helpers.hpp" +// System include(s) +#include +#include +#include +#include + namespace detray { /// The interface to the actors and aborters in the propagation. @@ -44,7 +49,27 @@ class actor_chain { } /// @returns the actor list - DETRAY_HOST_DEVICE const actor_list_type &actors() const { return _actors; } + DETRAY_HOST_DEVICE const actor_list_type &actors() const { + return m_actors; + } + + /// @returns a tuple of default constructible actor states and a + /// corresponding tuple of references + DETRAY_HOST_DEVICE + static constexpr auto make_actor_states() { + // Only possible if each state is default initializable + if constexpr ((std::default_initializable && + ...)) { + tuple_t states{}; + + return std::make_tuple( + states, + make_ref_tuple( + states, std::make_index_sequence{})); + } else { + return std::nullopt; + } + } private: /// Call the actors. Either single actor or composition. @@ -58,7 +83,13 @@ class actor_chain { actor_states_t &states, propagator_state_t &p_state) const { if constexpr (!typename actor_t::is_comp_actor()) { - actr(detail::get(states), p_state); + // No actor state defined (empty) + if constexpr (std::same_as) { + actr(p_state); + } else { + actr(detail::get(states), p_state); + } } else { actr(states, p_state); } @@ -73,11 +104,19 @@ class actor_chain { DETRAY_HOST_DEVICE inline void run( actor_states_t &states, propagator_state_t &p_state, std::index_sequence /*ids*/) const { - (run(detail::get(_actors), states, p_state), ...); + (run(detail::get(m_actors), states, p_state), ...); + } + + /// @returns a tuple of reference for every state in the tuple @param t + template + DETRAY_HOST_DEVICE static constexpr state make_ref_tuple( + tuple_t &t, + std::index_sequence /*ids*/) { + return detray::tie(detail::get(t)...); } /// Tuple of actors - actor_list_type _actors = {}; + actor_list_type m_actors = {}; }; /// Empty actor chain (placeholder) diff --git a/core/include/detray/propagator/actors/parameter_resetter.hpp b/core/include/detray/propagator/actors/parameter_resetter.hpp index 7ab323941..193071344 100644 --- a/core/include/detray/propagator/actors/parameter_resetter.hpp +++ b/core/include/detray/propagator/actors/parameter_resetter.hpp @@ -21,8 +21,6 @@ struct parameter_resetter : actor { using scalar_type = dscalar; - struct state {}; - /// Mask store visitor struct kernel { @@ -56,8 +54,7 @@ struct parameter_resetter : actor { }; template - DETRAY_HOST_DEVICE void operator()(state& /*resetter_state*/, - propagator_state_t& propagation) const { + DETRAY_HOST_DEVICE void operator()(propagator_state_t& propagation) const { const auto& navigation = propagation._navigation; auto& stepping = propagation._stepping; diff --git a/core/include/detray/propagator/actors/parameter_transporter.hpp b/core/include/detray/propagator/actors/parameter_transporter.hpp index e9973c463..d9ae6175e 100644 --- a/core/include/detray/propagator/actors/parameter_transporter.hpp +++ b/core/include/detray/propagator/actors/parameter_transporter.hpp @@ -35,8 +35,6 @@ struct parameter_transporter : actor { using bound_matrix_t = bound_matrix; /// @} - struct state {}; - struct get_full_jacobian_kernel { template - DETRAY_HOST_DEVICE void operator()(state& /*actor_state*/, - propagator_state_t& propagation) const { + DETRAY_HOST_DEVICE void operator()(propagator_state_t& propagation) const { auto& stepping = propagation._stepping; const auto& navigation = propagation._navigation; diff --git a/core/include/detray/propagator/base_actor.hpp b/core/include/detray/propagator/base_actor.hpp index d9646624f..ccdf029b5 100644 --- a/core/include/detray/propagator/base_actor.hpp +++ b/core/include/detray/propagator/base_actor.hpp @@ -1,19 +1,22 @@ /** Detray library, part of the ACTS project (R&D line) * - * (c) 2022 CERN for the benefit of the ACTS project + * (c) 2022-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ #pragma once -#include -#include - +// Propagate include(s) #include "detray/definitions/detail/containers.hpp" #include "detray/definitions/detail/qualifiers.hpp" #include "detray/utils/tuple_helpers.hpp" +// System include(s) +#include +#include +#include + namespace detray { /// Base class actor implementation @@ -77,7 +80,7 @@ class composite_actor final : public actor_impl_t { } // ... then run the observers on the updated state - notify(_observers, states, actor_state, p_state, + notify(m_observers, states, actor_state, p_state, std::make_index_sequence{}); } @@ -97,8 +100,14 @@ class composite_actor final : public actor_impl_t { propagator_state_t &p_state) const { // Two cases: observer is a simple actor or a composite actor if constexpr (!typename observer_t::is_comp_actor()) { - observer(detail::get(states), - actor_state, p_state); + // No actor state defined (empty) + if constexpr (std::same_as) { + observer(actor_state, p_state); + } else { + observer(detail::get(states), + actor_state, p_state); + } } else { observer(states, actor_state, p_state); } @@ -126,7 +135,7 @@ class composite_actor final : public actor_impl_t { } /// Keep the observers (might be composites again) - tuple_t _observers = {}; + tuple_t m_observers = {}; }; } // namespace detray