Back to home page

EIC code displayed by LXR

 
 

    


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

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 #include "detray/utils/logging.hpp"
0012 
0013 // Detray test include(s)
0014 #include "detray/test/common/build_toy_detector.hpp"
0015 #include "detray/test/utils/hash_tree.hpp"
0016 
0017 // Example linear algebra plugin: std::array
0018 #include "detray/tutorial/types.hpp"
0019 
0020 // Vecmem include(s)
0021 #include <vecmem/memory/host_memory_resource.hpp>
0022 
0023 // System include(s)
0024 #include <iostream>
0025 
0026 // Hash of the "correct" geometry
0027 constexpr std::size_t root_hash = 9563506807235398581ul;
0028 
0029 ///
0030 /// Work in progress (!)
0031 ///
0032 /// Get a graph that represents the detector volumes (nodes) and their links via
0033 /// their adjacent boundary surfaces (edges) and hash it to detect linking
0034 /// changes that might affect the navigation.
0035 /// This could be useful in a CI job, but is poorly tested at this point (!).
0036 int main() {
0037   std::clog << "Volume Graph Tutorial\n=====================\n\n";
0038 
0039   // Get an example detector
0040   vecmem::host_memory_resource host_mr;
0041   const auto [det, names] =
0042       detray::build_toy_detector<detray::tutorial::algebra_t>(host_mr);
0043 
0044   // Build the graph and get its adjacency matrix
0045   detray::volume_graph graph(det);
0046   const auto &adj_mat = graph.adjacency_matrix();
0047 
0048   // Construct a hash tree on the graph and compare against existing hash to
0049   // detect changes
0050   auto geo_checker = detray::hash_tree(adj_mat);
0051 
0052   if (geo_checker.root() == root_hash) {
0053     DETRAY_INFO_HOST("Geometry links are consistent");
0054   } else {
0055     DETRAY_ERROR_HOST("Geometry linking has changed! Root hash is "
0056                       << geo_checker.root() << ". Please check geometry:\n"
0057                       << graph.to_string());
0058   }
0059 }