37#ifndef tklevel_scheme_H
38#define tklevel_scheme_H
44#include "tkn_config.h"
67 std::vector<shared_ptr<tklevel>> flevels;
68 std::vector<shared_ptr<tkdecay>> fdecays;
69 std::map<int, shared_ptr<tklevel>> fmapoflevels;
73 map<int,shared_ptr<tklevel>> fyrastmap_exact;
74 map<int,shared_ptr<tklevel>> fyrastmap_uncertain;
77 tkdataset(
const tkstring &_nuc,
int _zz,
int _aa,
const tkstring &_name,
int _id) : fid(_id), fA(_aa), fZ(_zz), fname(_name), fnucleus(_nuc) {}
92 shared_ptr<tkgammadecay>
add_gamma_decay(shared_ptr<tklevel> _lvlfrom, shared_ptr<tklevel> _lvlto,
double _ener=0.,
double _unc=0.);
98 const std::vector<shared_ptr<tklevel>> &get_levels() {
return flevels;}
100 const std::vector<shared_ptr<tkdecay>> &get_decays() {
return fdecays;}
103 void check_yrast(shared_ptr<tklevel> _lvl);
106 void print(
const tkstring &_data,
const tkstring &_option=
"");
113 std::map<tkstring, int> fmap_of_dataset_name_id;
114 std::map<int, shared_ptr<tkdataset>> fmap_of_dataset;
116 bool floaded =
false;
133 const shared_ptr<tkdataset> &
get_dataset() {
return fmap_of_dataset[fdatasetid];}
135 const std::map<int, shared_ptr<tkdataset>>
get_datasets() {
return fmap_of_dataset;}
138 const std::vector<shared_ptr<tklevel>> &
get_levels() {
return fmap_of_dataset[fdatasetid]->get_levels();}
140 std::vector<shared_ptr<tklevel>>
get_levels(std::function<
bool(shared_ptr<tklevel>)>
const& _selection);
143 const std::vector<shared_ptr<tkdecay>> &
get_decays() {
return fmap_of_dataset[fdatasetid]->get_decays();}
145 std::vector<shared_ptr<tkdecay>>
get_decays(std::function<
bool(shared_ptr<tkdecay>)>
const& _selection);
155 std::vector<shared_ptr<T>> decays;
157 auto test = dynamic_pointer_cast<T>(dec);
159 shared_ptr<T> gam = dynamic_pointer_cast<T>(dec);
160 decays.push_back(gam);
179 const std::vector<shared_ptr<T>>
get_decays(
const std::function<
bool (shared_ptr<T>)> &_selection) {
180 vector<shared_ptr<T>> res;
181 for(
const auto &dec : get_decays<T>())
if(_selection(dec)) res.push_back(dec);
205 if(lvls.size()!=2) {glog <<
warning <<
"get_decay(" << _name <<
") -- wrong syntax (ex: 2+1->0+1)" <<
do_endl;
return nullptr;}
206 shared_ptr<tklevel> lvl_from =
get_level(lvls.at(0),_exact);
207 shared_ptr<tklevel> lvl_to =
get_level(lvls.at(1),_exact);
208 if(!lvl_from) {glog <<
warning <<
"get_decay(" << _name <<
") -- " << lvls.at(0) <<
" level not found" <<
do_endl;
return nullptr;}
209 if(!lvl_to) {glog <<
warning <<
"get_decay(" << _name <<
") -- " << lvls.at(1) <<
" level not found" <<
do_endl;
return nullptr;}
210 int lvl_from_id = lvl_from->get_id();
211 int lvl_to_id = lvl_to->get_id();
212 for(
auto dec : get_decays<T>()) {
213 if((dec->get_level_from_id() == lvl_from_id) && (dec->get_level_to_id() == lvl_to_id))
return dec;
230 shared_ptr<T> clostest_dec;
231 double best_ediff=1e6;
232 for(
auto &dec: get_decays<T>()) {
233 double ediff = abs(dec->get_energy()-_energy);
234 if(ediff<best_ediff) {
Stores information on a specific 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
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
int get_id() const
returns the dataset ID
Collection of levels and decay.
virtual ~tklevel_scheme()=default
const std::map< int, shared_ptr< tkdataset > > get_datasets()
returns the list of available datasets
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 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
Stores information on a nuclear level.
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)