14#include "tkensdf_record.h"
35 if(_record.size() != (
RSIZE-1)) {
36 glog <<
error_v <<
"oups, record size: "<<_record.length()<<
" not equal to RSIZE: "<<
RSIZE-1<<
do_endl;
52 if(!fcontinuation_record.is_empty()) fcontinuation_record +=
"$";
60 if(!_is_continuation && !fcomment_record.empty()) fcomment_record +=
"\n";
71 f_is_continuation_record =
false;
74 if(fid.match(
"* G ")) {
76 if(!field6.
is_empty()) f_is_continuation_record =
true;
84 if(!field6.
is_empty()) f_is_continuation_record =
true;
88 if(fid.match(
"* L ")) {
90 if(!field6.
is_empty()) f_is_continuation_record =
true;
94 if(fid.match(
"* H ")) {
96 if(!field6.
is_empty()) f_is_continuation_record =
true;
100 if(fid.match(
"* E ")) {
102 if(!field6.
is_empty()) f_is_continuation_record =
true;
106 if(fid.match(
"* B ")) {
108 if(!field6.
is_empty()) f_is_continuation_record =
true;
112 if(frecord.is_empty()) {
117 if(fid.match(
"* ")) {
119 if(!field6.
is_empty()) f_is_continuation_record =
true;
123 if(fid.match(
" X*") && !field9.
is_empty()) {
128 if(fid.match(
"*PN*")) {
130 if(!field6.
is_empty()) f_is_continuation_record =
true;
134 if(fid.match(
" N*")) {
139 if(fid.match(
"* Q ")) {
141 if(!field6.
is_empty()) f_is_continuation_record =
true;
145 if(fid.match(
" P*")) {
150 if(fid.match(
"* A ")) {
152 if(!field6.
is_empty()) f_is_continuation_record =
true;
156 if( (fid.match(
"* *") || fid.match(
"* D*")) && (field9.
equal_to(
"N") || field9.
equal_to(
"P") || field9.
equal_to(
"A")) ) {
158 if(!field6.
is_empty()) f_is_continuation_record =
true;
162 if(fid.match(
" R ")) {
193 fenergy.info +=
";OFF=" + tmp_e;
199 else if(tmp_e.
substr(0,1)==
"+"){
205 index = tmp_e.
index(
"+");
206 if(index != std::string::npos && tmp_e.
substr(index-1,1).
to_lower() !=
"e") {
208 fenergy.info +=
";OFF=" + offset;
214 index = tmp_e.
index(
"(");
215 if(index != std::string::npos) {
217 fenergy.info +=
";VAL=()";
224 fenergy.unit =
"KEV";
225 fenergy.value = tmp_e.
atof();
227 fenergy.filled =
true;
231 fenergy.info +=
";ERR=" + tmp_de;
235 if(fenergy.value>0.) {
236 if(tmp_de.
is_empty()) fenergy.info +=
";ERR=?";
238 fenergy.err = tmp_de.
atof()*precision;
253 flifetime.info =
"? ";
258 flifetime.value = 3.2E23;
259 flifetime.unit =
"S";
260 flifetime.info +=
";STABLE";
263 auto tokens_lt = tmp_lt.
tokenize(
" ");
269 flifetime.value = tokens_lt.front().atof();
271 else flifetime.unit = tokens_lt.back();
278 flifetime.info +=
";ERR=" + lt_err;
286 bool inv = lt_err.
index(
"-") < lt_err.
index(
"+");
289 auto tokens_lt_err = lt_err.
tokenize(
" ");
290 if(tokens_lt_err.size()!=2) {
291 glog <<
error <<
" bad asymetric error decoding in record " << frecord <<
do_endl;
294 tkstring err_low_str = tokens_lt_err.back();
295 tkstring err_high_str = tokens_lt_err.front();
297 err_low_str = tokens_lt_err.front();
298 err_high_str = tokens_lt_err.back();
301 flifetime.err_low = err_low_str.
atof()*precision;
302 flifetime.err_high = err_high_str.
atof()*precision;
305 flifetime.err = lt_err.
atof()*precision;
310 flifetime.info +=
";ERR=?";
314 flifetime.info +=
";ISO=" + _st_ms;
317 flifetime.filled =
true;
329 f_is_continuation_record =
false;
330 fcontinuation_record =
"";
331 fcomment_record =
"";
333 fUncertain_record =
"";
335 fisknown_woth_offset =
false;
341 out <<
"Record: " << frecord << std::endl;
bool decode_lifetime(const tkstring &_st, const tkstring &_st_ms)
decode a lifetime record
bool decode_energy(const tkstring &_st)
decode an anergy record
void check_record_type()
check record type from its string
virtual void print(std::ostream &) const
virtual void add_comment_record(const tkstring &_comment_record, bool _is_continuation=false)
add a continuation record from a string
virtual bool set_record(const tkstring &_record)
define the record from a string. Option false only checks if the record is an identification record
tkstring fglobal_time_unit
virtual void add_continuation_record(const tkstring &_continuation_record)
add a continuation record from a string
void set_offset(tkstring _offset)
set_energy_offset
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
tkstring strip_all_extra_white_space() const
tkstring & to_lower()
Change all letters to lower case.
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.
bool is_alpha() const
Checks whether tkstring is only composed of alphabetic letters.
bool equal_to(const char *_s, ECaseCompare _cmp=kExact) const
Returns true if the string and _s are identical.
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
bool begins_with(const char *_s, ECaseCompare _cmp=kExact) const
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_v(tklog &log)
tklog & error(tklog &log)
tklog & do_endl(tklog &log)