62 : Name(name),SymbolName(symbol),Value(value)
68 size_t nbCat = pUnitsTable->size();
70 while ((i<nbCat)&&((*pUnitsTable)[i]->
GetName()!=category)) { i++; }
77 ((*pUnitsTable)[CategoryIndex]->GetUnitsList()).push_back(
this);
81 (*pUnitsTable)[i]->UpdateNameMxLen((
G4int)name.length());
82 (*pUnitsTable)[i]->UpdateSymbMxLen((
G4int)symbol.length());
89 if (!pUnitsTable) {
delete pUnitsTable; pUnitsTable = 0; }
106 SymbolName = right.SymbolName;
108 CategoryIndex = right.CategoryIndex;
144 for (
size_t j=0;j<units.size();j++)
146 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
147 if(str==name||str==symbol)
148 {
return units[j]->GetValue(); }
151 std::ostringstream message;
152 message <<
"The unit '" << str <<
"' does not exist in the Units Table.";
153 G4Exception(
"G4UnitDefinition::GetValueOf()",
"InvalidUnit",
166 for (
size_t j=0;j<units.size();j++)
168 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
169 if(str==name||str==symbol)
170 {
return (*pUnitsTable)[i]->GetName(); }
173 std::ostringstream message;
174 message <<
"The unit '" << str <<
"' does not exist in the Units Table.";
175 G4Exception(
"G4UnitDefinition::GetCategory()",
"InvalidUnit",
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;
338 G4cout <<
"\n ----- The Table of Units ----- \n";
340 for(
size_t i=0;i<pUnitsTable->size();i++)
342 (*pUnitsTable)[i]->PrintCategory();
351 for (
size_t i=0;i<pUnitsTable->size();i++)
353 delete (*pUnitsTable)[i];
355 pUnitsTable->clear();
361 : Name(name),UnitsList(),NameMxLen(0),SymbMxLen(0)
369 for(
size_t i=0;i<UnitsList.size();i++)
390 UnitsList = right.UnitsList;
391 NameMxLen = right.NameMxLen;
392 SymbMxLen = right.SymbMxLen;
416 for(
size_t i=0;i<UnitsList.size();i++)
417 { UnitsList[i]->PrintDefinition(); }
427 size_t nbCat = theUnitsTable.size();
429 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
432 G4cout <<
" G4BestUnit: the category " << category
433 <<
" does not exist !!" <<
G4endl;
434 G4Exception(
"G4BestUnit::G4BestUnit()",
"InvalidCall",
451 size_t nbCat = theUnitsTable.size();
453 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
456 G4cerr <<
" G4BestUnit: the category " << category
457 <<
" does not exist." <<
G4endl;
458 G4Exception(
"G4BestUnit::G4BestUnit()",
"InvalidCall",
462 Value[0] = value.
x();
463 Value[1] = value.
y();
464 Value[2] = value.
z();
476 std::ostringstream oss;
488 G4int len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
490 G4int ksup(-1), kinf(-1);
496 std::fabs(a.Value[1])),
497 std::fabs(a.Value[2]));
499 for (
size_t k=0; k<List.size(); k++)
501 G4double unit = List[k]->GetValue();
503 {
if(unit>umax) {umax=unit; ksup=k;}}
505 {
if(unit<umin) {umin=unit; kinf=k;}}
509 if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
510 if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
515 if(index==-1) { index=kinf; }
516 if(index==-1) { index=0; }
518 for (
G4int j=0; j<a.nbOfVals; j++)
519 { flux << a.Value[j]/(List[
index]->GetValue()) <<
" "; }
521 std::ios::fmtflags oldform = flux.flags();
524 flux << std::setw(len) << List[
index]->GetSymbol();
static void BuildUnitsTable()
G4int operator==(const G4UnitsCategory &) const
G4BestUnit(G4double internalValue, const G4String &category)
std::vector< G4UnitsCategory * > G4UnitsTable
G4UnitsCategory(const G4String &name)
static G4double GetValueOf(const G4String &)
G4GLOB_DLL std::ostream G4cout
G4UnitDefinition(const G4String &name, const G4String &symbol, const G4String &category, G4double value)
G4int operator!=(const G4UnitsCategory &) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static void ClearUnitsTable()
static G4UnitsTable & GetUnitsTable()
static G4String GetCategory(const G4String &)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
G4int operator!=(const G4UnitDefinition &) const
G4int operator==(const G4UnitDefinition &) const
static void PrintUnitsTable()
const G4String & GetName() const
const XML_Char int const XML_Char * value
std::vector< G4UnitDefinition * > G4UnitsContainer
G4GLOB_DLL std::ostream G4cerr