114 if(_unit == gunits->Undef_unit)
return false;
115 if (_unit == fUnit_key)
return true;
117 const auto current_type = gunits->get_type(fUnit_key);
118 const auto requested_type = gunits->get_type(_unit);
122 if (current_type == gunits->kUndef_type) {
124 fFactor = gunits->get_factor(fUnit_key);
129 if(requested_type == current_type && current_type != gunits->kNoConvUnits) {
131 fFactor = gunits->get_factor(fUnit_key);
135 if( ((current_type == gunits->kEnergy) && (requested_type == gunits->kTime)) ||
136 ((current_type == gunits->kTime) && (requested_type == gunits->kEnergy))) {
137 if (!std::isfinite(fValue) || fValue <= 0.) {
138 glog <<
warning_o <<
" cannot convert a non-positive or non-finite "
139 << gunits->get_name(fUnit_key) <<
" value to " << gunits->get_name(_unit) <<
do_endl;
150 constexpr double hbar_ln2_keV_s = (1.054571818e-34*6.2415091e+15)*0.69314718055994530942;
151 fValue = hbar_ln2_keV_s / fValue;
152 fFactor = gunits->get_factor(fUnit_key);
155 glog <<
warning_o <<
" sorry, unit conversion from " << gunits->get_name(fUnit_key) <<
" to " << gunits->get_name(_unit) <<
" not handle by TkN for the moment" <<
do_endl;
void set_value(const double &_val, const tkstring &_unit="")
set the value and unit from string, if _unit not defined, let in the current unit