File indexing completed on 2026-10-27 09:25:10
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <G4StepPoint.hh>
0010
0011 #include "corecel/Assert.hh"
0012 #include "corecel/Types.hh"
0013 #include "corecel/math/Quantity.hh"
0014 #include "geocel/g4/Convert.hh"
0015 #include "celeritas/UnitTypes.hh"
0016
0017 #include "GeantParticleView.hh"
0018 #include "GeantUnits.hh"
0019
0020 namespace celeritas
0021 {
0022
0023
0024
0025
0026
0027
0028
0029 class GeantStepPointView
0030 {
0031 public:
0032
0033
0034 using Energy = units::ClhepEnergy;
0035 using Length = lengthunits::ClhepLength;
0036 using Time = units::ClhepTime;
0037 using Speed = Quantity<units::CLight, double>;
0038 using real_type = double;
0039
0040
0041 public:
0042
0043 explicit GeantStepPointView(G4StepPoint& step_point) : sp_(step_point) {}
0044
0045
0046
0047
0048
0049 inline Array<Length, 3> pos() const;
0050
0051
0052 inline Array<double, 3> dir() const;
0053
0054
0055 inline Energy energy() const;
0056
0057
0058 inline Time time() const;
0059
0060
0061 real_type weight() const { return sp_.GetWeight(); }
0062
0063
0064 inline Speed speed() const;
0065
0066
0067
0068
0069
0070
0071 inline void pos(Array<Length, 3> const& position);
0072
0073
0074 inline void dir(Array<double, 3> const& direction);
0075
0076
0077 inline void energy(Energy kinetic_energy);
0078
0079
0080 inline void time(Time global_time);
0081
0082
0083 void weight(real_type w) { sp_.SetWeight(w); }
0084
0085
0086 void update_from_volume(G4LogicalVolume const& lv);
0087
0088
0089 void update_from_volume();
0090
0091
0092 void update_from_particle(GeantParticleView const& particle);
0093
0094
0095 void clear_unsupported();
0096
0097
0098
0099
0100 G4StepPoint& step_point() { return sp_; }
0101
0102 private:
0103 G4StepPoint& sp_;
0104 };
0105
0106
0107
0108
0109
0110
0111
0112 Array<GeantStepPointView::Length, 3> GeantStepPointView::pos() const
0113 {
0114 return make_quantity_array<Length>(to_array(sp_.GetPosition()));
0115 }
0116
0117
0118
0119
0120
0121 Array<double, 3> GeantStepPointView::dir() const
0122 {
0123 return to_array(sp_.GetMomentumDirection());
0124 }
0125
0126
0127
0128
0129
0130 GeantStepPointView::Energy GeantStepPointView::energy() const
0131 {
0132 return Energy{sp_.GetKineticEnergy()};
0133 }
0134
0135
0136
0137
0138
0139 GeantStepPointView::Time GeantStepPointView::time() const
0140 {
0141 return Time{sp_.GetGlobalTime()};
0142 }
0143
0144
0145
0146
0147
0148
0149
0150 GeantStepPointView::Speed GeantStepPointView::speed() const
0151 {
0152 return Speed{sp_.GetBeta()};
0153 }
0154
0155
0156
0157
0158
0159 void GeantStepPointView::pos(Array<Length, 3> const& position)
0160 {
0161 sp_.SetPosition(to_g4vector(value_as<Length>(position)));
0162 }
0163
0164
0165
0166
0167
0168 void GeantStepPointView::dir(Array<double, 3> const& direction)
0169 {
0170 sp_.SetMomentumDirection(to_g4vector(direction));
0171 }
0172
0173
0174
0175
0176
0177 void GeantStepPointView::energy(Energy kinetic_energy)
0178 {
0179 CELER_EXPECT(kinetic_energy >= zero_quantity());
0180 sp_.SetKineticEnergy(kinetic_energy.value());
0181
0182 }
0183
0184
0185
0186
0187
0188 void GeantStepPointView::time(Time global_time)
0189 {
0190 sp_.SetGlobalTime(global_time.value());
0191 }
0192
0193
0194 }