Skip to content

Commit 98bbbd3

Browse files
authored
fix: allow deprecating surface.associatedDetectorElement in Acts v45 (#2466)
### Briefly, what does this PR introduce? This PR removes the use of deprecated `surface.associatedDetectorElement` when in Acts v45 (acts-project/acts#5005). Before Acts v45 this didn't exist, so no roll-out possible for currently-used Acts versions. Note that in my testing this is more than just a replacement of one deprecated call with another with equal functionality. In addition to a deprecation warning during compilation, this change is also required to avoid a crash on nullptr surfaces in Acts v45, so it is necessary in addition to advisable. ### What kind of change does this PR introduce? - [x] Bug fix (issue: deprecated `surface.associatedDetectorElement`, fix crash due to nullptr surfaces) - [ ] New feature (issue #__) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No. ### Does this PR change default behavior? No.
1 parent e69bd9d commit 98bbbd3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/algorithms/tracking/ActsGeometryProvider.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,13 @@ void ActsGeometryProvider::initialize(const dd4hep::Detector* dd4hep_geo, std::s
100100
class ConvertDD4hepDetectorGeometryIdentifierHook : public Acts::GeometryIdentifierHook {
101101
Acts::GeometryIdentifier decorateIdentifier(Acts::GeometryIdentifier identifier,
102102
const Acts::Surface& surface) const override {
103+
#if Acts_VERSION_MAJOR >= 45
104+
const auto* placement = surface.surfacePlacement();
105+
const auto* dd4hep_det_element = dynamic_cast<const DD4hepDetectorElement*>(placement);
106+
#else
103107
const auto* dd4hep_det_element =
104108
dynamic_cast<const DD4hepDetectorElement*>(surface.associatedDetectorElement());
109+
#endif
105110
if (dd4hep_det_element == nullptr) {
106111
return identifier;
107112
}
@@ -166,8 +171,13 @@ void ActsGeometryProvider::initialize(const dd4hep::Detector* dd4hep_geo, std::s
166171
m_init_log->info("no surface??? ");
167172
return;
168173
}
174+
#if Acts_VERSION_MAJOR >= 45
175+
const auto* placement = surface->surfacePlacement();
176+
const auto* det_element = dynamic_cast<const DD4hepDetectorElement*>(placement);
177+
#else
169178
const auto* det_element =
170179
dynamic_cast<const DD4hepDetectorElement*>(surface->associatedDetectorElement());
180+
#endif
171181

172182
if (det_element == nullptr) {
173183
m_init_log->error("invalid det_element!!! det_element == nullptr ");

0 commit comments

Comments
 (0)