File indexing completed on 2026-05-27 07:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/core/detector.hpp"
0011 #include "detray/definitions/units.hpp"
0012
0013
0014 #include "detray/io/frontend/detector_reader.hpp"
0015
0016
0017 #include "detray/options/detector_io_options.hpp"
0018 #include "detray/options/parse_options.hpp"
0019 #include "detray/options/propagation_options.hpp"
0020 #include "detray/options/track_generator_options.hpp"
0021 #include "detray/test/cpu/material_scan.hpp"
0022 #include "detray/test/device/cuda/material_validation.hpp"
0023 #include "detray/test/framework/register_checks.hpp"
0024
0025
0026 #include <vecmem/memory/cuda/device_memory_resource.hpp>
0027 #include <vecmem/memory/host_memory_resource.hpp>
0028
0029
0030 #include <gtest/gtest.h>
0031
0032
0033 #include "detray/options/boost_program_options.hpp"
0034
0035
0036 #include <sstream>
0037 #include <stdexcept>
0038 #include <string>
0039
0040 namespace po = boost::program_options;
0041
0042 using namespace detray;
0043
0044 int main(int argc, char **argv) {
0045
0046 using metadata_t = test::default_metadata;
0047 using detector_t = detector<metadata_t>;
0048
0049
0050 ::testing::InitGoogleTest(&argc, argv);
0051
0052
0053 po::options_description desc("\ndetray CUDA material validation options");
0054
0055 desc.add_options()(
0056 "data_dir",
0057 po::value<std::string>()->default_value("./validation_data/material"),
0058 "Directory that contains the data files")(
0059 "material_tol", po::value<float>()->default_value(1.f),
0060 "Tolerance for comparing the material traces [%]")(
0061 "overlaps_tol",
0062 po::value<float>()->default_value(stepping::config{}.min_stepsize),
0063 "Tolerance for considering surfaces to be overlapping [mm]");
0064
0065
0066 detray::io::detector_reader_config reader_cfg{};
0067 detray::test::material_validation<detector_t>::config mat_val_cfg{};
0068 test::material_scan<detector_t>::config mat_scan_cfg{};
0069
0070 po::variables_map vm = detray::options::parse_options(
0071 desc, argc, argv, reader_cfg, mat_scan_cfg.track_generator(),
0072 mat_val_cfg.propagation());
0073
0074
0075 if (vm.count("material_tol") != 0u) {
0076 mat_val_cfg.relative_error(vm["material_tol"].as<float>() / 100.f);
0077 }
0078 if (vm.count("overlaps_tol") != 0u) {
0079 mat_scan_cfg.overlaps_tol(vm["overlaps_tol"].as<float>());
0080 }
0081 const auto data_dir{vm["data_dir"].as<std::string>()};
0082
0083
0084 vecmem::cuda::device_memory_resource dev_mr{};
0085 vecmem::host_memory_resource host_mr;
0086
0087 const auto [det, names] =
0088 detray::io::read_detector<detector_t>(host_mr, reader_cfg);
0089
0090 auto white_board = std::make_shared<test::whiteboard>();
0091 detector_t::geometry_context ctx{};
0092
0093
0094 mat_scan_cfg.name("material_scan_for_cuda");
0095 mat_scan_cfg.track_generator().uniform_eta(true);
0096 mat_scan_cfg.material_file(data_dir + "/material_scan_for_cuda");
0097 detray::test::register_checks<test::material_scan>(det, names, mat_scan_cfg,
0098 ctx, white_board);
0099
0100
0101 mat_val_cfg.name("material_validation_cuda");
0102 mat_val_cfg.material_file(data_dir + "/navigation_material_trace");
0103 mat_val_cfg.device_mr(&dev_mr);
0104
0105 test::register_checks<detray::cuda::material_validation>(
0106 det, names, mat_val_cfg, ctx, white_board);
0107
0108
0109 return RUN_ALL_TESTS();
0110 }