refactor: Surface takes shared ownership of SurfacePlacementBase#5305
Draft
paulgessinger wants to merge 3 commits intoacts-project:mainfrom
Draft
refactor: Surface takes shared ownership of SurfacePlacementBase#5305paulgessinger wants to merge 3 commits intoacts-project:mainfrom
paulgessinger wants to merge 3 commits intoacts-project:mainfrom
Conversation
Add a new ownership model where Surface can hold a shared_ptr to its SurfacePlacementBase (detector element), replacing the raw pointer. A std::variant in Surface::m_placement carries either the old raw pointer (backward compat) or the new shared_ptr path. Detector element classes (GenericDetectorElement, TGeoDetectorElement, DetectorElementStub) gain a createSurface() factory that calls shared_from_this() to hand shared ownership to the surface. The old surface() accessor is deprecated but kept for 1-2 releases via a m_legacySurface member that keeps the surface alive for code still using unique_ptr-managed elements. Call sites in DD4hep and TGeo plugins updated to use createSurface(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…IGNORE_DEPRECATED Add a static PortalPlacement::create() factory that constructs the placement via make_shared and then calls the non-deprecated assignSurfacePlacement(shared_ptr) overload (shared_from_this() is valid post-construction). Remove the #pragma GCC diagnostic workaround from PortalPlacement.cpp. Change VolumePlacementBase::m_portalPlacements from unique_ptr to shared_ptr and update portalPlacement() return types accordingly. Replace the raw #pragma GCC diagnostic in TGeoCylinderDiscSplitter.cpp with the central ACTS_PUSH_IGNORE_DEPRECATED / ACTS_POP_IGNORE_DEPRECATED macros from Acts/Utilities/Diagnostics.hpp. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the sequential std::get_if checks with a std::visit call using the overloaded visitor helper from Acts/Utilities/Helpers.hpp. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Surface::m_placementis now astd::variantholding either a rawconst SurfacePlacementBase*(old backward-compat path) or astd::shared_ptr<const SurfacePlacementBase>(new owning path)GenericDetectorElement,TGeoDetectorElement,DetectorElementStub) gain acreateSurface()factory that usesshared_from_this()to pass shared ownership into the surfacesurface()accessor onSurfacePlacementBaseis deprecated ([[deprecated]]) but kept for 1–2 releases; am_legacySurfacemember keeps the surface alive for callers still usingunique_ptr-managed elementsSurfacePlacementBasenow inheritsstd::enable_shared_from_thisPlaneSurface,DiscSurface,CylinderSurface,LineSurface) gain a parallel constructor takingshared_ptr<const SurfacePlacementBase>createSurface()Not migrated in this PR (use deprecated path, compiler warnings only)
PortalPlacement.cpp,Geant4DetectorElement.cpp,GeoModelDetectorElement,JsonDetectorElement— need factory-pattern refactor, separate PRassignSurfacePlacement(*element)Test plan
🤖 Generated with Claude Code