diff --git a/Core/include/Acts/Detector/Portal.hpp b/Core/include/Acts/Detector/Portal.hpp deleted file mode 100644 index 4c4bc7fe8a45..000000000000 --- a/Core/include/Acts/Detector/Portal.hpp +++ /dev/null @@ -1,161 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2022 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/Direction.hpp" -#include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Geometry/GeometryIdentifier.hpp" -#include "Acts/Navigation/NavigationDelegates.hpp" -#include "Acts/Navigation/NavigationState.hpp" -#include "Acts/Surfaces/BoundaryTolerance.hpp" -#include "Acts/Surfaces/RegularSurface.hpp" -#include "Acts/Surfaces/Surface.hpp" -#include "Acts/Surfaces/SurfaceVisitorConcept.hpp" - -#include -#include -#include -#include -#include - -namespace Acts { - -class ISurfaceMaterial; -class Surface; - -namespace Experimental { -class DetectorVolume; -struct NavigationState; - -/// A portal description between the detector volumes -/// -/// It has a Surface representation for navigation and propagation -/// and guides from one volume to the next. -/// -/// The surface can carry material to allow mapping onto -/// portal positions if required. -/// -class Portal { - public: - /// Constructor from surface w/o portal links - /// - /// @param surface is the representing surface - Portal(std::shared_ptr surface); - - /// The vector of attached volumes forward/backward, this is useful in the - /// geometry building - using AttachedDetectorVolumes = - std::array>, 2u>; - - /// Declare the DetectorVolume friend for portal setting - friend class DetectorVolume; - - Portal() = delete; - - /// Const access to the surface representation - const RegularSurface& surface() const; - - /// Non-const access to the surface reference - RegularSurface& surface(); - - /// @brief Visit all reachable surfaces of the detector - /// - /// @tparam visitor_t Type of the callable visitor - /// - /// @param visitor will be called with the represented surface - template - void visitSurface(visitor_t&& visitor) const { - visitor(m_surface.get()); - } - - /// @brief Visit all reachable surfaces of the detector - non-const - /// - /// @tparam visitor_t Type of the callable visitor - /// - /// @param visitor will be called with the represented surface - template - void visitMutableSurface(visitor_t&& visitor) { - visitor(m_surface.get()); - } - - /// Update the current volume - /// - /// @param gctx is the Geometry context of this call - /// @param nState [in,out] the navigation state for the volume to be updated - /// - void updateDetectorVolume(const GeometryContext& gctx, - NavigationState& nState) const noexcept(false); - - /// Set the geometry identifier (to the underlying surface) - /// - /// @param geometryId the geometry identifier to be assigned - void assignGeometryId(const GeometryIdentifier& geometryId); - - /// Fuse with another portal, this one is kept - /// - /// @param aPortal is the first portal to fuse - /// @param bPortal is the second portal to fuse - /// - /// @note this will combine the portal links from the both - /// portals into a new one, it will throw an exception if the - /// portals are not fusable - /// - /// @note if one portal carries material, it will be kept, - /// however, if both portals carry material, an exception - /// will be thrown and the portals are not fusable - /// - /// @note Both input portals become invalid, in that their update - /// delegates and attached volumes are reset - static std::shared_ptr fuse( - std::shared_ptr& aPortal, - std::shared_ptr& bPortal) noexcept(false); - - /// Update the volume link - /// - /// @param dir the direction of the link - /// @param portalNavigation is the navigation delegate - /// @param attachedVolumes is the list of attached volumes for book keeping - /// - /// @note this overwrites the existing link - void assignPortalNavigation( - Direction dir, ExternalNavigationDelegate portalNavigation, - std::vector> attachedVolumes); - - /// Update the volume link, w/o directive, i.e. it relies that there's only - /// one remaining link to be set, throws an exception if that's not the case - /// - /// @param portalNavigation is the navigation delegate - /// @param attachedVolumes is the list of attached volumes for book keeping - /// - /// @note this overwrites the existing link - void assignPortalNavigation(ExternalNavigationDelegate portalNavigation, - std::vector> - attachedVolumes) noexcept(false); - - // Access to the portal targets: opposite/along normal vector - const std::array& portalNavigation() const; - - // Access to the attached volumes - non-const access - AttachedDetectorVolumes& attachedDetectorVolumes(); - - private: - /// The surface representation of this portal - std::shared_ptr m_surface; - - /// The portal targets along/opposite the normal vector - std::array m_portalNavigation = { - ExternalNavigationDelegate{}, ExternalNavigationDelegate{}}; - - /// The portal attaches to the following volumes - AttachedDetectorVolumes m_attachedVolumes; -}; - -} // namespace Experimental -} // namespace Acts diff --git a/Core/src/Geometry/CMakeLists.txt b/Core/src/Geometry/CMakeLists.txt index 082a4abcdab3..14cb7d853a66 100644 --- a/Core/src/Geometry/CMakeLists.txt +++ b/Core/src/Geometry/CMakeLists.txt @@ -35,7 +35,6 @@ target_sources( Volume.cpp VolumeBounds.cpp CylinderVolumeStack.cpp - Portal.cpp GridPortalLink.cpp GridPortalLinkMerging.cpp TrivialPortalLink.cpp diff --git a/Core/src/Geometry/Portal.cpp b/Core/src/Geometry/Portal.cpp deleted file mode 100644 index a8522420d4fb..000000000000 --- a/Core/src/Geometry/Portal.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2024 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include "Acts/Geometry/Portal.hpp" - -#include "Acts/Geometry/CompositePortalLink.hpp" -#include "Acts/Geometry/GridPortalLink.hpp" -#include "Acts/Geometry/TrivialPortalLink.hpp" -#include "Acts/Surfaces/CylinderSurface.hpp" -#include "Acts/Surfaces/DiscSurface.hpp" -#include "Acts/Surfaces/RegularSurface.hpp" -#include "Acts/Utilities/BinningType.hpp" - -#include -#include - -namespace Acts { - -Portal::Portal(std::shared_ptr surface) - : m_surface(std::move(surface)) { - throw_assert(m_surface, "Portal surface is nullptr"); -} - -const TrackingVolume* Portal::resolveVolume(const GeometryContext& gctx, - const Vector3& position, - const Vector3& direction) const { - const Vector3 normal = m_surface->normal(gctx, position); - Direction side = Direction::fromScalar(normal.dot(direction)); - - const std::unique_ptr& link = - side == Direction::AlongNormal ? m_alongNormal : m_oppositeNormal; - - return nullptr; - if (link == nullptr) { - // no link is attached in this direction => this is the end of the world as - // we know it. (i feel fine) - return nullptr; - } else { - // return link->resolveVolume(position); - } -} - -std::ostream& operator<<(std::ostream& os, const PortalLinkBase& link) { - link.toStream(os); - return os; -} - -void PortalLinkBase::checkMergePreconditions(const PortalLinkBase& a, - const PortalLinkBase& b, - BinningValue direction) { - const auto& surfaceA = a.surface(); - const auto& surfaceB = b.surface(); - - throw_assert(&surfaceA != &surfaceB, - "Cannot merge portals to the same surface"); - - throw_assert(surfaceA.type() == surfaceB.type(), - "Cannot merge portals of different surface types"); - - throw_assert(surfaceA.bounds().type() == surfaceB.bounds().type(), - "Cannot merge portals of different surface bounds"); - - if (const auto* cylA = dynamic_cast(&surfaceA); - cylA != nullptr) { - const auto* cylB = dynamic_cast(&surfaceB); - throw_assert(cylB != nullptr, - "Cannot merge CylinderSurface with " - "non-CylinderSurface"); - throw_assert( - direction == BinningValue::binZ || direction == BinningValue::binRPhi, - "Invalid binning direction: " + binningValueName(direction)); - } else if (const auto* discA = dynamic_cast(&surfaceA); - discA != nullptr) { - const auto* discB = dynamic_cast(&surfaceB); - throw_assert(discB != nullptr, - "Cannot merge DiscSurface with non-DiscSurface"); - throw_assert( - direction == BinningValue::binR || direction == BinningValue::binPhi, - "Invalid binning direction: " + binningValueName(direction)); - - } else { - throw std::logic_error{"Surface type is not supported"}; - } -} - -std::unique_ptr PortalLinkBase::merge( - const std::shared_ptr& a, - const std::shared_ptr& b, BinningValue direction, - const Logger& logger) { - ACTS_DEBUG("Merging two arbitrary portals"); - - ACTS_VERBOSE(" - a: " << *a); - ACTS_VERBOSE(" - b: " << *b); - - checkMergePreconditions(*a, *b, direction); - - // Three options: - // 1. Grid - // 2. Trivial - // 3. Composite - - // Grid Grid - // Grid Trivial - // Grid Composite - // Trivial Grid - // Trivial Trivial - // Trivial Composite - // Composite Grid - // Composite Trivial - // Composite Composite - - if (auto aGrid = std::dynamic_pointer_cast(a); aGrid) { - if (auto bGrid = std::dynamic_pointer_cast(b); bGrid) { - ACTS_VERBOSE("Merging two grid portals"); - return GridPortalLink::merge(aGrid, bGrid, direction, logger); - - } else if (auto bTrivial = std::dynamic_pointer_cast(b); - bTrivial) { - ACTS_WARNING("Merging a grid portal with a trivial portal"); - return GridPortalLink::merge(aGrid, bTrivial->makeGrid(direction), - direction, logger); - - } else if (auto bComposite = - std::dynamic_pointer_cast(b); - bComposite) { - ACTS_WARNING("Merging a grid portal with a composite portal"); - return std::make_unique(aGrid, bComposite, - direction); - - } else { - throw std::logic_error{"Portal type is not supported"}; - } - - } else if (auto aTrivial = std::dynamic_pointer_cast(a); - aTrivial) { - if (auto bGrid = std::dynamic_pointer_cast(b); bGrid) { - ACTS_WARNING("Merging a trivial portal with a grid portal"); - return GridPortalLink::merge(aTrivial->makeGrid(direction), bGrid, - direction, logger); - - } else if (auto bTrivial = - std::dynamic_pointer_cast(b); - bTrivial) { - ACTS_WARNING("Merging two trivial portals"); - return GridPortalLink::merge(aTrivial->makeGrid(direction), - bTrivial->makeGrid(direction), direction, - logger); - - } else if (auto bComposite = - std::dynamic_pointer_cast(b); - bComposite) { - ACTS_WARNING("Merging a trivial portal with a composite portal"); - return std::make_unique(aTrivial, bComposite, - direction); - - } else { - throw std::logic_error{"Portal type is not supported"}; - } - - } else if (auto aComposite = - std::dynamic_pointer_cast(a); - aComposite) { - if (auto bGrid = std::dynamic_pointer_cast(b); bGrid) { - ACTS_WARNING("Merging a composite portal with a grid portal"); - return std::make_unique(aComposite, bGrid, - direction); - - } else if (auto bTrivial = std::dynamic_pointer_cast(b); - bTrivial) { - ACTS_WARNING("Merging a composite portal with a trivial portal"); - return std::make_unique(aComposite, bTrivial, - direction); - - } else if (auto bComposite = - std::dynamic_pointer_cast(b); - bComposite) { - ACTS_WARNING("Merging two composite portals"); - return std::make_unique(aComposite, bComposite, - direction); - - } else { - throw std::logic_error{"Portal type is not supported"}; - } - - } else { - throw std::logic_error{"Portal type is not supported"}; - } -} - -} // namespace Acts diff --git a/Tests/UnitTests/Core/Detector/CMakeLists.txt b/Tests/UnitTests/Core/Detector/CMakeLists.txt index eff298adb849..5ad3c568db0c 100644 --- a/Tests/UnitTests/Core/Detector/CMakeLists.txt +++ b/Tests/UnitTests/Core/Detector/CMakeLists.txt @@ -21,7 +21,7 @@ add_unittest(ReferenceGenerators ReferenceGeneratorsTests.cpp) add_unittest(SupportSurfacesHelper SupportSurfacesHelperTests.cpp) add_unittest(ProtoDetector ProtoDetectorTests.cpp) add_unittest(ProtoBinning ProtoBinningTests.cpp) -add_unittest(DetectorPortal PortalTests.cpp) +add_unittest(Portal PortalTests.cpp) add_unittest(PortalGenerators PortalGeneratorsTests.cpp) add_unittest(VolumeStructureBuilder VolumeStructureBuilderTests.cpp) add_unittest(MultiWireStructureBuilder MultiWireStructureBuilderTests.cpp) diff --git a/Tests/UnitTests/Core/Geometry/CMakeLists.txt b/Tests/UnitTests/Core/Geometry/CMakeLists.txt index 1fa422bb0a6f..3b058a882b4f 100644 --- a/Tests/UnitTests/Core/Geometry/CMakeLists.txt +++ b/Tests/UnitTests/Core/Geometry/CMakeLists.txt @@ -33,4 +33,3 @@ add_unittest(VolumeBounds VolumeBoundsTests.cpp) add_unittest(Volume VolumeTests.cpp) add_unittest(CylinderVolumeStack CylinderVolumeStackTests.cpp) add_unittest(PortalLink PortalLinkTests.cpp) -add_unittest(Portal PortalTests.cpp) diff --git a/Tests/UnitTests/Core/Geometry/PortalTests.cpp b/Tests/UnitTests/Core/Geometry/PortalTests.cpp deleted file mode 100644 index 341cb1e21f3f..000000000000 --- a/Tests/UnitTests/Core/Geometry/PortalTests.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2024 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include -#include -#include -#include - -#include "Acts/Definitions/Units.hpp" -#include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Geometry/Portal.hpp" - -using namespace Acts::UnitLiterals; - -namespace Acts::Test { - -auto logger = Acts::getDefaultLogger("UnitTests", Acts::Logging::VERBOSE); - -struct Fixture { - Logging::Level m_level; - Fixture() { - m_level = Acts::Logging::getFailureThreshold(); - Acts::Logging::setFailureThreshold(Acts::Logging::FATAL); - } - - ~Fixture() { Acts::Logging::setFailureThreshold(m_level); } -}; - -GeometryContext gctx; - -BOOST_FIXTURE_TEST_SUITE(Geometry, Fixture) - -BOOST_AUTO_TEST_SUITE(Portals) - -BOOST_AUTO_TEST_CASE(ConstructionFromVolume) { - // - Cylinder -} - -BOOST_AUTO_TEST_SUITE_END() // Portals - -BOOST_AUTO_TEST_SUITE_END() // Geometry - -} // namespace Acts::Test