59 const xercesc::DOMNamedNodeMap*
const attributes
60 = atomElement->getAttributes();
61 XMLSize_t attributeCount = attributes->getLength();
63 for (XMLSize_t attribute_index=0;
64 attribute_index<attributeCount; attribute_index++)
66 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
68 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
71 const xercesc::DOMAttr*
const attribute
72 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
75 G4Exception(
"G4GDMLReadMaterials::AtomRead()",
"InvalidRead",
82 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
else
94 const xercesc::DOMNamedNodeMap*
const attributes
95 = compositeElement->getAttributes();
96 XMLSize_t attributeCount = attributes->getLength();
98 for (XMLSize_t attribute_index=0;
99 attribute_index<attributeCount; attribute_index++)
101 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
103 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
106 const xercesc::DOMAttr*
const attribute
107 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
110 G4Exception(
"G4GDMLReadMaterials::CompositeRead()",
"InvalidRead",
118 if (attName==
"ref") { ref = attValue; }
129 const xercesc::DOMNamedNodeMap*
const attributes
130 = DElement->getAttributes();
131 XMLSize_t attributeCount = attributes->getLength();
133 for (XMLSize_t attribute_index=0;
134 attribute_index<attributeCount; attribute_index++)
136 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
138 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
141 const xercesc::DOMAttr*
const attribute
142 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
145 G4Exception(
"G4GDMLReadMaterials::DRead()",
"InvalidRead",
152 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
else
153 if (attName==
"unit") { unit =
eval.
Evaluate(attValue); }
164 const xercesc::DOMNamedNodeMap*
const attributes = PElement->getAttributes();
165 XMLSize_t attributeCount = attributes->getLength();
167 for (XMLSize_t attribute_index=0;
168 attribute_index<attributeCount; attribute_index++)
170 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
172 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
175 const xercesc::DOMAttr*
const attribute
176 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
179 G4Exception(
"G4GDMLReadMaterials::PRead()",
"InvalidRead",
186 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
else
187 if (attName==
"unit") { unit =
eval.
Evaluate(attValue); }
198 const xercesc::DOMNamedNodeMap*
const attributes = TElement->getAttributes();
199 XMLSize_t attributeCount = attributes->getLength();
201 for (XMLSize_t attribute_index=0;
202 attribute_index<attributeCount; attribute_index++)
204 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
206 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
209 const xercesc::DOMAttr*
const attribute
210 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
213 G4Exception(
"G4GDMLReadMaterials::TRead()",
"InvalidRead",
220 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
else
221 if (attName==
"unit") { unit =
eval.
Evaluate(attValue); }
232 const xercesc::DOMNamedNodeMap*
const attributes = PElement->getAttributes();
233 XMLSize_t attributeCount = attributes->getLength();
235 for (XMLSize_t attribute_index=0;
236 attribute_index<attributeCount; attribute_index++)
238 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
240 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
243 const xercesc::DOMAttr*
const attribute
244 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
247 G4Exception(
"G4GDMLReadMaterials::MEERead()",
"InvalidRead",
254 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
else
255 if (attName==
"unit") { unit =
eval.
Evaluate(attValue); }
262ElementRead(
const xercesc::DOMElement*
const elementElement)
269 const xercesc::DOMNamedNodeMap*
const attributes
270 = elementElement->getAttributes();
271 XMLSize_t attributeCount = attributes->getLength();
273 for (XMLSize_t attribute_index=0;
274 attribute_index<attributeCount; attribute_index++)
276 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
278 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
281 const xercesc::DOMAttr*
const attribute
282 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
285 G4Exception(
"G4GDMLReadMaterials::ElementRead()",
"InvalidRead",
292 if (attName==
"name") { name =
GenerateName(attValue); }
else
293 if (attName==
"formula") { formula = attValue; }
else
297 G4int nComponents = 0;
299 for (xercesc::DOMNode* iter = elementElement->getFirstChild();
300 iter != 0; iter = iter->getNextSibling())
302 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
304 const xercesc::DOMElement*
const child
305 =
dynamic_cast<xercesc::DOMElement*
>(iter);
308 G4Exception(
"G4GDMLReadMaterials::ElementRead()",
"InvalidRead",
315 if (
tag==
"fraction") { nComponents++; }
334 const xercesc::DOMNamedNodeMap*
const attributes
335 = fractionElement->getAttributes();
336 XMLSize_t attributeCount = attributes->getLength();
338 for (XMLSize_t attribute_index=0;
339 attribute_index<attributeCount; attribute_index++)
341 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
343 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
346 const xercesc::DOMAttr*
const attribute
347 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
350 G4Exception(
"G4GDMLReadMaterials::FractionRead()",
"InvalidRead",
358 if (attName==
"ref") { ref = attValue; }
365IsotopeRead(
const xercesc::DOMElement*
const isotopeElement)
372 const xercesc::DOMNamedNodeMap*
const attributes
373 = isotopeElement->getAttributes();
374 XMLSize_t attributeCount = attributes->getLength();
376 for (XMLSize_t attribute_index=0;
377 attribute_index<attributeCount;attribute_index++)
379 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
381 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
384 const xercesc::DOMAttr*
const attribute
385 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
388 G4Exception(
"G4GDMLReadMaterials::IsotopeRead()",
"InvalidRead",
395 if (attName==
"name") { name =
GenerateName(attValue); }
else
400 for (xercesc::DOMNode* iter = isotopeElement->getFirstChild();
401 iter != 0; iter = iter->getNextSibling())
403 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
405 const xercesc::DOMElement*
const child
406 =
dynamic_cast<xercesc::DOMElement*
>(iter);
409 G4Exception(
"G4GDMLReadMaterials::IsotopeRead()",
"InvalidRead",
422MaterialRead(
const xercesc::DOMElement*
const materialElement)
433 const xercesc::DOMNamedNodeMap*
const attributes
434 = materialElement->getAttributes();
435 XMLSize_t attributeCount = attributes->getLength();
437 for (XMLSize_t attribute_index=0;
438 attribute_index<attributeCount; attribute_index++)
440 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
442 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
445 const xercesc::DOMAttr*
const attribute
446 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
449 G4Exception(
"G4GDMLReadMaterials::MaterialRead()",
"InvalidRead",
456 if (attName==
"name") { name =
GenerateName(attValue); }
else
458 if (attName==
"state")
460 if (attValue==
"solid") { state =
kStateSolid; }
else
462 if (attValue==
"gas") { state =
kStateGas; }
466 size_t nComponents = 0;
468 for (xercesc::DOMNode* iter = materialElement->getFirstChild();
469 iter != 0; iter = iter->getNextSibling())
471 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
473 const xercesc::DOMElement*
const child
474 =
dynamic_cast<xercesc::DOMElement*
>(iter);
477 G4Exception(
"G4GDMLReadMaterials::MaterialRead()",
"InvalidRead",
488 if (
tag==
"D") { D =
DRead(child); }
else
489 if (
tag==
"P") { P =
PRead(child); }
else
490 if (
tag==
"T") { T =
TRead(child); }
else
491 if (
tag==
"MEE") { MEE =
MEERead(child); }
else
492 if (
tag==
"fraction" ||
tag==
"composite") { nComponents++; }
511 for (xercesc::DOMNode* iter = materialElement->getFirstChild();
512 iter != 0; iter = iter->getNextSibling())
514 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
516 const xercesc::DOMElement*
const child
517 =
dynamic_cast<xercesc::DOMElement*
>(iter);
520 G4Exception(
"G4GDMLReadMaterials::MaterialRead()",
"InvalidRead",
533 for (xercesc::DOMNode* iter = mixtureElement->getFirstChild();
534 iter != 0; iter = iter->getNextSibling())
536 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
538 const xercesc::DOMElement*
const child
539 =
dynamic_cast<xercesc::DOMElement*
>(iter);
542 G4Exception(
"G4GDMLReadMaterials::MixtureRead()",
"InvalidRead",
558MixtureRead(
const xercesc::DOMElement *
const mixtureElement,
561 for (xercesc::DOMNode* iter = mixtureElement->getFirstChild();
562 iter != 0; iter = iter->getNextSibling())
564 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
566 const xercesc::DOMElement*
const child
567 =
dynamic_cast<xercesc::DOMElement*
>(iter);
570 G4Exception(
"G4GDMLReadMaterials::MixtureRead()",
"InvalidRead",
584 if (materialPtr != 0) { material->
AddMaterial(materialPtr,n); }
else
585 if (elementPtr != 0) { material->
AddElement(elementPtr,n); }
587 if ((materialPtr == 0) && (elementPtr == 0))
589 G4String error_msg =
"Referenced material/element '"
591 G4Exception(
"G4GDMLReadMaterials::MixtureRead()",
"InvalidSetup",
595 else if (
tag==
"composite")
607PropertyRead(
const xercesc::DOMElement*
const propertyElement,
614 const xercesc::DOMNamedNodeMap*
const attributes
615 = propertyElement->getAttributes();
616 XMLSize_t attributeCount = attributes->getLength();
618 for (XMLSize_t attribute_index=0;
619 attribute_index<attributeCount; attribute_index++)
621 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
623 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
626 const xercesc::DOMAttr*
const attribute
627 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
630 G4Exception(
"G4GDMLReadMaterials::PropertyRead()",
"InvalidRead",
637 if (attName==
"name") { name =
GenerateName(attValue); }
else
638 if (attName==
"ref") { matrix =
GetMatrix(ref=attValue); }
652 if (matrix.
GetRows() == 0) {
return; }
667 for (
size_t i=0; i<matrix.
GetRows(); i++)
676MaterialsRead(
const xercesc::DOMElement*
const materialsElement)
680 for (xercesc::DOMNode* iter = materialsElement->getFirstChild();
681 iter != 0; iter = iter->getNextSibling())
683 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
685 const xercesc::DOMElement*
const child
686 =
dynamic_cast<xercesc::DOMElement*
>(iter);
689 G4Exception(
"G4GDMLReadMaterials::MaterialsRead()",
"InvalidRead",
701 G4String error_msg =
"Unknown tag in materials: " +
tag;
702 G4Exception(
"G4GDMLReadMaterials::MaterialsRead()",
"InvalidSetup",
718 if (verbose && !elementPtr)
720 G4String error_msg =
"Referenced element '" + ref +
"' was not found!";
721 G4Exception(
"G4GDMLReadMaterials::GetElement()",
"InvalidRead",
733 if (verbose && !isotopePtr)
735 G4String error_msg =
"Referenced isotope '" + ref +
"' was not found!";
736 G4Exception(
"G4GDMLReadMaterials::GetIsotope()",
"InvalidRead",
753 if (verbose && !materialPtr)
755 G4String error_msg =
"Referenced material '" + ref +
"' was not found!";
756 G4Exception(
"G4GDMLReadMaterials::GetMaterial()",
"InvalidRead",
G4PhysicsOrderedFreeVector G4MaterialPropertyVector
G4DLLIMPORT std::ostream G4cout
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
static G4Element * GetElement(G4String name, G4bool warning=true)
G4double Evaluate(const G4String &)
G4int EvaluateInteger(const G4String &)
G4double Get(size_t r, 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 char *key, G4double PropertyValue)
G4MaterialPropertyVector * AddProperty(const char *key, G4double *PhotonEnergies, G4double *PropertyValues, G4int NumEntries)
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
G4IonisParamMat * GetIonisation() const
void AddElement(G4Element *element, 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(G4double energy, G4double value)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)