-
Notifications
You must be signed in to change notification settings - Fork 0
/
Database.cxx
112 lines (101 loc) · 3.22 KB
/
Database.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (c) 2013 Patrick Huck
#include "StRoot/BesCocktail/Database.h"
#include <fstream>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/range/adaptor/map.hpp>
namespace fs = boost::filesystem;
namespace ad = boost::adaptors;
using std::cout;
using std::endl;
DatabaseManager* DatabaseManager::mDbm = NULL;
DatabaseManager::DatabaseManager(const string& d, bool bWrite)
: dbfile(d)
{
if ( !bWrite ) {
// load database (set mDB)
if ( dbfile == "" ) {
if ( fs::exists("db.yml") ) {
cout << "WARNING: using db.yml as database" << endl;
dbfile = "db.yml";
} else {
cout << "ERROR: not database input file provided and db.yml not found" << endl;
exit(0);
}
}
YAML::Node nodeIn = YAML::LoadFile(dbfile);
mDB = nodeIn.as<Database>();
initCcbrMap();
}
}
DatabaseManager* DatabaseManager::Instance(const string& d, bool bWrite) {
if ( !mDbm ) mDbm = new DatabaseManager(d, bWrite);
return mDbm;
}
void DatabaseManager::initCcbrMap() {
int id[4] = { 411, 421, 431, 4122 };
for ( int i = 0; i < 4; ++i ) {
mMapCcbr[id[i]] = getHdrVar("ccbr").at(i);
}
}
double DatabaseManager::getDecayMass(const string& p) {
if ( p == "omega" ) return getProperty("pion", "mass");
if ( p == "phi" ) return getProperty("eta", "mass");
return 0.;
}
double DatabaseManager::getMaxMassBW(const string& p) {
double arg = 1./getAlpha() - 1.;
double w = getProperty(p, "width");
double m = getProperty(p, "mass");
return 0.5*w*sqrt(arg) + m;
}
double DatabaseManager::getRatioBR(const string& p) { // dalitz / (ee + dalitz)
double br_ee = getProperty(p, "br_ee");
double br_da = getProperty(p, "br_da");
return br_da/(br_ee+br_da);
}
double DatabaseManager::getSumBR(const string& p) { // ee + dalitz
double br_ee = getProperty(p, "br_ee");
double br_da = getProperty(p, "br_da");
return br_ee+br_da;
}
double DatabaseManager::getPyBrWeight2(const int& p, const int& n) {
return getPyBrWeight(p) * getPyBrWeight(n);
}
void DatabaseManager::print() {
cout << "=== Header ===" << endl;
BOOST_FOREACH(string s, mDB.mHdr | ad::map_keys) {
cout << " " << s << ": ";
BOOST_FOREACH(double p, mDB.mHdr[s]) { cout << p << " " << std::flush; }
cout << endl;
}
cout << "=== Particles ===" << endl;
BOOST_FOREACH(string s, mDB.mPrt | ad::map_keys) {
cout << s << endl;
BOOST_FOREACH(string k, mDB.mPrt[s] | ad::map_keys) {
cout << " " << k << ": " << mDB.mPrt[s][k] << endl;
}
}
cout << "=== Hagedorn Parameters ===" << endl;
BOOST_FOREACH(string k, mDB.mHgd | ad::map_keys) {
cout << " " << k << ": ";
BOOST_FOREACH(double n, mDB.mHgd[k]) { cout << n << " "; }
cout << endl;
}
cout << "=== Tsallis Parameters ===" << endl;
BOOST_FOREACH(double e, mDB.mTsa | ad::map_keys) {
cout << " " << e << ": ";
BOOST_FOREACH(string s, mDB.mTsa[e] | ad::map_keys) {
cout << s << "=" << mDB.mTsa[e][s] << " ";
}
cout << endl;
}
cout << "=== Invariant Yields ===" << endl;
BOOST_FOREACH(double e, mDB.mYld | ad::map_keys) {
cout << " " << e << ": ";
BOOST_FOREACH(string p, mDB.mYld[e] | ad::map_keys) {
cout << p << "=" << mDB.mYld[e][p] << " ";
}
cout << endl;
}
}