Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Acts/Detector/Portal.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2022 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Direction.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Geometry/GeometryIdentifier.hpp"
0015 #include "Acts/Navigation/NavigationDelegates.hpp"
0016 #include "Acts/Navigation/NavigationState.hpp"
0017 #include "Acts/Surfaces/BoundaryCheck.hpp"
0018 #include "Acts/Surfaces/RegularSurface.hpp"
0019 #include "Acts/Surfaces/Surface.hpp"
0020 #include "Acts/Surfaces/SurfaceVisitorConcept.hpp"
0021 #include "Acts/Utilities/Concepts.hpp"
0022 
0023 #include <array>
0024 #include <map>
0025 #include <memory>
0026 #include <optional>
0027 #include <vector>
0028 
0029 namespace Acts {
0030 
0031 class ISurfaceMaterial;
0032 class Surface;
0033 
0034 namespace Experimental {
0035 class DetectorVolume;
0036 struct NavigationState;
0037 
0038 /// A portal description between the detector volumes
0039 ///
0040 /// It has a Surface representation for navigation and propagation
0041 /// and guides from one volume to the next.
0042 ///
0043 /// The surface can carry material to allow mapping onto
0044 /// portal positions if required.
0045 ///
0046 class Portal {
0047  public:
0048   /// Constructor from surface w/o portal links
0049   ///
0050   /// @param surface is the representing surface
0051   Portal(std::shared_ptr<RegularSurface> surface);
0052 
0053   /// The vector of attached volumes forward/backward, this is useful in the
0054   /// geometry building
0055   using AttachedDetectorVolumes =
0056       std::array<std::vector<std::shared_ptr<DetectorVolume>>, 2u>;
0057 
0058   /// Declare the DetectorVolume friend for portal setting
0059   friend class DetectorVolume;
0060 
0061   Portal() = delete;
0062 
0063   /// Const access to the surface representation
0064   const RegularSurface& surface() const;
0065 
0066   /// Non-const access to the surface reference
0067   RegularSurface& surface();
0068 
0069   /// @brief Visit all reachable surfaces of the detector
0070   ///
0071   /// @tparam visitor_t Type of the callable visitor
0072   ///
0073   /// @param visitor will be called with the represented surface
0074   template <ACTS_CONCEPT(SurfaceVisitor) visitor_t>
0075   void visitSurface(visitor_t&& visitor) const {
0076     visitor(m_surface.get());
0077   }
0078 
0079   /// @brief Visit all reachable surfaces of the detector - non-const
0080   ///
0081   /// @tparam visitor_t Type of the callable visitor
0082   ///
0083   /// @param visitor will be called with the represented surface
0084   template <ACTS_CONCEPT(MutableSurfaceVisitor) visitor_t>
0085   void visitMutableSurface(visitor_t&& visitor) {
0086     visitor(m_surface.get());
0087   }
0088 
0089   /// Update the current volume
0090   ///
0091   /// @param gctx is the Geometry context of this call
0092   /// @param nState [in,out] the navigation state for the volume to be updated
0093   ///
0094   void updateDetectorVolume(const GeometryContext& gctx,
0095                             NavigationState& nState) const noexcept(false);
0096 
0097   /// Set the geometry identifier (to the underlying surface)
0098   ///
0099   /// @param geometryId the geometry identifier to be assigned
0100   void assignGeometryId(const GeometryIdentifier& geometryId);
0101 
0102   /// Fuse with another portal, this one is kept
0103   ///
0104   /// @param aPortal is the first portal to fuse
0105   /// @param bPortal is the second portal to fuse
0106   ///
0107   /// @note this will combine the portal links from the both
0108   /// portals into a new one, it will throw an exception if the
0109   /// portals are not fusable
0110   ///
0111   /// @note if one portal carries material, it will be kept,
0112   /// however, if both portals carry material, an exception
0113   /// will be thrown and the portals are not fusable
0114   ///
0115   /// @note Both input portals become invalid, in that their update
0116   /// delegates and attached volumes are reset
0117   static std::shared_ptr<Portal> fuse(
0118       std::shared_ptr<Portal>& aPortal,
0119       std::shared_ptr<Portal>& bPortal) noexcept(false);
0120 
0121   /// Update the volume link
0122   ///
0123   /// @param dir the direction of the link
0124   /// @param portalNavigation is the navigation delegate
0125   /// @param attachedVolumes is the list of attached volumes for book keeping
0126   ///
0127   /// @note this overwrites the existing link
0128   void assignPortalNavigation(
0129       Direction dir, ExternalNavigationDelegate portalNavigation,
0130       std::vector<std::shared_ptr<DetectorVolume>> attachedVolumes);
0131 
0132   /// Update the volume link, w/o directive, i.e. it relies that there's only
0133   /// one remaining link to be set, throws an exception if that's not the case
0134   ///
0135   /// @param portalNavigation is the navigation delegate
0136   /// @param attachedVolumes is the list of attached volumes for book keeping
0137   ///
0138   /// @note this overwrites the existing link
0139   void assignPortalNavigation(ExternalNavigationDelegate portalNavigation,
0140                               std::vector<std::shared_ptr<DetectorVolume>>
0141                                   attachedVolumes) noexcept(false);
0142 
0143   // Access to the portal targets: opposite/along normal vector
0144   const std::array<ExternalNavigationDelegate, 2u>& portalNavigation() const;
0145 
0146   // Access to the attached volumes - non-const access
0147   AttachedDetectorVolumes& attachedDetectorVolumes();
0148 
0149  private:
0150   /// The surface representation of this portal
0151   std::shared_ptr<RegularSurface> m_surface;
0152 
0153   /// The portal targets along/opposite the normal vector
0154   std::array<ExternalNavigationDelegate, 2u> m_portalNavigation = {
0155       ExternalNavigationDelegate{}, ExternalNavigationDelegate{}};
0156 
0157   /// The portal attaches to the following volumes
0158   AttachedDetectorVolumes m_attachedVolumes;
0159 };
0160 
0161 }  // namespace Experimental
0162 }  // namespace Acts