diff --git a/CMakeLists.txt b/CMakeLists.txt index 362e5a355b..4a1f9833ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,7 +264,14 @@ if(DETRAY_SETUP_BENCHMARK) endif() # Set up covfie. -option(DETRAY_SETUP_COVFIE "Set up the covfie target(s) explicitly" TRUE) +if(DETRAY_BUILD_TESTING OR DETRAY_BUILD_BENCHMARKS OR DETRAY_BUILD_CLI_TOOLS) + set(DETRAY_BUILD_COVFIE ON) +endif() +option( + DETRAY_SETUP_COVFIE + "Set up the covfie target(s) explicitly" + ${DETRAY_BUILD_COVFIE} +) option( DETRAY_USE_SYSTEM_COVFIE "Pick up an existing installation of covfie from the build environment" diff --git a/detectors/CMakeLists.txt b/detectors/CMakeLists.txt index 08ee93a222..5f2cabad27 100644 --- a/detectors/CMakeLists.txt +++ b/detectors/CMakeLists.txt @@ -20,7 +20,7 @@ file( detray_add_library( detray_detectors detectors ${_detray_detectors_headers}) target_link_libraries( detray_detectors - INTERFACE covfie::core vecmem::core detray::core detray::io + INTERFACE vecmem::core detray::core detray::io ) unset(_detray_detector_headers) diff --git a/io/CMakeLists.txt b/io/CMakeLists.txt index 75fcdc2282..a160004dce 100644 --- a/io/CMakeLists.txt +++ b/io/CMakeLists.txt @@ -23,7 +23,6 @@ file( RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "include/detray/io/backend/*.hpp" "include/detray/io/backend/detail/*.hpp" - "include/detray/io/covfie/*.hpp" "include/detray/io/frontend/*.hpp" "include/detray/io/frontend/detail/*.hpp" "include/detray/io/frontend/impl/*.hpp" @@ -38,7 +37,6 @@ target_link_libraries( INTERFACE nlohmann_json::nlohmann_json vecmem::core - covfie::core detray::core detray::io_utils ) diff --git a/io/include/detray/io/backend/detail/grid_reader.hpp b/io/include/detray/io/backend/detail/grid_reader.hpp index 244a5924bc..1a2f8c83fe 100644 --- a/io/include/detray/io/backend/detail/grid_reader.hpp +++ b/io/include/detray/io/backend/detail/grid_reader.hpp @@ -403,7 +403,7 @@ class grid_reader { } entry.set_volume(volume_idx); entry.set_index(static_cast(c)); - vgr_builder->get().template populate>(mbin, entry); + grid.template populate>(mbin, entry); } } } else { diff --git a/io/include/detray/io/covfie/read_bfield.hpp b/io/include/detray/io/covfie/read_bfield.hpp deleted file mode 100644 index d004f034c1..0000000000 --- a/io/include/detray/io/covfie/read_bfield.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/** Detray library, part of the ACTS project (R&D line) - * - * (c) 2023 CERN for the benefit of the ACTS project - * - * Mozilla Public License Version 2.0 - */ - -#pragma once - -// Project include(s) -#include "detray/io/utils/file_handle.hpp" - -// Covfie include(s) -#include - -// System include(s) -#include -#include -#include -#include - -namespace detray::io { - -/// @brief Function that reads the first 4 bytes of a potential bfield file and -/// checks that it contains data for a covfie field -inline bool check_covfie_file(const std::string& file_name) { - - // Open binary file - io::file_handle file{file_name, std::ios_base::in | std::ios_base::binary}; - - // See "covfie/lib/core/utility/binary_io.hpp" - std::uint32_t hdr = covfie::utility::read_binary(*file); - - // Compare to magic bytes - return (hdr == covfie::utility::MAGIC_HEADER); -} - -/// @brief function that reads a covfie field from file -template -inline bfield_t read_bfield(const std::string& file_name) { - - if (!check_covfie_file(file_name)) { - throw std::runtime_error("Not a valid covfie file: " + file_name); - } - - // Open binary file - io::file_handle file{file_name, std::ios_base::in | std::ios_base::binary}; - - return bfield_t(*file); -} - -} // namespace detray::io diff --git a/plugins/svgtools/CMakeLists.txt b/plugins/svgtools/CMakeLists.txt index 5b505fca33..f9f4e02fca 100644 --- a/plugins/svgtools/CMakeLists.txt +++ b/plugins/svgtools/CMakeLists.txt @@ -19,7 +19,7 @@ detray_add_library( detray_svgtools svgtools ) target_link_libraries( detray_svgtools - INTERFACE detray::core actsvg::core actsvg::meta + INTERFACE detray::core detray::io actsvg::core actsvg::meta ) # Clean up. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cebba8e403..cc2d251ff8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,8 +4,6 @@ # # Mozilla Public License Version 2.0 -message(STATUS "Building 'detray::test_utils' component") - # Set the common C++ flags. include(detray-compiler-options-cpp) @@ -14,30 +12,76 @@ include_directories( $ ) -# Set up a test library, which can be used by downstream projects without -# building the detray unit and integration +# Detray unit and integration test framework (depends on google test) +if(DETRAY_BUILD_TESTING) + message(STATUS "Building 'detray::test_framework' component") + + file( + GLOB _detray_test_headers + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + "include/detray/test/framework/*.hpp" + ) + + add_library(detray_test_framework INTERFACE "${_detray_test_headers}") + add_library(detray::test_framework ALIAS detray_test_framework) + + target_include_directories( + detray_test_framework + INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include" + ) + + target_link_libraries( + detray_test_framework + INTERFACE GTest::gtest vecmem::core detray::core detray::detectors + ) + + unset(_detray_test_headers) +endif() + +# Common test dependencies such as test detectors, B-fields and track generators +# (depends on covfie) if(DETRAY_BUILD_TEST_UTILS) + message(STATUS "Building 'detray::test_common' component") + + file( + GLOB _detray_test_common_headers + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + "include/detray/test/common/*.hpp" + "include/detray/test/common/factories/*.hpp" + "include/detray/test/common/event_generator/*.hpp" + ) + + detray_add_library(detray_test_common test_common "${_detray_test_common_headers}") + + target_link_libraries( + detray_test_common + INTERFACE vecmem::core covfie::core detray::core detray::detectors + ) + + unset(_detray_test_common_headers) +endif() + +# Lightweight test utils library without external dependencies +if(DETRAY_BUILD_TEST_UTILS OR DETRAY_BUILD_VALIDATION_TOOLS) + message(STATUS "Building 'detray::test_utils' component") + file( GLOB _detray_test_utils_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "include/detray/test/utils/*.hpp" - "include/detray/test/utils/detectors/*.hpp" - "include/detray/test/utils/detectors/factories/*.hpp" - "include/detray/test/utils/simulation/event_generator/*.hpp" - "include/detray/test/utils/simulation/*.hpp" ) detray_add_library(detray_test_utils test_utils ${_detray_test_utils_headers}) - target_link_libraries( - detray_test_utils - INTERFACE vecmem::core detray::core detray::detectors - ) + + target_link_libraries(detray_test_utils INTERFACE vecmem::core detray::core) unset(_detray_test_utils_headers) endif() -# Build extended validation tools +# Build extended validation tools (actsvg and csv depencies) if(DETRAY_BUILD_VALIDATION_TOOLS) + message(STATUS "Building 'detray::validation_utils' component") + file( GLOB _detray_validation_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" @@ -45,6 +89,7 @@ if(DETRAY_BUILD_VALIDATION_TOOLS) ) detray_add_library(detray_validation_utils validation_utils ${_detray_validation_headers}) + target_link_libraries( detray_validation_utils INTERFACE @@ -58,33 +103,6 @@ if(DETRAY_BUILD_VALIDATION_TOOLS) unset(_detray_validation_headers) endif() -# Build the common (host and device) test library (mostly for integration tests) -if(DETRAY_BUILD_TESTING) - message(STATUS "Building 'detray::test_common' component") - - file( - GLOB _detray_test_headers - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - "include/detray/test/common/*.hpp" - "include/detray/test/common/detail/*.hpp" - ) - - add_library(detray_test_common INTERFACE "${_detray_test_headers}") - add_library(detray::test_common ALIAS detray_test_common) - - target_include_directories( - detray_test_common - INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include" - ) - - target_link_libraries( - detray_test_common - INTERFACE GTest::gtest vecmem::core detray::core detray::test_utils - ) - - unset(_detray_test_headers) -endif() - # Include all of the code-holding sub-directories. # Build the benchmarks diff --git a/tests/benchmarks/CMakeLists.txt b/tests/benchmarks/CMakeLists.txt index 7feecef868..bab02b283d 100644 --- a/tests/benchmarks/CMakeLists.txt +++ b/tests/benchmarks/CMakeLists.txt @@ -28,7 +28,7 @@ target_include_directories( target_link_libraries( detray_benchmarks - INTERFACE benchmark::benchmark vecmem::core detray::core detray::test_utils + INTERFACE benchmark::benchmark vecmem::core detray::core detray::test_common ) unset(_detray_benchmarks_headers) diff --git a/tests/benchmarks/cpu/CMakeLists.txt b/tests/benchmarks/cpu/CMakeLists.txt index c72bb07244..5fbcbcc0d9 100644 --- a/tests/benchmarks/cpu/CMakeLists.txt +++ b/tests/benchmarks/cpu/CMakeLists.txt @@ -24,7 +24,7 @@ macro(detray_add_cpu_benchmark algebra) "intersect_surfaces.cpp" "masks.cpp" LINK_LIBRARIES benchmark::benchmark benchmark::benchmark_main vecmem::core detray::benchmarks - detray::core_${algebra} detray::test_utils + detray::core_${algebra} detray::test_common ) target_compile_options( @@ -51,7 +51,7 @@ macro(detray_add_cpu_benchmark algebra) detray_add_executable( benchmark_cpu_propagation_${algebra} "propagation.cpp" LINK_LIBRARIES detray::benchmark_cpu benchmark::benchmark_main - vecmem::core detray::core_${algebra} detray::test_utils + vecmem::core detray::core_${algebra} detray::test_common ) target_compile_options( @@ -91,7 +91,7 @@ if(DETRAY_VC_SOA_PLUGIN) detray_add_executable(benchmark_cpu_vc_soa_vs_${algebra} "intersectors.cpp" LINK_LIBRARIES benchmark::benchmark benchmark::benchmark_main vecmem::core detray::core_vc_soa detray::core_vc_aos detray::core_${algebra} - detray::test_utils + detray::test_common ) target_compile_options( diff --git a/tests/benchmarks/cpu/find_volume.cpp b/tests/benchmarks/cpu/find_volume.cpp index 8f1ab15d77..f6c1b7c5a9 100644 --- a/tests/benchmarks/cpu/find_volume.cpp +++ b/tests/benchmarks/cpu/find_volume.cpp @@ -5,9 +5,11 @@ * Mozilla Public License Version 2.0 */ -// Detray test include(s). -#include "detray/test/utils/detectors/build_toy_detector.hpp" -#include "detray/test/utils/types.hpp" +// Detray benchmark include(s) +#include "detray/benchmarks/types.hpp" + +// Detray test include(s) +#include "detray/test/common/build_toy_detector.hpp" // VecMem include(s). #include @@ -21,8 +23,8 @@ // Use the detray:: namespace implicitly. using namespace detray; -using test_algebra = test::algebra; -using scalar = test::scalar; +using bench_algebra = benchmarks::algebra; +using scalar = benchmarks::scalar; // Benchmarks the cost of searching a volume by position void BM_FIND_VOLUMES(benchmark::State &state) { @@ -35,7 +37,7 @@ void BM_FIND_VOLUMES(benchmark::State &state) { vecmem::host_memory_resource host_mr; toy_det_config toy_cfg{}; toy_cfg.n_edc_layers(7u); - auto [d, names] = build_toy_detector(host_mr, toy_cfg); + auto [d, names] = build_toy_detector(host_mr, toy_cfg); static const unsigned int itest = 10000u; @@ -57,8 +59,8 @@ void BM_FIND_VOLUMES(benchmark::State &state) { for (auto _ : state) { for (unsigned int i1 = 0u; i1 < itest; ++i1) { for (unsigned int i0 = 0u; i0 < itest; ++i0) { - test::vector3 rz{static_cast(i0) * step0, 0.f, - static_cast(i1) * step1}; + benchmarks::vector3 rz{static_cast(i0) * step0, 0.f, + static_cast(i1) * step1}; const auto &v = d.volume(rz); benchmark::DoNotOptimize(successful); diff --git a/tests/benchmarks/cpu/grid.cpp b/tests/benchmarks/cpu/grid.cpp index 125c8e3b12..0922d65211 100644 --- a/tests/benchmarks/cpu/grid.cpp +++ b/tests/benchmarks/cpu/grid.cpp @@ -14,8 +14,8 @@ #include "detray/geometry/shapes/rectangle2D.hpp" #include "detray/utils/grid/detail/concepts.hpp" -// Detray test include(s). -#include "detray/test/utils/types.hpp" +// Detray benchmark include(s) +#include "detray/benchmarks/types.hpp" // VecMem include(s). #include @@ -32,14 +32,14 @@ // Use the detray:: namespace implicitly. using namespace detray; -using test_algebra = test::algebra; -using scalar = test::scalar; +using bench_algebra = benchmarks::algebra; +using scalar = benchmarks::scalar; namespace { #ifdef DETRAY_BENCHMARK_PRINTOUTS /// Test point for printouts -const auto tp = test::point2{12.f, 30.f}; +const auto tp = benchmarks::point2{12.f, 30.f}; #endif /// Prepare test points @@ -50,7 +50,7 @@ auto make_random_points() { std::uniform_real_distribution dist1(0.f, 24.f); std::uniform_real_distribution dist2(0.f, 59.f); - std::vector points{}; + std::vector points{}; for (unsigned int itest = 0u; itest < 1000000u; ++itest) { points.push_back({dist1(gen), dist2(gen)}); } @@ -63,7 +63,7 @@ template auto make_regular_grid(vecmem::memory_resource &mr) { // Data-owning grids with bin capacity 1 - auto gr_factory = grid_factory{mr}; + auto gr_factory = grid_factory{mr}; // Spans of the axes std::vector spans = {0.f, 25.f, 0.f, 60.f}; @@ -94,7 +94,7 @@ auto make_irregular_grid(vecmem::memory_resource &mr) { } // Data-owning grids with bin capacity 1 - auto gr_factory = grid_factory{mr}; + auto gr_factory = grid_factory{mr}; // Rectangular grid with closed bin bounds and irregular binning on all axes return gr_factory.template new_grid( diff --git a/tests/benchmarks/cpu/grid2.cpp b/tests/benchmarks/cpu/grid2.cpp index fbfbfb3ceb..a004bdc672 100644 --- a/tests/benchmarks/cpu/grid2.cpp +++ b/tests/benchmarks/cpu/grid2.cpp @@ -14,8 +14,8 @@ #include "detray/grids/populator.hpp" #include "detray/grids/serializer2.hpp" -// Detray test include(s). -#include "detray/test/utils/types.hpp" +// Detray benchmark include(s) +#include "detray/benchmarks/types.hpp" // VecMem include(s). #include @@ -35,7 +35,7 @@ namespace { #ifdef DETRAY_BENCHMARK_PRINTOUTS /// Test point for printouts -const auto tp = test::point2{12.f, 30.f}; +const auto tp = benchmarks::point2{12.f, 30.f}; #endif /// Prepare test points @@ -46,7 +46,7 @@ auto make_random_points() { std::uniform_real_distribution dist1(0.f, 24.f); std::uniform_real_distribution dist2(0.f, 59.f); - std::vector points{}; + std::vector points{}; for (unsigned int itest = 0u; itest < 1000000u; ++itest) { points.push_back({dist1(gen), dist2(gen)}); } diff --git a/tests/benchmarks/cpu/intersect_all.cpp b/tests/benchmarks/cpu/intersect_all.cpp index 34754ba5c5..c4029f4fe4 100644 --- a/tests/benchmarks/cpu/intersect_all.cpp +++ b/tests/benchmarks/cpu/intersect_all.cpp @@ -15,10 +15,12 @@ #include "detray/tracks/tracks.hpp" #include "detray/utils/ranges.hpp" -// Detray test include(s). -#include "detray/test/utils/detectors/build_toy_detector.hpp" -#include "detray/test/utils/simulation/event_generator/track_generators.hpp" -#include "detray/test/utils/types.hpp" +// Detray test include(s) +#include "detray/test/common/build_toy_detector.hpp" +#include "detray/test/common/track_generators.hpp" + +// Detray benchmark include(s) +#include "detray/benchmarks/types.hpp" // Vecmem include(s) #include @@ -34,10 +36,10 @@ // Use the detray:: namespace implicitly. using namespace detray; -using test_algebra = test::algebra; +using bench_algebra = benchmarks::algebra; using trk_generator_t = - uniform_track_generator>; + uniform_track_generator>; constexpr unsigned int theta_steps{100u}; constexpr unsigned int phi_steps{100u}; @@ -47,12 +49,12 @@ void BM_INTERSECT_ALL(benchmark::State &state) { // Detector configuration vecmem::host_memory_resource host_mr; - toy_det_config toy_cfg{}; + toy_det_config toy_cfg{}; toy_cfg.n_edc_layers(7u); - auto [d, names] = build_toy_detector(host_mr, toy_cfg); + auto [d, names] = build_toy_detector(host_mr, toy_cfg); using detector_t = decltype(d); - using scalar_t = dscalar; + using scalar_t = dscalar; using sf_desc_t = typename detector_t::surface_type; detector_t::geometry_context geo_context; @@ -62,8 +64,8 @@ void BM_INTERSECT_ALL(benchmark::State &state) { std::size_t hits{0u}; std::size_t missed{0u}; std::size_t n_surfaces{0u}; - test::point3 origin{0.f, 0.f, 0.f}; - std::vector> intersections{}; + benchmarks::point3 origin{0.f, 0.f, 0.f}; + std::vector> intersections{}; // Iterate through uniformly distributed momentum directions auto trk_generator = trk_generator_t{}; diff --git a/tests/benchmarks/cpu/intersect_surfaces.cpp b/tests/benchmarks/cpu/intersect_surfaces.cpp index 6e495aaa96..1ac503a807 100644 --- a/tests/benchmarks/cpu/intersect_surfaces.cpp +++ b/tests/benchmarks/cpu/intersect_surfaces.cpp @@ -15,9 +15,12 @@ #include "detray/navigation/intersection/ray_intersector.hpp" #include "detray/tracks/ray.hpp" -// Detray test include(s). +// Detray benchmark include(s) +#include "detray/benchmarks/types.hpp" + +// Detray test include(s) +#include "detray/test/common/track_generators.hpp" #include "detray/test/utils/planes_along_direction.hpp" -#include "detray/test/utils/simulation/event_generator/track_generators.hpp" // Google Benchmark include(s) #include @@ -25,15 +28,15 @@ // Use the detray:: namespace implicitly. using namespace detray; -using test_algebra = test::algebra; +using bench_algebra = benchmarks::algebra; -using ray_generator_t = uniform_track_generator>; +using ray_generator_t = uniform_track_generator>; static const unsigned int theta_steps = 100u; static const unsigned int phi_steps = 100u; -static const dvector dists = {1.f, 2.f, 3.f, 4.f, 5.f, - 6.f, 7.f, 8.f, 9.f, 10.f}; +static const dvector dists = {1.f, 2.f, 3.f, 4.f, 5.f, + 6.f, 7.f, 8.f, 9.f, 10.f}; /// This benchmark runs intersection with the planar intersector void BM_INTERSECT_PLANES(benchmark::State &state) { @@ -42,8 +45,8 @@ void BM_INTERSECT_PLANES(benchmark::State &state) { unsigned int sfmiss = 0u; auto [plane_descs, transforms] = test::planes_along_direction( - dists, vector::normalize(test::vector3{1.f, 1.f, 1.f})); - constexpr mask rect{0u, 10.f, 20.f}; + dists, vector::normalize(benchmarks::vector3{1.f, 1.f, 1.f})); + constexpr mask rect{0u, 10.f, 20.f}; // Iterate through uniformly distributed momentum directions auto ray_generator = ray_generator_t{}; @@ -57,7 +60,7 @@ void BM_INTERSECT_PLANES(benchmark::State &state) { for (const auto ray : ray_generator) { for (const auto &desc : plane_descs) { - auto pi = ray_intersector{}; + auto pi = ray_intersector{}; auto is = pi(ray, desc, rect, transforms[desc.transform()]); benchmark::DoNotOptimize(sfhit); @@ -97,22 +100,22 @@ using mask_link_t = dtyped_index; using material_link_t = dtyped_index; using surface_desc_t = surface_descriptor; -using intersection_t = intersection2D; +using intersection_t = intersection2D; /// This benchmark runs intersection with the cylinder intersector void BM_INTERSECT_CYLINDERS(benchmark::State &state) { - using cylinder_mask = mask; + using cylinder_mask = mask; unsigned int sfhit = 0u; unsigned int sfmiss = 0u; dvector cylinders; - for (test::scalar r : dists) { + for (benchmarks::scalar r : dists) { cylinders.push_back(cylinder_mask{0u, r, -10.f, 10.f}); } - test::transform3 trf{}; + benchmarks::transform3 trf{}; mask_link_t mask_link{mask_ids::e_cylinder2, 0}; material_link_t material_link{material_ids::e_slab, 0}; @@ -131,7 +134,7 @@ void BM_INTERSECT_CYLINDERS(benchmark::State &state) { for (const auto ray : ray_generator) { for (const auto &cylinder : cylinders) { - auto ci = ray_intersector{}; + auto ci = ray_intersector{}; auto inters = ci(ray, sf_desc, cylinder, trf); benchmark::DoNotOptimize(sfhit); @@ -159,17 +162,17 @@ BENCHMARK(BM_INTERSECT_CYLINDERS) /// intersector void BM_INTERSECT_PORTAL_CYLINDERS(benchmark::State &state) { - using cylinder_mask = mask; + using cylinder_mask = mask; unsigned int sfhit = 0u; unsigned int sfmiss = 0u; dvector cylinders; - for (test::scalar r : dists) { + for (benchmarks::scalar r : dists) { cylinders.push_back(cylinder_mask{0u, r, -10.f, 10.f}); } - test::transform3 trf{}; + benchmarks::transform3 trf{}; mask_link_t mask_link{mask_ids::e_cylinder2, 0u}; material_link_t material_link{material_ids::e_slab, 0u}; @@ -189,7 +192,7 @@ void BM_INTERSECT_PORTAL_CYLINDERS(benchmark::State &state) { for (const auto &cylinder : cylinders) { auto cpi = - ray_intersector{}; + ray_intersector{}; auto is = cpi(ray, sf_desc, cylinder, trf); benchmark::DoNotOptimize(sfhit); @@ -216,14 +219,14 @@ void BM_INTERSECT_CONCENTRIC_CYLINDERS(benchmark::State &state) { unsigned int sfhit = 0u; unsigned int sfmiss = 0u; - using cylinder_mask = mask; + using cylinder_mask = mask; dvector cylinders; - for (test::scalar r : dists) { + for (benchmarks::scalar r : dists) { cylinders.push_back(cylinder_mask(0u, r, -10.f, 10.f)); } - test::transform3 trf{}; + benchmarks::transform3 trf{}; mask_link_t mask_link{mask_ids::e_conc_cylinder3, 0u}; material_link_t material_link{material_ids::e_slab, 0u}; @@ -240,7 +243,7 @@ void BM_INTERSECT_CONCENTRIC_CYLINDERS(benchmark::State &state) { for (const auto ray : ray_generator) { for (const auto &cylinder : cylinders) { - auto cci = ray_concentric_cylinder_intersector{}; + auto cci = ray_concentric_cylinder_intersector{}; auto is = cci(ray, sf_desc, cylinder, trf); benchmark::DoNotOptimize(sfhit); diff --git a/tests/benchmarks/cpu/intersectors.cpp b/tests/benchmarks/cpu/intersectors.cpp index c5d299b776..53eb5d51fa 100644 --- a/tests/benchmarks/cpu/intersectors.cpp +++ b/tests/benchmarks/cpu/intersectors.cpp @@ -20,10 +20,12 @@ #include "detray/navigation/intersection/ray_intersector.hpp" #include "detray/tracks/ray.hpp" -// Detray test include(s). +// Detray benchmark include(s) +#include "detray/benchmarks/types.hpp" + +// Detray test include(s) +#include "detray/test/common/track_generators.hpp" #include "detray/test/utils/planes_along_direction.hpp" -#include "detray/test/utils/simulation/event_generator/track_generators.hpp" -#include "detray/test/utils/types.hpp" // Google Benchmark include(s) #include @@ -38,12 +40,12 @@ static constexpr unsigned int phi_steps{2000u}; static constexpr unsigned int n_surfaces{16u}; /// Linear algebra implementation using SoA memory layout -using algebra_v = detray::vc_soa; +using algebra_v = detray::vc_soa; /// Linear algebra implementation using AoS memory layout -// using algebra_array = detray::array; -using algebra_vc_aos = detray::vc_aos; -// using algebra_eigen = detray::eigen; +// using algebra_array = detray::array; +using algebra_vc_aos = detray::vc_aos; +// using algebra_eigen = detray::eigen; using algebra_s = algebra_vc_aos; @@ -91,7 +93,7 @@ dvector> get_dists(std::size_t n) { using scalar_t = dscalar; - dvector dists; + dvector dists; for (std::size_t i = 1u; i <= n; ++i) { dists.push_back(static_cast(i)); diff --git a/tests/benchmarks/cpu/masks.cpp b/tests/benchmarks/cpu/masks.cpp index 3b8a03e7d4..8a99722b9a 100644 --- a/tests/benchmarks/cpu/masks.cpp +++ b/tests/benchmarks/cpu/masks.cpp @@ -16,8 +16,8 @@ #include "detray/geometry/shapes.hpp" #include "detray/navigation/intersection/intersection.hpp" -// Detray test include(s). -#include "detray/test/utils/types.hpp" +// Detray benchmark include(s) +#include "detray/benchmarks/types.hpp" // Google benchmark include(s). #include @@ -28,15 +28,15 @@ // Use the detray:: namespace implicitly. using namespace detray; -using test_algebra = test::algebra; -using point3 = test::point3; -using scalar = test::scalar; +using bench_algebra = benchmarks::algebra; +using point3 = benchmarks::point3; +using scalar = benchmarks::scalar; static constexpr unsigned int steps_x3{1000u}; static constexpr unsigned int steps_y3{1000u}; static constexpr unsigned int steps_z3{1000u}; -static const test::transform3 trf{}; +static const benchmarks::transform3 trf{}; // Tolerance applied to the mask static constexpr scalar tol{0.f}; @@ -44,7 +44,7 @@ static constexpr scalar tol{0.f}; // This runs a benchmark on a rectangle2D mask void BM_MASK_CUBOID_3D(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type cb(0u, 0.f, 0.f, 0.f, 3.f, 4.f, 1.f); constexpr scalar world{10.f}; @@ -96,7 +96,7 @@ BENCHMARK(BM_MASK_CUBOID_3D) // This runs a benchmark on a rectangle2D mask void BM_MASK_RECTANGLE_2D(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type r(0u, 3.f, 4.f); constexpr scalar world{10.f}; @@ -148,7 +148,7 @@ BENCHMARK(BM_MASK_RECTANGLE_2D) // This runs a benchmark on a trapezoid2D mask void BM_MASK_TRAPEZOID_2D(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type t{0u, 2.f, 3.f, 4.f, 1.f / (2.f * 4.f)}; constexpr scalar world{10.f}; @@ -200,7 +200,7 @@ BENCHMARK(BM_MASK_TRAPEZOID_2D) // This runs a benchmark on a ring2D mask (as disc) void BM_MASK_DISC_2D(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type r{0u, 0.f, 5.f}; constexpr scalar world{10.f}; @@ -252,7 +252,7 @@ BENCHMARK(BM_MASK_DISC_2D) // This runs a benchmark on a ring2D mask void BM_MASK_RING_2D(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type r{0u, 2.f, 5.f}; constexpr scalar world{10.f}; @@ -304,7 +304,7 @@ BENCHMARK(BM_MASK_RING_2D) // This runs a benchmark on a cylinder2D mask void BM_MASK_CYLINDER_3D(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type c{ 0u, 1.f, -constant::pi, 0.f, 3.f, constant::pi, 5.f}; @@ -358,7 +358,7 @@ BENCHMARK(BM_MASK_CYLINDER_3D) // This runs a benchmark on a cylinder2D mask void BM_MASK_CYLINDER_2D(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type c{0u, 3.f, 0.f, 5.f}; constexpr scalar world{10.f}; @@ -408,7 +408,7 @@ BENCHMARK(BM_MASK_CYLINDER_2D) // This runs a benchmark on a cylinder2D mask void BM_MASK_CONCENTRIC_CYLINDER_2D(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type c{0u, 3.f, 0.f, 5.f}; constexpr scalar world{10.f}; @@ -458,7 +458,7 @@ BENCHMARK(BM_MASK_CONCENTRIC_CYLINDER_2D) // This runs a benchmark on an annulus2D mask void BM_MASK_ANNULUS_2D(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type ann{0u, 2.5f, 5.f, -0.64299f, 4.13173f, 1.f, 0.5f, 0.f}; constexpr scalar world{10.f}; @@ -508,7 +508,7 @@ BENCHMARK(BM_MASK_ANNULUS_2D) // This runs a benchmark on a straw tube mask void BM_MASK_LINE_CIRCULAR(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type st{0u, 3.f, 5.f}; constexpr scalar world{10.f}; @@ -560,7 +560,7 @@ BENCHMARK(BM_MASK_LINE_CIRCULAR) // This runs a benchmark on a wire cell mask void BM_MASK_LINE_SQUARE(benchmark::State &state) { - using mask_type = mask; + using mask_type = mask; constexpr mask_type dcl{0u, 3.f, 5.f}; constexpr scalar world{10.f}; diff --git a/tests/benchmarks/cpu/propagation.cpp b/tests/benchmarks/cpu/propagation.cpp index c422726ed9..ba76b3b4e1 100644 --- a/tests/benchmarks/cpu/propagation.cpp +++ b/tests/benchmarks/cpu/propagation.cpp @@ -6,7 +6,6 @@ */ // Project include(s) -#include "detray/detectors/bfield.hpp" #include "detray/navigation/navigator.hpp" #include "detray/propagator/actors.hpp" #include "detray/propagator/rk_stepper.hpp" @@ -14,12 +13,13 @@ // Detray benchmark include(s) #include "detray/benchmarks/cpu/propagation_benchmark.hpp" +#include "detray/benchmarks/types.hpp" -// Detray test include(s). -#include "detray/test/utils/detectors/build_toy_detector.hpp" -#include "detray/test/utils/detectors/build_wire_chamber.hpp" -#include "detray/test/utils/simulation/event_generator/track_generators.hpp" -#include "detray/test/utils/types.hpp" +// Detray test include(s) +#include "detray/test/common/bfield.hpp" +#include "detray/test/common/build_toy_detector.hpp" +#include "detray/test/common/build_wire_chamber.hpp" +#include "detray/test/common/track_generators.hpp" // Vecmem include(s) #include @@ -32,24 +32,24 @@ using namespace detray; int main(int argc, char** argv) { - using toy_detector_t = detector; - using test_algebra = typename toy_detector_t::algebra_type; - using scalar = dscalar; - using vector3 = dvector3D; + using toy_detector_t = detector; + using bench_algebra = typename toy_detector_t::algebra_type; + using scalar = dscalar; + using vector3 = dvector3D; - using free_track_parameters_t = free_track_parameters; + using free_track_parameters_t = free_track_parameters; using uniform_gen_t = detail::random_numbers>; using track_generator_t = random_track_generator; using field_t = bfield::const_field_t; - using stepper_t = rk_stepper; + using stepper_t = rk_stepper; using empty_chain_t = actor_chain<>; using default_chain = - actor_chain, - pointwise_material_interactor, - parameter_resetter>; + actor_chain, + pointwise_material_interactor, + parameter_resetter>; vecmem::host_memory_resource host_mr; @@ -104,15 +104,15 @@ int main(int argc, char** argv) { &host_mr, n_tracks, trk_cfg); const auto [toy_det, names] = - build_toy_detector(host_mr, toy_cfg); + build_toy_detector(host_mr, toy_cfg); const auto [wire_chamber, _] = - build_wire_chamber(host_mr, wire_chamber_cfg); + build_wire_chamber(host_mr, wire_chamber_cfg); - auto bfield = bfield::create_const_field(B); + auto bfield = create_const_field(B); dtuple<> empty_state{}; - pointwise_material_interactor::state interactor_state{}; + pointwise_material_interactor::state interactor_state{}; auto actor_states = detail::make_tuple(interactor_state); diff --git a/tests/benchmarks/cuda/CMakeLists.txt b/tests/benchmarks/cuda/CMakeLists.txt index b8f19d9b5e..1c3f8bbb6f 100644 --- a/tests/benchmarks/cuda/CMakeLists.txt +++ b/tests/benchmarks/cuda/CMakeLists.txt @@ -25,7 +25,7 @@ endif() foreach(algebra ${algebra_plugins}) detray_add_executable(benchmark_cuda_propagation_${algebra} "propagation.cpp" - LINK_LIBRARIES detray::benchmark_cuda_${algebra} detray::core_${algebra} vecmem::cuda detray::test_utils + LINK_LIBRARIES detray::benchmark_cuda_${algebra} detray::core_${algebra} vecmem::cuda detray::test_common ) target_compile_definitions( diff --git a/tests/benchmarks/cuda/propagation.cpp b/tests/benchmarks/cuda/propagation.cpp index 219928154e..e11838c540 100644 --- a/tests/benchmarks/cuda/propagation.cpp +++ b/tests/benchmarks/cuda/propagation.cpp @@ -6,7 +6,6 @@ */ // Project include(s) -#include "detray/detectors/bfield.hpp" #include "detray/navigation/navigator.hpp" #include "detray/propagator/actors.hpp" #include "detray/propagator/rk_stepper.hpp" @@ -14,12 +13,13 @@ // Detray benchmark include(s) #include "detray/benchmarks/device/cuda/propagation_benchmark.hpp" +#include "detray/benchmarks/types.hpp" -// Detray test include(s). -#include "detray/test/utils/detectors/build_toy_detector.hpp" -#include "detray/test/utils/detectors/build_wire_chamber.hpp" -#include "detray/test/utils/simulation/event_generator/track_generators.hpp" -#include "detray/test/utils/types.hpp" +// Detray test include(s) +#include "detray/test/common/bfield.hpp" +#include "detray/test/common/build_toy_detector.hpp" +#include "detray/test/common/build_wire_chamber.hpp" +#include "detray/test/common/track_generators.hpp" // Vecmem include(s) #include @@ -33,12 +33,12 @@ using namespace detray; int main(int argc, char** argv) { - using toy_detector_t = detector; - using test_algebra = typename toy_detector_t::algebra_type; - using scalar = dscalar; - using vector3 = dvector3D; + using toy_detector_t = detector; + using bench_algebra = typename toy_detector_t::algebra_type; + using scalar = dscalar; + using vector3 = dvector3D; - using free_track_parameters_t = free_track_parameters; + using free_track_parameters_t = free_track_parameters; using uniform_gen_t = detail::random_numbers>; using track_generator_t = @@ -99,15 +99,15 @@ int main(int argc, char** argv) { &host_mr, n_tracks, trk_cfg, true); const auto [toy_det, names] = - build_toy_detector(host_mr, toy_cfg); + build_toy_detector(host_mr, toy_cfg); const auto [wire_chamber, _] = - build_wire_chamber(host_mr, wire_chamber_cfg); + build_wire_chamber(host_mr, wire_chamber_cfg); - auto bfield = bfield::create_const_field(B); + auto bfield = create_const_field(B); dtuple<> empty_state{}; - pointwise_material_interactor::state interactor_state{}; + pointwise_material_interactor::state interactor_state{}; auto actor_states = detail::make_tuple(interactor_state); @@ -121,7 +121,7 @@ int main(int argc, char** argv) { detray::benchmarks::register_benchmark< detray::benchmarks::cuda_propagation_bm, detray::benchmarks::cuda_propagator_type< - test::toy_metadata, field_bknd_t, + detray::benchmarks::toy_metadata, field_bknd_t, detray::benchmarks::default_chain>>( "TOY_DETECTOR_W_COV_TRANSPORT", bench_cfg, prop_cfg, toy_det, bfield, &actor_states, track_samples, n_tracks, &dev_mr); @@ -130,7 +130,8 @@ int main(int argc, char** argv) { detray::benchmarks::register_benchmark< detray::benchmarks::cuda_propagation_bm, detray::benchmarks::cuda_propagator_type< - test::toy_metadata, field_bknd_t, detray::benchmarks::empty_chain>>( + detray::benchmarks::toy_metadata, field_bknd_t, + detray::benchmarks::empty_chain>>( "TOY_DETECTOR", bench_cfg, prop_cfg, toy_det, bfield, &empty_state, track_samples, n_tracks, &dev_mr); @@ -138,7 +139,7 @@ int main(int argc, char** argv) { detray::benchmarks::register_benchmark< detray::benchmarks::cuda_propagation_bm, detray::benchmarks::cuda_propagator_type< - test::default_metadata, field_bknd_t, + detray::benchmarks::default_metadata, field_bknd_t, detray::benchmarks::default_chain>>( "WIRE_CHAMBER_W_COV_TRANSPORT", bench_cfg, prop_cfg, wire_chamber, bfield, &actor_states, track_samples, n_tracks, &dev_mr); @@ -147,7 +148,7 @@ int main(int argc, char** argv) { detray::benchmarks::register_benchmark< detray::benchmarks::cuda_propagation_bm, detray::benchmarks::cuda_propagator_type< - test::default_metadata, field_bknd_t, + detray::benchmarks::default_metadata, field_bknd_t, detray::benchmarks::empty_chain>>( "WIRE_CHAMBER", bench_cfg, prop_cfg, wire_chamber, bfield, &empty_state, track_samples, n_tracks, &dev_mr); diff --git a/tests/benchmarks/include/detray/benchmarks/device/cuda/CMakeLists.txt b/tests/benchmarks/include/detray/benchmarks/device/cuda/CMakeLists.txt index e7fe1adbc3..4970131df2 100644 --- a/tests/benchmarks/include/detray/benchmarks/device/cuda/CMakeLists.txt +++ b/tests/benchmarks/include/detray/benchmarks/device/cuda/CMakeLists.txt @@ -40,7 +40,7 @@ foreach(algebra ${algebra_plugins}) PUBLIC vecmem::cuda detray::benchmarks - detray::test_utils + detray::test_common detray::core_${algebra} ) endforeach() diff --git a/tests/benchmarks/include/detray/benchmarks/device/cuda/propagation_benchmark.cu b/tests/benchmarks/include/detray/benchmarks/device/cuda/propagation_benchmark.cu index ba45520ffd..6b23b17934 100644 --- a/tests/benchmarks/include/detray/benchmarks/device/cuda/propagation_benchmark.cu +++ b/tests/benchmarks/include/detray/benchmarks/device/cuda/propagation_benchmark.cu @@ -139,14 +139,14 @@ void run_propagation_kernel( cuda_propagator_type::actor_chain_type::state_tuple *); -DECLARE_PROPAGATION_BENCHMARK(test::default_metadata, empty_chain, +DECLARE_PROPAGATION_BENCHMARK(benchmarks::default_metadata, empty_chain, const_field_t, propagation_opt::e_unsync) -DECLARE_PROPAGATION_BENCHMARK(test::default_metadata, default_chain, +DECLARE_PROPAGATION_BENCHMARK(benchmarks::default_metadata, default_chain, const_field_t, propagation_opt::e_unsync) -DECLARE_PROPAGATION_BENCHMARK(test::toy_metadata, empty_chain, const_field_t, - propagation_opt::e_unsync) -DECLARE_PROPAGATION_BENCHMARK(test::toy_metadata, default_chain, const_field_t, - propagation_opt::e_unsync) +DECLARE_PROPAGATION_BENCHMARK(benchmarks::toy_metadata, empty_chain, + const_field_t, propagation_opt::e_unsync) +DECLARE_PROPAGATION_BENCHMARK(benchmarks::toy_metadata, default_chain, + const_field_t, propagation_opt::e_unsync) } // namespace detray::benchmarks diff --git a/tests/benchmarks/include/detray/benchmarks/device/cuda/propagation_benchmark.hpp b/tests/benchmarks/include/detray/benchmarks/device/cuda/propagation_benchmark.hpp index 10fe03e8b1..bd812a9da2 100644 --- a/tests/benchmarks/include/detray/benchmarks/device/cuda/propagation_benchmark.hpp +++ b/tests/benchmarks/include/detray/benchmarks/device/cuda/propagation_benchmark.hpp @@ -9,20 +9,20 @@ // Project include(s) #include "detray/definitions/algebra.hpp" -#include "detray/detectors/bfield.hpp" #include "detray/navigation/navigator.hpp" #include "detray/propagator/actors.hpp" #include "detray/propagator/propagator.hpp" #include "detray/propagator/rk_stepper.hpp" #include "detray/tracks/tracks.hpp" -// Detray test include(s). -#include "detray/test/utils/types.hpp" +// Detray test include(s) +#include "detray/test/common/bfield.hpp" // Detray benchmark include(s) #include "detray/benchmarks/benchmark_base.hpp" #include "detray/benchmarks/propagation_benchmark_config.hpp" #include "detray/benchmarks/propagation_benchmark_utils.hpp" +#include "detray/benchmarks/types.hpp" // Vecmem include(s) #include @@ -51,7 +51,7 @@ using default_chain = actor_chain, pointwise_material_interactor, parameter_resetter>; -using const_field_t = bfield::const_bknd_t; +using const_field_t = bfield::const_bknd_t; template class actor_chain_t> diff --git a/tests/benchmarks/include/detray/benchmarks/types.hpp b/tests/benchmarks/include/detray/benchmarks/types.hpp new file mode 100644 index 0000000000..01dc7ee04d --- /dev/null +++ b/tests/benchmarks/include/detray/benchmarks/types.hpp @@ -0,0 +1,46 @@ +/** Detray library, part of the ACTS project (R&D line) + * + * (c) 2020-2024 CERN for the benefit of the ACTS project + * + * Mozilla Public License Version 2.0 + */ + +#pragma once + +// Detray core include(s). +#include "detray/definitions/algebra.hpp" + +// Detray detector include(s) +#include "detray/detectors/default_metadata.hpp" +#include "detray/detectors/toy_metadata.hpp" + +namespace detray::benchmarks { + +// Select algebra-plugin to compile the test with +#if DETRAY_ALGEBRA_ARRAY +using algebra = detray::array; + +#elif DETRAY_ALGEBRA_EIGEN +using algebra = detray::eigen; + +#elif DETRAY_ALGEBRA_SMATRIX +using algebra = detray::smatrix; + +#elif DETRAY_ALGEBRA_VC_AOS +using algebra = detray::vc_aos; +#endif + +// Test algebra types +using scalar = dscalar; +using point2 = dpoint2D; +using point3 = dpoint3D; +using vector3 = dvector3D; +using transform3 = dtransform3D; +template +using matrix = dmatrix; + +// Test detector types +using default_metadata = detray::default_metadata; +using toy_metadata = detray::toy_metadata; + +} // namespace detray::benchmarks diff --git a/detectors/include/detray/detectors/bfield.hpp b/tests/include/detray/test/common/bfield.hpp similarity index 55% rename from detectors/include/detray/detectors/bfield.hpp rename to tests/include/detray/test/common/bfield.hpp index 18b11f0c1b..a0842a575b 100644 --- a/detectors/include/detray/detectors/bfield.hpp +++ b/tests/include/detray/test/common/bfield.hpp @@ -1,6 +1,6 @@ /** Detray library, part of the ACTS project (R&D line) * - * (c) 2023 CERN for the benefit of the ACTS project + * (c) 2023-2025 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -9,7 +9,7 @@ // Project include(s) #include "detray/definitions/algebra.hpp" -#include "detray/io/covfie/read_bfield.hpp" +#include "detray/io/utils/file_handle.hpp" // Covfie include(s) #include @@ -20,7 +20,15 @@ #include #include -namespace detray::bfield { +// System include(s) +#include +#include +#include +#include + +namespace detray { + +namespace bfield { /// Constant bfield (host and device) template @@ -47,19 +55,49 @@ using inhom_bknd_nn_t = covfie::backend::affine< template using inhom_field_t = covfie::field>; +} // namespace bfield + +/// @brief Function that reads the first 4 bytes of a potential bfield file and +/// checks that it contains data for a covfie field +inline bool check_covfie_file(const std::string& file_name) { + + // Open binary file + io::file_handle file{file_name, std::ios_base::in | std::ios_base::binary}; + + // See "covfie/lib/core/utility/binary_io.hpp" + std::uint32_t hdr = covfie::utility::read_binary(*file); + + // Compare to magic bytes + return (hdr == covfie::utility::MAGIC_HEADER); +} + +/// @brief function that reads a covfie field from file +template +inline bfield_t read_bfield(const std::string& file_name) { + + if (!check_covfie_file(file_name)) { + throw std::runtime_error("Not a valid covfie file: " + file_name); + } + + // Open binary file + io::file_handle file{file_name, std::ios_base::in | std::ios_base::binary}; + + return bfield_t(*file); +} + /// @returns a constant covfie field constructed from the field vector @param B template -inline const_field_t create_const_field(const vector3_t &B) { - return const_field_t{covfie::make_parameter_pack( - typename const_bknd_t::configuration_t{B[0], B[1], B[2]})}; +inline bfield::const_field_t create_const_field(const vector3_t& B) { + return bfield::const_field_t{covfie::make_parameter_pack( + typename bfield::const_bknd_t::configuration_t{B[0], B[1], B[2]})}; } /// @returns a constant covfie field constructed from the field vector @param B template -inline inhom_field_t create_inhom_field() { - return io::read_bfield>( +inline bfield::inhom_field_t create_inhom_field() { + return read_bfield>( !std::getenv("DETRAY_BFIELD_FILE") ? "" : std::getenv("DETRAY_BFIELD_FILE")); } -} // namespace detray::bfield +} // namespace detray diff --git a/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp b/tests/include/detray/test/common/build_telescope_detector.hpp similarity index 99% rename from tests/include/detray/test/utils/detectors/build_telescope_detector.hpp rename to tests/include/detray/test/common/build_telescope_detector.hpp index 4052612811..fb1e00c8b9 100644 --- a/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp +++ b/tests/include/detray/test/common/build_telescope_detector.hpp @@ -23,7 +23,7 @@ #include "detray/utils/consistency_checker.hpp" // Detray test include(s) -#include "detray/test/utils/detectors/factories/telescope_generator.hpp" +#include "detray/test/common/factories/telescope_generator.hpp" // Vecmem include(s) #include diff --git a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp b/tests/include/detray/test/common/build_toy_detector.hpp similarity index 99% rename from tests/include/detray/test/utils/detectors/build_toy_detector.hpp rename to tests/include/detray/test/common/build_toy_detector.hpp index 70eb6909f5..df24d02eb2 100644 --- a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp +++ b/tests/include/detray/test/common/build_toy_detector.hpp @@ -29,8 +29,8 @@ #include "detray/utils/ranges.hpp" // Detray test include(s) -#include "detray/test/utils/detectors/factories/barrel_generator.hpp" -#include "detray/test/utils/detectors/factories/endcap_generator.hpp" +#include "detray/test/common/factories/barrel_generator.hpp" +#include "detray/test/common/factories/endcap_generator.hpp" // Vecmem include(s) #include diff --git a/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp b/tests/include/detray/test/common/build_wire_chamber.hpp similarity index 99% rename from tests/include/detray/test/utils/detectors/build_wire_chamber.hpp rename to tests/include/detray/test/common/build_wire_chamber.hpp index 3a26fc3b5d..e2c4cccb1e 100644 --- a/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp +++ b/tests/include/detray/test/common/build_wire_chamber.hpp @@ -23,7 +23,7 @@ #include "detray/utils/consistency_checker.hpp" // Detray test include(s) -#include "detray/test/utils/detectors/factories/wire_layer_generator.hpp" +#include "detray/test/common/factories/wire_layer_generator.hpp" // Vecmem include(s) #include diff --git a/tests/include/detray/test/utils/simulation/event_generator/random_numbers.hpp b/tests/include/detray/test/common/event_generator/random_numbers.hpp similarity index 100% rename from tests/include/detray/test/utils/simulation/event_generator/random_numbers.hpp rename to tests/include/detray/test/common/event_generator/random_numbers.hpp diff --git a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp b/tests/include/detray/test/common/event_generator/random_track_generator.hpp similarity index 98% rename from tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp rename to tests/include/detray/test/common/event_generator/random_track_generator.hpp index 975e808247..4a5301595e 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp +++ b/tests/include/detray/test/common/event_generator/random_track_generator.hpp @@ -16,7 +16,7 @@ #include "detray/utils/ranges/ranges.hpp" // Detray test include(s) -#include "detray/test/utils/simulation/event_generator/random_track_generator_config.hpp" +#include "detray/test/common/event_generator/random_track_generator_config.hpp" // System include(s) #include diff --git a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp b/tests/include/detray/test/common/event_generator/random_track_generator_config.hpp similarity index 99% rename from tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp rename to tests/include/detray/test/common/event_generator/random_track_generator_config.hpp index a50110b4cd..f928a5a8b8 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp +++ b/tests/include/detray/test/common/event_generator/random_track_generator_config.hpp @@ -14,7 +14,7 @@ #include "detray/definitions/units.hpp" // Detray test include(s) -#include "detray/test/utils/simulation/event_generator/random_numbers.hpp" +#include "detray/test/common/event_generator/random_numbers.hpp" // System include(s) #include diff --git a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp b/tests/include/detray/test/common/event_generator/uniform_track_generator.hpp similarity index 99% rename from tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp rename to tests/include/detray/test/common/event_generator/uniform_track_generator.hpp index 8464f832e1..8d92ddaf9d 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp +++ b/tests/include/detray/test/common/event_generator/uniform_track_generator.hpp @@ -16,7 +16,7 @@ #include "detray/utils/ranges/ranges.hpp" // Detray test include(s) -#include "detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp" +#include "detray/test/common/event_generator/uniform_track_generator_config.hpp" // System include(s) #include diff --git a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp b/tests/include/detray/test/common/event_generator/uniform_track_generator_config.hpp similarity index 99% rename from tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp rename to tests/include/detray/test/common/event_generator/uniform_track_generator_config.hpp index 97e6431eb8..70365f5a38 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp +++ b/tests/include/detray/test/common/event_generator/uniform_track_generator_config.hpp @@ -13,7 +13,7 @@ #include "detray/definitions/units.hpp" // Detray test include(s) -#include "detray/test/utils/simulation/event_generator/random_numbers.hpp" +#include "detray/test/common/event_generator/random_numbers.hpp" // System include(s) #include diff --git a/tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp b/tests/include/detray/test/common/factories/barrel_generator.hpp similarity index 100% rename from tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp rename to tests/include/detray/test/common/factories/barrel_generator.hpp diff --git a/tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp b/tests/include/detray/test/common/factories/endcap_generator.hpp similarity index 100% rename from tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp rename to tests/include/detray/test/common/factories/endcap_generator.hpp diff --git a/tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp b/tests/include/detray/test/common/factories/telescope_generator.hpp similarity index 100% rename from tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp rename to tests/include/detray/test/common/factories/telescope_generator.hpp diff --git a/tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp b/tests/include/detray/test/common/factories/wire_layer_generator.hpp similarity index 100% rename from tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp rename to tests/include/detray/test/common/factories/wire_layer_generator.hpp diff --git a/tests/include/detray/test/common/test_configuration.hpp b/tests/include/detray/test/common/test_configuration.hpp new file mode 100644 index 0000000000..88099e05cc --- /dev/null +++ b/tests/include/detray/test/common/test_configuration.hpp @@ -0,0 +1,67 @@ +/** Detray library, part of the ACTS project (R&D line) + * + * (c) 2025 CERN for the benefit of the ACTS project + * + * Mozilla Public License Version 2.0 + */ + +#pragma once + +// Project include(s) +#include "detray/propagator/propagation_config.hpp" + +// System include(s) +#include +#include + +namespace detray::test { + +/// Test configuration type +template +struct configuration { + /// General testing + /// @{ + /// Tolerance to compare two floating point values + scalar_t m_tolerance{std::numeric_limits::epsilon()}; + /// Shorthand for infinity + scalar_t inf{std::numeric_limits::infinity()}; + /// Shorthand for the floating point epsilon + scalar_t epsilon{std::numeric_limits::epsilon()}; + /// @} + + /// Propagation + /// @{ + propagation::config m_prop_cfg{}; + /// @} + + /// Setters + /// @{ + configuration& tol(scalar_t t) { + m_tolerance = t; + return *this; + } + /// @} + + /// Getters + /// @{ + scalar_t tol() const { return m_tolerance; } + propagation::config& propagation() { return m_prop_cfg; } + const propagation::config& propagation() const { return m_prop_cfg; } + /// @} + + /// Print configuration + std::ostream& operator<<(std::ostream& os) { + os << " -> test tolerance: \t " << tol() << std::endl; + os << " -> trk path limit: \t " << propagation().stepping.path_limit + << std::endl; + os << " -> overstepping tol:\t " + << propagation().navigation.overstep_tolerance << std::endl; + os << " -> step constraint: \t " + << propagation().stepping.step_constraint << std::endl; + os << std::endl; + + return os; + } +}; + +} // namespace detray::test diff --git a/tests/include/detray/test/utils/simulation/event_generator/track_generators.hpp b/tests/include/detray/test/common/track_generators.hpp similarity index 54% rename from tests/include/detray/test/utils/simulation/event_generator/track_generators.hpp rename to tests/include/detray/test/common/track_generators.hpp index b637fc2dc4..76bfbcf750 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/track_generators.hpp +++ b/tests/include/detray/test/common/track_generators.hpp @@ -8,5 +8,5 @@ #pragma once // Detray test include(s) -#include "detray/test/utils/simulation/event_generator/random_track_generator.hpp" -#include "detray/test/utils/simulation/event_generator/uniform_track_generator.hpp" +#include "detray/test/common/event_generator/random_track_generator.hpp" +#include "detray/test/common/event_generator/uniform_track_generator.hpp" diff --git a/tests/include/detray/test/cpu/CMakeLists.txt b/tests/include/detray/test/cpu/CMakeLists.txt index 0168d4e9d2..c0ec2ce8c4 100644 --- a/tests/include/detray/test/cpu/CMakeLists.txt +++ b/tests/include/detray/test/cpu/CMakeLists.txt @@ -4,7 +4,7 @@ # # Mozilla Public License Version 2.0 -# Set the CUDA build flags. +# Set the CPU build flags. include(detray-compiler-options-cpp) # Set up a test library, which the "new style" benchmarks and tests could use. diff --git a/tests/include/detray/test/cpu/detector_consistency.hpp b/tests/include/detray/test/cpu/detector_consistency.hpp index 521f8fa04b..8c3c7742c6 100644 --- a/tests/include/detray/test/cpu/detector_consistency.hpp +++ b/tests/include/detray/test/cpu/detector_consistency.hpp @@ -11,8 +11,8 @@ #include "detray/navigation/volume_graph.hpp" #include "detray/utils/consistency_checker.hpp" -// Detray test include(s). -#include "detray/test/common/fixture_base.hpp" +// Detray test include(s) +#include "detray/test/framework/fixture_base.hpp" #include "detray/test/utils/hash_tree.hpp" // System include(s) @@ -59,7 +59,7 @@ class consistency_check : public detray::test::fixture_base<> { explicit consistency_check( const detector_t &det, const typename detector_t::name_map &names, const config_t &cfg = {}, - const typename detector_t::geometry_context gctx = {}) + const typename detector_t::geometry_context &gctx = {}) : m_cfg{cfg}, m_gctx{gctx}, m_det{det}, m_names{names} {} /// Run the consistency check diff --git a/tests/include/detray/test/cpu/detector_scan.hpp b/tests/include/detray/test/cpu/detector_scan.hpp index 2bdad98ab2..ce381eb4f0 100644 --- a/tests/include/detray/test/cpu/detector_scan.hpp +++ b/tests/include/detray/test/cpu/detector_scan.hpp @@ -14,12 +14,12 @@ // Detray IO inlcude(s) #include "detray/io/utils/create_path.hpp" -// Detray test include(s). -#include "detray/test/common/detail/whiteboard.hpp" -#include "detray/test/common/detector_scan_config.hpp" -#include "detray/test/common/fixture_base.hpp" -#include "detray/test/utils/simulation/event_generator/track_generators.hpp" -#include "detray/test/utils/types.hpp" +// Detray test include(s) +#include "detray/test/common/track_generators.hpp" +#include "detray/test/framework/fixture_base.hpp" +#include "detray/test/framework/types.hpp" +#include "detray/test/framework/whiteboard.hpp" +#include "detray/test/validation/detector_scan_config.hpp" #include "detray/test/validation/detector_scan_utils.hpp" #include "detray/test/validation/detector_scanner.hpp" @@ -54,13 +54,23 @@ class detector_scan : public test::fixture_base<> { public: using fixture_type = test::fixture_base<>; - using config = detector_scan_config; + using config = detector_scan_config; explicit detector_scan( const detector_t &det, const typename detector_t::name_map &names, - const config &cfg = {}, + const config &cfg = {}, std::shared_ptr wb = nullptr, const typename detector_t::geometry_context gctx = {}) - : m_cfg{cfg}, m_gctx{gctx}, m_det{det}, m_names{names} {} + : m_cfg{cfg}, + m_gctx{gctx}, + m_det{det}, + m_names{names}, + m_whiteboard{std::move(wb)} { + + if (!m_whiteboard) { + throw std::invalid_argument("No white board was passed to " + + m_cfg.name()); + } + } /// Run the detector scan void TestBody() override { @@ -84,7 +94,7 @@ class detector_scan : public test::fixture_base<> { const std::size_t n_helices = fill_scan_data(); auto &detector_scan_traces = - m_cfg.whiteboard()->template get>( + m_whiteboard->template get>( m_cfg.name()); const std::string det_name{m_det.name(m_names)}; @@ -239,7 +249,7 @@ class detector_scan : public test::fixture_base<> { << " intersection traces to whiteboard" << std::endl; // Move the data to the whiteboard - m_cfg.whiteboard()->add(m_cfg.name(), std::move(intersection_traces)); + m_whiteboard->add(m_cfg.name(), std::move(intersection_traces)); return n_helices; } @@ -266,6 +276,8 @@ class detector_scan : public test::fixture_base<> { const detector_t &m_det; /// Volume names const typename detector_t::name_map &m_names; + /// Whiteboard to pin data + std::shared_ptr m_whiteboard{nullptr}; }; template diff --git a/tests/include/detray/test/cpu/material_scan.hpp b/tests/include/detray/test/cpu/material_scan.hpp index 24ff67c88c..b2c09674a2 100644 --- a/tests/include/detray/test/cpu/material_scan.hpp +++ b/tests/include/detray/test/cpu/material_scan.hpp @@ -15,16 +15,17 @@ #include "detray/io/utils/file_handle.hpp" // Detray test include(s) -#include "detray/test/common/detail/whiteboard.hpp" -#include "detray/test/common/fixture_base.hpp" -#include "detray/test/utils/simulation/event_generator/track_generators.hpp" -#include "detray/test/utils/types.hpp" +#include "detray/test/common/track_generators.hpp" +#include "detray/test/framework/fixture_base.hpp" +#include "detray/test/framework/types.hpp" +#include "detray/test/framework/whiteboard.hpp" #include "detray/test/validation/detector_scanner.hpp" #include "detray/test/validation/material_validation_utils.hpp" // System include(s) #include #include +#include #include namespace detray::test { @@ -48,8 +49,6 @@ class material_scan : public test::fixture_base<> { using trk_gen_config_t = typename track_generator_t::configuration; std::string m_name{"material_scan"}; - /// Save results for later use in downstream tests - std::shared_ptr m_white_board; trk_gen_config_t m_trk_gen_cfg{}; /// Getters @@ -59,10 +58,6 @@ class material_scan : public test::fixture_base<> { const trk_gen_config_t &track_generator() const { return m_trk_gen_cfg; } - std::shared_ptr whiteboard() { return m_white_board; } - std::shared_ptr whiteboard() const { - return m_white_board; - } /// @} /// Setters @@ -71,26 +66,22 @@ class material_scan : public test::fixture_base<> { m_name = n; return *this; } - config &whiteboard(std::shared_ptr w_board) { - if (!w_board) { - throw std::invalid_argument( - "Material scan: Not a valid whiteboard instance"); - } - m_white_board = std::move(w_board); - return *this; - } /// @} }; explicit material_scan( const detector_t &det, const typename detector_t::name_map &names, - const config &cfg = {}, + const config &cfg = {}, std::shared_ptr wb = nullptr, const typename detector_t::geometry_context &gctx = {}) - : m_cfg{cfg}, m_gctx{gctx}, m_det{det}, m_names{names} { + : m_cfg{cfg}, + m_gctx{gctx}, + m_det{det}, + m_names{names}, + m_whiteboard{std::move(wb)} { - if (!m_cfg.whiteboard()) { + if (!m_whiteboard) { throw std::invalid_argument("No white board was passed to " + - m_cfg.name() + " test"); + m_cfg.name()); } } @@ -220,9 +211,9 @@ class material_scan : public test::fixture_base<> { material_validator::write_material(coll_name + ".csv", mat_records); // Pin data to whiteboard - m_cfg.whiteboard()->add(coll_name, std::move(mat_records)); - m_cfg.whiteboard()->add(m_det.name(m_names) + "_material_scan_tracks", - std::move(tracks)); + m_whiteboard->add(coll_name, std::move(mat_records)); + m_whiteboard->add(m_det.name(m_names) + "_material_scan_tracks", + std::move(tracks)); } private: @@ -234,6 +225,8 @@ class material_scan : public test::fixture_base<> { const detector_t &m_det; /// Volume names const typename detector_t::name_map &m_names; + /// Whiteboard to pin data + std::shared_ptr m_whiteboard{nullptr}; }; } // namespace detray::test diff --git a/tests/include/detray/test/cpu/material_validation.hpp b/tests/include/detray/test/cpu/material_validation.hpp index 2953a7acc3..5e7605fa3e 100644 --- a/tests/include/detray/test/cpu/material_validation.hpp +++ b/tests/include/detray/test/cpu/material_validation.hpp @@ -13,8 +13,9 @@ #include "detray/utils/ranges.hpp" // Detray test include(s) -#include "detray/test/common/fixture_base.hpp" -#include "detray/test/common/material_validation_config.hpp" +#include "detray/test/framework/fixture_base.hpp" +#include "detray/test/framework/whiteboard.hpp" +#include "detray/test/validation/material_validation_config.hpp" #include "detray/test/validation/material_validation_utils.hpp" // Vecmem include(s) @@ -23,6 +24,7 @@ // System include(s) #include #include +#include #include #include #include @@ -87,15 +89,19 @@ class material_validation_impl : public test::fixture_base<> { public: using fixture_type = test::fixture_base<>; - using config = detray::test::material_validation_config; + using config = detray::test::material_validation_config; explicit material_validation_impl( const detector_t &det, const typename detector_t::name_map &names, - const config &cfg = {}, + const config &cfg = {}, std::shared_ptr wb = nullptr, const typename detector_t::geometry_context gctx = {}) - : m_cfg{cfg}, m_gctx{gctx}, m_det{det}, m_names{names} { + : m_cfg{cfg}, + m_gctx{gctx}, + m_det{det}, + m_names{names}, + m_whiteboard{std::move(wb)} { - if (!m_cfg.whiteboard()) { + if (!m_whiteboard) { throw std::invalid_argument("No white board was passed to " + m_cfg.name() + " test"); } @@ -105,12 +111,12 @@ class material_validation_impl : public test::fixture_base<> { m_track_data_name = m_det.name(m_names) + "_material_scan_tracks"; // Check that data is available in memory - if (!m_cfg.whiteboard()->exists(m_scan_data_name)) { + if (!m_whiteboard->exists(m_scan_data_name)) { throw std::invalid_argument( "Material validation: Could not find scan data on whiteboard." "Please run material scan first."); } - if (!m_cfg.whiteboard()->exists(m_track_data_name)) { + if (!m_whiteboard->exists(m_track_data_name)) { throw std::invalid_argument( "Material validation: Could not find track data on whiteboard." "Please run material scan first."); @@ -123,11 +129,11 @@ class material_validation_impl : public test::fixture_base<> { // Fetch the input data const auto &tracks = - m_cfg.whiteboard()->template get>( + m_whiteboard->template get>( m_track_data_name); const auto &truth_mat_records = - m_cfg.whiteboard()->template get>( + m_whiteboard->template get>( m_scan_data_name); std::cout << "\nINFO: Running material validation on: " @@ -222,6 +228,8 @@ class material_validation_impl : public test::fixture_base<> { const detector_t &m_det; /// Volume names const typename detector_t::name_map &m_names; + /// Whiteboard to pin data + std::shared_ptr m_whiteboard{nullptr}; }; template diff --git a/tests/include/detray/test/cpu/navigation_validation.hpp b/tests/include/detray/test/cpu/navigation_validation.hpp index c7d4b7a3de..3ec1d33fe5 100644 --- a/tests/include/detray/test/cpu/navigation_validation.hpp +++ b/tests/include/detray/test/cpu/navigation_validation.hpp @@ -8,21 +8,23 @@ #pragma once // Project include(s) -#include "detray/detectors/bfield.hpp" #include "detray/propagator/line_stepper.hpp" #include "detray/propagator/rk_stepper.hpp" #include "detray/tracks/ray.hpp" #include "detray/tracks/tracks.hpp" // Detray test include(s) -#include "detray/test/common/fixture_base.hpp" -#include "detray/test/common/navigation_validation_config.hpp" +#include "detray/test/common/bfield.hpp" +#include "detray/test/framework/fixture_base.hpp" +#include "detray/test/framework/whiteboard.hpp" #include "detray/test/validation/detector_scan_utils.hpp" #include "detray/test/validation/material_validation_utils.hpp" +#include "detray/test/validation/navigation_validation_config.hpp" #include "detray/test/validation/navigation_validation_utils.hpp" // System include(s) #include +#include #include namespace detray::test { @@ -47,15 +49,19 @@ class navigation_validation : public test::fixture_base<> { public: using fixture_type = test::fixture_base<>; - using config = navigation_validation_config; + using config = navigation_validation_config; explicit navigation_validation( const detector_t &det, const typename detector_t::name_map &names, - const config &cfg = {}, + const config &cfg = {}, std::shared_ptr wb = nullptr, const typename detector_t::geometry_context gctx = {}) - : m_cfg{cfg}, m_gctx{gctx}, m_det{det}, m_names{names} { + : m_cfg{cfg}, + m_gctx{gctx}, + m_det{det}, + m_names{names}, + m_whiteboard{std::move(wb)} { - if (!m_cfg.whiteboard()) { + if (!m_whiteboard) { throw std::invalid_argument("No white board was passed to " + m_cfg.name() + " test"); } @@ -87,7 +93,7 @@ class navigation_validation : public test::fixture_base<> { bfield_t b_field{}; if constexpr (!k_use_rays) { - b_field = bfield::create_const_field(m_cfg.B_vector()); + b_field = create_const_field(m_cfg.B_vector()); } // Use ray or helix @@ -107,12 +113,12 @@ class navigation_validation : public test::fixture_base<> { navigation_validator::surface_stats n_miss_truth{}; std::cout << "\nINFO: Fetching data from white board..." << std::endl; - if (!m_cfg.whiteboard()->exists(truth_data_name)) { + if (!m_whiteboard->exists(truth_data_name)) { throw std::runtime_error( "White board is empty! Please run detector scan first"); } auto &truth_traces = - m_cfg.whiteboard()->template get>( + m_whiteboard->template get>( truth_data_name); ASSERT_EQ(m_cfg.n_tracks(), truth_traces.size()); @@ -333,6 +339,8 @@ class navigation_validation : public test::fixture_base<> { const detector_t &m_det; /// Volume names const typename detector_t::name_map &m_names; + /// Whiteboard to pin data + std::shared_ptr m_whiteboard{nullptr}; }; template diff --git a/tests/include/detray/test/cpu/toy_detector_test.hpp b/tests/include/detray/test/cpu/toy_detector_test.hpp index 50553f9cc2..a27d6bdfc1 100644 --- a/tests/include/detray/test/cpu/toy_detector_test.hpp +++ b/tests/include/detray/test/cpu/toy_detector_test.hpp @@ -13,8 +13,8 @@ #include "detray/utils/consistency_checker.hpp" // Detray test include(s) -#include "detray/test/utils/detectors/build_toy_detector.hpp" -#include "detray/test/utils/types.hpp" +#include "detray/test/common/build_toy_detector.hpp" +#include "detray/test/framework/types.hpp" // GTest include(s) #include diff --git a/tests/include/detray/test/device/CMakeLists.txt b/tests/include/detray/test/device/CMakeLists.txt index 9359307cb5..b511b67d1d 100644 --- a/tests/include/detray/test/device/CMakeLists.txt +++ b/tests/include/detray/test/device/CMakeLists.txt @@ -10,7 +10,11 @@ add_library(detray::test_device ALIAS detray_test_device) target_link_libraries( detray_test_device - INTERFACE detray::core_array detray::test_common detray::test_utils + INTERFACE + detray::core_array + detray::test_framework + detray::test_utils + detray::validation_utils ) if(DETRAY_BUILD_CUDA) diff --git a/tests/include/detray/test/device/cuda/material_validation.hpp b/tests/include/detray/test/device/cuda/material_validation.hpp index 4335ec746a..64ccf1bf7f 100644 --- a/tests/include/detray/test/device/cuda/material_validation.hpp +++ b/tests/include/detray/test/device/cuda/material_validation.hpp @@ -12,7 +12,6 @@ #include "detray/tracks/tracks.hpp" // Detray test include(s) -#include "detray/test/common/material_validation_config.hpp" #include "detray/test/cpu/material_validation.hpp" #include "detray/test/validation/material_validation_utils.hpp" diff --git a/tests/include/detray/test/device/cuda/navigation_validation.hpp b/tests/include/detray/test/device/cuda/navigation_validation.hpp index b7e7e2ea06..df31eb3885 100644 --- a/tests/include/detray/test/device/cuda/navigation_validation.hpp +++ b/tests/include/detray/test/device/cuda/navigation_validation.hpp @@ -10,19 +10,20 @@ // Project include(s) #include "detray/core/detector.hpp" #include "detray/definitions/pdg_particle.hpp" -#include "detray/detectors/bfield.hpp" #include "detray/propagator/line_stepper.hpp" #include "detray/propagator/rk_stepper.hpp" #include "detray/tracks/ray.hpp" #include "detray/tracks/tracks.hpp" // Detray test include(s) -#include "detray/test/common/fixture_base.hpp" -#include "detray/test/common/navigation_validation_config.hpp" +#include "detray/test/common/bfield.hpp" +#include "detray/test/framework/fixture_base.hpp" +#include "detray/test/framework/whiteboard.hpp" #include "detray/test/utils/inspectors.hpp" #include "detray/test/validation/detector_scan_utils.hpp" #include "detray/test/validation/detector_scanner.hpp" #include "detray/test/validation/material_validation_utils.hpp" +#include "detray/test/validation/navigation_validation_config.hpp" #include "detray/test/validation/navigation_validation_utils.hpp" // Vecmem include(s) @@ -32,6 +33,7 @@ #include // System include(s) +#include #include namespace detray::cuda { @@ -164,15 +166,19 @@ class navigation_validation : public test::fixture_base<> { public: using fixture_type = test::fixture_base<>; - using config = detray::test::navigation_validation_config; + using config = detray::test::navigation_validation_config; explicit navigation_validation( const detector_t &det, const typename detector_t::name_map &names, - const config &cfg = {}, + const config &cfg = {}, std::shared_ptr wb = nullptr, const typename detector_t::geometry_context gctx = {}) - : m_cfg{cfg}, m_gctx{gctx}, m_det{det}, m_names{names} { + : m_cfg{cfg}, + m_gctx{gctx}, + m_det{det}, + m_names{names}, + m_whiteboard{wb} { - if (!m_cfg.whiteboard()) { + if (!m_whiteboard) { throw std::invalid_argument("No white board was passed to " + m_cfg.name() + " test"); } @@ -183,12 +189,12 @@ class navigation_validation : public test::fixture_base<> { : det_name + "_helix_scan_for_cuda"; // Pin the data onto the whiteboard - if (!m_cfg.whiteboard()->exists(m_truth_data_name) && + if (!m_whiteboard->exists(m_truth_data_name) && io::file_exists(m_cfg.intersection_file()) && io::file_exists(m_cfg.track_param_file())) { // Name clash: Choose alternative name - if (m_cfg.whiteboard()->exists(m_truth_data_name)) { + if (m_whiteboard->exists(m_truth_data_name)) { m_truth_data_name = io::alt_file_name(m_truth_data_name); } @@ -201,9 +207,9 @@ class navigation_validation : public test::fixture_base<> { m_cfg.track_param_file(), intersection_traces); - m_cfg.whiteboard()->add(m_truth_data_name, - std::move(intersection_traces)); - } else if (m_cfg.whiteboard()->exists(m_truth_data_name)) { + m_whiteboard->add(m_truth_data_name, + std::move(intersection_traces)); + } else if (m_whiteboard->exists(m_truth_data_name)) { std::cout << "\nINFO: Fetching data from white board..." << std::endl; } else { @@ -212,7 +218,7 @@ class navigation_validation : public test::fixture_base<> { } // Check that data is ready - if (!m_cfg.whiteboard()->exists(m_truth_data_name)) { + if (!m_whiteboard->exists(m_truth_data_name)) { throw std::invalid_argument( "Data for navigation check is not on the whiteboard"); } @@ -236,12 +242,12 @@ class navigation_validation : public test::fixture_base<> { bfield_t b_field{}; if constexpr (!k_use_rays) { - b_field = bfield::create_const_field(m_cfg.B_vector()); + b_field = create_const_field(m_cfg.B_vector()); } // Fetch the truth data auto &truth_intersection_traces = - m_cfg.whiteboard()->template get>( + m_whiteboard->template get>( m_truth_data_name); ASSERT_EQ(m_cfg.n_tracks(), truth_intersection_traces.size()); @@ -463,6 +469,8 @@ class navigation_validation : public test::fixture_base<> { const detector_t &m_det; /// Volume names const typename detector_t::name_map &m_names; + /// Whiteboard to pin data + std::shared_ptr m_whiteboard{nullptr}; }; template diff --git a/tests/include/detray/test/device/propagator_test.hpp b/tests/include/detray/test/device/propagator_test.hpp index 38c7d5f7d2..73f173751d 100644 --- a/tests/include/detray/test/device/propagator_test.hpp +++ b/tests/include/detray/test/device/propagator_test.hpp @@ -18,10 +18,10 @@ #include "detray/tracks/tracks.hpp" // Detray test include(s) +#include "detray/test/common/track_generators.hpp" +#include "detray/test/framework/types.hpp" #include "detray/test/utils/inspectors.hpp" -#include "detray/test/utils/simulation/event_generator/track_generators.hpp" -#include "detray/test/utils/types.hpp" -#include "detray/test/validation/step_tracer.hpp" +#include "detray/test/utils/step_tracer.hpp" // Vecmem include(s) #include diff --git a/tests/include/detray/test/common/assert.hpp b/tests/include/detray/test/framework/assert.hpp similarity index 100% rename from tests/include/detray/test/common/assert.hpp rename to tests/include/detray/test/framework/assert.hpp diff --git a/tests/include/detray/test/common/fixture_base.hpp b/tests/include/detray/test/framework/fixture_base.hpp similarity index 52% rename from tests/include/detray/test/common/fixture_base.hpp rename to tests/include/detray/test/framework/fixture_base.hpp index 61db29dd9d..f029b29680 100644 --- a/tests/include/detray/test/common/fixture_base.hpp +++ b/tests/include/detray/test/framework/fixture_base.hpp @@ -12,8 +12,9 @@ #include "detray/definitions/units.hpp" #include "detray/propagator/propagator.hpp" -// Detray test include(s). -#include "detray/test/utils/types.hpp" +// Detray test include(s) +#include "detray/test/common/test_configuration.hpp" +#include "detray/test/framework/types.hpp" // GTest include(s) #include @@ -39,52 +40,7 @@ class fixture_base : public scope { using transform3 = test::transform3; /// @} - /// Local configuration type - struct configuration { - /// General testing - /// @{ - /// Tolerance to compare two floating point values - scalar m_tolerance{std::numeric_limits::epsilon()}; - /// Shorthand for infinity - scalar inf{std::numeric_limits::infinity()}; - /// Shorthand for the floating point epsilon - scalar epsilon{std::numeric_limits::epsilon()}; - /// @} - - /// Propagation - /// @{ - propagation::config m_prop_cfg{}; - /// @} - - /// Setters - /// @{ - configuration& tol(scalar t) { - m_tolerance = t; - return *this; - } - /// @} - - /// Getters - /// @{ - scalar tol() const { return m_tolerance; } - propagation::config& propagation() { return m_prop_cfg; } - const propagation::config& propagation() const { return m_prop_cfg; } - /// @} - - /// Print configuration - std::ostream& operator<<(std::ostream& os) { - os << " -> test tolerance: \t " << tol() << std::endl; - os << " -> trk path limit: \t " - << propagation().stepping.path_limit << std::endl; - os << " -> overstepping tol:\t " - << propagation().navigation.overstep_tolerance << std::endl; - os << " -> step constraint: \t " - << propagation().stepping.step_constraint << std::endl; - os << std::endl; - - return os; - } - }; + using configuration = detray::test::configuration; /// Constructor explicit fixture_base(const configuration& cfg = {}) diff --git a/tests/include/detray/test/common/detail/register_checks.hpp b/tests/include/detray/test/framework/register_checks.hpp similarity index 51% rename from tests/include/detray/test/common/detail/register_checks.hpp rename to tests/include/detray/test/framework/register_checks.hpp index 768425edc7..a6255d28b2 100644 --- a/tests/include/detray/test/common/detail/register_checks.hpp +++ b/tests/include/detray/test/framework/register_checks.hpp @@ -7,13 +7,17 @@ #pragma once +// Detray test include(s) +#include "detray/test/framework/whiteboard.hpp" + // GTest include(s) #include // System include(s) +#include #include -namespace detray::detail { +namespace detray::test { template