TkN 2.6
Toolkit for Nuclei
Loading...
Searching...
No Matches
tkmeasure Class Reference

Stores a physical measurement with its value, unit, and uncertainty. More...

#include <physics/tkmeasure.h>

Inheritance diagram for tkmeasure:
tkproperty

Public Member Functions

 tkmeasure ()
 
 tkmeasure (double _value, const tkstring &_unit_name, double _err=0)
 
 tkmeasure (double _value, const tkstring &_unit_name, double _errlow, double _errhigh)
 
 tkmeasure (double _value, const tkunit_manager::units_keys &_unit, double _err=0)
 
 tkmeasure (double _value, const tkunit_manager::units_keys &_unit, double _errlow, double _errhigh)
 
virtual ~tkmeasure () override=default
 
double get_error () const
 returns the error on the measured value
 
double get_error (const tkstring &_unit_name)
 returns the error on the measured value in the required string unit
 
double get_error (const tkunit_manager::units_keys &_unit)
 returns the error on the measured value in the required unit key
 
double get_error_high () const
 returns the high assymetric error on the measured value
 
double get_error_high (const tkstring &_unit_name)
 returns the high assymetric error on the measured value in the required string unit
 
double get_error_high (const tkunit_manager::units_keys &_unit)
 returns the high assymetric error on the measured value in the required unit key
 
double get_error_low () const
 returns the low assymetric error on the measured value
 
double get_error_low (const tkstring &_unit_name)
 returns the low assymetric error on the measured value in the required string unit
 
double get_error_low (const tkunit_manager::units_keys &_unit)
 returns the low assymetric error on the measured value in the required unit key
 
int get_exp_error_precision (const double &_err) const
 calculate the needed precision for printouts
 
const tkstringget_info_tag ()
 returns the info tag (calculation, systematic, approx value...)
 
const tkstringget_info_tag_const () const
 
const tkstringget_type () const
 returns the measured data type (energy, lifetime...)
 
tkstring get_unit () const
 returns the unit name
 
tkunit_manager::units_keys get_unit_key () const
 returns the unit key
 
double get_value () const
 returns the measure value
 
double get_value (const tkstring &_unit_name)
 returns the measure value in the required string unit
 
double get_value (const tkunit_manager::units_keys &_unit)
 returns the measure value in the required unit key
 
bool is_asym_errors () const
 test is the measure uncertainty is asymmetric
 
tkmeasure operator* (double _multiplier) const
 
tkmeasure operator+ (const tkmeasure &_measure) const
 
tkmeasure operator- () const
 
tkmeasure operator- (const tkmeasure &_measure) const
 
void print (bool with_return=true)
 print the measured properties
 
void set (const double &_val, const tkstring &_unit="")
 set the measured value and unit. No given units keeps the current one
 
void set (const double &_val, const tkunit_manager::units_keys &_unit)
 set the measured value and unit key
 
virtual void set_error (const double &_err)
 set the error of this measured data
 
virtual void set_error (const double &_err_low, const double &_err_high)
 set the asymmetric error of this value
 
void set_info_tag (const tkstring &_tag)
 define the info tag (calculation, systematic, approx value...)
 
void set_type (const tkstring &_type)
 set the measured data type (energy, lifetime...)
 
bool set_unit (const tkstring &_unit_name)
 set the measured data unit (value and errors)
 
bool set_unit (const tkunit_manager::units_keys &_unit)
 set the measured data unit (value and errors)
 
- Public Member Functions inherited from tkproperty
 tkproperty ()
 
 tkproperty (tkproperty::data_info _info)
 
virtual ~tkproperty ()
 
void clear ()
 clear the property
 
data_info get_info ()
 to get information about this data
 
data_info get_info_const () const
 
tkstring get_info_str (bool _showknown=true) const
 to print in string the data_info
 
tkstring get_reference ()
 to get the reference of this data
 
bool is_converted () const
 to know if the value has been converted
 
bool is_info (data_info _info) const
 to get some information about this data
 
bool is_known () const
 to get some information about this data
 
void set_converted (bool _val=true)
 to define the value as a converted one
 
void set_info (tkproperty::data_info _info)
 to set some information about this data
 
void set_reference (const char *_st)
 to set the reference of this data
 

Friends

tkmeasure operator* (double _multiplier, const tkmeasure &obj)
 
std::ostream & operator<< (std::ostream &os, const tkmeasure *_measure)
 redefinition of the << operator to take precision into account
 

Additional Inherited Members

- Public Types inherited from tkproperty
enum  data_info {
  kKnown , kUnknown , kTentative , kTheo ,
  kAbout , kSystematic , kLimit , kUncertain
}
 flags that qualify a given data More...
 
- Static Public Member Functions inherited from tkproperty
static data_info what_is (const tkstring &_st)
 It deduces from a string the kind of data.
 

Detailed Description

Stores a physical measurement with its value, unit, and uncertainty.

Stores information on an experimental measure.

A tkmeasure encapsulates a measured quantity together with its unit and symmetric or asymmetric uncertainty. It also carries a tag describing the quality of the measurement (limit value, approximate, systematic, calculated, etc.).

Values can be retrieved in any compatible unit via get_value(units_key). Errors are accessible via get_error(), or get_error_low() / get_error_high() for asymmetric uncertainties.

Example:

tknucleus nuc("14C");
auto lifetime = nuc.get("lifetime");
cout << lifetime->get_value() << " " << lifetime->get_unit()
<< " +- " << lifetime->get_error() << endl;
Represents a nucleus and provides access to its properties.
Definition tknucleus.h:50
See also
tkunit_manager, tknucleus, tklevel, tkdecay

See the measures and units user guide.

Definition at line 56 of file tkmeasure.h.

Constructor & Destructor Documentation

◆ tkmeasure() [1/5]

tkmeasure ( )
inline

Definition at line 70 of file tkmeasure.h.

◆ tkmeasure() [2/5]

tkmeasure ( double _value,
const tkstring & _unit_name,
double _err = 0 )
inline

Definition at line 71 of file tkmeasure.h.

◆ tkmeasure() [3/5]

tkmeasure ( double _value,
const tkstring & _unit_name,
double _errlow,
double _errhigh )
inline

Definition at line 72 of file tkmeasure.h.

◆ tkmeasure() [4/5]

tkmeasure ( double _value,
const tkunit_manager::units_keys & _unit,
double _err = 0 )

Definition at line 28 of file tkmeasure.cpp.

◆ tkmeasure() [5/5]

tkmeasure ( double _value,
const tkunit_manager::units_keys & _unit,
double _errlow,
double _errhigh )

Definition at line 36 of file tkmeasure.cpp.

◆ ~tkmeasure()

virtual ~tkmeasure ( )
overridevirtualdefault

Member Function Documentation

◆ get_error() [1/3]

double get_error ( ) const

returns the error on the measured value

Definition at line 151 of file tkmeasure.cpp.

◆ get_error() [2/3]

double get_error ( const tkstring & _unit_name)
inline

returns the error on the measured value in the required string unit

Definition at line 125 of file tkmeasure.h.

◆ get_error() [3/3]

double get_error ( const tkunit_manager::units_keys & _unit)

returns the error on the measured value in the required unit key

Definition at line 160 of file tkmeasure.cpp.

◆ get_error_high() [1/3]

double get_error_high ( ) const

returns the high assymetric error on the measured value

Definition at line 186 of file tkmeasure.cpp.

◆ get_error_high() [2/3]

double get_error_high ( const tkstring & _unit_name)
inline

returns the high assymetric error on the measured value in the required string unit

Definition at line 139 of file tkmeasure.h.

◆ get_error_high() [3/3]

double get_error_high ( const tkunit_manager::units_keys & _unit)

returns the high assymetric error on the measured value in the required unit key

Definition at line 194 of file tkmeasure.cpp.

◆ get_error_low() [1/3]

double get_error_low ( ) const

returns the low assymetric error on the measured value

Definition at line 169 of file tkmeasure.cpp.

◆ get_error_low() [2/3]

double get_error_low ( const tkstring & _unit_name)
inline

returns the low assymetric error on the measured value in the required string unit

Definition at line 132 of file tkmeasure.h.

◆ get_error_low() [3/3]

double get_error_low ( const tkunit_manager::units_keys & _unit)

returns the low assymetric error on the measured value in the required unit key

Definition at line 177 of file tkmeasure.cpp.

◆ get_exp_error_precision()

int get_exp_error_precision ( const double & _err) const
inline

calculate the needed precision for printouts

Definition at line 319 of file tkmeasure.h.

◆ get_info_tag()

const tkstring & get_info_tag ( )
inline

returns the info tag (calculation, systematic, approx value...)

Definition at line 83 of file tkmeasure.h.

◆ get_info_tag_const()

const tkstring & get_info_tag_const ( ) const
inline

Definition at line 84 of file tkmeasure.h.

◆ get_type()

const tkstring & get_type ( ) const
inline

returns the measured data type (energy, lifetime...)

Definition at line 89 of file tkmeasure.h.

◆ get_unit()

tkstring get_unit ( ) const
inline

returns the unit name

Definition at line 142 of file tkmeasure.h.

◆ get_unit_key()

tkunit_manager::units_keys get_unit_key ( ) const
inline

returns the unit key

Definition at line 144 of file tkmeasure.h.

◆ get_value() [1/3]

double get_value ( ) const
inline

returns the measure value

Definition at line 92 of file tkmeasure.h.

◆ get_value() [2/3]

double get_value ( const tkstring & _unit_name)
inline

returns the measure value in the required string unit

Definition at line 96 of file tkmeasure.h.

◆ get_value() [3/3]

double get_value ( const tkunit_manager::units_keys & _unit)

returns the measure value in the required unit key

Definition at line 141 of file tkmeasure.cpp.

◆ is_asym_errors()

bool is_asym_errors ( ) const
inline

test is the measure uncertainty is asymmetric

Definition at line 78 of file tkmeasure.h.

◆ operator*()

tkmeasure operator* ( double _multiplier) const
inline

Definition at line 276 of file tkmeasure.h.

◆ operator+()

tkmeasure operator+ ( const tkmeasure & _measure) const
inline

Definition at line 233 of file tkmeasure.h.

◆ operator-() [1/2]

tkmeasure operator- ( ) const
inline

Definition at line 306 of file tkmeasure.h.

◆ operator-() [2/2]

tkmeasure operator- ( const tkmeasure & _measure) const
inline

Definition at line 311 of file tkmeasure.h.

◆ print()

void print ( bool with_return = true)
inline

print the measured properties

Definition at line 227 of file tkmeasure.h.

◆ set() [1/2]

void set ( const double & _val,
const tkstring & _unit = "" )

set the measured value and unit. No given units keeps the current one

Definition at line 80 of file tkmeasure.cpp.

◆ set() [2/2]

void set ( const double & _val,
const tkunit_manager::units_keys & _unit )

set the measured value and unit key

Definition at line 86 of file tkmeasure.cpp.

◆ set_error() [1/2]

virtual void set_error ( const double & _err)
inlinevirtual

set the error of this measured data

Definition at line 104 of file tkmeasure.h.

◆ set_error() [2/2]

virtual void set_error ( const double & _err_low,
const double & _err_high )
inlinevirtual

set the asymmetric error of this value

Definition at line 112 of file tkmeasure.h.

◆ set_info_tag()

void set_info_tag ( const tkstring & _tag)

define the info tag (calculation, systematic, approx value...)

Definition at line 46 of file tkmeasure.cpp.

◆ set_type()

void set_type ( const tkstring & _type)
inline

set the measured data type (energy, lifetime...)

Definition at line 87 of file tkmeasure.h.

◆ set_unit() [1/2]

bool set_unit ( const tkstring & _unit_name)
inline

set the measured data unit (value and errors)

Definition at line 147 of file tkmeasure.h.

◆ set_unit() [2/2]

bool set_unit ( const tkunit_manager::units_keys & _unit)

set the measured data unit (value and errors)

Definition at line 92 of file tkmeasure.cpp.

Friends And Related Symbol Documentation

◆ operator*

tkmeasure operator* ( double _multiplier,
const tkmeasure & obj )
friend

Definition at line 305 of file tkmeasure.h.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const tkmeasure * _measure )
friend

redefinition of the << operator to take precision into account

Definition at line 152 of file tkmeasure.h.


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