Back to home page

EIC code displayed by LXR

 
 

    


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

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/navigation/volume_graph.hpp"
0011 
0012 // Detray test include(s)
0013 #include "detray/test/common/build_toy_detector.hpp"
0014 #include "detray/test/framework/types.hpp"
0015 
0016 // Vecmem include(s)
0017 #include <vecmem/memory/host_memory_resource.hpp>
0018 
0019 // GTest include(s)
0020 #include <gtest/gtest.h>
0021 
0022 // System include(s)
0023 #include <iostream>
0024 #include <map>
0025 
0026 // This tests the linking of a geometry by loading it into a graph structure
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   /// Prints linking information for every node when visited
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   // Build the graph
0049   volume_graph<detector_t, volume_printout> graph(det);
0050 
0051   // Is everything accessible from the graph?
0052   EXPECT_EQ(graph.n_nodes(), det.volumes().size());
0053 
0054   // std::clog << graph.to_string() << std::endl;
0055   // std::clog << "Walking through geometry: " << std::endl;
0056   //  graph.bfs();
0057 
0058   const auto &adj_mat = graph.adjacency_matrix();
0059 
0060   // toy geometry 1 endcap layer, 4 barrel layers, including gap layers
0061   dvector<dindex> adj_truth = {// beampipe
0062                                1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2,
0063                                // endcap layer 1
0064                                1, 108, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
0065                                // connector layer
0066                                1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1,
0067                                // barrel layer 1
0068                                0, 0, 1, 224, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
0069                                // barrel gap 1
0070                                1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0071                                // barrel layer 2
0072                                0, 0, 1, 0, 0, 448, 1, 0, 1, 0, 0, 0, 0, 1, 0,
0073                                // barrel gap 2
0074                                0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0075                                // barrel layer 3
0076                                0, 0, 1, 0, 0, 0, 0, 728, 1, 0, 1, 0, 0, 1, 0,
0077                                // barrel gap 3
0078                                0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0,
0079                                // barrel layer 4
0080                                0, 0, 1, 0, 0, 0, 0, 0, 0, 1092, 1, 1, 0, 1, 0,
0081                                // barrel gap 4
0082                                0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0,
0083                                // barrel gap 5
0084                                0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1,
0085                                // endcap layer 2
0086                                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 1, 2,
0087                                // connector layer
0088                                1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
0089                                // world volume
0090                                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
0091 
0092   // Check this with graph
0093   ASSERT_TRUE(adj_mat == adj_truth) << graph.to_string();
0094 }