Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-13 08:53:26

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/detail/BremFinalStateHelper.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "celeritas/Quantities.hh"
0010 #include "celeritas/phys/InteractionUtils.hh"
0011 #include "celeritas/phys/Secondary.hh"
0012 
0013 namespace celeritas
0014 {
0015 namespace detail
0016 {
0017 //---------------------------------------------------------------------------//
0018 /*!
0019  * Sample the angular distribution of photon from e+/e- Bremsstrahlung.
0020  */
0021 class BremFinalStateHelper
0022 {
0023   public:
0024     //!@{
0025     //! \name Type aliases
0026     using Energy = units::MevEnergy;
0027     using Mass = units::MevMass;
0028     using Momentum = units::MevMomentum;
0029     //!@}
0030 
0031   public:
0032     // Construct from data
0033     inline CELER_FUNCTION BremFinalStateHelper(Energy inc_energy,
0034                                                Real3 const& inc_direction,
0035                                                Momentum inc_momentum,
0036                                                ParticleId gamma_id,
0037                                                Energy gamma_energy,
0038                                                real_type costheta,
0039                                                Secondary* secondary);
0040 
0041     // Update the final state for the given RNG and the photon energy
0042     template<class Engine>
0043     inline CELER_FUNCTION Interaction operator()(Engine& rng);
0044 
0045   private:
0046     // Incident particle direction
0047     Real3 const& inc_direction_;
0048     // Incident particle momentum
0049     Momentum inc_momentum_;
0050     // Exiting energy
0051     Energy exit_energy_;
0052     // Bremsstrahlung photon id
0053     ParticleId gamma_id_;
0054     // Exiting gamma energy
0055     Energy gamma_energy_;
0056     // Secondary polar angle
0057     real_type costheta_;
0058     // Allocated secondary gamma
0059     Secondary* secondary_;
0060 };
0061 
0062 //---------------------------------------------------------------------------//
0063 // INLINE DEFINITIONS
0064 //---------------------------------------------------------------------------//
0065 /*!
0066  * Construct from incident particle and exiting gamma data.
0067  */
0068 CELER_FUNCTION
0069 BremFinalStateHelper::BremFinalStateHelper(Energy inc_energy,
0070                                            Real3 const& inc_direction,
0071                                            Momentum inc_momentum,
0072                                            ParticleId gamma_id,
0073                                            Energy gamma_energy,
0074                                            real_type costheta,
0075                                            Secondary* secondary)
0076     : inc_direction_(inc_direction)
0077     , inc_momentum_(inc_momentum)
0078     , exit_energy_{inc_energy - gamma_energy}
0079     , gamma_id_(gamma_id)
0080     , gamma_energy_{gamma_energy}
0081     , costheta_(costheta)
0082     , secondary_{secondary}
0083 {
0084     CELER_EXPECT(secondary_);
0085 }
0086 
0087 //---------------------------------------------------------------------------//
0088 /*!
0089  * Update the final state of the primary particle and the secondary photon.
0090  */
0091 template<class Engine>
0092 CELER_FUNCTION Interaction BremFinalStateHelper::operator()(Engine& rng)
0093 {
0094     // Generate exiting gamma direction from isotropic azimuthal angle and
0095     // TsaiUrbanDistribution for polar angle (based on G4ModifiedTsai)
0096     secondary_->direction
0097         = ExitingDirectionSampler{costheta_, inc_direction_}(rng);
0098     secondary_->particle_id = gamma_id_;
0099     secondary_->energy = gamma_energy_;
0100 
0101     // Construct interaction for change to parent (incoming) particle
0102     Interaction result;
0103     result.energy = exit_energy_;
0104     result.direction = calc_exiting_direction(
0105         {inc_momentum_.value(), inc_direction_},
0106         {gamma_energy_.value(), secondary_->direction});
0107     result.secondaries = {secondary_, 1};
0108 
0109     return result;
0110 }
0111 
0112 //---------------------------------------------------------------------------//
0113 }  // namespace detail
0114 }  // namespace celeritas