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) 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)
 

Constructor & Destructor Documentation

◆ TRestSystemOfUnits()

TRestSystemOfUnits::TRestSystemOfUnits ( std::string  unitsStr)

Constructor from a unit std::string.

Definition at line 280 of file TRestSystemOfUnits.cxx.

Member Function Documentation

◆ GetUnitScale()

double TRestSystemOfUnits::GetUnitScale ( std::string  singleUnit)
private

Get the scale of the unit to convert to the REST standard units.

Definition at line 370 of file TRestSystemOfUnits.cxx.

◆ GetUnitType()

int TRestSystemOfUnits::GetUnitType ( std::string  singleUnit)
private

Get the type of the units.

Definition at line 363 of file TRestSystemOfUnits.cxx.

◆ IsZombie()

bool REST_Units::TRestSystemOfUnits::IsZombie ( ) const
inline

Whether this unit is zombie(invalid)

Definition at line 67 of file TRestSystemOfUnits.h.

◆ ToStandardDefinition()

string TRestSystemOfUnits::ToStandardDefinition ( )

Definition at line 377 of file TRestSystemOfUnits.cxx.

Friends And Related Function Documentation

◆ operator*

Double_t operator* ( const Double_t &  val,
const TRestSystemOfUnits units 
)
friend

Definition at line 70 of file TRestSystemOfUnits.h.

◆ operator/

Double_t operator/ ( const Double_t &  val,
const TRestSystemOfUnits units 
)
friend

Definition at line 75 of file TRestSystemOfUnits.h.

Field Documentation

◆ fComponentOrder

std::vector<double> REST_Units::TRestSystemOfUnits::fComponentOrder
private

Definition at line 52 of file TRestSystemOfUnits.h.

◆ fComponents

std::vector<int> REST_Units::TRestSystemOfUnits::fComponents
private

Definition at line 50 of file TRestSystemOfUnits.h.

◆ fScaleCombined

double REST_Units::TRestSystemOfUnits::fScaleCombined
private

Definition at line 56 of file TRestSystemOfUnits.h.

◆ fZombie

Bool_t REST_Units::TRestSystemOfUnits::fZombie
private

Definition at line 54 of file TRestSystemOfUnits.h.


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