From fa7f7f0c0ce56628d4dd8834023eb966ef7fd407 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Mon, 30 Sep 2024 16:17:14 +0200 Subject: [PATCH 1/5] refactor(geo): Teach ProtoLayer to respect local coordinate system --- Core/include/Acts/Geometry/ProtoLayer.hpp | 19 +- Core/src/Geometry/ProtoLayer.cpp | 20 +- .../Core/Geometry/ProtoLayerTests.cpp | 189 +++++++++++++++--- 3 files changed, 189 insertions(+), 39 deletions(-) diff --git a/Core/include/Acts/Geometry/ProtoLayer.hpp b/Core/include/Acts/Geometry/ProtoLayer.hpp index d12e674918d..bff858b6461 100644 --- a/Core/include/Acts/Geometry/ProtoLayer.hpp +++ b/Core/include/Acts/Geometry/ProtoLayer.hpp @@ -33,6 +33,9 @@ struct ProtoLayer { /// The envelope parameters ExtentEnvelope envelope = ExtentEnvelope::Zero(); + /// The local transform + Transform3 transform = Transform3::Identity(); + /// Constructor /// /// Loops over a provided vector of surface and calculates the various @@ -41,8 +44,10 @@ struct ProtoLayer { /// /// @param gctx The current geometry context object, e.g. alignment /// @param surfaces The vector of surfaces to consider + /// @param transform The local transform to evaluate the sizing in ProtoLayer(const GeometryContext& gctx, - const std::vector& surfaces); + const std::vector& surfaces, + const Transform3& transform = Transform3::Identity()); /// Constructor /// @@ -52,8 +57,10 @@ struct ProtoLayer { /// /// @param gctx The current geometry context object, e.g. alignment /// @param surfaces The vector of surfaces to consider + /// @param transform The local transform to evaluate the sizing in ProtoLayer(const GeometryContext& gctx, - const std::vector>& surfaces); + const std::vector>& surfaces, + const Transform3& transform = Transform3::Identity()); ProtoLayer() = default; @@ -81,6 +88,14 @@ struct ProtoLayer { /// @param sl the input ostream std::ostream& toStream(std::ostream& sl) const; + /// Output stream operator + /// @param sl the input ostream + /// @param pl the ProtoLayer to be printed + /// @return the output ostream + friend std::ostream& operator<<(std::ostream& sl, const ProtoLayer& pl) { + return pl.toStream(sl); + } + /// Give access to the surfaces used/assigned to the ProtoLayer const std::vector& surfaces() const; diff --git a/Core/src/Geometry/ProtoLayer.cpp b/Core/src/Geometry/ProtoLayer.cpp index 659b34b1168..3a3714de5e3 100644 --- a/Core/src/Geometry/ProtoLayer.cpp +++ b/Core/src/Geometry/ProtoLayer.cpp @@ -13,26 +13,23 @@ #include "Acts/Surfaces/RegularSurface.hpp" #include "Acts/Utilities/Helpers.hpp" -#include -#include -#include -#include - using Acts::VectorHelpers::perp; using Acts::VectorHelpers::phi; namespace Acts { ProtoLayer::ProtoLayer(const GeometryContext& gctx, - const std::vector& surfaces) - : m_surfaces(surfaces) { + const std::vector& surfaces, + const Transform3& transform) + : transform(transform), m_surfaces(surfaces) { measure(gctx, surfaces); } ProtoLayer::ProtoLayer( const GeometryContext& gctx, - const std::vector>& surfaces) - : m_surfaces(unpack_shared_vector(surfaces)) { + const std::vector>& surfaces, + const Transform3& transform) + : transform(transform), m_surfaces(unpack_shared_vector(surfaces)) { measure(gctx, m_surfaces); } @@ -80,13 +77,12 @@ void ProtoLayer::measure(const GeometryContext& gctx, Vector3 sfNormal = regSurface->normal(gctx, sf->center(gctx)); std::vector deltaT = {-0.5 * thickness, 0.5 * thickness}; for (const auto& dT : deltaT) { - Transform3 dtransform = Transform3::Identity(); - dtransform.pretranslate(dT * sfNormal); + Transform3 dtransform = transform * Translation3{dT * sfNormal}; extent.extend(sfPolyhedron.extent(dtransform)); } continue; } - extent.extend(sfPolyhedron.extent()); + extent.extend(sfPolyhedron.extent(transform)); } } diff --git a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp index cbace6a6559..54d443420e2 100644 --- a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp @@ -9,15 +9,19 @@ #include #include "Acts/Definitions/Algebra.hpp" +#include "Acts/Definitions/Units.hpp" +#include "Acts/Geometry/DetectorElementBase.hpp" #include "Acts/Geometry/Extent.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/ProtoLayer.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/Surface.hpp" +#include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/RangeXD.hpp" +#include "Acts/Visualization/ObjVisualization3D.hpp" #include #include @@ -29,10 +33,21 @@ namespace Acts::Test::Layers { +GeometryContext tgContext = GeometryContext(); + +void draw(const ProtoLayer& layer, std::filesystem::path const& path) { + ObjVisualization3D obj; + for (auto const& surface : layer.surfaces()) { + surface->visualize(obj, tgContext); + } + + obj.write(path); +} + BOOST_AUTO_TEST_SUITE(Geometry) BOOST_AUTO_TEST_CASE(ProtoLayerTests) { - GeometryContext tgContext = GeometryContext(); + using enum BinningValue; // Create a proto layer with 4 surfaces on the x/y grid auto recBounds = std::make_shared(3., 6.); @@ -83,6 +98,8 @@ BOOST_AUTO_TEST_CASE(ProtoLayerTests) { auto pLayerSf = createProtoLayer(Transform3::Identity()); auto pLayerSfShared = createProtoLayer(Transform3::Identity()); + draw(pLayerSf, "ProtoLayerTests0.obj"); + BOOST_CHECK(pLayerSf.extent.range() == pLayerSfShared.extent.range()); BOOST_CHECK(pLayerSf.envelope == pLayerSfShared.envelope); @@ -105,20 +122,20 @@ BOOST_AUTO_TEST_CASE(ProtoLayerTests) { // Test 1 - identity transform auto protoLayer = createProtoLayer(Transform3::Identity()); - CHECK_CLOSE_ABS(protoLayer.range(BinningValue::binX), 12., 1e-8); - CHECK_CLOSE_ABS(protoLayer.medium(BinningValue::binX), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayer.min(BinningValue::binX), -6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.max(BinningValue::binX), 6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.range(BinningValue::binY), 6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.medium(BinningValue::binY), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayer.min(BinningValue::binY), -3., 1e-8); - CHECK_CLOSE_ABS(protoLayer.max(BinningValue::binY), 3., 1e-8); - CHECK_CLOSE_ABS(protoLayer.range(BinningValue::binZ), 12., 1e-8); - CHECK_CLOSE_ABS(protoLayer.medium(BinningValue::binZ), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayer.min(BinningValue::binZ), -6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.max(BinningValue::binZ), 6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.max(BinningValue::binR), std::hypot(3, 6), 1e-8); - CHECK_CLOSE_ABS(protoLayer.min(BinningValue::binR), 3., 1e-8); + CHECK_CLOSE_ABS(protoLayer.range(binX), 12., 1e-8); + CHECK_CLOSE_ABS(protoLayer.medium(binX), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayer.min(binX), -6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.max(binX), 6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.range(binY), 6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.medium(binY), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayer.min(binY), -3., 1e-8); + CHECK_CLOSE_ABS(protoLayer.max(binY), 3., 1e-8); + CHECK_CLOSE_ABS(protoLayer.range(binZ), 12., 1e-8); + CHECK_CLOSE_ABS(protoLayer.medium(binZ), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayer.min(binZ), -6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.max(binZ), 6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.max(binR), std::hypot(3, 6), 1e-8); + CHECK_CLOSE_ABS(protoLayer.min(binR), 3., 1e-8); // Test 1a @@ -127,16 +144,15 @@ BOOST_AUTO_TEST_CASE(ProtoLayerTests) { auto protoLayerRot = createProtoLayer(AngleAxis3(-0.345, Vector3::UnitZ()) * Transform3::Identity()); - BOOST_CHECK_NE(protoLayer.min(BinningValue::binX), -6.); - CHECK_CLOSE_ABS(protoLayerRot.medium(BinningValue::binX), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.medium(BinningValue::binY), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.range(BinningValue::binZ), 12., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.medium(BinningValue::binZ), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.min(BinningValue::binZ), -6., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.max(BinningValue::binZ), 6., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.min(BinningValue::binR), 3., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.max(BinningValue::binR), std::hypot(3, 6), - 1e-8); + BOOST_CHECK_NE(protoLayer.min(binX), -6.); + CHECK_CLOSE_ABS(protoLayerRot.medium(binX), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.medium(binY), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.range(binZ), 12., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.medium(binZ), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.min(binZ), -6., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.max(binZ), 6., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.min(binR), 3., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.max(binR), std::hypot(3, 6), 1e-8); std::stringstream sstream; protoLayerRot.toStream(sstream); @@ -155,6 +171,129 @@ Extent in space : BOOST_CHECK_EQUAL(sstream.str(), oString); } +BOOST_AUTO_TEST_CASE(OrientedLayer) { + using enum BinningValue; + using namespace Acts::UnitLiterals; + + Transform3 base = Transform3::Identity(); + + auto recBounds = std::make_shared(3_mm, 6_mm); + + std::vector> detectorElements; + + auto makeFan = [&](double yrot, double thickness = 0) { + detectorElements.clear(); + + std::size_t nSensors = 8; + double deltaPhi = 2 * M_PI / nSensors; + double r = 20_mm; + std::vector> surfaces; + for (std::size_t i = 0; i < nSensors; i++) { + // Create a fan of sensors + + Transform3 trf = base * AngleAxis3{yrot, Vector3::UnitY()} * + AngleAxis3{deltaPhi * i, Vector3::UnitZ()} * + Translation3(Vector3::UnitX() * r); + + auto& element = detectorElements.emplace_back( + std::make_unique(trf, recBounds, thickness)); + + surfaces.push_back(element->surface().getSharedPtr()); + } + return surfaces; + }; + + std::vector> surfaces = makeFan(0_degree); + + ProtoLayer protoLayer(tgContext, surfaces); + + BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); + BOOST_CHECK_CLOSE(protoLayer.range(binX), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binX), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binX), 23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.range(binY), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binY), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binY), 23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.range(binZ), 0_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binZ), 0_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binZ), 0_mm, 1e-8); + + std::cout << protoLayer << std::endl; + + surfaces = makeFan(90_degree); + + // Do NOT provide rotation matrix: sizing will be affected + protoLayer = {tgContext, surfaces}; + + std::cout << protoLayer << std::endl; + + BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); + CHECK_SMALL(protoLayer.range(binX), 1e-14); + CHECK_SMALL(protoLayer.min(binX), 1e-14); + CHECK_SMALL(protoLayer.max(binX), 1e-14); + BOOST_CHECK_CLOSE(protoLayer.range(binY), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binY), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binY), 23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.range(binZ), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binZ), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binZ), 23_mm, 1e-8); + + // Do NOT provide rotation matrix: sizing will be affected + protoLayer = {tgContext, surfaces, + Transform3{AngleAxis3{90_degree, Vector3::UnitY()}}}; + + std::cout << protoLayer << std::endl; + + BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); + BOOST_CHECK_CLOSE(protoLayer.range(binX), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binX), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binX), 23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.range(binY), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binY), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binY), 23_mm, 1e-8); + CHECK_SMALL(protoLayer.range(binZ), 1e-14); + CHECK_SMALL(protoLayer.min(binZ), 1e-14); + CHECK_SMALL(protoLayer.max(binZ), 1e-14); + + draw(protoLayer, "OrientedLayer.obj"); + + // @TODO: Test thickness + surfaces = makeFan(0_degree, 10_mm); + + protoLayer = {tgContext, surfaces}; + + BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); + BOOST_CHECK_CLOSE(protoLayer.range(binX), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binX), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binX), 23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.range(binY), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binY), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binY), 23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.range(binZ), 10_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binZ), -5_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binZ), 5_mm, 1e-8); + + std::cout << protoLayer << std::endl; + + surfaces = makeFan(90_degree, 10_mm); + + protoLayer = {tgContext, surfaces, + Transform3{AngleAxis3{90_degree, Vector3::UnitY()}}}; + + BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); + BOOST_CHECK_CLOSE(protoLayer.range(binX), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binX), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binX), 23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.range(binY), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binY), -23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binY), 23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.range(binZ), 10_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binZ), -5_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binZ), 5_mm, 1e-8); + + std::cout << protoLayer << std::endl; +} + BOOST_AUTO_TEST_SUITE_END() } // namespace Acts::Test::Layers From 44f8d6e1f677e5a284ad6b8b3b6c934dc305a342 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Tue, 1 Oct 2024 10:24:13 +0200 Subject: [PATCH 2/5] refactor(geo): Add ProtoLayer constructor from mutable shared surface pointers --- Core/include/Acts/Geometry/ProtoLayer.hpp | 13 +++++++++++++ Core/src/Geometry/ProtoLayer.cpp | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/Core/include/Acts/Geometry/ProtoLayer.hpp b/Core/include/Acts/Geometry/ProtoLayer.hpp index bff858b6461..fcf6d003f2a 100644 --- a/Core/include/Acts/Geometry/ProtoLayer.hpp +++ b/Core/include/Acts/Geometry/ProtoLayer.hpp @@ -62,6 +62,19 @@ struct ProtoLayer { const std::vector>& surfaces, const Transform3& transform = Transform3::Identity()); + /// Constructor + /// + /// Loops over a provided vector of surface and calculates the various + /// min/max values in one go. Also takes into account the thickness + /// of an associated DetectorElement, if it exists. + /// + /// @param gctx The current geometry context object, e.g. alignment + /// @param surfaces The vector of surfaces to consider + /// @param transform The local transform to evaluate the sizing in + ProtoLayer(const GeometryContext& gctx, + const std::vector>& surfaces, + const Transform3& transform = Transform3::Identity()); + ProtoLayer() = default; /// Get the parameters : min diff --git a/Core/src/Geometry/ProtoLayer.cpp b/Core/src/Geometry/ProtoLayer.cpp index 3a3714de5e3..375d83eca0e 100644 --- a/Core/src/Geometry/ProtoLayer.cpp +++ b/Core/src/Geometry/ProtoLayer.cpp @@ -33,6 +33,17 @@ ProtoLayer::ProtoLayer( measure(gctx, m_surfaces); } +ProtoLayer::ProtoLayer(const GeometryContext& gctx, + const std::vector>& surfaces, + const Transform3& transform) + : transform(transform) { + m_surfaces.reserve(surfaces.size()); + for (const auto& sf : surfaces) { + m_surfaces.push_back(sf.get()); + } + measure(gctx, m_surfaces); +} + double ProtoLayer::min(BinningValue bval, bool addenv) const { if (addenv) { return extent.min(bval) - envelope[bval][0u]; From 993654a647c57887f0668722b6dd2899bb91a0e2 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Tue, 1 Oct 2024 15:13:42 +0200 Subject: [PATCH 3/5] refactor(geo): fix protolayer test --- Core/src/Geometry/ProtoLayer.cpp | 3 +-- .../Core/Geometry/ProtoLayerTests.cpp | 26 +++++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Core/src/Geometry/ProtoLayer.cpp b/Core/src/Geometry/ProtoLayer.cpp index 375d83eca0e..b699f992b81 100644 --- a/Core/src/Geometry/ProtoLayer.cpp +++ b/Core/src/Geometry/ProtoLayer.cpp @@ -86,8 +86,7 @@ void ProtoLayer::measure(const GeometryContext& gctx, double thickness = element->thickness(); // We need a translation along and opposite half thickness Vector3 sfNormal = regSurface->normal(gctx, sf->center(gctx)); - std::vector deltaT = {-0.5 * thickness, 0.5 * thickness}; - for (const auto& dT : deltaT) { + for (const auto& dT : {-0.5 * thickness, 0.5 * thickness}) { Transform3 dtransform = transform * Translation3{dT * sfNormal}; extent.extend(sfPolyhedron.extent(dtransform)); } diff --git a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp index 54d443420e2..76094a8a662 100644 --- a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp @@ -208,19 +208,18 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { ProtoLayer protoLayer(tgContext, surfaces); BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); - BOOST_CHECK_CLOSE(protoLayer.range(binX), 46_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.min(binX), -23_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.max(binX), 23_mm, 1e-8); - BOOST_CHECK_CLOSE(protoLayer.range(binY), 46_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.min(binY), -23_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.max(binY), 23_mm, 1e-8); - BOOST_CHECK_CLOSE(protoLayer.range(binZ), 0_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.min(binZ), 0_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.max(binZ), 0_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binR), 17_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.max(binR), 23.769728648_mm, 1e-8); std::cout << protoLayer << std::endl; - surfaces = makeFan(90_degree); + surfaces = makeFan(45_degree); // Do NOT provide rotation matrix: sizing will be affected protoLayer = {tgContext, surfaces}; @@ -228,19 +227,15 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { std::cout << protoLayer << std::endl; BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); - CHECK_SMALL(protoLayer.range(binX), 1e-14); - CHECK_SMALL(protoLayer.min(binX), 1e-14); - CHECK_SMALL(protoLayer.max(binX), 1e-14); - BOOST_CHECK_CLOSE(protoLayer.range(binY), 46_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binX), -16.26345596_mm, 1e-4); + BOOST_CHECK_CLOSE(protoLayer.max(binX), 16.26345596_mm, 1e-4); BOOST_CHECK_CLOSE(protoLayer.min(binY), -23_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.max(binY), 23_mm, 1e-8); - BOOST_CHECK_CLOSE(protoLayer.range(binZ), 46_mm, 1e-8); - BOOST_CHECK_CLOSE(protoLayer.min(binZ), -23_mm, 1e-8); - BOOST_CHECK_CLOSE(protoLayer.max(binZ), 23_mm, 1e-8); + BOOST_CHECK_CLOSE(protoLayer.min(binZ), -16.26345596_mm, 1e-4); + BOOST_CHECK_CLOSE(protoLayer.max(binZ), 16.26345596_mm, 1e-4); - // Do NOT provide rotation matrix: sizing will be affected protoLayer = {tgContext, surfaces, - Transform3{AngleAxis3{90_degree, Vector3::UnitY()}}}; + Transform3{AngleAxis3{45_degree, Vector3::UnitY()}}.inverse()}; std::cout << protoLayer << std::endl; @@ -257,7 +252,6 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { draw(protoLayer, "OrientedLayer.obj"); - // @TODO: Test thickness surfaces = makeFan(0_degree, 10_mm); protoLayer = {tgContext, surfaces}; @@ -275,10 +269,10 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { std::cout << protoLayer << std::endl; - surfaces = makeFan(90_degree, 10_mm); + surfaces = makeFan(45_degree, 10_mm); protoLayer = {tgContext, surfaces, - Transform3{AngleAxis3{90_degree, Vector3::UnitY()}}}; + Transform3{AngleAxis3{45_degree, Vector3::UnitY()}}.inverse()}; BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); BOOST_CHECK_CLOSE(protoLayer.range(binX), 46_mm, 1e-8); From 31532fcc4e5e7bd1b631f5af041afa093537c767 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Mon, 7 Oct 2024 09:43:30 +0200 Subject: [PATCH 4/5] cleanup test --- .../Core/Geometry/ProtoLayerTests.cpp | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp index 76094a8a662..efde97d9b41 100644 --- a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp @@ -21,29 +21,17 @@ #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/RangeXD.hpp" -#include "Acts/Visualization/ObjVisualization3D.hpp" -#include #include #include #include #include -#include #include namespace Acts::Test::Layers { GeometryContext tgContext = GeometryContext(); -void draw(const ProtoLayer& layer, std::filesystem::path const& path) { - ObjVisualization3D obj; - for (auto const& surface : layer.surfaces()) { - surface->visualize(obj, tgContext); - } - - obj.write(path); -} - BOOST_AUTO_TEST_SUITE(Geometry) BOOST_AUTO_TEST_CASE(ProtoLayerTests) { @@ -98,8 +86,6 @@ BOOST_AUTO_TEST_CASE(ProtoLayerTests) { auto pLayerSf = createProtoLayer(Transform3::Identity()); auto pLayerSfShared = createProtoLayer(Transform3::Identity()); - draw(pLayerSf, "ProtoLayerTests0.obj"); - BOOST_CHECK(pLayerSf.extent.range() == pLayerSfShared.extent.range()); BOOST_CHECK(pLayerSf.envelope == pLayerSfShared.envelope); @@ -217,15 +203,11 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { BOOST_CHECK_CLOSE(protoLayer.min(binR), 17_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.max(binR), 23.769728648_mm, 1e-8); - std::cout << protoLayer << std::endl; - surfaces = makeFan(45_degree); // Do NOT provide rotation matrix: sizing will be affected protoLayer = {tgContext, surfaces}; - std::cout << protoLayer << std::endl; - BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); BOOST_CHECK_CLOSE(protoLayer.min(binX), -16.26345596_mm, 1e-4); BOOST_CHECK_CLOSE(protoLayer.max(binX), 16.26345596_mm, 1e-4); @@ -237,8 +219,6 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { protoLayer = {tgContext, surfaces, Transform3{AngleAxis3{45_degree, Vector3::UnitY()}}.inverse()}; - std::cout << protoLayer << std::endl; - BOOST_CHECK_EQUAL(protoLayer.surfaces().size(), 8); BOOST_CHECK_CLOSE(protoLayer.range(binX), 46_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.min(binX), -23_mm, 1e-8); @@ -250,8 +230,6 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { CHECK_SMALL(protoLayer.min(binZ), 1e-14); CHECK_SMALL(protoLayer.max(binZ), 1e-14); - draw(protoLayer, "OrientedLayer.obj"); - surfaces = makeFan(0_degree, 10_mm); protoLayer = {tgContext, surfaces}; @@ -267,8 +245,6 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { BOOST_CHECK_CLOSE(protoLayer.min(binZ), -5_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.max(binZ), 5_mm, 1e-8); - std::cout << protoLayer << std::endl; - surfaces = makeFan(45_degree, 10_mm); protoLayer = {tgContext, surfaces, @@ -284,8 +260,6 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { BOOST_CHECK_CLOSE(protoLayer.range(binZ), 10_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.min(binZ), -5_mm, 1e-8); BOOST_CHECK_CLOSE(protoLayer.max(binZ), 5_mm, 1e-8); - - std::cout << protoLayer << std::endl; } BOOST_AUTO_TEST_SUITE_END() From dd4d544def5bcb3678572e3c8c547b06996af63c Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Mon, 7 Oct 2024 10:02:29 +0200 Subject: [PATCH 5/5] gcc fix --- Core/include/Acts/Geometry/ProtoLayer.hpp | 12 ++++++------ Core/src/Geometry/ProtoLayer.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Core/include/Acts/Geometry/ProtoLayer.hpp b/Core/include/Acts/Geometry/ProtoLayer.hpp index fcf6d003f2a..1e5d95dc025 100644 --- a/Core/include/Acts/Geometry/ProtoLayer.hpp +++ b/Core/include/Acts/Geometry/ProtoLayer.hpp @@ -44,10 +44,10 @@ struct ProtoLayer { /// /// @param gctx The current geometry context object, e.g. alignment /// @param surfaces The vector of surfaces to consider - /// @param transform The local transform to evaluate the sizing in + /// @param transformIn The local transform to evaluate the sizing in ProtoLayer(const GeometryContext& gctx, const std::vector& surfaces, - const Transform3& transform = Transform3::Identity()); + const Transform3& transformIn = Transform3::Identity()); /// Constructor /// @@ -57,10 +57,10 @@ struct ProtoLayer { /// /// @param gctx The current geometry context object, e.g. alignment /// @param surfaces The vector of surfaces to consider - /// @param transform The local transform to evaluate the sizing in + /// @param transformIn The local transform to evaluate the sizing in ProtoLayer(const GeometryContext& gctx, const std::vector>& surfaces, - const Transform3& transform = Transform3::Identity()); + const Transform3& transformIn = Transform3::Identity()); /// Constructor /// @@ -70,10 +70,10 @@ struct ProtoLayer { /// /// @param gctx The current geometry context object, e.g. alignment /// @param surfaces The vector of surfaces to consider - /// @param transform The local transform to evaluate the sizing in + /// @param transformIn The local transform to evaluate the sizing in ProtoLayer(const GeometryContext& gctx, const std::vector>& surfaces, - const Transform3& transform = Transform3::Identity()); + const Transform3& transformIn = Transform3::Identity()); ProtoLayer() = default; diff --git a/Core/src/Geometry/ProtoLayer.cpp b/Core/src/Geometry/ProtoLayer.cpp index b699f992b81..c8f190d4293 100644 --- a/Core/src/Geometry/ProtoLayer.cpp +++ b/Core/src/Geometry/ProtoLayer.cpp @@ -20,23 +20,23 @@ namespace Acts { ProtoLayer::ProtoLayer(const GeometryContext& gctx, const std::vector& surfaces, - const Transform3& transform) - : transform(transform), m_surfaces(surfaces) { + const Transform3& transformIn) + : transform(transformIn), m_surfaces(surfaces) { measure(gctx, surfaces); } ProtoLayer::ProtoLayer( const GeometryContext& gctx, const std::vector>& surfaces, - const Transform3& transform) - : transform(transform), m_surfaces(unpack_shared_vector(surfaces)) { + const Transform3& transformIn) + : transform(transformIn), m_surfaces(unpack_shared_vector(surfaces)) { measure(gctx, m_surfaces); } ProtoLayer::ProtoLayer(const GeometryContext& gctx, const std::vector>& surfaces, - const Transform3& transform) - : transform(transform) { + const Transform3& transformIn) + : transform(transformIn) { m_surfaces.reserve(surfaces.size()); for (const auto& sf : surfaces) { m_surfaces.push_back(sf.get());