54 const xercesc::DOMElement*
const atomElement)
59 const xercesc::DOMNamedNodeMap*
const attributes =
60 atomElement->getAttributes();
61 XMLSize_t attributeCount = attributes->getLength();
63 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
66 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
68 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
73 const xercesc::DOMAttr*
const attribute =
74 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
75 if(attribute ==
nullptr)
77 G4Exception(
"G4GDMLReadMaterials::AtomRead()",
"InvalidRead",
84 if(attName ==
"value")
88 else if(attName ==
"unit")
93 G4Exception(
"G4GDMLReadMaterials::AtomRead()",
"InvalidRead",
104 const xercesc::DOMElement*
const compositeElement,
G4String& ref)
108 const xercesc::DOMNamedNodeMap*
const attributes =
109 compositeElement->getAttributes();
110 XMLSize_t attributeCount = attributes->getLength();
112 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
115 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
117 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
122 const xercesc::DOMAttr*
const attribute =
123 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
124 if(attribute ==
nullptr)
126 G4Exception(
"G4GDMLReadMaterials::CompositeRead()",
"InvalidRead",
137 else if(attName ==
"ref")
152 const xercesc::DOMNamedNodeMap*
const attributes = DElement->getAttributes();
153 XMLSize_t attributeCount = attributes->getLength();
155 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
158 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
160 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
165 const xercesc::DOMAttr*
const attribute =
166 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
167 if(attribute ==
nullptr)
170 "No attribute found!");
176 if(attName ==
"value")
180 else if(attName ==
"unit")
185 G4Exception(
"G4GDMLReadMaterials::DRead()",
"InvalidRead",
200 const xercesc::DOMNamedNodeMap*
const attributes = PElement->getAttributes();
201 XMLSize_t attributeCount = attributes->getLength();
203 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
206 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
208 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
213 const xercesc::DOMAttr*
const attribute =
214 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
215 if(attribute ==
nullptr)
218 "No attribute found!");
224 if(attName ==
"value")
228 else if(attName ==
"unit")
233 G4Exception(
"G4GDMLReadMaterials::PRead()",
"InvalidRead",
248 const xercesc::DOMNamedNodeMap*
const attributes = TElement->getAttributes();
249 XMLSize_t attributeCount = attributes->getLength();
251 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
254 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
256 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
261 const xercesc::DOMAttr*
const attribute =
262 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
263 if(attribute ==
nullptr)
266 "No attribute found!");
272 if(attName ==
"value")
276 else if(attName ==
"unit")
281 G4Exception(
"G4GDMLReadMaterials::TRead()",
"InvalidRead",
296 const xercesc::DOMNamedNodeMap*
const attributes = PElement->getAttributes();
297 XMLSize_t attributeCount = attributes->getLength();
299 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
302 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
304 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
309 const xercesc::DOMAttr*
const attribute =
310 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
311 if(attribute ==
nullptr)
313 G4Exception(
"G4GDMLReadMaterials::MEERead()",
"InvalidRead",
320 if(attName ==
"value")
324 else if(attName ==
"unit")
329 G4Exception(
"G4GDMLReadMaterials::MEERead()",
"InvalidRead",
340 const xercesc::DOMElement*
const elementElement)
347 const xercesc::DOMNamedNodeMap*
const attributes =
348 elementElement->getAttributes();
349 XMLSize_t attributeCount = attributes->getLength();
351 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
354 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
356 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
361 const xercesc::DOMAttr*
const attribute =
362 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
363 if(attribute ==
nullptr)
365 G4Exception(
"G4GDMLReadMaterials::ElementRead()",
"InvalidRead",
372 if(attName ==
"name")
376 else if(attName ==
"formula")
380 else if(attName ==
"Z")
386 G4int nComponents = 0;
388 for(xercesc::DOMNode* iter = elementElement->getFirstChild(); iter !=
nullptr;
389 iter = iter->getNextSibling())
391 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
396 const xercesc::DOMElement*
const child =
397 dynamic_cast<xercesc::DOMElement*
>(iter);
400 G4Exception(
"G4GDMLReadMaterials::ElementRead()",
"InvalidRead",
410 else if(
tag ==
"fraction")
429 const xercesc::DOMElement*
const fractionElement,
G4String& ref)
433 const xercesc::DOMNamedNodeMap*
const attributes =
434 fractionElement->getAttributes();
435 XMLSize_t attributeCount = attributes->getLength();
437 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
440 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
442 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
447 const xercesc::DOMAttr*
const attribute =
448 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
449 if(attribute ==
nullptr)
451 G4Exception(
"G4GDMLReadMaterials::FractionRead()",
"InvalidRead",
462 else if(attName ==
"ref")
473 const xercesc::DOMElement*
const isotopeElement)
480 const xercesc::DOMNamedNodeMap*
const attributes =
481 isotopeElement->getAttributes();
482 XMLSize_t attributeCount = attributes->getLength();
484 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
487 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
489 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
494 const xercesc::DOMAttr*
const attribute =
495 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
496 if(attribute ==
nullptr)
498 G4Exception(
"G4GDMLReadMaterials::IsotopeRead()",
"InvalidRead",
505 if(attName ==
"name")
509 else if(attName ==
"Z")
513 else if(attName ==
"N")
519 for(xercesc::DOMNode* iter = isotopeElement->getFirstChild(); iter !=
nullptr;
520 iter = iter->getNextSibling())
522 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
527 const xercesc::DOMElement*
const child =
528 dynamic_cast<xercesc::DOMElement*
>(iter);
531 G4Exception(
"G4GDMLReadMaterials::IsotopeRead()",
"InvalidRead",
548 const xercesc::DOMElement*
const materialElement)
559 const xercesc::DOMNamedNodeMap*
const attributes =
560 materialElement->getAttributes();
561 XMLSize_t attributeCount = attributes->getLength();
563 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
566 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
568 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
573 const xercesc::DOMAttr*
const attribute =
574 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
575 if(attribute ==
nullptr)
577 G4Exception(
"G4GDMLReadMaterials::MaterialRead()",
"InvalidRead",
584 if(attName ==
"name")
588 else if(attName ==
"Z")
592 else if(attName ==
"state")
594 if(attValue ==
"solid")
598 else if(attValue ==
"liquid")
602 else if(attValue ==
"gas")
609 std::size_t nComponents = 0;
611 for(xercesc::DOMNode* iter = materialElement->getFirstChild();
612 iter !=
nullptr; iter = iter->getNextSibling())
614 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
619 const xercesc::DOMElement*
const child =
620 dynamic_cast<xercesc::DOMElement*
>(iter);
623 G4Exception(
"G4GDMLReadMaterials::MaterialRead()",
"InvalidRead",
633 else if(
tag ==
"Dref")
637 else if(
tag ==
"Pref")
641 else if(
tag ==
"Tref")
645 else if(
tag ==
"MEEref")
661 else if(
tag ==
"MEE")
665 else if(
tag ==
"fraction" ||
tag ==
"composite")
687 for(xercesc::DOMNode* iter = materialElement->getFirstChild();
688 iter !=
nullptr; iter = iter->getNextSibling())
690 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
695 const xercesc::DOMElement*
const child =
696 dynamic_cast<xercesc::DOMElement*
>(iter);
699 G4Exception(
"G4GDMLReadMaterials::MaterialRead()",
"InvalidRead",
705 if(
tag ==
"property")
714 const xercesc::DOMElement*
const mixtureElement,
G4Element* element)
716 for(xercesc::DOMNode* iter = mixtureElement->getFirstChild(); iter !=
nullptr;
717 iter = iter->getNextSibling())
719 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
724 const xercesc::DOMElement*
const child =
725 dynamic_cast<xercesc::DOMElement*
>(iter);
728 G4Exception(
"G4GDMLReadMaterials::MixtureRead()",
"InvalidRead",
734 if(
tag ==
"fraction")
745 const xercesc::DOMElement*
const mixtureElement,
G4Material* material)
747 for(xercesc::DOMNode* iter = mixtureElement->getFirstChild(); iter !=
nullptr;
748 iter = iter->getNextSibling())
750 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
755 const xercesc::DOMElement*
const child =
756 dynamic_cast<xercesc::DOMElement*
>(iter);
759 G4Exception(
"G4GDMLReadMaterials::MixtureRead()",
"InvalidRead",
765 if(
tag ==
"fraction")
773 if(elementPtr !=
nullptr)
777 else if(materialPtr !=
nullptr)
782 if((materialPtr ==
nullptr) && (elementPtr ==
nullptr))
784 G4String error_msg =
"Referenced material/element '" +
786 G4Exception(
"G4GDMLReadMaterials::MixtureRead()",
"InvalidSetup",
790 else if(
tag ==
"composite")
803 const xercesc::DOMElement*
const propertyElement,
G4Material* material)
809 const xercesc::DOMNamedNodeMap*
const attributes =
810 propertyElement->getAttributes();
811 XMLSize_t attributeCount = attributes->getLength();
813 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
816 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
818 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
823 const xercesc::DOMAttr*
const attribute =
824 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
825 if(attribute ==
nullptr)
827 G4Exception(
"G4GDMLReadMaterials::PropertyRead()",
"InvalidRead",
834 if(attName ==
"name")
838 else if(attName ==
"ref")
861 if(matprop ==
nullptr)
873 for(std::size_t i = 0; i < matrix.
GetRows(); ++i)
883 const xercesc::DOMElement*
const materialsElement)
888 for(xercesc::DOMNode* iter = materialsElement->getFirstChild();
889 iter !=
nullptr; iter = iter->getNextSibling())
891 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
896 const xercesc::DOMElement*
const child =
897 dynamic_cast<xercesc::DOMElement*
>(iter);
900 G4Exception(
"G4GDMLReadMaterials::MaterialsRead()",
"InvalidRead",
910 else if(
tag ==
"element")
914 else if(
tag ==
"isotope")
918 else if(
tag ==
"material")
924 G4String error_msg =
"Unknown tag in materials: " +
tag;
925 G4Exception(
"G4GDMLReadMaterials::MaterialsRead()",
"InvalidSetup",
937 if(elementPtr ==
nullptr)
942 if(verbose && elementPtr ==
nullptr)
944 G4String error_msg =
"Referenced element '" + ref +
"' was not found!";
945 G4Exception(
"G4GDMLReadMaterials::GetElement()",
"InvalidRead",
958 if(verbose && isotopePtr ==
nullptr)
960 G4String error_msg =
"Referenced isotope '" + ref +
"' was not found!";
961 G4Exception(
"G4GDMLReadMaterials::GetIsotope()",
"InvalidRead",
974 if(materialPtr ==
nullptr)
979 if(verbose && materialPtr ==
nullptr)
981 G4String error_msg =
"Referenced material '" + ref +
"' was not found!";
982 G4Exception(
"G4GDMLReadMaterials::GetMaterial()",
"InvalidRead",
G4double D(G4double temp)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4PhysicsFreeVector G4MaterialPropertyVector
G4GLOB_DLL std::ostream G4cout
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
static G4Element * GetElement(const G4String &name, G4bool warning=true)
G4double Evaluate(const G4String &)
G4int EvaluateInteger(const G4String &)
std::size_t GetCols() const
std::size_t GetRows() const
G4double Get(std::size_t r, std::size_t c) const
G4double GetQuantity(const G4String &)
G4GDMLMatrix GetMatrix(const G4String &)
G4String RefRead(const xercesc::DOMElement *const)
virtual void DefineRead(const xercesc::DOMElement *const)
void PropertyRead(const xercesc::DOMElement *const, G4Material *)
G4double MEERead(const xercesc::DOMElement *const)
void MixtureRead(const xercesc::DOMElement *const, G4Element *)
G4double DRead(const xercesc::DOMElement *const)
G4double AtomRead(const xercesc::DOMElement *const)
G4Material * GetMaterial(const G4String &, G4bool verbose=true) const
G4Element * GetElement(const G4String &, G4bool verbose=true) const
G4double PRead(const xercesc::DOMElement *const)
virtual ~G4GDMLReadMaterials()
G4Isotope * GetIsotope(const G4String &, G4bool verbose=true) const
G4int CompositeRead(const xercesc::DOMElement *const, G4String &)
virtual void MaterialsRead(const xercesc::DOMElement *const)
G4double TRead(const xercesc::DOMElement *const)
G4double FractionRead(const xercesc::DOMElement *const, G4String &)
void ElementRead(const xercesc::DOMElement *const)
void IsotopeRead(const xercesc::DOMElement *const)
void MaterialRead(const xercesc::DOMElement *const)
G4String Strip(const G4String &) const
G4String GenerateName(const G4String &name, G4bool strip=false)
G4String Transcode(const XMLCh *const)
void SetMeanExcitationEnergy(G4double value)
static G4Isotope * GetIsotope(const G4String &name, G4bool warning=false)
void AddConstProperty(const G4String &key, G4double propertyValue, G4bool createNewKey=false)
G4MaterialPropertyVector * AddProperty(const G4String &key, const std::vector< G4double > &photonEnergies, const std::vector< G4double > &propertyValues, G4bool createNewKey=false, G4bool spline=false)
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
G4IonisParamMat * GetIonisation() const
void AddElement(G4Element *elm, G4int nAtoms)
void AddMaterial(G4Material *material, G4double fraction)
void SetMaterialPropertiesTable(G4MaterialPropertiesTable *anMPT)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static G4NistManager * Instance()
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
void InsertValues(const G4double energy, const G4double value)
static G4double GetValueOf(const G4String &)
static G4String GetCategory(const G4String &)