File indexing completed on 2025-09-17 08:53:44
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/math/ArraySoftUnit.hh"
0010 #include "geocel/Types.hh"
0011 #include "celeritas/Quantities.hh"
0012
0013 #include "ParticleData.hh"
0014
0015 namespace celeritas
0016 {
0017 namespace optical
0018 {
0019
0020
0021
0022
0023 class ParticleTrackView
0024 {
0025 public:
0026
0027
0028 using Energy = units::MevEnergy;
0029
0030
0031
0032 struct Initializer
0033 {
0034 Energy energy;
0035 Real3 polarization{0, 0, 0};
0036 };
0037
0038 public:
0039 inline CELER_FUNCTION
0040 ParticleTrackView(NativeRef<ParticleStateData> const&, TrackSlotId);
0041
0042
0043 inline CELER_FUNCTION ParticleTrackView& operator=(Initializer const&);
0044
0045
0046 CELER_FORCEINLINE_FUNCTION Energy energy() const;
0047
0048
0049 CELER_FORCEINLINE_FUNCTION Real3 const& polarization() const;
0050
0051
0052 inline CELER_FUNCTION void energy(Energy);
0053
0054
0055 inline CELER_FUNCTION void polarization(Real3 const&);
0056
0057 private:
0058 NativeRef<ParticleStateData> const& states_;
0059 TrackSlotId track_slot_;
0060 };
0061
0062
0063
0064
0065
0066
0067
0068 CELER_FUNCTION
0069 ParticleTrackView::ParticleTrackView(NativeRef<ParticleStateData> const& states,
0070 TrackSlotId tid)
0071 : states_(states), track_slot_(tid)
0072 {
0073 CELER_EXPECT(track_slot_ < states_.size());
0074 }
0075
0076
0077
0078
0079
0080 CELER_FUNCTION ParticleTrackView&
0081 ParticleTrackView::operator=(Initializer const& init)
0082 {
0083 CELER_EXPECT(init.energy >= zero_quantity());
0084 states_.energy[track_slot_] = value_as<Energy>(init.energy);
0085 states_.polarization[track_slot_] = init.polarization;
0086 return *this;
0087 }
0088
0089
0090
0091
0092
0093 CELER_FUNCTION auto ParticleTrackView::energy() const -> Energy
0094 {
0095 return Energy{states_.energy[track_slot_]};
0096 }
0097
0098
0099
0100
0101
0102 CELER_FUNCTION Real3 const& ParticleTrackView::polarization() const
0103 {
0104 return states_.polarization[track_slot_];
0105 }
0106
0107
0108
0109
0110
0111 CELER_FUNCTION
0112 void ParticleTrackView::energy(Energy energy)
0113 {
0114 CELER_EXPECT(energy >= zero_quantity());
0115 states_.energy[track_slot_] = value_as<Energy>(energy);
0116 }
0117
0118
0119
0120
0121
0122 CELER_FUNCTION
0123 void ParticleTrackView::polarization(Real3 const& polarization)
0124 {
0125 CELER_EXPECT(is_soft_unit_vector(polarization));
0126 states_.polarization[track_slot_] = polarization;
0127 }
0128
0129
0130 }
0131 }