ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Process.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Process.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
13 
14 namespace ActsFatras {
15 
17 struct EveryParticle {
18  constexpr bool operator()(const Particle &) const { return true; }
19 };
20 
21 // No-op input selector that selects all configurations.
22 struct EveryInput {
23  constexpr bool operator()(const Particle &,
24  const Acts::MaterialProperties &) const {
25  return true;
26  }
27 };
28 
30 template <typename ParticleSelector>
31 struct AsInputSelector : public ParticleSelector {
33  const Acts::MaterialProperties &) const {
34  return ParticleSelector::operator()(particle);
35  }
36 };
37 
52 template <typename physics_t, typename input_selector_t = EveryInput,
53  typename output_particle_selector_t = EveryParticle,
54  typename child_particle_selector_t = output_particle_selector_t>
55 struct Process {
57  physics_t physics;
59  input_selector_t selectInput;
61  output_particle_selector_t selectOutputParticle;
63  child_particle_selector_t selectChildParticle;
64 
74  template <typename generator_t>
75  bool operator()(generator_t &generator, const Acts::MaterialProperties &slab,
76  Particle &particle, std::vector<Particle> &generated) const {
77  // not selecting this process is not a break condition
78  if (not selectInput(particle, slab)) {
79  return false;
80  }
81  // modify particle according to the physics process
82  auto children = physics(generator, slab, particle);
83  // move selected child particles to the output container
84  std::copy_if(children.begin(), children.end(),
85  std::back_inserter(generated), selectChildParticle);
86  // break condition is defined by whether the output particle is still valid
87  // or not e.g. because it has fallen below a momentum threshold.
88  return not selectOutputParticle(particle);
89  }
90 };
91 
92 } // namespace ActsFatras