TkN 2.1
Toolkit for Nuclei
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 * This software is governed by the CeCILL-B license under French law and *
11 * abiding by the rules of distribution of free software. You can use, *
12 * modify and/ or redistribute the software under the terms of the *
13 * CeCILL-B license as circulated by CEA, CNRS and INRIA at the following *
14 * URL \"http://www.cecill.info\". *
15 * *
16 * As a counterpart to the access to the source code and rights to copy, *
17 * modify and redistribute granted by the license, users are provided *
18 * only with a limited warranty and the software's author, the holder of *
19 * the economic rights, and the successive licensors have only limited *
20 * liability. *
21 * *
22 * In this respect, the user's attention is drawn to the risks associated *
23 * with loading, using, modifying and/or developing or reproducing the *
24 * software by the user in light of its specific status of free software, *
25 * that may mean that it is complicated to manipulate, and that also *
26 * therefore means that it is reserved for developers and experienced *
27 * professionals having in-depth computer knowledge. Users are therefore *
28 * encouraged to load and test the software's suitability as regards *
29 * their requirements in conditions enabling the security of their *
30 * systems and/or data to be ensured and, more generally, to use and *
31 * operate it in the same conditions as regards security. *
32 * *
33 * The fact that you are presently reading this means that you have had *
34 * knowledge of the CeCILL-B license and that you accept its terms. *
35 ********************************************************************************/
36
37#include "tkdecay.h"
38#include "tklevel.h"
39#include "tklog.h"
40
41namespace tkn {
52}
53
54using namespace tkn;
55
56array<tkstring,6> tkdecay::decay_type_str = {"undefined", "beta", "ec", "alpha", "particle", "gamma"};
57
58tkdecay::tkdecay(int _id, int _from_id, int _to_id, const tkdb_table::measure_data_struct &_struc, decay_type _type) :
59 tkproperty_list("decay"),
60 fdecay_id(_id),
61 fdecay_level_from_id(_from_id),
62 fdecay_level_to_id(_to_id),
63 fdecay_type(_type)
64{
65 shared_ptr<tkmeasure> energy = make_shared<tkmeasure>(_struc.value,_struc.unit);
66 if(_struc.value>=0.) energy->set_info(tkproperty::kKnown);
67 if(_struc.err>0.) energy->set_error(_struc.err);
68 else if(_struc.err_low>0. && _struc.err_high>0.) energy->set_error(_struc.err_low,_struc.err_high);
69 if(!_struc.info.is_empty()) energy->set_info_tag(_struc.info);
70 energy->set_type(tkstring::form("%s decay energy",decay_type_str.at(fdecay_type).data()));
71 add_property("energy",energy);
72}
73
80{
81 return get("energy")->get_value(_unit);
82}
83
92void tkdecay::print(const tkstring &_option) const
93{
94 // in line printout
95 if(_option.contains("tab")) {
96 std::cout << std::setw(15) << left << fdecay_id << std::setw(15) << left << get_energy_meas()->get_value();
97 if(get_energy_meas()->get_error()>0.) std::cout << std::setw(15) << left << get_energy_meas()->get_error() << std::endl;
98 else std::cout << " " << std::setw(15) << left << " " << std::endl;
99 }
100 else {
101 if(not _option.contains("quiet")) glog << info;
102 glog << get_energy_meas();
103 if(has_property("mult")) glog << ", mult " << get_property("mult");
104 for(auto &prop: fProperties) {
105 if(prop.first=="energy") continue;
106 if(prop.first=="mult") continue;
107 if(prop.second.type=="TEXT") {
108 glog << ", " << prop.second.value;
109 if(!prop.second.unit.is_empty()) cout << " " << prop.second.unit;
110 }
111 else glog << ", " << get(prop.first).get();
112 }
113 if(is_uncertain()) {
114 glog << " uncertain decay tag: " << funcertain_decay;
115 }
116 if(_option.contains("levto")) {
117 glog << " final level: " << flevelto->get_spin_parity_str() << " (";
118 if(flevelto->is_energy_offset()) glog << flevelto->get_offset_bandhead()<<"+";
119 auto save_precision = cout.precision();
120 glog << setprecision(flevelto->get_energy_measure()->get_exp_error_precision(flevelto->get_energy_measure()->get_value())) << flevelto->get_energy(tkunit_manager::keV,true) << " keV)";
121 cout.precision(save_precision);
122 }
123 glog << do_endl;
124 if(has_comment()&&_option.contains("com")) {
125 tkstring _comment = get_comment().copy().replace_all("\n","\n ");
126 glog << comment << _comment << do_endl;
127 }
128 }
129}
130
131#ifdef HAS_ROOT
133ClassImp(tkdecay);
134#endif
135
137{
138 shared_ptr<tkmeasure> RI = make_shared<tkmeasure>(_struc.value,_struc.unit);
139 RI->set(_struc.value,_struc.unit);
140 RI->set_info(tkproperty::kKnown);
141 if(_struc.err>0.) RI->set_error(_struc.err);
142 if(!_struc.info.is_empty()) RI->set_info_tag(_struc.info);
143 RI->set_type("RI");
144 add_property("RI",RI);
145}
146
147void tkgammadecay::set_relative_intensity(double _val, double _unc)
148{
149 auto RI = get("RI");
150 if(!RI) {
151 shared_ptr<tkmeasure> RI = make_shared<tkmeasure>(_val,"%");
152 RI->set(_val,"%");
153 RI->set_info(tkproperty::kKnown);
154 if(_unc>0.) RI->set_error(_unc);
155 RI->set_type("RI");
156 add_property("RI",RI);
157 }
158 else {
159 RI->set(_val);
160 if(_unc>0.) RI->set_error(_unc);
161 }
162}
163
165{
166 add_property_str("mult",_mul,"");
167}
168
170{
171 shared_ptr<tkmeasure> MR = make_shared<tkmeasure>(_struc.value,_struc.unit);
172 MR->set(_struc.value,_struc.unit);
173 MR->set_info(tkproperty::kKnown);
174 if(_struc.err>0.) MR->set_error(_struc.err);
175 else if(_struc.err_low>0. && _struc.err_high>0.) MR->set_error(_struc.err_low,_struc.err_high);
176 if(!_struc.info.is_empty()) MR->set_info_tag(_struc.info);
177 MR->set_type("mix ratio");
178 add_property("mix ratio",MR);
179}
180
182{
183 shared_ptr<tkmeasure> CC = make_shared<tkmeasure>(_struc.value,_struc.unit);
184 CC->set(_struc.value,_struc.unit);
185 CC->set_info(tkproperty::kKnown);
186 if(_struc.err>0.) CC->set_error(_struc.err);
187 if(!_struc.info.is_empty()) CC->set_info_tag(_struc.info);
188 CC->set_type("conv");
189 add_property("conv",CC);
190}
191
193{
194 tkstring name = _struc.info;
195 tkstring type = name.tokenize(";").front().remove_all("TYPE=");
196 shared_ptr<tkmeasure> B = make_shared<tkmeasure>(_struc.value,_struc.unit);
197 B->set_info(tkproperty::kKnown);
198 if(_struc.err>0.) B->set_error(_struc.err);
199 else if(_struc.err_low>0. && _struc.err_high>0.) B->set_error(_struc.err_low,_struc.err_high);
200 if(!_struc.info.is_empty()) B->set_info_tag(_struc.info);
201 B->set_type(type);
202 add_property(type,B);
203}
204
213{
214 if(!has_property("RI")) return std::nan("1");
215 return get("RI")->get_value();
216}
217
226{
227 if(!has_property("mix ratio")) return std::nan("1");
228 return get("mix ratio")->get_value();
229}
230
239{
240 if(!has_property("conv")) return std::nan("1");
241 return get("conv")->get_value();
242}
243
244shared_ptr<tkmeasure> tkgammadecay::get_trans_prob_measure(bool _elec, int _L, bool _WU)
245{
246 tkstring name = "B";
247 if(_elec) name += "E";
248 else name += "M";
249 name += to_string(_L);
250 if(_WU) name += "W";
251 return get(name);
252}
253
262double tkgammadecay::get_trans_prob(bool _elec, int _L, bool _WU)
263{
264 auto meas = get_trans_prob_measure(_elec, _L, _WU);
265 if(!meas) return std::nan("1");
266 return meas->get_value();
267}
Stores information on a nuclear decay.
Definition: tkdecay.h:56
bool is_uncertain() const
check if the decay is uncertain
Definition: tkdecay.h:98
const tkstring & get_comment() const
get the level comment string
Definition: tkdecay.h:96
void print(const tkstring &_option="") const
print the decay properties
Definition: tkdecay.cpp:92
static array< tkstring, 6 > decay_type_str
Definition: tkdecay.h:63
bool has_comment() const
check if a comment exists
Definition: tkdecay.h:94
double get_energy(const tkunit_manager::units_keys _unit=tkunit_manager::units_keys::keV)
returns the energy in keV by default
Definition: tkdecay.cpp:79
shared_ptr< tkmeasure > get_energy_meas() const
returns the energy tkmeasure object
Definition: tkdecay.h:86
void set_relative_intensity(tkdb_table::measure_data_struct &_struc)
set the relative intensity info
Definition: tkdecay.cpp:136
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:262
void set_mixing_ratio(tkdb_table::measure_data_struct &_struc)
set the mixing ratio info
Definition: tkdecay.cpp:169
double get_conv_coeff()
returns the gamma conversion coefficient value
Definition: tkdecay.cpp:238
double get_mixing_ratio()
returns the gamma mixing ratio value
Definition: tkdecay.cpp:225
double get_relative_intensity()
returns the gamma relative intensity (100% correspond the the more intence gamma-ray)
Definition: tkdecay.cpp:212
void set_multipolarity(const tkstring &_mul)
set the relative intensity info
Definition: tkdecay.cpp:164
void set_transition_probability(tkdb_table::measure_data_struct &_struc)
set the transition probability
Definition: tkdecay.cpp:192
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:244
void set_conv_coeff(tkdb_table::measure_data_struct &_struc)
set the conversion coeff
Definition: tkdecay.cpp:181
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:54
tkstring copy() const
Returns a copy of this string.
Definition: tkstring.cpp:370
static const char * form(const char *_format,...)
Definition: tkstring.cpp:431
std::vector< tkstring > tokenize(const tkstring &_delim=" ") const
Create a vector of string separated by at least one delimiter.
Definition: tkstring.cpp:254
bool is_empty() const
Definition: tkstring.h:163
bool contains(const char *_pat, ECaseCompare _cmp=kExact) const
Definition: tkstring.h:197
tkstring & replace_all(const tkstring &_s1, const tkstring &_s2)
Definition: tkstring.h:203
units_keys
units identifiers
Definition: tkunit.h:69
Definition: tklog.cpp:39
tklog & info(tklog &log)
Definition: tklog.h:336
tklog & do_endl(tklog &log)
Definition: tklog.h:235
tklog & comment(tklog &log)
Definition: tklog.h:342
data structure used to fill a tkmeasure object from the sqlite database
Definition: tkdb_table.h:72