File indexing completed on 2025-09-17 08:53:37
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010 #include <vector>
0011
0012 #include "corecel/Config.hh"
0013
0014 #include "corecel/cont/EnumArray.hh"
0015 #include "geocel/Types.hh"
0016 #include "celeritas/geo/GeoFwd.hh"
0017 #include "celeritas/user/StepInterface.hh"
0018
0019 class G4LogicalVolume;
0020 class G4ParticleDefinition;
0021
0022 namespace celeritas
0023 {
0024
0025 namespace inp
0026 {
0027 struct GeantSd;
0028 }
0029 namespace detail
0030 {
0031 class HitProcessor;
0032 }
0033
0034 class ParticleParams;
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 class GeantSd final : public StepInterface
0052 {
0053 public:
0054
0055
0056 using StepStateHostRef = HostRef<StepStateData>;
0057 using StepStateDeviceRef = DeviceRef<StepStateData>;
0058 using SPConstVecLV
0059 = std::shared_ptr<std::vector<G4LogicalVolume const*> const>;
0060 using HitProcessor = detail::HitProcessor;
0061 using SPProcessor = std::shared_ptr<HitProcessor>;
0062 using SPConstGeo = std::shared_ptr<GeoParams const>;
0063 using VecVolId = std::vector<VolumeId>;
0064 using VecParticle = std::vector<G4ParticleDefinition const*>;
0065 using StepPointBool = EnumArray<StepPoint, bool>;
0066 using Input = inp::GeantSd;
0067
0068
0069 public:
0070
0071 GeantSd(SPConstGeo geo,
0072 ParticleParams const& par,
0073 Input const& setup,
0074 StreamId::size_type num_streams);
0075
0076 CELER_DEFAULT_MOVE_DELETE_COPY(GeantSd);
0077
0078
0079 ~GeantSd();
0080
0081
0082 SPProcessor make_local_processor(StreamId sid);
0083
0084
0085 Filters filters() const final;
0086
0087
0088 StepSelection selection() const final { return selection_; }
0089
0090
0091 void process_steps(HostStepState) final;
0092
0093
0094 void process_steps(DeviceStepState) final;
0095
0096
0097
0098
0099 SPConstVecLV const& geant_vols() const { return geant_vols_; }
0100
0101
0102 VecVolId const& celer_vols() const { return celer_vols_; }
0103
0104
0105 VecParticle const& geant_particles() const { return particles_; }
0106
0107
0108 StepPointBool const& locate_touchable() const { return locate_touchable_; }
0109
0110 private:
0111 using VecLV = std::vector<G4LogicalVolume const*>;
0112
0113 bool nonzero_energy_deposition_{};
0114 VecVolId celer_vols_;
0115
0116
0117 SPConstGeo geo_;
0118 SPConstVecLV geant_vols_;
0119 VecParticle particles_;
0120 StepSelection selection_;
0121 StepPointBool locate_touchable_{};
0122
0123 std::vector<std::weak_ptr<HitProcessor>> processor_weakptrs_;
0124 std::vector<HitProcessor*> processors_;
0125
0126
0127 void setup_volumes(GeoParams const& geo, Input const& setup);
0128
0129 void setup_particles(ParticleParams const& par);
0130
0131
0132 HitProcessor& get_local_hit_processor(StreamId);
0133 };
0134
0135 #if !CELERITAS_USE_GEANT4
0136
0137 inline GeantSd::GeantSd(SPConstGeo,
0138 ParticleParams const&,
0139 Input const&,
0140 StreamId::size_type)
0141 {
0142 CELER_NOT_CONFIGURED("Geant4");
0143 }
0144
0145 inline GeantSd::~GeantSd() = default;
0146
0147 inline GeantSd::SPProcessor GeantSd::make_local_processor(StreamId)
0148 {
0149 CELER_ASSERT_UNREACHABLE();
0150 }
0151
0152 inline GeantSd::Filters GeantSd::filters() const
0153 {
0154 CELER_ASSERT_UNREACHABLE();
0155 }
0156
0157 inline void GeantSd::process_steps(HostStepState)
0158 {
0159 CELER_ASSERT_UNREACHABLE();
0160 }
0161
0162 inline void GeantSd::process_steps(DeviceStepState)
0163 {
0164 CELER_ASSERT_UNREACHABLE();
0165 }
0166
0167 #endif
0168
0169 }