Analysis Software
Documentation for sPHENIX simulation 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 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 
11 #include "Acts/Utilities/Definitions.hpp"
12 
13 #include <cmath>
14 
15 namespace Fatras {
16 
31 template <typename physics_t, typename selector_in_t, typename selector_out_t,
32  typename selector_child_t>
33 
34 struct Process {
35 
37  physics_t process;
38 
40  selector_in_t selectorIn;
41  selector_out_t selectorOut;
42  selector_child_t selectorChild;
43 
45  template <typename generator_t, typename detector_t, typename particle_t>
46  bool operator()(generator_t &gen, const detector_t &det, particle_t &in,
47  std::vector<particle_t> &out) const {
48  // check if the process applies
49  if (selectorIn(det, in)) {
50  // apply energy loss and get eventual children
51  auto children = process(gen, det, in);
52  if (children.size()) {
53  // copy the children that comply with the child selector
54  std::copy_if(
55  children.begin(), children.end(), std::back_inserter(out),
56  [this, det](const particle_t &p) { return selectorChild(det, p); });
57  }
58  }
59  // check if this killed the particle,
60  // or pushed below threshold
61  return (!selectorOut(det, in));
62  }
63 };
64 
65 } // namespace Fatras