CMS 3D CMS Logo

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 <memory>
45 #include <CLHEP/Vector/ThreeVector.h>
46 
48 typedef std::vector<ALIUnitsCategory*> ALIUnitsTable;
49 
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
52 
53 class ALIUnitDefinition : public std::enable_shared_from_this<ALIUnitDefinition>
54 {
55 public: // with description
56 
59 
60 public: // without description
61 
63  ALIint operator==(const ALIUnitDefinition&) const;
64  ALIint operator!=(const ALIUnitDefinition&) const;
65 
66 private:
67 
70 
71 public: // with description
72 
73  ALIstring GetName() const {return Name;}
74  ALIstring GetSymbol() const {return SymbolName;}
75  ALIdouble GetValue() const {return Value;}
76 
77  void PrintDefinition();
78 
79  static void BuildUnitsTable();
80  static void PrintUnitsTable();
81 
83 
86 
87 private:
88 
89  ALIstring Name; // SI name
90  ALIstring SymbolName; // SI symbol
91  ALIdouble Value; // value in the internal system of units
92 
93  static
94  ALIUnitsTable theUnitsTable; // table of Units
95 
96 
97  size_t CategoryIndex; // category index of this unit
98 };
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
101 
102 using ALIUnitsContainer = std::vector<std::shared_ptr<ALIUnitDefinition>>;
103 
105 {
106 public: // without description
107 
109  ~ALIUnitsCategory();
110  ALIint operator==(const ALIUnitsCategory&) const;
111  ALIint operator!=(const ALIUnitsCategory&) const;
112 
113 private:
114 
117 
118 public: // without description
119 
120  ALIstring GetName() const {return Name;}
121  ALIUnitsContainer& GetUnitsList() {return UnitsList;}
122  ALIint GetNameMxLen() const {return NameMxLen;}
123  ALIint GetSymbMxLen() const {return SymbMxLen;}
124  void UpdateNameMxLen(ALIint len) {if (NameMxLen<len) NameMxLen=len;}
125  void UpdateSymbMxLen(ALIint len) {if (SymbMxLen<len) SymbMxLen=len;}
126  void PrintCategory();
127 
128 private:
129 
130  ALIstring Name; // dimensional family: Length,Volume,Energy ...
131  ALIUnitsContainer UnitsList; // List of units in this family
132  ALIint NameMxLen; // max length of the units name
133  ALIint SymbMxLen; // max length of the units symbol
134 };
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
137 
139 {
140 public: // with description
141 
142  ALIBestUnit(ALIdouble internalValue, ALIstring category);
143  ALIBestUnit(const CLHEP::Hep3Vector& internalValue, ALIstring category);
144  // These constructors convert a physical quantity from its internalValue
145  // into the most appropriate unit of the same category.
146  // In practice it builds an object VU = (newValue, newUnit)
147 
148  ~ALIBestUnit();
149 
150 public: // without description
151 
152  ALIdouble* GetValue() {return Value;}
153  ALIstring GetCategory() const {return Category;}
154  size_t GetIndexOfCategory() const {return IndexOfCategory;}
155 
156 public: // with description
157 
158  friend
159  std::ostream& operator<<(std::ostream&,ALIBestUnit VU);
160  // Default format to print the objet VU above.
161 
162 private:
163 
164  ALIdouble Value[3]; // value in the internal system of units
165  ALIint nbOfVals; // ALIdouble=1; CLHEP::Hep3Vector=3
166  ALIstring Category; // dimensional family: Length,Volume,Energy ...
167  size_t IndexOfCategory; // position of Category in UnitsTable
168 };
169 
170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
171 
172 #endif
ALIstring GetName() const
Definition: ALIUnitsTable.h:73
long double ALIdouble
Definition: CocoaGlobals.h:11
ALIstring Category
ALIint operator==(const ALIUnitDefinition &) const
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:47
ALIUnitDefinition & operator=(const ALIUnitDefinition &)
ALIstring SymbolName
Definition: ALIUnitsTable.h:90
ALIint operator!=(const ALIUnitDefinition &) const
int ALIint
Definition: CocoaGlobals.h:15
ALIUnitDefinition(ALIstring name, ALIstring symbol, ALIstring category, ALIdouble value)
static ALIstring GetCategory(ALIstring)
ALIint nbOfVals
ALIUnitsContainer UnitsList
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
ALIdouble GetValue() const
Definition: ALIUnitsTable.h:75
void UpdateSymbMxLen(ALIint len)
static void PrintUnitsTable()
ALIdouble * GetValue()
size_t IndexOfCategory
size_t GetIndexOfCategory() const
static void BuildUnitsTable()
Definition: value.py:1
void UpdateNameMxLen(ALIint len)
ALIint GetSymbMxLen() const
ALIint GetNameMxLen() const
std::vector< std::shared_ptr< ALIUnitDefinition >> ALIUnitsContainer
ALIstring GetName() const
static ALIdouble GetValueOf(ALIstring)
ALIstring GetCategory() const
std::string ALIstring
Definition: CocoaGlobals.h:9
static ALIUnitsTable theUnitsTable
Definition: ALIUnitsTable.h:94
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:82
ALIUnitsContainer & GetUnitsList()
ALIstring GetSymbol() const
Definition: ALIUnitsTable.h:74