From f4080e44d38b7f7f3d6246e39d2ae4b6e650de5c Mon Sep 17 00:00:00 2001 From: Fabrice Le Goff Date: Thu, 7 Nov 2024 14:36:09 +0100 Subject: [PATCH 1/2] consistently use io::get_absolute_path when dealing with user-input file paths --- examples/run/cpu/truth_fitting_example.cpp | 12 ++++++------ examples/run/cuda/truth_fitting_example_cuda.cpp | 12 ++++++------ examples/simulation/simulate.cpp | 8 ++++---- io/src/read_detector.cpp | 6 +++--- io/src/read_detector_description.cpp | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/run/cpu/truth_fitting_example.cpp b/examples/run/cpu/truth_fitting_example.cpp index 4d8234f41e..2e91376dd3 100644 --- a/examples/run/cpu/truth_fitting_example.cpp +++ b/examples/run/cpu/truth_fitting_example.cpp @@ -87,15 +87,15 @@ int main(int argc, char* argv[]) { // Read the detector detray::io::detector_reader_config reader_cfg{}; - reader_cfg.add_file(traccc::io::data_directory() + - detector_opts.detector_file); + reader_cfg.add_file(traccc::io::get_absolute_path( + detector_opts.detector_file)); if (!detector_opts.material_file.empty()) { - reader_cfg.add_file(traccc::io::data_directory() + - detector_opts.material_file); + reader_cfg.add_file(traccc::io::get_absolute_path( + detector_opts.material_file)); } if (!detector_opts.grid_file.empty()) { - reader_cfg.add_file(traccc::io::data_directory() + - detector_opts.grid_file); + reader_cfg.add_file(traccc::io::get_absolute_path( + detector_opts.grid_file)); } const auto [host_det, names] = detray::io::read_detector(host_mr, reader_cfg); diff --git a/examples/run/cuda/truth_fitting_example_cuda.cpp b/examples/run/cuda/truth_fitting_example_cuda.cpp index 0ee741193d..c2832cf5a4 100644 --- a/examples/run/cuda/truth_fitting_example_cuda.cpp +++ b/examples/run/cuda/truth_fitting_example_cuda.cpp @@ -114,15 +114,15 @@ int main(int argc, char* argv[]) { // Read the detector detray::io::detector_reader_config reader_cfg{}; - reader_cfg.add_file(traccc::io::data_directory() + - detector_opts.detector_file); + reader_cfg.add_file(traccc::io::get_absolute_path( + detector_opts.detector_file)); if (!detector_opts.material_file.empty()) { - reader_cfg.add_file(traccc::io::data_directory() + - detector_opts.material_file); + reader_cfg.add_file(traccc::io::get_absolute_path( + detector_opts.material_file)); } if (!detector_opts.grid_file.empty()) { - reader_cfg.add_file(traccc::io::data_directory() + - detector_opts.grid_file); + reader_cfg.add_file(traccc::io::get_absolute_path( + detector_opts.grid_file)); } auto [host_det, names] = detray::io::read_detector(mng_mr, reader_cfg); diff --git a/examples/simulation/simulate.cpp b/examples/simulation/simulate.cpp index 633763952e..09c83d633c 100644 --- a/examples/simulation/simulate.cpp +++ b/examples/simulation/simulate.cpp @@ -68,13 +68,13 @@ int main(int argc, char* argv[]) { // Read the detector detray::io::detector_reader_config reader_cfg{}; - reader_cfg.add_file(traccc::io::data_directory() + det_opts.detector_file); + reader_cfg.add_file(traccc::io::get_absolute_path(det_opts.detector_file)); if (!det_opts.material_file.empty()) { - reader_cfg.add_file(traccc::io::data_directory() + - det_opts.material_file); + reader_cfg.add_file(traccc::io::get_absolute_path( + det_opts.material_file)); } if (!det_opts.grid_file.empty()) { - reader_cfg.add_file(traccc::io::data_directory() + det_opts.grid_file); + reader_cfg.add_file(traccc::io::get_absolute_path(det_opts.grid_file)); } // Memory resource used by the EDM. diff --git a/io/src/read_detector.cpp b/io/src/read_detector.cpp index 14702494dd..880f86dcc1 100644 --- a/io/src/read_detector.cpp +++ b/io/src/read_detector.cpp @@ -28,12 +28,12 @@ void read_detector(detector_t& detector, vecmem::memory_resource& mr, // Set up the detector reader configuration. detray::io::detector_reader_config cfg; - cfg.add_file(traccc::io::data_directory() + std::string{geometry_file}); + cfg.add_file(traccc::io::get_absolute_path(geometry_file)); if (material_file.empty() == false) { - cfg.add_file(traccc::io::data_directory() + std::string{material_file}); + cfg.add_file(traccc::io::get_absolute_path(material_file)); } if (grid_file.empty() == false) { - cfg.add_file(traccc::io::data_directory() + std::string{grid_file}); + cfg.add_file(traccc::io::get_absolute_path(grid_file)); } // Read the detector. diff --git a/io/src/read_detector_description.cpp b/io/src/read_detector_description.cpp index 373da16735..5d7ab4bb17 100644 --- a/io/src/read_detector_description.cpp +++ b/io/src/read_detector_description.cpp @@ -45,8 +45,8 @@ void read_csv_dd(traccc::silicon_detector_description::host& dd, // Read the geometry description as a map of surface tranformations. const std::map surfaces = - traccc::io::csv::read_surfaces(traccc::io::data_directory() + - geometry_file.data()); + traccc::io::csv::read_surfaces(traccc::io::get_absolute_path( + geometry_file.data())); // Fill the detector description with information about the (sensitive) // surfaces, and the digitization configurations belonging to those From 725ee31209182c16eba01fb6c7bdb6c104f639be Mon Sep 17 00:00:00 2001 From: Fabrice Le Goff Date: Thu, 7 Nov 2024 15:55:16 +0100 Subject: [PATCH 2/2] clang formatting --- examples/run/cpu/truth_fitting_example.cpp | 12 ++++++------ examples/run/cuda/truth_fitting_example_cuda.cpp | 12 ++++++------ examples/simulation/simulate.cpp | 4 ++-- io/src/read_detector_description.cpp | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/run/cpu/truth_fitting_example.cpp b/examples/run/cpu/truth_fitting_example.cpp index 2e91376dd3..2874cb5629 100644 --- a/examples/run/cpu/truth_fitting_example.cpp +++ b/examples/run/cpu/truth_fitting_example.cpp @@ -87,15 +87,15 @@ int main(int argc, char* argv[]) { // Read the detector detray::io::detector_reader_config reader_cfg{}; - reader_cfg.add_file(traccc::io::get_absolute_path( - detector_opts.detector_file)); + reader_cfg.add_file( + traccc::io::get_absolute_path(detector_opts.detector_file)); if (!detector_opts.material_file.empty()) { - reader_cfg.add_file(traccc::io::get_absolute_path( - detector_opts.material_file)); + reader_cfg.add_file( + traccc::io::get_absolute_path(detector_opts.material_file)); } if (!detector_opts.grid_file.empty()) { - reader_cfg.add_file(traccc::io::get_absolute_path( - detector_opts.grid_file)); + reader_cfg.add_file( + traccc::io::get_absolute_path(detector_opts.grid_file)); } const auto [host_det, names] = detray::io::read_detector(host_mr, reader_cfg); diff --git a/examples/run/cuda/truth_fitting_example_cuda.cpp b/examples/run/cuda/truth_fitting_example_cuda.cpp index c2832cf5a4..ca5b2095b5 100644 --- a/examples/run/cuda/truth_fitting_example_cuda.cpp +++ b/examples/run/cuda/truth_fitting_example_cuda.cpp @@ -114,15 +114,15 @@ int main(int argc, char* argv[]) { // Read the detector detray::io::detector_reader_config reader_cfg{}; - reader_cfg.add_file(traccc::io::get_absolute_path( - detector_opts.detector_file)); + reader_cfg.add_file( + traccc::io::get_absolute_path(detector_opts.detector_file)); if (!detector_opts.material_file.empty()) { - reader_cfg.add_file(traccc::io::get_absolute_path( - detector_opts.material_file)); + reader_cfg.add_file( + traccc::io::get_absolute_path(detector_opts.material_file)); } if (!detector_opts.grid_file.empty()) { - reader_cfg.add_file(traccc::io::get_absolute_path( - detector_opts.grid_file)); + reader_cfg.add_file( + traccc::io::get_absolute_path(detector_opts.grid_file)); } auto [host_det, names] = detray::io::read_detector(mng_mr, reader_cfg); diff --git a/examples/simulation/simulate.cpp b/examples/simulation/simulate.cpp index 09c83d633c..510d084abe 100644 --- a/examples/simulation/simulate.cpp +++ b/examples/simulation/simulate.cpp @@ -70,8 +70,8 @@ int main(int argc, char* argv[]) { detray::io::detector_reader_config reader_cfg{}; reader_cfg.add_file(traccc::io::get_absolute_path(det_opts.detector_file)); if (!det_opts.material_file.empty()) { - reader_cfg.add_file(traccc::io::get_absolute_path( - det_opts.material_file)); + reader_cfg.add_file( + traccc::io::get_absolute_path(det_opts.material_file)); } if (!det_opts.grid_file.empty()) { reader_cfg.add_file(traccc::io::get_absolute_path(det_opts.grid_file)); diff --git a/io/src/read_detector_description.cpp b/io/src/read_detector_description.cpp index 5d7ab4bb17..c91b91275f 100644 --- a/io/src/read_detector_description.cpp +++ b/io/src/read_detector_description.cpp @@ -45,8 +45,8 @@ void read_csv_dd(traccc::silicon_detector_description::host& dd, // Read the geometry description as a map of surface tranformations. const std::map surfaces = - traccc::io::csv::read_surfaces(traccc::io::get_absolute_path( - geometry_file.data())); + traccc::io::csv::read_surfaces( + traccc::io::get_absolute_path(geometry_file.data())); // Fill the detector description with information about the (sensitive) // surfaces, and the digitization configurations belonging to those