CMS 3D CMS Logo

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 
16 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
17 
19 {
20 public: // with description
21 
22  CocoaUnitDefinition(const ALIstring& name, const ALIstring& symbol,
24 
25 public: // without description
26 
30 
31 private:
32 
35 
36 public: // with description
37 
38  const ALIstring& GetName() const {return Name;}
39  const ALIstring& GetSymbol() const {return SymbolName;}
40  ALIdouble GetValue() const {return Value;}
41 
42  void PrintDefinition();
43 
44  static void BuildUnitsTable();
45  static void PrintUnitsTable();
46 
48 
49  static ALIdouble GetValueOf (const ALIstring&);
50  static ALIstring GetCategory(const ALIstring&);
51 
52 private:
53 
54  ALIstring Name; // SI name
55  ALIstring SymbolName; // SI symbol
56  ALIdouble Value; // value in the internal system of units
57 
58  static
59  CocoaUnitsTable theUnitsTable; // table of Units
60 
61 
62  size_t CategoryIndex; // category index of this unit
63 };
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
66 
67 typedef std::vector<CocoaUnitDefinition*> CocoaUnitsContainer;
68 
70 {
71 public: // without description
72 
75  ALIint operator==(const CocoaUnitsCategory&) const;
76  ALIint operator!=(const CocoaUnitsCategory&) const;
77 
78 private:
79 
82 
83 public: // without description
84 
85  const ALIstring& GetName() const {return Name;}
86  CocoaUnitsContainer& GetUnitsList() {return UnitsList;}
87  ALIint GetNameMxLen() const {return NameMxLen;}
88  ALIint GetSymbMxLen() const {return SymbMxLen;}
89  void UpdateNameMxLen(ALIint len) {if (NameMxLen<len) NameMxLen=len;}
90  void UpdateSymbMxLen(ALIint len) {if (SymbMxLen<len) SymbMxLen=len;}
91  void PrintCategory();
92 
93 private:
94 
95  ALIstring Name; // dimensional family: Length,Volume,Energy ...
96  CocoaUnitsContainer UnitsList; // List of units in this family
97  ALIint NameMxLen; // max length of the units name
98  ALIint SymbMxLen; // max length of the units symbol
99 };
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
102 
104 {
105 public: // with description
106 
107  CocoaBestUnit(ALIdouble internalValue, const ALIstring& category);
108  CocoaBestUnit(const CLHEP::Hep3Vector& internalValue, const ALIstring& category);
109  // These constructors convert a physical quantity from its internalValue
110  // into the most appropriate unit of the same category.
111  // In practice it builds an object VU = (newValue, newUnit)
112 
113  ~CocoaBestUnit();
114 
115 public: // without description
116 
117  ALIdouble* GetValue() {return Value;}
118  const ALIstring& GetCategory() const {return Category;}
119  size_t GetIndexOfCategory() const {return IndexOfCategory;}
120 
121 public: // with description
122 
123  friend
124  std::ostream& operator<<(std::ostream&,CocoaBestUnit VU);
125  // Default format to print the objet VU above.
126 
127 private:
128 
129  ALIdouble Value[3]; // value in the internal system of units
130  ALIint nbOfVals; // ALIdouble=1; CLHEP::Hep3Vector=3
131  ALIstring Category; // dimensional family: Length,Volume,Energy ...
132  size_t IndexOfCategory; // position of Category in UnitsTable
133 };
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
136 
137 #endif
std::vector< CocoaUnitDefinition * > CocoaUnitsContainer
ALIint operator!=(const CocoaUnitDefinition &) const
CocoaUnitsContainer UnitsList
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIstring GetCategory(const ALIstring &)
static void BuildUnitsTable()
static CocoaUnitsTable & GetUnitsTable()
void UpdateNameMxLen(ALIint len)
const ALIstring & GetSymbol() const
size_t IndexOfCategory
const ALIstring & GetName() const
int ALIint
Definition: CocoaGlobals.h:15
ALIdouble GetValue() const
void UpdateSymbMxLen(ALIint len)
ALIint GetSymbMxLen() const
static void PrintUnitsTable()
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
CocoaUnitDefinition(const ALIstring &name, const ALIstring &symbol, const ALIstring &category, ALIdouble value)
const ALIstring & GetName() const
CocoaUnitDefinition & operator=(const CocoaUnitDefinition &)
std::vector< CocoaUnitsCategory * > CocoaUnitsTable
Definition: value.py:1
ALIint GetNameMxLen() const
const ALIstring & GetCategory() const
static CocoaUnitsTable theUnitsTable
static ALIdouble GetValueOf(const ALIstring &)
ALIint operator==(const CocoaUnitDefinition &) const
std::string ALIstring
Definition: CocoaGlobals.h:9
ALIdouble * GetValue()
size_t GetIndexOfCategory() const
ALIstring Category
CocoaUnitsContainer & GetUnitsList()