Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UnitsTable.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id$
28//
29//
30// -----------------------------------------------------------------
31//
32// ------------------- class G4UnitsTable -----------------
33//
34// 17-05-98: first version, M.Maire
35// 13-10-98: Units and symbols printed in fixed length, M.Maire
36// 18-01-00: BestUnit for three vector, M.Maire
37// 06-03-01: Migrated to STL vectors, G.Cosmo
38//
39// Class description:
40//
41// This class maintains a table of Units.
42// A Unit has a name, a symbol, a value and belong to a category (i.e. its
43// dimensional definition): Length, Time, Energy, etc...
44// The Units are grouped by category. The TableOfUnits is a list of categories.
45// The class G4BestUnit allows to convert automaticaly a physical quantity
46// from its internal value into the most appropriate Unit of the same category.
47//
48
49//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51
52#ifndef G4UnitsTable_HH
53#define G4UnitsTable_HH
54
55#include "globals.hh"
56#include <vector>
57#include "G4ThreeVector.hh"
58
59class G4UnitsCategory;
60typedef std::vector<G4UnitsCategory*> G4UnitsTable;
61
62//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
63
65{
66public: // with description
67
68 G4UnitDefinition(const G4String& name, const G4String& symbol,
69 const G4String& category, G4double value);
70
71 public: // without description
72
74 G4int operator==(const G4UnitDefinition&) const;
75 G4int operator!=(const G4UnitDefinition&) const;
76
77 public: // with description
78
79 inline const G4String& GetName() const;
80 inline const G4String& GetSymbol() const;
81 inline G4double GetValue() const;
82
83 void PrintDefinition();
84
85 static void BuildUnitsTable();
86 static void PrintUnitsTable();
87 static void ClearUnitsTable();
88
90
91 static G4double GetValueOf (const G4String&);
92 static G4String GetCategory(const G4String&);
93
94 private:
95
97 G4UnitDefinition& operator=(const G4UnitDefinition&);
98
99 private:
100
101 G4String Name; // SI name
102 G4String SymbolName; // SI symbol
103 G4double Value; // value in the internal system of units
104
105 static G4UnitsTable theUnitsTable; // table of Units
106
107 size_t CategoryIndex; // category index of this unit
108};
109
110//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
111
112typedef std::vector<G4UnitDefinition*> G4UnitsContainer;
113
115{
116 public: // without description
117
118 explicit G4UnitsCategory(const G4String& name);
120 G4int operator==(const G4UnitsCategory&) const;
121 G4int operator!=(const G4UnitsCategory&) const;
122
123 public: // without description
124
125 inline const G4String& GetName() const;
127 inline G4int GetNameMxLen() const;
128 inline G4int GetSymbMxLen() const;
129 inline void UpdateNameMxLen(G4int len);
130 inline void UpdateSymbMxLen(G4int len);
131 void PrintCategory();
132
133 private:
134
136 G4UnitsCategory& operator=(const G4UnitsCategory&);
137
138 private:
139
140 G4String Name; // dimensional family: Length,Volume,Energy
141 G4UnitsContainer UnitsList; // List of units in this family
142 G4int NameMxLen; // max length of the units name
143 G4int SymbMxLen; // max length of the units symbol
144};
145
146//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
147
149{
150 public: // with description
151
152 G4BestUnit(G4double internalValue, const G4String& category);
153 G4BestUnit(const G4ThreeVector& internalValue, const G4String& category);
154 // These constructors convert a physical quantity from its internalValue
155 // into the most appropriate unit of the same category.
156 // In practice it builds an object VU = (newValue, newUnit)
157
158 ~G4BestUnit();
159
160 public: // without description
161
163 inline const G4String& GetCategory() const;
164 inline size_t GetIndexOfCategory() const;
165 operator G4String () const; // Conversion to best string.
166
167 public: // with description
168
169 friend std::ostream& operator<<(std::ostream&,G4BestUnit VU);
170 // Default format to print the objet VU above.
171
172 private:
173
174 G4double Value[3]; // value in the internal system of units
175 G4int nbOfVals; // G4double=1; G4ThreeVector=3
176 G4String Category; // dimensional family: Length,Volume,Energy ...
177 size_t IndexOfCategory; // position of Category in UnitsTable
178};
179
180#include "G4UnitsTable.icc"
181
182//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
183
184#endif
std::ostream & operator<<(std::ostream &out, const G4CellScoreComposer &ps)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:60
std::vector< G4UnitDefinition * > G4UnitsContainer
size_t GetIndexOfCategory() const
G4double * GetValue()
const G4String & GetCategory() const
G4int operator!=(const G4UnitDefinition &) const
static void ClearUnitsTable()
static void BuildUnitsTable()
G4double GetValue() const
static G4double GetValueOf(const G4String &)
G4int operator==(const G4UnitDefinition &) const
static G4String GetCategory(const G4String &)
static void PrintUnitsTable()
const G4String & GetName() const
static G4UnitsTable & GetUnitsTable()
const G4String & GetSymbol() const
const G4String & GetName() const
void UpdateSymbMxLen(G4int len)
G4UnitsContainer & GetUnitsList()
G4int operator==(const G4UnitsCategory &) const
void UpdateNameMxLen(G4int len)
G4int GetNameMxLen() const
G4int GetSymbMxLen() const
G4int operator!=(const G4UnitsCategory &) const