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 53 of file ALIUnitsTable.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file ALIUnitsTable.cc.

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

15  : Name(name),SymbolName(symbol),Value(value)
16 {
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)) i++;
22  if (i == nbCat) 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 
32 }
ALIstring GetName() const
Definition: ALIUnitsTable.h:73
ALIstring SymbolName
Definition: ALIUnitsTable.h:90
int ALIint
Definition: CocoaGlobals.h:15
Definition: value.py:1
static ALIUnitsTable theUnitsTable
Definition: ALIUnitsTable.h:94
ALIUnitDefinition::~ALIUnitDefinition ( )

Definition at line 36 of file ALIUnitsTable.cc.

37 {}
ALIUnitDefinition::ALIUnitDefinition ( ALIUnitDefinition right)
private

Definition at line 41 of file ALIUnitsTable.cc.

42 {
43  *this = right;
44 }

Member Function Documentation

void ALIUnitDefinition::BuildUnitsTable ( )
static

Definition at line 126 of file ALIUnitsTable.cc.

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

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

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

Definition at line 95 of file ALIUnitsTable.cc.

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

Referenced by GetUnitsTable().

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

Definition at line 73 of file ALIUnitsTable.h.

References Name.

Referenced by ALIUnitDefinition().

73 {return Name;}
ALIstring ALIUnitDefinition::GetSymbol ( ) const
inline

Definition at line 74 of file ALIUnitsTable.h.

References SymbolName.

74 {return SymbolName;}
ALIstring SymbolName
Definition: ALIUnitsTable.h:90
static ALIUnitsTable& ALIUnitDefinition::GetUnitsTable ( )
inlinestatic

Definition at line 82 of file ALIUnitsTable.h.

References GetCategory(), GetValueOf(), and theUnitsTable.

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

82 {return theUnitsTable;}
static ALIUnitsTable theUnitsTable
Definition: ALIUnitsTable.h:94
ALIdouble ALIUnitDefinition::GetValue ( ) const
inline

Definition at line 75 of file ALIUnitsTable.h.

References BuildUnitsTable(), PrintDefinition(), PrintUnitsTable(), and Value.

75 {return Value;}
ALIdouble ALIUnitDefinition::GetValueOf ( ALIstring  stri)
static

Definition at line 75 of file ALIUnitsTable.cc.

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

Referenced by GetUnitsTable(), and ParameterMgr::getVal().

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

Definition at line 69 of file ALIUnitsTable.cc.

70 {
71  return (this != &right);
72 }
ALIUnitDefinition & ALIUnitDefinition::operator= ( const ALIUnitDefinition right)
private

Definition at line 48 of file ALIUnitsTable.cc.

References CategoryIndex, Name, SymbolName, and Value.

49 {
50  if (this != &right)
51  {
52  Name = right.Name;
53  SymbolName = right.SymbolName;
54  Value = right.Value;
56  }
57  return *this;
58 }
ALIstring SymbolName
Definition: ALIUnitsTable.h:90
ALIint ALIUnitDefinition::operator== ( const ALIUnitDefinition right) const

Definition at line 62 of file ALIUnitsTable.cc.

63 {
64  return (this == &right);
65 }
void ALIUnitDefinition::PrintDefinition ( )

Definition at line 116 of file ALIUnitsTable.cc.

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

Referenced by GetValue().

117 {
118  ALIint nameL = theUnitsTable[CategoryIndex]->GetNameMxLen();
119  ALIint symbL = theUnitsTable[CategoryIndex]->GetSymbMxLen();
120  std::cout << std::setw(nameL) << Name << " ("
121  << std::setw(symbL) << SymbolName << ") = " << Value << std::endl;
122 }
ALIstring SymbolName
Definition: ALIUnitsTable.h:90
int ALIint
Definition: CocoaGlobals.h:15
static ALIUnitsTable theUnitsTable
Definition: ALIUnitsTable.h:94
void ALIUnitDefinition::PrintUnitsTable ( )
static

Definition at line 243 of file ALIUnitsTable.cc.

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

Referenced by GetValue().

244 {
245  std::cout << "\n ----- The Table of Units ----- \n";
246  for(size_t i=0;i<theUnitsTable.size();i++)
247  theUnitsTable[i]->PrintCategory();
248 }
static ALIUnitsTable theUnitsTable
Definition: ALIUnitsTable.h:94

Member Data Documentation

size_t ALIUnitDefinition::CategoryIndex
private

Definition at line 97 of file ALIUnitsTable.h.

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

ALIstring ALIUnitDefinition::Name
private

Definition at line 89 of file ALIUnitsTable.h.

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

ALIstring ALIUnitDefinition::SymbolName
private

Definition at line 90 of file ALIUnitsTable.h.

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

ALIUnitsTable ALIUnitDefinition::theUnitsTable
staticprivate
ALIdouble ALIUnitDefinition::Value
private

Definition at line 91 of file ALIUnitsTable.h.

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