62 : Name(name),SymbolName(symbol),Value(value)
66 size_t nbCat = theUnitsTable.size();
68 while ((i<nbCat)&&(theUnitsTable[i]->
GetName()!=category)) { i++; }
75 (theUnitsTable[CategoryIndex]->GetUnitsList()).push_back(
this);
79 theUnitsTable[i]->UpdateNameMxLen((
G4int)name.length());
80 theUnitsTable[i]->UpdateSymbMxLen((
G4int)symbol.length());
103 SymbolName = right.SymbolName;
105 CategoryIndex = right.CategoryIndex;
129 return theUnitsTable;
140 for (
size_t j=0;j<units.size();j++)
142 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
143 if(str==name||str==symbol)
144 {
return units[j]->GetValue(); }
147 std::ostringstream message;
148 message <<
"The unit '" << str <<
"' does not exist in the Units Table.";
149 G4Exception(
"G4UnitDefinition::GetValueOf()",
"InvalidUnit",
162 for (
size_t j=0;j<units.size();j++)
164 name=units[j]->GetName(); symbol=units[j]->GetSymbol();
165 if(str==name||str==symbol)
166 {
return theUnitsTable[i]->GetName(); }
169 std::ostringstream message;
170 message <<
"The unit '" << str <<
"' does not exist in the Units Table.";
171 G4Exception(
"G4UnitDefinition::GetCategory()",
"InvalidUnit",
181 G4int nameL = theUnitsTable[CategoryIndex]->GetNameMxLen();
182 G4int symbL = theUnitsTable[CategoryIndex]->GetSymbMxLen();
183 G4cout << std::setw(nameL) << Name <<
" ("
184 << std::setw(symbL) << SymbolName <<
") = " << Value <<
G4endl;
226 new G4UnitDefinition(
"millisteradian",
"msr" ,
"Solid angle",steradian*0.001);
278 new G4UnitDefinition(
"eV*cm2/g",
" eV*cm2/g",
"Energy*Surface/Mass", eV*cm2/g);
279 new G4UnitDefinition(
"keV*cm2/g",
"keV*cm2/g",
"Energy*Surface/Mass",keV*cm2/g);
280 new G4UnitDefinition(
"MeV*cm2/g",
"MeV*cm2/g",
"Energy*Surface/Mass",MeV*cm2/g);
281 new G4UnitDefinition(
"GeV*cm2/g",
"GeV*cm2/g",
"Energy*Surface/Mass",GeV*cm2/g);
334 G4cout <<
"\n ----- The Table of Units ----- \n";
335 for(
size_t i=0;i<theUnitsTable.size();i++)
337 theUnitsTable[i]->PrintCategory();
345 for (
size_t i=0;i<theUnitsTable.size();i++)
347 delete theUnitsTable[i];
349 theUnitsTable.clear();
355 : Name(name),UnitsList(),NameMxLen(0),SymbMxLen(0)
363 for(
size_t i=0;i<UnitsList.size();i++)
384 UnitsList = right.UnitsList;
385 NameMxLen = right.NameMxLen;
386 SymbMxLen = right.SymbMxLen;
410 for(
size_t i=0;i<UnitsList.size();i++)
411 { UnitsList[i]->PrintDefinition(); }
421 size_t nbCat = theUnitsTable.size();
423 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
426 G4cout <<
" G4BestUnit: the category " << category
427 <<
" does not exist !!" <<
G4endl;
428 G4Exception(
"G4BestUnit::G4BestUnit()",
"InvalidCall",
445 size_t nbCat = theUnitsTable.size();
447 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
450 G4cerr <<
" G4BestUnit: the category " << category
451 <<
" does not exist." <<
G4endl;
452 G4Exception(
"G4BestUnit::G4BestUnit()",
"InvalidCall",
456 Value[0] = value.
x();
457 Value[1] = value.
y();
458 Value[2] = value.
z();
470 std::ostringstream oss;
482 G4int len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
484 G4int ksup(-1), kinf(-1);
489 G4double value = std::max(std::max(std::fabs(a.Value[0]),
490 std::fabs(a.Value[1])),
491 std::fabs(a.Value[2]));
493 for (
size_t k=0; k<List.size(); k++)
495 G4double unit = List[k]->GetValue();
497 {
if(unit>umax) {umax=unit; ksup=k;}}
499 {
if(unit<umin) {umin=unit; kinf=k;}}
503 if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
504 if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
509 if(index==-1) { index=kinf; }
510 if(index==-1) { index=0; }
512 for (
G4int j=0; j<a.nbOfVals; j++)
513 { flux << a.Value[j]/(List[index]->GetValue()) <<
" "; }
515 std::ios::fmtflags oldform = flux.flags();
517 flux.setf(std::ios::left,std::ios::adjustfield);
518 flux << std::setw(len) << List[index]->GetSymbol();
std::ostream & operator<<(std::ostream &flux, G4BestUnit a)
std::vector< G4UnitsCategory * > G4UnitsTable
std::vector< G4UnitDefinition * > G4UnitsContainer
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
G4BestUnit(G4double internalValue, const G4String &category)
G4int operator!=(const G4UnitDefinition &) const
static void ClearUnitsTable()
G4UnitDefinition(const G4String &name, const G4String &symbol, const G4String &category, G4double value)
static void BuildUnitsTable()
static G4double GetValueOf(const G4String &)
G4int operator==(const G4UnitDefinition &) const
static G4String GetCategory(const G4String &)
static void PrintUnitsTable()
const G4String & GetName() const
static G4UnitsTable & GetUnitsTable()
G4UnitsCategory(const G4String &name)
G4int operator==(const G4UnitsCategory &) const
G4int operator!=(const G4UnitsCategory &) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)