58 #ifdef G4MULTITHREADED
64 G4UnitsTable::~G4UnitsTable()
66 G4UnitsTable::iterator itr = begin();
67 for(;itr!=end();itr++)
79 :
Name(name),SymbolName(symbol),Value(value)
85 G4Exception(
"G4UnitDefinition::G4UnitDefinition",
"UnitsTable0000",
89 #ifdef G4MULTITHREADED
106 ((*pUnitsTable)[
CategoryIndex]->GetUnitsList()).push_back(
this);
110 (*pUnitsTable)[i]->UpdateNameMxLen((
G4int)name.length());
111 (*pUnitsTable)[i]->UpdateSymbMxLen((
G4int)symbol.length());
160 #ifdef G4MULTITHREADED
175 for (
size_t j=0;j<units.size();++j)
177 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
178 if(str==name||str==symbol) {
return true; }
192 for (
size_t j=0;j<units.size();++j)
194 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
195 if(str==name||str==symbol) {
return units[j]->GetValue(); }
199 message <<
"The unit '" << str <<
"' does not exist in the Units Table!";
200 G4Exception(
"G4UnitDefinition::GetValueOf()",
"InvalidUnit",
213 for (
size_t j=0;j<units.size();++j)
215 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
216 if(str==name||str==symbol) {
return (*
pUnitsTable)[i]->GetName(); }
220 message <<
"The unit '" << str <<
"' does not exist in the Units Table!";
221 G4Exception(
"G4UnitDefinition::GetCategory()",
"InvalidUnit",
392 G4cout <<
"\n ----- The Table of Units ----- \n";
396 (*pUnitsTable)[i]->PrintCategory();
404 #ifdef G4MULTITHREADED
408 { pUnitsTableShadow =
nullptr; }
412 delete (*pUnitsTable)[i];
422 :
Name(name),UnitsList(),NameMxLen(0),SymbMxLen(0)
488 size_t nbCat = theUnitsTable.size();
490 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
493 G4cout <<
" G4BestUnit: the category " << category
494 <<
" does not exist !!" <<
G4endl;
495 G4Exception(
"G4BestUnit::G4BestUnit()",
"InvalidCall",
512 size_t nbCat = theUnitsTable.size();
514 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
517 G4cerr <<
" G4BestUnit: the category " << category
518 <<
" does not exist." <<
G4endl;
519 G4Exception(
"G4BestUnit::G4BestUnit()",
"InvalidCall",
537 std::ostringstream oss;
551 G4int ksup(-1), kinf(-1);
557 std::fabs(a.
Value[1])),
558 std::fabs(a.
Value[2]));
560 for (
size_t k=0;
k<List.size();
k++)
564 {
if(unit>umax) {umax=unit; ksup=
k;}}
566 {
if(unit<umin) {umin=unit; kinf=
k;}}
570 if ((ratio>=1.)&&(ratio<rsup)) {rsup=
ratio; ksup=
k;}
571 if ((ratio< 1.)&&(ratio>rinf)) {rinf=
ratio; kinf=
k;}
576 if(index==-1) { index=kinf; }
577 if(index==-1) { index=0; }
580 { flux << a.
Value[j]/(List[index]->GetValue()) <<
" "; }
582 std::ios::fmtflags oldform = flux.flags();
585 flux << std::setw(len) << List[index]->GetSymbol();
592 #ifdef G4MULTITHREADED
594 void G4UnitsTable::Synchronize()
596 G4UnitsTable* orig = &(G4UnitDefinition::GetUnitsTableShadow());
597 if(
this==orig)
return;
599 G4UnitsTable::iterator utItr = orig->begin();
600 for(;utItr!=orig->end();utItr++)
605 G4UnitsContainer::iterator ucItr = units->begin();
606 for(;ucItr!=units->end();ucItr++)
609 if(!Contains(unit,catName))
623 G4UnitsTable::iterator utItr = begin();
624 for(;utItr!=end();utItr++)
628 if(catName!=categoryName)
continue;
630 G4UnitsContainer::iterator ucItr = units->begin();
631 for(;ucItr!=units->end();ucItr++)
633 if((*ucItr)->GetName()==unit->
GetName() &&
634 (*ucItr)->GetSymbol()==unit->
GetSymbol())