CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ALIUnitsTable.h
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * DISCLAIMER *
4 // * *
5 // * The following disclaimer summarizes all the specific disclaimers *
6 // * of contributors to this software. The specific disclaimers,which *
7 // * govern, are listed with their locations in: *
8 // * http://cern.ch/geant4/license *
9 // * *
10 // * Neither the authors of this software system, nor their employing *
11 // * institutes,nor the agencies providing financial support for this *
12 // * work make any representation or warranty, express or implied, *
13 // * regarding this software system or assume any liability for its *
14 // * use. *
15 // * *
16 // * This code implementation is the intellectual property of the *
17 // * GEANT4 collaboration. *
18 // * By copying, distributing or modifying the Program (or any work *
19 // * based on the Program) you indicate your acceptance of this *
20 // * statement, and all its terms. *
21 // ********************************************************************
22 //
23 // -----------------------------------------------------------------
24 //
25 // ------------------- class ALIUnitsTable -----------------
26 //
27 // Class description:
28 //
29 // This class maintains a table of Units.
30 // A Unit has a name, a symbol, a value and belong to a category (i.e. its
31 // dimensional definition): Length, Time, Energy, etc...
32 // The Units are grouped by category. The TableOfUnits is a list of categories.
33 // The class G4BestUnit allows to convert automaticaly a physical quantity
34 // from its internal value into the most appropriate Unit of the same category.
35 //
36 
37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
38 
39 #ifndef ALIUnitsTable_HH
40 #define ALIUnitsTable_HH
41 
43 #include <vector>
44 #include <CLHEP/Vector/ThreeVector.h>
45 
47 typedef std::vector<ALIUnitsCategory*> ALIUnitsTable;
48 
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51 
53 {
54 public: // with description
55 
58 
59 public: // without description
60 
62  ALIint operator==(const ALIUnitDefinition&) const;
63  ALIint operator!=(const ALIUnitDefinition&) const;
64 
65 private:
66 
69 
70 public: // with description
71 
72  ALIstring GetName() const {return Name;}
73  ALIstring GetSymbol() const {return SymbolName;}
74  ALIdouble GetValue() const {return Value;}
75 
76  void PrintDefinition();
77 
78  static void BuildUnitsTable();
79  static void PrintUnitsTable();
80 
82 
85 
86 private:
87 
88  ALIstring Name; // SI name
89  ALIstring SymbolName; // SI symbol
90  ALIdouble Value; // value in the internal system of units
91 
92  static
93  ALIUnitsTable theUnitsTable; // table of Units
94 
95 
96  size_t CategoryIndex; // category index of this unit
97 };
98 
99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
100 
101 typedef std::vector<ALIUnitDefinition*> ALIUnitsContainer;
102 
104 {
105 public: // without description
106 
109  ALIint operator==(const ALIUnitsCategory&) const;
110  ALIint operator!=(const ALIUnitsCategory&) const;
111 
112 private:
113 
116 
117 public: // without description
118 
119  ALIstring GetName() const {return Name;}
121  ALIint GetNameMxLen() const {return NameMxLen;}
122  ALIint GetSymbMxLen() const {return SymbMxLen;}
123  void UpdateNameMxLen(ALIint len) {if (NameMxLen<len) NameMxLen=len;}
124  void UpdateSymbMxLen(ALIint len) {if (SymbMxLen<len) SymbMxLen=len;}
125  void PrintCategory();
126 
127 private:
128 
129  ALIstring Name; // dimensional family: Length,Volume,Energy ...
130  ALIUnitsContainer UnitsList; // List of units in this family
131  ALIint NameMxLen; // max length of the units name
132  ALIint SymbMxLen; // max length of the units symbol
133 };
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
136 
138 {
139 public: // with description
140 
141  ALIBestUnit(ALIdouble internalValue, ALIstring category);
142  ALIBestUnit(const CLHEP::Hep3Vector& internalValue, ALIstring category);
143  // These constructors convert a physical quantity from its internalValue
144  // into the most appropriate unit of the same category.
145  // In practice it builds an object VU = (newValue, newUnit)
146 
147  ~ALIBestUnit();
148 
149 public: // without description
150 
151  ALIdouble* GetValue() {return Value;}
152  ALIstring GetCategory() const {return Category;}
153  size_t GetIndexOfCategory() const {return IndexOfCategory;}
154 
155 public: // with description
156 
157  friend
158  std::ostream& operator<<(std::ostream&,ALIBestUnit VU);
159  // Default format to print the objet VU above.
160 
161 private:
162 
163  ALIdouble Value[3]; // value in the internal system of units
164  ALIint nbOfVals; // ALIdouble=1; CLHEP::Hep3Vector=3
165  ALIstring Category; // dimensional family: Length,Volume,Energy ...
166  size_t IndexOfCategory; // position of Category in UnitsTable
167 };
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
170 
171 #endif
ALIstring GetName() const
Definition: ALIUnitsTable.h:72
long double ALIdouble
Definition: CocoaGlobals.h:11
ALIstring Category
ALIint operator==(const ALIUnitDefinition &) const
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:46
ALIUnitDefinition & operator=(const ALIUnitDefinition &)
ALIstring SymbolName
Definition: ALIUnitsTable.h:89
std::vector< ALIUnitDefinition * > ALIUnitsContainer
ALIint operator!=(const ALIUnitDefinition &) const
ALIBestUnit(ALIdouble internalValue, ALIstring category)
int ALIint
Definition: CocoaGlobals.h:15
ALIUnitDefinition(ALIstring name, ALIstring symbol, ALIstring category, ALIdouble value)
static ALIstring GetCategory(ALIstring)
ALIint nbOfVals
ALIUnitsContainer UnitsList
ALIdouble GetValue() const
Definition: ALIUnitsTable.h:74
void UpdateSymbMxLen(ALIint len)
ALIint operator==(const ALIUnitsCategory &) const
ALIUnitsCategory & operator=(const ALIUnitsCategory &)
static void PrintUnitsTable()
ALIdouble * GetValue()
size_t IndexOfCategory
ALIUnitsCategory(ALIstring name)
size_t GetIndexOfCategory() const
static void BuildUnitsTable()
ALIdouble Value[3]
ALIint operator!=(const ALIUnitsCategory &) const
void UpdateNameMxLen(ALIint len)
ALIint GetSymbMxLen() const
ALIint GetNameMxLen() const
ALIstring GetName() const
static ALIdouble GetValueOf(ALIstring)
ALIstring GetCategory() const
std::string ALIstring
Definition: CocoaGlobals.h:9
friend std::ostream & operator<<(std::ostream &, ALIBestUnit VU)
static ALIUnitsTable theUnitsTable
Definition: ALIUnitsTable.h:93
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:81
ALIUnitsContainer & GetUnitsList()
ALIstring GetSymbol() const
Definition: ALIUnitsTable.h:73