30 using phys::units::io::operator<<;
41 template <
int N,
typename T>
42 auto constexpr static_pow([[maybe_unused]] T x) {
43 if constexpr (N == 0) {
45 }
else if constexpr (N > 0) {
46 return x * static_pow<N - 1, T>(x);
48 return 1 / static_pow<-N, T>(x);
66 using phys::units::io::operator<<;
100 template <
typename DimFrom,
typename DimTo>
101 auto constexpr conversion_factor_HEP_to_SI() {
102 static_assert(DimFrom::dim1 == 0 && DimFrom::dim2 == 0 && DimFrom::dim3 == 0 &&
103 DimFrom::dim4 == 0 && DimFrom::dim5 == 0 && DimFrom::dim6 == 0 &&
105 "must be a pure HEP type");
108 DimTo::dim4 == 0 && DimTo::dim5 == 0 && DimTo::dim6 == 0 && DimTo::dim7 == 0,
109 "conversion possible only into L, M, T dimensions");
111 int constexpr e = DimFrom::dim8;
113 int constexpr l = DimTo::dim1;
114 int constexpr m = DimTo::dim2;
115 int constexpr t = DimTo::dim3;
118 int constexpr q = -m - t;
119 static_assert(q == l + e - 2 * m,
"HEP/SI dimension mismatch!");
121 return static_pow<-e>(constants::hBarC) * static_pow<p>(constants::hBar) *
122 static_pow<q>(constants::c);
125 template <
typename DimFrom>
126 auto constexpr conversion_factor_SI_to_HEP() {
127 static_assert(DimFrom::dim4 == 0 && DimFrom::dim5 == 0 && DimFrom::dim6 == 0 &&
128 DimFrom::dim7 == 0 && DimFrom::dim8 == 0,
129 "must be pure L, M, T type");
131 int constexpr l = DimFrom::dim1;
132 int constexpr m = DimFrom::dim2;
133 int constexpr t = DimFrom::dim3;
135 int constexpr p = -m;
136 int constexpr q = m + t;
137 int constexpr e = m - t - l;
139 return static_pow<e>(constants::hBarC) * static_pow<p>(constants::hBar) *
140 static_pow<q>(constants::c);
143 template <
typename DimTo,
typename DimFrom>
145 return conversion_factor_HEP_to_SI<DimFrom, DimTo>() * q;
148 template <
typename DimFrom>
150 return conversion_factor_SI_to_HEP<DimFrom>() * q;
169 QUANTITY_DEFINE_SCALING_LITERALS(eV,
hepenergy_d, 1)
180 using namespace units;
181 using namespace units::si;
185 using phys::units::io::operator<<;
We could drag dimensions around individually, but it's much more convenient to package them...
IO for compile-time quantity library.
Zero-overhead dimensional analysis and unit/quantity manipulation and conversion. ...
Extension of the phys::units package.
class "quantity" is the heart of the library.
The cascade namespace assembles all objects needed to simulate full particles cascades.
Constants are defined with static units, based on the package (namespace) phys::units, imported in PhysicsUnits.hpp.
SI units as used mainly in CORSIKA8 as basedline.
constexpr X magnitude(quantity< DX, X > const &q)
quantity's magnitude.