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 5.1)


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