|
||||
File indexing completed on 2025-01-18 09:10:53
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/Utilities/AxisDefinitions.hpp" 0014 #include "Acts/Utilities/Logger.hpp" 0015 #include "Acts/Utilities/Result.hpp" 0016 0017 #include <memory> 0018 0019 namespace Acts { 0020 0021 class RegularSurface; 0022 class TrackingVolume; 0023 class GeometryContext; 0024 0025 /// PortalLinkBase is the abstract base class for all portal links. 0026 /// A portal link is a mapping between a surface and a point on the surface and 0027 /// a destination tracking volum. 0028 /// The derived classes implement different ways to resolve a volume 0029 class PortalLinkBase { 0030 protected: 0031 /// Constructor from a surface. This constructor is only 0032 /// called from derived classes 0033 /// @param surface The surface 0034 explicit PortalLinkBase(std::shared_ptr<RegularSurface> surface) 0035 : m_surface(std::move(surface)) { 0036 if (!m_surface) { 0037 throw std::invalid_argument("Surface pointer must not be null"); 0038 } 0039 } 0040 0041 public: 0042 /// Virtual destructor in case the object is held as a derived 0043 virtual ~PortalLinkBase() = default; 0044 0045 /// Resolve a volume given a global position. Depending on the derived class, 0046 /// the global position might be converted to a local position before lookup. 0047 /// @param gctx The geometry context 0048 /// @param position The global position 0049 /// @param tolerance The tolerance for the lookup 0050 /// 0051 /// @return The tracking volume or null if no connection was found 0052 virtual Result<const TrackingVolume*> resolveVolume( 0053 const GeometryContext& gctx, const Vector3& position, 0054 double tolerance = s_onSurfaceTolerance) const = 0; 0055 0056 /// Resolve a volume given a local position. The local position is assumed to 0057 /// be on surface. 0058 /// @param gctx The geometry context 0059 /// @param position The local position 0060 /// @param tolerance The tolerance for the lookup 0061 /// 0062 /// @return The tracking volume or null if no connection was found 0063 virtual Result<const TrackingVolume*> resolveVolume( 0064 const GeometryContext& gctx, const Vector2& position, 0065 double tolerance = s_onSurfaceTolerance) const = 0; 0066 0067 //// Merge two portal link into a single one. The merge can resolve 0068 /// combinations of difference derived classes, and will try to flatten and 0069 /// deep merge given links if possible. 0070 /// @param a The first portal link 0071 /// @param b The second portal link 0072 /// @param direction The binning direction in which to merge. Valid values are 0073 /// depend on the surface types associated with the links. 0074 /// @param logger The logger to use for messages 0075 /// @return The merged portal link 0076 static std::unique_ptr<PortalLinkBase> merge( 0077 std::unique_ptr<PortalLinkBase> a, std::unique_ptr<PortalLinkBase> b, 0078 AxisDirection direction, const Logger& logger = getDummyLogger()); 0079 0080 /// Stream output function 0081 /// @param os The output stream 0082 virtual void toStream(std::ostream& os) const = 0; 0083 0084 /// Stream output operator 0085 /// @param os The output stream 0086 /// @param link The portal link 0087 friend std::ostream& operator<<(std::ostream& os, 0088 const PortalLinkBase& link) { 0089 link.toStream(os); 0090 return os; 0091 } 0092 0093 /// Getter for the associated surface 0094 /// @return The surface 0095 const RegularSurface& surface() const { return *m_surface; } 0096 0097 /// Setter for the surface 0098 /// @param surface The surface 0099 void setSurface(std::shared_ptr<RegularSurface> surface) { 0100 m_surface = std::move(surface); 0101 } 0102 0103 /// Getter for the underlying shared pointer 0104 /// @return The shared pointer to the surface 0105 const std::shared_ptr<RegularSurface>& surfacePtr() const { 0106 return m_surface; 0107 } 0108 0109 protected: 0110 /// Helper function to check a number of preconditions before merging is 0111 /// executed. 0112 static void checkMergePreconditions(const PortalLinkBase& a, 0113 const PortalLinkBase& b, 0114 AxisDirection direction); 0115 0116 std::shared_ptr<RegularSurface> m_surface; 0117 }; 0118 0119 } // 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 |