40 shared_ptr<tkmeasure> energy = make_shared<tkmeasure>(_struc.
value, _struc.
unit);
43 energy->set_error(_struc.
err);
47 energy->set_type(
"Level energy");
48 add_property(
"energy", energy);
50 if (energy->get_info_tag().contains(
";OFF=")) {
51 int idx = energy->get_info_tag().index(
";OFF=");
53 set_energy_offset(offset);
59 shared_ptr<tkmeasure> lifetime = make_shared<tkmeasure>(_struc.
value, _struc.
unit);
62 lifetime->set_error(_struc.
err);
66 if (lifetime->get_info_tag().contains(
"STABLE")) fis_stable =
true;
67 lifetime->set_type(
"lifetime");
68 add_property(
"lifetime", lifetime,
tkstring::form(
"%g", lifetime->get_value()));
70 if (lifetime->get_info_tag().contains(
";ISO=")) {
72 int idx = lifetime->get_info_tag().index(
";ISO=");
73 fisomer_level = lifetime->get_info_tag().substr(idx + 6, 1).atoi();
74 if (fisomer_level == 0) fisomer_level = 1;
80 if (_spin >= 0) fspin_parity->set_spin(_spin);
81 if (_parity >= 0) fspin_parity->set_parity(_parity);
82 fspin_parity->set_from_str(_jpi_str);
83 add_property_str(
"spin_parity", _jpi_str,
"");
98 glog <<
error << gunits->get_name(_unit) <<
" is not of 'energy' type (returns nan(1))" <<
do_endl;
101 if (
get(
"energy")->get_unit() ==
"") {
102 cout << fenergy_offset << endl;
103 cout << fbelongs_to_nucleus << endl;
107 glog <<
warning <<
"Level is only known relatively to an offset, use the _with_offset option to get the relative energy" <<
do_endl;
108 return std::nan(
"1");
110 return get(
"energy")->get_value(_unit);
124 glog <<
error << gunits->get_name(_unit) <<
" is not of 'time' or 'energy' type (returns nan(1))" <<
do_endl;
125 return std::nan(
"1");
127 return get(
"lifetime")->get_value(_unit);
140 lifetime_str =
"STABLE";
147 for (
auto &unit : units) {
168 return fisYrast_uncertain;
170 return fisYrast_exact;
183 std::cout << std::setw(15) << left << flevel_id;
189 std::cout << std::setw(15) << left <<
" ";
191 std::cout << std::setw(15) << left << fspin_parity->get_jpi_str();
197 std::cout << std::setw(15) << left <<
" ";
200 std::cout << std::setw(15) << left <<
" "
201 << std::setw(15) << left <<
" "
202 << std::setw(15) << left <<
" ";
204 std::cout << std::endl;
206 constexpr size_t print_label_width = 14;
207 std::ostringstream level_message;
208 level_message << std::left << std::setw(print_label_width) <<
"Nuclear level:";
213 glog <<
info << level_message.str() <<
" " << &energy_print;
215 glog <<
" ; Jpi: " << setw(4) << fspin_parity->get_jpi_str();
220 glog <<
" [1rst isomer]";
222 glog <<
" [2nd isomer]";
224 glog <<
" [3rd isomer]";
229 glog <<
" uncertain level tag: " << funcertain_level;
234 const size_t comment_prefix_size = 13;
235 const size_t line_offset = comment_prefix_size + print_label_width + 1;
236 const std::string first_indent(line_offset - comment_prefix_size,
' ');
Represents a nuclear excited level (or ground state).
bool is_isomer()
returns true is the level an isomer
bool is_stable()
returns true if the level stable
double get_lifetime(const tkunit_manager::units_keys _unit=tkunit_manager::units_keys::s)
returns the lifetime (in second by default)
shared_ptr< tkmeasure > get_lifetime_measure()
returns the lifetime tkmeasure object
const tkstring & get_comment()
get the level comment string
double get_energy(const tkunit_manager::units_keys _unit=tkunit_manager::units_keys::keV, bool _with_offset=false)
returns the energy in keV by default
tkstring get_offset_bandhead()
returns the bandhead string offset value (ex: X)
shared_ptr< tkmeasure > get_energy_measure()
returns the energy tkmeasure object
void set_jpi(double _spin, int _parity, const tkstring &_jpi_str)
define the spin parity
tklevel(int _id, const tkdb_table::measure_data_struct &_struc)
tkstring get_lifetime_str()
returns the lifetime in string (using the best adapted unit)
bool is_uncertain()
check if the level is uncertain
bool is_energy_offset()
to know if the energy is known with an energy offset
void print(const tkstring &_option="")
print the level properties
int get_isomer_level()
get the isomer level (1 for the ␌1rst (lowest energy) isomer, 2 for the second, etc....
bool is_yrast(bool _with_tentative=false)
returns true if the level is yrast
void set_lifetime(tkdb_table::measure_data_struct &_struc)
define the level lifetime
bool has_comment()
check if a comment exists
Stores a physical measurement with its value, unit, and uncertainty.
void set_type(const tkstring &_type)
set the measured data type (energy, lifetime...)
Contains list of properties.
bool has_property(const tkstring &_property) const
to check if the property is available
shared_ptr< tkmeasure > get(const tkstring &_property) const
get the property as tkmeasure
Nuclear excited state spin-parity.
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
static const char * form(const char *_format,...)
static tkstring Form(const char *_format,...)
tkstring substr(size_type __pos=0, size_type __n=npos) const
Inlines.
bool contains(const char *_pat, ECaseCompare _cmp=kExact) const
units_keys
units identifiers
static std::vector< std::tuple< tkstring, units_type, double > > funits_properties
std::string wrap_text(const tkstring &_text, size_t _first_content_col, size_t _continuation_col, size_t _max_line_width=80)
tklog & error(tklog &log)
tklog & do_endl(tklog &log)
tklog & warning(tklog &log)
tklog & comment(tklog &log)
data structure used to fill a tkmeasure object from the sqlite database