37#ifndef tklevel_scheme_H
38#define tklevel_scheme_H
46#include "tkn_config.h"
69 std::vector<shared_ptr<tklevel>> flevels;
70 std::vector<shared_ptr<tkdecay>> fdecays;
71 std::map<int, shared_ptr<tklevel>> fmapoflevels;
75 map<int,shared_ptr<tklevel>> fyrastmap_exact;
76 map<int,shared_ptr<tklevel>> fyrastmap_uncertain;
79 tkdataset(
const tkstring &_nuc,
int _zz,
int _aa,
const tkstring &_name,
int _id) : fid(_id), fA(_aa), fZ(_zz), fname(_name), fnucleus(_nuc) {}
94 shared_ptr<tkgammadecay>
add_gamma_decay(shared_ptr<tklevel> _lvlfrom, shared_ptr<tklevel> _lvlto,
double _ener=0.,
double _unc=0.);
100 const std::vector<shared_ptr<tklevel>> &get_levels() {
return flevels;}
102 const std::vector<shared_ptr<tkdecay>> &get_decays() {
return fdecays;}
105 void check_yrast(shared_ptr<tklevel> _lvl);
108 void print(
const tkstring &_data,
const tkstring &_option=
"");
115 std::map<tkstring, int> fmap_of_dataset_name_id;
116 std::map<int, shared_ptr<tkdataset>> fmap_of_dataset;
118 bool floaded =
false;
135 const shared_ptr<tkdataset> &
get_dataset() {
return fmap_of_dataset[fdatasetid];}
137 const std::map<int, shared_ptr<tkdataset>> &
get_datasets()
const {
return fmap_of_dataset;}
140 const std::vector<shared_ptr<tklevel>> &
get_levels() {
return fmap_of_dataset[fdatasetid]->get_levels();}
142 std::vector<shared_ptr<tklevel>>
get_levels(std::function<
bool(shared_ptr<tklevel>)>
const& _selection);
145 const std::vector<shared_ptr<tkdecay>> &
get_decays() {
return fmap_of_dataset[fdatasetid]->get_decays();}
147 std::vector<shared_ptr<tkdecay>>
get_decays(std::function<
bool(shared_ptr<tkdecay>)>
const& _selection);
157 std::vector<shared_ptr<T>> decays;
159 auto test = dynamic_pointer_cast<T>(dec);
161 shared_ptr<T> gam = dynamic_pointer_cast<T>(dec);
162 decays.push_back(gam);
181 const std::vector<shared_ptr<T>>
get_decays(
const std::function<
bool (shared_ptr<T>)> &_selection) {
182 vector<shared_ptr<T>> res;
184 std::copy_if(decays.begin(), decays.end(), std::back_inserter(res),
185 [&_selection](
const auto &dec) { return _selection(dec); });
209 if(lvls.size()!=2) {glog <<
warning <<
"get_decay(" << _name <<
") -- wrong syntax (ex: 2+1->0+1)" <<
do_endl;
return nullptr;}
210 shared_ptr<tklevel> lvl_from =
get_level(lvls.at(0),_exact);
211 shared_ptr<tklevel> lvl_to =
get_level(lvls.at(1),_exact);
212 if(!lvl_from) {glog <<
warning <<
"get_decay(" << _name <<
") -- " << lvls.at(0) <<
" level not found" <<
do_endl;
return nullptr;}
213 if(!lvl_to) {glog <<
warning <<
"get_decay(" << _name <<
") -- " << lvls.at(1) <<
" level not found" <<
do_endl;
return nullptr;}
214 int lvl_from_id = lvl_from->get_id();
215 int lvl_to_id = lvl_to->get_id();
217 if((dec->get_level_from_id() == lvl_from_id) && (dec->get_level_to_id() == lvl_to_id))
return dec;
234 shared_ptr<T> clostest_dec;
235 double best_ediff=1e6;
237 double ediff = abs(dec->get_energy()-_energy);
238 if(ediff<best_ediff) {
shared_ptr< tklevel > add_level(double _ener, double _unc, tkstring _unit, tkstring _jpistr)
manually add a new level to the dataset
virtual ~tkdataset()=default
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
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
virtual ~tklevel_scheme()=default
tklevel_scheme(const tkstring &_nuc, int _zz, int _aa)
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
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)