File indexing completed on 2026-07-26 08:22:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "traccc/io/read_spacepoints.hpp"
0010
0011 #include "csv/read_spacepoints.hpp"
0012 #include "read_binary.hpp"
0013 #include "traccc/io/utils.hpp"
0014
0015
0016 #include <filesystem>
0017
0018 namespace traccc::io {
0019
0020 void read_spacepoints(
0021 edm::spacepoint_collection::host& spacepoints,
0022 edm::measurement_collection::host& measurements, std::size_t event,
0023 std::string_view directory, const traccc::host_detector* detector,
0024 const traccc::detector_design_description::host* det_desc,
0025 const traccc::detector_conditions_description::host* det_cond,
0026 data_format format) {
0027 switch (format) {
0028 case data_format::csv: {
0029 read_spacepoints(
0030 spacepoints, measurements,
0031 get_absolute_path(
0032 (std::filesystem::path(directory) /
0033 std::filesystem::path(get_event_filename(event, "-hits.csv")))
0034 .native()),
0035 get_absolute_path((std::filesystem::path(directory) /
0036 std::filesystem::path(get_event_filename(
0037 event, "-measurements.csv")))
0038 .native()),
0039 get_absolute_path((std::filesystem::path(directory) /
0040 std::filesystem::path(get_event_filename(
0041 event, "-measurement-simhit-map.csv")))
0042 .native()),
0043 detector, det_desc, det_cond, format);
0044 break;
0045 }
0046 case data_format::binary: {
0047 read_spacepoints(
0048 spacepoints, measurements,
0049 get_absolute_path(
0050 (std::filesystem::path(directory) /
0051 std::filesystem::path(get_event_filename(event, "-hits.dat")))
0052 .native()),
0053 get_absolute_path((std::filesystem::path(directory) /
0054 std::filesystem::path(get_event_filename(
0055 event, "-measurements.dat")))
0056 .native()),
0057 "", detector, det_desc, det_cond, format);
0058 break;
0059 }
0060 default:
0061 throw std::invalid_argument("Unsupported data format");
0062 }
0063 }
0064
0065 void read_spacepoints(
0066 edm::spacepoint_collection::host& spacepoints,
0067 edm::measurement_collection::host& measurements,
0068 std::string_view hit_filename, std::string_view meas_filename,
0069 std::string_view meas_hit_map_filename,
0070 const traccc::host_detector* detector,
0071 const traccc::detector_design_description::host* det_desc,
0072 const traccc::detector_conditions_description::host* det_cond,
0073 data_format format) {
0074 switch (format) {
0075 case data_format::csv:
0076 csv::read_spacepoints(spacepoints, measurements, hit_filename,
0077 meas_filename, meas_hit_map_filename, detector,
0078 det_desc, det_cond);
0079 break;
0080 case data_format::binary:
0081 details::read_binary_soa(spacepoints, hit_filename);
0082 details::read_binary_soa(measurements, meas_filename);
0083 break;
0084 default:
0085 throw std::invalid_argument("Unsupported data format");
0086 }
0087 }
0088
0089 }