File: UnitIO.h
Description:
The IUnit and OUnit classes are used to
facilitate input and output of unitful numbers from and to
persistent streams. An Energy can hence be read and written like
this:
is << iunit(x, GeV);
os
>> ounit(x, GeV);
Also containers of unitful
numbers may be written like this, as well as Lorentz and three
vectors.
See
also:
namespace Pythia7
template <typename T, typename UT>
STRUCT
OUnit
Public members:
OUnit(const T & t, const UT & u): theX(t), theUnit(u) {}
OUnit(const OUnit<T,UT> & iu): theX(iu.theX), theUnit(iu.theUnit) {}
const T & theX;
const UT & theUnit;
template <typename T, typename UT>
STRUCT
IUnit
Public members:
IUnit(T & t, const UT & u): theX(t), theUnit(u) {}
IUnit(const IUnit<T,UT> & iu): theX(iu.theX), theUnit(iu.theUnit) {}
T & theX;
const UT & theUnit;
template <typename T, typename UT>
inline OUnit<T,UT> ounit(const T & t, const UT & ut) {
return OUnit<T,UT>(t, ut);
template <typename T, typename UT>
inline IUnit<T,UT> iunit(T & t, const UT & ut) {
return IUnit<T,UT>(t, ut);
template <typename OStream, typename T, typename UT>
void ounitstream(OStream & os, const T & t, UT & u) {
os << t/u;
template <typename IStream, typename T, typename UT>
void iunitstream(IStream & is, T & t, UT & u) {
double d;
is >> d;
t = d*u;;
template <typename OStream, typename T, typename UT>
OStream & operator<<(OStream & os, const OUnit<T,UT> & u) {
ounitstream(os, u.theX, u.theUnit);
return os;
template <typename IStream, typename T, typename UT>
IStream & operator>>(IStream & is, const IUnit<T,UT> & u) {
iunitstream(is, u.theX, u.theUnit);
return is;
DEFINED MACROS
INCLUDED FILES