File indexing completed on 2026-05-27 07:24:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/core/detector.hpp"
0011 #include "detray/tracks/ray.hpp"
0012
0013
0014 #include "detray/plugins/svgtools/illustrator.hpp"
0015 #include "detray/plugins/svgtools/writer.hpp"
0016
0017
0018 #include "detray/test/common/build_toy_detector.hpp"
0019 #include "detray/test/common/track_generators.hpp"
0020 #include "detray/test/framework/types.hpp"
0021 #include "detray/test/validation/detector_scanner.hpp"
0022 #include "detray/test/validation/svg_display.hpp"
0023 #include "detray/tracks/tracks.hpp"
0024
0025
0026 #include <vecmem/memory/host_memory_resource.hpp>
0027
0028
0029 #include <actsvg/core.hpp>
0030
0031
0032 #include <gtest/gtest.h>
0033
0034
0035 #include <array>
0036 #include <string>
0037
0038 GTEST_TEST(svgtools, intersections) {
0039
0040
0041
0042
0043
0044
0045
0046 const auto axes =
0047 actsvg::draw::x_y_axes("axes", {-250, 250}, {-250, 250},
0048 actsvg::style::stroke(), "axis1", "axis2");
0049
0050
0051 const actsvg::views::z_r view;
0052
0053
0054 vecmem::host_memory_resource host_mr;
0055 const auto [det, names] =
0056 detray::build_toy_detector<detray::test::algebra>(host_mr);
0057
0058 using detector_t = decltype(det);
0059 using test_algebra = typename detector_t::algebra_type;
0060
0061 detector_t::geometry_context gctx{};
0062
0063
0064 const detray::svgtools::illustrator il{det, names};
0065
0066
0067 const auto svg_det = il.draw_detector(view);
0068
0069
0070 using generator_t =
0071 detray::uniform_track_generator<detray::detail::ray<test_algebra>>;
0072 auto trk_gen_cfg = generator_t::configuration{};
0073 trk_gen_cfg.origin(0.f, 0.f, 100.f).phi_steps(10u).theta_steps(10u);
0074
0075 std::size_t index = 0;
0076
0077 for (const auto test_ray : generator_t{trk_gen_cfg}) {
0078
0079 const auto intersection_record =
0080 detray::detector_scanner::run<detray::ray_scan>(gctx, det, test_ray);
0081
0082 const std::string name =
0083 "test_svgtools_intersection_record" + std::to_string(index);
0084
0085
0086 auto intersections =
0087 detray::detail::transcribe_intersections(intersection_record);
0088 const auto svg_ir =
0089 il.draw_intersections(name, intersections, test_ray.dir(), view);
0090
0091 detray::svgtools::write_svg(name, {axes, svg_det, svg_ir});
0092
0093 index++;
0094 }
0095 }