20 Units* Units::_theUnits =
nullptr;
22 Units* Units::getUnitsInstance() {
23 if(_theUnits ==
nullptr) {
24 _theUnits =
new Units();
31 return *Units::getUnitsInstance();
35 _unitfactors.insert({
"eV",
eV});
36 _unitfactors.insert({
"ev",
eV});
37 _unitfactors.insert({
"EV",
eV});
38 _unitfactors.insert({
"keV",
keV});
39 _unitfactors.insert({
"KeV",
keV});
40 _unitfactors.insert({
"KEV",
keV});
41 _unitfactors.insert({
"kev",
keV});
42 _unitfactors.insert({
"MeV",
MeV});
43 _unitfactors.insert({
"mev",
MeV});
44 _unitfactors.insert({
"MEV",
MeV});
45 _unitfactors.insert({
"GeV",
GeV});
46 _unitfactors.insert({
"GEV",
GeV});
47 _unitfactors.insert({
"gev",
GeV});
48 _unitfactors.insert({
"TeV",
TeV});
49 _unitfactors.insert({
"TEV",
TeV});
50 _unitfactors.insert({
"tev",
TeV});
53 double Units::getUnitsRescalingToMC(
string mcunits,
string localunits)
const {
54 auto it = _unitfactors.find(mcunits);
55 auto it2 = _unitfactors.find(localunits);
56 if(it != _unitfactors.end() && it2 != _unitfactors.end()) {
57 return it2->second/it->second;
58 }
else if (it == _unitfactors.end()) {
59 throw Error(
"Specified " + mcunits +
" units not found. Mars Climate Orbiter would like a word.");
60 }
else if (it2 == _unitfactors.end()) {
61 throw Error(
"Specified " + localunits +
" units not found. Sometimes the bull wins.");
static constexpr double MeV
Hammer class for dealing with units.
Message logging routines.
Hammer exception definitions.
static constexpr double GeV