aegir
Phlex-based simulation framework for the SHiP experiment.
Loading...
Searching...
No Matches
config_units.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 CERN for the benefit of the SHiP Collaboration
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5// config_units.hpp — typed reads of dimensional configuration parameters
6//
7// Workflow configuration stays plain numbers (jsonnet has no unit syntax);
8// the C++ parameter definition is the single source of truth for the unit.
9// From the get_quantity() call onward the value is a typed quantity and can
10// no longer be mixed up with a value in another unit.
11
12#pragma once
13
14#include <SHiP/Units.hpp>
15#include <string>
16
17#include "phlex/configuration.hpp"
18
19namespace aegir {
20
23template <auto U>
24[[nodiscard]] mp_units::quantity<U, double> get_quantity(
25 phlex::configuration const& config, std::string const& key,
26 mp_units::quantity<U, double> fallback) {
27 return config.get<double>(key, fallback.numerical_value_in(U)) * U;
28}
29
30} // namespace aegir
Definition math_utils.hpp:12
mp_units::quantity< U, double > get_quantity(phlex::configuration const &config, std::string const &key, mp_units::quantity< U, double > fallback)
Read config key key as a quantity in the unit of fallback, e.g.
Definition config_units.hpp:24