|
REST-for-Physics
v2.3
Rare Event Searches ToolKit for Physics
|
This namespace defines the unit conversion for different units which are understood by REST. More...
Data Structures | |
| class | TRestSystemOfUnits |
| struct | UnitsStruct |
Enumerations | |
| enum | Physical_Unit { Energy , Time , Length , Mass , Voltage , MagneticField , Pressure , Angle , NOT_A_UNIT = -1 } |
Functions | |
| double | _AddUnit (string name, int type, double scale) |
| Add a unit with given name, type and scale. More... | |
| AddUnit (arcmin, REST_Units::Angle, TMath::RadToDeg() *60.) | |
| AddUnit (arcsec, REST_Units::Angle, TMath::RadToDeg() *3600.) | |
| AddUnit (atm, REST_Units::Pressure, 1.013) | |
| AddUnit (bar, REST_Units::Pressure, 1.) | |
| AddUnit (cm, REST_Units::Length, 1e-1) | |
| AddUnit (day, REST_Units::Time, 1.16e-11) | |
| AddUnit (deg, REST_Units::Angle, TMath::RadToDeg()) | |
| AddUnit (degree, REST_Units::Angle, TMath::RadToDeg()) | |
| AddUnit (degrees, REST_Units::Angle, TMath::RadToDeg()) | |
| AddUnit (eV, REST_Units::Energy, 1e3) | |
| AddUnit (G, REST_Units::MagneticField, 1.e4) | |
| AddUnit (g, REST_Units::Mass, 1e3) | |
| AddUnit (GeV, REST_Units::Energy, 1e-6) | |
| AddUnit (gram, REST_Units::Mass, 1e3) | |
| AddUnit (hr, REST_Units::Time, 2.78e-10) | |
| AddUnit (Hz, REST_Units::Time, 1.e6) | |
| AddUnit (J, REST_Units::Energy, 1.60e-19) | |
| AddUnit (keV, REST_Units::Energy, 1) | |
| AddUnit (kg, REST_Units::Mass, 1.) | |
| AddUnit (kJ, REST_Units::Energy, 1.60e-22) | |
| AddUnit (kPa, REST_Units::Pressure, 101.325) | |
| AddUnit (kV, REST_Units::Voltage, 1.e-3) | |
| AddUnit (m, REST_Units::Length, 1e-3) | |
| AddUnit (mbar, REST_Units::Pressure, 1.e3) | |
| AddUnit (MeV, REST_Units::Energy, 1e-3) | |
| AddUnit (meV, REST_Units::Energy, 1e6) | |
| AddUnit (mg, REST_Units::Mass, 1e6) | |
| AddUnit (minu, REST_Units::Time, 1.67e-8) | |
| AddUnit (mm, REST_Units::Length, 1.) | |
| AddUnit (mon, REST_Units::Time, 3.85e-13) | |
| AddUnit (MPa, REST_Units::Pressure, 0.101325) | |
| AddUnit (mPa, REST_Units::Pressure, 10132500) | |
| AddUnit (ms, REST_Units::Time, 1.e-3) | |
| AddUnit (mT, REST_Units::MagneticField, 1.e3) | |
| AddUnit (mV, REST_Units::Voltage, 1.e3) | |
| AddUnit (nm, REST_Units::Length, 1e6) | |
| AddUnit (ns, REST_Units::Time, 1.e3) | |
| AddUnit (Pa, REST_Units::Pressure, 101325) | |
| AddUnit (rad, REST_Units::Angle, 1.) | |
| AddUnit (radian, REST_Units::Angle, 1.) | |
| AddUnit (radians, REST_Units::Angle, 1.) | |
| AddUnit (s, REST_Units::Time, 1.e-6) | |
| AddUnit (T, REST_Units::MagneticField, 1.) | |
| AddUnit (ton, REST_Units::Mass, 1e-3) | |
| AddUnit (torr, REST_Units::Pressure, 760) | |
| AddUnit (um, REST_Units::Length, 1e3) | |
| AddUnit (us, REST_Units::Time, 1.) | |
| AddUnit (V, REST_Units::Voltage, 1.) | |
| AddUnit (yr, REST_Units::Time, 3.17e-14) | |
| Double_t | ConvertRESTUnitsValueToCustomUnits (Double_t value, string unitsStr) |
| Convert value with REST units into the given custom units. More... | |
| Double_t | ConvertValueToRESTUnits (Double_t value, string unitsStr) |
| Convert value into REST units. More... | |
| std::string | FindRESTUnitsInString (string s) |
| Find and return the units definition in a string. More... | |
| TVector2 | Get2DVectorInRESTUnits (string in) |
| It scales a physics measurement with its units into a REST default units value. More... | |
| TVector2 | Get2DVectorValueInString (string in) |
| It scales a physics measurement with its units into a REST default units value. More... | |
| TVector3 | Get3DVectorInRESTUnits (string in) |
| It scales a physics measurement with its units into a REST default units value. More... | |
| TVector3 | Get3DVectorValueInString (string in) |
| It scales a physics measurement with its units into a REST default units value. More... | |
| Double_t | GetDblValueInRESTUnits (string in) |
| It scales a physics measurement with its units into a REST default units value. More... | |
| Double_t | GetDblValueInString (string in) |
| It scales a physics measurement with its units into a REST default units value. More... | |
| double | GetScaleToStandardUnit (string unitsdef) |
| Get the scale to REST standard unit. scale (unitsdef) = 1 (standard unit) More... | |
| std::string | GetStandardUnitDefinition (string unitsdef) |
| Get standard form of this unit definition. More... | |
| Double_t | GetValueInRESTUnits (string in) |
| It scales a physics measurement with its units into a REST default units value. More... | |
| bool | IsBasicUnit (string unitsStr) |
| Checks if the string is a REST basic unit. More... | |
| bool | IsUnit (string unitsStr) |
| Checks if the string is a REST supported unit. More... | |
| std::string | RemoveUnitsFromString (string s) |
| It should remove all units found inside the input string. More... | |
Variables | |
| map< string, pair< int, double > > | __ListOfRESTUnits |
This namespace defines the unit conversion for different units which are understood by REST.
TODO : Write a detailed documentation here
RESTsoft - Software for Rare Event Searches with TPCs
History of developments:
2017-Nov: First concept and implementation of REST_Units namespace.
| enum REST_Units::Physical_Unit |
Definition at line 36 of file TRestSystemOfUnits.h.
| double REST_Units::_AddUnit | ( | string | name, |
| int | type, | ||
| double | scale | ||
| ) |
Add a unit with given name, type and scale.
Helper method, called during __static_initialization_and_destruction_0() to fill __ListOfRESTUnits
Definition at line 227 of file TRestSystemOfUnits.cxx.
| Double_t REST_Units::ConvertRESTUnitsValueToCustomUnits | ( | Double_t | value, |
| std::string | unitsStr | ||
| ) |
Convert value with REST units into the given custom units.
Definition at line 218 of file TRestSystemOfUnits.cxx.
| Double_t REST_Units::ConvertValueToRESTUnits | ( | Double_t | value, |
| string | unitsStr | ||
| ) |
Convert value into REST units.
For a given value with custom units, REST will first find its equivalent REST units and calculate the scaling factor. Then it will strip off the custom units by dividing the value with the scaling factor.
e.g. REST standard unit for dimension time*mass is kg*us. When we call: double a = ConvertValueToRESTUnits(8, "kg-yr"); // a = 2.5236593e+14 The returned value is in unit "kg-us".
The returned the value can be thought as "unitless". This means we don't need to care about it when saving it. When we are going to use it, we just add the unit back. For example: SetExposure(a*units("ton-day")); This explictily adds the unit "ton-day" to the "unitless" value a.
Definition at line 211 of file TRestSystemOfUnits.cxx.
| std::string REST_Units::FindRESTUnitsInString | ( | string | s | ) |
Find and return the units definition in a string.
We suppose the last of value before units must be "1234567890(),.-". Hence this prepority can be used to spilt the input string into value part and unit part e.g. value="(1,-13)mm" value="-3mm" can both be recognized
Definition at line 94 of file TRestSystemOfUnits.cxx.
| TVector2 REST_Units::Get2DVectorInRESTUnits | ( | string | in | ) |
It scales a physics measurement with its units into a REST default units value.
For example, string in = "(0,5)MeV", return (0,5000) (keV)
Definition at line 173 of file TRestSystemOfUnits.cxx.
| TVector2 REST_Units::Get2DVectorValueInString | ( | string | in | ) |
It scales a physics measurement with its units into a REST default units value.
For example, string in = "(0,5)MeV", return (0,5000) (keV)
Definition at line 160 of file TRestSystemOfUnits.cxx.
| TVector3 REST_Units::Get3DVectorInRESTUnits | ( | string | in | ) |
It scales a physics measurement with its units into a REST default units value.
For example, string in = "(0,5,6)cm", return (0,50,60) mm
Definition at line 194 of file TRestSystemOfUnits.cxx.
| TVector3 REST_Units::Get3DVectorValueInString | ( | string | in | ) |
It scales a physics measurement with its units into a REST default units value.
For example, string in = "(0,5,6)cm", return (0,50,60) mm
Definition at line 180 of file TRestSystemOfUnits.cxx.
| Double_t REST_Units::GetDblValueInRESTUnits | ( | string | in | ) |
It scales a physics measurement with its units into a REST default units value.
For example, string in = "35.V/cm", return 3.5 (V/mm)
Definition at line 153 of file TRestSystemOfUnits.cxx.
| Double_t REST_Units::GetDblValueInString | ( | string | in | ) |
It scales a physics measurement with its units into a REST default units value.
For example, string in = "35.V/cm", return 3.5 (V/mm)
Definition at line 135 of file TRestSystemOfUnits.cxx.
| double REST_Units::GetScaleToStandardUnit | ( | string | unitsdef | ) |
Get the scale to REST standard unit. scale (unitsdef) = 1 (standard unit)
e.g. 0.001(m) = 1(mm). Where "mm" is REST standard unit.
Definition at line 76 of file TRestSystemOfUnits.cxx.
| std::string REST_Units::GetStandardUnitDefinition | ( | string | unitsdef | ) |
Get standard form of this unit definition.
e.g. m/s --> mm/us
Definition at line 82 of file TRestSystemOfUnits.cxx.
| Double_t REST_Units::GetValueInRESTUnits | ( | string | in | ) |
It scales a physics measurement with its units into a REST default units value.
For example, string in = "35.V/cm", return 3.5 (V/mm)
Definition at line 146 of file TRestSystemOfUnits.cxx.
| bool REST_Units::IsBasicUnit | ( | std::string | in | ) |
Checks if the string is a REST basic unit.
Definition at line 70 of file TRestSystemOfUnits.cxx.
| bool REST_Units::IsUnit | ( | string | unitsStr | ) |
Checks if the string is a REST supported unit.
REST supports several basic units and kinds of their combinations(multiply, divide) e.g. cm, ns, mV, kg, keV V/cm, kg-yr
Note: REST doesn't support units combination with numbers, e.g. m/s^2
Definition at line 65 of file TRestSystemOfUnits.cxx.
| std::string REST_Units::RemoveUnitsFromString | ( | string | s | ) |
It should remove all units found inside the input string.
We suppose the last of value before units must be "1234567890(),.-eE". Hence this prepority can be used to spilt the input string into value part and unit part e.g. value="(1,-13)mm" value="-3mm" value="6e-5mm" can both be recognized
Definition at line 115 of file TRestSystemOfUnits.cxx.
| map<string, pair<int, double> > REST_Units::__ListOfRESTUnits |
Definition at line 32 of file TRestSystemOfUnits.cxx.