File indexing completed on 2026-05-27 07:24:05
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/definitions/detail/qualifiers.hpp"
0013 #include "detray/geometry/surface.hpp"
0014 #include "detray/geometry/tracking_volume.hpp"
0015
0016
0017 #include <iomanip>
0018 #include <sstream>
0019 #include <string>
0020
0021 namespace detray::utils {
0022
0023 namespace detail {
0024
0025
0026 struct accelerator_printer {
0027
0028
0029
0030
0031
0032 template <typename accel_coll_t, typename index_t>
0033 DETRAY_HOST void operator()(const accel_coll_t &accel_coll, const index_t idx,
0034 std::stringstream &os) const {
0035 os << accel_coll[idx];
0036 }
0037 };
0038
0039
0040 struct material_printer {
0041
0042
0043
0044
0045
0046 template <typename material_coll_t, typename index_t>
0047 DETRAY_HOST void operator()(const material_coll_t &material_coll,
0048 const index_t idx, std::stringstream &os) const {
0049 os << material_coll[idx] << std::endl;
0050 }
0051 };
0052
0053 }
0054
0055
0056 template <typename detector_t>
0057 DETRAY_HOST inline std::string print_detector(
0058 const detector_t &det, const typename detector_t::name_map &names = {}) {
0059
0060 std::stringstream debug_stream{};
0061
0062 debug_stream << std::left << "[>] Detector " << det.name(names) << " has "
0063 << det.volumes().size() << " volumes." << std::endl;
0064
0065 for (const auto [i, v_desc] : detray::views::enumerate(det.volumes())) {
0066 tracking_volume v{det, v_desc};
0067
0068 debug_stream << "[>>] Volume " << v.name(names) << std::endl;
0069 debug_stream << v << std::endl;
0070
0071 debug_stream << "[>>>] Acceleration Structures:" << std::endl;
0072 const auto acc_link = v_desc.accel_link();
0073 for (std::size_t j = 0u; j < acc_link.size(); ++j) {
0074
0075 if (!acc_link[j].is_invalid_id() && !acc_link[j].is_invalid_index()) {
0076 debug_stream << "Surfaces registered in '" << acc_link[j].id()
0077 << "':" << std::endl;
0078 det.accelerator_store().template visit<detail::accelerator_printer>(
0079 acc_link[j], debug_stream);
0080 }
0081 }
0082
0083 debug_stream << "[>>>] Surfaces:" << std::endl;
0084 for (const auto sf_desc : v.template surfaces<>()) {
0085 geometry::surface sf{det, sf_desc};
0086 debug_stream << sf << std::endl;
0087
0088
0089 if (sf.has_material()) {
0090 debug_stream << "[>>>>] Surface material: ";
0091 sf.template visit_material<detail::material_printer>(debug_stream);
0092 }
0093 }
0094
0095 debug_stream << std::endl;
0096 }
0097
0098 return debug_stream.str();
0099 }
0100
0101 }