File indexing completed on 2026-05-27 07:24:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/core/detector.hpp"
0011 #include "detray/navigation/volume_graph.hpp"
0012 #include "detray/utils/logging.hpp"
0013
0014
0015 #include "detray/io/frontend/detector_reader.hpp"
0016 #include "detray/io/utils/file_handle.hpp"
0017
0018
0019 #include "detray/tutorial/types.hpp"
0020
0021
0022 #include <vecmem/memory/host_memory_resource.hpp>
0023
0024
0025 #include <ios>
0026 #include <iostream>
0027 #include <stdexcept>
0028 #include <string>
0029
0030
0031
0032 int main(int argc, char** argv) {
0033 std::clog << "Detector Graph Tutorial\n=======================\n";
0034
0035
0036 auto reader_cfg = detray::io::detector_reader_config{};
0037 if (argc == 2) {
0038 reader_cfg.add_file(argv[1]);
0039 } else {
0040 throw std::runtime_error("Please specify an input file name!");
0041 }
0042
0043 std::clog << reader_cfg << std::endl;
0044
0045
0046 using metadata_t = detray::tutorial::toy_metadata;
0047 using detector_t = detray::detector<metadata_t>;
0048
0049
0050 vecmem::host_memory_resource host_mr;
0051
0052
0053 const auto [det, names] =
0054 detray::io::read_detector<detector_t>(host_mr, reader_cfg);
0055
0056
0057 detray::volume_graph graph(det);
0058
0059 const std::string file_stem{det.name(names) + "_dot"};
0060 const std::ios_base::openmode io_mode{std::ios::out | std::ios::trunc};
0061 detray::io::file_handle out_file{file_stem, ".txt", io_mode};
0062
0063 *out_file << graph.to_dot_string() << std::endl;
0064
0065 DETRAY_INFO_HOST("Wrote file: " << file_stem + ".txt");
0066 }