Skip to content

refactor(detray): Detray-level closed-set detector instantiation#5641

Open
paulgessinger wants to merge 6 commits into
acts-project:mainfrom
paulgessinger:refactor/detray-meta-inst
Open

refactor(detray): Detray-level closed-set detector instantiation#5641
paulgessinger wants to merge 6 commits into
acts-project:mainfrom
paulgessinger:refactor/detray-meta-inst

Conversation

@paulgessinger

@paulgessinger paulgessinger commented Jul 6, 2026

Copy link
Copy Markdown
Member

Replace the free-function namespace with a class holding a Config that
takes a DetrayPayloadConverter instance, so payload conversion can be
customized from the call site. convert() returns a combined DetrayGeometry
type bundling the detray detector, name map, detray-to-surface map and the
owning TrackingGeometry. Mirror the new C++ API in the Python bindings
(no alternative signatures/names) and update the validation scripts.

Drop the redundant 'Acts' prefix from names: unprefixed is ACTS by
default, detray types are prefixed.
Centralize the closed set of detray metadata (Odd, Default) in
DetrayMetadata.hpp and iterate it via ACTS_DETRAY_METADATA_FOR_EACH.
Split the heavy convert() and detector IO (consistency check, JSON write,
read) definitions into .ipp files and declare extern template
instantiations so they compile once per metadata in dedicated TUs;
experiment code can still instantiate custom metadata.

Dispatch the Python bindings over the closed set with the metadata as the
first argument, and replace readODD with a metadata-dispatched read.
Split each per-metadata instantiation into per-operation translation units
(convert, consistency check, JSON write, read) to cut peak compile memory,
and generate them from CMake via configure_file (gainmatrix pattern) from
.cpp.in templates. Reduce the leaking macros to a single
ACTS_DETRAY_METADATA_FOR_EACH and move internal-only helpers into a detail
namespace.
Switch the test to the same closed-set metadata types so it links the
extern template definitions instead of instantiating the heavy detray
algorithms locally, and drop the svgtools instantiation.
@paulgessinger paulgessinger added the 🛑 blocked This item is blocked by another item label Jul 6, 2026
@github-actions github-actions Bot added this to the next milestone Jul 6, 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 Component - Detray Affects the Detray project labels Jul 6, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

///
/// @returns the assembled detector
template <class detector_t>
detector_t assemble_detector(

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.

I think this should merge with the detector_components_reader which so far only handles file readers, but we could add overloads for e.g. add_geometry_reader that takes a payload and adds a bare reader without file frontend (might need to adjust the internal map for that). And then we add a new function read_components_from_payload that does what read_components_from_file does


geometry_reader::from_payload<detector_t>(det_builder, geometry);

if (homogeneous_material != nullptr) {

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
if (homogeneous_material != nullptr) {
if (homogeneous_material != nullptr) {
if constexpr (detray::concepts::has_homogeneous_material<detector_t>) {

There is a concept for every detector component to turn off stuff that the detector type cannot hold

@@ -0,0 +1,29 @@
// This file is part of the ACTS project.

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.

I think this should into the IO lib?


namespace detray {

using io_detector_t = detector<@DETRAY_META@<array<float>>>;

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.

This needs the detray scalar type, so that we can build double precision detectors in double precision tests

/// @return a map from detray surface identifiers to the source surfaces
template <typename detector_t>
std::unordered_map<detray::geometry::identifier, const Acts::Surface*>
buildDetrayToSurfaceMap(const detector_t& detrayDetector,

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.

The detray detector has this inbuilt, btw

@niermann999 niermann999 changed the title refactor: Detray-level closed-set detector instantiation refactor(detray): Detray-level closed-set detector instantiation Jul 7, 2026
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 - Detray Affects the Detray project Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins 🛑 blocked This item is blocked by another item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants