File indexing completed on 2026-05-27 07:24:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/navigation/volume_graph.hpp"
0011
0012
0013 #include "detray/test/common/build_toy_detector.hpp"
0014 #include "detray/test/framework/types.hpp"
0015
0016
0017 #include <vecmem/memory/host_memory_resource.hpp>
0018
0019
0020 #include <gtest/gtest.h>
0021
0022
0023 #include <iostream>
0024 #include <map>
0025
0026
0027 GTEST_TEST(detray_navigation, volume_graph) {
0028 using namespace detray;
0029
0030 using test_algebra = test::algebra;
0031
0032 vecmem::host_memory_resource host_mr;
0033
0034 toy_det_config<test::scalar> toy_cfg{};
0035 toy_cfg.n_edc_layers(1u);
0036
0037 auto [det, names] = build_toy_detector<test_algebra>(host_mr, toy_cfg);
0038
0039 using detector_t = decltype(det);
0040
0041
0042 struct volume_printout {
0043 void operator()(const detector_t::volume_type &n) const {
0044 std::clog << "On volume: " << n.index() << std::endl;
0045 }
0046 };
0047
0048
0049 volume_graph<detector_t, volume_printout> graph(det);
0050
0051
0052 EXPECT_EQ(graph.n_nodes(), det.volumes().size());
0053
0054
0055
0056
0057
0058 const auto &adj_mat = graph.adjacency_matrix();
0059
0060
0061 dvector<dindex> adj_truth = {
0062 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2,
0063
0064 1, 108, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
0065
0066 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1,
0067
0068 0, 0, 1, 224, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
0069
0070 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0071
0072 0, 0, 1, 0, 0, 448, 1, 0, 1, 0, 0, 0, 0, 1, 0,
0073
0074 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0075
0076 0, 0, 1, 0, 0, 0, 0, 728, 1, 0, 1, 0, 0, 1, 0,
0077
0078 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0,
0079
0080 0, 0, 1, 0, 0, 0, 0, 0, 0, 1092, 1, 1, 0, 1, 0,
0081
0082 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0,
0083
0084 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1,
0085
0086 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 1, 2,
0087
0088 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
0089
0090 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
0091
0092
0093 ASSERT_TRUE(adj_mat == adj_truth) << graph.to_string();
0094 }