ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
print_detector.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s)
12#include "detray/definitions/detail/qualifiers.hpp"
13#include "detray/geometry/surface.hpp"
14#include "detray/geometry/tracking_volume.hpp"
15
16// System include(s)
17#include <iomanip>
18#include <sstream>
19#include <string>
20
21namespace detray::utils {
22
23namespace detail {
24
32 template <typename accel_coll_t, typename index_t>
33 DETRAY_HOST void operator()(const accel_coll_t &accel_coll, const index_t idx,
34 std::stringstream &os) const {
35 os << accel_coll[idx];
36 }
37};
38
46 template <typename material_coll_t, typename index_t>
47 DETRAY_HOST void operator()(const material_coll_t &material_coll,
48 const index_t idx, std::stringstream &os) const {
49 os << material_coll[idx] << std::endl;
50 }
51};
52
53} // namespace detail
54
59template <concepts::detector detector_t>
60DETRAY_HOST inline std::string print_detector(
61 const detector_t &det, const typename detector_t::name_map &names = {}) {
62 // Gathers navigation information across navigator update calls
63 std::stringstream debug_stream{};
64
65 debug_stream << std::left << "[>] Detector " << det.name(names) << " has "
66 << det.volumes().size() << " volumes." << std::endl;
67
68 for (const auto [i, v_desc] : detray::views::enumerate(det.volumes())) {
69 tracking_volume v{det, v_desc};
70
71 debug_stream << "[>>] Volume " << v.name(names) << std::endl;
72 debug_stream << v << std::endl;
73
74 debug_stream << "[>>>] Acceleration Structures:" << std::endl;
75 const auto acc_link = v_desc.accel_link();
76 for (std::size_t j = 0u; j < acc_link.size(); ++j) {
77 // An acceleration data structure link was set, but is invalid
78 if (!acc_link[j].is_invalid_id() && !acc_link[j].is_invalid_index()) {
79 debug_stream << "Surfaces registered in '" << acc_link[j].id()
80 << "':" << std::endl;
81 det.accelerator_store().template visit<detail::accelerator_printer>(
82 acc_link[j], debug_stream);
83 }
84 }
85
86 debug_stream << "[>>>] Surfaces:" << std::endl;
87 for (const auto sf_desc : v.template surfaces<>()) {
88 geometry::surface sf{det, sf_desc};
89 debug_stream << sf << std::endl;
90
91 // Check the surface material, if present
92 if (sf.has_material()) {
93 debug_stream << "[>>>>] Surface material: ";
94 sf.template visit_material<detail::material_printer>(debug_stream);
95 }
96 }
97
98 debug_stream << std::endl;
99 }
100
101 return debug_stream.str();
102}
103
104} // namespace detray::utils
A functor that retrieves an acceleration struct and prints it.
Definition print_detector.hpp:26
void operator()(const accel_coll_t &accel_coll, const index_t idx, std::stringstream &os) const
Print an acceleration structure.
Definition print_detector.hpp:33
A functor that retrieves material and prints it.
Definition print_detector.hpp:40
void operator()(const material_coll_t &material_coll, const index_t idx, std::stringstream &os) const
Print material.
Definition print_detector.hpp:47