REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Private Member Functions | Private Attributes | Friends
REST_Units::TRestSystemOfUnits Class Reference

Detailed Description

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)
 
std::string ToStandardDefinition ()
 
 TRestSystemOfUnits (std::string unitsStr)
 Constructor from a unit std::string.
 

Private Member Functions

double GetUnitScale (std::string singleUnit)
 Get the scale of the unit to convert to the REST standard units.
 
int GetUnitType (std::string singleUnit)
 Get the type of the units.
 

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)
 

The documentation for this class was generated from the following files: