Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:08

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2018 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Utilities/Definitions.hpp"
0012 
0013 #include <cmath>
0014 
0015 namespace Fatras {
0016 
0017 /// @brief Process class that turns a parameterized or
0018 /// tabularized fast simulation module into a process that
0019 /// can be plugged into the PhysicsList
0020 ///
0021 /// This is plugin for physics processes
0022 ///  - scattering
0023 ///  - energy loss
0024 ///  - pair production
0025 ///  - hadronic interaction
0026 ///  - decay
0027 ///
0028 /// The type (and actual trigger) of the particle
0029 /// and interaction is steered via the Selector list
0030 /// for in and out.
0031 template <typename physics_t, typename selector_in_t, typename selector_out_t,
0032           typename selector_child_t>
0033 
0034 struct Process {
0035 
0036   /// The actual physics that is happening
0037   physics_t process;
0038 
0039   /// The selector list
0040   selector_in_t selectorIn;
0041   selector_out_t selectorOut;
0042   selector_child_t selectorChild;
0043 
0044   /// This is the scattering call operator
0045   template <typename generator_t, typename detector_t, typename particle_t>
0046   bool operator()(generator_t &gen, const detector_t &det, particle_t &in,
0047                   std::vector<particle_t> &out) const {
0048     // check if the process applies
0049     if (selectorIn(det, in)) {
0050       // apply energy loss and get eventual children
0051       auto children = process(gen, det, in);
0052       if (children.size()) {
0053         // copy the children that comply with the child selector
0054         std::copy_if(
0055             children.begin(), children.end(), std::back_inserter(out),
0056             [this, det](const particle_t &p) { return selectorChild(det, p); });
0057       }
0058     }
0059     // check if this killed the particle,
0060     // or pushed below threshold
0061     return (!selectorOut(det, in));
0062   }
0063 };
0064 
0065 } // namespace Fatras