58AuxiliaryRead(
const xercesc::DOMElement*
const auxiliaryElement)
62 const xercesc::DOMNamedNodeMap*
const attributes
63 = auxiliaryElement->getAttributes();
64 XMLSize_t attributeCount = attributes->getLength();
66 for (XMLSize_t attribute_index=0;
67 attribute_index<attributeCount; attribute_index++)
69 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
71 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
74 const xercesc::DOMAttr*
const attribute
75 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
85 if (attName==
"auxtype") { auxpair.
type = attValue; }
else
87 if (attName==
"auxvalue") { auxpair.
value = attValue; }
102 const xercesc::DOMNamedNodeMap*
const attributes
103 = bordersurfaceElement->getAttributes();
104 XMLSize_t attributeCount = attributes->getLength();
106 for (XMLSize_t attribute_index=0;
107 attribute_index<attributeCount; attribute_index++)
109 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
111 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
114 const xercesc::DOMAttr*
const attribute
115 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
118 G4Exception(
"G4GDMLReadStructure::BorderSurfaceRead()",
127 if (attName==
"surfaceproperty")
131 for (xercesc::DOMNode* iter = bordersurfaceElement->getFirstChild();
132 iter != 0; iter = iter->getNextSibling())
134 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
136 const xercesc::DOMElement*
const child
137 =
dynamic_cast<xercesc::DOMElement*
>(iter);
140 G4Exception(
"G4GDMLReadStructure::BorderSurfaceRead()",
146 if (
tag !=
"physvolref") {
continue; }
169 const xercesc::DOMNamedNodeMap*
const attributes
170 = divisionvolElement->getAttributes();
171 XMLSize_t attributeCount = attributes->getLength();
173 for (XMLSize_t attribute_index=0;
174 attribute_index<attributeCount; attribute_index++)
176 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
178 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
181 const xercesc::DOMAttr*
const attribute
182 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
185 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
192 if (attName==
"name") { name = attValue; }
else
193 if (attName==
"unit") { unit =
eval.
Evaluate(attValue); }
else
194 if (attName==
"width") { width =
eval.
Evaluate(attValue); }
else
195 if (attName==
"offset") { offset =
eval.
Evaluate(attValue); }
else
199 if (attValue==
"kXAxis") { axis =
kXAxis; }
else
200 if (attValue==
"kYAxis") { axis =
kYAxis; }
else
201 if (attValue==
"kZAxis") { axis =
kZAxis; }
else
202 if (attValue==
"kRho") { axis =
kRho; }
else
203 if (attValue==
"kPhi") { axis =
kPhi; }
210 for (xercesc::DOMNode* iter = divisionvolElement->getFirstChild();
211 iter != 0;iter = iter->getNextSibling())
213 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
215 const xercesc::DOMElement*
const child
216 =
dynamic_cast<xercesc::DOMElement*
>(iter);
219 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
228 if (!logvol) {
return; }
234 if ((number != 0) && (width == 0.0))
239 else if ((number == 0) && (width != 0.0))
255FileRead(
const xercesc::DOMElement*
const fileElement)
260 const xercesc::DOMNamedNodeMap*
const attributes
261 = fileElement->getAttributes();
262 XMLSize_t attributeCount = attributes->getLength();
264 for (XMLSize_t attribute_index=0;
265 attribute_index<attributeCount; attribute_index++)
267 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
269 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
272 const xercesc::DOMAttr*
const attribute
273 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
283 if (attName==
"name") { name = attValue; }
else
284 if (attName==
"volname") { volname = attValue; }
287 const G4bool isModule =
true;
296 G4GDMLAuxMapType::const_iterator pos;
297 for (pos = aux->begin(); pos != aux->end(); ++pos)
299 auxMap.insert(std::make_pair(pos->first,pos->second));
316PhysvolRead(
const xercesc::DOMElement*
const physvolElement,
326 const xercesc::DOMNamedNodeMap*
const attributes
327 = physvolElement->getAttributes();
328 XMLSize_t attributeCount = attributes->getLength();
330 for (XMLSize_t attribute_index=0;
331 attribute_index<attributeCount; attribute_index++)
333 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
335 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
338 const xercesc::DOMAttr*
const attribute
339 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
349 if (attName==
"name") { name = attValue; }
352 for (xercesc::DOMNode* iter = physvolElement->getFirstChild();
353 iter != 0; iter = iter->getNextSibling())
355 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
357 const xercesc::DOMElement*
const child
358 =
dynamic_cast<xercesc::DOMElement*
>(iter);
367 if (
tag==
"volumeref")
371 if (!assembly) { logvol =
GetVolume(child_name); }
373 else if (
tag==
"file")
375 else if (
tag==
"position")
377 else if (
tag==
"rotation")
379 else if (
tag==
"scale")
381 else if (
tag==
"positionref")
383 else if (
tag==
"rotationref")
385 else if (
tag==
"scaleref")
389 G4String error_msg =
"Unknown tag in physvol: " +
tag;
390 G4Exception(
"G4GDMLReadStructure::PhysvolRead()",
"ReadError",
397 transform = transform*
G4Scale3D(scale.
x(),scale.
y(),scale.
z());
401 if (!logvol) {
return; }
412 if (!logvol) {
return; }
427 for (xercesc::DOMNode* iter = replicavolElement->getFirstChild();
428 iter != 0; iter = iter->getNextSibling())
430 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
432 const xercesc::DOMElement*
const child
433 =
dynamic_cast<xercesc::DOMElement*
>(iter);
436 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
442 if (
tag==
"volumeref")
446 else if (
tag==
"replicate_along_axis")
452 G4String error_msg =
"Unknown tag in ReplicavolRead: " +
tag;
453 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
460ReplicaRead(
const xercesc::DOMElement*
const replicaElement,
470 for (xercesc::DOMNode* iter = replicaElement->getFirstChild();
471 iter != 0; iter = iter->getNextSibling())
473 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
475 const xercesc::DOMElement*
const child
476 =
dynamic_cast<xercesc::DOMElement*
>(iter);
489 if (
tag==
"positionref")
491 if (
tag==
"rotationref")
493 if (
tag==
"direction")
501 G4String error_msg =
"Unknown tag in ReplicaRead: " +
tag;
502 G4Exception(
"G4GDMLReadStructure::ReplicaRead()",
"ReadError",
517AxisRead(
const xercesc::DOMElement*
const axisElement)
521 const xercesc::DOMNamedNodeMap*
const attributes
522 = axisElement->getAttributes();
523 XMLSize_t attributeCount = attributes->getLength();
525 for (XMLSize_t attribute_index=0;
526 attribute_index<attributeCount; attribute_index++)
528 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
530 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
533 const xercesc::DOMAttr*
const attribute
534 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
545 else if (attName==
"y")
547 else if (attName==
"z")
549 else if (attName==
"rho")
551 else if (attName==
"phi")
559QuantityRead(
const xercesc::DOMElement*
const readElement)
563 const xercesc::DOMNamedNodeMap*
const attributes
564 = readElement->getAttributes();
565 XMLSize_t attributeCount = attributes->getLength();
567 for (XMLSize_t attribute_index=0;
568 attribute_index<attributeCount; attribute_index++)
570 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
572 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
574 const xercesc::DOMAttr*
const attribute
575 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
585 if (attName==
"unit") { unit =
eval.
Evaluate(attValue); }
else
586 if (attName==
"value"){ value=
eval.
Evaluate(attValue); }
593VolumeRead(
const xercesc::DOMElement*
const volumeElement)
599 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
601 xercesc::XMLString::release(&name_attr);
603 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
604 iter != 0; iter = iter->getNextSibling())
606 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
608 const xercesc::DOMElement*
const child
609 =
dynamic_cast<xercesc::DOMElement*
>(iter);
618 if (
tag==
"auxiliary")
620 if (
tag==
"materialref")
635AssemblyRead(
const xercesc::DOMElement*
const assemblyElement)
637 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
639 xercesc::XMLString::release(&name_attr);
644 for (xercesc::DOMNode* iter = assemblyElement->getFirstChild();
645 iter != 0; iter = iter->getNextSibling())
647 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
648 const xercesc::DOMElement*
const child
649 =
dynamic_cast<xercesc::DOMElement*
>(iter);
664 G4cout <<
"Unsupported GDML tag '" <<
tag
665 <<
"' for Geant4 assembly structure !" <<
G4endl;
677 const xercesc::DOMNamedNodeMap*
const attributes
678 = skinsurfaceElement->getAttributes();
679 XMLSize_t attributeCount = attributes->getLength();
681 for (XMLSize_t attribute_index=0;
682 attribute_index<attributeCount; attribute_index++)
684 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
686 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
689 const xercesc::DOMAttr*
const attribute
690 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
693 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
702 if (attName==
"surfaceproperty")
706 for (xercesc::DOMNode* iter = skinsurfaceElement->getFirstChild();
707 iter != 0; iter = iter->getNextSibling())
709 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
711 const xercesc::DOMElement*
const child
712 =
dynamic_cast<xercesc::DOMElement*
>(iter);
715 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
721 if (
tag==
"volumeref")
727 G4String error_msg =
"Unknown tag in skinsurface: " +
tag;
728 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
"ReadError",
739 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
740 iter != 0; iter = iter->getNextSibling())
742 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
744 const xercesc::DOMElement*
const child
745 =
dynamic_cast<xercesc::DOMElement*
>(iter);
748 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
754 if ((
tag==
"auxiliary") || (
tag==
"materialref") || (
tag==
"solidref"))
758 else if (
tag==
"paramvol")
762 else if (
tag==
"physvol")
766 else if (
tag==
"replicavol")
769 const xercesc::DOMNamedNodeMap*
const attributes
770 = child->getAttributes();
771 XMLSize_t attributeCount = attributes->getLength();
772 for (XMLSize_t attribute_index=0;
773 attribute_index<attributeCount; attribute_index++)
775 xercesc::DOMNode* attribute_node
776 = attributes->item(attribute_index);
777 if (attribute_node->getNodeType()!=xercesc::DOMNode::ATTRIBUTE_NODE)
781 const xercesc::DOMAttr*
const attribute
782 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
785 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
791 if (attName==
"number")
798 else if (
tag==
"divisionvol")
802 else if (
tag==
"loop")
808 G4cout <<
"Treating unknown GDML tag in volume '" <<
tag
809 <<
"' as GDML extension..." <<
G4endl;
815StructureRead(
const xercesc::DOMElement*
const structureElement)
819 for (xercesc::DOMNode* iter = structureElement->getFirstChild();
820 iter != 0; iter = iter->getNextSibling())
822 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
824 const xercesc::DOMElement*
const child
825 =
dynamic_cast<xercesc::DOMElement*
>(iter);
828 G4Exception(
"G4GDMLReadStructure::StructureRead()",
841 G4String error_msg =
"Unknown tag in structure: " +
tag;
842 G4Exception(
"G4GDMLReadStructure::StructureRead()",
856 G4String error_msg =
"Referenced physvol '" + ref +
"' was not found!";
857 G4Exception(
"G4GDMLReadStructure::GetPhysvol()",
"ReadError",
872 G4String error_msg =
"Referenced volume '" + ref +
"' was not found!";
873 G4Exception(
"G4GDMLReadStructure::GetVolume()",
"ReadError",
883 G4GDMLAssemblyMapType::const_iterator pos =
assemblyMap.find(ref);
884 if (pos !=
assemblyMap.end()) {
return pos->second; }
891 G4GDMLAuxMapType::const_iterator pos =
auxMap.find(logvol);
892 if (pos !=
auxMap.end()) {
return pos->second; }
917 volume->
GetName()+
"_PV",0,0,0);
std::map< G4LogicalVolume *, G4GDMLAuxListType > G4GDMLAuxMapType
std::vector< G4GDMLAuxPairType > G4GDMLAuxListType
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
CLHEP::Hep3Vector G4ThreeVector
G4DLLIMPORT std::ostream G4cout
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool surfCheck=false)
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation)
G4double Evaluate(const G4String &)
G4int EvaluateInteger(const G4String &)
G4ThreeVector GetScale(const G4String &)
void VectorRead(const xercesc::DOMElement *const, G4ThreeVector &)
G4RotationMatrix GetRotationMatrix(const G4ThreeVector &)
G4ThreeVector GetPosition(const G4String &)
G4String RefRead(const xercesc::DOMElement *const)
G4ThreeVector GetRotation(const G4String &)
G4Material * GetMaterial(const G4String &, G4bool verbose=true) const
virtual void ParamvolRead(const xercesc::DOMElement *const, G4LogicalVolume *)
G4String GetSetup(const G4String &)
G4SurfaceProperty * GetSurfaceProperty(const G4String &) const
G4VSolid * GetSolid(const G4String &) const
const G4GDMLAuxMapType * GetAuxMap() const
void BorderSurfaceRead(const xercesc::DOMElement *const)
virtual void Volume_contentRead(const xercesc::DOMElement *const)
virtual void StructureRead(const xercesc::DOMElement *const)
void AssemblyRead(const xercesc::DOMElement *const)
G4LogicalVolume * GetVolume(const G4String &) const
void PhysvolRead(const xercesc::DOMElement *const, G4AssemblyVolume *assembly=0)
void ReplicaRead(const xercesc::DOMElement *const replicaElement, G4LogicalVolume *logvol, G4int number)
EAxis AxisRead(const xercesc::DOMElement *const axisElement)
G4VPhysicalVolume * GetWorldVolume(const G4String &)
G4double QuantityRead(const xercesc::DOMElement *const readElement)
void DivisionvolRead(const xercesc::DOMElement *const)
std::map< std::string, G4VPhysicalVolume * > setuptoPV
void SkinSurfaceRead(const xercesc::DOMElement *const)
G4LogicalVolume * pMotherLogical
virtual ~G4GDMLReadStructure()
void ReplicavolRead(const xercesc::DOMElement *const, G4int number)
G4GDMLAuxPairType AuxiliaryRead(const xercesc::DOMElement *const)
virtual void VolumeRead(const xercesc::DOMElement *const)
G4GDMLAssemblyMapType assemblyMap
G4VPhysicalVolume * GetPhysvol(const G4String &) const
G4AssemblyVolume * GetAssembly(const G4String &) const
G4LogicalVolume * FileRead(const xercesc::DOMElement *const)
G4GDMLAuxListType GetVolumeAuxiliaryInformation(G4LogicalVolume *) const
G4String Strip(const G4String &) const
void GeneratePhysvolName(const G4String &, G4VPhysicalVolume *)
G4String GenerateName(const G4String &name, G4bool strip=false)
void LoopRead(const xercesc::DOMElement *const, void(G4GDMLRead::*)(const xercesc::DOMElement *const))
virtual void Volume_contentRead(const xercesc::DOMElement *const)=0
void Read(const G4String &, G4bool validation, G4bool isModule, G4bool strip=true)
G4String Transcode(const XMLCh *const)
virtual void StructureRead(const xercesc::DOMElement *const)=0
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
static G4LogicalVolumeStore * GetInstance()
void SetVisAttributes(const G4VisAttributes *pVA)
static G4PVDivisionFactory * GetInstance()
static G4PhysicalVolumeStore * GetInstance()
G4VPhysicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
G4PhysicalVolumesPair Divide(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofDivisions, G4double width, G4double offset)
static G4ReflectionFactory * Instance()
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
G4PhysicalVolumesPair Replicate(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofReplicas, G4double width, G4double offset=0)
static const G4VisAttributes Invisible
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)