Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4UnitsTable.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4UnitsTable.cc 99523 2016-09-26 10:25:48Z gcosmo $
28 //
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 //
31 // 17-05-98: first version, M.Maire
32 // 05-08-98: angstrom,microbarn,picobarn,petaelectronvolt, M.Maire
33 // 13-10-98: units and symbols printed in fixed length, M.Maire
34 // 01-03-01: parsec, M.Maire
35 // 06-03-01: migration to STL vectors, G.Cosmo
36 // 06-05-02: BestUnit operator<< flux instead of G4cout (mma)
37 // 12-08-05: cm2/g ("Surface/Mass") (mma)
38 // 30-06-05: um for micrometer (mma)
39 // 07-02-06: GeV/cm MeV/cm keV/cm eV/cm ("Energy/Length") (mma)
40 // 15-02-06: g/cm2 ("Mass/Surface")
41 // MeV*cm2/g ..etc.. ("Energy*Surface/Mass")
42 // 18-08-06: remove symbol mum (mma)
43 // 06-05-08: V/m ("Electric field") (mma)
44 // 09-08-10: new category "Solid angle" (mma)
45 //
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
49 #include <iomanip>
50 #include <sstream>
51 
52 #include "G4UnitsTable.hh"
53 #include "G4SystemOfUnits.hh"
54 #include "G4Threading.hh"
55 
56 G4ThreadLocal G4UnitsTable* G4UnitDefinition::pUnitsTable = 0;
57 G4ThreadLocal G4bool G4UnitDefinition::unitsTableDestroyed = false;
58 
59 #ifdef G4MULTITHREADED
60 G4UnitsTable* G4UnitDefinition::pUnitsTableShadow = 0;
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 G4UnitsTable::~G4UnitsTable()
66 {
67  G4UnitsTable::iterator itr = begin();
68  for(;itr!=end();itr++)
69  { delete *itr; }
70  clear();
71 }
72 
73 #endif
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78  const G4String& symbol,
79  const G4String& category, G4double value)
80  : Name(name),SymbolName(symbol),Value(value)
81 {
82  if (!pUnitsTable)
83  {
84  if(unitsTableDestroyed)
85  {
86  G4Exception("G4UnitDefinition::G4UnitDefinition","UnitsTable0000",
87  FatalException,"G4UnitsTable had already deleted.");
88  }
89  pUnitsTable = new G4UnitsTable;
90 #ifdef G4MULTITHREADED
92  { pUnitsTableShadow = pUnitsTable; }
93 #endif
94  }
95 
96  // Does the Category objet already exist ?
97  //
98  size_t nbCat = pUnitsTable->size();
99  size_t i = 0;
100  while ((i<nbCat)&&((*pUnitsTable)[i]->GetName()!=category)) { i++; }
101  if (i == nbCat)
102  { pUnitsTable->push_back( new G4UnitsCategory(category)); }
103  CategoryIndex = i;
104 
105  // Insert this Unit in the Units table
106  //
107  ((*pUnitsTable)[CategoryIndex]->GetUnitsList()).push_back(this);
108 
109  // Update string max length for name and symbol
110  //
111  (*pUnitsTable)[i]->UpdateNameMxLen((G4int)name.length());
112  (*pUnitsTable)[i]->UpdateSymbMxLen((G4int)symbol.length());
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116 
118 {;}
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
123 {
124  *this = right;
125 }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
128 
129 G4UnitDefinition& G4UnitDefinition::operator=(const G4UnitDefinition& right)
130 {
131  if (this != &right)
132  {
133  Name = right.Name;
134  SymbolName = right.SymbolName;
135  Value = right.Value;
136  CategoryIndex = right.CategoryIndex;
137  }
138  return *this;
139 }
140 
141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
142 
144 {
145  return (this == (G4UnitDefinition *) &right);
146 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
149 
151 {
152  return (this != (G4UnitDefinition *) &right);
153 }
154 
155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
156 
158 {
159  if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
160  if(pUnitsTable->size()==0) { BuildUnitsTable(); }
161 #ifdef G4MULTITHREADED
162  if(G4Threading::IsMasterThread() && !pUnitsTableShadow)
163  { pUnitsTableShadow = pUnitsTable; }
164 #endif
165  return *pUnitsTable;
166 }
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169 
171 {
172  G4String name, symbol;
173  for (size_t i=0;i<(GetUnitsTable()).size();++i)
174  {
175  G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
176  for (size_t j=0;j<units.size();++j)
177  {
178  name=units[j]->GetName(); symbol=units[j]->GetSymbol();
179  if(str==name||str==symbol) { return true; }
180  }
181  }
182  return false;
183 }
184 
185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
186 
188 {
189  G4String name, symbol;
190  for (size_t i=0;i<(GetUnitsTable()).size();++i)
191  {
192  G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
193  for (size_t j=0;j<units.size();++j)
194  {
195  name=units[j]->GetName(); symbol=units[j]->GetSymbol();
196  if(str==name||str==symbol) { return units[j]->GetValue(); }
197  }
198  }
199  std::ostringstream message;
200  message << "The unit '" << str << "' does not exist in the Units Table!";
201  G4Exception("G4UnitDefinition::GetValueOf()", "InvalidUnit",
202  FatalException, message);
203  return 0.;
204 }
205 
206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
207 
209 {
210  G4String name, symbol;
211  for (size_t i=0;i<(GetUnitsTable()).size();++i)
212  {
213  G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
214  for (size_t j=0;j<units.size();++j)
215  {
216  name=units[j]->GetName(); symbol=units[j]->GetSymbol();
217  if(str==name||str==symbol) { return (*pUnitsTable)[i]->GetName(); }
218  }
219  }
220  std::ostringstream message;
221  message << "The unit '" << str << "' does not exist in the Units Table!";
222  G4Exception("G4UnitDefinition::GetCategory()", "InvalidUnit",
223  FatalException, message);
224  name = "None";
225  return name;
226 }
227 
228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
229 
231 {
232  G4int nameL = (*pUnitsTable)[CategoryIndex]->GetNameMxLen();
233  G4int symbL = (*pUnitsTable)[CategoryIndex]->GetSymbMxLen();
234  G4cout << std::setw(nameL) << Name << " ("
235  << std::setw(symbL) << SymbolName << ") = " << Value << G4endl;
236 }
237 
238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
239 
241 {
242  //Length
243  new G4UnitDefinition( "parsec","pc" ,"Length",parsec);
244  new G4UnitDefinition( "kilometer","km" ,"Length",kilometer);
245  new G4UnitDefinition( "meter","m" ,"Length",meter);
246  new G4UnitDefinition("centimeter","cm" ,"Length",centimeter);
247  new G4UnitDefinition("millimeter","mm" ,"Length",millimeter);
248  new G4UnitDefinition("micrometer","um" ,"Length",micrometer);
249  new G4UnitDefinition( "nanometer","nm" ,"Length",nanometer);
250  new G4UnitDefinition( "angstrom","Ang" ,"Length",angstrom);
251  new G4UnitDefinition( "fermi","fm" ,"Length",fermi);
252 
253  //Surface
254  new G4UnitDefinition( "kilometer2","km2" ,"Surface",kilometer2);
255  new G4UnitDefinition( "meter2","m2" ,"Surface",meter2);
256  new G4UnitDefinition("centimeter2","cm2" ,"Surface",centimeter2);
257  new G4UnitDefinition("millimeter2","mm2" ,"Surface",millimeter2);
258  new G4UnitDefinition( "barn","barn" ,"Surface",barn);
259  new G4UnitDefinition( "millibarn","mbarn" ,"Surface",millibarn);
260  new G4UnitDefinition( "microbarn","mubarn" ,"Surface",microbarn);
261  new G4UnitDefinition( "nanobarn","nbarn" ,"Surface",nanobarn);
262  new G4UnitDefinition( "picobarn","pbarn" ,"Surface",picobarn);
263 
264  //Volume
265  new G4UnitDefinition( "kilometer3","km3" ,"Volume",kilometer3);
266  new G4UnitDefinition( "meter3","m3" ,"Volume",meter3);
267  new G4UnitDefinition("centimeter3","cm3" ,"Volume",centimeter3);
268  new G4UnitDefinition("millimeter3","mm3" ,"Volume",millimeter3);
269 
270  new G4UnitDefinition( "liter","L" ,"Volume",liter);
271  new G4UnitDefinition( "dL","dL" ,"Volume",dL);
272  new G4UnitDefinition( "cL","cL" ,"Volume",cL);
273  new G4UnitDefinition( "mL","mL" ,"Volume",mL);
274 
275  //Angle
276  new G4UnitDefinition( "radian","rad" ,"Angle",radian);
277  new G4UnitDefinition("milliradian","mrad" ,"Angle",milliradian);
278  new G4UnitDefinition( "degree","deg" ,"Angle",degree);
279 
280  //Solid angle
281  new G4UnitDefinition( "steradian","sr" ,"Solid angle",steradian);
282  new G4UnitDefinition("millisteradian","msr" ,"Solid angle",steradian*0.001);
283 
284  //Time
285  new G4UnitDefinition( "second","s" ,"Time",second);
286  new G4UnitDefinition("millisecond","ms" ,"Time",millisecond);
287  new G4UnitDefinition("microsecond","us" ,"Time",microsecond);
288  new G4UnitDefinition( "nanosecond","ns" ,"Time",nanosecond);
289  new G4UnitDefinition( "picosecond","ps" ,"Time",picosecond);
290 
291  //Frequency
292  new G4UnitDefinition( "hertz","Hz" ,"Frequency",hertz);
293  new G4UnitDefinition("kilohertz","kHz" ,"Frequency",kilohertz);
294  new G4UnitDefinition("megahertz","MHz" ,"Frequency",megahertz);
295 
296  //Electric charge
297  new G4UnitDefinition( "eplus","e+" ,"Electric charge",eplus);
298  new G4UnitDefinition("coulomb","C" ,"Electric charge",coulomb);
299 
300  //Energy
301  new G4UnitDefinition( "electronvolt","eV" ,"Energy",electronvolt);
302  new G4UnitDefinition("kiloelectronvolt","keV","Energy",kiloelectronvolt);
303  new G4UnitDefinition("megaelectronvolt","MeV","Energy",megaelectronvolt);
304  new G4UnitDefinition("gigaelectronvolt","GeV","Energy",gigaelectronvolt);
305  new G4UnitDefinition("teraelectronvolt","TeV","Energy",teraelectronvolt);
306  new G4UnitDefinition("petaelectronvolt","PeV","Energy",petaelectronvolt);
307  new G4UnitDefinition( "joule","J" ,"Energy",joule);
308 
309  // Energy/Length
310  new G4UnitDefinition( "GeV/cm", "GeV/cm","Energy/Length", GeV/cm);
311  new G4UnitDefinition( "MeV/cm", "MeV/cm","Energy/Length", MeV/cm);
312  new G4UnitDefinition( "keV/cm", "keV/cm","Energy/Length", keV/cm);
313  new G4UnitDefinition( "eV/cm", "eV/cm","Energy/Length", eV/cm);
314 
315  //Mass
316  new G4UnitDefinition("milligram","mg","Mass",milligram);
317  new G4UnitDefinition( "gram","g" ,"Mass",gram);
318  new G4UnitDefinition( "kilogram","kg","Mass",kilogram);
319 
320  //Volumic Mass
321  new G4UnitDefinition( "g/cm3", "g/cm3","Volumic Mass", g/cm3);
322  new G4UnitDefinition("mg/cm3","mg/cm3","Volumic Mass",mg/cm3);
323  new G4UnitDefinition("kg/m3", "kg/m3", "Volumic Mass",kg/m3);
324 
325  // Mass/Surface
326  new G4UnitDefinition( "g/cm2", "g/cm2","Mass/Surface", g/cm2);
327  new G4UnitDefinition( "mg/cm2", "mg/cm2","Mass/Surface", mg/cm2);
328  new G4UnitDefinition( "kg/cm2", "kg/cm2","Mass/Surface", kg/cm2);
329 
330  // Surface/Mass
331  new G4UnitDefinition( "cm2/g", "cm2/g","Surface/Mass", cm2/g);
332 
333  // Energy.Surface/Mass
334  new G4UnitDefinition( "eV*cm2/g", " eV*cm2/g","Energy*Surface/Mass", eV*cm2/g);
335  new G4UnitDefinition("keV*cm2/g", "keV*cm2/g","Energy*Surface/Mass",keV*cm2/g);
336  new G4UnitDefinition("MeV*cm2/g", "MeV*cm2/g","Energy*Surface/Mass",MeV*cm2/g);
337  new G4UnitDefinition("GeV*cm2/g", "GeV*cm2/g","Energy*Surface/Mass",GeV*cm2/g);
338 
339  //Power
340  new G4UnitDefinition("watt","W","Power",watt);
341 
342  //Force
343  new G4UnitDefinition("newton","N","Force",newton);
344 
345  //Pressure
346  new G4UnitDefinition( "pascal","Pa" ,"Pressure",hep_pascal);
347  new G4UnitDefinition( "bar","bar","Pressure",bar);
348  new G4UnitDefinition("atmosphere","atm","Pressure",atmosphere);
349 
350  //Electric current
351  new G4UnitDefinition( "ampere","A" ,"Electric current",ampere);
352  new G4UnitDefinition("milliampere","mA" ,"Electric current",milliampere);
353  new G4UnitDefinition("microampere","muA","Electric current",microampere);
354  new G4UnitDefinition( "nanoampere","nA" ,"Electric current",nanoampere);
355 
356  //Electric potential
357  new G4UnitDefinition( "volt","V" ,"Electric potential",volt);
358  new G4UnitDefinition("kilovolt","kV","Electric potential",kilovolt);
359  new G4UnitDefinition("megavolt","MV","Electric potential",megavolt);
360 
361  //Electric field
362  new G4UnitDefinition( "volt/m","V/m" ,"Electric field",volt/m);
363  new G4UnitDefinition("kilovolt/m","kV/m","Electric field",kilovolt/m);
364  new G4UnitDefinition("megavolt/m","MV/m","Electric field",megavolt/m);
365 
366  //Magnetic flux
367  new G4UnitDefinition("weber","Wb","Magnetic flux",weber);
368 
369  //Magnetic flux density
370  new G4UnitDefinition( "tesla","T" ,"Magnetic flux density",tesla);
371  new G4UnitDefinition("kilogauss","kG","Magnetic flux density",kilogauss);
372  new G4UnitDefinition( "gauss","G" ,"Magnetic flux density",gauss);
373 
374  //Temperature
375  new G4UnitDefinition("kelvin","K","Temperature",kelvin);
376 
377  //Amount of substance
378  new G4UnitDefinition("mole","mol","Amount of substance",mole);
379  new G4UnitDefinition("g/mole","g/mol","Molar mass",g/mole);
380 
381  //Activity
382  new G4UnitDefinition("becquerel","Bq","Activity",becquerel);
383  new G4UnitDefinition( "curie","Ci","Activity",curie);
384 
385  //Dose
386  new G4UnitDefinition("gray","Gy","Dose",gray);
387 }
388 
389 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
390 
392 {
393  G4cout << "\n ----- The Table of Units ----- \n";
394  if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
395  for(size_t i=0;i<pUnitsTable->size();i++)
396  {
397  (*pUnitsTable)[i]->PrintCategory();
398  }
399 }
400 
401 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
402 
404 {
405 #ifdef G4MULTITHREADED
406  delete pUnitsTable;
407  pUnitsTable = nullptr;
409  { pUnitsTableShadow = nullptr; }
410 #else
411  for (size_t i=0;i<pUnitsTable->size();i++)
412  {
413  delete (*pUnitsTable)[i];
414  }
415  pUnitsTable->clear();
416 #endif
417  unitsTableDestroyed = true;
418 }
419 
420 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
421 
423  : Name(name),UnitsList(),NameMxLen(0),SymbMxLen(0)
424 {
425 }
426 
427 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
428 
430 {
431  for(size_t i=0;i<UnitsList.size();i++)
432  {
433  delete UnitsList[i];
434  }
435  UnitsList.clear();
436 }
437 
438 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
439 
441 {
442  *this = right;
443 }
444 
445 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
446 
447 G4UnitsCategory& G4UnitsCategory::operator=(const G4UnitsCategory& right)
448 {
449  if (this != &right)
450  {
451  Name = right.Name;
452  UnitsList = right.UnitsList;
453  NameMxLen = right.NameMxLen;
454  SymbMxLen = right.SymbMxLen;
455  }
456  return *this;
457 }
458 
459 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
460 
462 {
463  return (this == (G4UnitsCategory *) &right);
464 }
465 
466 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
467 
469 {
470  return (this != (G4UnitsCategory *) &right);
471 }
472 
473 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
474 
476 {
477  G4cout << "\n category: " << Name << G4endl;
478  for(size_t i=0;i<UnitsList.size();i++)
479  { UnitsList[i]->PrintDefinition(); }
480 }
481 
482 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
483 
485  : nbOfVals(1)
486 {
487  // find the category
489  size_t nbCat = theUnitsTable.size();
490  size_t i = 0;
491  while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
492  if (i == nbCat)
493  {
494  G4cout << " G4BestUnit: the category " << category
495  << " does not exist !!" << G4endl;
496  G4Exception("G4BestUnit::G4BestUnit()", "InvalidCall",
497  FatalException, "Missing unit category !") ;
498  }
499  //
500  Value[0] = value;
501  Value[1] = 0.;
502  Value[2] = 0.;
503  IndexOfCategory = i;
504 }
505 
506 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
507 
509  : nbOfVals(3)
510 {
511  // find the category
513  size_t nbCat = theUnitsTable.size();
514  size_t i = 0;
515  while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
516  if (i == nbCat)
517  {
518  G4cerr << " G4BestUnit: the category " << category
519  << " does not exist." << G4endl;
520  G4Exception("G4BestUnit::G4BestUnit()", "InvalidCall",
521  FatalException, "Missing unit category !") ;
522  }
523  //
524  Value[0] = value.x();
525  Value[1] = value.y();
526  Value[2] = value.z();
527  IndexOfCategory = i;
528 }
529 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
530 
532 {}
533 
534 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
535 
536 G4BestUnit::operator G4String () const
537 {
538  std::ostringstream oss;
539  oss << *this;
540  return oss.str();
541 }
542 
543 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
544 
545 std::ostream& operator<<(std::ostream& flux, G4BestUnit a)
546 {
548  G4UnitsContainer& List = theUnitsTable[a.IndexOfCategory]
549  ->GetUnitsList();
550  G4int len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
551 
552  G4int ksup(-1), kinf(-1);
553  G4double umax(0.), umin(DBL_MAX);
554  G4double rsup(DBL_MAX), rinf(0.);
555 
556  //for a ThreeVector, choose the best unit for the biggest value
557  G4double value = std::max(std::max(std::fabs(a.Value[0]),
558  std::fabs(a.Value[1])),
559  std::fabs(a.Value[2]));
560 
561  for (size_t k=0; k<List.size(); k++)
562  {
563  G4double unit = List[k]->GetValue();
564  if (!(value!=DBL_MAX))
565  {if(unit>umax) {umax=unit; ksup=k;}}
566  else if (value<=DBL_MIN)
567  {if(unit<umin) {umin=unit; kinf=k;}}
568  else
569  {
570  G4double ratio = value/unit;
571  if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
572  if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
573  }
574  }
575 
576  G4int index=ksup;
577  if(index==-1) { index=kinf; }
578  if(index==-1) { index=0; }
579 
580  for (G4int j=0; j<a.nbOfVals; j++)
581  { flux << a.Value[j]/(List[index]->GetValue()) << " "; }
582 
583  std::ios::fmtflags oldform = flux.flags();
584 
585  flux.setf(std::ios::left,std::ios::adjustfield);
586  flux << std::setw(len) << List[index]->GetSymbol();
587  flux.flags(oldform);
588 
589  return flux;
590 }
591 
592 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
593 #ifdef G4MULTITHREADED
594 
595 void G4UnitsTable::Synchronize()
596 {
597  G4UnitsTable* orig = &(G4UnitDefinition::GetUnitsTableShadow());
598  if(this==orig) return;
599 
600  G4UnitsTable::iterator utItr = orig->begin();
601  for(;utItr!=orig->end();utItr++)
602  {
603  G4UnitsCategory* category = *utItr;
604  G4String catName = category->GetName();
605  G4UnitsContainer* units = &(category->GetUnitsList());
606  G4UnitsContainer::iterator ucItr = units->begin();
607  for(;ucItr!=units->end();ucItr++)
608  {
609  G4UnitDefinition* unit = *ucItr;
610  if(!Contains(unit,catName))
611  {
612  new G4UnitDefinition(unit->GetName(),unit->GetSymbol(),
613  catName,unit->GetValue());
614  }
615  }
616  }
617 }
618 
619 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
620 
621 G4bool G4UnitsTable::Contains(const G4UnitDefinition* unit,
622  const G4String& categoryName)
623 {
624  G4UnitsTable::iterator utItr = begin();
625  for(;utItr!=end();utItr++)
626  {
627  G4UnitsCategory* category = *utItr;
628  G4String catName = category->GetName();
629  if(catName!=categoryName) continue;
630  G4UnitsContainer* units = &(category->GetUnitsList());
631  G4UnitsContainer::iterator ucItr = units->begin();
632  for(;ucItr!=units->end();ucItr++)
633  {
634  if((*ucItr)->GetName()==unit->GetName() &&
635  (*ucItr)->GetSymbol()==unit->GetSymbol())
636  { return true; }
637  }
638  }
639  return false;
640 }
641 
642 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
643 
644 #endif
645 
static constexpr double tesla
Definition: G4SIunits.hh:268
static constexpr double parsec
Definition: G4SIunits.hh:98
const XML_Char int len
Definition: expat.h:262
const XML_Char * name
Definition: expat.h:151
static void BuildUnitsTable()
G4int operator==(const G4UnitsCategory &) const
static constexpr double mg
Definition: G4SIunits.hh:184
static constexpr double kilovolt
Definition: G4SIunits.hh:243
static constexpr double hep_pascal
Definition: G4SIunits.hh:235
static constexpr double teraelectronvolt
Definition: G4SIunits.hh:210
static constexpr double millimeter2
Definition: G4SIunits.hh:87
static constexpr double cm2
Definition: G4SIunits.hh:120
double x() const
static constexpr double milliradian
Definition: G4SIunits.hh:143
static constexpr double centimeter
Definition: G4SIunits.hh:90
G4BestUnit(G4double internalValue, const G4String &category)
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:60
static constexpr double megaelectronvolt
Definition: G4SIunits.hh:208
static constexpr double becquerel
Definition: G4SIunits.hh:291
static constexpr double coulomb
Definition: G4SIunits.hh:197
static constexpr double liter
Definition: G4SIunits.hh:123
static constexpr double hertz
Definition: G4SIunits.hh:163
static constexpr double nanometer
Definition: G4SIunits.hh:101
static constexpr double ampere
Definition: G4SIunits.hh:189
static constexpr double weber
Definition: G4SIunits.hh:263
static constexpr double second
Definition: G4SIunits.hh:157
static constexpr double m3
Definition: G4SIunits.hh:131
static constexpr double g
Definition: G4SIunits.hh:183
const G4String & GetSymbol() const
#define G4ThreadLocal
Definition: tls.hh:89
G4UnitsContainer & GetUnitsList()
static constexpr double millimeter3
Definition: G4SIunits.hh:88
static constexpr double watt
Definition: G4SIunits.hh:224
G4UnitsCategory(const G4String &name)
int G4int
Definition: G4Types.hh:78
static constexpr double electronvolt
Definition: G4SIunits.hh:206
static constexpr double newton
Definition: G4SIunits.hh:229
static constexpr double meter3
Definition: G4SIunits.hh:84
static constexpr double nanosecond
Definition: G4SIunits.hh:158
static constexpr double picosecond
Definition: G4SIunits.hh:161
double z() const
static constexpr double meter
Definition: G4SIunits.hh:82
static constexpr double gram
Definition: G4SIunits.hh:178
static constexpr double microampere
Definition: G4SIunits.hh:191
static constexpr double kilometer2
Definition: G4SIunits.hh:95
static G4double GetValueOf(const G4String &)
G4GLOB_DLL std::ostream G4cout
static constexpr double m
Definition: G4SIunits.hh:129
const XML_Char int const XML_Char * value
Definition: expat.h:331
static constexpr double gauss
Definition: G4SIunits.hh:270
static constexpr double nanobarn
Definition: G4SIunits.hh:108
static constexpr double milliampere
Definition: G4SIunits.hh:190
static constexpr double degree
Definition: G4SIunits.hh:144
static constexpr double megahertz
Definition: G4SIunits.hh:165
static constexpr double kilogauss
Definition: G4SIunits.hh:271
bool G4bool
Definition: G4Types.hh:79
G4UnitDefinition(const G4String &name, const G4String &symbol, const G4String &category, G4double value)
Definition: G4UnitsTable.cc:77
static constexpr double steradian
Definition: G4SIunits.hh:146
static constexpr double gray
Definition: G4SIunits.hh:309
static constexpr double cm
Definition: G4SIunits.hh:119
static constexpr double eplus
Definition: G4SIunits.hh:199
static constexpr double centimeter2
Definition: G4SIunits.hh:91
G4int operator!=(const G4UnitsCategory &) const
static constexpr double eV
Definition: G4SIunits.hh:215
const G4String & GetName() const
static constexpr double kg
Definition: G4SIunits.hh:182
static constexpr double kelvin
Definition: G4SIunits.hh:281
static constexpr double cm3
Definition: G4SIunits.hh:121
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static void ClearUnitsTable()
static G4UnitsTable & GetUnitsTable()
static constexpr double radian
Definition: G4SIunits.hh:142
static G4String GetCategory(const G4String &)
static constexpr double petaelectronvolt
Definition: G4SIunits.hh:211
static constexpr double kilohertz
Definition: G4SIunits.hh:164
static constexpr double gigaelectronvolt
Definition: G4SIunits.hh:209
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static constexpr double kilogram
Definition: G4SIunits.hh:177
static constexpr double nanoampere
Definition: G4SIunits.hh:192
static constexpr double joule
Definition: G4SIunits.hh:204
static constexpr double milligram
Definition: G4SIunits.hh:179
static constexpr double kiloelectronvolt
Definition: G4SIunits.hh:207
double y() const
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
#define DBL_MIN
Definition: templates.hh:75
static constexpr double millimeter
Definition: G4SIunits.hh:86
G4int operator!=(const G4UnitDefinition &) const
static constexpr double mL
Definition: G4SIunits.hh:127
static constexpr double GeV
Definition: G4SIunits.hh:217
static constexpr double megavolt
Definition: G4SIunits.hh:242
static constexpr double millisecond
Definition: G4SIunits.hh:159
G4int operator==(const G4UnitDefinition &) const
static void PrintUnitsTable()
const G4String & GetName() const
static constexpr double microsecond
Definition: G4SIunits.hh:160
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
static constexpr double angstrom
Definition: G4SIunits.hh:102
static constexpr double kilometer3
Definition: G4SIunits.hh:96
G4bool IsMasterThread()
Definition: G4Threading.cc:146
static constexpr double meter2
Definition: G4SIunits.hh:83
G4double GetValue() const
static constexpr double bar
Definition: G4SIunits.hh:236
static constexpr double volt
Definition: G4SIunits.hh:244
static constexpr double curie
Definition: G4SIunits.hh:292
double G4double
Definition: G4Types.hh:76
std::vector< G4UnitDefinition * > G4UnitsContainer
static constexpr double fermi
Definition: G4SIunits.hh:103
static constexpr double barn
Definition: G4SIunits.hh:105
static constexpr double cL
Definition: G4SIunits.hh:126
static constexpr double centimeter3
Definition: G4SIunits.hh:92
#define DBL_MAX
Definition: templates.hh:83
static constexpr double keV
Definition: G4SIunits.hh:216
static constexpr double atmosphere
Definition: G4SIunits.hh:237
static constexpr double micrometer
Definition: G4SIunits.hh:100
static constexpr double mole
Definition: G4SIunits.hh:286
static constexpr double kilometer
Definition: G4SIunits.hh:94
static constexpr double dL
Definition: G4SIunits.hh:125
static constexpr double millibarn
Definition: G4SIunits.hh:106
static G4bool IsUnitDefined(const G4String &)
static constexpr double microbarn
Definition: G4SIunits.hh:107
G4GLOB_DLL std::ostream G4cerr
static constexpr double picobarn
Definition: G4SIunits.hh:109