#include <G4UnitsTable.hh>
Public Member Functions | |
G4UnitDefinition (const G4String &name, const G4String &symbol, const G4String &category, G4double value) | |
~G4UnitDefinition () | |
G4int | operator== (const G4UnitDefinition &) const |
G4int | operator!= (const G4UnitDefinition &) const |
const G4String & | GetName () const |
const G4String & | GetSymbol () const |
G4double | GetValue () const |
void | PrintDefinition () |
Static Public Member Functions | |
static void | BuildUnitsTable () |
static void | PrintUnitsTable () |
static void | ClearUnitsTable () |
static G4UnitsTable & | GetUnitsTable () |
static G4double | GetValueOf (const G4String &) |
static G4String | GetCategory (const G4String &) |
Definition at line 64 of file G4UnitsTable.hh.
G4UnitDefinition::G4UnitDefinition | ( | const G4String & | name, | |
const G4String & | symbol, | |||
const G4String & | category, | |||
G4double | value | |||
) |
Definition at line 59 of file G4UnitsTable.cc.
References GetName().
Referenced by BuildUnitsTable().
00062 : Name(name),SymbolName(symbol),Value(value) 00063 { 00064 // Does the Category objet already exist ? 00065 // 00066 size_t nbCat = theUnitsTable.size(); 00067 size_t i = 0; 00068 while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; } 00069 if (i == nbCat) 00070 { theUnitsTable.push_back( new G4UnitsCategory(category)); } 00071 CategoryIndex = i; 00072 00073 // Insert this Unit in the Units table 00074 // 00075 (theUnitsTable[CategoryIndex]->GetUnitsList()).push_back(this); 00076 00077 // Update string max length for name and symbol 00078 // 00079 theUnitsTable[i]->UpdateNameMxLen((G4int)name.length()); 00080 theUnitsTable[i]->UpdateSymbMxLen((G4int)symbol.length()); 00081 }
G4UnitDefinition::~G4UnitDefinition | ( | ) |
void G4UnitDefinition::BuildUnitsTable | ( | ) | [static] |
Definition at line 189 of file G4UnitsTable.cc.
References G4UnitDefinition(), and pascal.
Referenced by G4GDMLRead::G4GDMLRead(), GetUnitsTable(), and G4DimensionedTypeUtils::GetUnitValue().
00190 { 00191 //Length 00192 new G4UnitDefinition( "parsec","pc" ,"Length",parsec); 00193 new G4UnitDefinition( "kilometer","km" ,"Length",kilometer); 00194 new G4UnitDefinition( "meter","m" ,"Length",meter); 00195 new G4UnitDefinition("centimeter","cm" ,"Length",centimeter); 00196 new G4UnitDefinition("millimeter","mm" ,"Length",millimeter); 00197 new G4UnitDefinition("micrometer","um" ,"Length",micrometer); 00198 new G4UnitDefinition( "nanometer","nm" ,"Length",nanometer); 00199 new G4UnitDefinition( "angstrom","Ang" ,"Length",angstrom); 00200 new G4UnitDefinition( "fermi","fm" ,"Length",fermi); 00201 00202 //Surface 00203 new G4UnitDefinition( "kilometer2","km2" ,"Surface",kilometer2); 00204 new G4UnitDefinition( "meter2","m2" ,"Surface",meter2); 00205 new G4UnitDefinition("centimeter2","cm2" ,"Surface",centimeter2); 00206 new G4UnitDefinition("millimeter2","mm2" ,"Surface",millimeter2); 00207 new G4UnitDefinition( "barn","barn" ,"Surface",barn); 00208 new G4UnitDefinition( "millibarn","mbarn" ,"Surface",millibarn); 00209 new G4UnitDefinition( "microbarn","mubarn" ,"Surface",microbarn); 00210 new G4UnitDefinition( "nanobarn","nbarn" ,"Surface",nanobarn); 00211 new G4UnitDefinition( "picobarn","pbarn" ,"Surface",picobarn); 00212 00213 //Volume 00214 new G4UnitDefinition( "kilometer3","km3" ,"Volume",kilometer3); 00215 new G4UnitDefinition( "meter3","m3" ,"Volume",meter3); 00216 new G4UnitDefinition("centimeter3","cm3" ,"Volume",centimeter3); 00217 new G4UnitDefinition("millimeter3","mm3" ,"Volume",millimeter3); 00218 00219 //Angle 00220 new G4UnitDefinition( "radian","rad" ,"Angle",radian); 00221 new G4UnitDefinition("milliradian","mrad" ,"Angle",milliradian); 00222 new G4UnitDefinition( "degree","deg" ,"Angle",degree); 00223 00224 //Solid angle 00225 new G4UnitDefinition( "steradian","sr" ,"Solid angle",steradian); 00226 new G4UnitDefinition("millisteradian","msr" ,"Solid angle",steradian*0.001); 00227 00228 //Time 00229 new G4UnitDefinition( "second","s" ,"Time",second); 00230 new G4UnitDefinition("millisecond","ms" ,"Time",millisecond); 00231 new G4UnitDefinition("microsecond","mus" ,"Time",microsecond); 00232 new G4UnitDefinition( "nanosecond","ns" ,"Time",nanosecond); 00233 new G4UnitDefinition( "picosecond","ps" ,"Time",picosecond); 00234 00235 //Frequency 00236 new G4UnitDefinition( "hertz","Hz" ,"Frequency",hertz); 00237 new G4UnitDefinition("kilohertz","kHz" ,"Frequency",kilohertz); 00238 new G4UnitDefinition("megahertz","MHz" ,"Frequency",megahertz); 00239 00240 //Electric charge 00241 new G4UnitDefinition( "eplus","e+" ,"Electric charge",eplus); 00242 new G4UnitDefinition("coulomb","C" ,"Electric charge",coulomb); 00243 00244 //Energy 00245 new G4UnitDefinition( "electronvolt","eV" ,"Energy",electronvolt); 00246 new G4UnitDefinition("kiloelectronvolt","keV","Energy",kiloelectronvolt); 00247 new G4UnitDefinition("megaelectronvolt","MeV","Energy",megaelectronvolt); 00248 new G4UnitDefinition("gigaelectronvolt","GeV","Energy",gigaelectronvolt); 00249 new G4UnitDefinition("teraelectronvolt","TeV","Energy",teraelectronvolt); 00250 new G4UnitDefinition("petaelectronvolt","PeV","Energy",petaelectronvolt); 00251 new G4UnitDefinition( "joule","J" ,"Energy",joule); 00252 00253 // Energy/Length 00254 new G4UnitDefinition( "GeV/cm", "GeV/cm","Energy/Length", GeV/cm); 00255 new G4UnitDefinition( "MeV/cm", "MeV/cm","Energy/Length", MeV/cm); 00256 new G4UnitDefinition( "keV/cm", "keV/cm","Energy/Length", keV/cm); 00257 new G4UnitDefinition( "eV/cm", "eV/cm","Energy/Length", eV/cm); 00258 00259 //Mass 00260 new G4UnitDefinition("milligram","mg","Mass",milligram); 00261 new G4UnitDefinition( "gram","g" ,"Mass",gram); 00262 new G4UnitDefinition( "kilogram","kg","Mass",kilogram); 00263 00264 //Volumic Mass 00265 new G4UnitDefinition( "g/cm3", "g/cm3","Volumic Mass", g/cm3); 00266 new G4UnitDefinition("mg/cm3","mg/cm3","Volumic Mass",mg/cm3); 00267 new G4UnitDefinition("kg/m3", "kg/m3", "Volumic Mass",kg/m3); 00268 00269 // Mass/Surface 00270 new G4UnitDefinition( "g/cm2", "g/cm2","Mass/Surface", g/cm2); 00271 new G4UnitDefinition( "mg/cm2", "mg/cm2","Mass/Surface", mg/cm2); 00272 new G4UnitDefinition( "kg/cm2", "kg/cm2","Mass/Surface", kg/cm2); 00273 00274 // Surface/Mass 00275 new G4UnitDefinition( "cm2/g", "cm2/g","Surface/Mass", cm2/g); 00276 00277 // Energy.Surface/Mass 00278 new G4UnitDefinition( "eV*cm2/g", " eV*cm2/g","Energy*Surface/Mass", eV*cm2/g); 00279 new G4UnitDefinition("keV*cm2/g", "keV*cm2/g","Energy*Surface/Mass",keV*cm2/g); 00280 new G4UnitDefinition("MeV*cm2/g", "MeV*cm2/g","Energy*Surface/Mass",MeV*cm2/g); 00281 new G4UnitDefinition("GeV*cm2/g", "GeV*cm2/g","Energy*Surface/Mass",GeV*cm2/g); 00282 00283 //Power 00284 new G4UnitDefinition("watt","W","Power",watt); 00285 00286 //Force 00287 new G4UnitDefinition("newton","N","Force",newton); 00288 00289 //Pressure 00290 new G4UnitDefinition( "pascal","Pa" ,"Pressure",pascal); 00291 new G4UnitDefinition( "bar","bar","Pressure",bar); 00292 new G4UnitDefinition("atmosphere","atm","Pressure",atmosphere); 00293 00294 //Electric current 00295 new G4UnitDefinition( "ampere","A" ,"Electric current",ampere); 00296 new G4UnitDefinition("milliampere","mA" ,"Electric current",milliampere); 00297 new G4UnitDefinition("microampere","muA","Electric current",microampere); 00298 new G4UnitDefinition( "nanoampere","nA" ,"Electric current",nanoampere); 00299 00300 //Electric potential 00301 new G4UnitDefinition( "volt","V" ,"Electric potential",volt); 00302 new G4UnitDefinition("kilovolt","kV","Electric potential",kilovolt); 00303 new G4UnitDefinition("megavolt","MV","Electric potential",megavolt); 00304 00305 //Electric field 00306 new G4UnitDefinition( "volt/m","V/m","Electric field",volt/m); 00307 00308 //Magnetic flux 00309 new G4UnitDefinition("weber","Wb","Magnetic flux",weber); 00310 00311 //Magnetic flux density 00312 new G4UnitDefinition( "tesla","T" ,"Magnetic flux density",tesla); 00313 new G4UnitDefinition("kilogauss","kG","Magnetic flux density",kilogauss); 00314 new G4UnitDefinition( "gauss","G" ,"Magnetic flux density",gauss); 00315 00316 //Temperature 00317 new G4UnitDefinition("kelvin","K","Temperature",kelvin); 00318 00319 //Amount of substance 00320 new G4UnitDefinition("mole","mol","Amount of substance",mole); 00321 00322 //Activity 00323 new G4UnitDefinition("becquerel","Bq","Activity",becquerel); 00324 new G4UnitDefinition( "curie","Ci","Activity",curie); 00325 00326 //Dose 00327 new G4UnitDefinition("gray","Gy","Dose",gray); 00328 }
void G4UnitDefinition::ClearUnitsTable | ( | ) | [static] |
Definition at line 343 of file G4UnitsTable.cc.
Referenced by G4RunManagerKernel::~G4RunManagerKernel().
00344 { 00345 for (size_t i=0;i<theUnitsTable.size();i++) 00346 { 00347 delete theUnitsTable[i]; 00348 } 00349 theUnitsTable.clear(); 00350 }
Definition at line 156 of file G4UnitsTable.cc.
References G4Exception(), GetName(), GetUnitsTable(), and JustWarning.
Referenced by G4UIcommand::CategoryOf(), G4VPrimitiveScorer::CheckAndSetUnit(), and G4AttCheck::Standard().
00157 { 00158 G4String name,symbol; 00159 for (size_t i=0;i<(GetUnitsTable()).size();i++) 00160 { 00161 G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList(); 00162 for (size_t j=0;j<units.size();j++) 00163 { 00164 name=units[j]->GetName(); symbol=units[j]->GetSymbol(); 00165 if(str==name||str==symbol) 00166 { return theUnitsTable[i]->GetName(); } 00167 } 00168 } 00169 std::ostringstream message; 00170 message << "The unit '" << str << "' does not exist in the Units Table."; 00171 G4Exception("G4UnitDefinition::GetCategory()", "InvalidUnit", 00172 JustWarning, message, "Returning Value = 0."); 00173 name = "None"; 00174 return name; 00175 }
const G4String & G4UnitDefinition::GetName | ( | ) | const [inline] |
Definition at line 39 of file G4UnitsTable.icc.
Referenced by G4UnitDefinition(), GetCategory(), GetValueOf(), and G4DimensionedTypeUtils::HasName::operator()().
const G4String & G4UnitDefinition::GetSymbol | ( | ) | const [inline] |
Definition at line 45 of file G4UnitsTable.icc.
Referenced by G4DimensionedTypeUtils::HasName::operator()().
G4UnitsTable & G4UnitDefinition::GetUnitsTable | ( | ) | [static] |
Definition at line 126 of file G4UnitsTable.cc.
References BuildUnitsTable().
Referenced by G4AttCheck::G4AttCheck(), G4BestUnit::G4BestUnit(), GetCategory(), G4DimensionedTypeUtils::GetUnitValue(), GetValueOf(), operator<<(), and G4UIcommand::UnitsList().
00127 { 00128 if(theUnitsTable.size()==0) { BuildUnitsTable(); } 00129 return theUnitsTable; 00130 }
G4double G4UnitDefinition::GetValue | ( | ) | const [inline] |
Definition at line 134 of file G4UnitsTable.cc.
References G4Exception(), GetName(), GetUnitsTable(), and JustWarning.
Referenced by G4VPrimitiveScorer::CheckAndSetUnit(), G4ScoreQuantityMessenger::FParticleWithEnergyCommand(), G4tgrUtils::GetDouble(), G4VAnalysisManager::GetUnitValue(), G4VisCommandsViewerSet::SetNewValue(), G4AdjointSimMessenger::SetNewValue(), G4AttCheck::Standard(), and G4UIcommand::ValueOf().
00135 { 00136 G4String name,symbol; 00137 for (size_t i=0;i<(GetUnitsTable()).size();i++) 00138 { 00139 G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList(); 00140 for (size_t j=0;j<units.size();j++) 00141 { 00142 name=units[j]->GetName(); symbol=units[j]->GetSymbol(); 00143 if(str==name||str==symbol) 00144 { return units[j]->GetValue(); } 00145 } 00146 } 00147 std::ostringstream message; 00148 message << "The unit '" << str << "' does not exist in the Units Table."; 00149 G4Exception("G4UnitDefinition::GetValueOf()", "InvalidUnit", 00150 JustWarning, message, "Returning Value = 0."); 00151 return 0.; 00152 }
G4int G4UnitDefinition::operator!= | ( | const G4UnitDefinition & | ) | const |
Definition at line 119 of file G4UnitsTable.cc.
00120 { 00121 return (this != (G4UnitDefinition *) &right); 00122 }
G4int G4UnitDefinition::operator== | ( | const G4UnitDefinition & | ) | const |
Definition at line 112 of file G4UnitsTable.cc.
00113 { 00114 return (this == (G4UnitDefinition *) &right); 00115 }
void G4UnitDefinition::PrintDefinition | ( | ) |
Definition at line 179 of file G4UnitsTable.cc.
References G4cout, and G4endl.
00180 { 00181 G4int nameL = theUnitsTable[CategoryIndex]->GetNameMxLen(); 00182 G4int symbL = theUnitsTable[CategoryIndex]->GetSymbMxLen(); 00183 G4cout << std::setw(nameL) << Name << " (" 00184 << std::setw(symbL) << SymbolName << ") = " << Value << G4endl; 00185 }
void G4UnitDefinition::PrintUnitsTable | ( | ) | [static] |
Definition at line 332 of file G4UnitsTable.cc.
References G4cout.
Referenced by G4UnitsMessenger::SetNewValue().
00333 { 00334 G4cout << "\n ----- The Table of Units ----- \n"; 00335 for(size_t i=0;i<theUnitsTable.size();i++) 00336 { 00337 theUnitsTable[i]->PrintCategory(); 00338 } 00339 }