ATLAS Offline Software
Loading...
Searching...
No Matches
Units.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3/*
4 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5*/
6
34
35
36#ifndef ATHENAKERNEL_UNITS_H
37#define ATHENAKERNEL_UNITS_H
38
39
40#include "GaudiKernel/SystemOfUnits.h"
41#include "GaudiKernel/PhysicalConstants.h"
42
43
44namespace Athena {
45namespace Units {
46
47
58template <int TAG> class Unit {};
59template <int TAG>
60constexpr double operator/ (double x, const Unit<TAG> u)
61{
62 constexpr double recip = 1. / static_cast<double>(u);
63 return x * recip;
64}
65template <int TAG>
66constexpr float operator/ (float x, const Unit<TAG> u)
67{
68 constexpr float recip = 1. / static_cast<float>(u);
69 return x * recip;
70}
71
72
73// Include a selection of units from SystemOfUnits.h
74#define UNIT(NAME) \
75template <> class Unit<__LINE__> \
76{ \
77public: \
78 constexpr operator double() const { return Gaudi::Units::NAME; } \
79}; \
80constexpr static const Unit<__LINE__> NAME
81
82UNIT (millimeter);
83UNIT (millimeter2);
84UNIT (millimeter3);
85UNIT (centimeter);
86UNIT (centimeter2);
87UNIT (centimeter3);
88UNIT (meter);
89UNIT (meter2);
90UNIT (meter3);
91UNIT (micrometer);
92UNIT (um);
93UNIT (mm);
94UNIT (mm2);
95UNIT (mm3);
97UNIT (cm2);
99UNIT (radian);
100UNIT (degree);
101UNIT (rad);
103UNIT (picosecond);
104UNIT (nanosecond);
105UNIT (microsecond);
106UNIT (millisecond);
107UNIT (second);
108UNIT (ns);
110UNIT (ms);
111UNIT (keV);
112UNIT (MeV);
114UNIT (TeV);
115UNIT (gram);
118UNIT (c_light);
119#undef UNIT
120
121
122} // namespace Units
123} // namespace Athena
124
125
126#endif // not ATHENAKERNEL_ATLASUNITS_H
#define cm3
#define mole
#define deg
#define UNIT(NAME)
Definition Units.h:74
#define x
Wrapper to avoid constant divisions when using units.
Definition Units.h:58
constexpr double operator/(double x, const Unit< TAG > u)
Definition Units.h:60
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....