Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/persistency/ascii/src/G4tgbMaterialMgr.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 /persistency/ascii/src/G4tgbMaterialMgr.cc (Version 11.3.0) and /persistency/ascii/src/G4tgbMaterialMgr.cc (Version 10.6.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 // G4tgbMaterialMgr implementation             << 
 27 //                                                 26 //
 28 // Author: P.Arce, CIEMAT (November 2007)      <<  27 //
 29 // ------------------------------------------- <<  28 //
                                                   >>  29 // class G4tgbMaterialMgr
                                                   >>  30 
                                                   >>  31 // History:
                                                   >>  32 // - Created.                                 P.Arce, CIEMAT (November 2007)
                                                   >>  33 // -------------------------------------------------------------------------
 30                                                    34 
 31 #include "G4tgbMaterialMgr.hh"                     35 #include "G4tgbMaterialMgr.hh"
 32 #include "G4tgbMaterialMixtureByWeight.hh"         36 #include "G4tgbMaterialMixtureByWeight.hh"
 33 #include "G4tgbMaterialMixtureByVolume.hh"         37 #include "G4tgbMaterialMixtureByVolume.hh"
 34 #include "G4tgbMaterialMixtureByNoAtoms.hh"        38 #include "G4tgbMaterialMixtureByNoAtoms.hh"
 35 #include "G4tgbMaterialSimple.hh"                  39 #include "G4tgbMaterialSimple.hh"
 36                                                    40 
 37 #include "G4tgrMaterialFactory.hh"                 41 #include "G4tgrMaterialFactory.hh"
 38 #include "G4tgrMaterialSimple.hh"                  42 #include "G4tgrMaterialSimple.hh"
 39 #include "G4tgrMaterialMixture.hh"                 43 #include "G4tgrMaterialMixture.hh"
 40 #include "G4tgrUtils.hh"                           44 #include "G4tgrUtils.hh"
 41 #include "G4tgrMessenger.hh"                       45 #include "G4tgrMessenger.hh"
 42 #include "G4NistManager.hh"                        46 #include "G4NistManager.hh"
 43                                                    47 
 44 G4ThreadLocal G4tgbMaterialMgr* G4tgbMaterialM << 
 45                                                    48 
 46 // ------------------------------------------- <<  49 G4ThreadLocal G4tgbMaterialMgr* G4tgbMaterialMgr::theInstance = 0;
                                                   >>  50 
                                                   >>  51 
                                                   >>  52 // -------------------------------------------------------------------------
 47 G4tgbMaterialMgr::G4tgbMaterialMgr()               53 G4tgbMaterialMgr::G4tgbMaterialMgr()
 48 {                                                  54 {
 49 }                                                  55 }
 50                                                    56 
 51 // ------------------------------------------- <<  57 
                                                   >>  58 // -------------------------------------------------------------------------
 52 G4tgbMaterialMgr* G4tgbMaterialMgr::GetInstanc     59 G4tgbMaterialMgr* G4tgbMaterialMgr::GetInstance()
 53 {                                                  60 {
 54   if(theInstance == nullptr)                   <<  61   if( !theInstance )
 55   {                                                62   {
 56     theInstance = new G4tgbMaterialMgr;            63     theInstance = new G4tgbMaterialMgr;
 57     theInstance->CopyIsotopes();                   64     theInstance->CopyIsotopes();
 58     theInstance->CopyElements();                   65     theInstance->CopyElements();
 59     theInstance->CopyMaterials();                  66     theInstance->CopyMaterials();
 60   }                                                67   }
 61   return theInstance;                              68   return theInstance;
 62 }                                                  69 }
 63                                                    70 
 64 // ------------------------------------------- <<  71 
                                                   >>  72 // -------------------------------------------------------------------------
 65 G4tgbMaterialMgr::~G4tgbMaterialMgr()              73 G4tgbMaterialMgr::~G4tgbMaterialMgr()
 66 {                                                  74 {
 67   for(auto isotcite = theG4tgbIsotopes.cbegin( <<  75   G4mstgbisot::const_iterator isotcite;
 68            isotcite != theG4tgbIsotopes.cend() <<  76   for( isotcite = theG4tgbIsotopes.begin();
                                                   >>  77        isotcite != theG4tgbIsotopes.end(); isotcite++)
 69   {                                                78   {
 70     delete(*isotcite).second;                  <<  79     delete (*isotcite).second;
 71   }                                                80   }
 72   theG4tgbIsotopes.clear();                        81   theG4tgbIsotopes.clear();
 73                                                    82 
 74   for(auto elemcite = theG4tgbElements.cbegin( <<  83   G4mstgbelem::const_iterator elemcite;
 75            elemcite != theG4tgbElements.cend() <<  84   for( elemcite = theG4tgbElements.begin();
                                                   >>  85        elemcite != theG4tgbElements.end(); elemcite++)
 76   {                                                86   {
 77     delete(*elemcite).second;                  <<  87     delete (*elemcite).second;
 78   }                                                88   }
 79   theG4tgbElements.clear();                        89   theG4tgbElements.clear();
 80                                                    90 
 81   for(auto matcite = theG4tgbMaterials.cbegin( <<  91   G4mstgbmate::const_iterator matcite;
 82            matcite != theG4tgbMaterials.cend() <<  92   for( matcite = theG4tgbMaterials.begin();
                                                   >>  93        matcite != theG4tgbMaterials.end(); matcite++)
 83   {                                                94   {
 84     delete(*matcite).second;                   <<  95     delete (*matcite).second;
 85   }                                                96   }
 86   theG4tgbMaterials.clear();                       97   theG4tgbMaterials.clear();
 87                                                    98 
 88   delete theInstance;                              99   delete theInstance;
 89 }                                                 100 }
 90                                                   101 
 91 // ------------------------------------------- << 102 
                                                   >> 103 // -------------------------------------------------------------------------
 92 void G4tgbMaterialMgr::CopyIsotopes()             104 void G4tgbMaterialMgr::CopyIsotopes()
 93 {                                                 105 {
 94   const G4mstgrisot tgrIsots =                 << 106   const G4mstgrisot tgrIsots
 95     G4tgrMaterialFactory::GetInstance()->GetIs << 107         = G4tgrMaterialFactory::GetInstance()->GetIsotopeList();
 96   for(auto cite = tgrIsots.cbegin(); cite != t << 108   G4mstgrisot::const_iterator cite;
                                                   >> 109   for( cite = tgrIsots.begin(); cite != tgrIsots.end(); cite++ )
 97   {                                               110   {
 98     G4tgrIsotope* tgr                = (*cite) << 111     G4tgrIsotope* tgr = (*cite).second;
 99     G4tgbIsotope* tgb                = new G4t << 112     G4tgbIsotope* tgb = new G4tgbIsotope( tgr );
100     theG4tgbIsotopes[tgb->GetName()] = tgb;       113     theG4tgbIsotopes[tgb->GetName()] = tgb;
101   }                                               114   }
102 }                                                 115 }
103                                                   116 
104 // ------------------------------------------- << 117 
                                                   >> 118 // -------------------------------------------------------------------------
105 void G4tgbMaterialMgr::CopyElements()             119 void G4tgbMaterialMgr::CopyElements()
106 {                                                 120 {
107   const G4mstgrelem tgrElems =                 << 121   const G4mstgrelem tgrElems
108     G4tgrMaterialFactory::GetInstance()->GetEl << 122         = G4tgrMaterialFactory::GetInstance()->GetElementList();
109   for(auto cite = tgrElems.cbegin(); cite != t << 123   G4mstgrelem::const_iterator cite;
                                                   >> 124   for( cite = tgrElems.begin(); cite != tgrElems.end(); cite++ )
110   {                                               125   {
111     G4tgrElement* tgr                = (*cite) << 126     G4tgrElement* tgr = (*cite).second;
112     G4tgbElement* tgb                = new G4t << 127     G4tgbElement* tgb = new G4tgbElement( tgr );
113     theG4tgbElements[tgb->GetName()] = tgb;       128     theG4tgbElements[tgb->GetName()] = tgb;
114   }                                               129   }
115 }                                                 130 }
116                                                   131 
117 // ------------------------------------------- << 132 
                                                   >> 133 // -------------------------------------------------------------------------
118 void G4tgbMaterialMgr::CopyMaterials()            134 void G4tgbMaterialMgr::CopyMaterials()
119 {                                                 135 {
120   const G4mstgrmate tgrMates =                 << 136   const G4mstgrmate tgrMates
121     G4tgrMaterialFactory::GetInstance()->GetMa << 137         = G4tgrMaterialFactory::GetInstance()->GetMaterialList();
122   for(auto cite = tgrMates.cbegin(); cite != t << 138   G4mstgrmate::const_iterator cite;
                                                   >> 139   for( cite = tgrMates.begin(); cite != tgrMates.end(); cite++ )
123   {                                               140   {
124     G4tgrMaterial* tgr = (*cite).second;          141     G4tgrMaterial* tgr = (*cite).second;
125     G4tgbMaterial* tgb = nullptr;              << 142     G4tgbMaterial* tgb = 0;
126     if(tgr->GetType() == "MaterialSimple")     << 143     if( tgr->GetType() == "MaterialSimple" ) {
127     {                                          << 144       tgb = new G4tgbMaterialSimple( tgr );
128       tgb = new G4tgbMaterialSimple(tgr);      << 145     } else if( tgr->GetType() == "MaterialMixtureByWeight" ) {
129     }                                          << 146       tgb = new G4tgbMaterialMixtureByWeight( tgr );
130     else if(tgr->GetType() == "MaterialMixture << 147     } else if( tgr->GetType() == "MaterialMixtureByNoAtoms" ) {
131     {                                          << 148       tgb = new G4tgbMaterialMixtureByNoAtoms( tgr );
132       tgb = new G4tgbMaterialMixtureByWeight(t << 149     } else if( tgr->GetType() == "MaterialMixtureByVolume" ) {
133     }                                          << 150       tgb = new G4tgbMaterialMixtureByVolume( tgr );
134     else if(tgr->GetType() == "MaterialMixture << 151     } else {
135     {                                          << 
136       tgb = new G4tgbMaterialMixtureByNoAtoms( << 
137     }                                          << 
138     else if(tgr->GetType() == "MaterialMixture << 
139     {                                          << 
140       tgb = new G4tgbMaterialMixtureByVolume(t << 
141     }                                          << 
142     else                                       << 
143     {                                          << 
144       return;                                     152       return;
145     }                                             153     }
146     theG4tgbMaterials[tgb->GetName()] = tgb;      154     theG4tgbMaterials[tgb->GetName()] = tgb;
147   }                                               155   }
148 }                                                 156 }
149                                                   157 
150 // ------------------------------------------- << 158 
151 G4Isotope* G4tgbMaterialMgr::FindOrBuildG4Isot << 159 // -------------------------------------------------------------------------
                                                   >> 160 G4Isotope* G4tgbMaterialMgr::FindOrBuildG4Isotope(const G4String & name) 
152 {                                                 161 {
153   G4Isotope* g4isot = FindBuiltG4Isotope(name) << 162   G4Isotope* g4isot = FindBuiltG4Isotope( name );
154   if(g4isot == nullptr)                        << 163   if( g4isot == 0 )
155   {                                               164   {
156     G4tgbIsotope* tgbisot = FindG4tgbIsotope(n << 165     G4tgbIsotope* tgbisot = FindG4tgbIsotope( name );
157     // FindG4tgbIsotope never returns nullptr, << 166     // FindG4tgbIsotope never returns 0, otherwise if not found, crashes
158     g4isot = tgbisot->BuildG4Isotope();           167     g4isot = tgbisot->BuildG4Isotope();
159     // Register it                                168     // Register it
160     G4String isotname       = g4isot->GetName( << 169     G4String isotname = g4isot->GetName();
161     theG4Isotopes[isotname] = g4isot;             170     theG4Isotopes[isotname] = g4isot;
162   }                                               171   }
163   else                                            172   else
164   {                                            << 173   { 
165 #ifdef G4VERBOSE                                  174 #ifdef G4VERBOSE
166     if(G4tgrMessenger::GetVerboseLevel() >= 1) << 175     if( G4tgrMessenger::GetVerboseLevel() >= 1 )
167     {                                             176     {
168       G4cout << " G4tgbMaterialMgr::FindOrBuil    177       G4cout << " G4tgbMaterialMgr::FindOrBuildG4Isotope() -"
169              << " G4Isotope already built: " <    178              << " G4Isotope already built: " << g4isot->GetName() << G4endl;
170     }                                             179     }
171 #endif                                            180 #endif
172   }                                               181   }
173                                                   182 
174 #ifdef G4VERBOSE                                  183 #ifdef G4VERBOSE
175   if(G4tgrMessenger::GetVerboseLevel() >= 2)   << 184   if( G4tgrMessenger::GetVerboseLevel() >= 2 )
176   {                                               185   {
177     G4cout << " G4tgbMaterialMgr::FindOrBuildG << 186     G4cout << " G4tgbMaterialMgr::FindOrBuildG4Isotope() - Isotope: "
178            << G4endl;                          << 187            << name << G4endl;
179   }                                               188   }
180 #endif                                            189 #endif
181   return g4isot;                                  190   return g4isot;
182 }                                              << 191 } 
183                                                   192 
184 // ------------------------------------------- << 
185 G4Isotope* G4tgbMaterialMgr::FindBuiltG4Isotop << 
186 {                                              << 
187   G4Isotope* g4isot = nullptr;                 << 
188                                                   193 
189   G4msg4isot::const_iterator cite = theG4Isoto << 194 // -------------------------------------------------------------------------
190   if(cite != theG4Isotopes.cend())             << 195 G4Isotope* G4tgbMaterialMgr::FindBuiltG4Isotope(const G4String & name) const 
                                                   >> 196 {
                                                   >> 197   G4Isotope* g4isot = 0;
                                                   >> 198  
                                                   >> 199   G4msg4isot::const_iterator cite = theG4Isotopes.find( name );
                                                   >> 200   if( cite != theG4Isotopes.end() )
191   {                                               201   {
192     g4isot = (*cite).second;                      202     g4isot = (*cite).second;
193 #ifdef G4VERBOSE                                  203 #ifdef G4VERBOSE
194     if(G4tgrMessenger::GetVerboseLevel() >= 2) << 204     if( G4tgrMessenger::GetVerboseLevel() >= 2 )
195     {                                          << 205       {
196       G4cout << " G4tgbMaterialMgr::FindBuiltG << 206         G4cout << " G4tgbMaterialMgr::FindBuiltG4Isotope() - Isotope: "
197              << " = " << g4isot << G4endl;     << 207                << name << " = " << g4isot << G4endl;
198     }                                          << 208       }
199 #endif                                            209 #endif
200   }                                            << 210 
                                                   >> 211   } 
201                                                   212 
202   return g4isot;                                  213   return g4isot;
203 }                                                 214 }
204                                                   215 
205 // ------------------------------------------- << 216 
206 G4tgbIsotope* G4tgbMaterialMgr::FindG4tgbIsoto << 217 // -------------------------------------------------------------------------
207                                                << 218 G4tgbIsotope* G4tgbMaterialMgr::FindG4tgbIsotope(const G4String & name,
                                                   >> 219                                                        G4bool bMustExist ) const 
208 {                                                 220 {
209   G4tgbIsotope* isot = nullptr;                << 221   G4tgbIsotope* isot = 0;
210                                                   222 
211   G4mstgbisot::const_iterator cite = theG4tgbI << 223   G4mstgbisot::const_iterator cite = theG4tgbIsotopes.find( name ); 
212   if(cite != theG4tgbIsotopes.cend())          << 224   if( cite != theG4tgbIsotopes.end() )
213   {                                               225   {
214 #ifdef G4VERBOSE                                  226 #ifdef G4VERBOSE
215     if(G4tgrMessenger::GetVerboseLevel() >= 2) << 227     if( G4tgrMessenger::GetVerboseLevel() >= 2 )
216     {                                             228     {
217       G4cout << " G4tgbMaterialMgr::FindG4tgbI    229       G4cout << " G4tgbMaterialMgr::FindG4tgbIsotope() -"
218              << " G4tgbIsotope found: " << ((* << 230              << " G4tgbIsotope found: " << ( (*cite).second )->GetName()
219              << G4endl;                           231              << G4endl;
220     }                                             232     }
221 #endif                                            233 #endif
222     isot = (*cite).second;                        234     isot = (*cite).second;
223   }                                               235   }
224   if((isot == nullptr) && bMustExist)          << 236   if( (isot == 0) && bMustExist )
225   {                                               237   {
226     G4String ErrMessage = "Isotope " + name +     238     G4String ErrMessage = "Isotope " + name + " not found !";
227     G4Exception("G4tgbMaterialMgr::FindG4tgbIs << 239     G4Exception("G4tgbMaterialMgr::FindG4tgbIsotope()",
228                 FatalException, ErrMessage);   << 240                 "InvalidSetup", FatalException, ErrMessage);
229   }                                               241   }
230                                                   242 
231   return isot;                                    243   return isot;
232 }                                                 244 }
233                                                   245 
234 // ------------------------------------------- << 246 
235 G4Element* G4tgbMaterialMgr::FindOrBuildG4Elem << 247 // -------------------------------------------------------------------------
236                                                << 248 G4Element* G4tgbMaterialMgr::FindOrBuildG4Element(const G4String & name,
                                                   >> 249                                                   G4bool bMustExist ) 
237 {                                                 250 {
238   G4Element* g4elem = FindBuiltG4Element(name) << 251   G4Element* g4elem = FindBuiltG4Element( name );
239   if(g4elem == nullptr)                        << 252   if( g4elem == 0 )
240   {                                               253   {
241     G4tgbElement* tgbelem = FindG4tgbElement(n << 254     G4tgbElement* tgbelem = FindG4tgbElement( name, false );
242     if(tgbelem == nullptr)                     << 255     if( tgbelem == 0)
243     {                                             256     {
244       // If FindG4tgbElement returns nullptr,  << 257       // If FindG4tgbElement returns 0, look for a G4NISTElement
245       G4cout << "  G4NistManager::Instance()->    258       G4cout << "  G4NistManager::Instance()->FindOrBuildElement( " << G4endl;
246       g4elem = G4NistManager::Instance()->Find    259       g4elem = G4NistManager::Instance()->FindOrBuildElement(name);
247     }                                             260     }
248     else                                          261     else
249     {                                             262     {
250       if(tgbelem->GetType() == "ElementSimple" << 263       if( tgbelem->GetType() == "ElementSimple" )
251       {                                           264       {
252         g4elem = tgbelem->BuildG4ElementSimple    265         g4elem = tgbelem->BuildG4ElementSimple();
253       }                                           266       }
254       else if(tgbelem->GetType() == "ElementFr << 267       else if( tgbelem->GetType() == "ElementFromIsotopes" )
255       {                                           268       {
256         g4elem = tgbelem->BuildG4ElementFromIs    269         g4elem = tgbelem->BuildG4ElementFromIsotopes();
257       }                                           270       }
258       else                                        271       else
259       {                                           272       {
260         G4String ErrMessage =                  << 273         G4String ErrMessage = "Element type " + tgbelem->GetType()
261           "Element type " + tgbelem->GetType() << 274           + " does not exist !";
262         G4Exception("G4tgbMaterialMgr::GetG4El << 275         G4Exception("G4tgbMaterialMgr::GetG4Element()",
263                     FatalException, ErrMessage << 276                     "InvalidSetup", FatalException, ErrMessage);
264       }                                           277       }
265     }                                             278     }
266     // Register it                                279     // Register it
267     if((g4elem != nullptr))                    << 280     if( (g4elem != 0) )
268     {                                             281     {
269       theG4Elements[g4elem->GetName()] = g4ele    282       theG4Elements[g4elem->GetName()] = g4elem;
270 #ifdef G4VERBOSE                                  283 #ifdef G4VERBOSE
271       if(G4tgrMessenger::GetVerboseLevel() >=  << 284       if( G4tgrMessenger::GetVerboseLevel() >= 2 )
272       {                                        << 285         {
273         G4cout << " G4tgbMaterialMgr::FindOrBu << 286           G4cout << " G4tgbMaterialMgr::FindOrBuildG4Element() - Element: "
274                << name << G4endl;              << 287                  << name << G4endl;
275       }                                        << 288         }
276 #endif                                            289 #endif
277     }                                             290     }
278     else                                          291     else
279     {                                             292     {
280       if(bMustExist)                           << 293       if( bMustExist )
281       {                                           294       {
282         G4String ErrMessage = "Element " + nam    295         G4String ErrMessage = "Element " + name + " not found !";
283         G4Exception("G4tgbMaterialMgr::FindOrB << 296         G4Exception("G4tgbMaterialMgr::FindOrBuildG4Element()",
284                     FatalException, ErrMessage << 297                     "InvalidSetup", FatalException, ErrMessage);
285       }                                           298       }
286 #ifdef G4VERBOSE                                  299 #ifdef G4VERBOSE
287       if(G4tgrMessenger::GetVerboseLevel() >=  << 300       if( G4tgrMessenger::GetVerboseLevel() >= 2 )
288       {                                           301       {
289         G4cout << " G4tgbMaterialMgr::FindOrBu    302         G4cout << " G4tgbMaterialMgr::FindOrBuildG4Element() - Element: "
290                << name << " not found  " << G4    303                << name << " not found  " << G4endl;
291       }                                           304       }
292 #endif                                            305 #endif
293     }                                             306     }
294   }                                               307   }
295   else                                            308   else
296   {                                            << 309   { 
297 #ifdef G4VERBOSE                                  310 #ifdef G4VERBOSE
298     if(G4tgrMessenger::GetVerboseLevel() >= 1) << 311     if( G4tgrMessenger::GetVerboseLevel() >= 1 )
299     {                                             312     {
300       G4cout << " G4tgbMaterialMgr::GetG4Eleme    313       G4cout << " G4tgbMaterialMgr::GetG4Element() -"
301              << " G4Element already built: " < << 314              << " G4Element already built: " << g4elem->GetName() << G4endl; 
302     }                                             315     }
303 #endif                                            316 #endif
304   }                                               317   }
305                                                   318 
306   return g4elem;                                  319   return g4elem;
307 }                                              << 320 } 
308                                                   321 
309 // ------------------------------------------- << 
310 G4Element* G4tgbMaterialMgr::FindBuiltG4Elemen << 
311 {                                              << 
312   G4Element* g4elem = nullptr;                 << 
313                                                   322 
314   G4msg4elem::const_iterator cite = theG4Eleme << 323 // -------------------------------------------------------------------------
315   if(cite != theG4Elements.cend())             << 324 G4Element* G4tgbMaterialMgr::FindBuiltG4Element(const G4String & name) const 
                                                   >> 325 {
                                                   >> 326   G4Element* g4elem = 0;
                                                   >> 327  
                                                   >> 328   G4msg4elem::const_iterator cite = theG4Elements.find( name );
                                                   >> 329   if( cite != theG4Elements.end() )
316   {                                               330   {
317     g4elem = (*cite).second;                      331     g4elem = (*cite).second;
318 #ifdef G4VERBOSE                                  332 #ifdef G4VERBOSE
319     if(G4tgrMessenger::GetVerboseLevel() >= 2) << 333     if( G4tgrMessenger::GetVerboseLevel() >= 2 )
320     {                                             334     {
321       G4cout << " G4tgbMaterialMgr::FindBuiltG << 335       G4cout << " G4tgbMaterialMgr::FindBuiltG4Element() - Element: "
322              << " = " << g4elem << G4endl;     << 336              << name << " = " << g4elem << G4endl;
323     }                                             337     }
324 #endif                                            338 #endif
325   }                                            << 339   } 
326                                                   340 
327   return g4elem;                                  341   return g4elem;
328 }                                                 342 }
329                                                   343 
330 // ------------------------------------------- << 344 
331 G4tgbElement* G4tgbMaterialMgr::FindG4tgbEleme << 345 // -------------------------------------------------------------------------
332                                                << 346 G4tgbElement* G4tgbMaterialMgr::FindG4tgbElement(const G4String & name,
                                                   >> 347                                                        G4bool bMustExist ) const
333 {                                                 348 {
334   G4tgbElement* elem = nullptr;                << 349   G4tgbElement* elem = 0;
335                                                   350 
336   G4mstgbelem::const_iterator cite = theG4tgbE << 351   G4mstgbelem::const_iterator cite = theG4tgbElements.find( name ); 
337   if(cite != theG4tgbElements.cend())          << 352   if( cite != theG4tgbElements.end() )
338   {                                               353   {
339 #ifdef G4VERBOSE                                  354 #ifdef G4VERBOSE
340     if(G4tgrMessenger::GetVerboseLevel() >= 2) << 355     if( G4tgrMessenger::GetVerboseLevel() >= 2 )
341     {                                             356     {
342       G4cout << " G4tgbMaterialMgr::FindG4tgbE    357       G4cout << " G4tgbMaterialMgr::FindG4tgbElement() -"
343              << " G4tgbElement found: " << ((* << 358              << " G4tgbElement found: " << ( (*cite).second )->GetName()
344              << G4endl;                           359              << G4endl;
345     }                                             360     }
346 #endif                                            361 #endif
347     elem = (*cite).second;                        362     elem = (*cite).second;
348   }                                               363   }
349   if((elem == nullptr) && bMustExist)          << 364   if( (elem == 0) && bMustExist )
350   {                                               365   {
351     G4String ErrMessage = "Element " + name +     366     G4String ErrMessage = "Element " + name + "  not found !";
352     G4Exception("G4tgbMaterialMgr::FindG4tgbEl << 367     G4Exception("G4tgbMaterialMgr::FindG4tgbElement()",
353                 FatalException, ErrMessage);   << 368                 "InvalidSetup", FatalException, ErrMessage);
354   }                                               369   }
355                                                   370 
356   return elem;                                    371   return elem;
357 }                                                 372 }
358                                                   373 
359 // ------------------------------------------- << 374 
360 G4Material* G4tgbMaterialMgr::FindOrBuildG4Mat << 375 // -------------------------------------------------------------------------
361                                                << 376 G4Material* G4tgbMaterialMgr::FindOrBuildG4Material(const G4String & name,
                                                   >> 377                                                     G4bool bMustExist )  
362 {                                                 378 {
363   G4Material* g4mate = FindBuiltG4Material(nam << 379   G4Material* g4mate = FindBuiltG4Material( name );
364   if(g4mate == nullptr)                        << 380   if( g4mate == 0)
365   {                                               381   {
366     G4tgbMaterial* tgbmate = FindG4tgbMaterial << 382     G4tgbMaterial* tgbmate = FindG4tgbMaterial( name, false );
367                                                << 383    
368     if(tgbmate == nullptr)                     << 384     if( tgbmate == 0)
369     {                                             385     {
370       // if FindG4tgbMaterial() returns 0, loo    386       // if FindG4tgbMaterial() returns 0, look for a G4NISTMaterial
371       g4mate = G4NistManager::Instance()->Find    387       g4mate = G4NistManager::Instance()->FindOrBuildMaterial(name);
372     }                                             388     }
373     else                                          389     else
374     {                                             390     {
375       g4mate = tgbmate->BuildG4Material();        391       g4mate = tgbmate->BuildG4Material();
376                                                   392 
377       if(tgbmate->GetTgrMate()->GetIonisationM << 393       if( tgbmate->GetTgrMate()->GetIonisationMeanExcitationEnergy() != -1. )
378       {                                           394       {
379         g4mate->GetIonisation()->SetMeanExcita << 395         g4mate->GetIonisation()->SetMeanExcitationEnergy(tgbmate->
380           tgbmate->GetTgrMate()->GetIonisation << 396                 GetTgrMate()->GetIonisationMeanExcitationEnergy());
381       }                                           397       }
382     }                                             398     }
383                                                   399 
384     // Register it                                400     // Register it
385     if(g4mate != nullptr)                      << 401     if( g4mate != 0 )
386     {                                             402     {
387       theG4Materials[g4mate->GetName()] = g4ma    403       theG4Materials[g4mate->GetName()] = g4mate;
388 #ifdef G4VERBOSE                                  404 #ifdef G4VERBOSE
389       if(G4tgrMessenger::GetVerboseLevel() >=  << 405       if( G4tgrMessenger::GetVerboseLevel() >= 2 )
390       {                                           406       {
391         G4cout << " G4tgbMaterialMgr::FindOrBu    407         G4cout << " G4tgbMaterialMgr::FindOrBuildG4Material() - Material: "
392                << name << G4endl;                 408                << name << G4endl;
393       }                                           409       }
394 #endif                                            410 #endif
395     }                                             411     }
396     else                                          412     else
397     {                                             413     {
398       if(bMustExist)                           << 414       if( bMustExist )
399       {                                           415       {
400         G4String ErrMessage = "Material " + na    416         G4String ErrMessage = "Material " + name + "  not found !";
401         G4Exception("G4tgbMaterialMgr::FindOrB << 417         G4Exception("G4tgbMaterialMgr::FindOrBuildG4Material()",
402                     FatalException, ErrMessage << 418                     "InvalidSetup", FatalException, ErrMessage);
403       }                                        << 419       }  
404 #ifdef G4VERBOSE                                  420 #ifdef G4VERBOSE
405       if(G4tgrMessenger::GetVerboseLevel() >=  << 421       if( G4tgrMessenger::GetVerboseLevel() >= 2 )
406       {                                           422       {
407         G4cout << " G4tgbMaterialMgr::FindOrBu    423         G4cout << " G4tgbMaterialMgr::FindOrBuildG4Material() - Element: "
408                << name << " not found  " << G4    424                << name << " not found  " << G4endl;
409       }                                           425       }
410 #endif                                            426 #endif
411     }                                             427     }
412   }                                               428   }
413   else                                            429   else
414   {                                            << 430   { 
415 #ifdef G4VERBOSE                                  431 #ifdef G4VERBOSE
416     if(G4tgrMessenger::GetVerboseLevel() >= 1) << 432     if( G4tgrMessenger::GetVerboseLevel() >= 1 )
417     {                                             433     {
418       G4cout << " G4tgbMaterialMgr::FindOrBuil    434       G4cout << " G4tgbMaterialMgr::FindOrBuildG4Material() -"
419              << " G4Material already built: "     435              << " G4Material already built: " << g4mate->GetName() << G4endl;
420     }                                             436     }
421 #endif                                            437 #endif
422   }                                               438   }
423                                                   439 
424   return g4mate;                                  440   return g4mate;
425 }                                                 441 }
426                                                   442 
427 // ------------------------------------------- << 443 
428 G4Material* G4tgbMaterialMgr::FindBuiltG4Mater << 444 // -------------------------------------------------------------------------
                                                   >> 445 G4Material* G4tgbMaterialMgr::FindBuiltG4Material(const G4String & name) const 
429 {                                                 446 {
430   G4Material* g4mate = nullptr;                << 447   G4Material* g4mate = 0;
431   //---------- look for an existing G4Material    448   //---------- look for an existing G4Material
432   G4msg4mate::const_iterator cite = theG4Mater << 449   G4msg4mate::const_iterator cite = theG4Materials.find( name );
433   if(cite != theG4Materials.cend())            << 450   if( cite != theG4Materials.end() )
434   {                                               451   {
435     g4mate = (*cite).second;                      452     g4mate = (*cite).second;
436 #ifdef G4VERBOSE                                  453 #ifdef G4VERBOSE
437     if(G4tgrMessenger::GetVerboseLevel() >= 2) << 454     if( G4tgrMessenger::GetVerboseLevel() >= 2 )
438     {                                             455     {
439       G4cout << " G4tgbMaterialMgr::FindBuiltG << 456       G4cout << " G4tgbMaterialMgr::FindBuiltG4Material() - Material: "
440              << " = " << g4mate << G4endl;     << 457              << name << " = " << g4mate << G4endl;
441     }                                             458     }
442 #endif                                            459 #endif
443   }                                               460   }
444                                                   461 
445   return g4mate;                                  462   return g4mate;
446 }                                                 463 }
447                                                   464 
                                                   >> 465 
448 // -------------------------------------------    466 // -------------------------------------------------------------------------
449 G4tgbMaterial* G4tgbMaterialMgr::FindG4tgbMate << 467 G4tgbMaterial* G4tgbMaterialMgr::FindG4tgbMaterial(const G4String & name,
450                                                << 468                                                    G4bool bMustExist ) const 
451 {                                                 469 {
452   G4tgbMaterial* mate = nullptr;               << 470   G4tgbMaterial* mate = 0;
453   G4mstgbmate::const_iterator cite = theG4tgbM << 471   G4mstgbmate::const_iterator cite = theG4tgbMaterials.find( name );
454   if(cite != theG4tgbMaterials.cend())         << 472   if( cite != theG4tgbMaterials.end() )
455   {                                               473   {
456     mate = (*cite).second;                        474     mate = (*cite).second;
457 #ifdef G4VERBOSE                                  475 #ifdef G4VERBOSE
458     if(G4tgrMessenger::GetVerboseLevel() >= 2) << 476     if( G4tgrMessenger::GetVerboseLevel() >= 2 )
459     {                                             477     {
460       G4cout << " G4tgbMaterialMgr::FindG4tgbM    478       G4cout << " G4tgbMaterialMgr::FindG4tgbMaterial() -"
461              << " G4tgbMaterial found: " << (( << 479              << " G4tgbMaterial found: " << ( (*cite).second )->GetName()
462              << " type " << ((*cite).second)-> << 480              << " type " << ( (*cite).second )->GetName() << G4endl;
463     }                                             481     }
464 #endif                                            482 #endif
465   }                                               483   }
466                                                   484 
467   if((mate == nullptr) && bMustExist)          << 485   if( (mate == 0) && bMustExist )
468   {                                               486   {
469     G4String ErrMessage = "Material " + name +    487     G4String ErrMessage = "Material " + name + "  not found !";
470     G4Exception("G4tgbMaterialMgr::FindG4tgbMa << 488     G4Exception("G4tgbMaterialMgr::FindG4tgbMaterial()",
471                 FatalException, ErrMessage);   << 489                 "InvalidSetup", FatalException, ErrMessage);
472   }                                               490   }
473                                                   491 
474   return mate;                                    492   return mate;
475 }                                                 493 }
476                                                   494