genie::utils::units Namespace Reference

Simple unit system utilities. More...


double UnitFromString (string u)

Detailed Description

Simple unit system utilities.

Costas Andreopoulos <costas.andreopoulos> University of Liverpool & STFC Rutherford Appleton Lab

May 06, 2004

Copyright (c) 2003-2019, The GENIE Collaboration For the full text of the license visit or see $GENIE/LICENSE

Function Documentation

double genie::utils::units::UnitFromString ( string  u)

Definition at line 26 of file UnitUtils.cxx.

References genie::units::A, genie::units::angstrom, genie::units::b, genie::units::barn, genie::units::centimeter, genie::units::centimeter2, genie::units::centimeter3, genie::units::clhep_def_density_unit, genie::units::cm, genie::units::cm2, genie::units::cm3, genie::units::decimeter, genie::units::decimeter2, genie::units::decimeter3, genie::units::deg, genie::units::degree, genie::units::electronvolt, genie::units::eV, exit(), genie::units::fermi, genie::units::fm, genie::units::g, genie::units::g_cm3, genie::units::GeV, genie::units::GHz, genie::units::gigaelectronvolt, genie::units::gigahertz, genie::units::gram, genie::units::gram_centimeter3, genie::units::hertz, genie::units::Hz, genie::units::keV, genie::units::kg, genie::units::kg_m3, genie::units::kHz, genie::units::kiloelectronvolt, genie::units::kilogram, genie::units::kilogram_meter3, genie::units::kilohertz, LOG, genie::units::m, genie::units::m2, genie::units::m3, genie::units::mb, genie::units::megaelectronvolt, genie::units::megahertz, genie::units::meter, genie::units::meter2, genie::units::meter3, genie::units::MeV, genie::units::mg, genie::units::MHz, genie::units::microbarn, genie::units::micrometer, genie::units::microsecond, genie::units::millibarn, genie::units::milligram, genie::units::millimeter, genie::units::millimeter2, genie::units::millimeter3, genie::units::milliradian, genie::units::millisecond, genie::units::mm, genie::units::mm2, genie::units::mm3, genie::units::mrad, genie::units::ms, genie::units::nanobarn, genie::units::nanometer, genie::units::nanosecond, genie::units::nb, genie::units::ns, genie::units::pb, genie::units::petaelectronvolt, genie::units::PeV, pFATAL, genie::units::picobarn, genie::units::picosecond, genie::units::ps, genie::units::qe, genie::units::qe_coulomb, genie::units::rad, genie::units::radian, genie::units::s, genie::units::second, genie::units::sr, genie::units::steradian, genie::units::teraelectronvolt, genie::units::TeV, submit_hadd::u, genie::units::ub, and genie::units::us.

Referenced by GetCommandLineArgs(), genie::flux::GDk2NuFlux::Initialize(), genie::flux::GNuMIFlux::Initialize(), genie::flux::GDk2NuFlux::LengthUnits(), genie::flux::GNuMIFlux::LengthUnits(), genie::flux::GDk2NuFluxXMLHelper::ParseParamSet(), genie::flux::GNuMIFluxXMLHelper::ParseParamSet(), genie::flux::GNuMIFlux::SetFluxWindow(), genie::flux::GDk2NuFlux::SetLengthUnits(), genie::flux::GNuMIFlux::SetLengthUnits(), genie::flux::GNuMIFlux::UseFluxAtFarDetCenter(), genie::flux::GNuMIFlux::UseFluxAtNearDetCenter(), and genie::flux::GDk2NuFluxXMLHelper::~GDk2NuFluxXMLHelper().

27 {
28 // Returns the appropriate unit based on the input string
29 // The GENIE units are defined in $GENIE/src/Conventions/Units.h
31  if (u == "gigaelectronvolt") return genie::units::gigaelectronvolt;
32  else if (u == "GeV" ) return genie::units::GeV;
34  else if (u == "meter" ) return genie::units::meter;
35  else if (u == "kilogram" ) return genie::units::kilogram;
36  else if (u == "second" ) return genie::units::second;
38  else if (u == "millimeter" ) return genie::units::millimeter;
39  else if (u == "millimeter2" ) return genie::units::millimeter2;
40  else if (u == "millimeter3" ) return genie::units::millimeter3;
41  else if (u == "centimeter" ) return genie::units::centimeter;
42  else if (u == "centimeter2" ) return genie::units::centimeter2;
43  else if (u == "centimeter3" ) return genie::units::centimeter3;
44  else if (u == "decimeter" ) return genie::units::decimeter;
45  else if (u == "decimeter2" ) return genie::units::decimeter2;
46  else if (u == "decimeter3" ) return genie::units::decimeter3;
47  else if (u == "meter2" ) return genie::units::meter2;
48  else if (u == "meter3" ) return genie::units::meter3;
49  else if (u == "micrometer" ) return genie::units::micrometer;
50  else if (u == "nanometer" ) return genie::units::nanometer;
51  else if (u == "angstrom" ) return genie::units::angstrom;
52  else if (u == "fermi" ) return genie::units::fermi;
53  else if (u == "barn" ) return genie::units::barn;
54  else if (u == "millibarn" ) return genie::units::millibarn;
55  else if (u == "microbarn" ) return genie::units::microbarn;
56  else if (u == "nanobarn" ) return genie::units::nanobarn;
57  else if (u == "picobarn" ) return genie::units::picobarn;
59  else if (u == "millisecond" ) return genie::units::millisecond;
60  else if (u == "microsecond" ) return genie::units::microsecond;
61  else if (u == "nanosecond" ) return genie::units::nanosecond;
62  else if (u == "picosecond" ) return genie::units::picosecond;
63  else if (u == "s" ) return genie::units::s;
64  else if (u == "ms" ) return genie::units::ms;
65  else if (u == "us" ) return genie::units::us;
66  else if (u == "ns" ) return genie::units::ns;
67  else if (u == "ps" ) return genie::units::ps;
68  else if (u == "hertz" ) return genie::units::hertz;
69  else if (u == "kilohertz" ) return genie::units::kilohertz;
70  else if (u == "megahertz" ) return genie::units::megahertz;
71  else if (u == "gigahertz" ) return genie::units::gigahertz;
72  else if (u == "Hz" ) return genie::units::Hz;
73  else if (u == "kHz" ) return genie::units::kHz;
74  else if (u == "MHz" ) return genie::units::MHz;
75  else if (u == "GHz" ) return genie::units::GHz;
77  else if (u == "qe" ) return genie::units::qe;
78  else if (u == "qe_coulomb" ) return genie::units::qe_coulomb;
80  else if (u == "electronvolt" ) return genie::units::electronvolt;
81  else if (u == "kiloelectronvolt") return genie::units::kiloelectronvolt;
82  else if (u == "megaelectronvolt") return genie::units::megaelectronvolt;
83  else if (u == "teraelectronvolt") return genie::units::teraelectronvolt;
84  else if (u == "petaelectronvolt") return genie::units::petaelectronvolt;
85  else if (u == "eV" ) return genie::units::eV;
86  else if (u == "keV" ) return genie::units::keV;
87  else if (u == "MeV" ) return genie::units::MeV;
88  else if (u == "TeV" ) return genie::units::TeV;
89  else if (u == "PeV" ) return genie::units::PeV;
91  else if (u == "gram" ) return genie::units::gram;
92  else if (u == "milligram" ) return genie::units::milligram;
93  else if (u == "kg" ) return genie::units::kg;
94  else if (u == "g" ) return genie::units::g;
95  else if (u == "mg" ) return genie::units::mg;
97  else if (u == "kilogram_meter3" ) return genie::units::kilogram_meter3;
98  else if (u == "gram_centimeter3") return genie::units::gram_centimeter3;
99  else if (u == "kg_m3" ) return genie::units::kg_m3;
100  else if (u == "g_cm3" ) return genie::units::g_cm3;
102  else if (u == "radian" ) return genie::units::radian;
103  else if (u == "milliradian" ) return genie::units::milliradian;
104  else if (u == "degree" ) return genie::units::degree;
105  else if (u == "steradian" ) return genie::units::steradian;
106  else if (u == "rad" ) return genie::units::rad;
107  else if (u == "mrad" ) return genie::units::mrad;
108  else if (u == "sr" ) return genie::units::sr;
109  else if (u == "deg" ) return genie::units::deg;
111  else if (u == "mm2" ) return genie::units::mm2;
112  else if (u == "mm3" ) return genie::units::mm3;
113  else if (u == "mm" ) return genie::units::mm;
114  else if (u == "cm2" ) return genie::units::cm2;
115  else if (u == "cm3" ) return genie::units::cm3;
116  else if (u == "cm" ) return genie::units::cm;
117  else if (u == "m2" ) return genie::units::m2;
118  else if (u == "m3" ) return genie::units::m3;
119  else if (u == "m" ) return genie::units::m;
120  else if (u == "A" ) return genie::units::A;
121  else if (u == "fm" ) return genie::units::fm;
122  else if (u == "b" ) return genie::units::b;
123  else if (u == "mb" ) return genie::units::mb;
124  else if (u == "ub" ) return genie::units::ub;
125  else if (u == "nb" ) return genie::units::nb;
126  else if (u == "pb" ) return genie::units::pb;
128  else if (u == "clhep_def_density_unit")
131  else {
132  LOG("Units", pFATAL) << "Unknown units: " << u;
133  exit(1);
134  }
135  return 1.;
136 }
static const double hertz
Definition: Units.h:105
static const double m
Definition: Units.h:79
static const double second
Definition: Units.h:35
static const double kg
Definition: Units.h:144
static const double micrometer
Definition: Units.h:60
static const double nanobarn
Definition: Units.h:69
static const double keV
Definition: Units.h:129
static const double kilogram_meter3
Definition: Units.h:150
static const double meter2
Definition: Units.h:58
static const double teraelectronvolt
Definition: Units.h:125
static const double ps
Definition: Units.h:103
static const double g_cm3
Definition: Units.h:154
static const double ns
Definition: Units.h:102
static const double fermi
Definition: Units.h:63
static const double gigahertz
Definition: Units.h:108
static const double nanometer
Definition: Units.h:61
static const double MeV
Definition: Units.h:130
#define pFATAL
Definition: Messenger.h:57
static const double eV
Definition: Units.h:128
static const double millisecond
Definition: Units.h:94
static const double Hz
Definition: Units.h:110
static const double degree
Definition: Units.h:162
static const double milligram
Definition: Units.h:142
static const double microsecond
Definition: Units.h:95
static const double kiloelectronvolt
Definition: Units.h:123
static const double decimeter2
Definition: Units.h:56
static const double g
Definition: Units.h:145
static const double mm2
Definition: Units.h:74
static const double cm2
Definition: Units.h:77
static const double qe
Definition: Units.h:117
static const double megaelectronvolt
Definition: Units.h:124
static const double angstrom
Definition: Units.h:62
static const double qe_coulomb
Definition: Units.h:118
static const double deg
Definition: Units.h:168
static const double pb
Definition: Units.h:90
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
static const double centimeter3
Definition: Units.h:54
static const double mm3
Definition: Units.h:75
static const double decimeter
Definition: Units.h:55
static const double gram_centimeter3
Definition: Units.h:151
static const double milliradian
Definition: Units.h:161
static const double clhep_def_density_unit
Definition: Units.h:172
static const double meter
Definition: Units.h:33
static const double steradian
Definition: Units.h:163
static const double MHz
Definition: Units.h:112
static const double kilogram
Definition: Units.h:34
static const double kg_m3
Definition: Units.h:153
static const double fm
Definition: Units.h:83
static const double mrad
Definition: Units.h:166
static const double decimeter3
Definition: Units.h:57
static const double mg
Definition: Units.h:146
static const double kHz
Definition: Units.h:111
static const double mm
Definition: Units.h:73
static const double kilohertz
Definition: Units.h:106
static const double gram
Definition: Units.h:141
static const double picosecond
Definition: Units.h:97
static const double barn
Definition: Units.h:66
static const double millimeter2
Definition: Units.h:50
static const double ub
Definition: Units.h:88
static const double megahertz
Definition: Units.h:107
static const double A
Definition: Units.h:82
static const double us
Definition: Units.h:101
static const double PeV
Definition: Units.h:132
static const double petaelectronvolt
Definition: Units.h:126
static const double nanosecond
Definition: Units.h:96
static const double rad
Definition: Units.h:165
static const double cm3
Definition: Units.h:78
static const double ms
Definition: Units.h:100
static const double GHz
Definition: Units.h:113
static const double radian
Definition: Units.h:160
static const double m2
Definition: Units.h:80
static const double meter3
Definition: Units.h:59
static const double b
Definition: Units.h:86
static const double picobarn
Definition: Units.h:70
static const double millimeter
Definition: Units.h:49
static const double cm
Definition: Units.h:76
static const double centimeter
Definition: Units.h:52
static const double s
Definition: Units.h:99
static const double nb
Definition: Units.h:89
static const double m3
Definition: Units.h:81
static const double electronvolt
Definition: Units.h:122
static const double mb
Definition: Units.h:87
static const double GeV
Definition: Units.h:29
static const double millibarn
Definition: Units.h:67
static const double sr
Definition: Units.h:167
static const double gigaelectronvolt
Definition: Units.h:28
static const double microbarn
Definition: Units.h:68
static const double TeV
Definition: Units.h:131
static const double millimeter3
Definition: Units.h:51
static const double centimeter2
Definition: Units.h:53