39#include "tkensdf_reader.h"
56 glog.set_class(
"ensdf_ascii_reader");
57 glog.set_method(
tkstring::form(
"open_nuc(%s,%d)",_nuc_name.data(),_ftype));
59 if(TKN_SYS ==
nullptr) {
60 glog <<
error_v <<
" TKN_SYS environment variable not defined, cannot find the repository of the data bases !" <<
do_endl;
69 if(_ftype ==
kensdf) file_name =
tkstring::Form(
"%s/ENSDF/%s.ens",finput_folder.data(),_nuc_name.data());
70 else if(_ftype ==
kxundl) file_name =
tkstring::Form(
"%s/XUNDL/%s.ens",finput_folder.data(),_nuc_name.data());
72 glog <<
warning_v <<
" database for nucleus " << _nuc_name <<
" not found" <<
do_endl;
81 return open_file(file_name);
84bool tkensdf_reader::open_file(
const tkstring &_file_name)
86 glog.set_class(
"ensdf_ascii_reader");
87 glog.set_method(
tkstring::form(
"open_file(%s)", _file_name.data()));
89 if ( fEnsdf_file.is_open() ) {
92 fEnsdf_file.open(_file_name);
102 bool new_dataset =
false;
106 getline(fEnsdf_file,record);
108 if(! fEnsdf_file.good())
break;
120 if ( !fEnsdf_file && new_dataset) {
121 the_identification_record.
fposition.second = read_record;
122 fDataSets.push_back(the_identification_record);
123 the_identification_record.
clear();
134 if(fVerbose) the_identification_record.
print(std::cout);
139 fDataSets.push_back(the_identification_record);
140 the_identification_record.
clear();
144 if(fVerbose) glog <<
info << fDataSets.size() <<
" datasets have been found in the ENSDF file " << _file_name <<
do_endl;
147 return fEnsdf_file.is_open();
152 if(!fEnsdf_file.is_open()) {
157 if(fdata_type==
kxundl) data_type =
"XUNDL";
158 glog <<
info <<
"Database type: "<< data_type <<
do_endl;
159 glog <<
info << fDataSets.size() <<
" datasets have been found for nucleus " << fNucleus <<
":"<<
do_endl;
160 for(
auto &key: fDataSets) key.print(std::cout);
168 if(_dataset ==
nullptr)
return false;
171 getline(fEnsdf_file,record);
172 return fEnsdf_file.good();
177 if(_dataset ==
nullptr)
return false;
180 getline(fEnsdf_file,record);
181 return fEnsdf_file.good();
184void tkensdf_reader::close_file()
194 std::cout<<std::endl;
199 for(
auto i: frecords_counter) {
203 std::cout<< left <<
" - Record Type : counts without(with) continuation records" << std::endl;
204 for(
auto i: frecords_counter) {
205 if(i.first ==
tkensdf_record::kident) std::cout<< left <<
" - identification : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
206 else if(i.first ==
tkensdf_record::khistory) std::cout<< left <<
" - History : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
207 else if(i.first ==
tkensdf_record::kq_value) std::cout<< left <<
" - Q-value : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
208 else if(i.first ==
tkensdf_record::kxref) std::cout<< left <<
" - X-ref : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
209 else if(i.first ==
tkensdf_record::kcomment) std::cout<< left <<
" - Comment : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
210 else if(i.first ==
tkensdf_record::kparent) std::cout<< left <<
" - Parent : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
211 else if(i.first ==
tkensdf_record::knorm) std::cout<< left <<
" - Normalisation : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
212 else if(i.first ==
tkensdf_record::kprodnorm) std::cout<< left <<
" - Production norm : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
213 else if(i.first ==
tkensdf_record::klevel) std::cout<< left <<
" - Level : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
214 else if(i.first ==
tkensdf_record::kbeta) std::cout<< left <<
" - Beta : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
215 else if(i.first ==
tkensdf_record::kec) std::cout<< left <<
" - EC : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
216 else if(i.first ==
tkensdf_record::kalpha) std::cout<< left <<
" - Alpha : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
217 else if(i.first ==
tkensdf_record::kparticle) std::cout<< left <<
" - Particle : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
218 else if(i.first ==
tkensdf_record::kgamma) std::cout<< left <<
" - Gamma : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
219 else if(i.first ==
tkensdf_record::kreference)std::cout<< left <<
" - Reference : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
220 else if(i.first ==
tkensdf_record::kend) std::cout<< left <<
" - End : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
221 else if(i.first ==
tkensdf_record::kunknown) std::cout<< left <<
" - Unknown : " << setw(maxsize1+1) << i.second.first <<
" (" << setw(maxsize2) << i.second.second <<
")" << std::endl;
223 std::cout<<std::endl;
Decodding of the ENSDF identification record properties.
void print(std::ostream &) const override
virtual bool set_record(const tkstring &_record) override
define the record from a string
std::pair< int, int > fposition
void set_stpop_position(int _pos)
void set_current_position(int _pos)
void set_start_position(int _pos)
int get_current_position()
void print_datasets()
print the list of loaded data sets for the current nucleus and data type
bool open_nuc(const tkstring &_nuc_name, const ensdf_data_type &_ftype=kensdf)
open the file for the slected nucleus and data type, and extract the available data sets
bool first_record(tkensdf_ident_rec *_dataset, tkstring &record)
move in the current file to the first record of the selected data set
void print_record_counters()
print record counters
bool next_record(tkensdf_ident_rec *_dataset, tkstring &record)
get the next record of the selected data set
Decodding of the ENSDF records.
virtual bool set_record(const tkstring &_record)
define the record from a string. Option false only checks if the record is an identification record
bool is_continuation_record()
to now if the record is a continuation record or not
record_type get_record_type()
get record type
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
tkstring copy() const
Returns a copy of this string.
tkstring & to_lower()
Change all letters to lower case.
static const char * form(const char *_format,...)
static tkstring Form(const char *_format,...)
tkstring & capitalize()
Change first letter of string from lower to upper case.
tklog & error_v(tklog &log)
tklog & warning_v(tklog &log)
tklog & error(tklog &log)
tklog & do_endl(tklog &log)