File Simulation.hpp

namespace ActsFatras
struct FailedParticle
#include <ActsFatras/Kernel/Simulation.hpp>

A particle that failed to simulate.

Public Members

std::error_code error

The associated error code for this particular failure case.

Particle particle

Initial particle state of the failed particle.

This must store the full particle state to be able to handle secondaries that are not in the input particle list. Otherwise they could not be referenced.

template<typename charged_selector_t, typename charged_simulator_t, typename neutral_selector_t, typename neutral_simulator_t>
struct Simulation
#include <ActsFatras/Kernel/Simulation.hpp>

Multi-particle/event simulation.

The selector types for charged and neutral particles do not need to check for the particle charge. This is done automatically by the simulator to ensure consistency.

Template Parameters
  • charged_selector_t – Callable selector type for charged particles

  • charged_simulator_t – Single particle simulator for charged particles

  • neutral_selector_t – Callable selector type for neutral particles

  • neutral_simulator_t – Single particle simulator for neutral particles

Public Functions

inline Simulation(charged_simulator_t &&charged_, neutral_simulator_t &&neutral_)

Construct from the single charged/neutral particle simulators.

template<typename generator_t, typename input_particles_t, typename output_particles_t, typename hits_t>
inline Acts::Result<std::vector<FailedParticle>> simulate(const Acts::GeometryContext &geoCtx, const Acts::MagneticFieldContext &magCtx, generator_t &generator, const input_particles_t &inputParticles, output_particles_t &simulatedParticlesInitial, output_particles_t &simulatedParticlesFinal, hits_t &hits) const

Simulate multiple particles and generated secondaries.

This takes all input particles and simulates those passing the selection using the appropriate simulator. All selected particle states including additional ones generated from interactions are stored in separate output containers; both the initial state at the production vertex and the final state after propagation are stored. Hits generated from selected input and generated particles are stored in the hit container.

Note

Parameter edge-cases can lead to errors in the underlying propagator and thus to particles that fail to simulate. Here, full events are simulated and the failure to simulate one particle should not be considered a general failure of the simulator. Instead, a list of particles that fail to simulate is provided to the user. It is the users responsibility to handle them.

Note

Failed particles are removed from the regular output, i.e. they do not appear in the simulated particles containers nor do they generate hits.

Warning

Particle-hit association is based on particle ids generated during the simulation. This requires that all input particles must have generation and sub-particle number set to zero.

Parameters
  • geoCtx – is the geometry context to access surface geometries

  • magCtx – is the magnetic field context to access field values

  • generator – is the random number generator

  • inputParticles – contains all particles that should be simulated

  • simulatedParticlesInitial – contains initial particle states

  • simulatedParticlesFinal – contains final particle states

  • hits – contains all generated hits

Return values
  • Acts::Result::Error – if there is a fundamental issue

  • Acts::Result::Success – with all particles that failed to simulate

Template Parameters
  • generator_t – is the type of the random number generator

  • input_particles_t – is a Container for particles

  • output_particles_t – is a SequenceContainer for particles

  • hits_t – is a SequenceContainer for hits

Public Members

charged_simulator_t charged
neutral_simulator_t neutral
charged_selector_t selectCharged
neutral_selector_t selectNeutral

Private Functions

template<typename particles_t, typename hits_t>
inline void copyOutputs(const SimulationResult &result, particles_t &particlesInitial, particles_t &particlesFinal, hits_t &hits) const

Copy results to output containers.

Template Parameters
  • particles_t – is a SequenceContainer for particles

  • hits_t – is a SequenceContainer for hits

inline bool selectParticle(const Particle &particle) const

Select if the particle should be simulated at all.

Private Static Functions

template<typename particles_t>
static inline void renumberTailParticleIds(particles_t &particles, std::size_t lastValid)

Renumber particle ids in the tail of the container.

Ensures particle ids are unique by modifying the sub-particle number within each generation.

Note

This function assumes that all particles in the tail have the same vertex numbers (primary/secondary) and particle number and are ordered according to their generation number.

Parameters
  • particles – particle container in which particles are renumbered

  • lastValid – index of the last particle with a valid particle id

Template Parameters

particles_t – is a SequenceContainer for particles

template<typename propagator_t, typename interactions_t, typename hit_surface_selector_t, typename decay_t>
struct SingleParticleSimulation
#include <ActsFatras/Kernel/Simulation.hpp>

Single particle simulation with fixed propagator, interactions, and decay.

Template Parameters
  • generator_t – random number generator

  • interactions_t – interaction list

  • hit_surface_selector_t – selector for hit surfaces

  • decay_t – decay module

Public Functions

inline SingleParticleSimulation(propagator_t &&propagator_, std::shared_ptr<const Acts::Logger> localLogger_)

Alternatively construct the simulator with an external logger.

inline const Acts::Logger &logger() const

Provide access to the local logger instance, e.g. for logging macros.

template<typename generator_t>
inline Acts::Result<SimulationResult> simulate(const Acts::GeometryContext &geoCtx, const Acts::MagneticFieldContext &magCtx, generator_t &generator, const Particle &particle) const

Simulate a single particle without secondaries.

Template Parameters

generator_t – is the type of the random number generator

Parameters
  • geoCtx – is the geometry context to access surface geometries

  • magCtx – is the magnetic field context to access field values

  • generator – is the random number generator

  • particle – is the initial particle state

Returns

Simulated particle state, hits, and generated particles.

Public Members

decay_t decay

Decay module.

interactions_t interactions

Interaction list containing the simulated interactions.

std::shared_ptr<const Acts::Logger> localLogger = nullptr

Local logger for debug output.

Acts::LoggerWrapper loggerWrapper = Acts::getDummyLogger()

Wrapped logger for debug output.

propagator_t propagator

How and within which geometry to propagate the particle.

hit_surface_selector_t selectHitSurface

Selector for surfaces that should generate hits.