File indexing completed on 2026-09-18 09:09:31
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 CELER_EXPECT(is_soft_unit_vector(init.polarization));
0085
0086 states_.energy[track_slot_] = value_as<Energy>(init.energy);
0087 states_.polarization[track_slot_] = init.polarization;
0088 return *this;
0089 }
0090
0091
0092
0093
0094
0095 CELER_FUNCTION auto ParticleTrackView::energy() const -> Energy
0096 {
0097 return Energy{states_.energy[track_slot_]};
0098 }
0099
0100
0101
0102
0103
0104 CELER_FUNCTION Real3 const& ParticleTrackView::polarization() const
0105 {
0106 return states_.polarization[track_slot_];
0107 }
0108
0109
0110
0111
0112
0113 CELER_FUNCTION
0114 void ParticleTrackView::energy(Energy energy)
0115 {
0116 CELER_EXPECT(energy >= zero_quantity());
0117 states_.energy[track_slot_] = value_as<Energy>(energy);
0118 }
0119
0120
0121
0122
0123
0124 CELER_FUNCTION
0125 void ParticleTrackView::polarization(Real3 const& polarization)
0126 {
0127 CELER_EXPECT(is_soft_unit_vector(polarization));
0128 states_.polarization[track_slot_] = polarization;
0129 }
0130
0131
0132 }
0133 }