14#ifndef tklevel_scheme_H
15#define tklevel_scheme_H
23#include "tkn_config.h"
54 tkstring fdataset_comment{};
55 tkstring fdataset_date{};
56 tkstring fdataset_source{};
58 std::vector<shared_ptr<tklevel>> flevels;
59 std::vector<shared_ptr<tkdecay>> fdecays;
60 std::map<int, shared_ptr<tklevel>> fmapoflevels;
64 map<int, shared_ptr<tklevel>> fyrastmap_exact;
65 map<int, shared_ptr<tklevel>> fyrastmap_uncertain;
68 tkdataset(
const tkstring &_nuc,
int _zz,
int _aa,
const tkstring &_name,
int _id) : fid(_id), fA(_aa), fZ(_zz), fname(_name), fnucleus(_nuc) {}
81 bool has_comment()
const {
return !fdataset_comment.is_empty(); }
85 bool has_date()
const {
return !fdataset_date.is_empty(); }
89 bool is_xundl()
const {
return fdataset_source ==
"XUNDL"; }
95 shared_ptr<tkgammadecay>
add_gamma_decay(shared_ptr<tklevel> _lvlfrom, shared_ptr<tklevel> _lvlto,
double _ener = 0.,
double _unc = 0.);
101 const std::vector<shared_ptr<tklevel>> &get_levels() {
return flevels; }
103 const std::vector<shared_ptr<tkdecay>> &get_decays() {
return fdecays; }
106 void check_yrast(shared_ptr<tklevel> _lvl);
109 void print(
const tkstring &_data,
const tkstring &_option =
"");
135 std::map<tkstring, int> fmap_of_dataset_name_id;
136 std::map<int, shared_ptr<tkdataset>> fmap_of_dataset;
138 bool floaded =
false;
155 const shared_ptr<tkdataset> &
get_dataset() {
return fmap_of_dataset[fdatasetid]; }
157 const std::map<int, shared_ptr<tkdataset>> &
get_datasets()
const {
return fmap_of_dataset; }
160 const std::vector<shared_ptr<tklevel>> &
get_levels() {
return fmap_of_dataset[fdatasetid]->get_levels(); }
162 std::vector<shared_ptr<tklevel>>
get_levels(std::function<
bool(shared_ptr<tklevel>)>
const &_selection);
165 const std::vector<shared_ptr<tkdecay>> &
get_decays() {
return fmap_of_dataset[fdatasetid]->get_decays(); }
167 std::vector<shared_ptr<tkdecay>>
get_decays(std::function<
bool(shared_ptr<tkdecay>)>
const &_selection);
175 template <
typename T>
178 std::vector<shared_ptr<T>> decays;
180 auto test = dynamic_pointer_cast<T>(dec);
182 shared_ptr<T> gam = dynamic_pointer_cast<T>(dec);
183 decays.push_back(gam);
201 template <
typename T>
202 const std::vector<shared_ptr<T>>
get_decays(
const std::function<
bool(shared_ptr<T>)> &_selection)
204 vector<shared_ptr<T>> res;
206 std::copy_if(decays.begin(), decays.end(), std::back_inserter(res),
207 [&_selection](
const auto &dec) { return _selection(dec); });
228 template <
typename T>
232 if (lvls.size() != 2) {
233 glog <<
warning <<
"get_decay(" << _name <<
") -- wrong syntax (ex: 2+1->0+1)" <<
do_endl;
236 shared_ptr<tklevel> lvl_from =
get_level(lvls.at(0), _exact);
237 shared_ptr<tklevel> lvl_to =
get_level(lvls.at(1), _exact);
239 glog <<
warning <<
"get_decay(" << _name <<
") -- " << lvls.at(0) <<
" level not found" <<
do_endl;
243 glog <<
warning <<
"get_decay(" << _name <<
") -- " << lvls.at(1) <<
" level not found" <<
do_endl;
246 int lvl_from_id = lvl_from->get_id();
247 int lvl_to_id = lvl_to->get_id();
249 if ((dec->get_level_from_id() == lvl_from_id) && (dec->get_level_to_id() == lvl_to_id))
return dec;
264 template <
typename T>
267 shared_ptr<T> clostest_dec;
268 double best_ediff = 1e6;
270 double ediff = abs(dec->get_energy() - _energy);
271 if (ediff < best_ediff) {
283 void init(
bool _load_default_dataset);
shared_ptr< tklevel > add_level(double _ener, double _unc, tkstring _unit, tkstring _jpistr)
manually add a new level to the dataset
virtual ~tkdataset()=default
const tkstring & get_comment() const
returns the dataset comment
shared_ptr< tkgammadecay > add_gamma_decay(shared_ptr< tklevel > _lvlfrom, shared_ptr< tklevel > _lvlto, double _ener=0., double _unc=0.)
add a new decay between two levels to the dataset
bool has_comment() const
returns true if the dataset has a comment
const tkstring & get_source() const
returns the dataset source ("ENSDF" or "XUNDL")
bool is_xundl() const
returns true if the dataset comes from XUNDL
bool has_date() const
returns true if the dataset has a date
const tkstring & get_name() const
returns the dataset name
tkdataset(const tkstring &_nuc, int _zz, int _aa, const tkstring &_name, int _id)
const tkstring & get_nucleus_name() const
returns the nucleus name associated to this dataset
friend class tklevel_scheme
int get_id() const
returns the dataset ID
const tkstring & get_date() const
returns the dataset date (YYYY-MM format)
Manages the available datasets for a given nucleus.
virtual ~tklevel_scheme()=default
void print(const tkstring &_data="", const tkstring &_option="")
print the level scheme information
const std::vector< shared_ptr< tklevel > > & get_levels()
get the vector containing all the levels
const shared_ptr< T > get_decay(double _energy)
Template method to get the decay of type T (ex: tkgammadecay) corresponding to the closest energy.
const std::vector< shared_ptr< T > > get_decays()
Template method to get the vector containing all the decays of type T (ex: tkgammadecay)
const std::map< int, shared_ptr< tkdataset > > & get_datasets() const
returns the list of available datasets
const shared_ptr< T > get_decay(const tkstring &_name, bool _exact=true)
Template method to get the decay of type T (ex: tkgammadecay) corresponding to the given name.
bool select_dataset(const tkstring &_dataset_name)
select a dataset using its name
const std::vector< shared_ptr< T > > get_decays(const std::function< bool(shared_ptr< T >)> &_selection)
Template method to get the vector containing all the decays of type T (ex: tkgammadecay) filtered by ...
const shared_ptr< tkdataset > & get_dataset()
returns the current dataset
shared_ptr< tklevel > get_level(const tkstring &_name, bool _exact=true)
get the level corresponding to the given name
tklevel_scheme(const tkstring &_nuc, int _zz, int _aa, bool _load_default_dataset=true)
const std::vector< shared_ptr< tkdecay > > & get_decays()
get the vector containing all the decays
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
std::vector< tkstring > tokenize_from_string(const tkstring &_delim) const
Create a vector of string separated by a full string as delimiter.
tklog & do_endl(tklog &log)
tklog & warning(tklog &log)