REST-for-Physics
v2.3
Rare Event Searches ToolKit for Physics
|
Wrapper class for custom composite unit, e.g. mm/us, kg-yr, kg-m/s^2, cm^3
Implemented operator /
and *
, meaning strip-off/adds the unit for a unit-embeded/unitless value
Example 1: convert exposure "24(kg-yr)" to unit "ton-day" SetExposure(24/units("kg-yr")*units("ton-day"));
Example 2: save a "unitless" value, then assign a concrete unit when using it double field = GetDblParameterWithUnits("electricField");
fGas->GetDriftVelocity(field*units("V/cm"));
Note: If the unit definition is not recognized, the object will be zombie, and the value will not be converted. Note: Single unit must be pure alpha. It cannot contain numbers or symbols. Do not use cm3, we shal use cm^3 instead.
Definition at line 47 of file TRestSystemOfUnits.h.
Public Member Functions | |
bool | IsZombie () const |
Whether this unit is zombie(invalid) More... | |
std::string | ToStandardDefinition () |
TRestSystemOfUnits (std::string unitsStr) | |
Constructor from a unit std::string. More... | |
Private Member Functions | |
double | GetUnitScale (std::string singleUnit) |
Get the scale of the unit to convert to the REST standard units. More... | |
int | GetUnitType (std::string singleUnit) |
Get the type of the units. More... | |
Private Attributes | |
std::vector< double > | fComponentOrder |
std::vector< int > | fComponents |
double | fScaleCombined |
Bool_t | fZombie |
Friends | |
Double_t | operator* (const Double_t &val, const TRestSystemOfUnits &units) |
Double_t | operator/ (const Double_t &val, const TRestSystemOfUnits &units) |
TRestSystemOfUnits::TRestSystemOfUnits | ( | std::string | unitsStr | ) |
Constructor from a unit std::string.
Definition at line 280 of file TRestSystemOfUnits.cxx.
|
private |
Get the scale of the unit to convert to the REST standard units.
Definition at line 370 of file TRestSystemOfUnits.cxx.
|
private |
Get the type of the units.
Definition at line 363 of file TRestSystemOfUnits.cxx.
|
inline |
Whether this unit is zombie(invalid)
Definition at line 67 of file TRestSystemOfUnits.h.
string TRestSystemOfUnits::ToStandardDefinition | ( | ) |
Definition at line 377 of file TRestSystemOfUnits.cxx.
|
friend |
Definition at line 70 of file TRestSystemOfUnits.h.
|
friend |
Definition at line 75 of file TRestSystemOfUnits.h.
|
private |
Definition at line 52 of file TRestSystemOfUnits.h.
|
private |
Definition at line 50 of file TRestSystemOfUnits.h.
|
private |
Definition at line 56 of file TRestSystemOfUnits.h.
|
private |
Definition at line 54 of file TRestSystemOfUnits.h.