ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
detector_io_options.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// detray IO include(s)
12#include "detray/io/frontend/detector_reader_config.hpp"
13#include "detray/io/frontend/detector_writer_config.hpp"
14
15// Detray test include(s)
16#include "detray/options/options_handling.hpp"
17
18// Boost
19#include "detray/options/boost_program_options.hpp"
20
21// System include(s)
22#include <stdexcept>
23#include <string>
24
25namespace detray::options {
26
28template <>
29void add_options<detray::io::detector_reader_config>(
30 boost::program_options::options_description &desc,
31 const detray::io::detector_reader_config & /*unused*/) {
32 desc.add_options()("geometry_file",
33 boost::program_options::value<std::string>(),
34 "Detector geometry input file")(
35 "grid_file", boost::program_options::value<std::string>(),
36 "Detector surface grid input file")(
37 "material_file", boost::program_options::value<std::string>(),
38 "Detector material input file");
39}
40
42template <>
43void configure_options<detray::io::detector_reader_config>(
44 const boost::program_options::variables_map &vm,
45 detray::io::detector_reader_config &cfg) {
46 // Input files
47 if (vm.count("geometry_file") != 0u) {
48 cfg.add_file(vm["geometry_file"].as<std::string>());
49 } else {
50 throw std::invalid_argument("Please specify a geometry input file!\n\n");
51 }
52 if (vm.count("material_file") != 0u) {
53 cfg.add_file(vm["material_file"].as<std::string>());
54 }
55 if (vm.count("grid_file") != 0u) {
56 cfg.add_file(vm["grid_file"].as<std::string>());
57 }
58}
59
61template <>
62void add_options<detray::io::detector_writer_config>(
63 boost::program_options::options_description &desc,
64 const detray::io::detector_writer_config &cfg) {
65 desc.add_options()(
66 "outdir",
67 boost::program_options::value<std::string>()->default_value(cfg.path()),
68 "Output directory for detector files")(
69 "compactify_json", "not implemented")("write_material",
70 "toggle material output")(
71 "write_grids", "toggle grid output")("replace_files",
72 "whether to replace existing files");
73}
74
76template <>
77void configure_options<detray::io::detector_writer_config>(
78 const boost::program_options::variables_map &vm,
79 detray::io::detector_writer_config &cfg) {
80 if (!vm["outdir"].defaulted()) {
81 cfg.path(vm["outdir"].as<std::string>());
82 }
83 cfg.compactify_json(vm.count("compactify_json") != 0u);
84 cfg.write_material(vm.count("write_material") != 0u);
85 cfg.write_grids(vm.count("write_grids") != 0u);
86 cfg.replace_files(vm.count("replace_files") != 0u);
87}
88
89} // namespace detray::options
detector_reader_config & add_file(const std::string &file_name)
SettersAdd a detector component file to the input list.
Definition detector_reader_config.hpp:58
bool write_grids() const
Return whether accelerator grids are written.
Definition detector_writer_config.hpp:54
bool write_material() const
Return whether material data is written.
Definition detector_writer_config.hpp:51
bool compactify_json() const
Return whether JSON output is compacted.
Definition detector_writer_config.hpp:48
bool replace_files() const
Return whether existing output files are replaced.
Definition detector_writer_config.hpp:45
const std::string & path() const
GettersReturn the output directory used for detector files.
Definition detector_writer_config.hpp:39