From 666d876a97f11e07accc5ea26ff1ccd7182d7979 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Mon, 3 Feb 2025 16:56:26 +0100 Subject: [PATCH 1/4] update to newest traccc+detray+friends --- CMakeLists.txt | 10 +++---- .../ActsExamples/Traccc/DetrayPropagator.hpp | 27 ++++++++++++++----- Examples/Python/src/Detray.cpp | 6 ++--- .../Plugins/Detray/DetrayConversionUtils.hpp | 6 ++++- .../Acts/Plugins/Detray/DetrayConverter.hpp | 4 +-- cmake/ActsExternSources.cmake | 10 +++---- 6 files changed, 40 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0dad0cf109..371e902c419 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,11 +269,11 @@ set(_acts_root_version 6.20) set(_acts_tbb_version 2020.1) set(_acts_pythia8_version 8.309) set(_acts_pybind11_version 2.13.1) -set(_acts_detray_version 0.75.3) -set(_acts_traccc_version 0.16.0) -set(_acts_covfie_version 0.10.0) -set(_acts_vecmem_version 1.4.0) -set(_acts_algebraplugins_version 0.22.0) +set(_acts_detray_version 0.87.0) +set(_acts_traccc_version 0.19.0) +set(_acts_covfie_version 0.11.0) +set(_acts_vecmem_version 1.13.0) +set(_acts_algebraplugins_version 0.26.2) set(_acts_annoy_version 1.17.3) # recommended dependency version. if there is an opportunity to reach diff --git a/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp b/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp index 999e8826333..b8997f16de9 100644 --- a/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp +++ b/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp @@ -18,9 +18,10 @@ #include #include +#include #include #include -#include +#include namespace ActsExamples { @@ -110,10 +111,16 @@ class DetrayPropagator : public PropagatorInterface { stepper_t, DetrayNavigator, detray::actor_chain>; - typename Propagator::state propagation(track, - m_cfg.detrayStore->detector); + // Context & Config + using Context = Propagator::state::context_type; + Context dCtx{}; + using Config = detray::propagation::config; + Config dCfg{}; - Propagator propagator; + typename Propagator::state propagation(track, m_cfg.detrayStore->detector, + dCtx); + + Propagator propagator(dCfg); MaterialTracer::state materialTracerState{ *m_cfg.detrayStore->memoryResource}; @@ -159,10 +166,16 @@ class DetrayPropagator : public PropagatorInterface { using Propagator = detray::propagator>; - typename Propagator::state propagation(track, - m_cfg.detrayStore->detector); + // Context & Config + using Context = Propagator::state::context_type; + Context dCtx{}; + using Config = detray::propagation::config; + Config dCfg{}; + + typename Propagator::state propagation(track, m_cfg.detrayStore->detector, + dCtx); - Propagator propagator; + Propagator propagator(dCfg); // Run the actual propagation propagator.propagate(propagation); } diff --git a/Examples/Python/src/Detray.cpp b/Examples/Python/src/Detray.cpp index a409d80c4bf..816b68ca4c1 100644 --- a/Examples/Python/src/Detray.cpp +++ b/Examples/Python/src/Detray.cpp @@ -7,6 +7,7 @@ // file, You can obtain one at https://mozilla.org/MPL/2.0/. #include "Acts/Detector/Detector.hpp" +#include "Acts/Plugins/Detray/DetrayConversionUtils.hpp" #include "Acts/Plugins/Detray/DetrayConverter.hpp" #include "Acts/Plugins/Python/Utilities.hpp" @@ -32,9 +33,8 @@ void addDetray(Context& ctx) { auto detray = m.def_submodule("detray"); { - py::class_, - std::shared_ptr>>(detray, - "detray_detector"); + py::class_>( + detray, "detray_detector"); } { diff --git a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionUtils.hpp b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionUtils.hpp index 7adc9bbe3f0..bc33b38cc89 100644 --- a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionUtils.hpp +++ b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionUtils.hpp @@ -15,7 +15,9 @@ #include #include +#include #include +#include #include namespace Acts { @@ -24,7 +26,9 @@ namespace Experimental { class DetectorVolume; } -using DetrayHostDetector = detray::detector; +using DetrayMetaData = detray::default_metadata>; + +using DetrayHostDetector = detray::detector; namespace DetrayConversionUtils { diff --git a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp index 104c71e1893..79cb1641d62 100644 --- a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp +++ b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp @@ -69,7 +69,7 @@ class DetrayConverter { detectorPayload); // (2a) homogeneous material - if constexpr (detray::detail::has_homogeneous_material_v) { + if constexpr (detray::concepts::has_homogeneous_material) { if (options.convertMaterial) { detray::io::detector_homogeneous_material_payload materialSlabsPayload = DetrayMaterialConverter::convertHomogeneousSurfaceMaterial( @@ -80,7 +80,7 @@ class DetrayConverter { } // (2b) material grids - if constexpr (detray::detail::has_material_grids_v) { + if constexpr (detray::concepts::has_material_rods) { if (options.convertMaterial) { detray::io::detector_grids_payload diff --git a/cmake/ActsExternSources.cmake b/cmake/ActsExternSources.cmake index 8d994815a9d..2316ca9e0ca 100644 --- a/cmake/ActsExternSources.cmake +++ b/cmake/ActsExternSources.cmake @@ -6,35 +6,35 @@ set(ACTS_ACTSVG_SOURCE mark_as_advanced(ACTS_ACTSVG_SOURCE) set(ACTS_VECMEM_SOURCE - "URL;https://github.com/acts-project/vecmem/archive/refs/tags/v${_acts_vecmem_version}.tar.gz;URL_HASH;SHA256=545dfb4de4f9f3d773eef6a0e3297ebf981bb81950930d0991ad739e31ab16af" + "URL;https://github.com/acts-project/vecmem/archive/refs/tags/v${_acts_vecmem_version}.tar.gz;URL_HASH;SHA256=fc21cea04140e1210c83a32579b0a7194601889b6c895404214ac55ce547342b" CACHE STRING "Source to take VECMEM from" ) mark_as_advanced(ACTS_VECMEM_SOURCE) set(ACTS_ALGEBRAPLUGINS_SOURCE - "URL;https://github.com/acts-project/algebra-plugins/archive/refs/tags/v${_acts_algebraplugins_version}.tar.gz;URL_HASH;SHA256=6fde02181c1b856c0a17a1925f0969798eecd5e3d6f2a87ea2eb365b6c948cc1" + "URL;https://github.com/acts-project/algebra-plugins/archive/refs/tags/v${_acts_algebraplugins_version}.tar.gz;URL_HASH;SHA256=0170f22e1a75493b86464f27991117bc2c5a9d52554c75786e321d4c591990e7" CACHE STRING "Source to take ALGEBRAPLUGINS from" ) mark_as_advanced(ACTS_ALGEBRAPLUGINS_SOURCE) set(ACTS_COVFIE_SOURCE - "URL;https://github.com/acts-project/covfie/archive/refs/tags/v${_acts_covfie_version}.tar.gz;URL_HASH;SHA256=d44142b302ffc193ad2229f1d2cc6d8d720dd9da8c37989ada4f23018f86c964" + "URL;https://github.com/acts-project/covfie/archive/refs/tags/v${_acts_covfie_version}.tar.gz;URL_HASH;SHA256=39fcd0f218d3b4f3aacc6af497a8cda8767511efae7a72b47781f10fd4340f4f" CACHE STRING "Source to take COVFIE from" ) mark_as_advanced(ACTS_COVFIE_SOURCE) set(ACTS_DETRAY_SOURCE - "URL;https://github.com/acts-project/detray/archive/refs/tags/v${_acts_detray_version}.tar.gz;URL_HASH;SHA256=1249d7398d1e534bd36b6f5a7d06a5e67adf6adeb8bca188d7e35490a675de7a" + "URL;https://github.com/acts-project/detray/archive/refs/tags/v${_acts_detray_version}.tar.gz;URL_HASH;SHA256=2d4a76432dd6ddbfc00b88b5d482072e471fefc264b60748bb1f9a123963576e" CACHE STRING "Source to take DETRAY from" ) mark_as_advanced(ACTS_DETRAY_SOURCE) set(ACTS_TRACCC_SOURCE - "URL;https://github.com/acts-project/traccc/archive/refs/tags/v${_acts_traccc_version}.tar.gz;URL_HASH;SHA256=86e0ebe7364d3a2106301d50a89feef583470da53c9dae6d1430dcc6eda7dba9" + "URL;https://github.com/acts-project/traccc/archive/refs/tags/v${_acts_traccc_version}.tar.gz;URL_HASH;SHA256=0a0f923dd4da9b3e76c634264aadf3994bbfe790c0bf4965140e671aa3fd4e2d" CACHE STRING "Source to take TRACCC from" ) From 7065d650846b5186e2665a6f0846ac450830f441 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Mon, 3 Feb 2025 17:11:04 +0100 Subject: [PATCH 2/4] don't shaddow --- .../ActsExamples/Traccc/DetrayPropagator.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp b/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp index b8997f16de9..7152ee3f7ee 100644 --- a/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp +++ b/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp @@ -112,10 +112,10 @@ class DetrayPropagator : public PropagatorInterface { detray::actor_chain>; // Context & Config - using Context = Propagator::state::context_type; - Context dCtx{}; - using Config = detray::propagation::config; - Config dCfg{}; + using DetrayContext = Propagator::state::context_type; + DetrayContext dCtx{}; + using DetrayConfig = detray::propagation::config; + DetrayConfig dCfg{}; typename Propagator::state propagation(track, m_cfg.detrayStore->detector, dCtx); @@ -167,10 +167,10 @@ class DetrayPropagator : public PropagatorInterface { detray::propagator>; // Context & Config - using Context = Propagator::state::context_type; - Context dCtx{}; - using Config = detray::propagation::config; - Config dCfg{}; + using DetrayContext = Propagator::state::context_type; + DetrayContext dCtx{}; + using DetrayConfig = detray::propagation::config; + DetrayConfig dCfg{}; typename Propagator::state propagation(track, m_cfg.detrayStore->detector, dCtx); From e57bbb3983035307b9bf4aeac66d88d82b528ce4 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Mon, 3 Feb 2025 17:29:08 +0100 Subject: [PATCH 3/4] pre-review ready --- .../ActsExamples/Traccc/DetrayPropagator.hpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp b/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp index 7152ee3f7ee..301ef694bd4 100644 --- a/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp +++ b/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp @@ -111,15 +111,13 @@ class DetrayPropagator : public PropagatorInterface { stepper_t, DetrayNavigator, detray::actor_chain>; - // Context & Config - using DetrayContext = Propagator::state::context_type; + using DetrayContext = typename Propagator::state::context_type; DetrayContext dCtx{}; using DetrayConfig = detray::propagation::config; DetrayConfig dCfg{}; - + // Add common configuration here typename Propagator::state propagation(track, m_cfg.detrayStore->detector, dCtx); - Propagator propagator(dCfg); MaterialTracer::state materialTracerState{ @@ -166,16 +164,15 @@ class DetrayPropagator : public PropagatorInterface { using Propagator = detray::propagator>; - // Context & Config - using DetrayContext = Propagator::state::context_type; + using DetrayContext = typename Propagator::state::context_type; DetrayContext dCtx{}; using DetrayConfig = detray::propagation::config; DetrayConfig dCfg{}; - + // Add common configuration here typename Propagator::state propagation(track, m_cfg.detrayStore->detector, dCtx); - Propagator propagator(dCfg); + // Run the actual propagation propagator.propagate(propagation); } From 3d63ac1e9773abf50f41b5b731bc234a1383f064 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Tue, 4 Feb 2025 10:33:38 +0100 Subject: [PATCH 4/4] make pytest run again --- Examples/Python/src/Covfie.cpp | 16 +++++++++++----- Examples/Python/tests/test_covfie.py | 14 +++++++++----- .../Acts/Plugins/Detray/DetrayConverter.hpp | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Examples/Python/src/Covfie.cpp b/Examples/Python/src/Covfie.cpp index 27ceb17373f..8afb920e3f4 100644 --- a/Examples/Python/src/Covfie.cpp +++ b/Examples/Python/src/Covfie.cpp @@ -20,7 +20,7 @@ using namespace pybind11::literals; namespace Acts::Python { namespace { -template +template void declareCovfieField(py::module& m, const std::string& fieldName) { using view_t = typename field_t::view_t; m.def("toView", @@ -28,7 +28,7 @@ void declareCovfieField(py::module& m, const std::string& fieldName) { py::class_>(m, fieldName.c_str()); py::class_>( m, (fieldName + std::string("View")).c_str()) - .def("at", &view_t::template at); + .def("at", &view_t::template at); } } // namespace @@ -36,9 +36,15 @@ void addCovfie(Context& ctx) { auto main = ctx.get("main"); auto m = main.def_submodule("covfie", "Submodule for covfie conversion"); - declareCovfieField(m, - "CovfieConstantField"); - declareCovfieField( + py::class_, + std::shared_ptr>>(m, + "ArrayFloat3") + .def("at", [](const covfie::array::array& self, + std::size_t i) { return self[i]; }); + + declareCovfieField( + m, "CovfieConstantField"); + declareCovfieField( m, "CovfieAffineLinearStridedField"); m.def("makeCovfieField", diff --git a/Examples/Python/tests/test_covfie.py b/Examples/Python/tests/test_covfie.py index 3c1d7ca0d3d..bc8804883b0 100644 --- a/Examples/Python/tests/test_covfie.py +++ b/Examples/Python/tests/test_covfie.py @@ -13,8 +13,11 @@ def test_constant_field_conversion(): cf = covfie.makeCovfieField(af) view = covfie.toView(cf) points = [(0, 0, 1), (1, 1, 1), (1, 0, 2)] - for x, y, z in points: - assert view.at(x, y, z) == [1, 2, 3] + for [x, y, z] in points: + field = view.at(x, y, z) + assert field.at(0) == 1 + assert field.at(1) == 2 + assert field.at(2) == 3 @pytest.mark.skipif(not covfieEnabled, reason="Covfie plugin not available") @@ -51,10 +54,11 @@ def test_root_field_conversion(): error_margin_half_width = 0.0001 for x, y, z in points: - val = af.getField(acts.Vector3(x, y, z), fc) - Bx1, By1, Bz1 = val[0], val[1], val[2] + rfield = af.getField(acts.Vector3(x, y, z), fc) + Bx1, By1, Bz1 = rfield[0], rfield[1], rfield[2] - Bx2, By2, Bz2 = tuple(view.at(x, y, z)) + tfield = view.at(x, y, z) + Bx2, By2, Bz2 = tfield.at(0), tfield.at(1), tfield.at(2) assert ( abs(Bx1 - Bx2) < error_margin_half_width diff --git a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp index 79cb1641d62..473d06451bb 100644 --- a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp +++ b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp @@ -80,7 +80,7 @@ class DetrayConverter { } // (2b) material grids - if constexpr (detray::concepts::has_material_rods) { + if constexpr (detray::concepts::has_material_maps) { if (options.convertMaterial) { detray::io::detector_grids_payload