Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:17

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 // detray IO include(s)
0012 #include "detray/io/frontend/detector_reader_config.hpp"
0013 #include "detray/io/frontend/detector_writer_config.hpp"
0014 
0015 // Detray test include(s)
0016 #include "detray/options/options_handling.hpp"
0017 
0018 // Boost
0019 #include "detray/options/boost_program_options.hpp"
0020 
0021 // System include(s)
0022 #include <stdexcept>
0023 #include <string>
0024 
0025 namespace detray::options {
0026 
0027 /// Add options for the detray detector reader
0028 template <>
0029 void add_options<detray::io::detector_reader_config>(
0030     boost::program_options::options_description &desc,
0031     const detray::io::detector_reader_config & /*unused*/) {
0032   desc.add_options()("geometry_file",
0033                      boost::program_options::value<std::string>(),
0034                      "Detector geometry input file")(
0035       "grid_file", boost::program_options::value<std::string>(),
0036       "Detector surface grid input file")(
0037       "material_file", boost::program_options::value<std::string>(),
0038       "Detector material input file");
0039 }
0040 
0041 /// Configure the detray detector reader
0042 template <>
0043 void configure_options<detray::io::detector_reader_config>(
0044     const boost::program_options::variables_map &vm,
0045     detray::io::detector_reader_config &cfg) {
0046   // Input files
0047   if (vm.count("geometry_file") != 0u) {
0048     cfg.add_file(vm["geometry_file"].as<std::string>());
0049   } else {
0050     throw std::invalid_argument("Please specify a geometry input file!\n\n");
0051   }
0052   if (vm.count("material_file") != 0u) {
0053     cfg.add_file(vm["material_file"].as<std::string>());
0054   }
0055   if (vm.count("grid_file") != 0u) {
0056     cfg.add_file(vm["grid_file"].as<std::string>());
0057   }
0058 }
0059 
0060 /// Add options for the detray detector writer
0061 template <>
0062 void add_options<detray::io::detector_writer_config>(
0063     boost::program_options::options_description &desc,
0064     const detray::io::detector_writer_config &cfg) {
0065   desc.add_options()(
0066       "outdir",
0067       boost::program_options::value<std::string>()->default_value(cfg.path()),
0068       "Output directory for detector files")(
0069       "compactify_json", "not implemented")("write_material",
0070                                             "toggle material output")(
0071       "write_grids", "toggle grid output")("replace_files",
0072                                            "whether to replace existing files");
0073 }
0074 
0075 /// Configure the detray detector writer
0076 template <>
0077 void configure_options<detray::io::detector_writer_config>(
0078     const boost::program_options::variables_map &vm,
0079     detray::io::detector_writer_config &cfg) {
0080   if (!vm["outdir"].defaulted()) {
0081     cfg.path(vm["outdir"].as<std::string>());
0082   }
0083   cfg.compactify_json(vm.count("compactify_json") != 0u);
0084   cfg.write_material(vm.count("write_material") != 0u);
0085   cfg.write_grids(vm.count("write_grids") != 0u);
0086   cfg.replace_files(vm.count("replace_files") != 0u);
0087 }
0088 
0089 }  // namespace detray::options