Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4UnitsTable class implementation 26 // G4UnitsTable class implementation 27 // 27 // 28 // Author: M.Maire, 17.05.1998 - First version 28 // Author: M.Maire, 17.05.1998 - First version 29 // Revisions: G.Cosmo, 06.03.2001 - Migrated t 29 // Revisions: G.Cosmo, 06.03.2001 - Migrated to STL vectors 30 // ------------------------------------------- 30 // -------------------------------------------------------------------- 31 31 32 #include <iomanip> 32 #include <iomanip> 33 #include <sstream> 33 #include <sstream> 34 34 35 #include "G4SystemOfUnits.hh" 35 #include "G4SystemOfUnits.hh" 36 #include "G4Threading.hh" 36 #include "G4Threading.hh" 37 #include "G4UnitsTable.hh" 37 #include "G4UnitsTable.hh" 38 38 39 G4ThreadLocal G4UnitsTable* G4UnitDefinition:: 39 G4ThreadLocal G4UnitsTable* G4UnitDefinition::pUnitsTable = nullptr; 40 G4ThreadLocal G4bool G4UnitDefinition::unitsTa 40 G4ThreadLocal G4bool G4UnitDefinition::unitsTableDestroyed = false; 41 41 42 #ifdef G4MULTITHREADED 42 #ifdef G4MULTITHREADED 43 G4UnitsTable* G4UnitDefinition::pUnitsTableSha 43 G4UnitsTable* G4UnitDefinition::pUnitsTableShadow = nullptr; 44 44 45 // ------------------------------------------- 45 // -------------------------------------------------------------------- 46 46 47 G4UnitsTable::~G4UnitsTable() 47 G4UnitsTable::~G4UnitsTable() 48 { 48 { 49 for(const auto itr : *this) 49 for(const auto itr : *this) 50 { 50 { 51 delete itr; 51 delete itr; 52 } 52 } 53 clear(); 53 clear(); 54 } 54 } 55 55 56 #endif 56 #endif 57 57 58 // ------------------------------------------- 58 // -------------------------------------------------------------------- 59 59 60 G4UnitDefinition::G4UnitDefinition(const G4Str 60 G4UnitDefinition::G4UnitDefinition(const G4String& name, const G4String& symbol, 61 const G4Str 61 const G4String& category, G4double value) 62 : Name(name) 62 : Name(name) 63 , SymbolName(symbol) 63 , SymbolName(symbol) 64 , Value(value) 64 , Value(value) 65 { 65 { 66 if(pUnitsTable == nullptr) 66 if(pUnitsTable == nullptr) 67 { 67 { 68 if(unitsTableDestroyed) 68 if(unitsTableDestroyed) 69 { 69 { 70 G4Exception("G4UnitDefinition::G4UnitDef 70 G4Exception("G4UnitDefinition::G4UnitDefinition", "UnitsTable0000", 71 FatalException, "G4UnitsTabl 71 FatalException, "G4UnitsTable had already deleted."); 72 } 72 } 73 pUnitsTable = new G4UnitsTable; 73 pUnitsTable = new G4UnitsTable; 74 #ifdef G4MULTITHREADED 74 #ifdef G4MULTITHREADED 75 if(G4Threading::IsMasterThread()) 75 if(G4Threading::IsMasterThread()) 76 { 76 { 77 pUnitsTableShadow = pUnitsTable; 77 pUnitsTableShadow = pUnitsTable; 78 } 78 } 79 #endif 79 #endif 80 } 80 } 81 81 82 // Does the Category objet already exist ? 82 // Does the Category objet already exist ? 83 // 83 // 84 std::size_t nbCat = pUnitsTable->size(); 84 std::size_t nbCat = pUnitsTable->size(); 85 std::size_t i = 0; 85 std::size_t i = 0; 86 while((i < nbCat) && ((*pUnitsTable)[i]->Get 86 while((i < nbCat) && ((*pUnitsTable)[i]->GetName() != category)) 87 { 87 { 88 ++i; 88 ++i; 89 } 89 } 90 if(i == nbCat) 90 if(i == nbCat) 91 { 91 { 92 pUnitsTable->push_back(new G4UnitsCategory 92 pUnitsTable->push_back(new G4UnitsCategory(category)); 93 } 93 } 94 CategoryIndex = i; 94 CategoryIndex = i; 95 95 96 // Insert this Unit in the Units table 96 // Insert this Unit in the Units table 97 // 97 // 98 ((*pUnitsTable)[CategoryIndex]->GetUnitsList 98 ((*pUnitsTable)[CategoryIndex]->GetUnitsList()).push_back(this); 99 99 100 // Update string max length for name and sym 100 // Update string max length for name and symbol 101 // 101 // 102 (*pUnitsTable)[i]->UpdateNameMxLen((G4int) n 102 (*pUnitsTable)[i]->UpdateNameMxLen((G4int) name.length()); 103 (*pUnitsTable)[i]->UpdateSymbMxLen((G4int) s 103 (*pUnitsTable)[i]->UpdateSymbMxLen((G4int) symbol.length()); 104 } 104 } 105 105 106 // ------------------------------------------- 106 // -------------------------------------------------------------------- 107 107 108 G4UnitDefinition::G4UnitDefinition(const G4Uni 108 G4UnitDefinition::G4UnitDefinition(const G4UnitDefinition& right) 109 { 109 { 110 *this = right; 110 *this = right; 111 } 111 } 112 112 113 // ------------------------------------------- 113 // -------------------------------------------------------------------- 114 114 115 G4UnitDefinition& G4UnitDefinition::operator=( 115 G4UnitDefinition& G4UnitDefinition::operator=(const G4UnitDefinition& right) 116 { 116 { 117 if(this != &right) 117 if(this != &right) 118 { 118 { 119 Name = right.Name; 119 Name = right.Name; 120 SymbolName = right.SymbolName; 120 SymbolName = right.SymbolName; 121 Value = right.Value; 121 Value = right.Value; 122 CategoryIndex = right.CategoryIndex; 122 CategoryIndex = right.CategoryIndex; 123 } 123 } 124 return *this; 124 return *this; 125 } 125 } 126 126 127 // ------------------------------------------- 127 // -------------------------------------------------------------------- 128 128 129 G4bool G4UnitDefinition::operator==(const G4Un 129 G4bool G4UnitDefinition::operator==(const G4UnitDefinition& right) const 130 { 130 { 131 return (this == (G4UnitDefinition*) &right); 131 return (this == (G4UnitDefinition*) &right); 132 } 132 } 133 133 134 // ------------------------------------------- 134 // -------------------------------------------------------------------- 135 135 136 G4bool G4UnitDefinition::operator!=(const G4Un 136 G4bool G4UnitDefinition::operator!=(const G4UnitDefinition& right) const 137 { 137 { 138 return (this != (G4UnitDefinition*) &right); 138 return (this != (G4UnitDefinition*) &right); 139 } 139 } 140 140 141 // ------------------------------------------- 141 // -------------------------------------------------------------------- 142 142 143 G4UnitsTable& G4UnitDefinition::GetUnitsTable( 143 G4UnitsTable& G4UnitDefinition::GetUnitsTable() 144 { 144 { 145 if(pUnitsTable == nullptr) 145 if(pUnitsTable == nullptr) 146 { 146 { 147 pUnitsTable = new G4UnitsTable; 147 pUnitsTable = new G4UnitsTable; 148 } 148 } 149 if(pUnitsTable->empty()) 149 if(pUnitsTable->empty()) 150 { 150 { 151 BuildUnitsTable(); 151 BuildUnitsTable(); 152 } 152 } 153 #ifdef G4MULTITHREADED 153 #ifdef G4MULTITHREADED 154 if(G4Threading::IsMasterThread() && pUnitsTa 154 if(G4Threading::IsMasterThread() && pUnitsTableShadow == nullptr) 155 { 155 { 156 pUnitsTableShadow = pUnitsTable; 156 pUnitsTableShadow = pUnitsTable; 157 } 157 } 158 #endif 158 #endif 159 return *pUnitsTable; 159 return *pUnitsTable; 160 } 160 } 161 161 162 // ------------------------------------------- 162 // -------------------------------------------------------------------- 163 163 164 G4bool G4UnitDefinition::IsUnitDefined(const G 164 G4bool G4UnitDefinition::IsUnitDefined(const G4String& str) 165 { 165 { 166 G4String name, symbol; 166 G4String name, symbol; 167 for(std::size_t i = 0; i < (GetUnitsTable()) 167 for(std::size_t i = 0; i < (GetUnitsTable()).size(); ++i) 168 { 168 { 169 G4UnitsContainer& units = (*pUnitsTable)[i 169 G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList(); 170 for(auto& unit : units) 170 for(auto& unit : units) 171 { 171 { 172 name = unit->GetName(); 172 name = unit->GetName(); 173 symbol = unit->GetSymbol(); 173 symbol = unit->GetSymbol(); 174 if(str == name || str == symbol) 174 if(str == name || str == symbol) 175 { 175 { 176 return true; 176 return true; 177 } 177 } 178 } 178 } 179 } 179 } 180 return false; 180 return false; 181 } 181 } 182 182 183 // ------------------------------------------- 183 // -------------------------------------------------------------------- 184 184 185 G4double G4UnitDefinition::GetValueOf(const G4 185 G4double G4UnitDefinition::GetValueOf(const G4String& str) 186 { 186 { 187 G4String name, symbol; 187 G4String name, symbol; 188 for(std::size_t i = 0; i < (GetUnitsTable()) 188 for(std::size_t i = 0; i < (GetUnitsTable()).size(); ++i) 189 { 189 { 190 G4UnitsContainer& units = (*pUnitsTable)[i 190 G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList(); 191 for(auto& unit : units) 191 for(auto& unit : units) 192 { 192 { 193 name = unit->GetName(); 193 name = unit->GetName(); 194 symbol = unit->GetSymbol(); 194 symbol = unit->GetSymbol(); 195 if(str == name || str == symbol) 195 if(str == name || str == symbol) 196 { 196 { 197 return unit->GetValue(); 197 return unit->GetValue(); 198 } 198 } 199 } 199 } 200 } 200 } 201 std::ostringstream message; 201 std::ostringstream message; 202 message << "The unit '" << str << "' does no 202 message << "The unit '" << str << "' does not exist in the Units Table!"; 203 G4Exception("G4UnitDefinition::GetValueOf()" 203 G4Exception("G4UnitDefinition::GetValueOf()", "InvalidUnit", FatalException, 204 message); 204 message); 205 return 0.; 205 return 0.; 206 } 206 } 207 207 208 // ------------------------------------------- 208 // -------------------------------------------------------------------- 209 209 210 G4String G4UnitDefinition::GetCategory(const G 210 G4String G4UnitDefinition::GetCategory(const G4String& str) 211 { 211 { 212 G4String name, symbol; 212 G4String name, symbol; 213 for(std::size_t i = 0; i < (GetUnitsTable()) 213 for(std::size_t i = 0; i < (GetUnitsTable()).size(); ++i) 214 { 214 { 215 G4UnitsContainer& units = (*pUnitsTable)[i 215 G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList(); 216 for(auto& unit : units) 216 for(auto& unit : units) 217 { 217 { 218 name = unit->GetName(); 218 name = unit->GetName(); 219 symbol = unit->GetSymbol(); 219 symbol = unit->GetSymbol(); 220 if(str == name || str == symbol) 220 if(str == name || str == symbol) 221 { 221 { 222 return (*pUnitsTable)[i]->GetName(); 222 return (*pUnitsTable)[i]->GetName(); 223 } 223 } 224 } 224 } 225 } 225 } 226 std::ostringstream message; 226 std::ostringstream message; 227 message << "The unit '" << str << "' does no 227 message << "The unit '" << str << "' does not exist in the Units Table!"; 228 G4Exception("G4UnitDefinition::GetCategory() 228 G4Exception("G4UnitDefinition::GetCategory()", "InvalidUnit", FatalException, 229 message); 229 message); 230 name = "None"; 230 name = "None"; 231 return name; 231 return name; 232 } 232 } 233 233 234 // ------------------------------------------- 234 // -------------------------------------------------------------------- 235 235 236 void G4UnitDefinition::PrintDefinition() 236 void G4UnitDefinition::PrintDefinition() 237 { 237 { 238 G4int nameL = (*pUnitsTable)[CategoryIndex]- 238 G4int nameL = (*pUnitsTable)[CategoryIndex]->GetNameMxLen(); 239 G4int symbL = (*pUnitsTable)[CategoryIndex]- 239 G4int symbL = (*pUnitsTable)[CategoryIndex]->GetSymbMxLen(); 240 G4cout << std::setw(nameL) << Name << " (" < 240 G4cout << std::setw(nameL) << Name << " (" << std::setw(symbL) << SymbolName 241 << ") = " << Value << G4endl; 241 << ") = " << Value << G4endl; 242 } 242 } 243 243 244 // ------------------------------------------- 244 // -------------------------------------------------------------------- 245 245 246 void G4UnitDefinition::BuildUnitsTable() 246 void G4UnitDefinition::BuildUnitsTable() 247 { 247 { 248 // Length 248 // Length 249 new G4UnitDefinition("parsec", "pc", "Length 249 new G4UnitDefinition("parsec", "pc", "Length", parsec); 250 new G4UnitDefinition("kilometer", "km", "Len 250 new G4UnitDefinition("kilometer", "km", "Length", kilometer); 251 new G4UnitDefinition("meter", "m", "Length", 251 new G4UnitDefinition("meter", "m", "Length", meter); 252 new G4UnitDefinition("centimeter", "cm", "Le 252 new G4UnitDefinition("centimeter", "cm", "Length", centimeter); 253 new G4UnitDefinition("millimeter", "mm", "Le 253 new G4UnitDefinition("millimeter", "mm", "Length", millimeter); 254 new G4UnitDefinition("micrometer", "um", "Le 254 new G4UnitDefinition("micrometer", "um", "Length", micrometer); 255 new G4UnitDefinition("nanometer", "nm", "Len 255 new G4UnitDefinition("nanometer", "nm", "Length", nanometer); 256 new G4UnitDefinition("angstrom", "Ang", "Len 256 new G4UnitDefinition("angstrom", "Ang", "Length", angstrom); 257 new G4UnitDefinition("fermi", "fm", "Length" 257 new G4UnitDefinition("fermi", "fm", "Length", fermi); 258 258 259 // Surface 259 // Surface 260 new G4UnitDefinition("kilometer2", "km2", "S 260 new G4UnitDefinition("kilometer2", "km2", "Surface", kilometer2); 261 new G4UnitDefinition("meter2", "m2", "Surfac 261 new G4UnitDefinition("meter2", "m2", "Surface", meter2); 262 new G4UnitDefinition("centimeter2", "cm2", " 262 new G4UnitDefinition("centimeter2", "cm2", "Surface", centimeter2); 263 new G4UnitDefinition("millimeter2", "mm2", " 263 new G4UnitDefinition("millimeter2", "mm2", "Surface", millimeter2); 264 new G4UnitDefinition("barn", "barn", "Surfac 264 new G4UnitDefinition("barn", "barn", "Surface", barn); 265 new G4UnitDefinition("millibarn", "mbarn", " 265 new G4UnitDefinition("millibarn", "mbarn", "Surface", millibarn); 266 new G4UnitDefinition("microbarn", "mubarn", 266 new G4UnitDefinition("microbarn", "mubarn", "Surface", microbarn); 267 new G4UnitDefinition("nanobarn", "nbarn", "S 267 new G4UnitDefinition("nanobarn", "nbarn", "Surface", nanobarn); 268 new G4UnitDefinition("picobarn", "pbarn", "S 268 new G4UnitDefinition("picobarn", "pbarn", "Surface", picobarn); 269 269 270 // Volume 270 // Volume 271 new G4UnitDefinition("kilometer3", "km3", "V 271 new G4UnitDefinition("kilometer3", "km3", "Volume", kilometer3); 272 new G4UnitDefinition("meter3", "m3", "Volume 272 new G4UnitDefinition("meter3", "m3", "Volume", meter3); 273 new G4UnitDefinition("centimeter3", "cm3", " 273 new G4UnitDefinition("centimeter3", "cm3", "Volume", centimeter3); 274 new G4UnitDefinition("millimeter3", "mm3", " 274 new G4UnitDefinition("millimeter3", "mm3", "Volume", millimeter3); 275 275 276 new G4UnitDefinition("liter", "L", "Volume", 276 new G4UnitDefinition("liter", "L", "Volume", liter); 277 new G4UnitDefinition("dL", "dL", "Volume", d 277 new G4UnitDefinition("dL", "dL", "Volume", dL); 278 new G4UnitDefinition("cL", "cL", "Volume", c 278 new G4UnitDefinition("cL", "cL", "Volume", cL); 279 new G4UnitDefinition("mL", "mL", "Volume", m 279 new G4UnitDefinition("mL", "mL", "Volume", mL); 280 280 281 // Angle 281 // Angle 282 new G4UnitDefinition("radian", "rad", "Angle 282 new G4UnitDefinition("radian", "rad", "Angle", radian); 283 new G4UnitDefinition("milliradian", "mrad", 283 new G4UnitDefinition("milliradian", "mrad", "Angle", milliradian); 284 new G4UnitDefinition("degree", "deg", "Angle 284 new G4UnitDefinition("degree", "deg", "Angle", degree); 285 285 286 // Solid angle 286 // Solid angle 287 new G4UnitDefinition("steradian", "sr", "Sol 287 new G4UnitDefinition("steradian", "sr", "Solid angle", steradian); 288 new G4UnitDefinition("millisteradian", "msr" 288 new G4UnitDefinition("millisteradian", "msr", "Solid angle", 289 steradian * 0.001); 289 steradian * 0.001); 290 290 291 // Time 291 // Time 292 new G4UnitDefinition("second", "s", "Time", 292 new G4UnitDefinition("second", "s", "Time", second); 293 new G4UnitDefinition("millisecond", "ms", "T 293 new G4UnitDefinition("millisecond", "ms", "Time", millisecond); 294 new G4UnitDefinition("microsecond", "us", "T 294 new G4UnitDefinition("microsecond", "us", "Time", microsecond); 295 new G4UnitDefinition("nanosecond", "ns", "Ti 295 new G4UnitDefinition("nanosecond", "ns", "Time", nanosecond); 296 new G4UnitDefinition("picosecond", "ps", "Ti 296 new G4UnitDefinition("picosecond", "ps", "Time", picosecond); 297 new G4UnitDefinition("minute", "min", "Time" 297 new G4UnitDefinition("minute", "min", "Time", minute); 298 new G4UnitDefinition("hour", "h", "Time" 298 new G4UnitDefinition("hour", "h", "Time", hour); 299 new G4UnitDefinition("day", "d", "Time" 299 new G4UnitDefinition("day", "d", "Time", day); 300 new G4UnitDefinition("year", "y", "Time" 300 new G4UnitDefinition("year", "y", "Time", year); 301 301 302 // Frequency 302 // Frequency 303 new G4UnitDefinition("hertz", "Hz", "Frequen 303 new G4UnitDefinition("hertz", "Hz", "Frequency", hertz); 304 new G4UnitDefinition("kilohertz", "kHz", "Fr 304 new G4UnitDefinition("kilohertz", "kHz", "Frequency", kilohertz); 305 new G4UnitDefinition("megahertz", "MHz", "Fr 305 new G4UnitDefinition("megahertz", "MHz", "Frequency", megahertz); 306 306 307 // Velocity 307 // Velocity 308 new G4UnitDefinition("cm/ns", "cm/ns", "Velo 308 new G4UnitDefinition("cm/ns", "cm/ns", "Velocity", cm/ns); 309 new G4UnitDefinition("mm/ns", "mm/ns", "Velo 309 new G4UnitDefinition("mm/ns", "mm/ns", "Velocity", mm/ns); 310 new G4UnitDefinition("cm/us", "cm/us", "Velo 310 new G4UnitDefinition("cm/us", "cm/us", "Velocity", cm/us); 311 new G4UnitDefinition("km/s" , "km/s" , "Velo 311 new G4UnitDefinition("km/s" , "km/s" , "Velocity", km/s); 312 new G4UnitDefinition("cm/ms", "cm/ms", "Velo 312 new G4UnitDefinition("cm/ms", "cm/ms", "Velocity", cm/ms); 313 new G4UnitDefinition( "m/s" , "m/s" , "Velo 313 new G4UnitDefinition( "m/s" , "m/s" , "Velocity", m/s); 314 new G4UnitDefinition("cm/s" , "cm/s" , "Velo 314 new G4UnitDefinition("cm/s" , "cm/s" , "Velocity", cm/s); 315 new G4UnitDefinition("mm/s" , "mm/s" , "Velo 315 new G4UnitDefinition("mm/s" , "mm/s" , "Velocity", mm/s); 316 316 317 // Electric charge 317 // Electric charge 318 new G4UnitDefinition("eplus", "e+", "Electri 318 new G4UnitDefinition("eplus", "e+", "Electric charge", eplus); 319 new G4UnitDefinition("coulomb", "C", "Electr 319 new G4UnitDefinition("coulomb", "C", "Electric charge", coulomb); 320 320 321 // Energy 321 // Energy 322 new G4UnitDefinition("electronvolt", "eV", " 322 new G4UnitDefinition("electronvolt", "eV", "Energy", electronvolt); 323 new G4UnitDefinition("kiloelectronvolt", "ke 323 new G4UnitDefinition("kiloelectronvolt", "keV", "Energy", kiloelectronvolt); 324 new G4UnitDefinition("megaelectronvolt", "Me 324 new G4UnitDefinition("megaelectronvolt", "MeV", "Energy", megaelectronvolt); 325 new G4UnitDefinition("gigaelectronvolt", "Ge 325 new G4UnitDefinition("gigaelectronvolt", "GeV", "Energy", gigaelectronvolt); 326 new G4UnitDefinition("teraelectronvolt", "Te 326 new G4UnitDefinition("teraelectronvolt", "TeV", "Energy", teraelectronvolt); 327 new G4UnitDefinition("petaelectronvolt", "Pe 327 new G4UnitDefinition("petaelectronvolt", "PeV", "Energy", petaelectronvolt); 328 new G4UnitDefinition("millielectronVolt", "m 328 new G4UnitDefinition("millielectronVolt", "meV", "Energy", millielectronvolt); 329 new G4UnitDefinition("joule", "J", "Energy", 329 new G4UnitDefinition("joule", "J", "Energy", joule); 330 330 331 //Momentum 331 //Momentum 332 new G4UnitDefinition( "eV/c", "eV/c", "Mome 332 new G4UnitDefinition( "eV/c", "eV/c", "Momentum", eV); 333 new G4UnitDefinition("keV/c", "keV/c", "Mome 333 new G4UnitDefinition("keV/c", "keV/c", "Momentum", keV); 334 new G4UnitDefinition("MeV/c", "MeV/c", "Mome 334 new G4UnitDefinition("MeV/c", "MeV/c", "Momentum", MeV); 335 new G4UnitDefinition("GeV/c", "GeV/c", "Mome 335 new G4UnitDefinition("GeV/c", "GeV/c", "Momentum", GeV); 336 new G4UnitDefinition("TeV/c", "TeV/c", "Mome 336 new G4UnitDefinition("TeV/c", "TeV/c", "Momentum", TeV); 337 337 338 // Energy/Length 338 // Energy/Length 339 new G4UnitDefinition("GeV/cm", "GeV/cm", "En 339 new G4UnitDefinition("GeV/cm", "GeV/cm", "Energy/Length", GeV / cm); 340 new G4UnitDefinition("MeV/cm", "MeV/cm", "En 340 new G4UnitDefinition("MeV/cm", "MeV/cm", "Energy/Length", MeV / cm); 341 new G4UnitDefinition("keV/cm", "keV/cm", "En 341 new G4UnitDefinition("keV/cm", "keV/cm", "Energy/Length", keV / cm); 342 new G4UnitDefinition("eV/cm", "eV/cm", "Ener 342 new G4UnitDefinition("eV/cm", "eV/cm", "Energy/Length", eV / cm); 343 343 344 // Mass 344 // Mass 345 new G4UnitDefinition("milligram", "mg", "Mas 345 new G4UnitDefinition("milligram", "mg", "Mass", milligram); 346 new G4UnitDefinition("gram", "g", "Mass", gr 346 new G4UnitDefinition("gram", "g", "Mass", gram); 347 new G4UnitDefinition("kilogram", "kg", "Mass 347 new G4UnitDefinition("kilogram", "kg", "Mass", kilogram); 348 348 349 // Volumic Mass 349 // Volumic Mass 350 new G4UnitDefinition("g/cm3", "g/cm3", "Volu 350 new G4UnitDefinition("g/cm3", "g/cm3", "Volumic Mass", g / cm3); 351 new G4UnitDefinition("mg/cm3", "mg/cm3", "Vo 351 new G4UnitDefinition("mg/cm3", "mg/cm3", "Volumic Mass", mg / cm3); 352 new G4UnitDefinition("kg/m3", "kg/m3", "Volu 352 new G4UnitDefinition("kg/m3", "kg/m3", "Volumic Mass", kg / m3); 353 353 354 // Mass/Surface 354 // Mass/Surface 355 new G4UnitDefinition("g/cm2", "g/cm2", "Mass 355 new G4UnitDefinition("g/cm2", "g/cm2", "Mass/Surface", g / cm2); 356 new G4UnitDefinition("mg/cm2", "mg/cm2", "Ma 356 new G4UnitDefinition("mg/cm2", "mg/cm2", "Mass/Surface", mg / cm2); 357 new G4UnitDefinition("kg/cm2", "kg/cm2", "Ma 357 new G4UnitDefinition("kg/cm2", "kg/cm2", "Mass/Surface", kg / cm2); 358 358 359 // Surface/Mass 359 // Surface/Mass 360 new G4UnitDefinition("cm2/g", "cm2/g", "Surf 360 new G4UnitDefinition("cm2/g", "cm2/g", "Surface/Mass", cm2 / g); 361 361 362 // Energy.Surface/Mass 362 // Energy.Surface/Mass 363 new G4UnitDefinition("eV*cm2/g", " eV*cm2/g" 363 new G4UnitDefinition("eV*cm2/g", " eV*cm2/g", "Energy*Surface/Mass", 364 eV * cm2 / g); 364 eV * cm2 / g); 365 new G4UnitDefinition("keV*cm2/g", "keV*cm2/g 365 new G4UnitDefinition("keV*cm2/g", "keV*cm2/g", "Energy*Surface/Mass", 366 keV * cm2 / g); 366 keV * cm2 / g); 367 new G4UnitDefinition("MeV*cm2/g", "MeV*cm2/g 367 new G4UnitDefinition("MeV*cm2/g", "MeV*cm2/g", "Energy*Surface/Mass", 368 MeV * cm2 / g); 368 MeV * cm2 / g); 369 new G4UnitDefinition("GeV*cm2/g", "GeV*cm2/g 369 new G4UnitDefinition("GeV*cm2/g", "GeV*cm2/g", "Energy*Surface/Mass", 370 GeV * cm2 / g); 370 GeV * cm2 / g); 371 371 372 // Power 372 // Power 373 new G4UnitDefinition("watt", "W", "Power", w 373 new G4UnitDefinition("watt", "W", "Power", watt); 374 374 375 // Force 375 // Force 376 new G4UnitDefinition("newton", "N", "Force", 376 new G4UnitDefinition("newton", "N", "Force", newton); 377 377 378 // Pressure 378 // Pressure 379 new G4UnitDefinition("pascal", "Pa", "Pressu 379 new G4UnitDefinition("pascal", "Pa", "Pressure", hep_pascal); 380 new G4UnitDefinition("bar", "bar", "Pressure 380 new G4UnitDefinition("bar", "bar", "Pressure", bar); 381 new G4UnitDefinition("atmosphere", "atm", "P 381 new G4UnitDefinition("atmosphere", "atm", "Pressure", atmosphere); 382 382 383 // Electric current 383 // Electric current 384 new G4UnitDefinition("ampere", "A", "Electri 384 new G4UnitDefinition("ampere", "A", "Electric current", ampere); 385 new G4UnitDefinition("milliampere", "mA", "E 385 new G4UnitDefinition("milliampere", "mA", "Electric current", milliampere); 386 new G4UnitDefinition("microampere", "muA", " 386 new G4UnitDefinition("microampere", "muA", "Electric current", microampere); 387 new G4UnitDefinition("nanoampere", "nA", "El 387 new G4UnitDefinition("nanoampere", "nA", "Electric current", nanoampere); 388 388 389 // Electric potential 389 // Electric potential 390 new G4UnitDefinition("volt", "V", "Electric 390 new G4UnitDefinition("volt", "V", "Electric potential", volt); 391 new G4UnitDefinition("kilovolt", "kV", "Elec 391 new G4UnitDefinition("kilovolt", "kV", "Electric potential", kilovolt); 392 new G4UnitDefinition("megavolt", "MV", "Elec 392 new G4UnitDefinition("megavolt", "MV", "Electric potential", megavolt); 393 393 394 // Electric field 394 // Electric field 395 new G4UnitDefinition("volt/m", "V/m", "Elect 395 new G4UnitDefinition("volt/m", "V/m", "Electric field", volt / m); 396 new G4UnitDefinition("kilovolt/m", "kV/m", " 396 new G4UnitDefinition("kilovolt/m", "kV/m", "Electric field", kilovolt / m); 397 new G4UnitDefinition("megavolt/m", "MV/m", " 397 new G4UnitDefinition("megavolt/m", "MV/m", "Electric field", megavolt / m); 398 398 399 // Magnetic flux 399 // Magnetic flux 400 new G4UnitDefinition("weber", "Wb", "Magneti 400 new G4UnitDefinition("weber", "Wb", "Magnetic flux", weber); 401 401 402 // Magnetic flux density 402 // Magnetic flux density 403 new G4UnitDefinition("tesla", "T", "Magnetic 403 new G4UnitDefinition("tesla", "T", "Magnetic flux density", tesla); 404 new G4UnitDefinition("kilogauss", "kG", "Mag 404 new G4UnitDefinition("kilogauss", "kG", "Magnetic flux density", kilogauss); 405 new G4UnitDefinition("gauss", "G", "Magnetic 405 new G4UnitDefinition("gauss", "G", "Magnetic flux density", gauss); 406 406 407 // Temperature 407 // Temperature 408 new G4UnitDefinition("kelvin", "K", "Tempera 408 new G4UnitDefinition("kelvin", "K", "Temperature", kelvin); 409 409 410 // Amount of substance 410 // Amount of substance 411 new G4UnitDefinition("mole", "mol", "Amount 411 new G4UnitDefinition("mole", "mol", "Amount of substance", mole); 412 new G4UnitDefinition("g/mole", "g/mol", "Mol 412 new G4UnitDefinition("g/mole", "g/mol", "Molar mass", g / mole); 413 413 414 // Activity 414 // Activity 415 new G4UnitDefinition("becquerel", "Bq", "Act 415 new G4UnitDefinition("becquerel", "Bq", "Activity", becquerel); 416 new G4UnitDefinition("curie", "Ci", "Activit 416 new G4UnitDefinition("curie", "Ci", "Activity", curie); 417 417 418 // Dose 418 // Dose 419 new G4UnitDefinition("gray", "Gy", "Dose", g 419 new G4UnitDefinition("gray", "Gy", "Dose", gray); 420 } 420 } 421 421 422 // ------------------------------------------- 422 // -------------------------------------------------------------------- 423 423 424 void G4UnitDefinition::PrintUnitsTable() 424 void G4UnitDefinition::PrintUnitsTable() 425 { 425 { 426 G4cout << "\n ----- The Table of Un 426 G4cout << "\n ----- The Table of Units ----- \n"; 427 if(pUnitsTable == nullptr) 427 if(pUnitsTable == nullptr) 428 { 428 { 429 pUnitsTable = new G4UnitsTable; 429 pUnitsTable = new G4UnitsTable; 430 } 430 } 431 for(std::size_t i = 0; i < pUnitsTable->size 431 for(std::size_t i = 0; i < pUnitsTable->size(); ++i) 432 { 432 { 433 (*pUnitsTable)[i]->PrintCategory(); 433 (*pUnitsTable)[i]->PrintCategory(); 434 } 434 } 435 } 435 } 436 436 437 // ------------------------------------------- 437 // -------------------------------------------------------------------- 438 438 439 void G4UnitDefinition::ClearUnitsTable() 439 void G4UnitDefinition::ClearUnitsTable() 440 { 440 { 441 #ifdef G4MULTITHREADED 441 #ifdef G4MULTITHREADED 442 delete pUnitsTable; 442 delete pUnitsTable; 443 pUnitsTable = nullptr; 443 pUnitsTable = nullptr; 444 if(G4Threading::IsMasterThread()) 444 if(G4Threading::IsMasterThread()) 445 { 445 { 446 pUnitsTableShadow = nullptr; 446 pUnitsTableShadow = nullptr; 447 } 447 } 448 #else 448 #else 449 for(std::size_t i = 0; i < pUnitsTable->size 449 for(std::size_t i = 0; i < pUnitsTable->size(); ++i) 450 { 450 { 451 delete(*pUnitsTable)[i]; 451 delete(*pUnitsTable)[i]; 452 } 452 } 453 pUnitsTable->clear(); 453 pUnitsTable->clear(); 454 #endif 454 #endif 455 unitsTableDestroyed = true; 455 unitsTableDestroyed = true; 456 } 456 } 457 457 458 // ------------------------------------------- 458 // -------------------------------------------------------------------- 459 459 460 G4UnitsCategory::G4UnitsCategory(const G4Strin 460 G4UnitsCategory::G4UnitsCategory(const G4String& name) 461 : Name(name) 461 : Name(name) 462 {} 462 {} 463 463 464 // ------------------------------------------- 464 // -------------------------------------------------------------------- 465 465 466 G4UnitsCategory::~G4UnitsCategory() 466 G4UnitsCategory::~G4UnitsCategory() 467 { 467 { 468 for(auto& i : UnitsList) 468 for(auto& i : UnitsList) 469 { 469 { 470 delete i; 470 delete i; 471 } 471 } 472 UnitsList.clear(); 472 UnitsList.clear(); 473 } 473 } 474 474 475 // ------------------------------------------- 475 // -------------------------------------------------------------------- 476 476 477 G4UnitsCategory::G4UnitsCategory(const G4Units 477 G4UnitsCategory::G4UnitsCategory(const G4UnitsCategory& right) 478 { 478 { 479 *this = right; 479 *this = right; 480 } 480 } 481 481 482 // ------------------------------------------- 482 // -------------------------------------------------------------------- 483 483 484 G4UnitsCategory& G4UnitsCategory::operator=(co 484 G4UnitsCategory& G4UnitsCategory::operator=(const G4UnitsCategory& right) 485 { 485 { 486 if(this != &right) 486 if(this != &right) 487 { 487 { 488 Name = right.Name; 488 Name = right.Name; 489 UnitsList = right.UnitsList; 489 UnitsList = right.UnitsList; 490 NameMxLen = right.NameMxLen; 490 NameMxLen = right.NameMxLen; 491 SymbMxLen = right.SymbMxLen; 491 SymbMxLen = right.SymbMxLen; 492 } 492 } 493 return *this; 493 return *this; 494 } 494 } 495 495 496 // ------------------------------------------- 496 // -------------------------------------------------------------------- 497 497 498 G4bool G4UnitsCategory::operator==(const G4Uni 498 G4bool G4UnitsCategory::operator==(const G4UnitsCategory& right) const 499 { 499 { 500 return (this == (G4UnitsCategory*) &right); 500 return (this == (G4UnitsCategory*) &right); 501 } 501 } 502 502 503 // ------------------------------------------- 503 // -------------------------------------------------------------------- 504 504 505 G4bool G4UnitsCategory::operator!=(const G4Uni 505 G4bool G4UnitsCategory::operator!=(const G4UnitsCategory& right) const 506 { 506 { 507 return (this != (G4UnitsCategory*) &right); 507 return (this != (G4UnitsCategory*) &right); 508 } 508 } 509 509 510 // ------------------------------------------- 510 // -------------------------------------------------------------------- 511 511 512 void G4UnitsCategory::PrintCategory() 512 void G4UnitsCategory::PrintCategory() 513 { 513 { 514 G4cout << "\n category: " << Name << G4endl 514 G4cout << "\n category: " << Name << G4endl; 515 for(auto& i : UnitsList) 515 for(auto& i : UnitsList) 516 { 516 { 517 i->PrintDefinition(); 517 i->PrintDefinition(); 518 } 518 } 519 } 519 } 520 520 521 // ------------------------------------------- 521 // -------------------------------------------------------------------- 522 522 523 G4BestUnit::G4BestUnit(G4double value, const G 523 G4BestUnit::G4BestUnit(G4double value, const G4String& category) 524 : nbOfVals(1) 524 : nbOfVals(1) 525 { 525 { 526 // find the category 526 // find the category 527 G4UnitsTable& theUnitsTable = G4UnitDefiniti 527 G4UnitsTable& theUnitsTable = G4UnitDefinition::GetUnitsTable(); 528 std::size_t nbCat = theUnitsTable. 528 std::size_t nbCat = theUnitsTable.size(); 529 std::size_t i = 0; 529 std::size_t i = 0; 530 while((i < nbCat) && (theUnitsTable[i]->GetN 530 while((i < nbCat) && (theUnitsTable[i]->GetName() != category)) 531 { 531 { 532 ++i; 532 ++i; 533 } 533 } 534 if(i == nbCat) 534 if(i == nbCat) 535 { 535 { 536 G4cout << " G4BestUnit: the category " << 536 G4cout << " G4BestUnit: the category " << category << " does not exist !!" 537 << G4endl; 537 << G4endl; 538 G4Exception("G4BestUnit::G4BestUnit()", "I 538 G4Exception("G4BestUnit::G4BestUnit()", "InvalidCall", FatalException, 539 "Missing unit category !"); 539 "Missing unit category !"); 540 } 540 } 541 541 542 Value[0] = value; 542 Value[0] = value; 543 Value[1] = 0.; 543 Value[1] = 0.; 544 Value[2] = 0.; 544 Value[2] = 0.; 545 Category = category; 545 Category = category; 546 IndexOfCategory = i; 546 IndexOfCategory = i; 547 } 547 } 548 548 549 // ------------------------------------------- 549 // -------------------------------------------------------------------- 550 550 551 G4BestUnit::G4BestUnit(const G4ThreeVector& va 551 G4BestUnit::G4BestUnit(const G4ThreeVector& value, const G4String& category) 552 : nbOfVals(3) 552 : nbOfVals(3) 553 { 553 { 554 // find the category 554 // find the category 555 G4UnitsTable& theUnitsTable = G4UnitDefiniti 555 G4UnitsTable& theUnitsTable = G4UnitDefinition::GetUnitsTable(); 556 std::size_t nbCat = theUnitsTable. 556 std::size_t nbCat = theUnitsTable.size(); 557 std::size_t i = 0; 557 std::size_t i = 0; 558 while((i < nbCat) && (theUnitsTable[i]->GetN 558 while((i < nbCat) && (theUnitsTable[i]->GetName() != category)) 559 { 559 { 560 ++i; 560 ++i; 561 } 561 } 562 if(i == nbCat) 562 if(i == nbCat) 563 { 563 { 564 G4cerr << " G4BestUnit: the category " << 564 G4cerr << " G4BestUnit: the category " << category << " does not exist." 565 << G4endl; 565 << G4endl; 566 G4Exception("G4BestUnit::G4BestUnit()", "I 566 G4Exception("G4BestUnit::G4BestUnit()", "InvalidCall", FatalException, 567 "Missing unit category !"); 567 "Missing unit category !"); 568 } 568 } 569 569 570 Value[0] = value.x(); 570 Value[0] = value.x(); 571 Value[1] = value.y(); 571 Value[1] = value.y(); 572 Value[2] = value.z(); 572 Value[2] = value.z(); 573 Category = category; 573 Category = category; 574 IndexOfCategory = i; 574 IndexOfCategory = i; 575 } 575 } 576 576 577 // ------------------------------------------- 577 // -------------------------------------------------------------------- 578 578 579 G4BestUnit::operator G4String() const 579 G4BestUnit::operator G4String() const 580 { 580 { 581 std::ostringstream oss; 581 std::ostringstream oss; 582 oss << *this; 582 oss << *this; 583 return oss.str(); 583 return oss.str(); 584 } 584 } 585 585 586 // ------------------------------------------- 586 // -------------------------------------------------------------------- 587 587 588 std::ostream& operator<<(std::ostream& flux, c 588 std::ostream& operator<<(std::ostream& flux, const G4BestUnit& a) 589 { 589 { 590 G4UnitsTable& theUnitsTable = G4UnitDefiniti 590 G4UnitsTable& theUnitsTable = G4UnitDefinition::GetUnitsTable(); 591 G4UnitsContainer& List = theUnitsTable[a.Ind 591 G4UnitsContainer& List = theUnitsTable[a.IndexOfCategory]->GetUnitsList(); 592 G4int len = theUnitsTable[a.Ind 592 G4int len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen(); 593 593 594 G4long ksup(-1), kinf(-1); 594 G4long ksup(-1), kinf(-1); 595 G4double umax(0.), umin(DBL_MAX); 595 G4double umax(0.), umin(DBL_MAX); 596 G4double rsup(DBL_MAX), rinf(0.); 596 G4double rsup(DBL_MAX), rinf(0.); 597 597 598 // for a ThreeVector, choose the best unit f 598 // for a ThreeVector, choose the best unit for the biggest value 599 G4double value = 599 G4double value = 600 std::max(std::max(std::fabs(a.Value[0]), s 600 std::max(std::max(std::fabs(a.Value[0]), std::fabs(a.Value[1])), 601 std::fabs(a.Value[2])); 601 std::fabs(a.Value[2])); 602 602 603 //special treatement for Energy. 603 //special treatement for Energy. 604 if ((a.Category == "Energy") && (value == 0. 604 if ((a.Category == "Energy") && (value == 0.)) { 605 for (G4int j = 0; j < a.nbOfVals; ++j) { 605 for (G4int j = 0; j < a.nbOfVals; ++j) { 606 flux << a.Value[j] << " "; 606 flux << a.Value[j] << " "; 607 } 607 } 608 std::ios::fmtflags oldform = flux.flags(); 608 std::ios::fmtflags oldform = flux.flags(); 609 flux.setf(std::ios::left, std::ios::adjust 609 flux.setf(std::ios::left, std::ios::adjustfield); 610 flux << std::setw(len) << "eV"; 610 flux << std::setw(len) << "eV"; 611 flux.flags(oldform); 611 flux.flags(oldform); 612 return flux; 612 return flux; 613 } 613 } 614 614 615 //here, value != 0. 615 //here, value != 0. 616 for(std::size_t k = 0; k < List.size(); ++k) 616 for(std::size_t k = 0; k < List.size(); ++k) 617 { 617 { 618 G4double unit = List[k]->GetValue(); 618 G4double unit = List[k]->GetValue(); 619 if(!(value != DBL_MAX)) 619 if(!(value != DBL_MAX)) 620 { 620 { 621 if(unit > umax) 621 if(unit > umax) 622 { 622 { 623 umax = unit; 623 umax = unit; 624 ksup = k; 624 ksup = k; 625 } 625 } 626 } 626 } 627 else if(value <= DBL_MIN) 627 else if(value <= DBL_MIN) 628 { 628 { 629 if(unit < umin) 629 if(unit < umin) 630 { 630 { 631 umin = unit; 631 umin = unit; 632 kinf = k; 632 kinf = k; 633 } 633 } 634 } 634 } 635 else 635 else 636 { 636 { 637 G4double ratio = value / unit; 637 G4double ratio = value / unit; 638 if((ratio >= 1.) && (ratio < rsup)) 638 if((ratio >= 1.) && (ratio < rsup)) 639 { 639 { 640 rsup = ratio; 640 rsup = ratio; 641 ksup = k; 641 ksup = k; 642 } 642 } 643 if((ratio < 1.) && (ratio > rinf)) 643 if((ratio < 1.) && (ratio > rinf)) 644 { 644 { 645 rinf = ratio; 645 rinf = ratio; 646 kinf = k; 646 kinf = k; 647 } 647 } 648 } 648 } 649 } 649 } 650 650 651 G4long index = ksup; 651 G4long index = ksup; 652 if(index == -1) 652 if(index == -1) 653 { 653 { 654 index = kinf; 654 index = kinf; 655 } 655 } 656 if(index == -1) 656 if(index == -1) 657 { 657 { 658 index = 0; 658 index = 0; 659 } 659 } 660 660 661 for(G4int j = 0; j < a.nbOfVals; ++j) 661 for(G4int j = 0; j < a.nbOfVals; ++j) 662 { 662 { 663 flux << a.Value[j] / (List[index]->GetValu 663 flux << a.Value[j] / (List[index]->GetValue()) << " "; 664 } 664 } 665 665 666 std::ios::fmtflags oldform = flux.flags(); 666 std::ios::fmtflags oldform = flux.flags(); 667 667 668 flux.setf(std::ios::left, std::ios::adjustfi 668 flux.setf(std::ios::left, std::ios::adjustfield); 669 flux << std::setw(len) << List[index]->GetSy 669 flux << std::setw(len) << List[index]->GetSymbol(); 670 flux.flags(oldform); 670 flux.flags(oldform); 671 671 672 return flux; 672 return flux; 673 } 673 } 674 674 675 // ------------------------------------------- 675 // -------------------------------------------------------------------- 676 676 677 #ifdef G4MULTITHREADED 677 #ifdef G4MULTITHREADED 678 678 679 void G4UnitsTable::Synchronize() 679 void G4UnitsTable::Synchronize() 680 { 680 { 681 G4UnitsTable* orig = &(G4UnitDefinition::Get 681 G4UnitsTable* orig = &(G4UnitDefinition::GetUnitsTableShadow()); 682 if(this == orig) 682 if(this == orig) 683 { 683 { 684 return; 684 return; 685 } 685 } 686 686 687 for(const auto category : *orig) 687 for(const auto category : *orig) 688 { 688 { 689 G4String catName = category->GetN 689 G4String catName = category->GetName(); 690 G4UnitsContainer* units = &(category->Ge 690 G4UnitsContainer* units = &(category->GetUnitsList()); 691 for(const auto unit : *units) 691 for(const auto unit : *units) 692 { 692 { 693 if(!Contains(unit, catName)) 693 if(!Contains(unit, catName)) 694 { 694 { 695 new G4UnitDefinition(unit->GetName(), 695 new G4UnitDefinition(unit->GetName(), unit->GetSymbol(), catName, 696 unit->GetValue()) 696 unit->GetValue()); 697 } 697 } 698 } 698 } 699 } 699 } 700 } 700 } 701 701 702 // ------------------------------------------- 702 // -------------------------------------------------------------------- 703 703 704 G4bool G4UnitsTable::Contains(const G4UnitDefi 704 G4bool G4UnitsTable::Contains(const G4UnitDefinition* unit, 705 const G4String& 705 const G4String& categoryName) 706 { 706 { 707 for(const auto category : *this) 707 for(const auto category : *this) 708 { 708 { 709 G4String catName = category->GetName(); 709 G4String catName = category->GetName(); 710 if(catName != categoryName) 710 if(catName != categoryName) 711 { 711 { 712 continue; 712 continue; 713 } 713 } 714 G4UnitsContainer* units = &(category->GetU 714 G4UnitsContainer* units = &(category->GetUnitsList()); 715 for(const auto ucItr : *units) 715 for(const auto ucItr : *units) 716 { 716 { 717 if(ucItr->GetName() == unit->GetName() & 717 if(ucItr->GetName() == unit->GetName() && 718 ucItr->GetSymbol() == unit->GetSymbol 718 ucItr->GetSymbol() == unit->GetSymbol()) 719 { 719 { 720 return true; 720 return true; 721 } 721 } 722 } 722 } 723 } 723 } 724 return false; 724 return false; 725 } 725 } 726 726 727 #endif 727 #endif 728 728