GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
genie::utils::units Namespace Reference

Simple unit system utilities. More...

Functions

double UnitFromString (string u)
 

Detailed Description

Simple unit system utilities.

Author
Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool
Created:
May 06, 2004
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Function Documentation

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

Definition at line 18 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, 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, genie::units::ub, and genie::units::us.

Referenced by genie::hnl::VertexGenerator::EnforceUnits(), GetCommandLineArgs(), genie::flux::GNuMIFlux::Initialize(), genie::flux::GNuMIFlux::LengthUnits(), genie::hnl::VertexGenerator::MakeSDV(), genie::flux::GNuMIFluxXMLHelper::ParseParamSet(), genie::flux::GNuMIFlux::SetFluxWindow(), genie::flux::GNuMIFlux::SetLengthUnits(), genie::flux::GNuMIFlux::UseFluxAtFarDetCenter(), and genie::flux::GNuMIFlux::UseFluxAtNearDetCenter().

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