59 const xercesc::DOMElement*
const bordersurfaceElement)
67 const xercesc::DOMNamedNodeMap*
const attributes =
68 bordersurfaceElement->getAttributes();
69 XMLSize_t attributeCount = attributes->getLength();
71 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
74 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
76 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
81 const xercesc::DOMAttr*
const attribute =
82 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
83 if(attribute ==
nullptr)
85 G4Exception(
"G4GDMLReadStructure::BorderSurfaceRead()",
"InvalidRead",
96 else if(attName ==
"surfaceproperty")
102 for(xercesc::DOMNode* iter = bordersurfaceElement->getFirstChild();
103 iter !=
nullptr; iter = iter->getNextSibling())
105 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
110 const xercesc::DOMElement*
const child =
111 dynamic_cast<xercesc::DOMElement*
>(iter);
114 G4Exception(
"G4GDMLReadStructure::BorderSurfaceRead()",
"InvalidRead",
120 if(
tag !=
"physvolref")
144 const xercesc::DOMElement*
const divisionvolElement)
154 const xercesc::DOMNamedNodeMap*
const attributes =
155 divisionvolElement->getAttributes();
156 XMLSize_t attributeCount = attributes->getLength();
159 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
162 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
164 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
169 const xercesc::DOMAttr*
const attribute =
170 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
171 if(attribute ==
nullptr)
173 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
"InvalidRead",
180 if(attName ==
"name")
184 else if(attName ==
"unit")
189 else if(attName ==
"width")
193 else if(attName ==
"offset")
197 else if(attName ==
"number")
201 else if(attName ==
"axis")
203 if(attValue ==
"kXAxis")
207 else if(attValue ==
"kYAxis")
211 else if(attValue ==
"kZAxis")
215 else if(attValue ==
"kRho")
219 else if(attValue ==
"kPhi")
227 unitname !=
"Length") ||
228 ((axis ==
kRho || axis ==
kPhi) && unitname !=
"Angle"))
230 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
"InvalidRead",
237 for(xercesc::DOMNode* iter = divisionvolElement->getFirstChild();
238 iter !=
nullptr; iter = iter->getNextSibling())
240 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
245 const xercesc::DOMElement*
const child =
246 dynamic_cast<xercesc::DOMElement*
>(iter);
249 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
"InvalidRead",
255 if(
tag ==
"volumeref")
261 if(logvol ==
nullptr)
270 if((number != 0) && (width == 0.0))
275 else if((number == 0) && (width != 0.0))
286 if(pair.first !=
nullptr)
290 if(pair.second !=
nullptr)
298 const xercesc::DOMElement*
const fileElement)
303 const xercesc::DOMNamedNodeMap*
const attributes =
304 fileElement->getAttributes();
305 XMLSize_t attributeCount = attributes->getLength();
307 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
310 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
312 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
317 const xercesc::DOMAttr*
const attribute =
318 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
319 if(attribute ==
nullptr)
321 G4Exception(
"G4GDMLReadStructure::FileRead()",
"InvalidRead",
328 if(attName ==
"name")
332 else if(attName ==
"volname")
338 const G4bool isModule =
true;
347 for(
auto pos = aux->cbegin(); pos != aux->cend(); ++pos)
349 auxMap.insert(std::make_pair(pos->first, pos->second));
367 const xercesc::DOMElement*
const physvolElement,
G4AssemblyVolume* pAssembly)
375 G4int copynumber = 0;
377 const xercesc::DOMNamedNodeMap*
const attributes =
378 physvolElement->getAttributes();
379 XMLSize_t attributeCount = attributes->getLength();
381 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
384 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
386 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
391 const xercesc::DOMAttr*
const attribute =
392 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
393 if(attribute ==
nullptr)
395 G4Exception(
"G4GDMLReadStructure::PhysvolRead()",
"InvalidRead",
402 if(attName ==
"name")
406 if(attName ==
"copynumber")
412 for(xercesc::DOMNode* iter = physvolElement->getFirstChild(); iter !=
nullptr;
413 iter = iter->getNextSibling())
415 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
420 const xercesc::DOMElement*
const child =
421 dynamic_cast<xercesc::DOMElement*
>(iter);
424 G4Exception(
"G4GDMLReadStructure::PhysvolRead()",
"InvalidRead",
430 if(
tag ==
"volumeref")
434 if(assembly ==
nullptr)
439 else if(
tag ==
"file")
443 else if(
tag ==
"position")
447 else if(
tag ==
"rotation")
451 else if(
tag ==
"scale")
455 else if(
tag ==
"positionref")
459 else if(
tag ==
"rotationref")
463 else if(
tag ==
"scaleref")
469 G4String error_msg =
"Unknown tag in physvol: " +
tag;
470 G4Exception(
"G4GDMLReadStructure::PhysvolRead()",
"ReadError",
477 transform = transform *
G4Scale3D(scale.
x(), scale.
y(), scale.
z());
479 if(pAssembly !=
nullptr)
481 if(assembly !=
nullptr)
485 if(logvol ==
nullptr)
493 if(assembly !=
nullptr)
499 if(logvol ==
nullptr)
507 if(pair.first !=
nullptr)
511 if(pair.second !=
nullptr)
521 const xercesc::DOMElement*
const replicavolElement,
G4int number)
524 for(xercesc::DOMNode* iter = replicavolElement->getFirstChild();
525 iter !=
nullptr; iter = iter->getNextSibling())
527 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
532 const xercesc::DOMElement*
const child =
533 dynamic_cast<xercesc::DOMElement*
>(iter);
536 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
"InvalidRead",
542 if(
tag ==
"volumeref")
546 else if(
tag ==
"replicate_along_axis")
555 G4String error_msg =
"Unknown tag in ReplicavolRead: " +
tag;
556 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
"ReadError",
564 const xercesc::DOMElement*
const replicaElement,
G4LogicalVolume* logvol,
574 for(xercesc::DOMNode* iter = replicaElement->getFirstChild(); iter !=
nullptr;
575 iter = iter->getNextSibling())
577 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
582 const xercesc::DOMElement*
const child =
583 dynamic_cast<xercesc::DOMElement*
>(iter);
586 G4Exception(
"G4GDMLReadStructure::ReplicaRead()",
"InvalidRead",
592 if(
tag ==
"position")
596 else if(
tag ==
"rotation")
600 else if(
tag ==
"positionref")
604 else if(
tag ==
"rotationref")
608 else if(
tag ==
"direction")
612 else if(
tag ==
"width")
616 else if(
tag ==
"offset")
622 G4String error_msg =
"Unknown tag in ReplicaRead: " +
tag;
623 G4Exception(
"G4GDMLReadStructure::ReplicaRead()",
"ReadError",
632 if(pair.first !=
nullptr)
636 if(pair.second !=
nullptr)
644 const xercesc::DOMElement*
const axisElement)
648 const xercesc::DOMNamedNodeMap*
const attributes =
649 axisElement->getAttributes();
650 XMLSize_t attributeCount = attributes->getLength();
652 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
655 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
657 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
662 const xercesc::DOMAttr*
const attribute =
663 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
664 if(attribute ==
nullptr)
666 G4Exception(
"G4GDMLReadStructure::AxisRead()",
"InvalidRead",
679 else if(attName ==
"y")
686 else if(attName ==
"z")
693 else if(attName ==
"rho")
700 else if(attName ==
"phi")
714 const xercesc::DOMElement*
const readElement)
718 const xercesc::DOMNamedNodeMap*
const attributes =
719 readElement->getAttributes();
720 XMLSize_t attributeCount = attributes->getLength();
722 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
725 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
727 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
731 const xercesc::DOMAttr*
const attribute =
732 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
733 if(attribute ==
nullptr)
735 G4Exception(
"G4GDMLReadStructure::QuantityRead()",
"InvalidRead",
742 if(attName ==
"unit")
748 G4Exception(
"G4GDMLReadStructure::QuantityRead()",
"InvalidRead",
750 "Invalid unit for length or angle (width, offset)!");
753 else if(attName ==
"value")
764 const xercesc::DOMElement*
const volumeElement)
770 XMLCh* name_attr = xercesc::XMLString::transcode(
"name");
772 xercesc::XMLString::release(&name_attr);
774 for(xercesc::DOMNode* iter = volumeElement->getFirstChild(); iter !=
nullptr;
775 iter = iter->getNextSibling())
777 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
782 const xercesc::DOMElement*
const child =
783 dynamic_cast<xercesc::DOMElement*
>(iter);
786 G4Exception(
"G4GDMLReadStructure::VolumeRead()",
"InvalidRead",
792 if(
tag ==
"auxiliary")
796 else if(
tag ==
"materialref")
800 else if(
tag ==
"solidref")
819 const xercesc::DOMElement*
const assemblyElement)
821 XMLCh* name_attr = xercesc::XMLString::transcode(
"name");
823 xercesc::XMLString::release(&name_attr);
833 assemblyMap.insert(std::make_pair(aName, pAssembly));
836 for(xercesc::DOMNode* iter = assemblyElement->getFirstChild();
837 iter !=
nullptr; iter = iter->getNextSibling())
839 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
843 const xercesc::DOMElement*
const child =
844 dynamic_cast<xercesc::DOMElement*
>(iter);
847 G4Exception(
"G4GDMLReadStructure::AssemblyRead()",
"InvalidRead",
859 G4cout <<
"Unsupported GDML tag '" <<
tag
860 <<
"' for Geant4 assembly structure !" <<
G4endl;
867 const xercesc::DOMElement*
const skinsurfaceElement)
873 const xercesc::DOMNamedNodeMap*
const attributes =
874 skinsurfaceElement->getAttributes();
875 XMLSize_t attributeCount = attributes->getLength();
877 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
880 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
882 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
887 const xercesc::DOMAttr*
const attribute =
888 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
889 if(attribute ==
nullptr)
891 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
"InvalidRead",
898 if(attName ==
"name")
902 else if(attName ==
"surfaceproperty")
908 for(xercesc::DOMNode* iter = skinsurfaceElement->getFirstChild();
909 iter !=
nullptr; iter = iter->getNextSibling())
911 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
916 const xercesc::DOMElement*
const child =
917 dynamic_cast<xercesc::DOMElement*
>(iter);
920 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
"InvalidRead",
926 if(
tag ==
"volumeref")
932 G4String error_msg =
"Unknown tag in skinsurface: " +
tag;
933 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
"ReadError",
943 const xercesc::DOMElement*
const volumeElement)
945 for(xercesc::DOMNode* iter = volumeElement->getFirstChild(); iter !=
nullptr;
946 iter = iter->getNextSibling())
948 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
953 const xercesc::DOMElement*
const child =
954 dynamic_cast<xercesc::DOMElement*
>(iter);
957 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
"InvalidRead",
963 if((
tag ==
"auxiliary") || (
tag ==
"materialref") || (
tag ==
"solidref"))
967 else if(
tag ==
"paramvol")
971 else if(
tag ==
"physvol")
975 else if(
tag ==
"replicavol")
978 const xercesc::DOMNamedNodeMap*
const attributes = child->getAttributes();
979 XMLSize_t attributeCount = attributes->getLength();
980 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
983 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
984 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
988 const xercesc::DOMAttr*
const attribute =
989 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
990 if(attribute ==
nullptr)
992 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
998 if(attName ==
"number")
1005 else if(
tag ==
"divisionvol")
1009 else if(
tag ==
"loop")
1015 G4cout <<
"Treating unknown GDML tag in volume '" <<
tag
1016 <<
"' as GDML extension..." <<
G4endl;
1023 const xercesc::DOMElement*
const structureElement)
1028 for(xercesc::DOMNode* iter = structureElement->getFirstChild();
1029 iter !=
nullptr; iter = iter->getNextSibling())
1031 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
1036 const xercesc::DOMElement*
const child =
1037 dynamic_cast<xercesc::DOMElement*
>(iter);
1038 if(child ==
nullptr)
1040 G4Exception(
"G4GDMLReadStructure::StructureRead()",
"InvalidRead",
1046 if(
tag ==
"bordersurface")
1050 else if(
tag ==
"skinsurface")
1054 else if(
tag ==
"volume")
1058 else if(
tag ==
"assembly")
1062 else if(
tag ==
"loop")
1068 G4String error_msg =
"Unknown tag in structure: " +
tag;
1069 G4Exception(
"G4GDMLReadStructure::StructureRead()",
"ReadError",
1081 if(physvolPtr ==
nullptr)
1083 G4String error_msg =
"Referenced physvol '" + ref +
"' was not found!";
1084 G4Exception(
"G4GDMLReadStructure::GetPhysvol()",
"ReadError",
1097 if(volumePtr ==
nullptr)
1099 G4String error_msg =
"Referenced volume '" + ref +
"' was not found!";
1122 auto pos =
auxMap.find(logvol);
1155 volume->
GetName() +
"_PV", 0, 0, 0);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
std::map< G4LogicalVolume *, G4GDMLAuxListType > G4GDMLAuxMapType
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool surfCheck=false)
void AddPlacedAssembly(G4AssemblyVolume *pAssembly, G4Transform3D &transformation)
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)
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
G4GDMLAuxStructType AuxiliaryRead(const xercesc::DOMElement *const auxElem)
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, G4bool reverseSearch=false) const
static G4LogicalVolumeStore * GetInstance()
void SetVisAttributes(const G4VisAttributes *pVA)
const G4String & GetName() const
static G4PVDivisionFactory * GetInstance()
static G4PhysicalVolumeStore * GetInstance()
G4VPhysicalVolume * GetVolume(const G4String &name, G4bool verbose=true, G4bool reverseSearch=false) 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 G4double GetValueOf(const G4String &)
static G4String GetCategory(const G4String &)
static const G4VisAttributes & GetInvisible()