Warning, file /include/Acts/Navigation/NavigationStateUpdaters.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Common.hpp"
0013 #include "Acts/Detector/Portal.hpp"
0014 #include "Acts/Navigation/NavigationDelegates.hpp"
0015 #include "Acts/Navigation/NavigationState.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Utilities/BinningType.hpp"
0018 #include "Acts/Utilities/Enumerate.hpp"
0019 #include "Acts/Utilities/GridAccessHelpers.hpp"
0020 #include "Acts/Utilities/IAxis.hpp"
0021 #include "Acts/Utilities/VectorHelpers.hpp"
0022
0023 #include <array>
0024 #include <memory>
0025
0026 namespace Acts::Experimental {
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 inline void updateCandidates(const GeometryContext& gctx,
0038 NavigationState& nState) {
0039 const auto& position = nState.position;
0040 const auto& direction = nState.direction;
0041
0042 NavigationState::SurfaceCandidates nextSurfaceCandidates;
0043
0044 for (NavigationState::SurfaceCandidate c : nState.surfaceCandidates) {
0045
0046 const Surface& sRep =
0047 c.surface != nullptr ? *c.surface : c.portal->surface();
0048
0049
0050
0051 auto sIntersection = sRep.intersect(gctx, position, direction,
0052 c.boundaryCheck, s_onSurfaceTolerance);
0053 for (auto& si : sIntersection.split()) {
0054 c.objectIntersection = si;
0055 if (c.objectIntersection &&
0056 c.objectIntersection.pathLength() > nState.overstepTolerance) {
0057 nextSurfaceCandidates.emplace_back(c);
0058 }
0059 }
0060 }
0061
0062 nState.surfaceCandidates = std::move(nextSurfaceCandidates);
0063 }
0064
0065
0066
0067
0068
0069
0070
0071
0072 template <typename navigation_type, typename object_type, typename filler_type>
0073 class SingleObjectNavigation : public navigation_type {
0074 public:
0075
0076
0077 SingleObjectNavigation(const object_type* so) : m_object(so) {
0078 if (so == nullptr) {
0079 throw std::invalid_argument("SingleObjectNavigation: object is nullptr");
0080 }
0081 }
0082
0083
0084
0085
0086
0087
0088
0089 void update([[maybe_unused]] const GeometryContext& gctx,
0090 NavigationState& nState) const {
0091 filler_type::fill(nState, m_object);
0092 }
0093
0094
0095 const object_type* object() const { return m_object; }
0096
0097 private:
0098
0099 const object_type* m_object = nullptr;
0100 };
0101
0102
0103
0104
0105
0106
0107
0108
0109 template <typename navigation_type, typename extractor_type,
0110 typename filler_type>
0111 class StaticAccessNavigation : public navigation_type {
0112 public:
0113
0114
0115
0116
0117
0118
0119 void update([[maybe_unused]] const GeometryContext& gctx,
0120 NavigationState& nState) const {
0121 auto extracted = extractor_type::extract(gctx, nState);
0122 filler_type::fill(nState, extracted);
0123 }
0124 };
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139 template <typename navigation_type, typename grid_t, typename extractor_type,
0140 typename filler_type>
0141 class IndexedGridNavigation : public navigation_type {
0142 public:
0143
0144 using grid_type = grid_t;
0145
0146
0147 extractor_type extractor;
0148
0149
0150 grid_type grid;
0151
0152
0153 std::array<BinningValue, grid_type::DIM> casts{};
0154
0155
0156 Transform3 transform = Transform3::Identity();
0157
0158
0159
0160
0161
0162 IndexedGridNavigation(grid_type&& igrid,
0163 const std::array<BinningValue, grid_type::DIM>& icasts,
0164 const Transform3& itr = Transform3::Identity())
0165 : grid(std::move(igrid)), casts(icasts), transform(itr) {}
0166
0167 IndexedGridNavigation() = delete;
0168
0169
0170
0171
0172
0173
0174
0175
0176 void update(const GeometryContext& gctx, NavigationState& nState) const {
0177
0178 const auto& entry =
0179 grid.atPosition(GridAccessHelpers::castPosition<grid_type>(
0180 transform * nState.position, casts));
0181 auto extracted = extractor.extract(gctx, nState, entry);
0182 filler_type::fill(nState, extracted);
0183
0184
0185 if constexpr (std::is_base_of_v<IInternalNavigation, navigation_type>) {
0186
0187 updateCandidates(gctx, nState);
0188 }
0189 }
0190 };
0191
0192
0193
0194
0195
0196
0197
0198
0199 template <typename navigation_type, typename... updators_t>
0200 class ChainedNavigation : public navigation_type {
0201 public:
0202
0203 std::tuple<updators_t...> updators;
0204
0205
0206
0207
0208
0209 ChainedNavigation(const std::tuple<updators_t...>&& upts)
0210 : updators(std::move(upts)) {}
0211
0212
0213
0214
0215
0216
0217 void update(const GeometryContext& gctx, NavigationState& nState) const {
0218
0219 std::apply(
0220 [&](auto&&... updator) { ((updator.update(gctx, nState)), ...); },
0221 updators);
0222 }
0223 };
0224
0225 }