Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions
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 ( const G4String name,
const G4String symbol,
const G4String category,
G4double  value 
)

Definition at line 59 of file G4UnitsTable.cc.

References GetName().

Referenced by BuildUnitsTable().

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

Definition at line 87 of file G4UnitsTable.cc.

88 {
89  if (!pUnitsTable) { delete pUnitsTable; pUnitsTable = 0; }
90 }

Member Function Documentation

void G4UnitDefinition::BuildUnitsTable ( )
static

Definition at line 193 of file G4UnitsTable.cc.

References python.hepunit::ampere, python.hepunit::angstrom, python.hepunit::atmosphere, python.hepunit::bar, python.hepunit::barn, python.hepunit::becquerel, python.hepunit::centimeter, python.hepunit::centimeter2, python.hepunit::centimeter3, python.hepunit::cm, python.hepunit::cm2, python.hepunit::cm3, python.hepunit::coulomb, python.hepunit::curie, python.hepunit::degree, python.hepunit::electronvolt, python.hepunit::eplus, python.hepunit::eV, python.hepunit::fermi, g(), G4UnitDefinition(), python.hepunit::gauss, python.hepunit::GeV, python.hepunit::gigaelectronvolt, python.hepunit::gram, python.hepunit::gray, python.hepunit::hertz, python.hepunit::joule, python.hepunit::kelvin, python.hepunit::keV, python.hepunit::kg, python.hepunit::kiloelectronvolt, python.hepunit::kilogauss, python.hepunit::kilogram, python.hepunit::kilohertz, python.hepunit::kilometer, python.hepunit::kilometer2, python.hepunit::kilometer3, python.hepunit::kilovolt, python.hepunit::m, python.hepunit::m3, python.hepunit::megaelectronvolt, python.hepunit::megahertz, python.hepunit::megavolt, python.hepunit::meter, python.hepunit::meter2, python.hepunit::meter3, python.hepunit::MeV, python.hepunit::mg, python.hepunit::microampere, python.hepunit::microbarn, python.hepunit::micrometer, python.hepunit::microsecond, python.hepunit::milliampere, python.hepunit::millibarn, python.hepunit::milligram, python.hepunit::millimeter, python.hepunit::millimeter2, python.hepunit::millimeter3, python.hepunit::milliradian, python.hepunit::millisecond, python.hepunit::mole, python.hepunit::nanoampere, python.hepunit::nanobarn, python.hepunit::nanometer, python.hepunit::nanosecond, python.hepunit::newton, python.hepunit::parsec, pascal, python.hepunit::petaelectronvolt, python.hepunit::picobarn, python.hepunit::picosecond, python.hepunit::radian, python.hepunit::second, python.hepunit::steradian, python.hepunit::teraelectronvolt, python.hepunit::tesla, python.hepunit::volt, python.hepunit::watt, and python.hepunit::weber.

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

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

Definition at line 348 of file G4UnitsTable.cc.

Referenced by G4RunManagerKernel::~G4RunManagerKernel().

349 {
350  if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
351  for (size_t i=0;i<pUnitsTable->size();i++)
352  {
353  delete (*pUnitsTable)[i];
354  }
355  pUnitsTable->clear();
356 }
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:59
G4String G4UnitDefinition::GetCategory ( const G4String str)
static

Definition at line 160 of file G4UnitsTable.cc.

References G4Exception(), GetUnitsTable(), JustWarning, and symbol.

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

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

Definition at line 129 of file G4UnitsTable.cc.

References BuildUnitsTable().

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

130 {
131  if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
132  if(pUnitsTable->size()==0) { BuildUnitsTable(); }
133  return *pUnitsTable;
134 }
static void BuildUnitsTable()
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:59
G4double G4UnitDefinition::GetValue ( ) const
inline
G4double G4UnitDefinition::GetValueOf ( const G4String str)
static

Definition at line 138 of file G4UnitsTable.cc.

References G4Exception(), GetUnitsTable(), JustWarning, and symbol.

Referenced by G4VPrimitiveScorer::CheckAndSetUnit(), export_G4UnitsTable(), G4ScoreQuantityMessenger::FParticleWithEnergyCommand(), G4tgrUtils::GetDouble(), G4Analysis::GetUnitValue(), HistoManager::SetHisto(), G4VisCommandsViewerSet::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), RMC01AnalysisManagerMessenger::SetNewValue(), G4AdjointSimMessenger::SetNewValue(), G4AttCheck::Standard(), and G4UIcommand::ValueOf().

139 {
141  for (size_t i=0;i<(GetUnitsTable()).size();i++)
142  {
143  G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
144  for (size_t j=0;j<units.size();j++)
145  {
146  name=units[j]->GetName(); symbol=units[j]->GetSymbol();
147  if(str==name||str==symbol)
148  { return units[j]->GetValue(); }
149  }
150  }
151  std::ostringstream message;
152  message << "The unit '" << str << "' does not exist in the Units Table.";
153  G4Exception("G4UnitDefinition::GetValueOf()", "InvalidUnit",
154  JustWarning, message, "Returning Value = 0.");
155  return 0.;
156 }
G4String symbol
Definition: TRTMaterials.hh:40
const XML_Char * name
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4UnitsTable & GetUnitsTable()
std::vector< G4UnitDefinition * > G4UnitsContainer
G4int G4UnitDefinition::operator!= ( const G4UnitDefinition right) const

Definition at line 122 of file G4UnitsTable.cc.

123 {
124  return (this != (G4UnitDefinition *) &right);
125 }
G4int G4UnitDefinition::operator== ( const G4UnitDefinition right) const

Definition at line 115 of file G4UnitsTable.cc.

116 {
117  return (this == (G4UnitDefinition *) &right);
118 }
void G4UnitDefinition::PrintDefinition ( )

Definition at line 183 of file G4UnitsTable.cc.

References G4cout, and G4endl.

Referenced by export_G4UnitsTable().

184 {
185  G4int nameL = (*pUnitsTable)[CategoryIndex]->GetNameMxLen();
186  G4int symbL = (*pUnitsTable)[CategoryIndex]->GetSymbMxLen();
187  G4cout << std::setw(nameL) << Name << " ("
188  << std::setw(symbL) << SymbolName << ") = " << Value << G4endl;
189 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void G4UnitDefinition::PrintUnitsTable ( )
static

Definition at line 336 of file G4UnitsTable.cc.

References G4cout.

Referenced by export_G4UnitsTable(), and G4UnitsMessenger::SetNewValue().

337 {
338  G4cout << "\n ----- The Table of Units ----- \n";
339  if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
340  for(size_t i=0;i<pUnitsTable->size();i++)
341  {
342  (*pUnitsTable)[i]->PrintCategory();
343  }
344 }
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:59
G4GLOB_DLL std::ostream G4cout

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