44#include "tkn_config.h"
46#include "tkproperty.h"
57typedef std::map<tkstring,pair<tkstring,tkstring>>
properties;
70 bool fAsymError =
false;
77 tkmeasure(
double _value,
const tkstring &_unit_name,
double _errlow,
double _errhigh) :
tkmeasure(_value, gunits->get_key(_unit_name), _errlow, _errhigh) {}
104 void set(
const double &_val,
const tkstring &_unit=
"");
111 virtual void set_error(
const double &_err_low,
const double &_err_high) { fErrorLow.
set_value(_err_low); fErrorHigh.
set_value(_err_high) ; fError.
clear(); fAsymError =
true; }
147 int save_precision = os.precision();
167 os << left << std::setw(7) <<
"STABLE" << std::setw(9) <<
"";
178 os << left << setprecision(exp_error) << offset << std::setw(7) << _measure->
get_value();
187 os << left << setprecision(exp_error) << offset << std::setw(7) << _measure->
get_value();
188 os <<
" ("<< std::setw(5) << _measure->
get_error() <<
") " << _measure->
get_unit();
196 if(_measure->
get_value()==0.) os <<
" "<< std::setw(5) <<
" " <<
" " << _measure->
get_unit();
197 else os << fixed << left << setprecision(exp_error) <<
" ("<< std::setw(5) <<
" ? " <<
") " << _measure->
get_unit();
206 os.precision(save_precision);
212 void print(
bool with_return=
true) {cout<<(
this);
213 if(with_return) cout<<endl;}
220 glog <<
warning_o <<
"trying to add two different types of units... ignored" <<
do_endl;
225 double low_e1, high_e1, low_e2, high_e2;
243 result.
set_error(sqrt(low_e1*low_e1+low_e2*low_e2),sqrt(high_e1*high_e1+high_e2*high_e2));
245 else result.
set_error(sqrt(low_e1*low_e1+low_e2*low_e2));
259 double low_e1, high_e1;
291 tkmeasure result = *
this + measure_to_add;
299 int precision_int_err = (int) precision_float_error;
300 if(precision_float_error<1) precision_int_err = (int) (-(1./precision_float_error+0.5));
302 int exp_error = (int)std::floor(std::log10(std::fabs(precision_int_err) ) );
303 if(precision_int_err >= 0) exp_error = 0 ;
Stores information on an experimental measure.
const tkstring & get_info_tag()
returns the info tag (calculation, systematic, approx value...)
tkmeasure operator-() const
void print(bool with_return=true)
print the measured properties
const tkstring & get_type() const
returns the measured data type (energy, lifetime...)
double get_error() const
returns the error on the measured value
double get_error_high() const
returns the high assymetric error on the measured value
friend std::ostream & operator<<(std::ostream &os, const tkmeasure *_measure)
redefinition of the << operator to take precision into account
double get_error_high(const tkstring &_unit_name)
returns the high assymetric error on the measured value in the required string unit
tkstring get_unit() const
returns the unit name
void set_type(const tkstring &_type)
set the measured data type (energy, lifetime...)
tkunit_manager::units_keys get_unit_key() const
returns the unit key
double get_value(const tkstring &_unit_name)
returns the measure value in the required string unit
tkmeasure(double _value, const tkstring &_unit_name, double _errlow, double _errhigh)
bool is_asym_errors() const
test is the measure uncertainty is asymmetric
virtual void set_error(const double &_err)
set the error of this measured data
friend tkmeasure operator*(double _multiplier, const tkmeasure &obj)
const tkstring & get_info_tag_const() const
double get_error(const tkstring &_unit_name)
returns the error on the measured value in the required string unit
tkmeasure(double _value, const tkstring &_unit_name, double _err=0)
tkmeasure operator+(const tkmeasure &_measure) const
double get_value() const
returns the measure value
double get_error_low(const tkstring &_unit_name)
returns the low assymetric error on the measured value in the required string unit
bool set_unit(const tkstring &_unit_name)
set the measured data unit (value and errors)
double get_error_low() const
returns the low assymetric error on the measured value
virtual void set_error(const double &_err_low, const double &_err_high)
set the asymetruic error of this value
int get_exp_error_precision(const double &_err) const
calculate the needed precision for printouts
void set(const double &_val, const tkstring &_unit="")
set the measured value and unit. No given units keeps the current one
tkmeasure operator*(double _multiplier) const
tkmeasure operator-(const tkmeasure &_measure) const
virtual ~tkmeasure()=default
void set_info_tag(const tkstring &_tag)
define the info tag (calculation, systematic, approx value...)
Any property (data) with flags.
bool is_converted() const
to know if the value has been converted
void set_info(tkproperty::data_info _info)
to set some information about this data
void set_converted(bool _val=true)
to define the value as a converted one
data_info get_info_const() const
tkstring get_info_str(bool _showknown=true) const
to print in string the data_info
data_info get_info()
to get information about this data
bool is_info(data_info _info) const
to get some information about this data
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
tkstring copy() const
Returns a copy of this string.
static tkstring Form(const char *_format,...)
tkstring substr(size_type __pos=0, size_type __n=npos) const
Inlines.
size_t index(const char *_s, size_t _pos=0, ECaseCompare _cmp=kExact) const
Returns the index of the substring _s.
bool contains(const char *_pat, ECaseCompare _cmp=kExact) const
static double get_precision(tkstring _st)
Extract the precision for a given ENSDF data.
tkstring & replace_all(const tkstring &_s1, const tkstring &_s2)
units_keys
units identifiers
A measured value associated to its unit.
tkunit_manager::units_keys get_unit_key() const
returns the unit key
double get_value() const
get the value in the current unit
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
tkstring get_unit_name() const
returns the unit name
void clear()
reset the data_unit
tklog & warning_o(tklog &log)
std::map< tkstring, pair< tkstring, tkstring > > properties
tklog & do_endl(tklog &log)