From 9d302965f315caad43cb02d3708850c024bb9d9b Mon Sep 17 00:00:00 2001 From: Stephen Nicholas Swatman Date: Fri, 9 Aug 2024 18:35:10 +0200 Subject: [PATCH] fix: Minor fixes to detray and traccc plugins (#3483) This commit makes several minor fixes to the detray and traccc plugins, namely: 1. It establishes a dependency between the detray plugin and the JSON plugin. 2. It uses the Acts scalartype in both detray and traccc. 3. It fixes a few namespace errors in the detray plugin. 4. It fixes a missing import. 5. It disables the SVG tooling in detray, which we don't need. --- CMakeLists.txt | 3 +++ Plugins/Detray/CMakeLists.txt | 1 - .../Plugins/Detray/DetrayConversionHelper.hpp | 20 +++++++++++++------ .../Acts/Plugins/Detray/DetrayConverter.hpp | 2 +- Plugins/Detray/src/DetrayConverter.cpp | 6 ++++-- thirdparty/detray/CMakeLists.txt | 14 +++++++++---- thirdparty/traccc/CMakeLists.txt | 9 +++++++++ 7 files changed, 41 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5e41889246..f8e8a93ae5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,6 +151,9 @@ set_option_if( set_option_if( ACTS_BUILD_PLUGIN_DETRAY ACTS_BUILD_PLUGIN_TRACCC) +set_option_if( + ACTS_BUILD_PLUGIN_JSON + ACTS_BUILD_PLUGIN_DETRAY) set_option_if( ACTS_BUILD_PLUGIN_COVFIE ACTS_BUILD_PLUGIN_DETRAY) diff --git a/Plugins/Detray/CMakeLists.txt b/Plugins/Detray/CMakeLists.txt index a57ffa914a4..c04879d7c2e 100644 --- a/Plugins/Detray/CMakeLists.txt +++ b/Plugins/Detray/CMakeLists.txt @@ -21,7 +21,6 @@ target_link_libraries( detray::core_array detray::io detray::utils - detray::svgtools vecmem::core) install( diff --git a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionHelper.hpp b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionHelper.hpp index 5fdbd2d7002..d3452bed680 100644 --- a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionHelper.hpp +++ b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionHelper.hpp @@ -95,19 +95,27 @@ inline static std::size_t accelerationLink(const binning_values_t& casts) { // Default is `brute_force` std::size_t accLink = detray::io::accel_id::brute_force; if (casts.size() == 2u) { - if (casts[0u] == binX && casts[1u] == binY) { + if (casts[0u] == Acts::BinningValue::binX && + casts[1u] == Acts::BinningValue::binY) { accLink = detray::io::accel_id::cartesian2_grid; - } else if (casts[0u] == binR && casts[1u] == binPhi) { + } else if (casts[0u] == Acts::BinningValue::binR && + casts[1u] == Acts::BinningValue::binPhi) { accLink = detray::io::accel_id::polar2_grid; - } else if (casts[0u] == binZ && casts[1u] == binPhi) { + } else if (casts[0u] == Acts::BinningValue::binZ && + casts[1u] == Acts::BinningValue::binPhi) { accLink = detray::io::accel_id::cylinder2_grid; - } else if (casts[0u] == binZ && casts[1u] == binR) { + } else if (casts[0u] == Acts::BinningValue::binZ && + casts[1u] == Acts::BinningValue::binR) { accLink = detray::io::accel_id::cylinder3_grid; } } else if (casts.size() == 3u) { - if (casts[0u] == binX && casts[1u] == binY && casts[2u] == binZ) { + if (casts[0u] == Acts::BinningValue::binX && + casts[1u] == Acts::BinningValue::binY && + casts[2u] == Acts::BinningValue::binZ) { accLink = detray::io::accel_id::cuboid3_grid; - } else if (casts[0u] == binZ && casts[1u] == binPhi && casts[2u] == binR) { + } else if (casts[0u] == Acts::BinningValue::binZ && + casts[1u] == Acts::BinningValue::binPhi && + casts[2u] == Acts::BinningValue::binR) { accLink = detray::io::accel_id::cylinder3_grid; } } diff --git a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp index 4de8a8bf5ac..ff332d6d2a6 100644 --- a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp +++ b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp @@ -9,6 +9,7 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" +#include "Acts/Detector/Detector.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/VolumeBounds.hpp" @@ -28,7 +29,6 @@ class Surface; class SurfaceBounds; namespace Experimental { -class Detector; class DetectorVolume; class Portal; } // namespace Experimental diff --git a/Plugins/Detray/src/DetrayConverter.cpp b/Plugins/Detray/src/DetrayConverter.cpp index d3ce397923c..2aec9d55274 100644 --- a/Plugins/Detray/src/DetrayConverter.cpp +++ b/Plugins/Detray/src/DetrayConverter.cpp @@ -176,12 +176,14 @@ std::vector Acts::DetrayConverter::convertPortal( // Pick the surface dimension - via poly std::array clipRange = {0., 0.}; std::vector boundValues = surfaceAdjusted->bounds().values(); - if (surfaceType == Surface::SurfaceType::Cylinder && cast == binZ) { + if (surfaceType == Surface::SurfaceType::Cylinder && + cast == Acts::BinningValue::binZ) { ActsScalar zPosition = surfaceAdjusted->center(gctx).z(); clipRange = { zPosition - boundValues[CylinderBounds::BoundValues::eHalfLengthZ], zPosition + boundValues[CylinderBounds::BoundValues::eHalfLengthZ]}; - } else if (surfaceType == Surface::SurfaceType::Disc && cast == binR) { + } else if (surfaceType == Surface::SurfaceType::Disc && + cast == Acts::BinningValue::binR) { clipRange = {boundValues[RadialBounds::BoundValues::eMinR], boundValues[RadialBounds::BoundValues::eMaxR]}; } else { diff --git a/thirdparty/detray/CMakeLists.txt b/thirdparty/detray/CMakeLists.txt index 074737ae7a5..97d920da144 100644 --- a/thirdparty/detray/CMakeLists.txt +++ b/thirdparty/detray/CMakeLists.txt @@ -18,8 +18,14 @@ set( DETRAY_VERSION "v${_acts_detray_version}") FetchContent_Declare( Detray ${ACTS_DETRAY_SOURCE} ) # Options used in the build of Detray. -set( DETRAY_CUSTOM_SCALARTYPE "float" CACHE STRING - "Scalar type to use in the Detray code" ) +if(ACTS_CUSTOM_SCALARTYPE) + set(ACTS_DETRAY_SCALARTYPE ${ACTS_CUSTOM_SCALARTYPE}) +else() + set(ACTS_DETRAY_SCALARTYPE "double") +endif() + +set( DETRAY_CUSTOM_SCALARTYPE "${ACTS_DETRAY_SCALARTYPE}" CACHE STRING + "Scalar type to use in the Detray code" ) set( DETRAY_BUILD_TESTING OFF CACHE BOOL "Turn off the build of the Detray unit tests" ) @@ -48,8 +54,8 @@ set( DETRAY_SETUP_ACTSVG OFF CACHE BOOL "Do not set up Actsvg as part of Detray" ) set( DETRAY_SETUP_DFELIBS OFF CACHE BOOL "Do not set up Dfelibs as part of Detray" ) -set( DETRAY_SVG_DISPLAY ${ACTS_BUILD_PLUGIN_ACTSVG} CACHE BOOL - "Build the ActSVG display module depending on the ACTS_BUILD_PLUGIN_ACTSVG" ) +set( DETRAY_SVG_DISPLAY OFF CACHE BOOL + "No not build the ActSVG display module" ) #Now set up its build. diff --git a/thirdparty/traccc/CMakeLists.txt b/thirdparty/traccc/CMakeLists.txt index 2bea839ef1d..06c434e938f 100644 --- a/thirdparty/traccc/CMakeLists.txt +++ b/thirdparty/traccc/CMakeLists.txt @@ -18,6 +18,15 @@ set( TRACCC_VERSION "${_acts_traccc_version}") # Declare where to get traccc from. FetchContent_Declare( traccc ${ACTS_TRACCC_SOURCE} ) +if(ACTS_CUSTOM_SCALARTYPE) + set(ACTS_TRACCC_SCALARTYPE ${ACTS_CUSTOM_SCALARTYPE}) +else() + set(ACTS_TRACCC_SCALARTYPE "double") +endif() + +set( TRACCC_CUSTOM_SCALARTYPE "${ACTS_TRACCC_SCALARTYPE}" CACHE STRING + "Scalar type to use in the traccc code" ) + set( TRACCC_SETUP_VECMEM OFF CACHE BOOL "Do not set up Actsvg as part of Traccc" ) set( TRACCC_SETUP_EIGEN3 OFF CACHE BOOL