From 8d8e74aa5cf485d5d9201a25084db3d830c48c15 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Wed, 21 Aug 2024 16:12:55 +0200 Subject: [PATCH] revert: Portal --- Core/include/Acts/Geometry/Portal.hpp | 89 -------- Core/src/Geometry/CMakeLists.txt | 1 - Core/src/Geometry/Portal.cpp | 195 ------------------ Tests/UnitTests/Core/Detector/CMakeLists.txt | 2 +- Tests/UnitTests/Core/Geometry/CMakeLists.txt | 1 - Tests/UnitTests/Core/Geometry/PortalTests.cpp | 48 ----- 6 files changed, 1 insertion(+), 335 deletions(-) delete mode 100644 Core/include/Acts/Geometry/Portal.hpp delete mode 100644 Core/src/Geometry/Portal.cpp delete mode 100644 Tests/UnitTests/Core/Geometry/PortalTests.cpp diff --git a/Core/include/Acts/Geometry/Portal.hpp b/Core/include/Acts/Geometry/Portal.hpp deleted file mode 100644 index 6c09a4bf8e47..000000000000 --- a/Core/include/Acts/Geometry/Portal.hpp +++ /dev/null @@ -1,89 +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/. - -#pragma once - -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Utilities/BinningType.hpp" -#include "Acts/Utilities/Logger.hpp" - -#include - -namespace Acts { - -class RegularSurface; -class GeometryContext; -class TrackingVolume; -class CylinderSurface; -class PlaneSurface; -class DiscSurface; - -class PortalLinkBase; - -class Portal { - public: - Portal(std::shared_ptr surface); - - static std::shared_ptr fuse(const std::shared_ptr& aPortal, - const std::shared_ptr& bPortal); - - static std::shared_ptr mergeAdjacent( - const std::shared_ptr& aPortal, - const std::shared_ptr& bPortal); - - const TrackingVolume* resolveVolume(const GeometryContext& gctx, - const Vector3& position, - const Vector3& direction) const; - - private: - // @TODO: Potentially short circuit the virtual call - // using VolumeResolver = Delegate; - - std::shared_ptr m_surface; - - std::unique_ptr m_alongNormal; - std::unique_ptr m_oppositeNormal; -}; - -template -concept PortalSurfaceConcept = - std::is_same_v || std::is_same_v || - std::is_same_v; - -class PortalLinkBase { - public: - PortalLinkBase(std::shared_ptr surface) - : m_surface(std::move(surface)) {} - - virtual ~PortalLinkBase() = default; - - // @TODO: Does this need boundary tolerance? - virtual const TrackingVolume* resolveVolume( - const GeometryContext& gctx, const Vector2& position) const = 0; - - static std::unique_ptr merge( - const std::shared_ptr& a, - const std::shared_ptr& b, BinningValue direction, - const Logger& logger = getDummyLogger()); - - virtual void toStream(std::ostream& os) const = 0; - - friend std::ostream& operator<<(std::ostream& os, const PortalLinkBase& link); - - const RegularSurface& surface() const { return *m_surface; } - - protected: - static void checkMergePreconditions(const PortalLinkBase& a, - const PortalLinkBase& b, - BinningValue direction); - - std::shared_ptr m_surface; -}; - -} // 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