File indexing completed on 2026-05-27 07:24:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/tracks/trajectories.hpp"
0011
0012 #include "detray/core/detector.hpp"
0013 #include "detray/definitions/units.hpp"
0014
0015
0016 #include "detray/plugins/svgtools/illustrator.hpp"
0017 #include "detray/plugins/svgtools/writer.hpp"
0018
0019
0020 #include "detray/test/common/build_toy_detector.hpp"
0021 #include "detray/test/framework/types.hpp"
0022 #include "detray/test/validation/detector_scanner.hpp"
0023 #include "detray/test/validation/svg_display.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, trajectories) {
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::x_y 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 using detector_t = decltype(det);
0058
0059 detector_t::geometry_context gctx{};
0060
0061
0062 const detray::svgtools::illustrator il{det, names};
0063
0064
0065 const auto [svg_volumes, _] =
0066 il.draw_volumes(std::vector{7u, 9u, 11u, 13u}, view);
0067
0068
0069 using test_algebra = typename detector_t::algebra_type;
0070 using scalar = detray::dscalar<test_algebra>;
0071 using vector3 = detray::dvector3D<test_algebra>;
0072
0073 const typename detector_t::point3_type ori{0.f, 0.f, 80.f};
0074 const typename detector_t::point3_type dir{0, 1.f, 1.f};
0075
0076 const detray::detail::ray<test_algebra> ray(ori, 0.f, dir, 0.f);
0077 const auto ray_ir =
0078 detray::detector_scanner::run<detray::ray_scan>(gctx, det, ray);
0079
0080
0081 const auto svg_ray = il.draw_trajectory("trajectory", ray, 500.f, view);
0082
0083
0084 auto ray_intersections = detray::detail::transcribe_intersections(ray_ir);
0085 const auto svg_ray_ir =
0086 il.draw_intersections("record", ray_intersections, ray.dir(), view);
0087
0088 detray::svgtools::write_svg("test_svgtools_ray",
0089 {svg_volumes, svg_ray, svg_ray_ir});
0090
0091
0092
0093
0094 vector3 B{0.f * detray::unit<scalar>::T, 0.f * detray::unit<scalar>::T,
0095 1.f * detray::unit<scalar>::T};
0096
0097 const detray::detail::helix<test_algebra> helix(
0098 ori, 0.f, detray::vector::normalize(dir), -8.f, B);
0099 const auto helix_ir =
0100 detray::detector_scanner::run<detray::helix_scan>(gctx, det, helix);
0101
0102
0103 const auto svg_helix = il.draw_trajectory("trajectory", helix, 500.f, view);
0104
0105
0106 auto helix_intersections = detray::detail::transcribe_intersections(helix_ir);
0107 const auto svg_helix_ir =
0108 il.draw_intersections("record", helix_intersections, helix.dir(), view);
0109
0110 detray::svgtools::write_svg("test_svgtools_helix",
0111 {svg_volumes, svg_helix, svg_helix_ir});
0112 }