59 #ifdef G4MULTITHREADED
65 G4UnitsTable::~G4UnitsTable()
67 G4UnitsTable::iterator itr = begin();
68 for(;itr!=end();itr++)
80 : Name(name),SymbolName(symbol),Value(value)
86 G4Exception(
"G4UnitDefinition::G4UnitDefinition",
"UnitsTable0000",
90 #ifdef G4MULTITHREADED
107 ((*pUnitsTable)[
CategoryIndex]->GetUnitsList()).push_back(
this);
111 (*pUnitsTable)[i]->UpdateNameMxLen((
G4int)name.length());
112 (*pUnitsTable)[i]->UpdateSymbMxLen((
G4int)symbol.length());
161 #ifdef G4MULTITHREADED
176 for (
size_t j=0;j<units.size();++j)
178 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
179 if(str==name||str==symbol) {
return true; }
193 for (
size_t j=0;j<units.size();++j)
195 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
196 if(str==name||str==symbol) {
return units[j]->GetValue(); }
200 message <<
"The unit '" << str <<
"' does not exist in the Units Table!";
201 G4Exception(
"G4UnitDefinition::GetValueOf()",
"InvalidUnit",
214 for (
size_t j=0;j<units.size();++j)
216 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
217 if(str==name||str==symbol) {
return (*
pUnitsTable)[i]->GetName(); }
221 message <<
"The unit '" << str <<
"' does not exist in the Units Table!";
222 G4Exception(
"G4UnitDefinition::GetCategory()",
"InvalidUnit",
393 G4cout <<
"\n ----- The Table of Units ----- \n";
397 (*pUnitsTable)[i]->PrintCategory();
405 #ifdef G4MULTITHREADED
409 { pUnitsTableShadow =
nullptr; }
413 delete (*pUnitsTable)[i];
423 : Name(name),UnitsList(),NameMxLen(0),SymbMxLen(0)
489 size_t nbCat = theUnitsTable.size();
491 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
494 G4cout <<
" G4BestUnit: the category " << category
495 <<
" does not exist !!" <<
G4endl;
496 G4Exception(
"G4BestUnit::G4BestUnit()",
"InvalidCall",
513 size_t nbCat = theUnitsTable.size();
515 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
518 G4cerr <<
" G4BestUnit: the category " << category
519 <<
" does not exist." <<
G4endl;
520 G4Exception(
"G4BestUnit::G4BestUnit()",
"InvalidCall",
538 std::ostringstream oss;
552 G4int ksup(-1), kinf(-1);
558 std::fabs(a.
Value[1])),
559 std::fabs(a.
Value[2]));
561 for (
size_t k=0; k<List.size(); k++)
563 G4double unit = List[k]->GetValue();
565 {
if(unit>umax) {umax=unit; ksup=k;}}
567 {
if(unit<umin) {umin=unit; kinf=k;}}
571 if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
572 if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
577 if(index==-1) { index=kinf; }
578 if(index==-1) { index=0; }
581 { flux << a.
Value[j]/(List[index]->GetValue()) <<
" "; }
583 std::ios::fmtflags oldform = flux.flags();
586 flux << std::setw(len) << List[index]->GetSymbol();
593 #ifdef G4MULTITHREADED
595 void G4UnitsTable::Synchronize()
597 G4UnitsTable* orig = &(G4UnitDefinition::GetUnitsTableShadow());
598 if(
this==orig)
return;
600 G4UnitsTable::iterator utItr = orig->begin();
601 for(;utItr!=orig->end();utItr++)
606 G4UnitsContainer::iterator ucItr = units->begin();
607 for(;ucItr!=units->end();ucItr++)
610 if(!Contains(unit,catName))
624 G4UnitsTable::iterator utItr = begin();
625 for(;utItr!=end();utItr++)
629 if(catName!=categoryName)
continue;
631 G4UnitsContainer::iterator ucItr = units->begin();
632 for(;ucItr!=units->end();ucItr++)
634 if((*ucItr)->GetName()==unit->
GetName() &&
635 (*ucItr)->GetSymbol()==unit->
GetSymbol())
static constexpr double kelvin
static constexpr double micrometer
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static constexpr double hep_pascal
static constexpr double kilogram
static constexpr double atmosphere
std::vector< ExP01TrackerHit * > a
static constexpr double kilogauss
static constexpr double centimeter3
static constexpr double hertz
static constexpr double kilometer3
static constexpr double MeV
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
G4int operator==(const G4UnitsCategory &) const
static constexpr double megahertz
static constexpr double keV
void message(RunManager *runmanager)
static constexpr double millisecond
static constexpr double microsecond
G4BestUnit(G4double internalValue, const G4String &category)
static G4ThreadLocal G4UnitsTable * pUnitsTable
static constexpr double electronvolt
static constexpr double gray
static constexpr double dL
static constexpr double second
static constexpr double kg
static constexpr double milligram
G4UnitsContainer UnitsList
static constexpr double centimeter2
static constexpr double meter2
static constexpr double nanobarn
static constexpr double petaelectronvolt
static G4bool IsUnitDefined(const G4String &)
G4int operator!=(const G4UnitDefinition &) const
static constexpr double picobarn
static constexpr double weber
static constexpr double gigaelectronvolt
static constexpr double megaelectronvolt
std::vector< G4UnitsCategory * > G4UnitsTable
static constexpr double milliradian
static constexpr double g
static constexpr double m
static constexpr double meter3
static constexpr double nanoampere
static constexpr double m3
const G4String & GetSymbol() const
static constexpr double fermi
static constexpr double millibarn
static void PrintUnitsTable()
static constexpr double cm2
static constexpr double gauss
const XML_Char int const XML_Char * value
static constexpr double mg
static constexpr double parsec
static constexpr double kilometer2
static void ClearUnitsTable()
static constexpr double mL
static constexpr double kilohertz
const G4String & GetName() const
G4UnitsCategory(const G4String &name)
static constexpr double kiloelectronvolt
static constexpr double ampere
static G4double GetValueOf(const G4String &)
static constexpr double eV
G4UnitDefinition(const G4String &name, const G4String &symbol, const G4String &category, G4double value)
static constexpr double kilometer
static G4UnitsTable & GetUnitsTable()
static constexpr double coulomb
static constexpr double curie
static constexpr double nanosecond
static constexpr double becquerel
G4GLOB_DLL std::ostream G4cerr
static constexpr double microampere
static constexpr double microbarn
static constexpr double kilovolt
static constexpr double steradian
static constexpr double eplus
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4UnitDefinition & operator=(const G4UnitDefinition &)
G4int operator==(const G4UnitDefinition &) const
static constexpr double meter
static constexpr double teraelectronvolt
static constexpr double millimeter3
std::vector< G4UnitDefinition * > G4UnitsContainer
G4UnitsContainer & GetUnitsList()
static constexpr double barn
G4int operator!=(const G4UnitsCategory &) const
G4double GetValue() const
static constexpr double radian
static constexpr double megavolt
static constexpr double joule
static constexpr double milliampere
static constexpr double degree
static constexpr double centimeter
static constexpr double cm
G4GLOB_DLL std::ostream G4cout
static G4ThreadLocal G4bool unitsTableDestroyed
static constexpr double angstrom
static G4String GetCategory(const G4String &)
static constexpr double mole
static constexpr double cL
static constexpr double picosecond
static constexpr double millimeter2
static constexpr double bar
static constexpr double cm3
static constexpr double newton
static constexpr double watt
static constexpr double millimeter
static constexpr double liter
G4UnitsCategory & operator=(const G4UnitsCategory &)
static constexpr double GeV
static constexpr double volt
const G4String & GetName() const
static constexpr double tesla
static void BuildUnitsTable()
static constexpr double gram
static constexpr double nanometer