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