ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4UnitsTable.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4UnitsTable.hh
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
//
28
//
29
// -----------------------------------------------------------------
30
//
31
// ------------------- class G4UnitsTable -----------------
32
//
33
// 17-05-98: first version, M.Maire
34
// 13-10-98: Units and symbols printed in fixed length, M.Maire
35
// 18-01-00: BestUnit for three vector, M.Maire
36
// 06-03-01: Migrated to STL vectors, G.Cosmo
37
//
38
// Class description:
39
//
40
// This class maintains a table of Units.
41
// A Unit has a name, a symbol, a value and belong to a category (i.e. its
42
// dimensional definition): Length, Time, Energy, etc...
43
// The Units are grouped by category. The TableOfUnits is a list of categories.
44
// The class G4BestUnit allows to convert automaticaly a physical quantity
45
// from its internal value into the most appropriate Unit of the same category.
46
//
47
48
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
49
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50
51
#ifndef G4UnitsTable_HH
52
#define G4UnitsTable_HH
53
54
#include "
globals.hh
"
55
#include <vector>
56
#include "
G4ThreeVector.hh
"
57
58
class
G4UnitsCategory
;
59
class
G4UnitDefinition
;
60
61
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62
#ifdef G4MULTITHREADED
63
class
G4UnitsTable
:
public
std::vector<G4UnitsCategory*>
64
{
65
public
:
66
using
std::vector<G4UnitsCategory*>::vector;
67
G4UnitsTable
();
68
~
G4UnitsTable
();
69
70
public
:
71
void
Synchronize();
72
G4bool
Contains(
const
G4UnitDefinition
*,
const
G4String
&);
73
};
74
#else
75
typedef
std::vector<G4UnitsCategory*>
G4UnitsTable
;
76
#endif
77
78
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
79
80
class
G4UnitDefinition
81
{
82
public
:
// with description
83
84
G4UnitDefinition
(
const
G4String
&
name
,
const
G4String
& symbol,
85
const
G4String
& category,
G4double
value
);
86
87
public
:
// without description
88
89
~G4UnitDefinition
();
90
G4bool
operator==
(
const
G4UnitDefinition
&)
const
;
91
G4bool
operator!=
(
const
G4UnitDefinition
&)
const
;
92
93
public
:
// with description
94
95
inline
const
G4String
&
GetName
()
const
;
96
inline
const
G4String
&
GetSymbol
()
const
;
97
inline
G4double
GetValue
()
const
;
98
99
void
PrintDefinition
();
100
101
static
void
BuildUnitsTable
();
102
static
void
PrintUnitsTable
();
103
static
void
ClearUnitsTable
();
104
105
static
G4UnitsTable
&
GetUnitsTable
();
106
107
static
G4bool
IsUnitDefined
(
const
G4String
&);
108
static
G4double
GetValueOf
(
const
G4String
&);
109
static
G4String
GetCategory
(
const
G4String
&);
110
111
private
:
112
113
G4UnitDefinition
(
const
G4UnitDefinition
&);
114
G4UnitDefinition
&
operator=
(
const
G4UnitDefinition
&);
115
116
private
:
117
118
G4String
Name
;
// SI name
119
G4String
SymbolName
;
// SI symbol
120
G4double
Value
;
// value in the internal system of units
121
122
static
G4ThreadLocal
G4UnitsTable
*
pUnitsTable
;
// table of Units
123
static
G4ThreadLocal
G4bool
unitsTableDestroyed
;
124
125
size_t
CategoryIndex
;
// category index of this unit
126
127
#ifdef G4MULTITHREADED
128
static
G4UnitsTable
*pUnitsTableShadow;
// shadow of table of Units
129
public
:
130
inline
static
G4UnitsTable
& GetUnitsTableShadow()
131
{
return
*pUnitsTableShadow;}
132
#endif
133
};
134
135
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
136
137
typedef
std::vector<G4UnitDefinition*>
G4UnitsContainer
;
138
139
class
G4UnitsCategory
140
{
141
public
:
// without description
142
143
explicit
G4UnitsCategory
(
const
G4String
&
name
);
144
~G4UnitsCategory
();
145
G4bool
operator==
(
const
G4UnitsCategory
&)
const
;
146
G4bool
operator!=
(
const
G4UnitsCategory
&)
const
;
147
148
public
:
// without description
149
150
inline
const
G4String
&
GetName
()
const
;
151
inline
G4UnitsContainer
&
GetUnitsList
();
152
inline
G4int
GetNameMxLen
()
const
;
153
inline
G4int
GetSymbMxLen
()
const
;
154
inline
void
UpdateNameMxLen
(
G4int
len
);
155
inline
void
UpdateSymbMxLen
(
G4int
len);
156
void
PrintCategory
();
157
158
private
:
159
160
G4UnitsCategory
(
const
G4UnitsCategory
&);
161
G4UnitsCategory
&
operator=
(
const
G4UnitsCategory
&);
162
163
private
:
164
165
G4String
Name
;
// dimensional family: Length,Volume,Energy
166
G4UnitsContainer
UnitsList
;
// List of units in this family
167
G4int
NameMxLen
;
// max length of the units name
168
G4int
SymbMxLen
;
// max length of the units symbol
169
};
170
171
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
172
173
class
G4BestUnit
174
{
175
public
:
// with description
176
177
G4BestUnit
(
G4double
internalValue,
const
G4String
& category);
178
G4BestUnit
(
const
G4ThreeVector
& internalValue,
const
G4String
& category);
179
// These constructors convert a physical quantity from its internalValue
180
// into the most appropriate unit of the same category.
181
// In practice it builds an object VU = (newValue, newUnit)
182
183
~G4BestUnit
();
184
185
public
:
// without description
186
187
inline
G4double
*
GetValue
();
188
inline
const
G4String
&
GetCategory
()
const
;
189
inline
size_t
GetIndexOfCategory
()
const
;
190
operator
G4String
()
const
;
// Conversion to best string.
191
192
public
:
// with description
193
194
friend
std::ostream&
operator<<
(std::ostream&,
G4BestUnit
VU);
195
// Default format to print the objet VU above.
196
197
private
:
198
199
G4double
Value
[3];
// value in the internal system of units
200
G4int
nbOfVals
;
// G4double=1; G4ThreeVector=3
201
G4String
Category
;
// dimensional family: Length,Volume,Energy ...
202
size_t
IndexOfCategory
;
// position of Category in UnitsTable
203
};
204
205
#include "G4UnitsTable.icc"
206
207
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
208
209
#endif
geant4
tree
geant4-10.6-release
source
global
management
include
G4UnitsTable.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:21
using
1.8.2 with
ECCE GitHub integration