![]() |
ATLAS Offline Software
|
Wrapper to avoid constant divisions when using units. More...
#include "GaudiKernel/SystemOfUnits.h"
#include "GaudiKernel/PhysicalConstants.h"
Go to the source code of this file.
Classes | |
class | Athena::Units::Unit< TAG > |
Wrapper to avoid constant divisions when using units. More... | |
Namespaces | |
Athena | |
Some weak symbol referencing magic... | |
Athena::Units | |
Macros | |
#define | UNIT(NAME) |
Wrapper to avoid constant divisions when using units.
double pt_in_gev = pt / GeV;
However, writing it like this results in a division by a constant being generated. It would be faster to rewrite this as multiplication by the inverse, but the compiler won't do that by default as the results are not guaranteed to be the same.
Using the symbols defined here allow avoiding the divisions (in optimized builds) without having to write the above explicitly as
double pt_in_gev = pt * (1./GeV);
which is pretty ugly.
We do this by creating a static const object wrapping the value of the unit and overriding operator/ to change the division to multiplication by inverse.
Definition in file Units.h.