Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:09:55

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/Material/Interactions.hpp"
0012 #include "Fatras/Kernel/detail/RandomNumberDistributions.hpp"
0013 
0014 namespace Fatras {
0015 
0016 /// @brief The struct for the EnergyLoss physics list
0017 ///
0018 /// This generates the energy loss according to the Bethe-Bloch
0019 /// description, applying a landau generated enery loss
0020 ///
0021 /// It follows the interface of EnergyLoss samplers in Fatras
0022 /// that could return radiated photons for further processing,
0023 /// however, for the Bethe-Bloch application the return vector
0024 /// is always 0.
0025 struct BetheBloch {
0026 
0027   /// The flag to include BetheBloch process or not
0028   bool betheBloch = true;
0029 
0030   /// Scaling for most probable value
0031   double scaleFactorMPV = 1.;
0032 
0033   /// Scaling for Sigma
0034   double scaleFactorSigma = 1.;
0035 
0036   /// @brief Call operator for the Bethe Bloch energy loss
0037   ///
0038   /// @tparam generator_t is a random number generator type
0039   /// @tparam detector_t is the detector information type
0040   /// @tparam particle_t is the particle information type
0041   ///
0042   /// @param[in] generator is the random number generator
0043   /// @param[in] detector the detector information
0044   /// @param[in] particle the particle which is being scattered
0045   ///
0046   /// @return empty vector for BetheBloch - no secondaries created
0047   template <typename generator_t, typename detector_t, typename particle_t>
0048   std::vector<particle_t> operator()(generator_t &generator,
0049                                      const detector_t &detector,
0050                                      particle_t &particle) const {
0051 
0052     // Do nothing if the flag is set to false
0053     if (not betheBloch) {
0054       return {};
0055     }
0056 
0057     // Create a random landau distribution between in the intervall [0,1]
0058     LandauDist landauDist = LandauDist(0., 1.);
0059     double landau = landauDist(generator);
0060     double qop = particle.q() / particle.p();
0061 
0062     // @TODO Double investigate if we could do one call
0063     double energyLoss = Acts::computeEnergyLossLandau(
0064         detector, particle.pdg(), particle.m(), qop, particle.q());
0065     double energyLossSigma = Acts::computeEnergyLossLandauSigma(
0066         detector, particle.pdg(), particle.m(), qop, particle.q());
0067 
0068     // Simulate the energy loss
0069     double sampledEnergyLoss = scaleFactorMPV * std::fabs(energyLoss) +
0070                                scaleFactorSigma * energyLossSigma * landau;
0071 
0072     // Apply the energy loss
0073     particle.energyLoss(sampledEnergyLoss);
0074 
0075     // return empty children
0076     return {};
0077   }
0078 };
0079 
0080 } // namespace Fatras