Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:18

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