Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:00

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/em/interactor/RelativisticBremInteractor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/data/Collection.hh"
0012 #include "corecel/data/StackAllocator.hh"
0013 #include "corecel/math/Algorithms.hh"
0014 #include "corecel/math/ArrayUtils.hh"
0015 #include "celeritas/Quantities.hh"
0016 #include "celeritas/Types.hh"
0017 #include "celeritas/em/data/RelativisticBremData.hh"
0018 #include "celeritas/em/distribution/TsaiUrbanDistribution.hh"
0019 #include "celeritas/mat/ElementView.hh"
0020 #include "celeritas/mat/MaterialView.hh"
0021 #include "celeritas/phys/CutoffView.hh"
0022 #include "celeritas/phys/Interaction.hh"
0023 #include "celeritas/phys/ParticleTrackView.hh"
0024 #include "celeritas/phys/Secondary.hh"
0025 
0026 #include "detail/BremFinalStateHelper.hh"
0027 #include "detail/PhysicsConstants.hh"
0028 #include "detail/RBEnergySampler.hh"
0029 
0030 namespace celeritas
0031 {
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Perform a high-energy Bremsstrahlung interaction.
0035  *
0036  * This is a relativistic Bremsstrahlung model for high-energy (> 1 GeV)
0037  * electrons and positrons.
0038  *
0039  * \note This performs the same sampling routine as in Geant4's
0040  * G4eBremsstrahlungRelModel class, as documented in section 10.2.2 of the
0041  * Geant4 Physics Reference (release 10.7).
0042  */
0043 class RelativisticBremInteractor
0044 {
0045   public:
0046     //!@{
0047     //! \name Type aliases
0048     using Energy = units::MevEnergy;
0049     using Momentum = units::MevMomentum;
0050     using ElementData = RelBremElementData;
0051     using ItemIdT = celeritas::ItemId<unsigned int>;
0052     //!@}
0053 
0054   public:
0055     // Construct with shared and state data
0056     inline CELER_FUNCTION
0057     RelativisticBremInteractor(RelativisticBremRef const& shared,
0058                                ParticleTrackView const& particle,
0059                                Real3 const& direction,
0060                                CutoffView const& cutoffs,
0061                                StackAllocator<Secondary>& allocate,
0062                                MaterialView const& material,
0063                                ElementComponentId const& elcomp_id);
0064 
0065     // Sample an interaction with the given RNG
0066     template<class Engine>
0067     inline CELER_FUNCTION Interaction operator()(Engine& rng);
0068 
0069   private:
0070     //// DATA ////
0071 
0072     // Shared constant physics properties
0073     RelativisticBremRef const& shared_;
0074     // Incident particle energy
0075     Energy const inc_energy_;
0076     // Incident particle momentum
0077     Momentum const inc_momentum_;
0078     // Incident direction
0079     Real3 const& inc_direction_;
0080     // Allocate space for a secondary particle
0081     StackAllocator<Secondary>& allocate_;
0082 
0083     //// HELPER CLASSES ////
0084 
0085     // A helper to sample the photon energy from the relativistic model
0086     detail::RBEnergySampler sample_photon_energy_;
0087     // Secondary angular distribution
0088     TsaiUrbanDistribution sample_costheta_;
0089 };
0090 
0091 //---------------------------------------------------------------------------//
0092 // INLINE DEFINITIONS
0093 //---------------------------------------------------------------------------//
0094 /*!
0095  * Construct with shared and state data.
0096  */
0097 CELER_FUNCTION
0098 RelativisticBremInteractor::RelativisticBremInteractor(
0099     RelativisticBremRef const& shared,
0100     ParticleTrackView const& particle,
0101     Real3 const& direction,
0102     CutoffView const& cutoffs,
0103     StackAllocator<Secondary>& allocate,
0104     MaterialView const& material,
0105     ElementComponentId const& elcomp_id)
0106     : shared_(shared)
0107     , inc_energy_(particle.energy())
0108     , inc_momentum_(particle.momentum())
0109     , inc_direction_(direction)
0110     , allocate_(allocate)
0111     , sample_photon_energy_(shared, particle, cutoffs, material, elcomp_id)
0112     , sample_costheta_(inc_energy_, particle.mass())
0113 {
0114     CELER_EXPECT(particle.particle_id() == shared_.ids.electron
0115                  || particle.particle_id() == shared_.ids.positron);
0116 
0117     // Valid energy region of the relativistic e-/e+ Bremsstrahlung model
0118     CELER_EXPECT(inc_energy_ >= shared_.low_energy_limit);
0119 }
0120 
0121 //---------------------------------------------------------------------------//
0122 /*!
0123  * Sample the production of photons and update final states.
0124  */
0125 template<class Engine>
0126 CELER_FUNCTION Interaction RelativisticBremInteractor::operator()(Engine& rng)
0127 {
0128     // Allocate space for the brems photon
0129     Secondary* secondaries = allocate_(1);
0130     if (secondaries == nullptr)
0131     {
0132         // Failed to allocate space for the secondary
0133         return Interaction::from_failure();
0134     }
0135 
0136     // Update kinematics of the final state and return this interaction
0137     return detail::BremFinalStateHelper{inc_energy_,
0138                                         inc_direction_,
0139                                         inc_momentum_,
0140                                         shared_.ids.gamma,
0141                                         sample_photon_energy_(rng),
0142                                         sample_costheta_(rng),
0143                                         secondaries}(rng);
0144 }
0145 
0146 //---------------------------------------------------------------------------//
0147 }  // namespace celeritas