File indexing completed on 2025-09-18 09:09:00
0001
0002
0003
0004
0005
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
0035
0036
0037
0038
0039
0040
0041
0042
0043 class RelativisticBremInteractor
0044 {
0045 public:
0046
0047
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
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
0066 template<class Engine>
0067 inline CELER_FUNCTION Interaction operator()(Engine& rng);
0068
0069 private:
0070
0071
0072
0073 RelativisticBremRef const& shared_;
0074
0075 Energy const inc_energy_;
0076
0077 Momentum const inc_momentum_;
0078
0079 Real3 const& inc_direction_;
0080
0081 StackAllocator<Secondary>& allocate_;
0082
0083
0084
0085
0086 detail::RBEnergySampler sample_photon_energy_;
0087
0088 TsaiUrbanDistribution sample_costheta_;
0089 };
0090
0091
0092
0093
0094
0095
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
0118 CELER_EXPECT(inc_energy_ >= shared_.low_energy_limit);
0119 }
0120
0121
0122
0123
0124
0125 template<class Engine>
0126 CELER_FUNCTION Interaction RelativisticBremInteractor::operator()(Engine& rng)
0127 {
0128
0129 Secondary* secondaries = allocate_(1);
0130 if (secondaries == nullptr)
0131 {
0132
0133 return Interaction::from_failure();
0134 }
0135
0136
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 }