Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 G4bool IsUnitDefined (const G4String &)
 
static G4double GetValueOf (const G4String &)
 
static G4String GetCategory (const G4String &)
 

Detailed Description

Definition at line 80 of file G4UnitsTable.hh.

Constructor & Destructor Documentation

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

Definition at line 77 of file G4UnitsTable.cc.

80  : Name(name),SymbolName(symbol),Value(value)
81 {
82  if (!pUnitsTable)
83  {
84  if(unitsTableDestroyed)
85  {
86  G4Exception("G4UnitDefinition::G4UnitDefinition","UnitsTable0000",
87  FatalException,"G4UnitsTable had already deleted.");
88  }
89  pUnitsTable = new G4UnitsTable;
90 #ifdef G4MULTITHREADED
92  { pUnitsTableShadow = pUnitsTable; }
93 #endif
94  }
95 
96  // Does the Category objet already exist ?
97  //
98  size_t nbCat = pUnitsTable->size();
99  size_t i = 0;
100  while ((i<nbCat)&&((*pUnitsTable)[i]->GetName()!=category)) { i++; }
101  if (i == nbCat)
102  { pUnitsTable->push_back( new G4UnitsCategory(category)); }
103  CategoryIndex = i;
104 
105  // Insert this Unit in the Units table
106  //
107  ((*pUnitsTable)[CategoryIndex]->GetUnitsList()).push_back(this);
108 
109  // Update string max length for name and symbol
110  //
111  (*pUnitsTable)[i]->UpdateNameMxLen((G4int)name.length());
112  (*pUnitsTable)[i]->UpdateSymbMxLen((G4int)symbol.length());
113 }
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:60
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
Definition: expat.h:331
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4String & GetName() const
G4bool IsMasterThread()
Definition: G4Threading.cc:146

Here is the call graph for this function:

Here is the caller graph for this function:

G4UnitDefinition::~G4UnitDefinition ( )

Definition at line 117 of file G4UnitsTable.cc.

118 {;}

Member Function Documentation

void G4UnitDefinition::BuildUnitsTable ( )
static

Definition at line 240 of file G4UnitsTable.cc.

241 {
242  //Length
243  new G4UnitDefinition( "parsec","pc" ,"Length",parsec);
244  new G4UnitDefinition( "kilometer","km" ,"Length",kilometer);
245  new G4UnitDefinition( "meter","m" ,"Length",meter);
246  new G4UnitDefinition("centimeter","cm" ,"Length",centimeter);
247  new G4UnitDefinition("millimeter","mm" ,"Length",millimeter);
248  new G4UnitDefinition("micrometer","um" ,"Length",micrometer);
249  new G4UnitDefinition( "nanometer","nm" ,"Length",nanometer);
250  new G4UnitDefinition( "angstrom","Ang" ,"Length",angstrom);
251  new G4UnitDefinition( "fermi","fm" ,"Length",fermi);
252 
253  //Surface
254  new G4UnitDefinition( "kilometer2","km2" ,"Surface",kilometer2);
255  new G4UnitDefinition( "meter2","m2" ,"Surface",meter2);
256  new G4UnitDefinition("centimeter2","cm2" ,"Surface",centimeter2);
257  new G4UnitDefinition("millimeter2","mm2" ,"Surface",millimeter2);
258  new G4UnitDefinition( "barn","barn" ,"Surface",barn);
259  new G4UnitDefinition( "millibarn","mbarn" ,"Surface",millibarn);
260  new G4UnitDefinition( "microbarn","mubarn" ,"Surface",microbarn);
261  new G4UnitDefinition( "nanobarn","nbarn" ,"Surface",nanobarn);
262  new G4UnitDefinition( "picobarn","pbarn" ,"Surface",picobarn);
263 
264  //Volume
265  new G4UnitDefinition( "kilometer3","km3" ,"Volume",kilometer3);
266  new G4UnitDefinition( "meter3","m3" ,"Volume",meter3);
267  new G4UnitDefinition("centimeter3","cm3" ,"Volume",centimeter3);
268  new G4UnitDefinition("millimeter3","mm3" ,"Volume",millimeter3);
269 
270  new G4UnitDefinition( "liter","L" ,"Volume",liter);
271  new G4UnitDefinition( "dL","dL" ,"Volume",dL);
272  new G4UnitDefinition( "cL","cL" ,"Volume",cL);
273  new G4UnitDefinition( "mL","mL" ,"Volume",mL);
274 
275  //Angle
276  new G4UnitDefinition( "radian","rad" ,"Angle",radian);
277  new G4UnitDefinition("milliradian","mrad" ,"Angle",milliradian);
278  new G4UnitDefinition( "degree","deg" ,"Angle",degree);
279 
280  //Solid angle
281  new G4UnitDefinition( "steradian","sr" ,"Solid angle",steradian);
282  new G4UnitDefinition("millisteradian","msr" ,"Solid angle",steradian*0.001);
283 
284  //Time
285  new G4UnitDefinition( "second","s" ,"Time",second);
286  new G4UnitDefinition("millisecond","ms" ,"Time",millisecond);
287  new G4UnitDefinition("microsecond","us" ,"Time",microsecond);
288  new G4UnitDefinition( "nanosecond","ns" ,"Time",nanosecond);
289  new G4UnitDefinition( "picosecond","ps" ,"Time",picosecond);
290 
291  //Frequency
292  new G4UnitDefinition( "hertz","Hz" ,"Frequency",hertz);
293  new G4UnitDefinition("kilohertz","kHz" ,"Frequency",kilohertz);
294  new G4UnitDefinition("megahertz","MHz" ,"Frequency",megahertz);
295 
296  //Electric charge
297  new G4UnitDefinition( "eplus","e+" ,"Electric charge",eplus);
298  new G4UnitDefinition("coulomb","C" ,"Electric charge",coulomb);
299 
300  //Energy
301  new G4UnitDefinition( "electronvolt","eV" ,"Energy",electronvolt);
302  new G4UnitDefinition("kiloelectronvolt","keV","Energy",kiloelectronvolt);
303  new G4UnitDefinition("megaelectronvolt","MeV","Energy",megaelectronvolt);
304  new G4UnitDefinition("gigaelectronvolt","GeV","Energy",gigaelectronvolt);
305  new G4UnitDefinition("teraelectronvolt","TeV","Energy",teraelectronvolt);
306  new G4UnitDefinition("petaelectronvolt","PeV","Energy",petaelectronvolt);
307  new G4UnitDefinition( "joule","J" ,"Energy",joule);
308 
309  // Energy/Length
310  new G4UnitDefinition( "GeV/cm", "GeV/cm","Energy/Length", GeV/cm);
311  new G4UnitDefinition( "MeV/cm", "MeV/cm","Energy/Length", MeV/cm);
312  new G4UnitDefinition( "keV/cm", "keV/cm","Energy/Length", keV/cm);
313  new G4UnitDefinition( "eV/cm", "eV/cm","Energy/Length", eV/cm);
314 
315  //Mass
316  new G4UnitDefinition("milligram","mg","Mass",milligram);
317  new G4UnitDefinition( "gram","g" ,"Mass",gram);
318  new G4UnitDefinition( "kilogram","kg","Mass",kilogram);
319 
320  //Volumic Mass
321  new G4UnitDefinition( "g/cm3", "g/cm3","Volumic Mass", g/cm3);
322  new G4UnitDefinition("mg/cm3","mg/cm3","Volumic Mass",mg/cm3);
323  new G4UnitDefinition("kg/m3", "kg/m3", "Volumic Mass",kg/m3);
324 
325  // Mass/Surface
326  new G4UnitDefinition( "g/cm2", "g/cm2","Mass/Surface", g/cm2);
327  new G4UnitDefinition( "mg/cm2", "mg/cm2","Mass/Surface", mg/cm2);
328  new G4UnitDefinition( "kg/cm2", "kg/cm2","Mass/Surface", kg/cm2);
329 
330  // Surface/Mass
331  new G4UnitDefinition( "cm2/g", "cm2/g","Surface/Mass", cm2/g);
332 
333  // Energy.Surface/Mass
334  new G4UnitDefinition( "eV*cm2/g", " eV*cm2/g","Energy*Surface/Mass", eV*cm2/g);
335  new G4UnitDefinition("keV*cm2/g", "keV*cm2/g","Energy*Surface/Mass",keV*cm2/g);
336  new G4UnitDefinition("MeV*cm2/g", "MeV*cm2/g","Energy*Surface/Mass",MeV*cm2/g);
337  new G4UnitDefinition("GeV*cm2/g", "GeV*cm2/g","Energy*Surface/Mass",GeV*cm2/g);
338 
339  //Power
340  new G4UnitDefinition("watt","W","Power",watt);
341 
342  //Force
343  new G4UnitDefinition("newton","N","Force",newton);
344 
345  //Pressure
346  new G4UnitDefinition( "pascal","Pa" ,"Pressure",hep_pascal);
347  new G4UnitDefinition( "bar","bar","Pressure",bar);
348  new G4UnitDefinition("atmosphere","atm","Pressure",atmosphere);
349 
350  //Electric current
351  new G4UnitDefinition( "ampere","A" ,"Electric current",ampere);
352  new G4UnitDefinition("milliampere","mA" ,"Electric current",milliampere);
353  new G4UnitDefinition("microampere","muA","Electric current",microampere);
354  new G4UnitDefinition( "nanoampere","nA" ,"Electric current",nanoampere);
355 
356  //Electric potential
357  new G4UnitDefinition( "volt","V" ,"Electric potential",volt);
358  new G4UnitDefinition("kilovolt","kV","Electric potential",kilovolt);
359  new G4UnitDefinition("megavolt","MV","Electric potential",megavolt);
360 
361  //Electric field
362  new G4UnitDefinition( "volt/m","V/m" ,"Electric field",volt/m);
363  new G4UnitDefinition("kilovolt/m","kV/m","Electric field",kilovolt/m);
364  new G4UnitDefinition("megavolt/m","MV/m","Electric field",megavolt/m);
365 
366  //Magnetic flux
367  new G4UnitDefinition("weber","Wb","Magnetic flux",weber);
368 
369  //Magnetic flux density
370  new G4UnitDefinition( "tesla","T" ,"Magnetic flux density",tesla);
371  new G4UnitDefinition("kilogauss","kG","Magnetic flux density",kilogauss);
372  new G4UnitDefinition( "gauss","G" ,"Magnetic flux density",gauss);
373 
374  //Temperature
375  new G4UnitDefinition("kelvin","K","Temperature",kelvin);
376 
377  //Amount of substance
378  new G4UnitDefinition("mole","mol","Amount of substance",mole);
379  new G4UnitDefinition("g/mole","g/mol","Molar mass",g/mole);
380 
381  //Activity
382  new G4UnitDefinition("becquerel","Bq","Activity",becquerel);
383  new G4UnitDefinition( "curie","Ci","Activity",curie);
384 
385  //Dose
386  new G4UnitDefinition("gray","Gy","Dose",gray);
387 }
static constexpr double tesla
Definition: G4SIunits.hh:268
static constexpr double parsec
Definition: G4SIunits.hh:98
static constexpr double mg
Definition: G4SIunits.hh:184
static constexpr double kilovolt
Definition: G4SIunits.hh:243
static constexpr double hep_pascal
Definition: G4SIunits.hh:235
static constexpr double teraelectronvolt
Definition: G4SIunits.hh:210
static constexpr double millimeter2
Definition: G4SIunits.hh:87
static constexpr double cm2
Definition: G4SIunits.hh:120
static constexpr double milliradian
Definition: G4SIunits.hh:143
static constexpr double centimeter
Definition: G4SIunits.hh:90
static constexpr double megaelectronvolt
Definition: G4SIunits.hh:208
static constexpr double becquerel
Definition: G4SIunits.hh:291
static constexpr double coulomb
Definition: G4SIunits.hh:197
static constexpr double liter
Definition: G4SIunits.hh:123
static constexpr double hertz
Definition: G4SIunits.hh:163
static constexpr double nanometer
Definition: G4SIunits.hh:101
static constexpr double ampere
Definition: G4SIunits.hh:189
static constexpr double weber
Definition: G4SIunits.hh:263
static constexpr double second
Definition: G4SIunits.hh:157
static constexpr double m3
Definition: G4SIunits.hh:131
static constexpr double millimeter3
Definition: G4SIunits.hh:88
static constexpr double watt
Definition: G4SIunits.hh:224
static constexpr double electronvolt
Definition: G4SIunits.hh:206
static constexpr double newton
Definition: G4SIunits.hh:229
static constexpr double meter3
Definition: G4SIunits.hh:84
static constexpr double nanosecond
Definition: G4SIunits.hh:158
static constexpr double picosecond
Definition: G4SIunits.hh:161
static constexpr double meter
Definition: G4SIunits.hh:82
static constexpr double gram
Definition: G4SIunits.hh:178
static constexpr double microampere
Definition: G4SIunits.hh:191
static constexpr double kilometer2
Definition: G4SIunits.hh:95
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
static constexpr double m
Definition: G4SIunits.hh:129
static constexpr double gauss
Definition: G4SIunits.hh:270
static constexpr double nanobarn
Definition: G4SIunits.hh:108
static constexpr double milliampere
Definition: G4SIunits.hh:190
static constexpr double degree
Definition: G4SIunits.hh:144
static constexpr double megahertz
Definition: G4SIunits.hh:165
static constexpr double kilogauss
Definition: G4SIunits.hh:271
G4UnitDefinition(const G4String &name, const G4String &symbol, const G4String &category, G4double value)
Definition: G4UnitsTable.cc:77
static constexpr double steradian
Definition: G4SIunits.hh:146
static constexpr double gray
Definition: G4SIunits.hh:309
static constexpr double cm
Definition: G4SIunits.hh:119
static constexpr double eplus
Definition: G4SIunits.hh:199
static constexpr double centimeter2
Definition: G4SIunits.hh:91
static constexpr double eV
Definition: G4SIunits.hh:215
static constexpr double kg
Definition: G4SIunits.hh:182
static constexpr double kelvin
Definition: G4SIunits.hh:281
static constexpr double cm3
Definition: G4SIunits.hh:121
static constexpr double radian
Definition: G4SIunits.hh:142
static constexpr double petaelectronvolt
Definition: G4SIunits.hh:211
static constexpr double kilohertz
Definition: G4SIunits.hh:164
static constexpr double gigaelectronvolt
Definition: G4SIunits.hh:209
static constexpr double kilogram
Definition: G4SIunits.hh:177
static constexpr double nanoampere
Definition: G4SIunits.hh:192
static constexpr double joule
Definition: G4SIunits.hh:204
static constexpr double milligram
Definition: G4SIunits.hh:179
static constexpr double kiloelectronvolt
Definition: G4SIunits.hh:207
static constexpr double millimeter
Definition: G4SIunits.hh:86
static constexpr double mL
Definition: G4SIunits.hh:127
static constexpr double GeV
Definition: G4SIunits.hh:217
static constexpr double megavolt
Definition: G4SIunits.hh:242
static constexpr double millisecond
Definition: G4SIunits.hh:159
static constexpr double microsecond
Definition: G4SIunits.hh:160
static constexpr double MeV
Definition: G4SIunits.hh:214
static constexpr double angstrom
Definition: G4SIunits.hh:102
static constexpr double kilometer3
Definition: G4SIunits.hh:96
static constexpr double meter2
Definition: G4SIunits.hh:83
static constexpr double bar
Definition: G4SIunits.hh:236
static constexpr double volt
Definition: G4SIunits.hh:244
static constexpr double curie
Definition: G4SIunits.hh:292
static constexpr double fermi
Definition: G4SIunits.hh:103
static constexpr double barn
Definition: G4SIunits.hh:105
static constexpr double cL
Definition: G4SIunits.hh:126
static constexpr double centimeter3
Definition: G4SIunits.hh:92
static constexpr double keV
Definition: G4SIunits.hh:216
static constexpr double atmosphere
Definition: G4SIunits.hh:237
static constexpr double micrometer
Definition: G4SIunits.hh:100
static constexpr double mole
Definition: G4SIunits.hh:286
static constexpr double kilometer
Definition: G4SIunits.hh:94
static constexpr double dL
Definition: G4SIunits.hh:125
static constexpr double millibarn
Definition: G4SIunits.hh:106
static constexpr double microbarn
Definition: G4SIunits.hh:107
static constexpr double picobarn
Definition: G4SIunits.hh:109

Here is the call graph for this function:

Here is the caller graph for this function:

void G4UnitDefinition::ClearUnitsTable ( )
static

Definition at line 403 of file G4UnitsTable.cc.

404 {
405 #ifdef G4MULTITHREADED
406  delete pUnitsTable;
407  pUnitsTable = nullptr;
409  { pUnitsTableShadow = nullptr; }
410 #else
411  for (size_t i=0;i<pUnitsTable->size();i++)
412  {
413  delete (*pUnitsTable)[i];
414  }
415  pUnitsTable->clear();
416 #endif
417  unitsTableDestroyed = true;
418 }
G4bool IsMasterThread()
Definition: G4Threading.cc:146

Here is the call graph for this function:

Here is the caller graph for this function:

G4String G4UnitDefinition::GetCategory ( const G4String str)
static

Definition at line 208 of file G4UnitsTable.cc.

209 {
210  G4String name, symbol;
211  for (size_t i=0;i<(GetUnitsTable()).size();++i)
212  {
213  G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
214  for (size_t j=0;j<units.size();++j)
215  {
216  name=units[j]->GetName(); symbol=units[j]->GetSymbol();
217  if(str==name||str==symbol) { return (*pUnitsTable)[i]->GetName(); }
218  }
219  }
220  std::ostringstream message;
221  message << "The unit '" << str << "' does not exist in the Units Table!";
222  G4Exception("G4UnitDefinition::GetCategory()", "InvalidUnit",
223  FatalException, message);
224  name = "None";
225  return name;
226 }
const XML_Char * name
Definition: expat.h:151
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4UnitsTable & GetUnitsTable()
std::vector< G4UnitDefinition * > G4UnitsContainer

Here is the call graph for this function:

const G4String& G4UnitDefinition::GetName ( ) const
inline

Here is the caller graph for this function:

const G4String& G4UnitDefinition::GetSymbol ( ) const
inline

Here is the caller graph for this function:

G4UnitsTable & G4UnitDefinition::GetUnitsTable ( )
static

Definition at line 157 of file G4UnitsTable.cc.

158 {
159  if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
160  if(pUnitsTable->size()==0) { BuildUnitsTable(); }
161 #ifdef G4MULTITHREADED
162  if(G4Threading::IsMasterThread() && !pUnitsTableShadow)
163  { pUnitsTableShadow = pUnitsTable; }
164 #endif
165  return *pUnitsTable;
166 }
static void BuildUnitsTable()
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:60
G4bool IsMasterThread()
Definition: G4Threading.cc:146

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4UnitDefinition::GetValue ( ) const
inline

Here is the caller graph for this function:

G4double G4UnitDefinition::GetValueOf ( const G4String str)
static

Definition at line 187 of file G4UnitsTable.cc.

188 {
189  G4String name, symbol;
190  for (size_t i=0;i<(GetUnitsTable()).size();++i)
191  {
192  G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
193  for (size_t j=0;j<units.size();++j)
194  {
195  name=units[j]->GetName(); symbol=units[j]->GetSymbol();
196  if(str==name||str==symbol) { return units[j]->GetValue(); }
197  }
198  }
199  std::ostringstream message;
200  message << "The unit '" << str << "' does not exist in the Units Table!";
201  G4Exception("G4UnitDefinition::GetValueOf()", "InvalidUnit",
202  FatalException, message);
203  return 0.;
204 }
const XML_Char * name
Definition: expat.h:151
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4UnitsTable & GetUnitsTable()
std::vector< G4UnitDefinition * > G4UnitsContainer

Here is the call graph for this function:

G4bool G4UnitDefinition::IsUnitDefined ( const G4String str)
static

Definition at line 170 of file G4UnitsTable.cc.

171 {
172  G4String name, symbol;
173  for (size_t i=0;i<(GetUnitsTable()).size();++i)
174  {
175  G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
176  for (size_t j=0;j<units.size();++j)
177  {
178  name=units[j]->GetName(); symbol=units[j]->GetSymbol();
179  if(str==name||str==symbol) { return true; }
180  }
181  }
182  return false;
183 }
const XML_Char * name
Definition: expat.h:151
static G4UnitsTable & GetUnitsTable()
std::vector< G4UnitDefinition * > G4UnitsContainer

Here is the call graph for this function:

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

Definition at line 150 of file G4UnitsTable.cc.

151 {
152  return (this != (G4UnitDefinition *) &right);
153 }
G4int G4UnitDefinition::operator== ( const G4UnitDefinition right) const

Definition at line 143 of file G4UnitsTable.cc.

144 {
145  return (this == (G4UnitDefinition *) &right);
146 }
void G4UnitDefinition::PrintDefinition ( )

Definition at line 230 of file G4UnitsTable.cc.

231 {
232  G4int nameL = (*pUnitsTable)[CategoryIndex]->GetNameMxLen();
233  G4int symbL = (*pUnitsTable)[CategoryIndex]->GetSymbMxLen();
234  G4cout << std::setw(nameL) << Name << " ("
235  << std::setw(symbL) << SymbolName << ") = " << Value << G4endl;
236 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:

void G4UnitDefinition::PrintUnitsTable ( )
static

Definition at line 391 of file G4UnitsTable.cc.

392 {
393  G4cout << "\n ----- The Table of Units ----- \n";
394  if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
395  for(size_t i=0;i<pUnitsTable->size();i++)
396  {
397  (*pUnitsTable)[i]->PrintCategory();
398  }
399 }
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:60
G4GLOB_DLL std::ostream G4cout

Here is the caller graph for this function:


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