refactor(detray): Detray-level closed-set detector instantiation#5641
refactor(detray): Detray-level closed-set detector instantiation#5641paulgessinger wants to merge 6 commits into
Conversation
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.
|
| /// | ||
| /// @returns the assembled detector | ||
| template <class detector_t> | ||
| detector_t assemble_detector( |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
| 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. | |||
There was a problem hiding this comment.
I think this should into the IO lib?
|
|
||
| namespace detray { | ||
|
|
||
| using io_detector_t = detector<@DETRAY_META@<array<float>>>; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
The detray detector has this inbuilt, btw



Blocked by: