34 namespace ActsFatras {
42 template <
typename propagator_t,
typename interactions_t,
43 typename hit_surface_selector_t,
typename decay_t>
54 std::unique_ptr<const Acts::Logger>
logger;
58 std::unique_ptr<const Acts::Logger> _logger)
70 template <
typename generator_t>
77 hit_surface_selector_t>;
78 using Aborter =
typename Actor::ParticleNotAlive;
79 using Result =
typename Actor::result_type;
80 using Actions = Acts::ActionList<Actor>;
81 using Abort = Acts::AbortList<Aborter, Acts::EndOfWorldReached>;
85 PropagatorOptions
options(geoCtx, magCtx);
87 auto &actor = options.actionList.template get<Actor>();
97 if (not result.ok()) {
98 return result.error();
100 auto &
value = result.value().template get<Result>();
106 if (not result.ok()) {
107 return result.error();
109 auto &
value = result.value().template get<Result>();
136 template <
typename charged_selector_t,
typename charged_simulator_t,
137 typename neutral_selector_t,
typename neutral_simulator_t>
145 Simulation(charged_simulator_t &&charged_, neutral_simulator_t &&neutral_)
184 template <
typename generator_t,
typename input_particles_t,
185 typename output_particles_t,
typename hits_t>
190 output_particles_t &simulatedParticlesInitial,
191 output_particles_t &simulatedParticlesFinal, hits_t &hits)
const {
193 (simulatedParticlesInitial.size() == simulatedParticlesFinal.size()) and
194 "Inconsistent initial sizes of the simulated particle containers");
198 std::vector<FailedParticle> failedParticles;
200 for (
const Particle &inputParticle : inputParticles) {
206 if ((inputParticle.particleId().generation() != 0
u) or
207 (inputParticle.particleId().subParticle() != 0
u)) {
208 return detail::SimulationError::eInvalidInputParticleId;
220 auto iinitial = simulatedParticlesInitial.size();
221 simulatedParticlesInitial.push_back(inputParticle);
222 for (; iinitial < simulatedParticlesInitial.size(); ++iinitial) {
223 const auto &initialParticle = simulatedParticlesInitial[iinitial];
227 SingleParticleSimulationResult result =
228 SingleParticleSimulationResult::success({});
230 result =
charged.simulate(geoCtx, magCtx, generator, initialParticle);
232 result =
neutral.simulate(geoCtx, magCtx, generator, initialParticle);
235 if (not result.ok()) {
237 simulatedParticlesInitial.erase(
238 std::next(simulatedParticlesInitial.begin(), iinitial));
240 failedParticles.push_back({initialParticle, result.error()});
244 copyOutputs(result.value(), simulatedParticlesInitial,
245 simulatedParticlesFinal, hits);
259 return failedParticles;
276 template <
typename particles_t,
typename hits_t>
278 particles_t &particlesInitial, particles_t &particlesFinal,
279 hits_t &hits)
const {
282 particlesFinal.push_back(result.
particle);
286 std::back_inserter(particlesInitial),
288 std::copy(result.
hits.begin(), result.
hits.end(), std::back_inserter(hits));
305 template <
typename particles_t>
307 std::size_t lastValid) {
327 for (
auto j = lastValid; (
j + 1
u) < particles.size(); ++
j) {
328 const auto prevId = particles[
j].particleId();
329 auto currId = particles[
j + 1
u].particleId();
332 if (prevId.generation() != currId.generation()) {
336 if (prevId.subParticle() < currId.subParticle()) {
340 currId.setSubParticle(prevId.subParticle() + 1
u);
341 particles[
j + 1
u] = particles[
j + 1
u].withParticleId(currId);