File indexing completed on 2026-05-27 07:24:13
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/navigation/volume_graph.hpp"
0013 #include "detray/utils/consistency_checker.hpp"
0014 #include "detray/utils/logging.hpp"
0015
0016
0017 #include "detray/test/framework/fixture_base.hpp"
0018 #include "detray/test/utils/hash_tree.hpp"
0019
0020
0021 #include <iostream>
0022 #include <string>
0023 #include <string_view>
0024
0025 namespace detray::test {
0026
0027 struct consistency_check_config
0028 : public detray::test::fixture_base<>::configuration {
0029 std::string m_name{"detector_consistency"};
0030 bool m_write_graph{false};
0031
0032
0033
0034 const std::string &name() const { return m_name; }
0035 bool write_graph() const { return m_write_graph; }
0036
0037
0038
0039
0040 consistency_check_config &name(const std::string_view v) {
0041 m_name = v;
0042 return *this;
0043 }
0044 consistency_check_config &write_graph(const bool do_write) {
0045 m_write_graph = do_write;
0046 return *this;
0047 }
0048
0049 };
0050
0051
0052
0053
0054 template <typename detector_t>
0055 class consistency_check : public detray::test::fixture_base<> {
0056 public:
0057 using fixture_type = detray::test::fixture_base<>;
0058 using config = consistency_check_config;
0059
0060 template <typename config_t>
0061 explicit consistency_check(
0062 const detector_t &det, const typename detector_t::name_map &names,
0063 const config_t &cfg = {},
0064 const typename detector_t::geometry_context &gctx = {})
0065 : m_cfg{cfg}, m_gctx{gctx}, m_det{det}, m_names{names} {}
0066
0067
0068 void TestBody() override {
0069 DETRAY_INFO_HOST("Running consistency check on: " << m_det.name(m_names)
0070 << std::endl);
0071
0072
0073 volume_graph graph(m_det);
0074
0075 ASSERT_TRUE(detail::check_consistency(m_det, true, m_names))
0076 << graph.to_string();
0077
0078 if (m_cfg.write_graph()) {
0079 DETRAY_INFO_HOST(graph.to_string());
0080 }
0081
0082
0083 if (false) {
0084 constexpr std::size_t root_hash{3244u};
0085
0086 const auto &adj_mat = graph.adjacency_matrix();
0087
0088 auto geo_checker = hash_tree(adj_mat);
0089
0090 EXPECT_EQ(geo_checker.root(), root_hash) << graph.to_string();
0091 }
0092 }
0093
0094 private:
0095
0096 const config m_cfg;
0097
0098 typename detector_t::geometry_context m_gctx{};
0099
0100 const detector_t &m_det;
0101
0102 const typename detector_t::name_map &m_names;
0103 };
0104
0105 }