Skip to content

Commit

Permalink
refactor!: Fuse Actor and Aborter (#3573)
Browse files Browse the repository at this point in the history
Fuses Actors and Aborters into a single object with seperate `act` and `check` calls. The motivation for this is that Aborters cannot hold any state by their own currently but need an Actor to point to. To simplify this I propose to couple these two concepts.

At the same time I reworked the call mechanism for the actor and aborter functions which concepts and a simpler dispatch mechanism.

Class names changed a bit from `ActionList` to `ActorList` for example.
  • Loading branch information
andiwand authored Sep 24, 2024
1 parent 9ee3a10 commit 17b7b92
Show file tree
Hide file tree
Showing 46 changed files with 736 additions and 915 deletions.
16 changes: 7 additions & 9 deletions Core/include/Acts/Material/PropagatorMaterialAssigner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/Material/interface/IAssignmentFinder.hpp"
#include "Acts/Propagator/AbortList.hpp"
#include "Acts/Propagator/ActionList.hpp"
#include "Acts/Propagator/ActorList.hpp"
#include "Acts/Propagator/Propagator.hpp"
#include "Acts/Propagator/SurfaceCollector.hpp"
#include "Acts/Surfaces/Surface.hpp"
Expand Down Expand Up @@ -62,9 +61,9 @@ struct InteractionVolumeCollector {
/// @param [in,out] result is the mutable result object
template <typename propagator_state_t, typename stepper_t,
typename navigator_t>
void operator()(propagator_state_t& state, const stepper_t& stepper,
const navigator_t& navigator, result_type& result,
const Logger& /*logger*/) const {
void act(propagator_state_t& state, const stepper_t& stepper,
const navigator_t& navigator, result_type& result,
const Logger& /*logger*/) const {
// Retrieve the current volume
auto currentVolume = navigator.currentVolume(state.navigation);

Expand Down Expand Up @@ -131,11 +130,10 @@ class PropagatorMaterialAssigner final : public IAssignmentFinder {
// Prepare Action list and abort list
using MaterialSurfaceCollector =
SurfaceCollector<MaterialSurfaceIdentifier>;
using ActionList =
ActionList<MaterialSurfaceCollector, InteractionVolumeCollector>;
using AbortList = AbortList<EndOfWorldReached>;
using ActorList = ActorList<MaterialSurfaceCollector,
InteractionVolumeCollector, EndOfWorldReached>;
using PropagatorOptions =
typename propagator_t::template Options<ActionList, AbortList>;
typename propagator_t::template Options<ActorList>;

PropagatorOptions options(gctx, mctx);

Expand Down
115 changes: 0 additions & 115 deletions Core/include/Acts/Propagator/AbortList.hpp

This file was deleted.

94 changes: 0 additions & 94 deletions Core/include/Acts/Propagator/ActionList.hpp

This file was deleted.

87 changes: 87 additions & 0 deletions Core/include/Acts/Propagator/ActorConcepts.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// This file is part of the Acts project.
//
// Copyright (C) 2024 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#pragma once

#include <concepts>
#include <type_traits>
#include <utility>

namespace Acts {

template <typename actor_t>
concept ActorHasResult = requires { typename actor_t::result_type; };

template <typename actor_t, typename propagator_state_t, typename stepper_t,
typename navigator_t, typename... Args>
concept ActorHasActWithoutResult = requires(
const actor_t& a, propagator_state_t& state, const stepper_t& stepper,
const navigator_t& navigator, Args&&... args) {
{
a.act(state, stepper, navigator, std::move<Args>(args)...)
} -> std::same_as<void>;
};

template <typename actor_t, typename propagator_state_t, typename stepper_t,
typename navigator_t, typename... Args>
concept ActorHasActWithResult =
ActorHasResult<actor_t> &&
requires(const actor_t& a, propagator_state_t& state,
const stepper_t& stepper, const navigator_t& navigator,
typename actor_t::result_type& result, Args&&... args) {
{
a.act(state, stepper, navigator, result, std::move<Args>(args)...)
} -> std::same_as<void>;
};

template <typename actor_t, typename propagator_state_t, typename stepper_t,
typename navigator_t, typename... Args>
concept ActorHasAct =
ActorHasActWithoutResult<actor_t, propagator_state_t, stepper_t,
navigator_t, Args...> ||
ActorHasActWithResult<actor_t, propagator_state_t, stepper_t, navigator_t,
Args...>;

template <typename actor_t, typename propagator_state_t, typename stepper_t,
typename navigator_t, typename... Args>
concept ActorHasAbortWithoutResult = requires(
const actor_t& a, propagator_state_t& state, const stepper_t& stepper,
const navigator_t& navigator, Args&&... args) {
{
a.checkAbort(state, stepper, navigator, std::move<Args>(args)...)
} -> std::same_as<bool>;
};

template <typename actor_t, typename propagator_state_t, typename stepper_t,
typename navigator_t, typename... Args>
concept ActorHasAbortWithResult =
ActorHasResult<actor_t> &&
requires(const actor_t& a, propagator_state_t& state,
const stepper_t& stepper, const navigator_t& navigator,
typename actor_t::result_type& result, Args&&... args) {
{
a.checkAbort(state, stepper, navigator, result,
std::move<Args>(args)...)
} -> std::same_as<bool>;
};

template <typename actor_t, typename propagator_state_t, typename stepper_t,
typename navigator_t, typename... Args>
concept ActorHasAbort =
ActorHasAbortWithoutResult<actor_t, propagator_state_t, stepper_t,
navigator_t, Args...> ||
ActorHasAbortWithResult<actor_t, propagator_state_t, stepper_t, navigator_t,
Args...>;

template <typename actor_t, typename propagator_state_t, typename stepper_t,
typename navigator_t, typename... Args>
concept Actor =
ActorHasAct<actor_t, propagator_state_t, stepper_t, navigator_t, Args...> ||
ActorHasAbort<actor_t, propagator_state_t, stepper_t, navigator_t, Args...>;

} // namespace Acts
Loading

0 comments on commit 17b7b92

Please sign in to comment.