59 #ifdef G4MULTITHREADED
65 G4UnitsTable::~G4UnitsTable()
67 G4UnitsTable::iterator itr = begin();
68 for(;itr!=end();itr++)
80 : Name(name),SymbolName(symbol),Value(value)
84 if(unitsTableDestroyed)
86 G4Exception(
"G4UnitDefinition::G4UnitDefinition",
"UnitsTable0000",
90 #ifdef G4MULTITHREADED
92 { pUnitsTableShadow = pUnitsTable; }
98 size_t nbCat = pUnitsTable->size();
100 while ((i<nbCat)&&((*pUnitsTable)[i]->
GetName()!=category)) { i++; }
107 ((*pUnitsTable)[CategoryIndex]->GetUnitsList()).push_back(
this);
111 (*pUnitsTable)[i]->UpdateNameMxLen((
G4int)name.length());
112 (*pUnitsTable)[i]->UpdateSymbMxLen((
G4int)symbol.length());
134 SymbolName = right.SymbolName;
136 CategoryIndex = right.CategoryIndex;
161 #ifdef G4MULTITHREADED
163 { pUnitsTableShadow = pUnitsTable; }
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(); }
199 std::ostringstream message;
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(); }
220 std::ostringstream message;
221 message <<
"The unit '" << str <<
"' does not exist in the Units Table!";
222 G4Exception(
"G4UnitDefinition::GetCategory()",
"InvalidUnit",
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;
393 G4cout <<
"\n ----- The Table of Units ----- \n";
395 for(
size_t i=0;i<pUnitsTable->size();i++)
397 (*pUnitsTable)[i]->PrintCategory();
405 #ifdef G4MULTITHREADED
407 pUnitsTable =
nullptr;
409 { pUnitsTableShadow =
nullptr; }
411 for (
size_t i=0;i<pUnitsTable->size();i++)
413 delete (*pUnitsTable)[i];
415 pUnitsTable->clear();
417 unitsTableDestroyed =
true;
423 : Name(name),UnitsList(),NameMxLen(0),SymbMxLen(0)
431 for(
size_t i=0;i<UnitsList.size();i++)
452 UnitsList = right.UnitsList;
453 NameMxLen = right.NameMxLen;
454 SymbMxLen = right.SymbMxLen;
478 for(
size_t i=0;i<UnitsList.size();i++)
479 { UnitsList[i]->PrintDefinition(); }
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",
524 Value[0] = value.
x();
525 Value[1] = value.
y();
526 Value[2] = value.
z();
538 std::ostringstream oss;
550 G4int len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
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; }
580 for (
G4int j=0; j<a.nbOfVals; j++)
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 tesla
static constexpr double parsec
static void BuildUnitsTable()
G4int operator==(const G4UnitsCategory &) const
static constexpr double mg
static constexpr double kilovolt
static constexpr double hep_pascal
static constexpr double teraelectronvolt
static constexpr double millimeter2
static constexpr double cm2
std::vector< ExP01TrackerHit * > a
static constexpr double milliradian
static constexpr double centimeter
G4BestUnit(G4double internalValue, const G4String &category)
std::vector< G4UnitsCategory * > G4UnitsTable
static constexpr double megaelectronvolt
static constexpr double becquerel
static constexpr double coulomb
static constexpr double liter
static constexpr double hertz
static constexpr double nanometer
static constexpr double ampere
static constexpr double weber
static constexpr double second
static constexpr double m3
const G4String & GetSymbol() const
G4UnitsContainer & GetUnitsList()
static constexpr double millimeter3
static constexpr double watt
G4UnitsCategory(const G4String &name)
static constexpr double electronvolt
static constexpr double newton
static constexpr double meter3
static constexpr double nanosecond
static constexpr double picosecond
static constexpr double meter
static constexpr double gram
static constexpr double microampere
static constexpr double kilometer2
static G4double GetValueOf(const G4String &)
G4GLOB_DLL std::ostream G4cout
static constexpr double m
const XML_Char int const XML_Char * value
static constexpr double gauss
static constexpr double nanobarn
static constexpr double milliampere
static constexpr double degree
static constexpr double megahertz
static constexpr double kilogauss
G4UnitDefinition(const G4String &name, const G4String &symbol, const G4String &category, G4double value)
static constexpr double steradian
static constexpr double gray
static constexpr double cm
static constexpr double eplus
static constexpr double centimeter2
G4int operator!=(const G4UnitsCategory &) const
static constexpr double eV
const G4String & GetName() const
static constexpr double kg
static constexpr double kelvin
static constexpr double cm3
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static void ClearUnitsTable()
static G4UnitsTable & GetUnitsTable()
static constexpr double radian
static G4String GetCategory(const G4String &)
static constexpr double petaelectronvolt
static constexpr double kilohertz
static constexpr double gigaelectronvolt
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static constexpr double kilogram
static constexpr double nanoampere
static constexpr double joule
static constexpr double milligram
static constexpr double kiloelectronvolt
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
static constexpr double millimeter
G4int operator!=(const G4UnitDefinition &) const
static constexpr double mL
static constexpr double GeV
static constexpr double megavolt
static constexpr double millisecond
G4int operator==(const G4UnitDefinition &) const
static void PrintUnitsTable()
const G4String & GetName() const
static constexpr double microsecond
static constexpr double MeV
static constexpr double angstrom
static constexpr double kilometer3
static constexpr double meter2
G4double GetValue() const
static constexpr double bar
static constexpr double volt
static constexpr double curie
std::vector< G4UnitDefinition * > G4UnitsContainer
static constexpr double fermi
static constexpr double barn
static constexpr double cL
static constexpr double centimeter3
static constexpr double keV
static constexpr double atmosphere
static constexpr double micrometer
static constexpr double mole
static constexpr double kilometer
static constexpr double dL
static constexpr double millibarn
static G4bool IsUnitDefined(const G4String &)
static constexpr double microbarn
G4GLOB_DLL std::ostream G4cerr
static constexpr double picobarn