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 18 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(), i, and theUnitsTable.

Referenced by BuildUnitsTable().

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

Definition at line 34 of file CocoaUnitsTable.cc.

References i, and theUnitsTable.

35 {
36  for (size_t i=0;i<theUnitsTable.size();i++)
37  {
38  delete theUnitsTable[i];
39  }
40 }
int i
Definition: DBlmapReader.cc:9
static CocoaUnitsTable theUnitsTable
CocoaUnitDefinition::CocoaUnitDefinition ( const CocoaUnitDefinition right)
private

Definition at line 44 of file CocoaUnitsTable.cc.

45 {
46  *this = right;
47 }

Member Function Documentation

void CocoaUnitDefinition::BuildUnitsTable ( )
static

Definition at line 137 of file CocoaUnitsTable.cc.

References CocoaUnitDefinition(), fermi, g, and edm::second().

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

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

References BuildUnitsTable(), gather_cfg::cout, i, j, dataset::name, theUnitsTable, and units().

Referenced by GetValue().

107 {
108  if(theUnitsTable.size()==0) BuildUnitsTable();
109  ALIstring name,symbol;
110  for (size_t i=0;i<theUnitsTable.size();i++)
111  { CocoaUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
112  for (size_t j=0;j<units.size();j++)
113  { name=units[j]->GetName(); symbol=units[j]->GetSymbol();
114  if(str==name||str==symbol)
115  return theUnitsTable[i]->GetName();
116  }
117  }
118  std::cout << "Warning from CocoaUnitDefinition::GetCategory(" << str << ")."
119  << " The unit " << str << " does not exist in UnitsTable."
120  << " Return category = None" << std::endl;
121  name = "None";
122  return name;
123 }
std::vector< CocoaUnitDefinition * > CocoaUnitsContainer
int i
Definition: DBlmapReader.cc:9
static void BuildUnitsTable()
int j
Definition: DBlmapReader.cc:9
static CocoaUnitsTable theUnitsTable
TString units(TString variable, Char_t axis)
std::string ALIstring
Definition: CocoaGlobals.h:9
const ALIstring& CocoaUnitDefinition::GetName ( ) const
inline

Definition at line 38 of file CocoaUnitsTable.h.

References Name.

Referenced by CocoaUnitDefinition().

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

Definition at line 39 of file CocoaUnitsTable.h.

References SymbolName.

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

Definition at line 79 of file CocoaUnitsTable.cc.

References theUnitsTable.

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

80 {
81  return theUnitsTable;
82 }
static CocoaUnitsTable theUnitsTable
ALIdouble CocoaUnitDefinition::GetValue ( ) const
inline
ALIdouble CocoaUnitDefinition::GetValueOf ( const ALIstring str)
static

Definition at line 86 of file CocoaUnitsTable.cc.

References BuildUnitsTable(), gather_cfg::cout, i, j, dataset::name, theUnitsTable, and units().

Referenced by GetValue().

87 {
88  if(theUnitsTable.size()==0) BuildUnitsTable();
89  ALIstring name,symbol;
90  for (size_t i=0;i<theUnitsTable.size();i++)
91  { CocoaUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
92  for (size_t j=0;j<units.size();j++)
93  { name=units[j]->GetName(); symbol=units[j]->GetSymbol();
94  if(str==name||str==symbol)
95  return units[j]->GetValue();
96  }
97  }
98  std::cout << "Warning from CocoaUnitDefinition::GetValueOf(" << str << ")."
99  << " The unit " << str << " does not exist in UnitsTable."
100  << " Return Value = 0." << std::endl;
101  return 0.;
102 }
std::vector< CocoaUnitDefinition * > CocoaUnitsContainer
int i
Definition: DBlmapReader.cc:9
static void BuildUnitsTable()
int j
Definition: DBlmapReader.cc:9
static CocoaUnitsTable theUnitsTable
TString units(TString variable, Char_t axis)
std::string ALIstring
Definition: CocoaGlobals.h:9
ALIint CocoaUnitDefinition::operator!= ( const CocoaUnitDefinition right) const

Definition at line 72 of file CocoaUnitsTable.cc.

73 {
74  return (this != (CocoaUnitDefinition *) &right);
75 }
CocoaUnitDefinition & CocoaUnitDefinition::operator= ( const CocoaUnitDefinition right)
private

Definition at line 51 of file CocoaUnitsTable.cc.

References CategoryIndex, Name, SymbolName, and Value.

52 {
53  if (this != &right)
54  {
55  Name = right.Name;
56  SymbolName = right.SymbolName;
57  Value = right.Value;
59  }
60  return *this;
61 }
ALIint CocoaUnitDefinition::operator== ( const CocoaUnitDefinition right) const

Definition at line 65 of file CocoaUnitsTable.cc.

66 {
67  return (this == (CocoaUnitDefinition *) &right);
68 }
void CocoaUnitDefinition::PrintDefinition ( )

Definition at line 127 of file CocoaUnitsTable.cc.

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

Referenced by GetValue().

128 {
129  ALIint nameL = theUnitsTable[CategoryIndex]->GetNameMxLen();
130  ALIint symbL = theUnitsTable[CategoryIndex]->GetSymbMxLen();
131  std::cout << std::setw(nameL) << Name << " ("
132  << std::setw(symbL) << SymbolName << ") = " << Value << std::endl;
133 }
int ALIint
Definition: CocoaGlobals.h:15
static CocoaUnitsTable theUnitsTable
void CocoaUnitDefinition::PrintUnitsTable ( )
static

Definition at line 253 of file CocoaUnitsTable.cc.

References gather_cfg::cout, i, and theUnitsTable.

Referenced by GetValue().

254 {
255  std::cout << "\n ----- The Table of Units ----- \n";
256  for(size_t i=0;i<theUnitsTable.size();i++)
257  {
258  theUnitsTable[i]->PrintCategory();
259  }
260 }
int i
Definition: DBlmapReader.cc:9
static CocoaUnitsTable theUnitsTable

Member Data Documentation

size_t CocoaUnitDefinition::CategoryIndex
private

Definition at line 62 of file CocoaUnitsTable.h.

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

ALIstring CocoaUnitDefinition::Name
private

Definition at line 54 of file CocoaUnitsTable.h.

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

ALIstring CocoaUnitDefinition::SymbolName
private

Definition at line 55 of file CocoaUnitsTable.h.

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

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

Definition at line 56 of file CocoaUnitsTable.h.

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