14#include "tkensdf_gamma_rec.h"
39 fIs_final_level_set = _gamma_record.fIs_final_level_set;
40 fFinal_level_energy = _gamma_record.fFinal_level_energy;
52 fUncertain_record = frecord.
substr(79,1);
58 set_relative_intensity(frecord);
61 set_multipolarity(frecord);
64 set_mixing_ratio(frecord);
67 set_conv_coeff(frecord);
72void tkensdf_gamma_rec::set_relative_intensity(
const tkstring &_record)
74 auto RI_str = _record.
substr(21,8);
75 auto DRI_str = _record.
substr(29,2);
77 if(RI_str.contains(
"(")) {
78 frelative_intensity.
info +=
";VAL=()";
81 frelative_intensity.
value = RI_str.atof();
82 if(frelative_intensity.
value>0) frelative_intensity.
filled =
true;
85 frelative_intensity.
unit =
"%";
86 frelative_intensity.
err = DRI_str.atof();
89void tkensdf_gamma_rec::set_multipolarity(
const tkstring &_record)
91 auto str = _record.
substr(31,10);
95void tkensdf_gamma_rec::set_mixing_ratio(
const tkstring &_record)
100 fmixing_ratio.value = MR_str.
atof();
101 if(fmixing_ratio.value==0)
return;
103 if(!DMR_str.is_empty()) {
105 if(DMR_str.is_alpha()) {
106 fmixing_ratio.info +=
";ERR=" + DMR_str;
113 if(DMR_str.contains(
"+") && DMR_str.contains(
"-")) {
114 bool inv = DMR_str.index(
"-") < DMR_str.index(
"+");
115 DMR_str.replace_all(
"+",
" ");
116 DMR_str.replace_all(
"-",
" ");
117 auto tokens_lt_err = DMR_str.tokenize(
" ");
118 if(tokens_lt_err.size()!=2) {
119 glog <<
error <<
" bad asymetric error decoding in record " << frecord <<
do_endl;
122 tkstring err_low_str = tokens_lt_err.back();
123 tkstring err_high_str = tokens_lt_err.front();
125 err_low_str = tokens_lt_err.front();
126 err_high_str = tokens_lt_err.back();
129 fmixing_ratio.err_low = err_low_str.
atof()*precision;
130 fmixing_ratio.err_high = err_high_str.
atof()*precision;
133 fmixing_ratio.err = DMR_str.atof()*precision;
138 fmixing_ratio.info +=
";ERR=?";
140 fmixing_ratio.filled =
true;
143void tkensdf_gamma_rec::set_conv_coeff(
const tkstring &_record)
145 auto CC_str = _record.
substr(55,7);
146 auto DCC_str = _record.
substr(62,2);
148 fconv_coeff.value = CC_str.
atof();
149 if(fconv_coeff.value>0) fconv_coeff.filled =
true;
152 fconv_coeff.unit =
"";
153 fconv_coeff.err = DCC_str.atof();
156void tkensdf_gamma_rec::set_red_trans_prob(
const tkstring &_record)
158 auto tmp_rec = _record;
161 tkstring trans_name{};
165 if(tmp_rec.begins_with(
"BM")) {
169 if(tmp_rec.begins_with(
"BE")) {
173 if(!(is_elec || is_mag))
return;
175 trans_name += tmp_rec[2];
178 bool wu = (tmp_rec.substr(3,1) ==
"W");
179 if(wu) trans_name +=
"W";
181 tkdb_table::measure_data_struct *the_struct=
nullptr;
182 if(is_elec && wu) the_struct = &fBEW;
183 else if(is_elec && !wu) the_struct = &fBE;
184 else if(is_mag && wu) the_struct = &fBMW;
185 else if(is_mag && !wu) the_struct = &fBM;
186 if(!the_struct)
return;
187 if(the_struct->
filled)
return;
191 the_struct->
value *= pow(100,mult);
192 the_struct->
err *= pow(100,mult);
193 the_struct->
err_low *= pow(100,mult);
194 the_struct->
err_high *= pow(100,mult);
198 the_struct->
value *= pow(100,mult-1);
199 the_struct->
err *= pow(100,mult-1);
200 the_struct->
err_low *= pow(100,mult-1);
201 the_struct->
err_high *= pow(100,mult-1);
202 if(mult==1) the_struct->
unit =
"mu^2";
206 else the_struct->
unit =
"Weisskopf";
208 the_struct->
info +=
";TYPE=" + trans_name;
215 if(tmp_rec.substr(0,1) ==
"=") {
216 tmp_rec.remove_all(
"=");
217 auto toks = tmp_rec.tokenize(
" ");
218 tkstring val = toks.at(0);
220 if(toks.size()>1) err = toks.at(1);
233 auto tokens_lt_err = err.
tokenize(
" ");
234 if(tokens_lt_err.size()!=2) {
235 glog <<
error <<
" bad asymetric error decoding in record " << frecord <<
do_endl;
238 tkstring err_low_str = tokens_lt_err.back();
239 tkstring err_high_str = tokens_lt_err.front();
241 err_low_str = tokens_lt_err.front();
242 err_high_str = tokens_lt_err.back();
245 the_struct->
err_low = err_low_str.
atof()*precision;
249 the_struct->
err = err.
atof()*precision;
253 the_struct->
info +=
";ERR=?";
256 tmp_rec.replace_all(
">",
" GT ").replace_all(
"<",
" LT ");
258 auto toks = tmp_rec.tokenize(
" ");
259 tkstring lim = toks.at(0);
260 tkstring value = toks.at(1);
263 the_struct->
info +=
";ERR=" + lim;
266 the_struct->
filled =
true;
271 auto tokens = fcontinuation_record.tokenize(
"$");
272 for(
auto &token: tokens) {
274 if(token.contains(
"FL=")) {
275 fIs_final_level_set =
true;
276 token.remove_all_extra_white_space().remove_all(
"FL=");
277 if(token.is_float()) fFinal_level_energy = token.atof();
278 else fFinal_level_energy = -1;
280 if(token.contains(
"BE") || token.contains(
"BM")) {
281 set_red_trans_prob(token);
285 check_red_trans_prob();
288void tkensdf_gamma_rec::check_red_trans_prob()
291 double mass = frecord.substr(0,3).atof();
295 double conv = weisskopf_conversion(
true,mass,mult);
302 fBE.
info +=
";ERR=CONV";
308 double conv = 1./weisskopf_conversion(
true,mass,mult);
313 fBEW.
unit =
"Weisskopf";
315 fBEW.
info +=
";ERR=CONV";
318 if(!fBM.filled && fBMW.filled) {
319 tkstring transname = fBMW.info.
tokenize(
";").front().remove_all(
"TYPE=");
321 double conv = weisskopf_conversion(
false,mass,mult);
322 fBM.value = fBMW.value*conv;
323 fBM.err = fBMW.err*conv;
324 fBM.err_low = fBMW.err_low*conv;
325 fBM.err_high = fBMW.err_high*conv;
326 if(mult==1) fBM.unit =
"mu^2";
328 fBM.info = fBMW.info.copy().replace_all(transname,transname.
copy().
remove_all(
"W"));
329 fBM.info +=
";ERR=CONV";
332 if(fBM.filled && !fBMW.filled) {
333 tkstring transname = fBM.info.
tokenize(
";").front().remove_all(
"TYPE=");
335 double conv = 1./weisskopf_conversion(
false,mass,mult);
336 fBMW.value = fBM.value*conv;
337 fBMW.err = fBM.err*conv;
338 fBMW.err_low = fBM.err_low*conv;
339 fBMW.err_high = fBM.err_high*conv;
340 fBMW.unit =
"Weisskopf";
341 fBMW.info = fBM.info.copy().replace_all(transname,transname.
copy().
append(
"W"));
342 fBMW.info +=
";ERR=CONV";
348double tkensdf_gamma_rec::weisskopf_conversion(
bool electric,
double mass,
double mult)
350 if(electric)
return pow(1.2,2.*mult)/(4.*M_PI)*3./(mult+3.)*3./(mult+3.)*pow(mass,2.*mult/3.);
351 return 10./M_PI*pow(1.2,2.*mult-2.)*3./(mult+3.)*3./(mult+3.)*pow(mass,(2.*mult-2.)/3.);
358 fIs_final_level_set =
false;
359 fFinal_level_energy = -1.;
360 frelative_intensity.clear();
361 fmultipolarity.clear();
362 fmixing_ratio.clear();
void print(std::ostream &) const override
void analyse_continuation_record() override
analyse a continuation record
virtual void analyse_record() override
analyse the record content
virtual bool set_record(const tkstring &_record) override
define the record from a string
bool decode_energy(const tkstring &_st)
decode an anergy record
tkstring get_energy_str(const tkstring &_record) const
extract the energy part
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
tkstring strip_all_extra_white_space() const
tkstring copy() const
Returns a copy of this string.
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.
tkstring & remove_all(const tkstring &_s1)
tkstring substr(size_type __pos=0, size_type __n=npos) const
Inlines.
int atoi() const
Converts a string to integer value.
size_t index(const char *_s, size_t _pos=0, ECaseCompare _cmp=kExact) const
Returns the index of the substring _s.
tkstring & remove_all_extra_white_space()
bool contains(const char *_pat, ECaseCompare _cmp=kExact) const
tkstring & append(const tkstring &_st)
static double get_precision(tkstring _st)
Extract the precision for a given ENSDF data.
tkstring & replace_all(const tkstring &_s1, const tkstring &_s2)
double atof() const
Converts a string to double value.
tklog & error(tklog &log)
tklog & do_endl(tklog &log)