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 "geocel/GeantGeoUtils.hh"
0013 #include "celeritas/Types.hh"
0014 #include "celeritas/Units.hh"
0015 #include "celeritas/geo/GeoFwd.hh"
0016 #include "celeritas/user/DetectorSteps.hh"
0017
0018 #include "TouchableUpdaterInterface.hh"
0019
0020 class G4Navigator;
0021 class G4LogicalVolume;
0022 class G4VPhysicalVolume;
0023 class G4NavigationHistory;
0024
0025 namespace celeritas
0026 {
0027
0028 namespace detail
0029 {
0030
0031
0032
0033
0034 class LevelTouchableUpdater final : public TouchableUpdaterInterface
0035 {
0036 public:
0037
0038
0039 using SpanVolInst = Span<VolumeInstanceId const>;
0040 using SPConstGeo = std::shared_ptr<GeoParams const>;
0041
0042
0043 public:
0044
0045 inline static SpanVolInst volume_instances(DetectorStepOutput const& out,
0046 size_type step_index,
0047 StepPoint step_point);
0048
0049
0050 explicit LevelTouchableUpdater(SPConstGeo);
0051
0052
0053 ~LevelTouchableUpdater() final;
0054
0055
0056 bool operator()(DetectorStepOutput const& out,
0057 size_type step_index,
0058 StepPoint step_point,
0059 GeantTouchableBase* touchable) final;
0060
0061
0062 bool operator()(SpanVolInst ids, GeantTouchableBase* touchable);
0063
0064 private:
0065
0066 SPConstGeo geo_;
0067
0068 std::vector<GeantPhysicalInstance> phys_inst_;
0069
0070 std::unique_ptr<G4NavigationHistory> nav_hist_;
0071 };
0072
0073
0074
0075
0076
0077 auto LevelTouchableUpdater::volume_instances(DetectorStepOutput const& out,
0078 size_type i,
0079 StepPoint sp) -> SpanVolInst
0080 {
0081 CELER_EXPECT(i < out.size());
0082 CELER_EXPECT(out.volume_instance_depth > 0);
0083 CELER_EXPECT(!out.points[sp].volume_instance_ids.empty());
0084 auto ids = make_span(out.points[sp].volume_instance_ids);
0085 auto const depth = out.volume_instance_depth;
0086 CELER_EXPECT(ids.size() >= (i + 1) * depth);
0087 return ids.subspan(i * depth, depth);
0088 }
0089
0090
0091 }
0092 }