Skip to content

Commit

Permalink
make DD4hepGeometryContext not inhert from GeometryContext
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger committed Nov 19, 2024
1 parent e6ae304 commit 04c97f2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Plugins/DD4hep/DD4hepGeometryContext.hpp"
#include "Acts/Plugins/TGeo/TGeoDetectorElement.hpp"
#include "Acts/Utilities/ThrowAssert.hpp"

Expand Down Expand Up @@ -42,7 +43,7 @@ class DD4hepDetectorElement : public TGeoDetectorElement {
using DD4hepVolumeID = dd4hep::DDSegmentation::VolumeID;

/// Broadcast the context type
using ContextType = GeometryContext;
using ContextType = DD4hepGeometryContext;

/// Define a string based story
using Store = std::map<std::string,
Expand Down Expand Up @@ -94,6 +95,11 @@ class DD4hepDetectorElement : public TGeoDetectorElement {
/// @note This method enables dynamic geometry updates through the context
const Transform3& transform(const GeometryContext& gctx) const final;

/// Return the nominal transform
///
/// @note This method returns the nominal transform without any alignment
const Transform3& nominalTransform() const;

private:
/// DD4hep detector element
dd4hep::DetElement m_detElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/GeometryContext.hpp"

namespace Acts {

Expand All @@ -19,14 +18,10 @@ class DD4hepDetectorElement;
///
/// @brief DD4hep specific geometry context for alignment handling
///
/// Extends the base GeometryContext to provide DD4hep-specific alignment
/// capabilities. The context can be active or inactive, controlling whether
/// alignment corrections should be applied.
///
/// @note This context is specifically designed to work with DD4hepDetectorElement
/// and provides contextual transformations for alignment purposes.
///
class DD4hepGeometryContext : public GeometryContext {
class DD4hepGeometryContext {
public:
/// Explicit inactive constructor
/// Creates an inactive geometry context that skips alignment corrections
Expand Down
16 changes: 11 additions & 5 deletions Plugins/DD4hep/src/DD4hepDetectorElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ Acts::DD4hepDetectorElement::DD4hepDetectorElement(

const Acts::Transform3& Acts::DD4hepDetectorElement::transform(
const GeometryContext& gctx) const {
const Acts::DD4hepGeometryContext* dd4hepGtx =
gctx.maybeGet<DD4hepGeometryContext>();
if (dd4hepGtx != nullptr && dd4hepGtx->isActive()) {
return dd4hepGtx->contextualTransform(*this);
if (gctx.hasValue()) {
const DD4hepGeometryContext* dd4hepContext =
gctx.maybeGet<DD4hepGeometryContext>();
if (dd4hepContext != nullptr && dd4hepContext->isActive()) {
return dd4hepContext->contextualTransform(*this);
}
}
return TGeoDetectorElement::m_transform;
return nominalTransform();
}

const Acts::Transform3& Acts::DD4hepDetectorElement::nominalTransform() const {
return TGeoDetectorElement::m_transform;
};
2 changes: 1 addition & 1 deletion Plugins/DD4hep/src/DD4hepGeometryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
const Acts::Transform3& Acts::DD4hepGeometryContext::contextualTransform(
const Acts::DD4hepDetectorElement& dElement) const {
// Use inactive context as the base transformation state
return dElement.transform(DD4hepGeometryContext::inactive());
return dElement.nominalTransform();
}

0 comments on commit 04c97f2

Please sign in to comment.