Skip to content

feat: Gen3 DD4hep construction#5193

Open
paulgessinger wants to merge 61 commits intoacts-project:mainfrom
paulgessinger:feat/dd4hep-gen3
Open

feat: Gen3 DD4hep construction#5193
paulgessinger wants to merge 61 commits intoacts-project:mainfrom
paulgessinger:feat/dd4hep-gen3

Conversation

@paulgessinger
Copy link
Copy Markdown
Member

No description provided.

@github-actions github-actions bot added this to the next milestone Mar 3, 2026
@github-actions github-actions bot added Component - Core Affects the Core module Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins labels Mar 3, 2026
@tmadlener
Copy link
Copy Markdown
Contributor

From my point of view, I am pretty happy with the state of this. I have exercised a few of the geometries we have in k4geo in key4hep/k4ActsTracking#36 and at least for me the still existing amount of boilerplate is acceptable (and probably also necessary) given the layouts of the tracking devices we have.

@paulgessinger paulgessinger force-pushed the feat/dd4hep-gen3 branch 2 times, most recently from 65e8d40 to 3d94567 Compare March 27, 2026 14:37
@paulgessinger paulgessinger marked this pull request as ready for review March 27, 2026 14:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

📊: Physics performance monitoring for 70a3c8c

Full contents

physmon summary

@paulgessinger
Copy link
Copy Markdown
Member Author

It's finally green now @asalzburger @andiwand @tmadlener

Yufeng Wang and others added 27 commits April 1, 2026 12:47
tmadlener: Lifted from earlier work done on the old API design proposal
Do not prescribe CylinderContainers
Some helpers and at least some of the necessary disambiguation
Move ODD TGeo constants/layer binning logic into the DD4hep builder path and remove the generic TGeoBackend constant-provider plumbing.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of minor comments and one thought on the general implementation

but overall OK from my side - approving

Comment on lines +22 to +32
template <typename F, typename G, typename... Rest>
auto compose(const F& f, const G& g, Rest... rest) {
auto fg = [=]<typename T>(T&& x) -> decltype(auto) {
return std::invoke(f, g(std::forward<T>(x)));
};
if constexpr (sizeof...(rest) == 0) {
return fg;
} else {
return compose(fg, rest...);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: could be worth upstreaming into a utility

Comment on lines +104 to +114
// ElementLayerAssembler
template <detail::BlueprintBackend BackendT>
ElementLayerAssembler<BackendT>::ElementLayerAssembler(const Builder& builder)
: m_builder{&builder} {}

template <detail::BlueprintBackend BackendT>
ElementLayerAssembler<BackendT>&& ElementLayerAssembler<BackendT>::setLayerType(
LayerType layerType) && {
m_layerType = layerType;
return std::move(*this);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: maybe of these functions are one-liners - might be more convenient to put them in the "main" header file

it->sensors.push_back(sensor);
}

for (auto& group : groups) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (auto& group : groups) {
for (const auto& group : groups) {

does this need to be mutable?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this go into doc somewhere or was this accidentally committed?

Comment on lines +21 to +25
/// Helper struct for converting supported ROOT `TGeoShape` instances into ACTS
/// volumes.
struct TGeoVolumeConverter {
/// Utility type; not instantiable.
TGeoVolumeConverter() = delete;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: struct vs namespace - do you think we will need some config or state for this in the future?

/// @param builder The owning @ref BlueprintBuilder; must outlive this object.
explicit ElementLayerAssembler(const Builder& builder);

const Builder* m_builder;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const Builder* m_builder;
const Builder* m_builder = nullptr;

nitpick: since other variables are defaulted

layerSpec.layerAxes = std::move(layerAxes);
};

using LayerNodePtr = std::shared_ptr<Acts::Experimental::LayerBlueprintNode>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using LayerNodePtr = std::shared_ptr<Acts::Experimental::LayerBlueprintNode>;
using LayerNodePtr = std::shared_ptr<LayerBlueprintNode>;

nitpick: I think the namespace can be collapsed. there are a couple more cases in this file

/// @param builder The owning @ref BlueprintBuilder; must outlive this object.
explicit SensorLayerAssembler(const Builder& builder);

const Builder* m_builder;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const Builder* m_builder;
const Builder* m_builder{};

/// @param builder The owning @ref BlueprintBuilder; must outlive this object.
explicit SensorLayer(const Builder& builder);

const Builder* m_builder;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const Builder* m_builder;
const Builder* m_builder{};

Comment on lines +221 to +232
{ BackendT::kIdentifier } -> std::convertible_to<std::string_view>;
{ backend.world() } -> std::same_as<typename BackendT::Element>;
{ backend.nameOf(element) } -> std::same_as<std::string>;
{
backend.children(element)
} -> std::same_as<std::vector<typename BackendT::Element>>;
{ backend.parent(element) } -> std::same_as<typename BackendT::Element>;
{ backend.isSensitive(element) } -> std::same_as<bool>;
requires requires(const typename BackendT::Element& a,
const typename BackendT::Element& b) {
{ a == b } -> std::convertible_to<bool>;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts after going through the code:

I wonder if alternatively the Element can be type-erased via std::any or even a simple element index. This would allow to convert the backend to a virtual interface or maybe remove the backend and let the user derive from BlueprintBuilder.

Another option would be to have a virtual interface for Element and talk to it during construction. But this would require multiple dynamic allocations to traverse the tree. But for construction not critical I guess.

I don't think there is a huge advantage in either direction, just some thoughts on relaxing the templating. At the end the deciding factor should be the interface, flexibility and maintainability. Here I cannot really say anything as I haven't used the interface. Maybe @noemina @tmadlener @asalzburger can say more

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2 cents (from a user perspective for DD4hep). I am fairly happy with the current (templated) implementation. In the end what shows up in user code is ActsPlugins::DD4hep::BlueprintBuilder (and friends) and very few (if any) dedicated templates from the backend (see key4hep/k4ActsTracking#36). I think it would be almost transparent for us if this was switched to a pure virtual BlueprintBuilder, as long as the ActsPlugins::DD4hep::BlueprintBuilder survives with the same interface. The one thing where I think having dedicated element types is nice is for writing small utility functionality (e.g. for visitors) is rather straight forward at the moment because I can directly use the dd4hep types instead of, e.g. having to do an any_cast first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component - Core Affects the Core module Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants