TkN 2.3
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 * This software is governed by the CeCILL-B license under French law and *
11 * abiding by the rules of distribution of free software. You can use, *
12 * modify and/ or redistribute the software under the terms of the *
13 * CeCILL-B license as circulated by CEA, CNRS and INRIA at the following *
14 * URL \"http://www.cecill.info\". *
15 * *
16 * As a counterpart to the access to the source code and rights to copy, *
17 * modify and redistribute granted by the license, users are provided *
18 * only with a limited warranty and the software's author, the holder of *
19 * the economic rights, and the successive licensors have only limited *
20 * liability. *
21 * *
22 * In this respect, the user's attention is drawn to the risks associated *
23 * with loading, using, modifying and/or developing or reproducing the *
24 * software by the user in light of its specific status of free software, *
25 * that may mean that it is complicated to manipulate, and that also *
26 * therefore means that it is reserved for developers and experienced *
27 * professionals having in-depth computer knowledge. Users are therefore *
28 * encouraged to load and test the software's suitability as regards *
29 * their requirements in conditions enabling the security of their *
30 * systems and/or data to be ensured and, more generally, to use and *
31 * operate it in the same conditions as regards security. *
32 * *
33 * The fact that you are presently reading this means that you have had *
34 * knowledge of the CeCILL-B license and that you accept its terms. *
35 ********************************************************************************/
36
37#ifndef tkmanager_H
38#define tkmanager_H
39
40#include <map>
41#include <mutex>
42#include <functional>
43#include <unordered_map>
44#include <utility>
45
46#include "tklevel_scheme.h"
47#include "tknucleus.h"
48#include "tkstring.h"
49
50#ifdef HAS_ROOT
51#include "TClass.h"
52#endif
53
54namespace tkn {
55
56
64 int Z {0};
65 int N {0};
66 double value_mev {std::numeric_limits<double>::quiet_NaN()};
67 double sigma_mev {std::numeric_limits<double>::quiet_NaN()};
68 std::string type;
69
70 void print() {cout << "(Z,N) = " << Z << ", " << N << " : " << type << " = " << value_mev << " MeV, sigma = " << sigma_mev << endl;}
71};
72
74{
75 friend class tknucleus;
76
77 static std::recursive_mutex& get_mutex() {
78 static std::recursive_mutex mutex;
79 return mutex;
80 }
81
82protected:
83 std::map<tkstring, shared_ptr<tklevel_scheme>> fmap_of_level_scheme;
84
85 std::vector<shared_ptr<tknucleus>> fvector_of_nuclei;
86
87 std::map<tkstring, shared_ptr<tknucleus>> fmap_of_nuclei;
88 std::map<int, std::map<int, shared_ptr<tknucleus>>> fmap_of_nuclei_per_z_and_a;
89 std::map<int, std::vector<shared_ptr<tknucleus>>> fmap_of_nuclei_per_z;
90 std::map<int, std::vector<shared_ptr<tknucleus>>> fmap_of_nuclei_per_a;
91 std::map<int, std::vector<shared_ptr<tknucleus>>> fmap_of_nuclei_per_n;
92
93 std::map<int, tkstring> fmap_of_symbols;
94
95 int fmax_level_id=0;
96 int fmax_decay_id=0;
97
98 static tkmanager* g_data_manager;
99
101 std::unordered_map<std::string, std::vector<tkn_drip_point>> fdrip_lines;
102
103public:
104 static tkmanager* the_data_manager();
105 tkmanager();
106 virtual ~tkmanager();
107
109 bool is_level_scheme_loaded(const tkstring &_nuc) {return fmap_of_level_scheme.count(_nuc)!=0;}
110
112 void preload_level_schemes(bool _verbose=false);
113
115 bool known_nucleus(tkstring _nuc){return fmap_of_nuclei.count(_nuc);}
117 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));}
119 bool known_element(tkstring _nuc, int &_z);
121 bool known_element(int _z) { return fmap_of_nuclei_per_z.count(_z); }
123 const tkstring &get_element_symbol(int _charge){return fmap_of_symbols[_charge];}
124
126 vector<shared_ptr<tknucleus> > get_nuclei(std::function<bool(shared_ptr<tknucleus>)>const& _selection);
127
129 const vector<shared_ptr<tknucleus>> &get_nuclei(){return fvector_of_nuclei;}
130
132 const std::map<tkstring, shared_ptr<tknucleus>> &get_map_of_nuclei(){return fmap_of_nuclei;}
134 const std::map<int, std::vector<shared_ptr<tknucleus>>> &get_map_of_nuclei_per_z(){return fmap_of_nuclei_per_z;}
136 const std::map<int, std::vector<shared_ptr<tknucleus>>> &get_map_of_nuclei_per_a(){return fmap_of_nuclei_per_a;}
138 const std::map<int, std::vector<shared_ptr<tknucleus>>> &get_map_of_nuclei_per_n(){return fmap_of_nuclei_per_n;}
139
141 const vector<shared_ptr<tknucleus>> &get_nuclei_for_z(int z){return fmap_of_nuclei_per_z[z];}
143 const vector<shared_ptr<tknucleus>> &get_nuclei_for_a(int a){return fmap_of_nuclei_per_a[a];}
145 const vector<shared_ptr<tknucleus>> &get_nuclei_for_n(int n){return fmap_of_nuclei_per_n[n];}
146
148 shared_ptr<tknucleus> get_nucleus(const tkstring &_nuc){ return (fmap_of_nuclei.count(_nuc)) ? fmap_of_nuclei[_nuc] : nullptr;}
150 shared_ptr<tknucleus> get_nucleus(int _z, int _a) { return (known_nucleus(_z, _a)) ? fmap_of_nuclei_per_z_and_a[_z][_a] : nullptr;}
151
153 int get_new_level_id();
155 int get_new_decay_id();
156
158 void set_max_level_id(int _id) {if(_id>fmax_level_id) fmax_level_id = _id;}
160 void set_max_decay_id(int _id) {if(_id>fmax_decay_id) fmax_decay_id = _id;}
161
163 std::vector<tkn_drip_point> get_drip_line(const std::string& _type, bool reduce_per_Z=true);
164
165protected:
166 void preload_nuclei();
167 shared_ptr<tklevel_scheme> get_level_scheme(const tkstring &_nuc, int _zz, int _aa);
168
170 void load_drip_lines(const tkstring& json_path);
171
172#ifdef HAS_ROOT
174 ClassDef(tkmanager,0)
175#endif
176
177};
178}
179
180#define gmanager (tkn::tkmanager::the_data_manager())
181
182#endif
Manages the database loading and provides access to the physics properties.
Definition tkmanager.h:74
void set_max_level_id(int _id)
define the max value of the attributed level ids
Definition tkmanager.h:158
friend class tknucleus
Definition tkmanager.h:75
static tkmanager * the_data_manager()
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:136
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:143
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:132
shared_ptr< tknucleus > get_nucleus(const tkstring &_nuc)
return a shared pointer to a nucleus from its name
Definition tkmanager.h:148
bool known_nucleus(int _z, int _a)
is the nucleus Z and A known
Definition tkmanager.h:117
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:145
const vector< shared_ptr< tknucleus > > & get_nuclei()
return a vector containing all the known nuclei
Definition tkmanager.h:129
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:150
virtual ~tkmanager()
bool known_nucleus(tkstring _nuc)
is the nucleus symbol known (ex: "12C")
Definition tkmanager.h:115
const tkstring & get_element_symbol(int _charge)
returns the element symbol for a given proton number
Definition tkmanager.h:123
void set_max_decay_id(int _id)
define the max value of the attributed level ids
Definition tkmanager.h:160
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:134
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:138
bool known_element(int _z)
is the element Z is known
Definition tkmanager.h:121
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:141
bool is_level_scheme_loaded(const tkstring &_nuc)
returns true if the level scheme has already been loaded
Definition tkmanager.h:109
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
Definition tkstring.h:54
Definition tklog.cpp:39
A single drip-line data point.
Definition tkmanager.h:63
int Z
Proton number.
Definition tkmanager.h:64
double value_mev
Quantity value (MeV)
Definition tkmanager.h:66
std::string type
Quantity type: "S1n", "S2n", "S1p", or "S2p".
Definition tkmanager.h:68
int N
Neutron number.
Definition tkmanager.h:65
double sigma_mev
Quantity uncertainty (MeV)
Definition tkmanager.h:67