Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:25

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 // Project include(s)
0010 #include "detray/core/detector.hpp"
0011 
0012 // Detray plugin include(s)
0013 #include "detray/plugins/svgtools/illustrator.hpp"
0014 #include "detray/plugins/svgtools/writer.hpp"
0015 
0016 // Detray test include(s)
0017 #include "detray/test/common/build_toy_detector.hpp"
0018 #include "detray/test/framework/types.hpp"
0019 
0020 // Vecmem include(s)
0021 #include <vecmem/memory/host_memory_resource.hpp>
0022 
0023 // Actsvg include(s)
0024 #include <actsvg/core.hpp>
0025 
0026 // GTest include(s).
0027 #include <gtest/gtest.h>
0028 
0029 // System include(s)
0030 #include <array>
0031 #include <string>
0032 
0033 GTEST_TEST(svgtools, surfaces) {
0034   // This test creates the visualization using the illustrator class.
0035   // However, for full control over the process, it is also possible to use
0036   // the tools in svgstools::conversion, svgstools::display, and
0037   // actsvg::display by converting the object to a proto object, optionally
0038   // styling it, and then displaying it.
0039 
0040   // Axes.
0041   const auto axes = actsvg::draw::x_y_axes("axes", {-250, 250}, {-250, 250},
0042                                            actsvg::style::stroke());
0043 
0044   // Creating the views.
0045   const actsvg::views::x_y xy;
0046   const actsvg::views::z_r zr;
0047 
0048   // Creating the detector and geomentry context.
0049   vecmem::host_memory_resource host_mr;
0050   const auto [det, names] =
0051       detray::build_toy_detector<detray::test::algebra>(host_mr);
0052 
0053   // Creating the svg generator for the detector.
0054   const detray::svgtools::illustrator il{det, names};
0055 
0056   // Indexes of the surfaces in the detector to be visualized.
0057   std::array indices{200u, 201u, 202u, 203u, 204u};
0058 
0059   for (detray::dindex i : indices) {
0060     std::string name = "test_svgtools_surface" + std::to_string(i);
0061     // Visualization of surface/portal i:
0062     const auto [svg_xy, mat_xy] = il.draw_surface(i, xy);
0063     detray::svgtools::write_svg(name + "_xy", {axes, svg_xy});
0064     detray::svgtools::write_svg(name + "mat_xy", {axes, mat_xy});
0065     const auto [svg_zr, mat_zr] = il.draw_surface(i, zr);
0066     detray::svgtools::write_svg(name + "_zr", {axes, svg_zr});
0067     detray::svgtools::write_svg(name + "mat_zr", {axes, mat_zr});
0068   }
0069 }