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 // Project include(s)
0012 #include "detray/definitions/algebra.hpp"
0013 
0014 // Detray test include(s)
0015 #include "detray/options/options_handling.hpp"
0016 #include "detray/test/common/build_toy_detector.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 namespace detail {
0028 
0029 /// Add options for the detray toy detector
0030 template <concepts::scalar scalar_t>
0031 void add_toy_det_options(boost::program_options::options_description &desc,
0032                          const toy_det_config<scalar_t> &cfg) {
0033   desc.add_options()(
0034       "barrel_layers",
0035       boost::program_options::value<unsigned int>()->default_value(
0036           cfg.n_brl_layers()),
0037       "number of barrel layers [0-4]")(
0038       "endcap_layers",
0039       boost::program_options::value<unsigned int>()->default_value(
0040           cfg.n_edc_layers()),
0041       "number of endcap layers on either side [0-7]")(
0042       "homogeneous_material",
0043       "Generate homogeneous material description (default)")(
0044       "material_maps", "Generate material maps");
0045 }
0046 
0047 /// Configure the detray toy detector
0048 template <concepts::scalar scalar_t>
0049 void configure_toy_det_options(const boost::program_options::variables_map &vm,
0050                                toy_det_config<scalar_t> &cfg) {
0051   cfg.n_brl_layers(vm["barrel_layers"].as<unsigned int>());
0052   cfg.n_edc_layers(vm["endcap_layers"].as<unsigned int>());
0053 
0054   if (vm.count("homogeneous_material") != 0u &&
0055       vm.count("material_maps") != 0u) {
0056     throw std::invalid_argument("Please specify only one material description");
0057   }
0058   if (vm.count("homogeneous_material") != 0u) {
0059     cfg.use_material_maps(false);
0060   }
0061   if (vm.count("material_maps") != 0u) {
0062     cfg.use_material_maps(true);
0063   }
0064 }
0065 
0066 }  // namespace detail
0067 
0068 /// Add options for the toy detector
0069 /// @{
0070 template <>
0071 void add_options<toy_det_config<float>>(
0072     boost::program_options::options_description &desc,
0073     const toy_det_config<float> &cfg) {
0074   detail::add_toy_det_options(desc, cfg);
0075 }
0076 
0077 template <>
0078 void add_options<toy_det_config<double>>(
0079     boost::program_options::options_description &desc,
0080     const toy_det_config<double> &cfg) {
0081   detail::add_toy_det_options(desc, cfg);
0082 }
0083 /// @}
0084 
0085 /// Configure the detray toy detector
0086 /// @{
0087 template <>
0088 void configure_options<toy_det_config<float>>(
0089     const boost::program_options::variables_map &vm,
0090     toy_det_config<float> &cfg) {
0091   detail::configure_toy_det_options(vm, cfg);
0092 }
0093 
0094 template <>
0095 void configure_options<toy_det_config<double>>(
0096     const boost::program_options::variables_map &vm,
0097     toy_det_config<double> &cfg) {
0098   detail::configure_toy_det_options(vm, cfg);
0099 }
0100 /// @}
0101 
0102 }  // namespace detray::options