CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
CocoaUnitDefinition Class Reference

#include <CocoaUnitsTable.h>

Public Member Functions

 CocoaUnitDefinition (const ALIstring &name, const ALIstring &symbol, const ALIstring &category, ALIdouble value)
 
const ALIstringGetName () const
 
const ALIstringGetSymbol () const
 
ALIdouble GetValue () const
 
ALIint operator!= (const CocoaUnitDefinition &) const
 
ALIint operator== (const CocoaUnitDefinition &) const
 
void PrintDefinition ()
 
 ~CocoaUnitDefinition ()
 

Static Public Member Functions

static void BuildUnitsTable ()
 
static ALIstring GetCategory (const ALIstring &)
 
static CocoaUnitsTableGetUnitsTable ()
 
static ALIdouble GetValueOf (const ALIstring &)
 
static void PrintUnitsTable ()
 

Private Member Functions

 CocoaUnitDefinition (const CocoaUnitDefinition &)
 
CocoaUnitDefinitionoperator= (const CocoaUnitDefinition &)
 

Private Attributes

size_t CategoryIndex
 
ALIstring Name
 
ALIstring SymbolName
 
ALIdouble Value
 

Static Private Attributes

static CocoaUnitsTable theUnitsTable
 

Detailed Description

Definition at line 17 of file CocoaUnitsTable.h.

Constructor & Destructor Documentation

CocoaUnitDefinition::CocoaUnitDefinition ( const ALIstring name,
const ALIstring symbol,
const ALIstring category,
ALIdouble  value 
)

Definition at line 12 of file CocoaUnitsTable.cc.

References CategoryIndex, GetName(), mps_fire::i, push_back(), and theUnitsTable.

Referenced by BuildUnitsTable().

16  : Name(name), SymbolName(symbol), Value(value) {
17  //
18  //does the Category objet already exist ?
19  size_t nbCat = theUnitsTable.size();
20  size_t i = 0;
21  while ((i < nbCat) && (theUnitsTable[i]->GetName() != category))
22  i++;
23  if (i == nbCat)
25  CategoryIndex = i;
26  //
27  //insert this Unit in the Unitstable
28  (theUnitsTable[CategoryIndex]->GetUnitsList()).push_back(this);
29 
30  //update string max length for name and symbol
31  theUnitsTable[i]->UpdateNameMxLen((ALIint)name.length());
32  theUnitsTable[i]->UpdateSymbMxLen((ALIint)symbol.length());
33 }
static const char category[]
int ALIint
Definition: CocoaGlobals.h:15
const ALIstring & GetName() const
static CocoaUnitsTable theUnitsTable
deadvectors[0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
CocoaUnitDefinition::~CocoaUnitDefinition ( )

Definition at line 37 of file CocoaUnitsTable.cc.

References mps_fire::i, and theUnitsTable.

37  {
38  for (size_t i = 0; i < theUnitsTable.size(); i++) {
39  delete theUnitsTable[i];
40  }
41 }
static CocoaUnitsTable theUnitsTable
CocoaUnitDefinition::CocoaUnitDefinition ( const CocoaUnitDefinition right)
private

Definition at line 45 of file CocoaUnitsTable.cc.

45 { *this = right; }

Member Function Documentation

void CocoaUnitDefinition::BuildUnitsTable ( )
static

Definition at line 124 of file CocoaUnitsTable.cc.

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

Referenced by CocoaBestUnit::CocoaBestUnit(), GetCategory(), and GetValueOf().

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

Definition at line 94 of file CocoaUnitsTable.cc.

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

94  {
95  if (theUnitsTable.empty())
97  ALIstring name, symbol;
98  for (size_t i = 0; i < theUnitsTable.size(); i++) {
99  CocoaUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
100  for (size_t j = 0; j < units.size(); j++) {
101  name = units[j]->GetName();
102  symbol = units[j]->GetSymbol();
103  if (str == name || str == symbol)
104  return theUnitsTable[i]->GetName();
105  }
106  }
107  std::cout << "Warning from CocoaUnitDefinition::GetCategory(" << str << ")."
108  << " The unit " << str << " does not exist in UnitsTable."
109  << " Return category = None" << std::endl;
110  name = "None";
111  return name;
112 }
std::vector< CocoaUnitDefinition * > CocoaUnitsContainer
static void BuildUnitsTable()
static CocoaUnitsTable theUnitsTable
TString units(TString variable, Char_t axis)
std::string ALIstring
Definition: CocoaGlobals.h:9
tuple cout
Definition: gather_cfg.py:144
#define str(s)
const ALIstring& CocoaUnitDefinition::GetName ( ) const
inline

Definition at line 31 of file CocoaUnitsTable.h.

References Name.

Referenced by CocoaUnitDefinition().

31 { return Name; }
const ALIstring& CocoaUnitDefinition::GetSymbol ( ) const
inline

Definition at line 32 of file CocoaUnitsTable.h.

References SymbolName.

32 { return SymbolName; }
CocoaUnitsTable & CocoaUnitDefinition::GetUnitsTable ( )
static

Definition at line 69 of file CocoaUnitsTable.cc.

References theUnitsTable.

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

69 { return theUnitsTable; }
static CocoaUnitsTable theUnitsTable
ALIdouble CocoaUnitDefinition::GetValue ( ) const
inline

Definition at line 33 of file CocoaUnitsTable.h.

References Value.

33 { return Value; }
ALIdouble CocoaUnitDefinition::GetValueOf ( const ALIstring str)
static

Definition at line 73 of file CocoaUnitsTable.cc.

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

73  {
74  if (theUnitsTable.empty())
76  ALIstring name, symbol;
77  for (size_t i = 0; i < theUnitsTable.size(); i++) {
78  CocoaUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
79  for (size_t j = 0; j < units.size(); j++) {
80  name = units[j]->GetName();
81  symbol = units[j]->GetSymbol();
82  if (str == name || str == symbol)
83  return units[j]->GetValue();
84  }
85  }
86  std::cout << "Warning from CocoaUnitDefinition::GetValueOf(" << str << ")."
87  << " The unit " << str << " does not exist in UnitsTable."
88  << " Return Value = 0." << std::endl;
89  return 0.;
90 }
std::vector< CocoaUnitDefinition * > CocoaUnitsContainer
static void BuildUnitsTable()
static CocoaUnitsTable theUnitsTable
TString units(TString variable, Char_t axis)
std::string ALIstring
Definition: CocoaGlobals.h:9
tuple cout
Definition: gather_cfg.py:144
#define str(s)
ALIint CocoaUnitDefinition::operator!= ( const CocoaUnitDefinition right) const

Definition at line 65 of file CocoaUnitsTable.cc.

65 { return (this != &right); }
CocoaUnitDefinition & CocoaUnitDefinition::operator= ( const CocoaUnitDefinition right)
private

Definition at line 49 of file CocoaUnitsTable.cc.

References CategoryIndex, Name, SymbolName, and Value.

49  {
50  if (this != &right) {
51  Name = right.Name;
52  SymbolName = right.SymbolName;
53  Value = right.Value;
55  }
56  return *this;
57 }
ALIint CocoaUnitDefinition::operator== ( const CocoaUnitDefinition right) const

Definition at line 61 of file CocoaUnitsTable.cc.

61 { return (this == &right); }
void CocoaUnitDefinition::PrintDefinition ( )

Definition at line 116 of file CocoaUnitsTable.cc.

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

116  {
117  ALIint nameL = theUnitsTable[CategoryIndex]->GetNameMxLen();
118  ALIint symbL = theUnitsTable[CategoryIndex]->GetSymbMxLen();
119  std::cout << std::setw(nameL) << Name << " (" << std::setw(symbL) << SymbolName << ") = " << Value << std::endl;
120 }
int ALIint
Definition: CocoaGlobals.h:15
static CocoaUnitsTable theUnitsTable
tuple cout
Definition: gather_cfg.py:144
void CocoaUnitDefinition::PrintUnitsTable ( )
static

Definition at line 239 of file CocoaUnitsTable.cc.

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

239  {
240  std::cout << "\n ----- The Table of Units ----- \n";
241  for (size_t i = 0; i < theUnitsTable.size(); i++) {
242  theUnitsTable[i]->PrintCategory();
243  }
244 }
static CocoaUnitsTable theUnitsTable
tuple cout
Definition: gather_cfg.py:144

Member Data Documentation

size_t CocoaUnitDefinition::CategoryIndex
private

Definition at line 52 of file CocoaUnitsTable.h.

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

ALIstring CocoaUnitDefinition::Name
private

Definition at line 46 of file CocoaUnitsTable.h.

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

ALIstring CocoaUnitDefinition::SymbolName
private

Definition at line 47 of file CocoaUnitsTable.h.

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

CocoaUnitsTable CocoaUnitDefinition::theUnitsTable
staticprivate
ALIdouble CocoaUnitDefinition::Value
private

Definition at line 48 of file CocoaUnitsTable.h.

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