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::MaterialSlab &) const {
25  return true;
26  }
27 };
28 
30 template <typename ParticleSelector>
31 struct AsInputSelector : public ParticleSelector {
32  bool operator()(const Particle &particle, const Acts::MaterialSlab &) const {
33  return ParticleSelector::operator()(particle);
34  }
35 };
36 
51 template <typename physics_t, typename input_selector_t = EveryInput,
52  typename output_particle_selector_t = EveryParticle,
53  typename child_particle_selector_t = output_particle_selector_t>
54 struct Process {
56  physics_t physics;
58  input_selector_t selectInput;
60  output_particle_selector_t selectOutputParticle;
62  child_particle_selector_t selectChildParticle;
63 
73  template <typename generator_t>
74  bool operator()(generator_t &generator, const Acts::MaterialSlab &slab,
75  Particle &particle, std::vector<Particle> &generated) const {
76  // not selecting this process is not a break condition
77  if (not selectInput(particle, slab)) {
78  return false;
79  }
80  // modify particle according to the physics process
81  auto children = physics(generator, slab, particle);
82  // move selected child particles to the output container
83  std::copy_if(children.begin(), children.end(),
84  std::back_inserter(generated), selectChildParticle);
85  // break condition is defined by whether the output particle is still valid
86  // or not e.g. because it has fallen below a momentum threshold.
87  return not selectOutputParticle(particle);
88  }
89 };
90 
91 } // namespace ActsFatras