Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:19

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2022-2026 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Local include(s).
0009 #include "traccc/io/read_particles.hpp"
0010 
0011 #include "csv/read_particles.hpp"
0012 #include "traccc/io/utils.hpp"
0013 
0014 // System include(s).
0015 #include <filesystem>
0016 
0017 namespace traccc::io {
0018 
0019 void read_particles(particle_collection_types::host& particles,
0020                     std::size_t event, std::string_view directory,
0021                     data_format format, std::string_view filename_postfix) {
0022   switch (format) {
0023     case data_format::csv:
0024       read_particles(particles,
0025                      get_absolute_path(
0026                          (std::filesystem::path(directory) /
0027                           std::filesystem::path(get_event_filename(
0028                               event, std::string{filename_postfix} + ".csv")))
0029                              .native()),
0030                      format);
0031       break;
0032     default:
0033       throw std::invalid_argument("Unsupported data format");
0034   }
0035 }
0036 
0037 void read_particles(particle_collection_types::host& particles,
0038                     std::string_view filename, data_format format) {
0039   switch (format) {
0040     case data_format::csv:
0041       csv::read_particles(particles, filename);
0042       break;
0043     default:
0044       throw std::invalid_argument("Unsupported data format");
0045   }
0046 }
0047 
0048 void read_particles(particle_container_types::host& particles,
0049                     edm::measurement_collection::host& measurements,
0050                     std::size_t event, std::string_view directory,
0051                     const traccc::host_detector* detector, data_format format,
0052                     std::string_view filename_postfix) {
0053   switch (format) {
0054     case data_format::csv:
0055       read_particles(
0056           particles, measurements,
0057           get_absolute_path(
0058               (std::filesystem::path(directory) /
0059                std::filesystem::path(get_event_filename(
0060                    event, std::string{filename_postfix} + ".csv")))
0061                   .native()),
0062           get_absolute_path(
0063               (std::filesystem::path(directory) /
0064                std::filesystem::path(get_event_filename(event, "-hits.csv")))
0065                   .native()),
0066           get_absolute_path((std::filesystem::path(directory) /
0067                              std::filesystem::path(get_event_filename(
0068                                  event, "-measurements.csv")))
0069                                 .native()),
0070           get_absolute_path((std::filesystem::path(directory) /
0071                              std::filesystem::path(get_event_filename(
0072                                  event, "-measurement-simhit-map.csv")))
0073                                 .native()),
0074           detector, format);
0075       break;
0076     default:
0077       throw std::invalid_argument("Unsupported data format");
0078   }
0079 }
0080 
0081 void read_particles(particle_container_types::host& particles,
0082                     edm::measurement_collection::host& measurements,
0083                     std::string_view particles_file, std::string_view hits_file,
0084                     std::string_view measurements_file,
0085                     std::string_view hit_map_file,
0086                     const traccc::host_detector* detector, data_format format) {
0087   switch (format) {
0088     case data_format::csv:
0089       csv::read_particles(particles, measurements, particles_file, hits_file,
0090                           measurements_file, hit_map_file, detector);
0091       break;
0092     default:
0093       throw std::invalid_argument("Unsupported data format");
0094   }
0095 }
0096 
0097 }  // namespace traccc::io