File indexing completed on 2026-10-27 09:25:10
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <G4Step.hh>
0010
0011 #include "corecel/Assert.hh"
0012 #include "corecel/math/Quantity.hh"
0013 #include "celeritas/Types.hh"
0014 #include "celeritas/UnitTypes.hh"
0015
0016 #include "GeantStepPointView.hh"
0017
0018 namespace celeritas
0019 {
0020
0021
0022
0023
0024
0025
0026
0027 class GeantStepView
0028 {
0029 public:
0030
0031
0032 using Energy = units::ClhepEnergy;
0033 using Length = lengthunits::ClhepLength;
0034 using real_type = double;
0035
0036
0037 public:
0038
0039 explicit GeantStepView(G4Step& step) : s_(step) {}
0040
0041
0042
0043
0044
0045 inline Energy energy_deposition() const;
0046
0047
0048 inline Length step_length() const;
0049
0050
0051 inline GeantStepPointView pre_step() const;
0052
0053
0054 inline GeantStepPointView post_step() const;
0055
0056
0057 inline bool has_step_point(StepPoint sp) const;
0058
0059
0060 inline GeantStepPointView step_point(StepPoint sp) const;
0061
0062
0063
0064
0065
0066
0067 inline void energy_deposition(Energy edep);
0068
0069
0070 inline void step_length(Length length);
0071
0072
0073 void update_track();
0074
0075
0076 void delete_step_point(StepPoint sp);
0077
0078
0079
0080 private:
0081 G4Step& s_;
0082 };
0083
0084
0085
0086
0087
0088
0089
0090 auto GeantStepView::energy_deposition() const -> Energy
0091 {
0092 return Energy{s_.GetTotalEnergyDeposit()};
0093 }
0094
0095
0096
0097
0098
0099 GeantStepView::Length GeantStepView::step_length() const
0100 {
0101 return Length{s_.GetStepLength()};
0102 }
0103
0104
0105
0106
0107
0108 void GeantStepView::energy_deposition(Energy edep)
0109 {
0110 s_.SetTotalEnergyDeposit(edep.value());
0111 }
0112
0113
0114
0115
0116
0117 void GeantStepView::step_length(Length length)
0118 {
0119 s_.SetStepLength(length.value());
0120 if (s_.GetTrack())
0121 {
0122
0123 s_.GetTrack()->SetStepLength(s_.GetStepLength());
0124 }
0125 }
0126
0127
0128
0129
0130
0131 GeantStepPointView GeantStepView::pre_step() const
0132 {
0133 CELER_EXPECT(this->has_step_point(StepPoint::pre));
0134 return GeantStepPointView{*s_.GetPreStepPoint()};
0135 }
0136
0137
0138
0139
0140
0141 GeantStepPointView GeantStepView::post_step() const
0142 {
0143 CELER_EXPECT(this->has_step_point(StepPoint::post));
0144 return GeantStepPointView{*s_.GetPostStepPoint()};
0145 }
0146
0147
0148
0149
0150
0151 bool GeantStepView::has_step_point(StepPoint sp) const
0152 {
0153 CELER_EXPECT(sp != StepPoint::size_);
0154 return (sp == StepPoint::pre ? s_.GetPreStepPoint() : s_.GetPostStepPoint())
0155 != nullptr;
0156 }
0157
0158
0159
0160
0161
0162 GeantStepPointView GeantStepView::step_point(StepPoint sp) const
0163 {
0164 CELER_EXPECT(sp != StepPoint::size_);
0165 return sp == StepPoint::pre ? this->pre_step() : this->post_step();
0166 }
0167
0168
0169 }