Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UnitDefinition Class Reference

#include <G4UnitsTable.hh>

Public Member Functions

 G4UnitDefinition (const G4String &name, const G4String &symbol, const G4String &category, G4double value)
 
 ~G4UnitDefinition ()
 
G4int operator== (const G4UnitDefinition &) const
 
G4int operator!= (const G4UnitDefinition &) const
 
const G4StringGetName () const
 
const G4StringGetSymbol () const
 
G4double GetValue () const
 
void PrintDefinition ()
 

Static Public Member Functions

static void BuildUnitsTable ()
 
static void PrintUnitsTable ()
 
static void ClearUnitsTable ()
 
static G4UnitsTableGetUnitsTable ()
 
static G4double GetValueOf (const G4String &)
 
static G4String GetCategory (const G4String &)
 

Detailed Description

Definition at line 64 of file G4UnitsTable.hh.

Constructor & Destructor Documentation

◆ G4UnitDefinition()

G4UnitDefinition::G4UnitDefinition ( const G4String name,
const G4String symbol,
const G4String category,
G4double  value 
)

Definition at line 59 of file G4UnitsTable.cc.

62 : Name(name),SymbolName(symbol),Value(value)
63{
64 // Does the Category objet already exist ?
65 //
66 size_t nbCat = theUnitsTable.size();
67 size_t i = 0;
68 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
69 if (i == nbCat)
70 { theUnitsTable.push_back( new G4UnitsCategory(category)); }
71 CategoryIndex = i;
72
73 // Insert this Unit in the Units table
74 //
75 (theUnitsTable[CategoryIndex]->GetUnitsList()).push_back(this);
76
77 // Update string max length for name and symbol
78 //
79 theUnitsTable[i]->UpdateNameMxLen((G4int)name.length());
80 theUnitsTable[i]->UpdateSymbMxLen((G4int)symbol.length());
81}
int G4int
Definition: G4Types.hh:66
const G4String & GetName() const

◆ ~G4UnitDefinition()

G4UnitDefinition::~G4UnitDefinition ( )

Definition at line 85 of file G4UnitsTable.cc.

86{
87}

Member Function Documentation

◆ BuildUnitsTable()

void G4UnitDefinition::BuildUnitsTable ( )
static

Definition at line 189 of file G4UnitsTable.cc.

190{
191 //Length
192 new G4UnitDefinition( "parsec","pc" ,"Length",parsec);
193 new G4UnitDefinition( "kilometer","km" ,"Length",kilometer);
194 new G4UnitDefinition( "meter","m" ,"Length",meter);
195 new G4UnitDefinition("centimeter","cm" ,"Length",centimeter);
196 new G4UnitDefinition("millimeter","mm" ,"Length",millimeter);
197 new G4UnitDefinition("micrometer","um" ,"Length",micrometer);
198 new G4UnitDefinition( "nanometer","nm" ,"Length",nanometer);
199 new G4UnitDefinition( "angstrom","Ang" ,"Length",angstrom);
200 new G4UnitDefinition( "fermi","fm" ,"Length",fermi);
201
202 //Surface
203 new G4UnitDefinition( "kilometer2","km2" ,"Surface",kilometer2);
204 new G4UnitDefinition( "meter2","m2" ,"Surface",meter2);
205 new G4UnitDefinition("centimeter2","cm2" ,"Surface",centimeter2);
206 new G4UnitDefinition("millimeter2","mm2" ,"Surface",millimeter2);
207 new G4UnitDefinition( "barn","barn" ,"Surface",barn);
208 new G4UnitDefinition( "millibarn","mbarn" ,"Surface",millibarn);
209 new G4UnitDefinition( "microbarn","mubarn" ,"Surface",microbarn);
210 new G4UnitDefinition( "nanobarn","nbarn" ,"Surface",nanobarn);
211 new G4UnitDefinition( "picobarn","pbarn" ,"Surface",picobarn);
212
213 //Volume
214 new G4UnitDefinition( "kilometer3","km3" ,"Volume",kilometer3);
215 new G4UnitDefinition( "meter3","m3" ,"Volume",meter3);
216 new G4UnitDefinition("centimeter3","cm3" ,"Volume",centimeter3);
217 new G4UnitDefinition("millimeter3","mm3" ,"Volume",millimeter3);
218
219 //Angle
220 new G4UnitDefinition( "radian","rad" ,"Angle",radian);
221 new G4UnitDefinition("milliradian","mrad" ,"Angle",milliradian);
222 new G4UnitDefinition( "degree","deg" ,"Angle",degree);
223
224 //Solid angle
225 new G4UnitDefinition( "steradian","sr" ,"Solid angle",steradian);
226 new G4UnitDefinition("millisteradian","msr" ,"Solid angle",steradian*0.001);
227
228 //Time
229 new G4UnitDefinition( "second","s" ,"Time",second);
230 new G4UnitDefinition("millisecond","ms" ,"Time",millisecond);
231 new G4UnitDefinition("microsecond","mus" ,"Time",microsecond);
232 new G4UnitDefinition( "nanosecond","ns" ,"Time",nanosecond);
233 new G4UnitDefinition( "picosecond","ps" ,"Time",picosecond);
234
235 //Frequency
236 new G4UnitDefinition( "hertz","Hz" ,"Frequency",hertz);
237 new G4UnitDefinition("kilohertz","kHz" ,"Frequency",kilohertz);
238 new G4UnitDefinition("megahertz","MHz" ,"Frequency",megahertz);
239
240 //Electric charge
241 new G4UnitDefinition( "eplus","e+" ,"Electric charge",eplus);
242 new G4UnitDefinition("coulomb","C" ,"Electric charge",coulomb);
243
244 //Energy
245 new G4UnitDefinition( "electronvolt","eV" ,"Energy",electronvolt);
246 new G4UnitDefinition("kiloelectronvolt","keV","Energy",kiloelectronvolt);
247 new G4UnitDefinition("megaelectronvolt","MeV","Energy",megaelectronvolt);
248 new G4UnitDefinition("gigaelectronvolt","GeV","Energy",gigaelectronvolt);
249 new G4UnitDefinition("teraelectronvolt","TeV","Energy",teraelectronvolt);
250 new G4UnitDefinition("petaelectronvolt","PeV","Energy",petaelectronvolt);
251 new G4UnitDefinition( "joule","J" ,"Energy",joule);
252
253 // Energy/Length
254 new G4UnitDefinition( "GeV/cm", "GeV/cm","Energy/Length", GeV/cm);
255 new G4UnitDefinition( "MeV/cm", "MeV/cm","Energy/Length", MeV/cm);
256 new G4UnitDefinition( "keV/cm", "keV/cm","Energy/Length", keV/cm);
257 new G4UnitDefinition( "eV/cm", "eV/cm","Energy/Length", eV/cm);
258
259 //Mass
260 new G4UnitDefinition("milligram","mg","Mass",milligram);
261 new G4UnitDefinition( "gram","g" ,"Mass",gram);
262 new G4UnitDefinition( "kilogram","kg","Mass",kilogram);
263
264 //Volumic Mass
265 new G4UnitDefinition( "g/cm3", "g/cm3","Volumic Mass", g/cm3);
266 new G4UnitDefinition("mg/cm3","mg/cm3","Volumic Mass",mg/cm3);
267 new G4UnitDefinition("kg/m3", "kg/m3", "Volumic Mass",kg/m3);
268
269 // Mass/Surface
270 new G4UnitDefinition( "g/cm2", "g/cm2","Mass/Surface", g/cm2);
271 new G4UnitDefinition( "mg/cm2", "mg/cm2","Mass/Surface", mg/cm2);
272 new G4UnitDefinition( "kg/cm2", "kg/cm2","Mass/Surface", kg/cm2);
273
274 // Surface/Mass
275 new G4UnitDefinition( "cm2/g", "cm2/g","Surface/Mass", cm2/g);
276
277 // Energy.Surface/Mass
278 new G4UnitDefinition( "eV*cm2/g", " eV*cm2/g","Energy*Surface/Mass", eV*cm2/g);
279 new G4UnitDefinition("keV*cm2/g", "keV*cm2/g","Energy*Surface/Mass",keV*cm2/g);
280 new G4UnitDefinition("MeV*cm2/g", "MeV*cm2/g","Energy*Surface/Mass",MeV*cm2/g);
281 new G4UnitDefinition("GeV*cm2/g", "GeV*cm2/g","Energy*Surface/Mass",GeV*cm2/g);
282
283 //Power
284 new G4UnitDefinition("watt","W","Power",watt);
285
286 //Force
287 new G4UnitDefinition("newton","N","Force",newton);
288
289 //Pressure
290 new G4UnitDefinition( "pascal","Pa" ,"Pressure",pascal);
291 new G4UnitDefinition( "bar","bar","Pressure",bar);
292 new G4UnitDefinition("atmosphere","atm","Pressure",atmosphere);
293
294 //Electric current
295 new G4UnitDefinition( "ampere","A" ,"Electric current",ampere);
296 new G4UnitDefinition("milliampere","mA" ,"Electric current",milliampere);
297 new G4UnitDefinition("microampere","muA","Electric current",microampere);
298 new G4UnitDefinition( "nanoampere","nA" ,"Electric current",nanoampere);
299
300 //Electric potential
301 new G4UnitDefinition( "volt","V" ,"Electric potential",volt);
302 new G4UnitDefinition("kilovolt","kV","Electric potential",kilovolt);
303 new G4UnitDefinition("megavolt","MV","Electric potential",megavolt);
304
305 //Electric field
306 new G4UnitDefinition( "volt/m","V/m","Electric field",volt/m);
307
308 //Magnetic flux
309 new G4UnitDefinition("weber","Wb","Magnetic flux",weber);
310
311 //Magnetic flux density
312 new G4UnitDefinition( "tesla","T" ,"Magnetic flux density",tesla);
313 new G4UnitDefinition("kilogauss","kG","Magnetic flux density",kilogauss);
314 new G4UnitDefinition( "gauss","G" ,"Magnetic flux density",gauss);
315
316 //Temperature
317 new G4UnitDefinition("kelvin","K","Temperature",kelvin);
318
319 //Amount of substance
320 new G4UnitDefinition("mole","mol","Amount of substance",mole);
321
322 //Activity
323 new G4UnitDefinition("becquerel","Bq","Activity",becquerel);
324 new G4UnitDefinition( "curie","Ci","Activity",curie);
325
326 //Dose
327 new G4UnitDefinition("gray","Gy","Dose",gray);
328}
#define pascal

Referenced by G4GDMLRead::G4GDMLRead(), GetUnitsTable(), and G4DimensionedTypeUtils::GetUnitValue().

◆ ClearUnitsTable()

void G4UnitDefinition::ClearUnitsTable ( )
static

Definition at line 343 of file G4UnitsTable.cc.

344{
345 for (size_t i=0;i<theUnitsTable.size();i++)
346 {
347 delete theUnitsTable[i];
348 }
349 theUnitsTable.clear();
350}

Referenced by G4RunManagerKernel::~G4RunManagerKernel().

◆ GetCategory()

G4String G4UnitDefinition::GetCategory ( const G4String str)
static

Definition at line 156 of file G4UnitsTable.cc.

157{
158 G4String name,symbol;
159 for (size_t i=0;i<(GetUnitsTable()).size();i++)
160 {
161 G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
162 for (size_t j=0;j<units.size();j++)
163 {
164 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
165 if(str==name||str==symbol)
166 { return theUnitsTable[i]->GetName(); }
167 }
168 }
169 std::ostringstream message;
170 message << "The unit '" << str << "' does not exist in the Units Table.";
171 G4Exception("G4UnitDefinition::GetCategory()", "InvalidUnit",
172 JustWarning, message, "Returning Value = 0.");
173 name = "None";
174 return name;
175}
@ JustWarning
std::vector< G4UnitDefinition * > G4UnitsContainer
static G4UnitsTable & GetUnitsTable()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G4UIcommand::CategoryOf(), G4VPrimitiveScorer::CheckAndSetUnit(), and G4AttCheck::Standard().

◆ GetName()

const G4String & G4UnitDefinition::GetName ( ) const
inline

◆ GetSymbol()

const G4String & G4UnitDefinition::GetSymbol ( ) const
inline

◆ GetUnitsTable()

G4UnitsTable & G4UnitDefinition::GetUnitsTable ( )
static

Definition at line 126 of file G4UnitsTable.cc.

127{
128 if(theUnitsTable.size()==0) { BuildUnitsTable(); }
129 return theUnitsTable;
130}
static void BuildUnitsTable()

Referenced by G4AttCheck::G4AttCheck(), G4BestUnit::G4BestUnit(), GetCategory(), G4DimensionedTypeUtils::GetUnitValue(), GetValueOf(), and G4UIcommand::UnitsList().

◆ GetValue()

G4double G4UnitDefinition::GetValue ( ) const
inline

◆ GetValueOf()

G4double G4UnitDefinition::GetValueOf ( const G4String str)
static

Definition at line 134 of file G4UnitsTable.cc.

135{
136 G4String name,symbol;
137 for (size_t i=0;i<(GetUnitsTable()).size();i++)
138 {
139 G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
140 for (size_t j=0;j<units.size();j++)
141 {
142 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
143 if(str==name||str==symbol)
144 { return units[j]->GetValue(); }
145 }
146 }
147 std::ostringstream message;
148 message << "The unit '" << str << "' does not exist in the Units Table.";
149 G4Exception("G4UnitDefinition::GetValueOf()", "InvalidUnit",
150 JustWarning, message, "Returning Value = 0.");
151 return 0.;
152}

Referenced by G4VPrimitiveScorer::CheckAndSetUnit(), G4ScoreQuantityMessenger::FParticleWithEnergyCommand(), G4tgrUtils::GetDouble(), G4VAnalysisManager::GetUnitValue(), G4AdjointSimMessenger::SetNewValue(), G4VisCommandsViewerSet::SetNewValue(), G4AttCheck::Standard(), and G4UIcommand::ValueOf().

◆ operator!=()

G4int G4UnitDefinition::operator!= ( const G4UnitDefinition right) const

Definition at line 119 of file G4UnitsTable.cc.

120{
121 return (this != (G4UnitDefinition *) &right);
122}

◆ operator==()

G4int G4UnitDefinition::operator== ( const G4UnitDefinition right) const

Definition at line 112 of file G4UnitsTable.cc.

113{
114 return (this == (G4UnitDefinition *) &right);
115}

◆ PrintDefinition()

void G4UnitDefinition::PrintDefinition ( )

Definition at line 179 of file G4UnitsTable.cc.

180{
181 G4int nameL = theUnitsTable[CategoryIndex]->GetNameMxLen();
182 G4int symbL = theUnitsTable[CategoryIndex]->GetSymbMxLen();
183 G4cout << std::setw(nameL) << Name << " ("
184 << std::setw(symbL) << SymbolName << ") = " << Value << G4endl;
185}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout

◆ PrintUnitsTable()

void G4UnitDefinition::PrintUnitsTable ( )
static

Definition at line 332 of file G4UnitsTable.cc.

333{
334 G4cout << "\n ----- The Table of Units ----- \n";
335 for(size_t i=0;i<theUnitsTable.size();i++)
336 {
337 theUnitsTable[i]->PrintCategory();
338 }
339}

Referenced by G4UnitsMessenger::SetNewValue().


The documentation for this class was generated from the following files: