File indexing completed on 2026-04-28 07:12:10
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0013 #include "Acts/Propagator/ActorList.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 #include "Acts/Utilities/Result.hpp"
0016 #include "ActsFatras/EventData/Particle.hpp"
0017 #include "ActsFatras/Kernel/SingleParticleSimulationResult.hpp"
0018 #include "ActsFatras/Kernel/detail/SimulationActor.hpp"
0019
0020 #include <algorithm>
0021 #include <cassert>
0022 #include <memory>
0023
0024 namespace ActsFatras {
0025
0026
0027
0028
0029
0030
0031
0032 template <typename propagator_t, typename interactions_t,
0033 typename hit_surface_selector_t, typename decay_t>
0034 struct SingleParticleSimulation {
0035
0036 propagator_t propagator;
0037
0038 double maxStepSize = std::numeric_limits<double>::max();
0039
0040 double pathLimit = std::numeric_limits<double>::max();
0041
0042 decay_t decay;
0043
0044 interactions_t interactions;
0045
0046 hit_surface_selector_t selectHitSurface;
0047
0048 std::unique_ptr<const Acts::Logger> logger;
0049
0050
0051
0052
0053 SingleParticleSimulation(propagator_t &&propagator_,
0054 std::unique_ptr<const Acts::Logger> _logger)
0055 : propagator(propagator_), logger(std::move(_logger)) {}
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066 template <typename generator_t>
0067 Acts::Result<SingleParticleSimulationResult> simulate(
0068 const Acts::GeometryContext &geoCtx,
0069 const Acts::MagneticFieldContext &magCtx, generator_t &generator,
0070 const Particle &particle) const {
0071
0072 using Actor = detail::SimulationActor<generator_t, decay_t, interactions_t,
0073 hit_surface_selector_t>;
0074 using Result = typename Actor::result_type;
0075 using ActorList = Acts::ActorList<Actor>;
0076 using PropagatorOptions =
0077 typename propagator_t::template Options<ActorList>;
0078
0079
0080 PropagatorOptions options(geoCtx, magCtx);
0081 options.stepping.maxStepSize = maxStepSize;
0082 options.pathLimit = pathLimit;
0083
0084 auto &actor = options.actorList.template get<Actor>();
0085 actor.generator = &generator;
0086 actor.decay = decay;
0087 actor.interactions = interactions;
0088 actor.selectHitSurface = selectHitSurface;
0089 actor.initialParticle = particle;
0090
0091 if (particle.hasReferenceSurface()) {
0092 auto result = propagator.propagate(
0093 particle.boundParameters(geoCtx).value(), options);
0094 if (!result.ok()) {
0095 return result.error();
0096 }
0097 auto &value = result.value().template get<Result>();
0098 return std::move(value);
0099 }
0100
0101 auto result =
0102 propagator.propagate(particle.curvilinearParameters(), options);
0103 if (!result.ok()) {
0104 return result.error();
0105 }
0106 auto &value = result.value().template get<Result>();
0107 return std::move(value);
0108 }
0109 };
0110
0111 }