15#include "tkstate_time.h"
41 shared_ptr<tkmeasure> energy = make_shared<tkmeasure>(_struc.
value, _struc.
unit);
44 energy->set_error(_struc.
err);
48 energy->set_type(
"Level energy");
49 add_property(
"energy", energy);
51 if (energy->get_info_tag().contains(
";OFF=")) {
52 int idx = energy->get_info_tag().index(
";OFF=");
60 shared_ptr<tkmeasure> lifetime = make_shared<tkmeasure>(_struc.
value, _struc.
unit);
63 lifetime->set_error(_struc.
err);
67 if (lifetime->get_info_tag().contains(
"STABLE")) fis_stable =
true;
68 lifetime->set_type(gunits->get_type(lifetime->get_unit_key()) == gunits->kEnergy ?
"decay width" :
"half-life");
69 add_property(
"lifetime", lifetime,
tkstring::form(
"%g", lifetime->get_value()));
71 if (lifetime->get_info_tag().contains(
";ISO=")) {
73 int idx = lifetime->get_info_tag().index(
";ISO=");
74 fisomer_level = lifetime->get_info_tag().substr(idx + 6, 1).atoi();
75 if (fisomer_level == 0) fisomer_level = 1;
84 shared_ptr<tkmeasure> measure;
88 measure = make_shared<tkmeasure>(data.
value, data.
unit, data.
err);
91 measure->set_type(type);
99 add_property(
"magnetic_dipole", make_level_measure(_struc,
"magnetic dipole moment"));
104 add_property(
"electric_quadrupole", make_level_measure(_struc,
"electric quadrupole moment"));
109 if (!
has_property(
"magnetic_dipole"))
return std::nan(
"1");
110 return get(
"magnetic_dipole")->get_value();
115 if (!
has_property(
"electric_quadrupole"))
return std::nan(
"1");
116 return get(
"electric_quadrupole")->get_value();
121 if (_spin >= 0) fspin_parity->set_spin(_spin);
122 if (_parity >= 0) fspin_parity->set_parity(_parity);
123 fspin_parity->set_from_str(_jpi_str);
124 add_property_str(
"spin_parity", _jpi_str,
"");
139 glog <<
error << gunits->get_name(_unit) <<
" is not of 'energy' type (returns nan(1))" <<
do_endl;
140 return std::nan(
"1");
143 glog <<
warning <<
"Level is only known relatively to an offset, use the _with_offset option to get the relative energy" <<
do_endl;
144 return std::nan(
"1");
146 return get(
"energy")->get_value(_unit);
172 glog <<
error << gunits->get_name(_unit) <<
" is not of 'time' or 'energy' type (returns nan(1))" <<
do_endl;
173 return std::nan(
"1");
175 return get(
"lifetime")->get_value(_unit);
188 lifetime_str =
"STABLE";
195 for (
auto &unit : units) {
216 return fisYrast_uncertain;
218 return fisYrast_exact;
231 std::cout << std::setw(15) << left << flevel_id;
237 std::cout << std::setw(15) << left <<
" ";
239 std::cout << std::setw(15) << left << fspin_parity->get_jpi_str();
245 std::cout << std::setw(15) << left <<
" ";
248 std::cout << std::setw(15) << left <<
" "
249 << std::setw(15) << left <<
" "
250 << std::setw(15) << left <<
" ";
252 std::cout << std::endl;
254 constexpr size_t print_label_width = 14;
255 std::ostringstream level_message;
256 level_message << std::left << std::setw(print_label_width) <<
"Nuclear level:";
261 glog <<
info << level_message.str() <<
" " << &energy_print;
263 glog <<
" ; Jpi: " << setw(4) << fspin_parity->get_jpi_str();
268 glog <<
" [1rst isomer]";
270 glog <<
" [2nd isomer]";
272 glog <<
" [3rd isomer]";
277 glog <<
" uncertain level tag: " << funcertain_level;
282 const size_t comment_prefix_size = 13;
283 const size_t line_offset = comment_prefix_size + print_label_width + 1;
284 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)
double get_mean_lifetime(tkunit_manager::units_keys _unit=tkunit_manager::s)
Mean lifetime tau = T1/2 / ln(2); time units only; same missing/stable rules.
shared_ptr< tkmeasure > get_lifetime_measure()
Legacy stored measure: half-life in time units, width in energy units.
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
void set_electric_quadrupole(tkdb_table::measure_data_struct &_struc)
define the level electric quadrupole moment
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
void set_energy_offset(const tkstring &_offset)
define the energy offset
tklevel(int _id, const tkdb_table::measure_data_struct &_struc)
tkstring get_lifetime_str()
Legacy formatting of T1/2 or Gamma (not mean lifetime).
bool is_uncertain()
check if the level is uncertain
bool is_energy_offset()
to know if the energy is known with an energy offset
double get_decay_width(tkunit_manager::units_keys _unit=tkunit_manager::keV)
Decay width Gamma = hbar/tau; energy units only. Stable: 0; absent: NaN.
double get_electric_quadrupole()
return the electric quadrupole moment in barns
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 stored ENSDF half-life (time) or width (energy).
double get_half_life(tkunit_manager::units_keys _unit=tkunit_manager::s)
Half-life T1/2; time units only. Stable: +inf; absent/invalid unit: NaN.
bool has_comment()
check if a comment exists
double get_magnetic_dipole()
return the magnetic dipole moment in nuclear magnetons
void set_magnetic_dipole(tkdb_table::measure_data_struct &_struc)
define the level magnetic dipole moment
Stores a physical measurement with its value, unit, and uncertainty.
void set_type(const tkstring &_type)
set the measured data type (energy, lifetime...)
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
tkproperty_list(tkstring _name)
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 const std::vector< std::tuple< tkstring, units_type, double > > funits_properties
double state_time_value(const shared_ptr< tkmeasure > &measure, bool stable, tkunit_manager::units_keys unit, bool width)
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