TkN 2.4
Toolkit for Nuclei
Loading...
Searching...
No Matches
tkdecay.cpp
1/********************************************************************************
2 * Copyright (c) : Université de Lyon 1, CNRS/IN2P3, UMR5822, *
3 * IP2I, F-69622 Villeurbanne Cedex, France *
4 * Normandie Université, ENSICAEN, UNICAEN, CNRS/IN2P3, *
5 * LPC Caen, F-14000 Caen, France *
6 * Contibutor(s) : *
7 * Jérémie Dudouet jeremie.dudouet@cnrs.fr [2020] *
8 * Diego Gruyer diego.gruyer@cnrs.fr [2020] *
9 * *
10 * Licensed under the MIT License <http://opensource.org/licenses/MIT>. *
11 * SPDX-License-Identifier: MIT *
12 ********************************************************************************/
13
14#include "tkdecay.h"
15#include "tklevel.h"
16#include "tklog.h"
17
18namespace tkn {
29}
30
31using namespace tkn;
32
33array<tkstring,6> tkdecay::decay_type_str = {"undefined", "beta", "ec", "alpha", "particle", "gamma"};
34
35tkdecay::tkdecay(int _id, int _from_id, int _to_id, const tkdb_table::measure_data_struct &_struc, decay_type _type) :
36 tkproperty_list("decay"),
37 fdecay_id(_id),
38 fdecay_level_from_id(_from_id),
39 fdecay_level_to_id(_to_id),
40 fdecay_type(_type)
41{
42 shared_ptr<tkmeasure> energy = make_shared<tkmeasure>(_struc.value,_struc.unit);
43 if(_struc.value>=0.) energy->set_info(tkproperty::kKnown);
44 if(_struc.err>0.) energy->set_error(_struc.err);
45 else if(_struc.err_low>0. && _struc.err_high>0.) energy->set_error(_struc.err_low,_struc.err_high);
46 if(!_struc.info.is_empty()) energy->set_info_tag(_struc.info);
47 energy->set_type(tkstring::form("%s decay energy",decay_type_str.at(fdecay_type).data()));
48 add_property("energy",energy);
49}
50
57{
58 return get("energy")->get_value(_unit);
59}
60
69void tkdecay::print(const tkstring &_option) const
70{
71 // in line printout
72 if(_option.contains("tab")) {
73 std::cout << std::setw(15) << left << fdecay_id << std::setw(15) << left << get_energy_meas()->get_value();
74 if(get_energy_meas()->get_error()>0.) std::cout << std::setw(15) << left << get_energy_meas()->get_error() << std::endl;
75 else std::cout << " " << std::setw(15) << left << " " << std::endl;
76 }
77 else {
78 if(not _option.contains("quiet")) glog << info;
79 glog << get_energy_meas();
80 if(has_property("mult")) glog << ", mult " << get_property("mult");
81 for(auto &prop: fProperties) {
82 if(prop.first=="energy") continue;
83 if(prop.first=="mult") continue;
84 if(prop.second.type=="TEXT") {
85 glog << ", " << prop.second.value;
86 if(!prop.second.unit.is_empty()) cout << " " << prop.second.unit;
87 }
88 else glog << ", " << get(prop.first).get();
89 }
90 if(is_uncertain()) {
91 glog << " uncertain decay tag: " << funcertain_decay;
92 }
93 if(_option.contains("levto")) {
94 glog << " final level: " << flevelto->get_spin_parity_str() << " (";
95 if(flevelto->is_energy_offset()) glog << flevelto->get_offset_bandhead()<<"+";
96 auto save_precision = cout.precision();
97 glog << setprecision(flevelto->get_energy_measure()->get_exp_error_precision(flevelto->get_energy_measure()->get_value())) << flevelto->get_energy(tkunit_manager::keV,true) << " keV)";
98 cout.precision(save_precision);
99 }
100 glog << do_endl;
101 if(has_comment()&&_option.contains("com")) {
102 tkstring _comment = get_comment().copy().replace_all("\n","\n ");
103 glog << comment << _comment << do_endl;
104 }
105 }
106}
107
108#ifdef HAS_ROOT
110ClassImp(tkdecay);
111#endif
112
114{
115 shared_ptr<tkmeasure> RI = make_shared<tkmeasure>(_struc.value,_struc.unit);
116 RI->set(_struc.value,_struc.unit);
117 RI->set_info(tkproperty::kKnown);
118 if(_struc.err>0.) RI->set_error(_struc.err);
119 if(!_struc.info.is_empty()) RI->set_info_tag(_struc.info);
120 RI->set_type("RI");
121 add_property("RI",RI);
122}
123
124void tkgammadecay::set_relative_intensity(double _val, double _unc)
125{
126 auto RI = get("RI");
127 if(!RI) {
128 auto new_RI = make_shared<tkmeasure>(_val,"%");
129 new_RI->set(_val,"%");
130 new_RI->set_info(tkproperty::kKnown);
131 if(_unc>0.) new_RI->set_error(_unc);
132 new_RI->set_type("RI");
133 add_property("RI",new_RI);
134 }
135 else {
136 RI->set(_val);
137 if(_unc>0.) RI->set_error(_unc);
138 }
140
142{
143 add_property_str("mult",_mul,"");
144}
145
147{
148 shared_ptr<tkmeasure> MR = make_shared<tkmeasure>(_struc.value,_struc.unit);
149 MR->set(_struc.value,_struc.unit);
150 MR->set_info(tkproperty::kKnown);
151 if(_struc.err>0.) MR->set_error(_struc.err);
152 else if(_struc.err_low>0. && _struc.err_high>0.) MR->set_error(_struc.err_low,_struc.err_high);
153 if(!_struc.info.is_empty()) MR->set_info_tag(_struc.info);
154 MR->set_type("mix ratio");
155 add_property("mix ratio",MR);
156}
157
159{
160 shared_ptr<tkmeasure> CC = make_shared<tkmeasure>(_struc.value,_struc.unit);
161 CC->set(_struc.value,_struc.unit);
162 CC->set_info(tkproperty::kKnown);
163 if(_struc.err>0.) CC->set_error(_struc.err);
164 if(!_struc.info.is_empty()) CC->set_info_tag(_struc.info);
165 CC->set_type("conv");
166 add_property("conv",CC);
167}
168
170{
171 tkstring name = _struc.info;
172 tkstring type = name.tokenize(";").front().remove_all("TYPE=");
173 shared_ptr<tkmeasure> B = make_shared<tkmeasure>(_struc.value,_struc.unit);
174 B->set_info(tkproperty::kKnown);
175 if(_struc.err>0.) B->set_error(_struc.err);
176 else if(_struc.err_low>0. && _struc.err_high>0.) B->set_error(_struc.err_low,_struc.err_high);
177 if(!_struc.info.is_empty()) B->set_info_tag(_struc.info);
178 B->set_type(type);
179 add_property(type,B);
180}
181
190{
191 if(!has_property("RI")) return std::nan("1");
192 return get("RI")->get_value();
193}
194
203{
204 if(!has_property("mix ratio")) return std::nan("1");
205 return get("mix ratio")->get_value();
206}
207
211
216{
217 if(!has_property("conv")) return std::nan("1");
218 return get("conv")->get_value();
219}
220
221shared_ptr<tkmeasure> tkgammadecay::get_trans_prob_measure(bool _elec, int _L, bool _WU)
222{
223 tkstring name = "B";
224 if(_elec) name += "E";
225 else name += "M";
226 name += to_string(_L);
227 if(_WU) name += "W";
228 return get(name);
229}
230
239double tkgammadecay::get_trans_prob(bool _elec, int _L, bool _WU)
240{
241 auto meas = get_trans_prob_measure(_elec, _L, _WU);
242 if(!meas) return std::nan("1");
243 return meas->get_value();
244}
Stores information on a nuclear decay.
Definition tkdecay.h:33
bool is_uncertain() const
check if the decay is uncertain
Definition tkdecay.h:75
const tkstring & get_comment() const
get the level comment string
Definition tkdecay.h:73
void print(const tkstring &_option="") const
print the decay properties
Definition tkdecay.cpp:173
static array< tkstring, 6 > decay_type_str
Definition tkdecay.h:40
bool has_comment() const
check if a comment exists
Definition tkdecay.h:71
double get_energy(const tkunit_manager::units_keys _unit=tkunit_manager::units_keys::keV)
returns the energy in keV by default
Definition tkdecay.cpp:160
shared_ptr< tkmeasure > get_energy_meas() const
returns the energy tkmeasure object
Definition tkdecay.h:63
tkdecay(int _id, int _from_id, int _to_id, const tkdb_table::measure_data_struct &_struc, decay_type _type)
Definition tkdecay.cpp:139
void set_relative_intensity(tkdb_table::measure_data_struct &_struc)
set the relative intensity info
Definition tkdecay.cpp:217
double get_trans_prob(bool _elec, int _L, bool _WU)
returns the gamma gamma transition probability value (ex: BE2 in Weiksopf units, get_trans_prob(1,...
Definition tkdecay.cpp:343
void set_mixing_ratio(tkdb_table::measure_data_struct &_struc)
set the mixing ratio info
Definition tkdecay.cpp:250
double get_conv_coeff()
returns the gamma conversion coefficient value
Definition tkdecay.cpp:319
double get_mixing_ratio()
returns the gamma mixing ratio value
Definition tkdecay.cpp:306
double get_relative_intensity()
returns the gamma relative intensity (100% correspond the the more intence gamma-ray)
Definition tkdecay.cpp:293
void set_multipolarity(const tkstring &_mul)
set the relative intensity info
Definition tkdecay.cpp:245
void set_transition_probability(tkdb_table::measure_data_struct &_struc)
set the transition probability
Definition tkdecay.cpp:273
shared_ptr< tkmeasure > get_trans_prob_measure(bool _elec, int _L, bool _WU)
returns the gamma transition probability tkmeasure object (ex: BE2 in Weiksopf units,...
Definition tkdecay.cpp:325
void set_conv_coeff(tkdb_table::measure_data_struct &_struc)
set the conversion coeff
Definition tkdecay.cpp:262
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....
Definition tkstring.h:31
tkstring copy() const
Returns a copy of this string.
Definition tkstring.cpp:347
static const char * form(const char *_format,...)
Definition tkstring.cpp:408
std::vector< tkstring > tokenize(const tkstring &_delim=" ") const
Create a vector of string separated by at least one delimiter.
Definition tkstring.cpp:231
bool is_empty() const
Definition tkstring.h:140
bool contains(const char *_pat, ECaseCompare _cmp=kExact) const
Definition tkstring.h:174
tkstring & replace_all(const tkstring &_s1, const tkstring &_s2)
Definition tkstring.h:180
units_keys
units identifiers
Definition tkunit.h:46
Definition tklog.cpp:16
tklog & info(tklog &log)
Definition tklog.h:313
tklog & do_endl(tklog &log)
Definition tklog.h:212
tklog & comment(tklog &log)
Definition tklog.h:319
data structure used to fill a tkmeasure object from the sqlite database
Definition tkdb_table.h:49