Skip to content

Commit

Permalink
consistently use io::get_absolute_path when dealing with user-input f… (
Browse files Browse the repository at this point in the history
#764)

* consistently use io::get_absolute_path when dealing with user-input file paths

* clang formatting

---------

Co-authored-by: Fabrice Le Goff <[email protected]>
  • Loading branch information
flg and Fabrice Le Goff authored Nov 8, 2024
1 parent 0174113 commit f5a5e51
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions examples/run/cpu/truth_fitting_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_detector_type>(host_mr, reader_cfg);
Expand Down
12 changes: 6 additions & 6 deletions examples/run/cuda/truth_fitting_example_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<host_detector_type>(mng_mr, reader_cfg);
Expand Down
8 changes: 4 additions & 4 deletions examples/simulation/simulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions io/src/read_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions io/src/read_detector_description.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<traccc::geometry_id, traccc::transform3> 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
Expand Down

0 comments on commit f5a5e51

Please sign in to comment.