TkN 2.4
Toolkit for Nuclei
Loading...
Searching...
No Matches
tkmanager.h
1/********************************************************************************
2 * Copyright (c) : Université de Lyon 1, CNRS/IN2P3, UMR5822, *
3 * IP2I, F-69622 Villeurbanne Cedex, France *
4 * Normandie Université, ENSICAEN, UNICAEN, CNRS/IN2P3, *
5 * LPC Caen, F-14000 Caen, France *
6 * Contibutor(s) : *
7 * Jérémie Dudouet jeremie.dudouet@cnrs.fr [2020] *
8 * Diego Gruyer diego.gruyer@cnrs.fr [2020] *
9 * *
10 * Licensed under the MIT License <http://opensource.org/licenses/MIT>. *
11 * SPDX-License-Identifier: MIT *
12 ********************************************************************************/
13
14#ifndef tkmanager_H
15#define tkmanager_H
16
17#include <map>
18#include <mutex>
19#include <functional>
20#include <unordered_map>
21#include <utility>
22
23#include "tklevel_scheme.h"
24#include "tknucleus.h"
25#include "tkstring.h"
26
27#ifdef HAS_ROOT
28#include "TClass.h"
29#endif
30
31namespace tkn {
32
33
41 int Z {0};
42 int N {0};
43 double value_mev {std::numeric_limits<double>::quiet_NaN()};
44 double sigma_mev {std::numeric_limits<double>::quiet_NaN()};
45 std::string type;
46
47 void print() {cout << "(Z,N) = " << Z << ", " << N << " : " << type << " = " << value_mev << " MeV, sigma = " << sigma_mev << endl;}
48};
49
51{
52 friend class tknucleus;
53
54 static std::recursive_mutex& get_mutex() {
55 static std::recursive_mutex mutex;
56 return mutex;
57 }
58
59protected:
60 std::map<tkstring, shared_ptr<tklevel_scheme>> fmap_of_level_scheme;
61
62 std::vector<shared_ptr<tknucleus>> fvector_of_nuclei;
63
64 std::map<tkstring, shared_ptr<tknucleus>> fmap_of_nuclei;
65 std::map<int, std::map<int, shared_ptr<tknucleus>>> fmap_of_nuclei_per_z_and_a;
66 std::map<int, std::vector<shared_ptr<tknucleus>>> fmap_of_nuclei_per_z;
67 std::map<int, std::vector<shared_ptr<tknucleus>>> fmap_of_nuclei_per_a;
68 std::map<int, std::vector<shared_ptr<tknucleus>>> fmap_of_nuclei_per_n;
69
70 std::map<int, tkstring> fmap_of_symbols;
71
72 int fmax_level_id=0;
73 int fmax_decay_id=0;
74
75 static tkmanager* g_data_manager;
76
78 std::unordered_map<std::string, std::vector<tkn_drip_point>> fdrip_lines;
79
80public:
82 tkmanager();
83 virtual ~tkmanager();
84
86 bool is_level_scheme_loaded(const tkstring &_nuc) {return fmap_of_level_scheme.count(_nuc)!=0;}
87
89 void preload_level_schemes(bool _verbose=false);
90
92 bool known_nucleus(tkstring _nuc){return fmap_of_nuclei.count(_nuc);}
94 bool known_nucleus(int _z, int _a){return (fmap_of_nuclei_per_z_and_a.count(_z) && fmap_of_nuclei_per_z_and_a.at(_z).count(_a));}
96 bool known_element(tkstring _nuc, int &_z);
98 bool known_element(int _z) { return fmap_of_nuclei_per_z.count(_z); }
100 const tkstring &get_element_symbol(int _charge){return fmap_of_symbols[_charge];}
101
103 vector<shared_ptr<tknucleus> > get_nuclei(std::function<bool(shared_ptr<tknucleus>)>const& _selection);
104
106 const vector<shared_ptr<tknucleus>> &get_nuclei(){return fvector_of_nuclei;}
107
109 const std::map<tkstring, shared_ptr<tknucleus>> &get_map_of_nuclei(){return fmap_of_nuclei;}
111 const std::map<int, std::vector<shared_ptr<tknucleus>>> &get_map_of_nuclei_per_z(){return fmap_of_nuclei_per_z;}
113 const std::map<int, std::vector<shared_ptr<tknucleus>>> &get_map_of_nuclei_per_a(){return fmap_of_nuclei_per_a;}
115 const std::map<int, std::vector<shared_ptr<tknucleus>>> &get_map_of_nuclei_per_n(){return fmap_of_nuclei_per_n;}
116
118 const vector<shared_ptr<tknucleus>> &get_nuclei_for_z(int z){return fmap_of_nuclei_per_z[z];}
120 const vector<shared_ptr<tknucleus>> &get_nuclei_for_a(int a){return fmap_of_nuclei_per_a[a];}
122 const vector<shared_ptr<tknucleus>> &get_nuclei_for_n(int n){return fmap_of_nuclei_per_n[n];}
123
125 shared_ptr<tknucleus> get_nucleus(const tkstring &_nuc){ return (fmap_of_nuclei.count(_nuc)) ? fmap_of_nuclei[_nuc] : nullptr;}
127 shared_ptr<tknucleus> get_nucleus(int _z, int _a) { return (known_nucleus(_z, _a)) ? fmap_of_nuclei_per_z_and_a[_z][_a] : nullptr;}
128
130 int get_new_level_id();
132 int get_new_decay_id();
133
135 void set_max_level_id(int _id) {if(_id>fmax_level_id) fmax_level_id = _id;}
137 void set_max_decay_id(int _id) {if(_id>fmax_decay_id) fmax_decay_id = _id;}
138
140 std::vector<tkn_drip_point> get_drip_line(const std::string& _type, bool reduce_per_Z=true);
141
142protected:
143 void preload_nuclei();
144 shared_ptr<tklevel_scheme> get_level_scheme(const tkstring &_nuc, int _zz, int _aa);
145
147 void load_drip_lines(const tkstring& json_path);
148
149#ifdef HAS_ROOT
151 ClassDef(tkmanager,0)
152#endif
153
154};
155}
156
157#define gmanager (tkn::tkmanager::the_data_manager())
158
159#endif
Manages the database loading and provides access to the physics properties.
Definition tkmanager.h:51
void set_max_level_id(int _id)
define the max value of the attributed level ids
Definition tkmanager.h:135
friend class tknucleus
Definition tkmanager.h:52
static tkmanager * the_data_manager()
Definition tkmanager.cpp:83
int get_new_level_id()
define a new unique level id
const std::map< int, std::vector< shared_ptr< tknucleus > > > & get_map_of_nuclei_per_a()
return a map of nuclei vector sorted by a
Definition tkmanager.h:113
const vector< shared_ptr< tknucleus > > & get_nuclei_for_a(int a)
return a vector containing all the known nuclei for a given a
Definition tkmanager.h:120
std::vector< tkn_drip_point > get_drip_line(const std::string &_type, bool reduce_per_Z=true)
Get the drip line for a given type (optionally reduced per Z)
const std::map< tkstring, shared_ptr< tknucleus > > & get_map_of_nuclei()
return a map of nuclei sorted by name
Definition tkmanager.h:109
shared_ptr< tknucleus > get_nucleus(const tkstring &_nuc)
return a shared pointer to a nucleus from its name
Definition tkmanager.h:125
bool known_nucleus(int _z, int _a)
is the nucleus Z and A known
Definition tkmanager.h:94
const vector< shared_ptr< tknucleus > > & get_nuclei_for_n(int n)
return a vector containing all the known nuclei for a given n
Definition tkmanager.h:122
const vector< shared_ptr< tknucleus > > & get_nuclei()
return a vector containing all the known nuclei
Definition tkmanager.h:106
int get_new_decay_id()
define a new unique decay id
shared_ptr< tknucleus > get_nucleus(int _z, int _a)
return a shared pointer to a nucleus from its z an a
Definition tkmanager.h:127
virtual ~tkmanager()
bool known_nucleus(tkstring _nuc)
is the nucleus symbol known (ex: "12C")
Definition tkmanager.h:92
const tkstring & get_element_symbol(int _charge)
returns the element symbol for a given proton number
Definition tkmanager.h:100
void set_max_decay_id(int _id)
define the max value of the attributed level ids
Definition tkmanager.h:137
const std::map< int, std::vector< shared_ptr< tknucleus > > > & get_map_of_nuclei_per_z()
return a map of nuclei vector sorted by z
Definition tkmanager.h:111
const std::map< int, std::vector< shared_ptr< tknucleus > > > & get_map_of_nuclei_per_n()
return a map of nuclei vector sorted by n
Definition tkmanager.h:115
bool known_element(int _z)
is the element Z is known
Definition tkmanager.h:98
bool known_element(tkstring _nuc, int &_z)
is the element symbol is known (ex: "C")
void preload_level_schemes(bool _verbose=false)
preload all the level schemes from the database
const vector< shared_ptr< tknucleus > > & get_nuclei_for_z(int z)
return a vector containing all the known nuclei for a given z
Definition tkmanager.h:118
bool is_level_scheme_loaded(const tkstring &_nuc)
returns true if the level scheme has already been loaded
Definition tkmanager.h:86
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
Definition tkstring.h:31
Definition tklog.cpp:16
A single drip-line data point.
Definition tkmanager.h:40
int Z
Proton number.
Definition tkmanager.h:41
double value_mev
Quantity value (MeV)
Definition tkmanager.h:43
std::string type
Quantity type: "S1n", "S2n", "S1p", or "S2p".
Definition tkmanager.h:45
int N
Neutron number.
Definition tkmanager.h:42
double sigma_mev
Quantity uncertainty (MeV)
Definition tkmanager.h:44