Back to home page

EIC code displayed by LXR

 
 

    


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

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