Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/global/management/src/G4UnitsTable.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /global/management/src/G4UnitsTable.cc (Version 11.3.0) and /global/management/src/G4UnitsTable.cc (Version 9.5.p1)


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