File indexing completed on 2025-08-06 08:10:04
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Navigation/NavigationDelegates.hpp"
0013 #include "Acts/Navigation/NavigationState.hpp"
0014 #include "Acts/Navigation/NavigationStateFillers.hpp"
0015 #include "Acts/Navigation/NavigationStateUpdaters.hpp"
0016 #include "Acts/Utilities/Grid.hpp"
0017 #include "Acts/Utilities/detail/Axis.hpp"
0018
0019 #include <stdexcept>
0020
0021 namespace Acts::Experimental {
0022
0023 class DetectorVolume;
0024
0025
0026
0027
0028 struct EndOfWorldImpl : public INavigationDelegate {
0029
0030
0031
0032 inline void update(const GeometryContext& ,
0033 NavigationState& nState) const {
0034 nState.currentVolume = nullptr;
0035 }
0036 };
0037
0038
0039
0040
0041 struct SingleDetectorVolumeImpl : public INavigationDelegate {
0042 const DetectorVolume* dVolume = nullptr;
0043
0044
0045
0046 SingleDetectorVolumeImpl(const DetectorVolume* sVolume) noexcept(false)
0047 : dVolume(sVolume) {
0048 if (sVolume == nullptr) {
0049 throw std::invalid_argument(
0050 "DetectorVolumeUpdaters: nullptr provided, use EndOfWorld instead.");
0051 }
0052 }
0053
0054 SingleDetectorVolumeImpl() = delete;
0055
0056
0057
0058
0059
0060 inline void update(const GeometryContext& ,
0061 NavigationState& nState) const {
0062 nState.currentVolume = dVolume;
0063 }
0064 };
0065
0066 using SingleIndex = std::size_t;
0067
0068 using VariableBoundAxis =
0069 Acts::detail::Axis<Acts::detail::AxisType::Variable,
0070 Acts::detail::AxisBoundaryType::Bound>;
0071 using VariableBoundIndexGrid1 = Acts::Grid<SingleIndex, VariableBoundAxis>;
0072
0073
0074
0075
0076
0077
0078 struct DetectorVolumesCollection {
0079
0080 std::vector<const DetectorVolume*> dVolumes = {};
0081
0082
0083
0084
0085
0086
0087
0088 inline const DetectorVolume* extract(const GeometryContext& ,
0089 const NavigationState& ,
0090 const SingleIndex& index) const {
0091 return dVolumes[index];
0092 }
0093 };
0094
0095
0096
0097
0098
0099 struct BoundVolumesGrid1Impl : public INavigationDelegate {
0100 using IndexedUpdater =
0101 IndexedUpdaterImpl<VariableBoundIndexGrid1, DetectorVolumesCollection,
0102 DetectorVolumeFiller>;
0103
0104 IndexedUpdater indexedUpdater;
0105
0106
0107
0108
0109
0110
0111
0112 BoundVolumesGrid1Impl(
0113 const std::vector<ActsScalar>& gBoundaries, BinningValue bValue,
0114 const std::vector<const DetectorVolume*>& cVolumes,
0115 const Transform3& bTransform = Transform3::Identity()) noexcept(false)
0116 : indexedUpdater(IndexedUpdater(VariableBoundIndexGrid1(std::make_tuple(
0117 VariableBoundAxis(gBoundaries))),
0118 {bValue}, bTransform)) {
0119 indexedUpdater.extractor.dVolumes = cVolumes;
0120
0121 if (gBoundaries.size() != cVolumes.size() + 1u) {
0122 throw std::invalid_argument(
0123 "DetectorVolumeUpdaters: mismatching boundaries and volume numbers");
0124 }
0125
0126 for (std::size_t ib = 1u; ib < gBoundaries.size(); ++ib) {
0127 indexedUpdater.grid.at(ib) = ib - 1;
0128 }
0129 }
0130
0131 BoundVolumesGrid1Impl() = delete;
0132
0133
0134
0135
0136
0137 inline void update(const GeometryContext& gctx,
0138 NavigationState& nState) const {
0139 indexedUpdater.update(gctx, nState);
0140 }
0141 };
0142
0143 }