Warning, file /include/Acts/Navigation/MultiLayerNavigation.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/Detector/DetectorVolume.hpp"
0012 #include "Acts/Navigation/NavigationDelegates.hpp"
0013 #include "Acts/Navigation/NavigationStateFillers.hpp"
0014 #include "Acts/Navigation/NavigationStateUpdaters.hpp"
0015 #include "Acts/Utilities/VectorHelpers.hpp"
0016
0017 #include <array>
0018 #include <memory>
0019
0020 namespace Acts::Experimental {
0021
0022 template <typename grid_t, typename path_generator>
0023 class MultiLayerNavigation : public IInternalNavigation {
0024 public:
0025
0026 using grid_type = grid_t;
0027
0028
0029 grid_type grid;
0030
0031
0032 path_generator pgenerator;
0033
0034
0035 std::array<BinningValue, grid_type::DIM> casts{};
0036
0037
0038 Transform3 transform = Transform3::Identity();
0039
0040
0041
0042
0043
0044 MultiLayerNavigation(grid_type igrid,
0045 const std::array<BinningValue, grid_type::DIM>& icasts,
0046 const Transform3& itr = Transform3::Identity())
0047 : grid(std::move(igrid)), casts(icasts), transform(itr) {}
0048
0049 MultiLayerNavigation() = delete;
0050
0051
0052
0053
0054 void update(const GeometryContext& gctx, NavigationState& nState) const {
0055
0056 auto lposition = transform * nState.position;
0057 auto ldirection = transform.linear() * nState.direction;
0058
0059 auto step = std::sqrt(std::pow(grid.binWidth()[0], 2) +
0060 std::pow(grid.binWidth()[1], 2));
0061 auto path = pgenerator(lposition, ldirection, step, grid.numLocalBins()[1]);
0062
0063 std::vector<const Acts::Surface*> surfCandidates = {};
0064
0065 for (const auto& p : path) {
0066 const auto& entry = grid.atPosition(castPosition(p));
0067 const auto extracted =
0068 IndexedSurfacesExtractor::extract(gctx, nState, entry);
0069 surfCandidates.insert(surfCandidates.end(), extracted.begin(),
0070 extracted.end());
0071 }
0072
0073 resolveDuplicates(gctx, surfCandidates);
0074 SurfacesFiller::fill(nState, surfCandidates);
0075
0076 updateCandidates(gctx, nState);
0077 }
0078
0079
0080
0081
0082 std::array<ActsScalar, grid_type::DIM> castPosition(
0083 const Vector3& position) const {
0084 std::array<ActsScalar, grid_type::DIM> casted{};
0085 fillCasts(position, casted,
0086 std::make_integer_sequence<std::size_t, grid_type::DIM>{});
0087 return casted;
0088 }
0089
0090
0091
0092
0093
0094 void resolveDuplicates(const GeometryContext& gctx,
0095 std::vector<const Acts::Surface*>& surfaces) const {
0096
0097 std::sort(surfaces.begin(), surfaces.end(),
0098 [&gctx](const auto& surf1, const auto& surf2) {
0099 if (surf1->center(gctx).x() != surf2->center(gctx).x()) {
0100 return surf1->center(gctx).x() < surf2->center(gctx).x();
0101 }
0102 if (surf1->center(gctx).y() != surf2->center(gctx).y()) {
0103 return surf1->center(gctx).y() < surf2->center(gctx).y();
0104 }
0105 return surf1->center(gctx).z() < surf2->center(gctx).z();
0106 });
0107
0108
0109 surfaces.erase(std::unique(surfaces.begin(), surfaces.end()),
0110 surfaces.end());
0111 }
0112
0113 private:
0114
0115
0116
0117 template <typename Array, std::size_t... idx>
0118 void fillCasts(const Vector3& position, Array& a,
0119 std::index_sequence<idx...> ) const {
0120 ((a[idx] = VectorHelpers::cast(position, casts[idx])), ...);
0121 }
0122 };
0123
0124
0125
0126 struct PathGridSurfacesGenerator {
0127 std::vector<Vector3> operator()(Vector3 startPosition,
0128 const Vector3& direction, ActsScalar stepSize,
0129 std::size_t numberOfSteps) const {
0130 std::vector<Vector3> pathCoordinates = {};
0131 pathCoordinates.reserve(numberOfSteps);
0132
0133 Vector3 position = std::move(startPosition);
0134 Vector3 step = stepSize * direction;
0135
0136 for (std::size_t i = 0; i < numberOfSteps; i++) {
0137 pathCoordinates.push_back(position);
0138 position = position + step;
0139 }
0140
0141 return pathCoordinates;
0142 }
0143 };
0144
0145 }