TkN 2.7
Toolkit for Nuclei
Loading...
Searching...
No Matches
tkmoments_builder.h
1/********************************************************************************
2 * Copyright (c) : Université de Lyon 1, CNRS/IN2P3, UMR5822, *
3 * IP2I, F-69622 Villeurbanne Cedex, France *
4 * *
5 * Licensed under the MIT License <http://opensource.org/licenses/MIT>. *
6 * SPDX-License-Identifier: MIT *
7 ********************************************************************************/
8
9#ifndef tkmoments_builder_H
10#define tkmoments_builder_H
11
12#include "tkdatabase.h"
13
14#include <map>
15#include <string>
16#include <utility>
17#include <vector>
18
19namespace tkn {
20
29public:
30 explicit tkmoments_builder(tkdatabase *_database);
31 virtual ~tkmoments_builder() = default;
32
33 int fill_database(const char *_magnetic_filename,
34 const char *_quadrupole_filename,
35 int _only_charge = 0,
36 int _only_mass = 0);
37 int fill_database(const char *_magnetic_filename,
38 const char *_quadrupole_filename,
39 int _only_charge,
40 int _only_mass,
41 const char *_corrections_filename);
42
43 int get_imported_ground_state_count() const { return fImportedGroundStates; }
44 int get_imported_level_count() const { return fImportedLevels; }
45 int get_skipped_value_count() const { return fSkippedValues; }
46 int get_unmatched_level_count() const { return fUnmatchedLevels; }
47 int get_source_row_count() const { return fSourceRows; }
48 int get_level_candidate_row_count() const { return fLevelCandidateRows; }
49 int get_physically_forbidden_count() const { return fPhysicallyForbidden; }
50 int get_relaxed_level_match_count() const { return fRelaxedLevelMatches; }
51 int get_parity_relaxed_match_count() const { return fParityRelaxedMatches; }
52 int get_repaired_spin_match_count() const { return fRepairedSpinMatches; }
53 int get_corrected_source_field_count() const { return fCorrectedSourceFields; }
54 int get_alternative_moment_row_count() const { return fAlternativeMomentRows; }
56 { return fIncompatibleAlternativeMomentRows; }
57
58private:
59 struct level_candidate {
60 int id = -1;
61 double energy = 0.;
62 std::string offset;
63 std::string spin_parity;
64 double lifetime = 0.;
65 std::string lifetime_unit;
66 bool has_lifetime = false;
67 bool stable = false;
68 };
69
70 struct level_match {
71 int id = -1;
72 std::string method;
73 std::string adopted_spin;
74 };
75
76 struct parsed_energy {
77 double value = 0.;
78 std::string offset;
79 bool valid = false;
80 };
81
82 struct parsed_moment {
83 double value = 0.;
84 double uncertainty = 0.;
85 double uncertainty_low = 0.;
86 double uncertainty_high = 0.;
87 bool asymmetric = false;
88 bool has_uncertainty = false;
89 std::string info;
90 std::string source_fix;
91 std::string alternative;
92 bool alternative_incompatible = false;
93 bool valid = false;
94 };
95
96 using nucleus_key = std::pair<int, int>;
97
98 tkdatabase *fDataBase = nullptr;
99 bool fHasLevelTable = false;
100 std::map<nucleus_key, int> fIsotopeIds;
101 std::map<nucleus_key, bool> fIsotopeStable;
102 std::map<nucleus_key, std::vector<level_candidate>> fAdoptedLevels;
103 std::map<int, std::string> fLevelSpins;
104
105 int fImportedGroundStates = 0;
106 int fImportedLevels = 0;
107 int fSkippedValues = 0;
108 int fUnmatchedLevels = 0;
109 int fSourceRows = 0;
110 int fLevelCandidateRows = 0;
111 int fPhysicallyForbidden = 0;
112 int fRelaxedLevelMatches = 0;
113 int fParityRelaxedMatches = 0;
114 int fRepairedSpinMatches = 0;
115 int fCorrectedSourceFields = 0;
116 int fAlternativeMomentRows = 0;
117 int fIncompatibleAlternativeMomentRows = 0;
118
119 bool load_targets();
120 bool clear_existing_moments(int _only_charge, int _only_mass) const;
121 int import_file(const char *_filename,
122 const std::string &_moment_column,
123 const std::string &_property_name,
124 const std::string &_unit,
125 int _only_charge,
126 int _only_mass,
127 const char *_corrections_filename);
128
129 static parsed_energy parse_energy(const std::string &_text);
130 static parsed_moment parse_moment(const std::string &_text);
131 static std::string normalize_spin(const std::string &_text);
132 static bool spin_matches(const std::string &_stone_spin,
133 const std::string &_ensdf_spin);
134 static bool static_moment_allowed(const std::string &_property_name,
135 const std::string &_spin);
136 static bool lifetime_matches(const std::string &_stone_lifetime,
137 const level_candidate &_candidate);
138
139 level_match find_level(const nucleus_key &_nucleus,
140 const parsed_energy &_energy,
141 const std::string &_spin,
142 const std::string &_lifetime) const;
143 bool update_measure(const std::string &_table,
144 const std::string &_prefix,
145 const std::string &_id_column,
146 int _id,
147 const parsed_moment &_moment,
148 const std::string &_unit,
149 const std::string &_provenance) const;
150};
151
152} // namespace tkn
153
154#endif
Interface to the sqlite database.
Definition tkdatabase.h:33
int get_imported_level_count() const
int get_incompatible_alternative_moment_row_count() const
int get_alternative_moment_row_count() const
int get_imported_ground_state_count() const
tkmoments_builder(tkdatabase *_database)
int get_skipped_value_count() const
int get_corrected_source_field_count() const
int get_level_candidate_row_count() const
int get_physically_forbidden_count() const
int fill_database(const char *_magnetic_filename, const char *_quadrupole_filename, int _only_charge=0, int _only_mass=0)
int get_unmatched_level_count() const
int get_parity_relaxed_match_count() const
virtual ~tkmoments_builder()=default
int get_repaired_spin_match_count() const
int get_relaxed_level_match_count() const
Definition tklog.cpp:16