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