ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
toy_detector_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// Project include(s)
12#include "detray/definitions/algebra.hpp"
13
14// Detray test include(s)
15#include "detray/options/options_handling.hpp"
16#include "detray/test/common/build_toy_detector.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
27namespace detail {
28
30template <concepts::scalar scalar_t>
31void add_toy_det_options(boost::program_options::options_description &desc,
32 const toy_det_config<scalar_t> &cfg) {
33 desc.add_options()(
34 "barrel_layers",
35 boost::program_options::value<unsigned int>()->default_value(
36 cfg.n_brl_layers()),
37 "number of barrel layers [0-4]")(
38 "endcap_layers",
39 boost::program_options::value<unsigned int>()->default_value(
40 cfg.n_edc_layers()),
41 "number of endcap layers on either side [0-7]")(
42 "homogeneous_material",
43 "Generate homogeneous material description (default)")(
44 "material_maps", "Generate material maps");
45}
46
48template <concepts::scalar scalar_t>
49void configure_toy_det_options(const boost::program_options::variables_map &vm,
50 toy_det_config<scalar_t> &cfg) {
51 cfg.n_brl_layers(vm["barrel_layers"].as<unsigned int>());
52 cfg.n_edc_layers(vm["endcap_layers"].as<unsigned int>());
53
54 if (vm.count("homogeneous_material") != 0u &&
55 vm.count("material_maps") != 0u) {
56 throw std::invalid_argument("Please specify only one material description");
57 }
58 if (vm.count("homogeneous_material") != 0u) {
59 cfg.use_material_maps(false);
60 }
61 if (vm.count("material_maps") != 0u) {
62 cfg.use_material_maps(true);
63 }
64}
65
66} // namespace detail
67
70template <>
71void add_options<toy_det_config<float>>(
72 boost::program_options::options_description &desc,
73 const toy_det_config<float> &cfg) {
74 detail::add_toy_det_options(desc, cfg);
75}
76
77template <>
78void add_options<toy_det_config<double>>(
79 boost::program_options::options_description &desc,
80 const toy_det_config<double> &cfg) {
81 detail::add_toy_det_options(desc, cfg);
82}
84
87template <>
88void configure_options<toy_det_config<float>>(
89 const boost::program_options::variables_map &vm,
90 toy_det_config<float> &cfg) {
91 detail::configure_toy_det_options(vm, cfg);
92}
93
94template <>
95void configure_options<toy_det_config<double>>(
96 const boost::program_options::variables_map &vm,
97 toy_det_config<double> &cfg) {
98 detail::configure_toy_det_options(vm, cfg);
99}
101
102} // namespace detray::options