| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // File name: RadmonMaterialsManager.cc
|
|---|
| 28 | // Creation date: Sep 2005
|
|---|
| 29 | // Main author: Riccardo Capra <capra@ge.infn.it>
|
|---|
| 30 | //
|
|---|
| 31 | // Id: $Id: RadmonMaterialsManager.cc,v 1.4 2006/06/29 16:16:51 gunter Exp $
|
|---|
| 32 | // Tag: $Name: $
|
|---|
| 33 | //
|
|---|
| 34 |
|
|---|
| 35 | // Include files
|
|---|
| 36 | #include "RadmonMaterialsManager.hh"
|
|---|
| 37 | #include "RadmonMaterialsMessenger.hh"
|
|---|
| 38 | #include "RadmonMaterialsDumpStyle.hh"
|
|---|
| 39 | #include "G4UnitsTable.hh"
|
|---|
| 40 | #include "G4VisAttributes.hh"
|
|---|
| 41 | #include "G4Color.hh"
|
|---|
| 42 |
|
|---|
| 43 | #include <iomanip>
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | RadmonMaterialsManager * RadmonMaterialsManager :: Instance(void)
|
|---|
| 50 | {
|
|---|
| 51 | if (!instance)
|
|---|
| 52 | {
|
|---|
| 53 | instance=new RadmonMaterialsManager;
|
|---|
| 54 |
|
|---|
| 55 | if (!instance)
|
|---|
| 56 | G4Exception("RadmonMaterialsManager::Instance: RadmonMaterialsManager singleton not allocated.");
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | return instance;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | G4Element & RadmonMaterialsManager :: CreateElement(const G4String & elementName, const G4String & symbol, G4double zEff, G4double aEff)
|
|---|
| 67 | {
|
|---|
| 68 | G4Element * element(FindElement(elementName));
|
|---|
| 69 |
|
|---|
| 70 | if (element!=0)
|
|---|
| 71 | {
|
|---|
| 72 | G4cout << "RadmonMaterialsManager::CreateElement: Element \"" << elementName << "\" just exists." << G4endl;
|
|---|
| 73 | return (* element);
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | element=new G4Element(elementName, symbol, zEff, aEff);
|
|---|
| 77 |
|
|---|
| 78 | if (element==0)
|
|---|
| 79 | {
|
|---|
| 80 | G4String text("RadmonMaterialsManager::CreateElement: Element \"");
|
|---|
| 81 | text+=elementName;
|
|---|
| 82 | text+="\" not created.";
|
|---|
| 83 |
|
|---|
| 84 | G4Exception(text);
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | return (* element);
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | G4Element & RadmonMaterialsManager :: GetElement(const G4String & elementName)
|
|---|
| 93 | {
|
|---|
| 94 | G4Element * element(FindElement(elementName));
|
|---|
| 95 |
|
|---|
| 96 | if (element)
|
|---|
| 97 | return (* element);
|
|---|
| 98 |
|
|---|
| 99 | G4String text("RadmonMaterialsManager::GetElement: Element \"");
|
|---|
| 100 | text+=elementName;
|
|---|
| 101 | text+="\" not found.";
|
|---|
| 102 |
|
|---|
| 103 | G4Exception(text);
|
|---|
| 104 | return (* element);
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 | G4bool RadmonMaterialsManager :: ExistsElement(const G4String & elementName) const
|
|---|
| 110 | {
|
|---|
| 111 | return const_cast<RadmonMaterialsManager *>(this)->FindElement(elementName)!=0;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 | void RadmonMaterialsManager :: CreateMaterial(const G4String & materialName, G4double density, G4int nComponents)
|
|---|
| 119 | {
|
|---|
| 120 | if (FindMaterial(materialName)!=0 || FindIncompleteMaterial(materialName)!=0)
|
|---|
| 121 | {
|
|---|
| 122 | G4cout << "RadmonMaterialsManager::CreateMaterial: Material \"" << materialName << "\" just exists." << G4endl;
|
|---|
| 123 | return;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | if (nComponents==0)
|
|---|
| 127 | {
|
|---|
| 128 | G4String text("RadmonMaterialsManager::CreateMaterial: Material \"");
|
|---|
| 129 | text+=materialName;
|
|---|
| 130 | text+="\" must have at least one component.";
|
|---|
| 131 |
|
|---|
| 132 | G4Exception(text);
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | G4Material * material(new G4Material(materialName, density, nComponents));
|
|---|
| 136 |
|
|---|
| 137 | if (material==0)
|
|---|
| 138 | {
|
|---|
| 139 | G4String text("RadmonMaterialsManager::CreateMaterial: Material \"");
|
|---|
| 140 | text+=materialName;
|
|---|
| 141 | text+="\" not created.";
|
|---|
| 142 |
|
|---|
| 143 | G4Exception(text);
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | incompleteMaterialsList.push_back(material);
|
|---|
| 147 | G4VisAttributes * visAttributes(new G4VisAttributes);
|
|---|
| 148 | attributesMap[materialName]=visAttributes;
|
|---|
| 149 | visAttributes->SetColor(1., 1., 1., 1.);
|
|---|
| 150 | visAttributes->SetVisibility(true);
|
|---|
| 151 |
|
|---|
| 152 | return;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 | void RadmonMaterialsManager :: AddComponentByAtoms(const G4String & materialName, const G4String & elementName, G4int nAtoms)
|
|---|
| 158 | {
|
|---|
| 159 | G4Material * material(FindIncompleteMaterialOrAbort(materialName));
|
|---|
| 160 | G4Element & element(GetElement(elementName));
|
|---|
| 161 |
|
|---|
| 162 | material->AddElement(&element, nAtoms);
|
|---|
| 163 |
|
|---|
| 164 | UpdateIncompleteStatus(materialName);
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 | void RadmonMaterialsManager :: AddComponentByFraction(const G4String & materialName, const G4String & componentName, G4double fraction)
|
|---|
| 170 | {
|
|---|
| 171 | G4Material * material(FindIncompleteMaterialOrAbort(materialName));
|
|---|
| 172 |
|
|---|
| 173 | G4Material * componentMat(FindMaterial(componentName));
|
|---|
| 174 | if (componentMat)
|
|---|
| 175 | {
|
|---|
| 176 | material->AddMaterial(componentMat, fraction);
|
|---|
| 177 | UpdateIncompleteStatus(materialName);
|
|---|
| 178 | return;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | G4Element * componentElem(FindElement(componentName));
|
|---|
| 182 | if (componentElem)
|
|---|
| 183 | {
|
|---|
| 184 | material->AddElement(componentElem, fraction);
|
|---|
| 185 | UpdateIncompleteStatus(materialName);
|
|---|
| 186 | return;
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | G4String text("RadmonMaterialsManager::AddComponentByFraction: Component \"");
|
|---|
| 190 | text+=componentName;
|
|---|
| 191 | text+="\" not found.";
|
|---|
| 192 |
|
|---|
| 193 | G4Exception(text);
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 | G4Material & RadmonMaterialsManager :: GetMaterial(const G4String & materialName)
|
|---|
| 199 | {
|
|---|
| 200 | G4Material *material(FindMaterial(materialName));
|
|---|
| 201 |
|
|---|
| 202 | if (material)
|
|---|
| 203 | return (* material);
|
|---|
| 204 |
|
|---|
| 205 | G4String text("RadmonMaterialsManager::GetMaterial: Material \"");
|
|---|
| 206 | text+=materialName;
|
|---|
| 207 | text+="\" not found.";
|
|---|
| 208 |
|
|---|
| 209 | G4Exception(text);
|
|---|
| 210 | return (* material);
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 | G4bool RadmonMaterialsManager :: ExistsMaterial(const G4String & materialName) const
|
|---|
| 216 | {
|
|---|
| 217 | return const_cast<RadmonMaterialsManager *>(this)->FindMaterial(materialName)!=0;
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 |
|
|---|
| 223 |
|
|---|
| 224 | void RadmonMaterialsManager :: SetMaterialColor(const G4String & materialName, const G4Color & color)
|
|---|
| 225 | {
|
|---|
| 226 | if (attributesMap.find(materialName)==attributesMap.end())
|
|---|
| 227 | {
|
|---|
| 228 | G4cout << "RadmonMaterialsManager::SetMaterialColor: Material \"" << materialName << "\" does not exist." << G4endl;
|
|---|
| 229 | return;
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | attributesMap[materialName]->SetColor(color);
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 | void RadmonMaterialsManager :: SetMaterialVisibility(const G4String & materialName, G4bool visibility)
|
|---|
| 238 | {
|
|---|
| 239 | if (attributesMap.find(materialName)==attributesMap.end())
|
|---|
| 240 | {
|
|---|
| 241 | G4cout << "RadmonMaterialsManager::SetMaterialVisibility: Material \"" << materialName << "\" does not exist." << G4endl;
|
|---|
| 242 | return;
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | attributesMap[materialName]->SetVisibility(visibility);
|
|---|
| 246 | }
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 | void RadmonMaterialsManager :: SetMaterialForceWireframe(const G4String & materialName, G4bool force)
|
|---|
| 251 | {
|
|---|
| 252 | if (attributesMap.find(materialName)==attributesMap.end())
|
|---|
| 253 | {
|
|---|
| 254 | G4cout << "RadmonMaterialsManager::SetMaterialForceWireframe: Material \"" << materialName << "\" does not exist." << G4endl;
|
|---|
| 255 | return;
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | attributesMap[materialName]->SetForceWireframe(force);
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 | void RadmonMaterialsManager :: SetMaterialForceSolid(const G4String & materialName, G4bool force)
|
|---|
| 264 | {
|
|---|
| 265 | if (attributesMap.find(materialName)==attributesMap.end())
|
|---|
| 266 | {
|
|---|
| 267 | G4cout << "RadmonMaterialsManager::SetMaterialForceSolid: Material \"" << materialName << "\" does not exist." << G4endl;
|
|---|
| 268 | return;
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | attributesMap[materialName]->SetForceSolid(force);
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 | const G4Color & RadmonMaterialsManager :: GetMaterialColor(const G4String & materialName) const
|
|---|
| 279 | {
|
|---|
| 280 | MaterialAttributes::const_iterator i(attributesMap.find(materialName));
|
|---|
| 281 |
|
|---|
| 282 | if (i==attributesMap.end())
|
|---|
| 283 | {
|
|---|
| 284 | static G4Color white(1., 1., 1., 1.);
|
|---|
| 285 | G4cout << "RadmonMaterialsManager::GetMaterialColor: Material \"" << materialName << "\" does not exist." << G4endl;
|
|---|
| 286 |
|
|---|
| 287 | return white;
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 | return i->second->GetColor();
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 | G4bool RadmonMaterialsManager :: GetMaterialVisibility(const G4String & materialName) const
|
|---|
| 296 | {
|
|---|
| 297 | MaterialAttributes::const_iterator i(attributesMap.find(materialName));
|
|---|
| 298 |
|
|---|
| 299 | if (i==attributesMap.end())
|
|---|
| 300 | {
|
|---|
| 301 | G4cout << "RadmonMaterialsManager::GetMaterialVisibility: Material \"" << materialName << "\" does not exist." << G4endl;
|
|---|
| 302 | return true;
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | return i->second->IsVisible();
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 | G4bool RadmonMaterialsManager :: GetMaterialForceWireframe(const G4String & materialName) const
|
|---|
| 311 | {
|
|---|
| 312 | MaterialAttributes::const_iterator i(attributesMap.find(materialName));
|
|---|
| 313 |
|
|---|
| 314 | if (i==attributesMap.end())
|
|---|
| 315 | {
|
|---|
| 316 | G4cout << "RadmonMaterialsManager::GetMaterialForceWireframe: Material \"" << materialName << "\" does not exist." << G4endl;
|
|---|
| 317 | return false;
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 | if (!i->second->IsForceDrawingStyle())
|
|---|
| 321 | return false;
|
|---|
| 322 |
|
|---|
| 323 | return i->second->GetForcedDrawingStyle()==G4VisAttributes::wireframe;
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 | G4bool RadmonMaterialsManager :: GetMaterialForceSolid(const G4String & materialName) const
|
|---|
| 329 | {
|
|---|
| 330 | MaterialAttributes::const_iterator i(attributesMap.find(materialName));
|
|---|
| 331 |
|
|---|
| 332 | if (i==attributesMap.end())
|
|---|
| 333 | {
|
|---|
| 334 | G4cout << "RadmonMaterialsManager::GetMaterialForceSolid: Material \"" << materialName << "\" does not exist." << G4endl;
|
|---|
| 335 | return false;
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | if (!i->second->IsForceDrawingStyle())
|
|---|
| 339 | return false;
|
|---|
| 340 |
|
|---|
| 341 | return i->second->GetForcedDrawingStyle()==G4VisAttributes::solid;
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 | void RadmonMaterialsManager :: Dump(std::ostream & out, const G4String &indent) const
|
|---|
| 349 | {
|
|---|
| 350 | G4int width(RADMONMATERIALDUMP_INDENT_WIDTH-indent.length());
|
|---|
| 351 | if (width<0)
|
|---|
| 352 | width=0;
|
|---|
| 353 |
|
|---|
| 354 | G4String indent2(indent);
|
|---|
| 355 | indent2.prepend(" ");
|
|---|
| 356 | G4int width2(width-2);
|
|---|
| 357 | if (width2<0)
|
|---|
| 358 | width2=0;
|
|---|
| 359 |
|
|---|
| 360 | G4String indent3(indent2);
|
|---|
| 361 | indent3.prepend(" ");
|
|---|
| 362 | G4int width3(width2-2);
|
|---|
| 363 | if (width3<0)
|
|---|
| 364 | width3=0;
|
|---|
| 365 |
|
|---|
| 366 | out << indent << "Elements:\n";
|
|---|
| 367 |
|
|---|
| 368 | G4int n(GetNElements());
|
|---|
| 369 |
|
|---|
| 370 | if (n==0)
|
|---|
| 371 | out << indent2 << "No elements defined.\n\n";
|
|---|
| 372 | else
|
|---|
| 373 | {
|
|---|
| 374 | const G4Element * element;
|
|---|
| 375 |
|
|---|
| 376 | for (G4int i(0); i<n; i++)
|
|---|
| 377 | {
|
|---|
| 378 | element=&GetElement(i);
|
|---|
| 379 | out << indent2 << "Element # " << i << '\n'
|
|---|
| 380 | << indent3 << std::setw(width3); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Name"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = \"" << element->GetName() << "\"\n"
|
|---|
| 381 | << indent3 << std::setw(width3); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Zeff"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = " << std::setprecision(RADMONMATERIALDUMP_DOUBLE_PRECISION) << std::setw(RADMONMATERIALDUMP_DOUBLE_WIDTH) << element->GetZ() << '\n'
|
|---|
| 382 | << indent3 << std::setw(width3); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Aeff"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = " << std::setprecision(RADMONMATERIALDUMP_DOUBLE_PRECISION) << std::setw(RADMONMATERIALDUMP_DOUBLE_WIDTH) << G4BestUnit(element->GetA(), "Molar Mass") << "\n\n";
|
|---|
| 383 | }
|
|---|
| 384 | }
|
|---|
| 385 |
|
|---|
| 386 | out << indent << "Materials:\n";
|
|---|
| 387 |
|
|---|
| 388 | n=GetNMaterials();
|
|---|
| 389 |
|
|---|
| 390 | if (n==0)
|
|---|
| 391 | out << indent2 << "No materials defined.\n";
|
|---|
| 392 | else
|
|---|
| 393 | {
|
|---|
| 394 | const G4Material * material;
|
|---|
| 395 | G4int m;
|
|---|
| 396 |
|
|---|
| 397 | G4String indent4(indent3);
|
|---|
| 398 | indent4.prepend(" ");
|
|---|
| 399 | G4int width4(width3-2);
|
|---|
| 400 | if (width4<0)
|
|---|
| 401 | width4=0;
|
|---|
| 402 |
|
|---|
| 403 | const G4double * massFractions;
|
|---|
| 404 | const G4double * nAtoms;
|
|---|
| 405 |
|
|---|
| 406 | for (G4int i(0); i<n; i++)
|
|---|
| 407 | {
|
|---|
| 408 | if (i>0)
|
|---|
| 409 | out << '\n';
|
|---|
| 410 |
|
|---|
| 411 | material=&GetMaterial(i);
|
|---|
| 412 | out << indent2 << "Material # " << i << '\n'
|
|---|
| 413 | << indent3 << std::setw(width3); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Name"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = \"" << material->GetName() << "\"\n"
|
|---|
| 414 | << indent3 << std::setw(width3); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Density"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = " << std::setprecision(RADMONMATERIALDUMP_DOUBLE_PRECISION) << std::setw(RADMONMATERIALDUMP_DOUBLE_WIDTH) << G4BestUnit(material->GetDensity(), "Volumic Mass") << '\n';
|
|---|
| 415 |
|
|---|
| 416 | m=material->GetNumberOfElements();
|
|---|
| 417 | massFractions=material->GetFractionVector();
|
|---|
| 418 | nAtoms=material->GetVecNbOfAtomsPerVolume();
|
|---|
| 419 |
|
|---|
| 420 | for (G4int j(0); j<m; j++)
|
|---|
| 421 | {
|
|---|
| 422 | out << indent4 << std::setw(width4); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Element"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = \"" << material->GetElement(j)->GetName() << "\"\n"
|
|---|
| 423 | << std::setw(indent4.length()) << "" << std::setw(width4); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Mass fraction"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = " << std::setprecision(RADMONMATERIALDUMP_PERCENT_PRECISION) << std::setw(RADMONMATERIALDUMP_PERCENT_WIDTH) << (massFractions[j]/perCent) << " %\n"
|
|---|
| 424 | << std::setw(indent4.length()) << "" << std::setw(width4); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Abundance"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = " << std::setprecision(RADMONMATERIALDUMP_PERCENT_PRECISION) << std::setw(RADMONMATERIALDUMP_PERCENT_WIDTH) << (nAtoms[j]/(perCent*material->GetTotNbOfAtomsPerVolume())) << " %\n";
|
|---|
| 425 | }
|
|---|
| 426 | }
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | if (!incompleteMaterialsList.empty())
|
|---|
| 430 | {
|
|---|
| 431 | out << '\n' << indent << "Materials to be completed:\n";
|
|---|
| 432 |
|
|---|
| 433 | MaterialsList::const_iterator i(incompleteMaterialsList.begin());
|
|---|
| 434 | MaterialsList::const_iterator end(incompleteMaterialsList.end());
|
|---|
| 435 |
|
|---|
| 436 | while (i!=end)
|
|---|
| 437 | {
|
|---|
| 438 | out << indent2 << std::setw(width2); out.setf(std::ostream::left, std::ostream::adjustfield); out << "Name"; out.setf(std::ostream::right, std::ostream::adjustfield); out << " = \"" << (*i)->GetName() << "\"\n";
|
|---|
| 439 | i++;
|
|---|
| 440 | }
|
|---|
| 441 | }
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
|
|---|
| 448 | G4bool RadmonMaterialsManager :: Insert(std::istream & /* in */)
|
|---|
| 449 | {
|
|---|
| 450 | // TO BE DONE
|
|---|
| 451 | G4cout << "RadmonMaterialsManager::Insert(): PLEASE CHECK" << G4endl;
|
|---|
| 452 |
|
|---|
| 453 | return false;
|
|---|
| 454 | }
|
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 |
|
|---|
| 458 | G4bool RadmonMaterialsManager :: Save(std::ostream & /* out */) const
|
|---|
| 459 | {
|
|---|
| 460 | // TO BE DONE
|
|---|
| 461 | G4cout << "RadmonMaterialsManager::Save(): PLEASE CHECK" << G4endl;
|
|---|
| 462 |
|
|---|
| 463 | return false;
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 |
|
|---|
| 470 | inline G4Element * RadmonMaterialsManager :: FindElement(const G4String & elementName)
|
|---|
| 471 | {
|
|---|
| 472 | G4int n(GetNElements());
|
|---|
| 473 | G4Element * element;
|
|---|
| 474 |
|
|---|
| 475 | while (n>0)
|
|---|
| 476 | {
|
|---|
| 477 | n--;
|
|---|
| 478 | element=&GetElement(n);
|
|---|
| 479 |
|
|---|
| 480 | if (element->GetName()==elementName)
|
|---|
| 481 | return element;
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | return 0;
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 |
|
|---|
| 488 |
|
|---|
| 489 | inline G4Material * RadmonMaterialsManager :: FindMaterial(const G4String & materialName)
|
|---|
| 490 | {
|
|---|
| 491 | G4int n(GetNMaterials());
|
|---|
| 492 | G4Material * material;
|
|---|
| 493 |
|
|---|
| 494 | while (n>0)
|
|---|
| 495 | {
|
|---|
| 496 | n--;
|
|---|
| 497 | material=&GetMaterial(n);
|
|---|
| 498 |
|
|---|
| 499 | if (material->GetName()==materialName)
|
|---|
| 500 | return material;
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | return 0;
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 | G4Material * RadmonMaterialsManager :: FindIncompleteMaterial(const G4String & materialName)
|
|---|
| 509 | {
|
|---|
| 510 | MaterialsList::iterator i(incompleteMaterialsList.begin());
|
|---|
| 511 | MaterialsList::iterator end(incompleteMaterialsList.end());
|
|---|
| 512 |
|
|---|
| 513 | while (i!=end)
|
|---|
| 514 | {
|
|---|
| 515 | if ((*i)->GetName()==materialName)
|
|---|
| 516 | return (*i);
|
|---|
| 517 |
|
|---|
| 518 | i++;
|
|---|
| 519 | }
|
|---|
| 520 |
|
|---|
| 521 | return 0;
|
|---|
| 522 | }
|
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 | G4Material * RadmonMaterialsManager :: FindIncompleteMaterialOrAbort(const G4String & materialName)
|
|---|
| 527 | {
|
|---|
| 528 | G4Material * material(FindIncompleteMaterial(materialName));
|
|---|
| 529 |
|
|---|
| 530 | if (material)
|
|---|
| 531 | return material;
|
|---|
| 532 |
|
|---|
| 533 | if (&GetMaterial(materialName))
|
|---|
| 534 | {
|
|---|
| 535 | G4String text("RadmonMaterialsManager::FindIncompleteMaterialOrAbort: Material \"");
|
|---|
| 536 | text+=materialName;
|
|---|
| 537 | text+="\" does not need further components.";
|
|---|
| 538 |
|
|---|
| 539 | G4Exception(text);
|
|---|
| 540 | }
|
|---|
| 541 |
|
|---|
| 542 | return 0;
|
|---|
| 543 | }
|
|---|
| 544 |
|
|---|
| 545 |
|
|---|
| 546 |
|
|---|
| 547 | void RadmonMaterialsManager :: UpdateIncompleteStatus(const G4String & materialName)
|
|---|
| 548 | {
|
|---|
| 549 | if (!FindMaterial(materialName))
|
|---|
| 550 | return;
|
|---|
| 551 |
|
|---|
| 552 | MaterialsList::iterator i(incompleteMaterialsList.begin());
|
|---|
| 553 | MaterialsList::iterator end(incompleteMaterialsList.end());
|
|---|
| 554 |
|
|---|
| 555 | while (i!=end)
|
|---|
| 556 | {
|
|---|
| 557 | if ((*i)->GetName()==materialName)
|
|---|
| 558 | {
|
|---|
| 559 | incompleteMaterialsList.erase(i);
|
|---|
| 560 | return;
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | i++;
|
|---|
| 564 | }
|
|---|
| 565 | }
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
|
|---|
| 569 |
|
|---|
| 570 |
|
|---|
| 571 | inline RadmonMaterialsManager :: RadmonMaterialsManager()
|
|---|
| 572 | :
|
|---|
| 573 | messenger(new RadmonMaterialsMessenger(this))
|
|---|
| 574 | {
|
|---|
| 575 | new G4UnitDefinition("g/mole", "g/mole", "Molar Mass", g/mole);
|
|---|
| 576 | new G4UnitDefinition("mg/mole", "mg/mole", "Molar Mass", mg/mole);
|
|---|
| 577 | new G4UnitDefinition("kg/mole", "kg/mole", "Molar Mass", kg/mole);
|
|---|
| 578 |
|
|---|
| 579 | new G4Material("RADMON_VACUUM", 1., 1.01*g/mole, universe_mean_density, kStateGas, 0.1*kelvin, 1.e-19*pascal);
|
|---|
| 580 | }
|
|---|
| 581 |
|
|---|
| 582 |
|
|---|
| 583 |
|
|---|
| 584 | RadmonMaterialsManager :: ~RadmonMaterialsManager()
|
|---|
| 585 | {
|
|---|
| 586 | if (messenger)
|
|---|
| 587 | delete messenger;
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 |
|
|---|
| 591 |
|
|---|
| 592 |
|
|---|
| 593 |
|
|---|
| 594 | RadmonMaterialsManager * RadmonMaterialsManager :: instance(0);
|
|---|