diff --git a/Core/include/Acts/Surfaces/Surface.hpp b/Core/include/Acts/Surfaces/Surface.hpp index 3bfb6a57c39..adf0dba74e4 100644 --- a/Core/include/Acts/Surfaces/Surface.hpp +++ b/Core/include/Acts/Surfaces/Surface.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2020 CERN for the benefit of the Acts project +// Copyright (C) 2016-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 @@ -490,7 +490,7 @@ class Surface : public virtual GeometryObject, /// Transform3 definition that positions /// (translation, rotation) the surface in global space - Transform3 m_transform = Transform3::Identity(); + std::unique_ptr m_transform{}; /// Pointer to the a DetectorElementBase const DetectorElementBase* m_associatedDetElement{nullptr}; diff --git a/Core/src/Geometry/CylinderLayer.cpp b/Core/src/Geometry/CylinderLayer.cpp index 35002aac461..610147286cd 100644 --- a/Core/src/Geometry/CylinderLayer.cpp +++ b/Core/src/Geometry/CylinderLayer.cpp @@ -37,7 +37,7 @@ Acts::CylinderLayer::CylinderLayer( auto cVolumeBounds = std::make_shared( *CylinderSurface::m_bounds, thickness); // @todo rotate around x for the avePhi if you have a sector - m_representingVolume = std::make_unique(m_transform, cVolumeBounds); + m_representingVolume = std::make_unique(*m_transform, cVolumeBounds); // associate the layer to the surface CylinderSurface::associateLayer(*this); diff --git a/Core/src/Geometry/DiscLayer.cpp b/Core/src/Geometry/DiscLayer.cpp index ccb167f70a1..14f6f82ad68 100644 --- a/Core/src/Geometry/DiscLayer.cpp +++ b/Core/src/Geometry/DiscLayer.cpp @@ -39,7 +39,8 @@ Acts::DiscLayer::DiscLayer(const Transform3& transform, auto rVolumeBounds = std::make_shared(*rBounds, thickness); // @todo rotate around x for the avePhi if you have a sector - m_representingVolume = std::make_unique(m_transform, rVolumeBounds); + m_representingVolume = + std::make_unique(*m_transform, rVolumeBounds); } // associate the layer to the layer surface itself DiscSurface::associateLayer(*this); diff --git a/Core/src/Surfaces/PlaneSurface.cpp b/Core/src/Surfaces/PlaneSurface.cpp index d378694c67c..a43bd92efea 100644 --- a/Core/src/Surfaces/PlaneSurface.cpp +++ b/Core/src/Surfaces/PlaneSurface.cpp @@ -38,7 +38,8 @@ Acts::PlaneSurface::PlaneSurface(const GeometryContext& gctx, Acts::PlaneSurface::PlaneSurface(const Vector3& center, const Vector3& normal) : RegularSurface(), m_bounds(nullptr) { - m_transform = CurvilinearSurface(center, normal).transform(); + m_transform = std::make_unique( + CurvilinearSurface(center, normal).transform()); } Acts::PlaneSurface::PlaneSurface(std::shared_ptr pbounds, diff --git a/Core/src/Surfaces/Surface.cpp b/Core/src/Surfaces/Surface.cpp index f6e6c796815..f20294966e7 100644 --- a/Core/src/Surfaces/Surface.cpp +++ b/Core/src/Surfaces/Surface.cpp @@ -22,7 +22,7 @@ std::array "Cone", "Cylinder", "Disc", "Perigee", "Plane", "Straw", "Curvilinear"}; Acts::Surface::Surface(const Transform3& transform) - : GeometryObject(), m_transform(transform) {} + : GeometryObject(), m_transform(std::make_unique(transform)) {} Acts::Surface::Surface(const DetectorElementBase& detelement) : GeometryObject(), m_associatedDetElement(&detelement) {} @@ -30,13 +30,17 @@ Acts::Surface::Surface(const DetectorElementBase& detelement) Acts::Surface::Surface(const Surface& other) : GeometryObject(other), std::enable_shared_from_this(), - m_transform(other.m_transform), - m_surfaceMaterial(other.m_surfaceMaterial) {} + m_associatedDetElement(other.m_associatedDetElement), + m_surfaceMaterial(other.m_surfaceMaterial) { + if (other.m_transform) { + m_transform = std::make_unique(*other.m_transform); + } +} Acts::Surface::Surface(const GeometryContext& gctx, const Surface& other, const Transform3& shift) : GeometryObject(), - m_transform(shift * other.transform(gctx)), + m_transform(std::make_unique(shift * other.transform(gctx))), m_surfaceMaterial(other.m_surfaceMaterial) {} Acts::Surface::~Surface() = default; @@ -156,7 +160,11 @@ Acts::Surface& Acts::Surface::operator=(const Surface& other) { if (&other != this) { GeometryObject::operator=(other); // detector element, identifier & layer association are unique - m_transform = other.m_transform; + if (other.m_transform) { + m_transform = std::make_unique(*other.m_transform); + } else { + m_transform.reset(); + } m_associatedLayer = other.m_associatedLayer; m_surfaceMaterial = other.m_surfaceMaterial; m_associatedDetElement = other.m_associatedDetElement; @@ -182,7 +190,8 @@ bool Acts::Surface::operator==(const Surface& other) const { return false; } // (e) compare transform values - if (!m_transform.isApprox(other.m_transform, 1e-9)) { + if (m_transform && other.m_transform && + !m_transform->isApprox((*other.m_transform), 1e-9)) { return false; } // (f) compare material @@ -240,7 +249,7 @@ const Acts::Transform3& Acts::Surface::transform( if (m_associatedDetElement != nullptr) { return m_associatedDetElement->transform(gctx); } - return m_transform; + return *m_transform; } bool Acts::Surface::insideBounds(const Vector2& lposition, @@ -337,7 +346,7 @@ void Acts::Surface::assignDetectorElement( m_associatedDetElement = &detelement; // resetting the transform as it will be handled through the detector element // now - m_transform = Transform3::Identity(); + m_transform.reset(); } void Acts::Surface::assignSurfaceMaterial(