44 fdecay_level_from_id(_from_id),
45 fdecay_level_to_id(_to_id),
48 shared_ptr<tkmeasure> energy = make_shared<tkmeasure>(_struc.
value, _struc.
unit);
51 energy->set_error(_struc.
err);
55 energy->set_type(
tkstring::form(
"%s decay energy", decay_type_str.at(fdecay_type).data()));
56 add_property(
"energy", energy);
66 return get(
"energy")->get_value(_unit);
81 std::cout << std::setw(15) << left << fdecay_id << std::setw(15) << left <<
get_energy_meas()->get_value();
83 std::cout << std::setw(15) << left <<
get_energy_meas()->get_error() << std::endl;
85 std::cout <<
" " << std::setw(15) << left <<
" " << std::endl;
88 constexpr size_t print_label_width = 14;
89 std::ostringstream decay_message;
90 std::vector<std::string> property_messages;
92 std::string decay_label =
decay_type_str.at(fdecay_type) +
" decay:";
93 if (!decay_label.empty()) decay_label[0] =
static_cast<char>(std::toupper(
static_cast<unsigned char>(decay_label[0])));
94 decay_message << std::left << std::setw(print_label_width) << decay_label;
98 std::ostringstream energy_message;
99 energy_message << &energy_print;
100 property_messages.push_back(energy_message.str());
103 std::ostringstream property_message;
105 property_messages.push_back(property_message.str());
107 for (
auto &prop : fProperties) {
108 if (prop.first ==
"energy")
continue;
109 if (prop.first ==
"mult")
continue;
110 std::ostringstream property_message;
111 if (prop.second.type ==
"TEXT") {
112 property_message << prop.second.value;
113 if (!prop.second.unit.is_empty()) property_message <<
" " << prop.second.unit;
115 property_message <<
get(prop.first).get();
116 property_messages.push_back(property_message.str());
119 std::ostringstream property_message;
120 property_message <<
"uncertain decay tag: " << funcertain_decay;
121 property_messages.push_back(property_message.str());
124 std::ostringstream property_message;
125 property_message <<
"final level: " << flevelto->get_spin_parity_str();
127 tkmeasure energy_print = *flevelto->get_energy_measure();
129 property_message << &energy_print;
130 property_messages.push_back(property_message.str());
132 const std::string decay_str = decay_message.str();
133 const size_t line_offset = (_option.
contains(
"quiet") ? 16 : 13) + decay_str.length() + 1;
136 if (!property_messages.empty()) {
137 const std::string property_prefix =
"| ";
138 glog <<
" " << property_messages.front();
139 for (
size_t i = 1; i < property_messages.size(); ++i) {
141 << std::string(line_offset,
' ') << property_prefix;
142 for (
char c : property_messages.at(i)) {
144 if (c ==
'\n') glog << std::string(line_offset,
' ') << property_prefix;
150 const size_t comment_prefix_size = 13;
151 const size_t property_prefix_size = 2;
152 const size_t comment_start = line_offset + property_prefix_size;
153 const size_t comment_offset = comment_start > comment_prefix_size ? comment_start - comment_prefix_size : 0;
154 const std::string first_indent(comment_offset,
' ');
167 shared_ptr<tkmeasure> RI = make_shared<tkmeasure>(_struc.
value, _struc.
unit);
170 if (_struc.
err > 0.) RI->set_error(_struc.
err);
173 add_property(
"RI", RI);
180 auto new_RI = make_shared<tkmeasure>(_val,
"%");
181 new_RI->set(_val,
"%");
183 if (_unc > 0.) new_RI->set_error(_unc);
184 new_RI->set_type(
"RI");
185 add_property(
"RI", new_RI);
188 if (_unc > 0.) RI->set_error(_unc);
194 add_property_str(
"mult", _mul,
"");
199 shared_ptr<tkmeasure> MR = make_shared<tkmeasure>(_struc.
value, _struc.
unit);
203 MR->set_error(_struc.
err);
207 MR->set_type(
"mix ratio");
208 add_property(
"mix ratio", MR);
213 shared_ptr<tkmeasure> CC = make_shared<tkmeasure>(_struc.
value, _struc.
unit);
216 if (_struc.
err > 0.) CC->set_error(_struc.
err);
218 CC->set_type(
"conv");
219 add_property(
"conv", CC);
224 tkstring name = _struc.
info;
225 tkstring type = name.
tokenize(
";").front().remove_all(
"TYPE=");
226 shared_ptr<tkmeasure> B = make_shared<tkmeasure>(_struc.
value, _struc.
unit);
229 B->set_error(_struc.
err);
234 add_property(type, B);
247 return get(
"RI")->get_value();
260 return get(
"mix ratio")->get_value();
273 return get(
"conv")->get_value();
298 name += to_string(_L);
299 if (_WU) name +=
"W";
314 if (!meas)
return std::nan(
"1");
315 return meas->get_value();
Represents a nuclear decay transition between two levels.
bool is_uncertain() const
check if the decay is uncertain
const tkstring & get_comment() const
get the level comment string
void print(const tkstring &_option="") const
print the decay properties
static array< tkstring, 6 > decay_type_str
bool has_comment() const
check if a comment exists
double get_energy(const tkunit_manager::units_keys _unit=tkunit_manager::units_keys::keV)
returns the energy in keV by default
shared_ptr< tkmeasure > get_energy_meas() const
returns the energy tkmeasure object
tkdecay(int _id, int _from_id, int _to_id, const tkdb_table::measure_data_struct &_struc, decay_type _type)
void set_relative_intensity(tkdb_table::measure_data_struct &_struc)
set the relative intensity info
double get_trans_prob(bool _elec, int _L, bool _WU)
returns the gamma transition probability value (ex: BE2 in Weisskopf units, get_trans_prob(1,...
void set_mixing_ratio(tkdb_table::measure_data_struct &_struc)
set the mixing ratio info
double get_conv_coeff()
returns the gamma conversion coefficient value
double get_mixing_ratio()
returns the gamma mixing ratio value
double get_relative_intensity()
returns the gamma relative intensity (100% corresponds to the most intense gamma-ray)
void set_multipolarity(const tkstring &_mul)
set the relative intensity info
void set_transition_probability(tkdb_table::measure_data_struct &_struc)
set the transition probability
shared_ptr< tkmeasure > get_trans_prob_measure(bool _elec, int _L, bool _WU)
returns the gamma transition probability tkmeasure object (ex: BE2 in Weisskopf units,...
void set_conv_coeff(tkdb_table::measure_data_struct &_struc)
set the conversion coeff
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
tkstring get_property(const tkstring &_property) const
get the property value as a string
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
static const char * form(const char *_format,...)
std::vector< tkstring > tokenize(const tkstring &_delim=" ") const
Create a vector of string separated by at least one delimiter.
bool contains(const char *_pat, ECaseCompare _cmp=kExact) const
units_keys
units identifiers
std::string wrap_text(const tkstring &_text, size_t _first_content_col, size_t _continuation_col, size_t _max_line_width=80)
tklog & do_endl(tklog &log)
tklog & comment(tklog &log)
data structure used to fill a tkmeasure object from the sqlite database