|
|
|||
File indexing completed on 2025-12-16 09:22:28
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include "Acts/Definitions/Algebra.hpp" 0012 #include "Acts/Definitions/Tolerance.hpp" 0013 #include "Acts/Geometry/GeometryContext.hpp" 0014 #include "Acts/Geometry/Layer.hpp" 0015 #include "Acts/Geometry/Portal.hpp" 0016 #include "Acts/Propagator/NavigationTarget.hpp" 0017 #include "Acts/Surfaces/BoundaryTolerance.hpp" 0018 0019 #include <span> 0020 #include <vector> 0021 0022 namespace Acts { 0023 0024 class Surface; 0025 0026 /// The NavigationStream is a container for the navigation candidates that 0027 /// are currentlu processed in a given context. The context could be local to a 0028 /// volume, or global to an entire track following. 0029 /// 0030 /// The current candidates are stored in a vector of candidates, where an index 0031 /// is used to indicate the current active candidate. 0032 class NavigationStream { 0033 public: 0034 /// The query point for the navigation stream 0035 /// 0036 /// This holds the position and direction from which the navigation stream 0037 /// should either be initialized or updated. 0038 struct QueryPoint { 0039 /// The position of the query point 0040 Vector3 position = Vector3::Zero(); 0041 /// The direction of the query point 0042 Vector3 direction = Vector3::Zero(); 0043 }; 0044 0045 /// Switch to next next candidate 0046 /// 0047 /// @return true if a next candidate is available 0048 bool switchToNextCandidate() { 0049 if (m_currentIndex < m_candidates.size()) { 0050 ++m_currentIndex; 0051 return true; 0052 } 0053 return false; 0054 } 0055 0056 /// Const access the current candidate 0057 /// @return Const reference to current candidate 0058 const NavigationTarget& currentCandidate() const { 0059 return m_candidates.at(m_currentIndex); 0060 } 0061 0062 /// Current Index 0063 /// @return Index of the current candidate in the vector 0064 std::size_t currentIndex() const { return m_currentIndex; } 0065 0066 /// Non-const access the candidate vector 0067 /// @return Mutable reference to vector of navigation candidates 0068 std::vector<NavigationTarget>& candidates() { return m_candidates; } 0069 0070 /// Const access the candidate vector 0071 /// @return Const reference to vector of navigation candidates 0072 const std::vector<NavigationTarget>& candidates() const { 0073 return m_candidates; 0074 } 0075 0076 /// Non-const access the current candidate 0077 /// 0078 /// This will throw and out of bounds exception if the stream is not 0079 /// valid anymore. 0080 /// @return Mutable reference to current candidate 0081 NavigationTarget& currentCandidate() { 0082 return m_candidates.at(m_currentIndex); 0083 } 0084 0085 /// The number of active candidates 0086 /// @return Number of remaining candidates from current position onwards 0087 std::size_t remainingCandidates() const { 0088 return (m_candidates.size() - m_currentIndex); 0089 } 0090 0091 /// Fill one surface into the candidate vector 0092 /// 0093 /// @param surface the surface to be filled 0094 /// @param bTolerance the boundary tolerance used for the intersection 0095 void addSurfaceCandidate(const Surface& surface, 0096 const BoundaryTolerance& bTolerance); 0097 0098 /// Fill n surfaces into the candidate vector 0099 /// 0100 /// @param surfaces the surfaces that are filled in 0101 /// @param bTolerance the boundary tolerance used for the intersection 0102 void addSurfaceCandidates(std::span<const Surface*> surfaces, 0103 const BoundaryTolerance& bTolerance); 0104 0105 /// Fill one portal into the candidate vector 0106 /// 0107 /// @param portal the portals that are filled in 0108 void addPortalCandidate(const Portal& portal); 0109 0110 /// Initialize the stream from a query point 0111 /// 0112 /// @param gctx is the geometry context 0113 /// @param queryPoint holds current position, direction, etc. 0114 /// @param cTolerance is the candidate search tolerance 0115 /// @param onSurfaceTolerance is the tolerance for on-surface intersections 0116 /// 0117 /// This method will first de-duplicate the candidates on basis of the surface 0118 /// pointer to make sure that the multi-intersections are handled correctly. 0119 /// This will allow intializeStream() to be called even as a re-initialization 0120 /// and still work correctly with at one time valid candidates. 0121 /// 0122 /// @return true if the stream is active, false indicates that there are no valid candidates 0123 bool initialize(const GeometryContext& gctx, 0124 const NavigationStream::QueryPoint& queryPoint, 0125 const BoundaryTolerance& cTolerance, 0126 double onSurfaceTolerance = s_onSurfaceTolerance); 0127 0128 /// Convenience method to update a stream from a new query point, 0129 /// this could be called from navigation delegates that do not require 0130 /// a local state or from the navigator on the target stream 0131 /// 0132 /// @param gctx is the geometry context 0133 /// @param queryPoint holds current position, direction, etc. 0134 /// @param onSurfaceTolerance is the tolerance for on-surface intersections 0135 /// 0136 /// @return true if the stream is active, false indicate no valid candidates left 0137 bool update(const GeometryContext& gctx, 0138 const NavigationStream::QueryPoint& queryPoint, 0139 double onSurfaceTolerance = s_onSurfaceTolerance); 0140 0141 /// Reset the navigation stream by clearing all candidates and resetting the 0142 /// index. 0143 /// 0144 /// This clears the candidates vector and resets the current index to 0. 0145 void reset(); 0146 0147 private: 0148 /// The candidates of this navigation stream 0149 std::vector<NavigationTarget> m_candidates; 0150 0151 /// The currently active candidate 0152 std::size_t m_currentIndex = 0u; 0153 }; 0154 0155 class AppendOnlyNavigationStream { 0156 public: 0157 explicit AppendOnlyNavigationStream(NavigationStream& stream); 0158 void addSurfaceCandidate(const Surface& surface, 0159 const BoundaryTolerance& bTolerance); 0160 void addPortalCandidate(const Portal& portal); 0161 0162 private: 0163 NavigationStream* m_stream; 0164 }; 0165 0166 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|