CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ALIUnitDefinition Class Reference

#include <ALIUnitsTable.h>

Inheritance diagram for ALIUnitDefinition:

Public Member Functions

 ALIUnitDefinition (ALIstring name, ALIstring symbol, ALIstring category, ALIdouble value)
 
ALIstring GetName () const
 
ALIstring GetSymbol () const
 
ALIdouble GetValue () const
 
ALIint operator!= (const ALIUnitDefinition &) const
 
ALIint operator== (const ALIUnitDefinition &) const
 
void PrintDefinition ()
 
 ~ALIUnitDefinition ()
 

Static Public Member Functions

static void BuildUnitsTable ()
 
static ALIstring GetCategory (ALIstring)
 
static ALIUnitsTableGetUnitsTable ()
 
static ALIdouble GetValueOf (ALIstring)
 
static void PrintUnitsTable ()
 

Private Member Functions

 ALIUnitDefinition (ALIUnitDefinition &)
 
ALIUnitDefinitionoperator= (const ALIUnitDefinition &)
 

Private Attributes

size_t CategoryIndex
 
ALIstring Name
 
ALIstring SymbolName
 
ALIdouble Value
 

Static Private Attributes

static ALIUnitsTable theUnitsTable
 

Detailed Description

Definition at line 52 of file ALIUnitsTable.h.

Constructor & Destructor Documentation

◆ ALIUnitDefinition() [1/2]

ALIUnitDefinition::ALIUnitDefinition ( ALIstring  name,
ALIstring  symbol,
ALIstring  category,
ALIdouble  value 
)

Definition at line 13 of file ALIUnitsTable.cc.

14  : Name(name), SymbolName(symbol), Value(value) {
15  //
16  //does the Category objet already exist ?
17  size_t nbCat = theUnitsTable.size();
18  size_t i = 0;
19  while ((i < nbCat) && (theUnitsTable[i]->GetName() != category))
20  i++;
21  if (i == nbCat)
22  theUnitsTable.push_back(new ALIUnitsCategory(category));
23  CategoryIndex = i;
24  //
25  //insert this Unit in the Unitstable
26  (theUnitsTable[CategoryIndex]->GetUnitsList()).emplace_back(shared_from_this());
27 
28  //update ALIstring max length for name and symbol
29  theUnitsTable[i]->UpdateNameMxLen((ALIint)name.length());
30  theUnitsTable[i]->UpdateSymbMxLen((ALIint)symbol.length());
31 }

References taus_updatedMVAIds_cff::category, CategoryIndex, GetName(), mps_fire::i, Skims_PA_cff::name, and theUnitsTable.

◆ ~ALIUnitDefinition()

ALIUnitDefinition::~ALIUnitDefinition ( )

Definition at line 35 of file ALIUnitsTable.cc.

35 {}

◆ ALIUnitDefinition() [2/2]

ALIUnitDefinition::ALIUnitDefinition ( ALIUnitDefinition right)
private

Definition at line 39 of file ALIUnitsTable.cc.

40  : std::enable_shared_from_this<ALIUnitDefinition>(right) {
41  *this = right;
42 }

Member Function Documentation

◆ BuildUnitsTable()

void ALIUnitDefinition::BuildUnitsTable ( )
static

Definition at line 116 of file ALIUnitsTable.cc.

116  {
117  //Length
118  std::make_shared<ALIUnitDefinition>("kilometer", "km", "Length", kilometer);
119  std::make_shared<ALIUnitDefinition>("meter", "m", "Length", meter);
120  std::make_shared<ALIUnitDefinition>("centimeter", "cm", "Length", centimeter);
121  std::make_shared<ALIUnitDefinition>("millimeter", "mm", "Length", millimeter);
122  std::make_shared<ALIUnitDefinition>("micrometer", "mum", "Length", micrometer);
123  std::make_shared<ALIUnitDefinition>("nanometer", "nm", "Length", nanometer);
124  std::make_shared<ALIUnitDefinition>("angstrom", "Ang", "Length", angstrom);
125  std::make_shared<ALIUnitDefinition>("fermi", "fm", "Length", fermi);
126 
127  //Surface
128  std::make_shared<ALIUnitDefinition>("kilometer2", "km2", "Surface", kilometer2);
129  std::make_shared<ALIUnitDefinition>("meter2", "m2", "Surface", meter2);
130  std::make_shared<ALIUnitDefinition>("centimeter2", "cm2", "Surface", centimeter2);
131  std::make_shared<ALIUnitDefinition>("millimeter2", "mm2", "Surface", millimeter2);
132  std::make_shared<ALIUnitDefinition>("barn", "barn", "Surface", barn);
133  std::make_shared<ALIUnitDefinition>("millibarn", "mbarn", "Surface", millibarn);
134  std::make_shared<ALIUnitDefinition>("microbarn", "mubarn", "Surface", microbarn);
135  std::make_shared<ALIUnitDefinition>("nanobarn", "nbarn", "Surface", nanobarn);
136  std::make_shared<ALIUnitDefinition>("picobarn", "pbarn", "Surface", picobarn);
137 
138  //Volume
139  std::make_shared<ALIUnitDefinition>("kilometer3", "km3", "Volume", kilometer3);
140  std::make_shared<ALIUnitDefinition>("meter3", "m3", "Volume", meter3);
141  std::make_shared<ALIUnitDefinition>("centimeter3", "cm3", "Volume", centimeter3);
142  std::make_shared<ALIUnitDefinition>("millimeter3", "mm3", "Volume", millimeter3);
143 
144  //Angle
145  std::make_shared<ALIUnitDefinition>("radian", "rad", "Angle", radian);
146  std::make_shared<ALIUnitDefinition>("milliradian", "mrad", "Angle", milliradian);
147  std::make_shared<ALIUnitDefinition>("milliradian", "murad", "Angle", 0.001 * milliradian);
148  std::make_shared<ALIUnitDefinition>("steradian", "sr", "Angle", steradian);
149  std::make_shared<ALIUnitDefinition>("degree", "deg", "Angle", degree);
150 
151  //Time
152  std::make_shared<ALIUnitDefinition>("second", "s", "Time", second);
153  std::make_shared<ALIUnitDefinition>("millisecond", "ms", "Time", millisecond);
154  std::make_shared<ALIUnitDefinition>("microsecond", "mus", "Time", microsecond);
155  std::make_shared<ALIUnitDefinition>("nanosecond", "ns", "Time", nanosecond);
156  std::make_shared<ALIUnitDefinition>("picosecond", "ps", "Time", picosecond);
157 
158  //Frequency
159  std::make_shared<ALIUnitDefinition>("hertz", "Hz", "Frequency", hertz);
160  std::make_shared<ALIUnitDefinition>("kilohertz", "kHz", "Frequency", kilohertz);
161  std::make_shared<ALIUnitDefinition>("megahertz", "MHz", "Frequency", megahertz);
162 
163  //Electric charge
164  std::make_shared<ALIUnitDefinition>("eplus", "e+", "Electric charge", eplus);
165  std::make_shared<ALIUnitDefinition>("coulomb", "C", "Electric charge", coulomb);
166 
167  //Energy
168  std::make_shared<ALIUnitDefinition>("electronvolt", "eV", "Energy", electronvolt);
169  std::make_shared<ALIUnitDefinition>("kiloelectronvolt", "keV", "Energy", kiloelectronvolt);
170  std::make_shared<ALIUnitDefinition>("megaelectronvolt", "MeV", "Energy", megaelectronvolt);
171  std::make_shared<ALIUnitDefinition>("gigaelectronvolt", "GeV", "Energy", gigaelectronvolt);
172  std::make_shared<ALIUnitDefinition>("teraelectronvolt", "TeV", "Energy", teraelectronvolt);
173  std::make_shared<ALIUnitDefinition>("petaelectronvolt", "PeV", "Energy", petaelectronvolt);
174  std::make_shared<ALIUnitDefinition>("joule", "J", "Energy", joule);
175 
176  //Mass
177  std::make_shared<ALIUnitDefinition>("milligram", "mg", "Mass", milligram);
178  std::make_shared<ALIUnitDefinition>("gram", "g", "Mass", gram);
179  std::make_shared<ALIUnitDefinition>("kilogram", "kg", "Mass", kilogram);
180 
181  //Volumic Mass
182  std::make_shared<ALIUnitDefinition>("g/cm3", "g/cm3", "Volumic Mass", g / cm3);
183  std::make_shared<ALIUnitDefinition>("mg/cm3", "mg/cm3", "Volumic Mass", mg / cm3);
184  std::make_shared<ALIUnitDefinition>("kg/m3", "kg/m3", "Volumic Mass", kg / m3);
185 
186  //Power
187  std::make_shared<ALIUnitDefinition>("watt", "W", "Power", watt);
188 
189  //Force
190  std::make_shared<ALIUnitDefinition>("newton", "N", "Force", newton);
191 
192  //Pressure
193  std::make_shared<ALIUnitDefinition>("pascal", "Pa", "Pressure", pascal);
194  std::make_shared<ALIUnitDefinition>("bar", "bar", "Pressure", bar);
195  std::make_shared<ALIUnitDefinition>("atmosphere", "atm", "Pressure", atmosphere);
196 
197  //Electric current
198  std::make_shared<ALIUnitDefinition>("ampere", "A", "Electric current", ampere);
199  std::make_shared<ALIUnitDefinition>("milliampere", "mA", "Electric current", milliampere);
200  std::make_shared<ALIUnitDefinition>("microampere", "muA", "Electric current", microampere);
201  std::make_shared<ALIUnitDefinition>("nanoampere", "nA", "Electric current", nanoampere);
202 
203  //Electric potential
204  std::make_shared<ALIUnitDefinition>("volt", "V", "Electric potential", volt);
205  std::make_shared<ALIUnitDefinition>("kilovolt", "kV", "Electric potential", kilovolt);
206  std::make_shared<ALIUnitDefinition>("megavolt", "MV", "Electric potential", megavolt);
207 
208  //Magnetic flux
209  std::make_shared<ALIUnitDefinition>("weber", "Wb", "Magnetic flux", weber);
210 
211  //Magnetic flux density
212  std::make_shared<ALIUnitDefinition>("tesla", "T", "Magnetic flux density", tesla);
213  std::make_shared<ALIUnitDefinition>("kilogauss", "kG", "Magnetic flux density", kilogauss);
214  std::make_shared<ALIUnitDefinition>("gauss", "G", "Magnetic flux density", gauss);
215 
216  //Temperature
217  std::make_shared<ALIUnitDefinition>("kelvin", "K", "Temperature", kelvin);
218 
219  //Amount of substance
220  std::make_shared<ALIUnitDefinition>("mole", "mol", "Amount of substance", mole);
221 
222  //Activity
223  std::make_shared<ALIUnitDefinition>("becquerel", "Bq", "Activity", becquerel);
224  std::make_shared<ALIUnitDefinition>("curie", "Ci", "Activity", curie);
225 
226  //Dose
227  std::make_shared<ALIUnitDefinition>("gray", "Gy", "Dose", gray);
228 }

References fermi, g, geant_units::joule(), and edm::second().

Referenced by GetCategory(), and GetValueOf().

◆ GetCategory()

ALIstring ALIUnitDefinition::GetCategory ( ALIstring  stri)
static

Definition at line 86 of file ALIUnitsTable.cc.

86  {
87  if (theUnitsTable.empty())
89  ALIstring name, symbol;
90  for (size_t i = 0; i < theUnitsTable.size(); i++) {
91  ALIUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
92  for (size_t j = 0; j < units.size(); j++) {
93  name = units[j]->GetName();
94  symbol = units[j]->GetSymbol();
95  if (stri == name || stri == symbol)
96  return theUnitsTable[i]->GetName();
97  }
98  }
99  std::cout << "Warning from ALIUnitDefinition::GetCategory(" << stri << ")."
100  << " The unit " << stri << " does not exist in UnitsTable."
101  << " Return category = None" << std::endl;
102  name = "None";
103  return name;
104 }

References BuildUnitsTable(), gather_cfg::cout, mps_fire::i, dqmiolumiharvest::j, Skims_PA_cff::name, theUnitsTable, and units().

◆ GetName()

ALIstring ALIUnitDefinition::GetName ( ) const
inline

Definition at line 66 of file ALIUnitsTable.h.

66 { return Name; }

References Name.

Referenced by ALIUnitDefinition().

◆ GetSymbol()

ALIstring ALIUnitDefinition::GetSymbol ( ) const
inline

Definition at line 67 of file ALIUnitsTable.h.

67 { return SymbolName; }

References SymbolName.

◆ GetUnitsTable()

static ALIUnitsTable& ALIUnitDefinition::GetUnitsTable ( )
inlinestatic

Definition at line 75 of file ALIUnitsTable.h.

75 { return theUnitsTable; }

References theUnitsTable.

Referenced by ALIBestUnit::ALIBestUnit(), and operator<<().

◆ GetValue()

ALIdouble ALIUnitDefinition::GetValue ( ) const
inline

Definition at line 68 of file ALIUnitsTable.h.

68 { return Value; }

References Value.

◆ GetValueOf()

ALIdouble ALIUnitDefinition::GetValueOf ( ALIstring  stri)
static

Definition at line 65 of file ALIUnitsTable.cc.

65  {
66  if (theUnitsTable.empty())
68  ALIstring name, symbol;
69  for (size_t i = 0; i < theUnitsTable.size(); i++) {
70  ALIUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
71  for (size_t j = 0; j < units.size(); j++) {
72  name = units[j]->GetName();
73  symbol = units[j]->GetSymbol();
74  if (stri == name || stri == symbol)
75  return units[j]->GetValue();
76  }
77  }
78  std::cout << "Warning from ALIUnitDefinition::GetValueOf(" << stri << ")."
79  << " The unit " << stri << " does not exist in UnitsTable."
80  << " Return Value = 0." << std::endl;
81  return 0.;
82 }

References BuildUnitsTable(), gather_cfg::cout, mps_fire::i, dqmiolumiharvest::j, Skims_PA_cff::name, theUnitsTable, and units().

Referenced by ParameterMgr::getVal().

◆ operator!=()

ALIint ALIUnitDefinition::operator!= ( const ALIUnitDefinition right) const

Definition at line 62 of file ALIUnitsTable.cc.

62 { return (this != &right); }

◆ operator=()

ALIUnitDefinition & ALIUnitDefinition::operator= ( const ALIUnitDefinition right)
private

Definition at line 46 of file ALIUnitsTable.cc.

46  {
47  if (this != &right) {
48  Name = right.Name;
49  SymbolName = right.SymbolName;
50  Value = right.Value;
52  }
53  return *this;
54 }

References CategoryIndex, Name, SymbolName, and Value.

◆ operator==()

ALIint ALIUnitDefinition::operator== ( const ALIUnitDefinition right) const

Definition at line 58 of file ALIUnitsTable.cc.

58 { return (this == &right); }

◆ PrintDefinition()

void ALIUnitDefinition::PrintDefinition ( )

Definition at line 108 of file ALIUnitsTable.cc.

108  {
109  ALIint nameL = theUnitsTable[CategoryIndex]->GetNameMxLen();
110  ALIint symbL = theUnitsTable[CategoryIndex]->GetSymbMxLen();
111  std::cout << std::setw(nameL) << Name << " (" << std::setw(symbL) << SymbolName << ") = " << Value << std::endl;
112 }

References CategoryIndex, gather_cfg::cout, Name, SymbolName, theUnitsTable, and Value.

◆ PrintUnitsTable()

void ALIUnitDefinition::PrintUnitsTable ( )
static

Definition at line 232 of file ALIUnitsTable.cc.

232  {
233  std::cout << "\n ----- The Table of Units ----- \n";
234  for (size_t i = 0; i < theUnitsTable.size(); i++)
235  theUnitsTable[i]->PrintCategory();
236 }

References gather_cfg::cout, mps_fire::i, and theUnitsTable.

Member Data Documentation

◆ CategoryIndex

size_t ALIUnitDefinition::CategoryIndex
private

Definition at line 87 of file ALIUnitsTable.h.

Referenced by ALIUnitDefinition(), operator=(), and PrintDefinition().

◆ Name

ALIstring ALIUnitDefinition::Name
private

Definition at line 81 of file ALIUnitsTable.h.

Referenced by GetName(), operator=(), and PrintDefinition().

◆ SymbolName

ALIstring ALIUnitDefinition::SymbolName
private

Definition at line 82 of file ALIUnitsTable.h.

Referenced by GetSymbol(), operator=(), and PrintDefinition().

◆ theUnitsTable

ALIUnitsTable ALIUnitDefinition::theUnitsTable
staticprivate

◆ Value

ALIdouble ALIUnitDefinition::Value
private

Definition at line 83 of file ALIUnitsTable.h.

Referenced by GetValue(), operator=(), and PrintDefinition().

taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
mps_fire.i
i
Definition: mps_fire.py:428
geant_units::joule
constexpr long double joule(6.24150e+12)
ALIUnitDefinition::SymbolName
ALIstring SymbolName
Definition: ALIUnitsTable.h:82
ALIUnitDefinition::CategoryIndex
size_t CategoryIndex
Definition: ALIUnitsTable.h:87
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ALIstring
std::string ALIstring
Definition: CocoaGlobals.h:9
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
fermi
const double fermi
Definition: MathUtil.h:17
units
TString units(TString variable, Char_t axis)
ALIUnitsCategory
Definition: ALIUnitsTable.h:94
ALIUnitDefinition::GetName
ALIstring GetName() const
Definition: ALIUnitsTable.h:66
ALIUnitDefinition::BuildUnitsTable
static void BuildUnitsTable()
Definition: ALIUnitsTable.cc:116
ALIUnitsContainer
std::vector< std::shared_ptr< ALIUnitDefinition > > ALIUnitsContainer
Definition: ALIUnitsTable.h:92
value
Definition: value.py:1
ALIUnitDefinition::Value
ALIdouble Value
Definition: ALIUnitsTable.h:83
ALIUnitDefinition::theUnitsTable
static ALIUnitsTable theUnitsTable
Definition: ALIUnitsTable.h:85
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
ALIint
int ALIint
Definition: CocoaGlobals.h:15
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
ALIUnitDefinition::Name
ALIstring Name
Definition: ALIUnitsTable.h:81