CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CocoaUnitsTable.h
Go to the documentation of this file.
1 //
2 // This class is copied from G4UnitsTable
3 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
4 
5 #ifndef CocoaUnitsTable_HH
6 #define CocoaUnitsTable_HH
7 
9 #include <vector>
10 #include "CLHEP/Vector/ThreeVector.h"
11 
13 typedef std::vector<CocoaUnitsCategory*> CocoaUnitsTable;
14 
15 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
16 
18 public: // with description
20 
21 public: // without description
25 
26 private:
29 
30 public: // with description
31  const ALIstring& GetName() const { return Name; }
32  const ALIstring& GetSymbol() const { return SymbolName; }
33  ALIdouble GetValue() const { return Value; }
34 
35  void PrintDefinition();
36 
37  static void BuildUnitsTable();
38  static void PrintUnitsTable();
39 
41 
42  static ALIdouble GetValueOf(const ALIstring&);
43  static ALIstring GetCategory(const ALIstring&);
44 
45 private:
46  ALIstring Name; // SI name
47  ALIstring SymbolName; // SI symbol
48  ALIdouble Value; // value in the internal system of units
49 
50  static CocoaUnitsTable theUnitsTable; // table of Units
51 
52  size_t CategoryIndex; // category index of this unit
53 };
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
56 
57 typedef std::vector<CocoaUnitDefinition*> CocoaUnitsContainer;
58 
60 public: // without description
63  ALIint operator==(const CocoaUnitsCategory&) const;
64  ALIint operator!=(const CocoaUnitsCategory&) const;
65 
66 private:
69 
70 public: // without description
71  const ALIstring& GetName() const { return Name; }
73  ALIint GetNameMxLen() const { return NameMxLen; }
74  ALIint GetSymbMxLen() const { return SymbMxLen; }
75  void UpdateNameMxLen(ALIint len) {
76  if (NameMxLen < len)
77  NameMxLen = len;
78  }
79  void UpdateSymbMxLen(ALIint len) {
80  if (SymbMxLen < len)
81  SymbMxLen = len;
82  }
83  void PrintCategory();
84 
85 private:
86  ALIstring Name; // dimensional family: Length,Volume,Energy ...
87  CocoaUnitsContainer UnitsList; // List of units in this family
88  ALIint NameMxLen; // max length of the units name
89  ALIint SymbMxLen; // max length of the units symbol
90 };
91 
92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
93 
95 public: // with description
96  CocoaBestUnit(ALIdouble internalValue, const ALIstring& category);
97  CocoaBestUnit(const CLHEP::Hep3Vector& internalValue, const ALIstring& category);
98  // These constructors convert a physical quantity from its internalValue
99  // into the most appropriate unit of the same category.
100  // In practice it builds an object VU = (newValue, newUnit)
101 
102  ~CocoaBestUnit();
103 
104 public: // without description
105  ALIdouble* GetValue() { return Value; }
106  const ALIstring& GetCategory() const { return Category; }
107  size_t GetIndexOfCategory() const { return IndexOfCategory; }
108 
109 public: // with description
110  friend std::ostream& operator<<(std::ostream&, CocoaBestUnit VU);
111  // Default format to print the objet VU above.
112 
113 private:
114  ALIdouble Value[3]; // value in the internal system of units
115  ALIint nbOfVals; // ALIdouble=1; CLHEP::Hep3Vector=3
116  ALIstring Category; // dimensional family: Length,Volume,Energy ...
117  size_t IndexOfCategory; // position of Category in UnitsTable
118 };
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
121 
122 #endif
std::vector< CocoaUnitDefinition * > CocoaUnitsContainer
CocoaUnitsContainer UnitsList
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIstring GetCategory(const ALIstring &)
static void BuildUnitsTable()
const ALIstring & GetName() const
CocoaUnitsCategory(const ALIstring &name)
static CocoaUnitsTable & GetUnitsTable()
void UpdateNameMxLen(ALIint len)
ALIdouble Value[3]
size_t IndexOfCategory
int ALIint
Definition: CocoaGlobals.h:15
CocoaUnitsCategory & operator=(const CocoaUnitsCategory &)
const ALIstring & GetCategory() const
void UpdateSymbMxLen(ALIint len)
static void PrintUnitsTable()
CocoaUnitDefinition(const ALIstring &name, const ALIstring &symbol, const ALIstring &category, ALIdouble value)
ALIint GetSymbMxLen() const
CocoaUnitDefinition & operator=(const CocoaUnitDefinition &)
ALIint operator==(const CocoaUnitDefinition &) const
CocoaBestUnit(ALIdouble internalValue, const ALIstring &category)
std::vector< CocoaUnitsCategory * > CocoaUnitsTable
Definition: value.py:1
ALIint GetNameMxLen() const
const ALIstring & GetSymbol() const
const ALIstring & GetName() const
ALIint operator!=(const CocoaUnitsCategory &) const
static CocoaUnitsTable theUnitsTable
static ALIdouble GetValueOf(const ALIstring &)
size_t GetIndexOfCategory() const
std::string ALIstring
Definition: CocoaGlobals.h:9
ALIdouble * GetValue()
friend std::ostream & operator<<(std::ostream &, CocoaBestUnit VU)
ALIstring Category
ALIint operator!=(const CocoaUnitDefinition &) const
ALIint operator==(const CocoaUnitsCategory &) const
ALIdouble GetValue() const
CocoaUnitsContainer & GetUnitsList()