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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51 
52 class ALIUnitDefinition : public std::enable_shared_from_this<ALIUnitDefinition> {
53 public: // with description
55 
56 public: // without description
58  ALIint operator==(const ALIUnitDefinition&) const;
59  ALIint operator!=(const ALIUnitDefinition&) const;
60 
61 private:
64 
65 public: // with description
66  ALIstring GetName() const { return Name; }
67  ALIstring GetSymbol() const { return SymbolName; }
68  ALIdouble GetValue() const { return Value; }
69 
70  void PrintDefinition();
71 
72  static void BuildUnitsTable();
73  static void PrintUnitsTable();
74 
76 
79 
80 private:
81  ALIstring Name; // SI name
82  ALIstring SymbolName; // SI symbol
83  ALIdouble Value; // value in the internal system of units
84 
85  static ALIUnitsTable theUnitsTable; // table of Units
86 
87  size_t CategoryIndex; // category index of this unit
88 };
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
91 
92 using ALIUnitsContainer = std::vector<std::shared_ptr<ALIUnitDefinition>>;
93 
95 public: // without description
98  ALIint operator==(const ALIUnitsCategory&) const;
99  ALIint operator!=(const ALIUnitsCategory&) const;
100 
101 private:
104 
105 public: // without description
106  ALIstring GetName() const { return Name; }
108  ALIint GetNameMxLen() const { return NameMxLen; }
109  ALIint GetSymbMxLen() const { return SymbMxLen; }
111  if (NameMxLen < len)
112  NameMxLen = len;
113  }
115  if (SymbMxLen < len)
116  SymbMxLen = len;
117  }
118  void PrintCategory();
119 
120 private:
121  ALIstring Name; // dimensional family: Length,Volume,Energy ...
122  ALIUnitsContainer UnitsList; // List of units in this family
123  ALIint NameMxLen; // max length of the units name
124  ALIint SymbMxLen; // max length of the units symbol
125 };
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
128 
129 class ALIBestUnit {
130 public: // with description
131  ALIBestUnit(ALIdouble internalValue, ALIstring category);
132  ALIBestUnit(const CLHEP::Hep3Vector& internalValue, ALIstring category);
133  // These constructors convert a physical quantity from its internalValue
134  // into the most appropriate unit of the same category.
135  // In practice it builds an object VU = (newValue, newUnit)
136 
137  ~ALIBestUnit();
138 
139 public: // without description
140  ALIdouble* GetValue() { return Value; }
141  ALIstring GetCategory() const { return Category; }
142  size_t GetIndexOfCategory() const { return IndexOfCategory; }
143 
144 public: // with description
145  friend std::ostream& operator<<(std::ostream&, ALIBestUnit VU);
146  // Default format to print the objet VU above.
147 
148 private:
149  ALIdouble Value[3]; // value in the internal system of units
150  ALIint nbOfVals; // ALIdouble=1; CLHEP::Hep3Vector=3
151  ALIstring Category; // dimensional family: Length,Volume,Energy ...
152  size_t IndexOfCategory; // position of Category in UnitsTable
153 };
154 
155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
156 
157 #endif
ALIBestUnit::operator<<
friend std::ostream & operator<<(std::ostream &, ALIBestUnit VU)
Definition: ALIUnitsTable.cc:329
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:30
ALIUnitsCategory::Name
ALIstring Name
Definition: ALIUnitsTable.h:121
ALIUnitsTable
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:47
ALIUnitDefinition::operator=
ALIUnitDefinition & operator=(const ALIUnitDefinition &)
Definition: ALIUnitsTable.cc:46
ALIUnitsCategory::PrintCategory
void PrintCategory()
Definition: ALIUnitsTable.cc:274
ALIUnitDefinition::SymbolName
ALIstring SymbolName
Definition: ALIUnitsTable.h:82
ALIUnitsCategory::operator==
ALIint operator==(const ALIUnitsCategory &) const
Definition: ALIUnitsTable.cc:266
ALIBestUnit::Category
ALIstring Category
Definition: ALIUnitsTable.h:151
ALIUnitDefinition::operator!=
ALIint operator!=(const ALIUnitDefinition &) const
Definition: ALIUnitsTable.cc:62
ALIUnitDefinition::CategoryIndex
size_t CategoryIndex
Definition: ALIUnitsTable.h:87
ALIUnitDefinition::GetValue
ALIdouble GetValue() const
Definition: ALIUnitsTable.h:68
ALIstring
std::string ALIstring
Definition: CocoaGlobals.h:9
ALIUnitDefinition::ALIUnitDefinition
ALIUnitDefinition(ALIstring name, ALIstring symbol, ALIstring category, ALIdouble value)
Definition: ALIUnitsTable.cc:13
ALIUnitsCategory::UpdateSymbMxLen
void UpdateSymbMxLen(ALIint len)
Definition: ALIUnitsTable.h:114
ALIUnitsCategory::~ALIUnitsCategory
~ALIUnitsCategory()
Definition: ALIUnitsTable.cc:246
ALIUnitDefinition::GetCategory
static ALIstring GetCategory(ALIstring)
Definition: ALIUnitsTable.cc:86
ALIUnitsCategory
Definition: ALIUnitsTable.h:94
ALIBestUnit::GetValue
ALIdouble * GetValue()
Definition: ALIUnitsTable.h:140
ALIUnitDefinition::PrintDefinition
void PrintDefinition()
Definition: ALIUnitsTable.cc:108
ALIUnitDefinition
Definition: ALIUnitsTable.h:52
ALIBestUnit::ALIBestUnit
ALIBestUnit(ALIdouble internalValue, ALIstring category)
Definition: ALIUnitsTable.cc:282
ALIBestUnit::Value
ALIdouble Value[3]
Definition: ALIUnitsTable.h:149
ALIUnitsCategory::GetUnitsList
ALIUnitsContainer & GetUnitsList()
Definition: ALIUnitsTable.h:107
ALIBestUnit::nbOfVals
ALIint nbOfVals
Definition: ALIUnitsTable.h:150
ALIUnitDefinition::operator==
ALIint operator==(const ALIUnitDefinition &) const
Definition: ALIUnitsTable.cc:58
ALIUnitDefinition::GetName
ALIstring GetName() const
Definition: ALIUnitsTable.h:66
ALIBestUnit::IndexOfCategory
size_t IndexOfCategory
Definition: ALIUnitsTable.h:152
ALIUnitDefinition::GetSymbol
ALIstring GetSymbol() const
Definition: ALIUnitsTable.h:67
ALIUnitsCategory::UpdateNameMxLen
void UpdateNameMxLen(ALIint len)
Definition: ALIUnitsTable.h:110
ALIUnitDefinition::PrintUnitsTable
static void PrintUnitsTable()
Definition: ALIUnitsTable.cc:232
ALIUnitsCategory::UnitsList
ALIUnitsContainer UnitsList
Definition: ALIUnitsTable.h:122
ALIUnitsCategory::operator!=
ALIint operator!=(const ALIUnitsCategory &) const
Definition: ALIUnitsTable.cc:270
ALIBestUnit
Definition: ALIUnitsTable.h:129
ALIUnitDefinition::BuildUnitsTable
static void BuildUnitsTable()
Definition: ALIUnitsTable.cc:116
ALIUnitsContainer
std::vector< std::shared_ptr< ALIUnitDefinition > > ALIUnitsContainer
Definition: ALIUnitsTable.h:92
ALIdouble
long double ALIdouble
Definition: CocoaGlobals.h:11
value
Definition: value.py:1
ALIUnitDefinition::Value
ALIdouble Value
Definition: ALIUnitsTable.h:83
ALIBestUnit::GetIndexOfCategory
size_t GetIndexOfCategory() const
Definition: ALIUnitsTable.h:142
ALIUnitDefinition::GetValueOf
static ALIdouble GetValueOf(ALIstring)
Definition: ALIUnitsTable.cc:65
ALIUnitsCategory::operator=
ALIUnitsCategory & operator=(const ALIUnitsCategory &)
Definition: ALIUnitsTable.cc:254
ALIUnitsCategory::SymbMxLen
ALIint SymbMxLen
Definition: ALIUnitsTable.h:124
ALIUnitDefinition::theUnitsTable
static ALIUnitsTable theUnitsTable
Definition: ALIUnitsTable.h:85
ALIUnitDefinition::GetUnitsTable
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:75
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
ALIint
int ALIint
Definition: CocoaGlobals.h:15
ALIUnitsCategory::GetNameMxLen
ALIint GetNameMxLen() const
Definition: ALIUnitsTable.h:108
CocoaGlobals.h
ALIUnitDefinition::~ALIUnitDefinition
~ALIUnitDefinition()
Definition: ALIUnitsTable.cc:35
ALIUnitsCategory::GetSymbMxLen
ALIint GetSymbMxLen() const
Definition: ALIUnitsTable.h:109
ALIBestUnit::GetCategory
ALIstring GetCategory() const
Definition: ALIUnitsTable.h:141
ALIUnitsCategory::ALIUnitsCategory
ALIUnitsCategory(ALIstring name)
Definition: ALIUnitsTable.cc:240
ALIUnitsCategory::NameMxLen
ALIint NameMxLen
Definition: ALIUnitsTable.h:123
ALIUnitDefinition::Name
ALIstring Name
Definition: ALIUnitsTable.h:81
ALIBestUnit::~ALIBestUnit
~ALIBestUnit()
Definition: ALIUnitsTable.cc:325
ALIUnitsCategory::GetName
ALIstring GetName() const
Definition: ALIUnitsTable.h:106