CMS 3D CMS Logo

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() [1/2]

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

Definition at line 12 of file CocoaUnitsTable.cc.

References validateAlignments::category, CategoryIndex, GetName(), mps_fire::i, Skims_PA_cff::name, 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 }
int ALIint
Definition: CocoaGlobals.h:15
Definition: value.py:1
const ALIstring & GetName() const
static CocoaUnitsTable theUnitsTable
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})

◆ ~CocoaUnitDefinition()

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() [2/2]

CocoaUnitDefinition::CocoaUnitDefinition ( const CocoaUnitDefinition right)
private

Definition at line 45 of file CocoaUnitsTable.cc.

45 { *this = right; }

Member Function Documentation

◆ BuildUnitsTable()

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

◆ GetCategory()

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, Skims_PA_cff::name, str, 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
#define str(s)

◆ GetName()

const ALIstring& CocoaUnitDefinition::GetName ( ) const
inline

Definition at line 31 of file CocoaUnitsTable.h.

References Name.

Referenced by CocoaUnitDefinition().

31 { return Name; }

◆ GetSymbol()

const ALIstring& CocoaUnitDefinition::GetSymbol ( ) const
inline

Definition at line 32 of file CocoaUnitsTable.h.

References SymbolName.

32 { return SymbolName; }

◆ GetUnitsTable()

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

◆ GetValue()

ALIdouble CocoaUnitDefinition::GetValue ( ) const
inline

Definition at line 33 of file CocoaUnitsTable.h.

References Value.

33 { return Value; }

◆ GetValueOf()

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, Skims_PA_cff::name, str, 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
#define str(s)

◆ operator!=()

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

Definition at line 65 of file CocoaUnitsTable.cc.

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

◆ operator=()

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 }

◆ operator==()

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

Definition at line 61 of file CocoaUnitsTable.cc.

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

◆ PrintDefinition()

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

◆ PrintUnitsTable()

void CocoaUnitDefinition::PrintUnitsTable ( )
static

Definition at line 240 of file CocoaUnitsTable.cc.

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

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

Member Data Documentation

◆ CategoryIndex

size_t CocoaUnitDefinition::CategoryIndex
private

Definition at line 52 of file CocoaUnitsTable.h.

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

◆ Name

ALIstring CocoaUnitDefinition::Name
private

Definition at line 46 of file CocoaUnitsTable.h.

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

◆ SymbolName

ALIstring CocoaUnitDefinition::SymbolName
private

Definition at line 47 of file CocoaUnitsTable.h.

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

◆ theUnitsTable

CocoaUnitsTable CocoaUnitDefinition::theUnitsTable
staticprivate

◆ Value

ALIdouble CocoaUnitDefinition::Value
private

Definition at line 48 of file CocoaUnitsTable.h.

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