ATLAS Offline Software
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 
36 #ifndef ATHENAKERNEL_UNITS_H
37 #define ATHENAKERNEL_UNITS_H
38 
39 
40 #include "GaudiKernel/SystemOfUnits.h"
41 #include "GaudiKernel/PhysicalConstants.h"
42 
43 
44 namespace Athena {
45 namespace Units {
46 
47 
58 template <int TAG> class Unit {};
59 template <int TAG>
60 constexpr double operator/ (double x, const Unit<TAG> u)
61 {
62  constexpr double recip = 1. / static_cast<double>(u);
63  return x * recip;
64 }
65 template <int TAG>
66 constexpr 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) \
75 template <> class Unit<__LINE__> \
76 { \
77 public: \
78  constexpr operator double() const { return Gaudi::Units::NAME; } \
79 }; \
80 constexpr static const Unit<__LINE__> NAME
81 
92 UNIT (um);
93 UNIT (mm);
96 UNIT (cm);
109 UNIT (s);
116 UNIT (g);
119 #undef UNIT
120 
121 
122 } // namespace Units
123 } // namespace Athena
124 
125 
126 #endif // not ATHENAKERNEL_ATLASUNITS_H
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.nanosecond
int nanosecond
Definition: SystemOfUnits.py:119
python.SystemOfUnits.MeV
int MeV
Definition: SystemOfUnits.py:154
cm3
#define cm3
python.SystemOfUnits.microsecond
int microsecond
Definition: SystemOfUnits.py:122
deg
#define deg
Definition: SbPolyhedron.cxx:17
python.SystemOfUnits.TeV
int TeV
Definition: SystemOfUnits.py:158
python.SystemOfUnits.gram
int gram
Definition: SystemOfUnits.py:165
Athena::Units::Unit
Wrapper to avoid constant divisions when using units.
Definition: Units.h:58
python.SystemOfUnits.meter2
int meter2
Definition: SystemOfUnits.py:62
x
#define x
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
python.SystemOfUnits.mm3
int mm3
Definition: SystemOfUnits.py:85
python.SystemOfUnits.millisecond
int millisecond
Definition: SystemOfUnits.py:121
python.SystemOfUnits.keV
int keV
Definition: SystemOfUnits.py:156
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
python.SystemOfUnits.radian
int radian
Definition: SystemOfUnits.py:104
python.SystemOfUnits.millimeter
int millimeter
Definition: SystemOfUnits.py:53
python.SystemOfUnits.meter
int meter
Definition: SystemOfUnits.py:61
python.SystemOfUnits.cm2
int cm2
Definition: SystemOfUnits.py:88
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
Athena::Units::operator/
constexpr double operator/(double x, const Unit< TAG > u)
Definition: Units.h:60
python.SystemOfUnits.centimeter
int centimeter
Definition: SystemOfUnits.py:57
python.SystemOfUnits.micrometer
int micrometer
Definition: SystemOfUnits.py:71
Athena::Units
Definition: Units.h:45
python.SystemOfUnits.mm2
int mm2
Definition: SystemOfUnits.py:84
python.SystemOfUnits.centimeter3
int centimeter3
Definition: SystemOfUnits.py:59
python.PhysicalConstants.c_light
float c_light
Definition: PhysicalConstants.py:63
Athena::Units::UNIT
UNIT(millimeter)
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
python.SystemOfUnits.millimeter3
int millimeter3
Definition: SystemOfUnits.py:55
mole
#define mole
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130
python.SystemOfUnits.millimeter2
int millimeter2
Definition: SystemOfUnits.py:54
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
python.SystemOfUnits.centimeter2
int centimeter2
Definition: SystemOfUnits.py:58
python.SystemOfUnits.picosecond
int picosecond
Definition: SystemOfUnits.py:123
python.SystemOfUnits.rad
int rad
Definition: SystemOfUnits.py:111
python.SystemOfUnits.meter3
int meter3
Definition: SystemOfUnits.py:63