Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:13

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Material/MaterialSlab.hpp"
0012 #include "ActsFatras/EventData/Particle.hpp"
0013 
0014 namespace ActsFatras {
0015 
0016 /// A continuous simulation process based on a physics model plus selectors.
0017 ///
0018 /// @tparam physics_t is the physics model type
0019 /// @tparam input_particle_selector_t is the input particle selector
0020 /// @tparam output_particle_selector_t is the output particle selector
0021 /// @tparam child_particle_selector_t is the child particle selector
0022 ///
0023 /// The physics model type **must** provide a call operator with the following
0024 /// signature
0025 ///
0026 ///     <Particle Container>
0027 ///     operator()(
0028 ///         generator_t& generator,
0029 ///         const Acts::MaterialSlab& slab,
0030 ///         Particle& particle) const
0031 ///
0032 /// The return type can be any `Container` with `Particle` elements.
0033 ///
0034 /// The input selector defines whether the process is applied while the
0035 /// output selector defines a break condition, i.e. whether to continue
0036 /// simulating the particle propagation. The child selector is used to
0037 /// filter the generated child particles.
0038 ///
0039 /// @note The output and child particle selectors are identical unless the
0040 ///       child particle selector is explicitly specified.
0041 template <typename physics_t, typename input_particle_selector_t,
0042           typename output_particle_selector_t,
0043           typename child_particle_selector_t = output_particle_selector_t>
0044 struct ContinuousProcess {
0045   /// The physics interactions implementation.
0046   physics_t physics;
0047   /// Input selection: if this process applies to this particle.
0048   input_particle_selector_t selectInputParticle;
0049   /// Output selection: if the particle is still valid after the interaction.
0050   output_particle_selector_t selectOutputParticle;
0051   /// Child selection: if a generated child particle should be kept.
0052   child_particle_selector_t selectChildParticle;
0053 
0054   /// Execute the physics process considering the configured selectors.
0055   ///
0056   /// @param[in]     generator is the random number generator
0057   /// @param[in]     slab      is the passed material
0058   /// @param[in,out] particle  is the particle being updated
0059   /// @param[out]    generated is the container of generated particles
0060   /// @return Break condition, i.e. whether this process stops the propagation
0061   ///
0062   /// @tparam generator_t must be a RandomNumberEngine
0063   template <typename generator_t>
0064   bool operator()(generator_t &generator, const Acts::MaterialSlab &slab,
0065                   Particle &particle, std::vector<Particle> &generated) const {
0066     // not selecting this process is not a break condition
0067     if (!selectInputParticle(particle)) {
0068       return false;
0069     }
0070     // modify particle according to the physics process
0071     auto children = physics(generator, slab, particle);
0072     // move selected child particles to the output container
0073     std::copy_if(std::begin(children), std::end(children),
0074                  std::back_inserter(generated), selectChildParticle);
0075     // break condition is defined by whether the output particle is still valid
0076     // or not e.g. because it has fallen below a momentum threshold.
0077     return !selectOutputParticle(particle);
0078   }
0079 };
0080 
0081 }  // namespace ActsFatras