feat: Gen3 DD4hep construction#5193
feat: Gen3 DD4hep construction#5193paulgessinger wants to merge 61 commits intoacts-project:mainfrom
Conversation
f4d3d88 to
8538d86
Compare
|
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. |
b17a972 to
9acc9b5
Compare
65e8d40 to
3d94567
Compare
95c300f to
d98d492
Compare
|
It's finally green now @asalzburger @andiwand @tmadlener |
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.
46ce132 to
70a3c8c
Compare
|
andiwand
left a comment
There was a problem hiding this comment.
couple of minor comments and one thought on the general implementation
but overall OK from my side - approving
| 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...); | ||
| } | ||
| } |
There was a problem hiding this comment.
nitpick: could be worth upstreaming into a utility
| // 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); | ||
| } |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
| for (auto& group : groups) { | |
| for (const auto& group : groups) { |
does this need to be mutable?
There was a problem hiding this comment.
should this go into doc somewhere or was this accidentally committed?
| /// Helper struct for converting supported ROOT `TGeoShape` instances into ACTS | ||
| /// volumes. | ||
| struct TGeoVolumeConverter { | ||
| /// Utility type; not instantiable. | ||
| TGeoVolumeConverter() = delete; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
| 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>; |
There was a problem hiding this comment.
| 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; |
There was a problem hiding this comment.
| 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; |
There was a problem hiding this comment.
| const Builder* m_builder; | |
| const Builder* m_builder{}; |
| { 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>; | ||
| }; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.



No description provided.