Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
G4GDMLReadMaterials Class Referenceabstract

#include <G4GDMLReadMaterials.hh>

Inheritance diagram for G4GDMLReadMaterials:
G4GDMLReadDefine G4GDMLRead G4GDMLReadSolids G4GDMLReadSetup G4GDMLReadParamvol G4GDMLReadStructure

Public Member Functions

virtual void DefineRead (const xercesc::DOMElement *const)
 
virtual void ExtensionRead (const xercesc::DOMElement *const)
 
const G4GDMLAuxListTypeGetAuxList () const
 
G4double GetConstant (const G4String &)
 
G4ElementGetElement (const G4String &, G4bool verbose=true) const
 
G4IsotopeGetIsotope (const G4String &, G4bool verbose=true) const
 
G4MaterialGetMaterial (const G4String &, G4bool verbose=true) const
 
G4GDMLMatrix GetMatrix (const G4String &)
 
G4ThreeVector GetPosition (const G4String &)
 
G4double GetQuantity (const G4String &)
 
G4ThreeVector GetRotation (const G4String &)
 
G4ThreeVector GetScale (const G4String &)
 
virtual G4String GetSetup (const G4String &)=0
 
G4double GetVariable (const G4String &)
 
virtual G4LogicalVolumeGetVolume (const G4String &) const =0
 
G4bool IsValidID (const G4String &) const
 
virtual void MaterialsRead (const xercesc::DOMElement *const)
 
void OverlapCheck (G4bool)
 
virtual void Paramvol_contentRead (const xercesc::DOMElement *const)=0
 
void Read (const G4String &, G4bool validation, G4bool isModule, G4bool strip=true)
 
void SetReverseSearch (G4bool flag)
 
virtual void SetupRead (const xercesc::DOMElement *const)=0
 
virtual void SolidsRead (const xercesc::DOMElement *const)=0
 
void StripName (G4String &) const
 
void StripNames () const
 
virtual void StructureRead (const xercesc::DOMElement *const)=0
 
virtual void UserinfoRead (const xercesc::DOMElement *const)
 
virtual void Volume_contentRead (const xercesc::DOMElement *const)=0
 

Protected Member Functions

G4double AtomRead (const xercesc::DOMElement *const)
 
G4GDMLAuxStructType AuxiliaryRead (const xercesc::DOMElement *const auxElem)
 
G4int CompositeRead (const xercesc::DOMElement *const, G4String &)
 
void ConstantRead (const xercesc::DOMElement *const)
 
G4double DRead (const xercesc::DOMElement *const)
 
void ElementRead (const xercesc::DOMElement *const)
 
void ExpressionRead (const xercesc::DOMElement *const)
 
G4double FractionRead (const xercesc::DOMElement *const, G4String &)
 
 G4GDMLReadMaterials ()
 
G4String GenerateName (const G4String &name, G4bool strip=false)
 
void GeneratePhysvolName (const G4String &, G4VPhysicalVolume *)
 
G4RotationMatrix GetRotationMatrix (const G4ThreeVector &)
 
void IsotopeRead (const xercesc::DOMElement *const)
 
void LoopRead (const xercesc::DOMElement *const, void(G4GDMLRead::*)(const xercesc::DOMElement *const))
 
void MaterialRead (const xercesc::DOMElement *const)
 
void MatrixRead (const xercesc::DOMElement *const)
 
G4double MEERead (const xercesc::DOMElement *const)
 
void MixtureRead (const xercesc::DOMElement *const, G4Element *)
 
void MixtureRead (const xercesc::DOMElement *const, G4Material *)
 
void PositionRead (const xercesc::DOMElement *const)
 
G4double PRead (const xercesc::DOMElement *const)
 
void PropertyRead (const xercesc::DOMElement *const, G4Material *)
 
void QuantityRead (const xercesc::DOMElement *const)
 
G4String RefRead (const xercesc::DOMElement *const)
 
void RotationRead (const xercesc::DOMElement *const)
 
void ScaleRead (const xercesc::DOMElement *const)
 
G4String Strip (const G4String &) const
 
G4String Transcode (const XMLCh *const)
 
G4double TRead (const xercesc::DOMElement *const)
 
void VariableRead (const xercesc::DOMElement *const)
 
void VectorRead (const xercesc::DOMElement *const, G4ThreeVector &)
 
virtual ~G4GDMLReadMaterials ()
 

Protected Attributes

G4bool check = false
 
G4bool dostrip = true
 
G4GDMLEvaluator eval
 
std::map< G4String, G4GDMLMatrixmatrixMap
 
std::map< G4String, G4ThreeVectorpositionMap
 
std::map< G4String, G4doublequantityMap
 
G4bool reverseSearch = false
 
std::map< G4String, G4ThreeVectorrotationMap
 
std::map< G4String, G4ThreeVectorscaleMap
 
G4bool validate = true
 

Private Attributes

G4GDMLAuxListType auxGlobalList
 
G4int inLoop = 0
 
G4int loopCount = 0
 

Detailed Description

Definition at line 45 of file G4GDMLReadMaterials.hh.

Constructor & Destructor Documentation

◆ G4GDMLReadMaterials()

G4GDMLReadMaterials::G4GDMLReadMaterials ( )
protected

Definition at line 42 of file G4GDMLReadMaterials.cc.

◆ ~G4GDMLReadMaterials()

G4GDMLReadMaterials::~G4GDMLReadMaterials ( )
protectedvirtual

Definition at line 48 of file G4GDMLReadMaterials.cc.

49{
50}

Member Function Documentation

◆ AtomRead()

G4double G4GDMLReadMaterials::AtomRead ( const xercesc::DOMElement * const  atomElement)
protected

Definition at line 53 of file G4GDMLReadMaterials.cc.

55{
56 G4double value = 0.0;
57 G4double unit = g / mole;
58
59 const xercesc::DOMNamedNodeMap* const attributes =
60 atomElement->getAttributes();
61 XMLSize_t attributeCount = attributes->getLength();
62
63 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
64 ++attribute_index)
65 {
66 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
67
68 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
69 {
70 continue;
71 }
72
73 const xercesc::DOMAttr* const attribute =
74 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
75 if(attribute == nullptr)
76 {
77 G4Exception("G4GDMLReadMaterials::AtomRead()", "InvalidRead",
78 FatalException, "No attribute found!");
79 return value;
80 }
81 const G4String attName = Transcode(attribute->getName());
82 const G4String attValue = Transcode(attribute->getValue());
83
84 if(attName == "value")
85 {
86 value = eval.Evaluate(attValue);
87 }
88 else if(attName == "unit")
89 {
90 unit = G4UnitDefinition::GetValueOf(attValue);
91 if(G4UnitDefinition::GetCategory(attValue) != "Molar mass")
92 {
93 G4Exception("G4GDMLReadMaterials::AtomRead()", "InvalidRead",
94 FatalException, "Invalid unit for atomic mass!");
95 }
96 }
97 }
98
99 return value * unit;
100}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
static constexpr double mole
Definition: G4SIunits.hh:279
static constexpr double g
Definition: G4SIunits.hh:168
double G4double
Definition: G4Types.hh:83
G4double Evaluate(const G4String &)
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:156
static G4double GetValueOf(const G4String &)
static G4String GetCategory(const G4String &)

References G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, g, G4Exception(), G4UnitDefinition::GetCategory(), G4UnitDefinition::GetValueOf(), mole, and G4GDMLRead::Transcode().

Referenced by ElementRead(), IsotopeRead(), and MaterialRead().

◆ AuxiliaryRead()

G4GDMLAuxStructType G4GDMLRead::AuxiliaryRead ( const xercesc::DOMElement *const  auxElem)
protectedinherited

Definition at line 295 of file G4GDMLRead.cc.

297{
298 G4GDMLAuxStructType auxstruct = { "", "", "", 0 };
299 G4GDMLAuxListType* auxList = nullptr;
300
301 const xercesc::DOMNamedNodeMap* const attributes =
302 auxiliaryElement->getAttributes();
303 XMLSize_t attributeCount = attributes->getLength();
304
305 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
306 ++attribute_index)
307 {
308 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
309
310 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
311 {
312 continue;
313 }
314
315 const xercesc::DOMAttr* const attribute =
316 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
317 if(!attribute)
318 {
319 G4Exception("G4GDMLRead::AuxiliaryRead()", "InvalidRead", FatalException,
320 "No attribute found!");
321 return auxstruct;
322 }
323 const G4String attName = Transcode(attribute->getName());
324 const G4String attValue = Transcode(attribute->getValue());
325
326 if(attName == "auxtype")
327 {
328 auxstruct.type = attValue;
329 }
330 else if(attName == "auxvalue")
331 {
332 auxstruct.value = attValue;
333 }
334 else if(attName == "auxunit")
335 {
336 auxstruct.unit = attValue;
337 }
338 }
339
340 for(xercesc::DOMNode* iter = auxiliaryElement->getFirstChild();
341 iter != nullptr; iter = iter->getNextSibling())
342 {
343 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
344 {
345 continue;
346 }
347
348 const xercesc::DOMElement* const child =
349 dynamic_cast<xercesc::DOMElement*>(iter);
350 if(!child)
351 {
352 G4Exception("G4GDMLRead::AuxiliaryRead()", "InvalidRead", FatalException,
353 "No child found!");
354 break;
355 }
356 const G4String tag = Transcode(child->getTagName());
357
358 if(tag == "auxiliary")
359 {
360 if(!auxList)
361 {
362 auxList = new G4GDMLAuxListType;
363 }
364 auxList->push_back(AuxiliaryRead(child));
365 }
366 }
367
368 if(auxList)
369 {
370 auxstruct.auxList = auxList;
371 }
372
373 return auxstruct;
374}
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
G4GDMLAuxStructType AuxiliaryRead(const xercesc::DOMElement *const auxElem)
Definition: G4GDMLRead.cc:295
std::vector< G4GDMLAuxStructType > * auxList
Definition: xmlparse.cc:187

References G4GDMLRead::AuxiliaryRead(), G4GDMLAuxStructType::auxList, FatalException, G4Exception(), G4GDMLRead::Transcode(), G4GDMLAuxStructType::type, G4GDMLAuxStructType::unit, and G4GDMLAuxStructType::value.

Referenced by G4GDMLRead::AuxiliaryRead(), G4GDMLRead::UserinfoRead(), and G4GDMLReadStructure::VolumeRead().

◆ CompositeRead()

G4int G4GDMLReadMaterials::CompositeRead ( const xercesc::DOMElement * const  compositeElement,
G4String ref 
)
protected

Definition at line 103 of file G4GDMLReadMaterials.cc.

105{
106 G4int n = 0;
107
108 const xercesc::DOMNamedNodeMap* const attributes =
109 compositeElement->getAttributes();
110 XMLSize_t attributeCount = attributes->getLength();
111
112 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
113 ++attribute_index)
114 {
115 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
116
117 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
118 {
119 continue;
120 }
121
122 const xercesc::DOMAttr* const attribute =
123 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
124 if(attribute == nullptr)
125 {
126 G4Exception("G4GDMLReadMaterials::CompositeRead()", "InvalidRead",
127 FatalException, "No attribute found!");
128 return n;
129 }
130 const G4String attName = Transcode(attribute->getName());
131 const G4String attValue = Transcode(attribute->getValue());
132
133 if(attName == "n")
134 {
135 n = eval.EvaluateInteger(attValue);
136 }
137 else if(attName == "ref")
138 {
139 ref = attValue;
140 }
141 }
142
143 return n;
144}
int G4int
Definition: G4Types.hh:85
G4int EvaluateInteger(const G4String &)

References G4GDMLRead::eval, G4GDMLEvaluator::EvaluateInteger(), FatalException, G4Exception(), CLHEP::detail::n, and G4GDMLRead::Transcode().

Referenced by MixtureRead().

◆ ConstantRead()

void G4GDMLReadDefine::ConstantRead ( const xercesc::DOMElement * const  constantElement)
protectedinherited

Definition at line 167 of file G4GDMLReadDefine.cc.

169{
170 G4String name = "";
171 G4double value = 0.0;
172
173 const xercesc::DOMNamedNodeMap* const attributes =
174 constantElement->getAttributes();
175 XMLSize_t attributeCount = attributes->getLength();
176
177 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
178 ++attribute_index)
179 {
180 xercesc::DOMNode* node = attributes->item(attribute_index);
181
182 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
183 {
184 continue;
185 }
186
187 const xercesc::DOMAttr* const attribute =
188 dynamic_cast<xercesc::DOMAttr*>(node);
189 if(attribute == nullptr)
190 {
191 G4Exception("G4GDMLRead::ConstantRead()", "InvalidRead", FatalException,
192 "No attribute found!");
193 return;
194 }
195 const G4String attName = Transcode(attribute->getName());
196 const G4String attValue = Transcode(attribute->getValue());
197
198 if(attName == "name")
199 {
200 name = attValue;
201 }
202 else if(attName == "value")
203 {
204 value = eval.Evaluate(attValue);
205 }
206 }
207
208 eval.DefineConstant(name, value);
209}
void DefineConstant(const G4String &, G4double)
const char * name(G4int ptype)

References G4GDMLEvaluator::DefineConstant(), G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4InuclParticleNames::name(), and G4GDMLRead::Transcode().

Referenced by G4GDMLReadDefine::DefineRead().

◆ DefineRead()

void G4GDMLReadDefine::DefineRead ( const xercesc::DOMElement * const  defineElement)
virtualinherited

Implements G4GDMLRead.

Definition at line 596 of file G4GDMLReadDefine.cc.

598{
599#ifdef G4VERBOSE
600 G4cout << "G4GDML: Reading definitions..." << G4endl;
601#endif
602 for(xercesc::DOMNode* iter = defineElement->getFirstChild(); iter != nullptr;
603 iter = iter->getNextSibling())
604 {
605 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
606 {
607 continue;
608 }
609
610 const xercesc::DOMElement* const child =
611 dynamic_cast<xercesc::DOMElement*>(iter);
612 if(child == nullptr)
613 {
614 G4Exception("G4GDMLRead::DefineRead()", "InvalidRead", FatalException,
615 "No child found!");
616 return;
617 }
618 const G4String tag = Transcode(child->getTagName());
619
620 if(tag == "constant")
621 {
622 ConstantRead(child);
623 }
624 else if(tag == "matrix")
625 {
626 MatrixRead(child);
627 }
628 else if(tag == "position")
629 {
630 PositionRead(child);
631 }
632 else if(tag == "rotation")
633 {
634 RotationRead(child);
635 }
636 else if(tag == "scale")
637 {
638 ScaleRead(child);
639 }
640 else if(tag == "variable")
641 {
642 VariableRead(child);
643 }
644 else if(tag == "quantity")
645 {
646 QuantityRead(child);
647 }
648 else if(tag == "expression")
649 {
650 ExpressionRead(child);
651 }
652 else
653 {
654 G4String error_msg = "Unknown tag in define: " + tag;
655 G4Exception("G4GDMLReadDefine::defineRead()", "ReadError", FatalException,
656 error_msg);
657 }
658 }
659}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void ExpressionRead(const xercesc::DOMElement *const)
void VariableRead(const xercesc::DOMElement *const)
void QuantityRead(const xercesc::DOMElement *const)
void PositionRead(const xercesc::DOMElement *const)
void MatrixRead(const xercesc::DOMElement *const)
void RotationRead(const xercesc::DOMElement *const)
void ScaleRead(const xercesc::DOMElement *const)
void ConstantRead(const xercesc::DOMElement *const)

References G4GDMLReadDefine::ConstantRead(), G4GDMLReadDefine::ExpressionRead(), FatalException, G4cout, G4endl, G4Exception(), G4GDMLReadDefine::MatrixRead(), G4GDMLReadDefine::PositionRead(), G4GDMLReadDefine::QuantityRead(), G4GDMLReadDefine::RotationRead(), G4GDMLReadDefine::ScaleRead(), G4GDMLRead::Transcode(), and G4GDMLReadDefine::VariableRead().

Referenced by MaterialsRead(), and G4GDMLReadSolids::SolidsRead().

◆ DRead()

G4double G4GDMLReadMaterials::DRead ( const xercesc::DOMElement * const  DElement)
protected

Definition at line 147 of file G4GDMLReadMaterials.cc.

148{
149 G4double value = 0.0;
150 G4double unit = g / cm3;
151
152 const xercesc::DOMNamedNodeMap* const attributes = DElement->getAttributes();
153 XMLSize_t attributeCount = attributes->getLength();
154
155 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
156 ++attribute_index)
157 {
158 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
159
160 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
161 {
162 continue;
163 }
164
165 const xercesc::DOMAttr* const attribute =
166 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
167 if(attribute == nullptr)
168 {
169 G4Exception("G4GDMLReadMaterials::DRead()", "InvalidRead", FatalException,
170 "No attribute found!");
171 return value;
172 }
173 const G4String attName = Transcode(attribute->getName());
174 const G4String attValue = Transcode(attribute->getValue());
175
176 if(attName == "value")
177 {
178 value = eval.Evaluate(attValue);
179 }
180 else if(attName == "unit")
181 {
182 unit = G4UnitDefinition::GetValueOf(attValue);
183 if(G4UnitDefinition::GetCategory(attValue) != "Volumic Mass")
184 {
185 G4Exception("G4GDMLReadMaterials::DRead()", "InvalidRead",
186 FatalException, "Invalid unit for density!");
187 }
188 }
189 }
190
191 return value * unit;
192}
static constexpr double cm3
Definition: G4SIunits.hh:101

References cm3, G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, g, G4Exception(), G4UnitDefinition::GetCategory(), G4UnitDefinition::GetValueOf(), and G4GDMLRead::Transcode().

Referenced by MaterialRead().

◆ ElementRead()

void G4GDMLReadMaterials::ElementRead ( const xercesc::DOMElement * const  elementElement)
protected

Definition at line 339 of file G4GDMLReadMaterials.cc.

341{
343 G4String formula;
344 G4double a = 0.0;
345 G4double Z = 0.0;
346
347 const xercesc::DOMNamedNodeMap* const attributes =
348 elementElement->getAttributes();
349 XMLSize_t attributeCount = attributes->getLength();
350
351 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
352 ++attribute_index)
353 {
354 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
355
356 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
357 {
358 continue;
359 }
360
361 const xercesc::DOMAttr* const attribute =
362 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
363 if(attribute == nullptr)
364 {
365 G4Exception("G4GDMLReadMaterials::ElementRead()", "InvalidRead",
366 FatalException, "No attribute found!");
367 return;
368 }
369 const G4String attName = Transcode(attribute->getName());
370 const G4String attValue = Transcode(attribute->getValue());
371
372 if(attName == "name")
373 {
374 name = GenerateName(attValue);
375 }
376 else if(attName == "formula")
377 {
378 formula = attValue;
379 }
380 else if(attName == "Z")
381 {
382 Z = eval.Evaluate(attValue);
383 }
384 }
385
386 G4int nComponents = 0;
387
388 for(xercesc::DOMNode* iter = elementElement->getFirstChild(); iter != nullptr;
389 iter = iter->getNextSibling())
390 {
391 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
392 {
393 continue;
394 }
395
396 const xercesc::DOMElement* const child =
397 dynamic_cast<xercesc::DOMElement*>(iter);
398 if(child == nullptr)
399 {
400 G4Exception("G4GDMLReadMaterials::ElementRead()", "InvalidRead",
401 FatalException, "No child found!");
402 return;
403 }
404 const G4String tag = Transcode(child->getTagName());
405
406 if(tag == "atom")
407 {
408 a = AtomRead(child);
409 }
410 else if(tag == "fraction")
411 {
412 nComponents++;
413 }
414 }
415
416 if(nComponents > 0)
417 {
418 MixtureRead(elementElement,
419 new G4Element(Strip(name), formula, nComponents));
420 }
421 else
422 {
423 new G4Element(Strip(name), formula, Z, a);
424 }
425}
const G4int Z[17]
void MixtureRead(const xercesc::DOMElement *const, G4Element *)
G4double AtomRead(const xercesc::DOMElement *const)
G4String Strip(const G4String &) const
Definition: G4GDMLRead.cc:104
G4String GenerateName(const G4String &name, G4bool strip=false)
Definition: G4GDMLRead.cc:70

References AtomRead(), G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4GDMLRead::GenerateName(), MixtureRead(), G4InuclParticleNames::name(), G4GDMLRead::Strip(), G4GDMLRead::Transcode(), and Z.

Referenced by MaterialsRead().

◆ ExpressionRead()

void G4GDMLReadDefine::ExpressionRead ( const xercesc::DOMElement * const  expElement)
protectedinherited

Definition at line 212 of file G4GDMLReadDefine.cc.

214{
215 G4String name = "";
216 G4double value = 0.0;
217
218 const xercesc::DOMNamedNodeMap* const attributes =
219 expElement->getAttributes();
220 XMLSize_t attributeCount = attributes->getLength();
221
222 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
223 ++attribute_index)
224 {
225 xercesc::DOMNode* node = attributes->item(attribute_index);
226
227 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
228 {
229 continue;
230 }
231
232 const xercesc::DOMAttr* const attribute =
233 dynamic_cast<xercesc::DOMAttr*>(node);
234 if(attribute == nullptr)
235 {
236 G4Exception("G4GDMLRead::ExpressionRead()", "InvalidRead", FatalException,
237 "No attribute found!");
238 return;
239 }
240 const G4String attName = Transcode(attribute->getName());
241 const G4String attValue = Transcode(attribute->getValue());
242
243 if(attName == "name")
244 {
245 name = attValue;
246 }
247 }
248
249 const G4String expValue = Transcode(expElement->getTextContent());
250 value = eval.Evaluate(expValue);
251 eval.DefineConstant(name, value);
252}

References G4GDMLEvaluator::DefineConstant(), G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4InuclParticleNames::name(), and G4GDMLRead::Transcode().

Referenced by G4GDMLReadDefine::DefineRead().

◆ ExtensionRead()

void G4GDMLRead::ExtensionRead ( const xercesc::DOMElement * const  )
virtualinherited

Definition at line 414 of file G4GDMLRead.cc.

415{
416 G4String error_msg = "No handle to user-code for parsing extensions!";
417 G4Exception("G4GDMLRead::ExtensionRead()", "NotImplemented", JustWarning,
418 error_msg);
419}
@ JustWarning

References G4Exception(), and JustWarning.

Referenced by G4GDMLRead::Read().

◆ FractionRead()

G4double G4GDMLReadMaterials::FractionRead ( const xercesc::DOMElement * const  fractionElement,
G4String ref 
)
protected

Definition at line 428 of file G4GDMLReadMaterials.cc.

430{
431 G4double n = 0.0;
432
433 const xercesc::DOMNamedNodeMap* const attributes =
434 fractionElement->getAttributes();
435 XMLSize_t attributeCount = attributes->getLength();
436
437 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
438 ++attribute_index)
439 {
440 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
441
442 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
443 {
444 continue;
445 }
446
447 const xercesc::DOMAttr* const attribute =
448 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
449 if(attribute == nullptr)
450 {
451 G4Exception("G4GDMLReadMaterials::FractionRead()", "InvalidRead",
452 FatalException, "No attribute found!");
453 return n;
454 }
455 const G4String attName = Transcode(attribute->getName());
456 const G4String attValue = Transcode(attribute->getValue());
457
458 if(attName == "n")
459 {
460 n = eval.Evaluate(attValue);
461 }
462 else if(attName == "ref")
463 {
464 ref = attValue;
465 }
466 }
467
468 return n;
469}

References G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), CLHEP::detail::n, and G4GDMLRead::Transcode().

Referenced by MixtureRead().

◆ GenerateName()

G4String G4GDMLRead::GenerateName ( const G4String name,
G4bool  strip = false 
)
protectedinherited

Definition at line 70 of file G4GDMLRead.cc.

71{
72 G4String nameOut(nameIn);
73
74 if(inLoop > 0)
75 {
76 nameOut = eval.SolveBrackets(nameOut);
77 }
78 if(strip)
79 {
80 StripName(nameOut);
81 }
82
83 return nameOut;
84}
G4String SolveBrackets(const G4String &)
void StripName(G4String &) const
Definition: G4GDMLRead.cc:112
G4int inLoop
Definition: G4GDMLRead.hh:163
void strip(G4String &str, char c=' ')
Remove leading and trailing characters from string.

References G4GDMLRead::eval, G4GDMLRead::inLoop, G4GDMLEvaluator::SolveBrackets(), G4StrUtil::strip(), and G4GDMLRead::StripName().

Referenced by G4GDMLReadStructure::AssemblyRead(), G4GDMLReadSolids::BooleanRead(), G4GDMLReadStructure::BorderSurfaceRead(), G4GDMLReadSolids::BoxRead(), G4GDMLReadSolids::ConeRead(), G4GDMLReadSolids::CutTubeRead(), G4GDMLReadStructure::DivisionvolRead(), G4GDMLReadSolids::ElconeRead(), ElementRead(), G4GDMLReadSolids::EllipsoidRead(), G4GDMLReadSolids::EltubeRead(), G4GDMLReadStructure::FileRead(), G4GDMLReadSolids::GenericPolyconeRead(), G4GDMLReadSolids::GenericPolyhedraRead(), G4GDMLReadSolids::GenTrapRead(), G4GDMLReadStructure::GetWorldVolume(), G4GDMLReadSolids::HypeRead(), IsotopeRead(), MaterialRead(), G4GDMLReadDefine::MatrixRead(), MixtureRead(), G4GDMLReadSolids::MultiUnionNodeRead(), G4GDMLReadSolids::MultiUnionRead(), G4GDMLReadSolids::OpticalSurfaceRead(), G4GDMLReadSolids::OrbRead(), G4GDMLReadSolids::ParaboloidRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadParamvol::ParamvolRead(), G4GDMLReadSolids::ParaRead(), G4GDMLReadStructure::PhysvolRead(), G4GDMLReadSolids::PolyconeRead(), G4GDMLReadSolids::PolyhedraRead(), G4GDMLReadDefine::PositionRead(), PropertyRead(), G4GDMLReadSolids::PropertyRead(), G4GDMLReadSolids::QuadrangularRead(), G4GDMLReadSolids::ReflectedSolidRead(), G4GDMLReadStructure::ReplicaRead(), G4GDMLReadStructure::ReplicavolRead(), G4GDMLReadDefine::RotationRead(), G4GDMLReadSolids::ScaledSolidRead(), G4GDMLReadDefine::ScaleRead(), G4GDMLReadSetup::SetupRead(), G4GDMLReadStructure::SkinSurfaceRead(), G4GDMLReadSolids::SphereRead(), G4GDMLReadSolids::TessellatedRead(), G4GDMLReadSolids::TetRead(), G4GDMLReadSolids::TorusRead(), G4GDMLReadSolids::TrapRead(), G4GDMLReadSolids::TrdRead(), G4GDMLReadSolids::TriangularRead(), G4GDMLReadSolids::TubeRead(), G4GDMLReadSolids::TwistedboxRead(), G4GDMLReadSolids::TwistedtrapRead(), G4GDMLReadSolids::TwistedtrdRead(), G4GDMLReadSolids::TwistedtubsRead(), G4GDMLReadStructure::VolumeRead(), and G4GDMLReadSolids::XtruRead().

◆ GeneratePhysvolName()

void G4GDMLRead::GeneratePhysvolName ( const G4String nameIn,
G4VPhysicalVolume physvol 
)
protectedinherited

Definition at line 87 of file G4GDMLRead.cc.

89{
90 G4String nameOut(nameIn);
91
92 if(nameIn.empty())
93 {
94 std::stringstream stream;
95 stream << physvol->GetLogicalVolume()->GetName() << "_PV";
96 nameOut = stream.str();
97 }
98 nameOut = eval.SolveBrackets(nameOut);
99
100 physvol->SetName(nameOut);
101}
const G4String & GetName() const
G4LogicalVolume * GetLogicalVolume() const
void SetName(const G4String &pName)

References G4GDMLRead::eval, G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetName(), G4VPhysicalVolume::SetName(), and G4GDMLEvaluator::SolveBrackets().

Referenced by G4GDMLReadStructure::DivisionvolRead(), G4GDMLReadStructure::PhysvolRead(), and G4GDMLReadStructure::ReplicaRead().

◆ GetAuxList()

const G4GDMLAuxListType * G4GDMLRead::GetAuxList ( ) const
inherited

Definition at line 563 of file G4GDMLRead.cc.

564{
565 return &auxGlobalList;
566}
G4GDMLAuxListType auxGlobalList
Definition: G4GDMLRead.hh:164

References G4GDMLRead::auxGlobalList.

◆ GetConstant()

G4double G4GDMLReadDefine::GetConstant ( const G4String ref)
inherited

Definition at line 758 of file G4GDMLReadDefine.cc.

759{
760 return eval.GetConstant(ref);
761}
G4double GetConstant(const G4String &)

References G4GDMLRead::eval, and G4GDMLEvaluator::GetConstant().

◆ GetElement()

G4Element * G4GDMLReadMaterials::GetElement ( const G4String ref,
G4bool  verbose = true 
) const

Definition at line 932 of file G4GDMLReadMaterials.cc.

934{
935 G4Element* elementPtr = G4Element::GetElement(ref, false);
936
937 if(elementPtr == nullptr)
938 {
939 elementPtr = G4NistManager::Instance()->FindOrBuildElement(ref);
940 }
941
942 if(verbose && elementPtr == nullptr)
943 {
944 G4String error_msg = "Referenced element '" + ref + "' was not found!";
945 G4Exception("G4GDMLReadMaterials::GetElement()", "InvalidRead",
946 FatalException, error_msg);
947 }
948
949 return elementPtr;
950}
static G4Element * GetElement(G4String name, G4bool warning=true)
Definition: G4Element.cc:411
static G4NistManager * Instance()
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)

References FatalException, G4NistManager::FindOrBuildElement(), G4Exception(), G4Element::GetElement(), and G4NistManager::Instance().

Referenced by MixtureRead().

◆ GetIsotope()

G4Isotope * G4GDMLReadMaterials::GetIsotope ( const G4String ref,
G4bool  verbose = true 
) const

Definition at line 953 of file G4GDMLReadMaterials.cc.

955{
956 G4Isotope* isotopePtr = G4Isotope::GetIsotope(ref, false);
957
958 if(verbose && isotopePtr == nullptr)
959 {
960 G4String error_msg = "Referenced isotope '" + ref + "' was not found!";
961 G4Exception("G4GDMLReadMaterials::GetIsotope()", "InvalidRead",
962 FatalException, error_msg);
963 }
964
965 return isotopePtr;
966}
static G4Isotope * GetIsotope(const G4String &name, G4bool warning=false)
Definition: G4Isotope.cc:195

References FatalException, G4Exception(), and G4Isotope::GetIsotope().

Referenced by MixtureRead().

◆ GetMaterial()

G4Material * G4GDMLReadMaterials::GetMaterial ( const G4String ref,
G4bool  verbose = true 
) const

Definition at line 969 of file G4GDMLReadMaterials.cc.

971{
972 G4Material* materialPtr = G4Material::GetMaterial(ref, false);
973
974 if(materialPtr == nullptr)
975 {
976 materialPtr = G4NistManager::Instance()->FindOrBuildMaterial(ref);
977 }
978
979 if(verbose && materialPtr == nullptr)
980 {
981 G4String error_msg = "Referenced material '" + ref + "' was not found!";
982 G4Exception("G4GDMLReadMaterials::GetMaterial()", "InvalidRead",
983 FatalException, error_msg);
984 }
985
986 return materialPtr;
987}
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:686
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)

References FatalException, G4NistManager::FindOrBuildMaterial(), G4Exception(), G4Material::GetMaterial(), and G4NistManager::Instance().

Referenced by MixtureRead(), and G4GDMLReadStructure::VolumeRead().

◆ GetMatrix()

G4GDMLMatrix G4GDMLReadDefine::GetMatrix ( const G4String ref)
inherited

Definition at line 818 of file G4GDMLReadDefine.cc.

819{
820 if(matrixMap.find(ref) == matrixMap.end())
821 {
822 G4String error_msg = "Matrix '" + ref + "' was not found!";
823 G4Exception("G4GDMLReadDefine::getMatrix()", "ReadError", FatalException,
824 error_msg);
825 }
826 return matrixMap[ref];
827}
std::map< G4String, G4GDMLMatrix > matrixMap

References FatalException, G4Exception(), and G4GDMLReadDefine::matrixMap.

Referenced by PropertyRead(), and G4GDMLReadSolids::PropertyRead().

◆ GetPosition()

G4ThreeVector G4GDMLReadDefine::GetPosition ( const G4String ref)
inherited

Definition at line 782 of file G4GDMLReadDefine.cc.

783{
784 if(positionMap.find(ref) == positionMap.cend())
785 {
786 G4String error_msg = "Position '" + ref + "' was not found!";
787 G4Exception("G4GDMLReadDefine::getPosition()", "ReadError", FatalException,
788 error_msg);
789 }
790 return positionMap[ref];
791}
std::map< G4String, G4ThreeVector > positionMap

References FatalException, G4Exception(), and G4GDMLReadDefine::positionMap.

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadSolids::MultiUnionNodeRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadStructure::PhysvolRead(), G4GDMLReadSolids::QuadrangularRead(), G4GDMLReadStructure::ReplicaRead(), G4GDMLReadSolids::TetRead(), and G4GDMLReadSolids::TriangularRead().

◆ GetQuantity()

G4double G4GDMLReadDefine::GetQuantity ( const G4String ref)
inherited

Definition at line 770 of file G4GDMLReadDefine.cc.

771{
772 if(quantityMap.find(ref) == quantityMap.cend())
773 {
774 G4String error_msg = "Quantity '" + ref + "' was not found!";
775 G4Exception("G4GDMLReadDefine::getQuantity()", "ReadError", FatalException,
776 error_msg);
777 }
778 return quantityMap[ref];
779}
std::map< G4String, G4double > quantityMap

References FatalException, G4Exception(), and G4GDMLReadDefine::quantityMap.

Referenced by MaterialRead().

◆ GetRotation()

G4ThreeVector G4GDMLReadDefine::GetRotation ( const G4String ref)
inherited

Definition at line 794 of file G4GDMLReadDefine.cc.

795{
796 if(rotationMap.find(ref) == rotationMap.cend())
797 {
798 G4String error_msg = "Rotation '" + ref + "' was not found!";
799 G4Exception("G4GDMLReadDefine::getRotation()", "ReadError", FatalException,
800 error_msg);
801 }
802 return rotationMap[ref];
803}
std::map< G4String, G4ThreeVector > rotationMap

References FatalException, G4Exception(), and G4GDMLReadDefine::rotationMap.

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadSolids::MultiUnionNodeRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadStructure::PhysvolRead(), and G4GDMLReadStructure::ReplicaRead().

◆ GetRotationMatrix()

G4RotationMatrix G4GDMLReadDefine::GetRotationMatrix ( const G4ThreeVector angles)
protectedinherited

Definition at line 153 of file G4GDMLReadDefine.cc.

155{
157
158 rot.rotateX(angles.x());
159 rot.rotateY(angles.y());
160 rot.rotateZ(angles.z());
161 rot.rectify(); // Rectify matrix from possible roundoff errors
162
163 return rot;
164}
double z() const
double x() const
double y() const
HepRotation & rotateX(double delta)
Definition: Rotation.cc:61
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:87
HepRotation & rotateY(double delta)
Definition: Rotation.cc:74

References CLHEP::HepRotation::rectify(), CLHEP::HepRotation::rotateX(), CLHEP::HepRotation::rotateY(), CLHEP::HepRotation::rotateZ(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadSolids::MultiUnionNodeRead(), G4GDMLReadStructure::PhysvolRead(), and G4GDMLReadSolids::ReflectedSolidRead().

◆ GetScale()

G4ThreeVector G4GDMLReadDefine::GetScale ( const G4String ref)
inherited

Definition at line 806 of file G4GDMLReadDefine.cc.

807{
808 if(scaleMap.find(ref) == scaleMap.end())
809 {
810 G4String error_msg = "Scale '" + ref + "' was not found!";
811 G4Exception("G4GDMLReadDefine::getScale()", "ReadError", FatalException,
812 error_msg);
813 }
814 return scaleMap[ref];
815}
std::map< G4String, G4ThreeVector > scaleMap

References FatalException, G4Exception(), and G4GDMLReadDefine::scaleMap.

Referenced by G4GDMLReadStructure::PhysvolRead(), and G4GDMLReadSolids::ScaledSolidRead().

◆ GetSetup()

virtual G4String G4GDMLRead::GetSetup ( const G4String )
pure virtualinherited

Implemented in G4GDMLReadSetup.

◆ GetVariable()

G4double G4GDMLReadDefine::GetVariable ( const G4String ref)
inherited

Definition at line 764 of file G4GDMLReadDefine.cc.

765{
766 return eval.GetVariable(ref);
767}
G4double GetVariable(const G4String &)

References G4GDMLRead::eval, and G4GDMLEvaluator::GetVariable().

◆ GetVolume()

virtual G4LogicalVolume * G4GDMLRead::GetVolume ( const G4String ) const
pure virtualinherited

◆ IsotopeRead()

void G4GDMLReadMaterials::IsotopeRead ( const xercesc::DOMElement * const  isotopeElement)
protected

Definition at line 472 of file G4GDMLReadMaterials.cc.

474{
476 G4int Z = 0;
477 G4int N = 0;
478 G4double a = 0.0;
479
480 const xercesc::DOMNamedNodeMap* const attributes =
481 isotopeElement->getAttributes();
482 XMLSize_t attributeCount = attributes->getLength();
483
484 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
485 ++attribute_index)
486 {
487 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
488
489 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
490 {
491 continue;
492 }
493
494 const xercesc::DOMAttr* const attribute =
495 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
496 if(attribute == nullptr)
497 {
498 G4Exception("G4GDMLReadMaterials::IsotopeRead()", "InvalidRead",
499 FatalException, "No attribute found!");
500 return;
501 }
502 const G4String attName = Transcode(attribute->getName());
503 const G4String attValue = Transcode(attribute->getValue());
504
505 if(attName == "name")
506 {
507 name = GenerateName(attValue);
508 }
509 else if(attName == "Z")
510 {
511 Z = eval.EvaluateInteger(attValue);
512 }
513 else if(attName == "N")
514 {
515 N = eval.EvaluateInteger(attValue);
516 }
517 }
518
519 for(xercesc::DOMNode* iter = isotopeElement->getFirstChild(); iter != nullptr;
520 iter = iter->getNextSibling())
521 {
522 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
523 {
524 continue;
525 }
526
527 const xercesc::DOMElement* const child =
528 dynamic_cast<xercesc::DOMElement*>(iter);
529 if(child == nullptr)
530 {
531 G4Exception("G4GDMLReadMaterials::IsotopeRead()", "InvalidRead",
532 FatalException, "No child found!");
533 return;
534 }
535 const G4String tag = Transcode(child->getTagName());
536
537 if(tag == "atom")
538 {
539 a = AtomRead(child);
540 }
541 }
542
543 new G4Isotope(Strip(name), Z, N, a);
544}

References AtomRead(), G4GDMLRead::eval, G4GDMLEvaluator::EvaluateInteger(), FatalException, G4Exception(), G4GDMLRead::GenerateName(), G4InuclParticleNames::name(), G4GDMLRead::Strip(), G4GDMLRead::Transcode(), and Z.

Referenced by MaterialsRead().

◆ IsValidID()

G4bool G4GDMLReadDefine::IsValidID ( const G4String ref) const
inherited

Definition at line 752 of file G4GDMLReadDefine.cc.

753{
754 return eval.IsVariable(ref);
755}
G4bool IsVariable(const G4String &) const

References G4GDMLRead::eval, and G4GDMLEvaluator::IsVariable().

◆ LoopRead()

void G4GDMLRead::LoopRead ( const xercesc::DOMElement * const  element,
void(G4GDMLRead::*)(const xercesc::DOMElement *const)  func 
)
protectedinherited

Definition at line 194 of file G4GDMLRead.cc.

196{
197 G4String var;
198 G4String from;
199 G4String to;
200 G4String step;
201
202 const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
203 XMLSize_t attributeCount = attributes->getLength();
204
205 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
206 ++attribute_index)
207 {
208 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
209
210 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
211 {
212 continue;
213 }
214
215 const xercesc::DOMAttr* const attribute =
216 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
217 if(!attribute)
218 {
219 G4Exception("G4GDMLRead::LoopRead()", "InvalidRead", FatalException,
220 "No attribute found!");
221 return;
222 }
223 const G4String attribute_name = Transcode(attribute->getName());
224 const G4String attribute_value = Transcode(attribute->getValue());
225
226 if(attribute_name == "for")
227 {
228 var = attribute_value;
229 }
230 else if(attribute_name == "from")
231 {
232 from = attribute_value;
233 }
234 else if(attribute_name == "to")
235 {
236 to = attribute_value;
237 }
238 else if(attribute_name == "step")
239 {
240 step = attribute_value;
241 }
242 }
243
244 if(var.empty())
245 {
246 G4Exception("G4GDMLRead::loopRead()", "InvalidRead", FatalException,
247 "No variable is determined for loop!");
248 }
249
250 if(!eval.IsVariable(var))
251 {
252 G4Exception("G4GDMLRead::loopRead()", "InvalidRead", FatalException,
253 "Variable is not defined in loop!");
254 }
255
256 G4int _var = eval.EvaluateInteger(var);
257 G4int _from = eval.EvaluateInteger(from);
258 G4int _to = eval.EvaluateInteger(to);
259 G4int _step = eval.EvaluateInteger(step);
260
261 if(!from.empty())
262 {
263 _var = _from;
264 }
265
266 if((_from < _to) && (_step <= 0))
267 {
268 G4Exception("G4GDMLRead::loopRead()", "InvalidRead", FatalException,
269 "Infinite loop!");
270 }
271 if((_from > _to) && (_step >= 0))
272 {
273 G4Exception("G4GDMLRead::loopRead()", "InvalidRead", FatalException,
274 "Infinite loop!");
275 }
276
277 ++inLoop;
278
279 while(_var <= _to)
280 {
281 eval.SetVariable(var, _var);
282 (this->*func)(element);
283 _var += _step;
284 ++loopCount;
285 }
286
287 --inLoop;
288 if(!inLoop)
289 {
290 loopCount = 0;
291 }
292}
void SetVariable(const G4String &, G4double)
G4int loopCount
Definition: G4GDMLRead.hh:163

References G4GDMLRead::eval, G4GDMLEvaluator::EvaluateInteger(), FatalException, G4Exception(), G4GDMLRead::inLoop, G4GDMLEvaluator::IsVariable(), G4GDMLRead::loopCount, G4GDMLEvaluator::SetVariable(), and G4GDMLRead::Transcode().

Referenced by G4GDMLReadParamvol::ParameterisedRead(), G4GDMLReadParamvol::Paramvol_contentRead(), G4GDMLReadSolids::SolidsRead(), G4GDMLReadStructure::StructureRead(), and G4GDMLReadStructure::Volume_contentRead().

◆ MaterialRead()

void G4GDMLReadMaterials::MaterialRead ( const xercesc::DOMElement * const  materialElement)
protected

Definition at line 547 of file G4GDMLReadMaterials.cc.

549{
551 G4double Z = 0.0;
552 G4double a = 0.0;
553 G4double D = 0.0;
554 G4State state = kStateUndefined;
557 G4double MEE = -1.0;
558
559 const xercesc::DOMNamedNodeMap* const attributes =
560 materialElement->getAttributes();
561 XMLSize_t attributeCount = attributes->getLength();
562
563 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
564 ++attribute_index)
565 {
566 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
567
568 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
569 {
570 continue;
571 }
572
573 const xercesc::DOMAttr* const attribute =
574 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
575 if(attribute == nullptr)
576 {
577 G4Exception("G4GDMLReadMaterials::MaterialRead()", "InvalidRead",
578 FatalException, "No attribute found!");
579 return;
580 }
581 const G4String attName = Transcode(attribute->getName());
582 const G4String attValue = Transcode(attribute->getValue());
583
584 if(attName == "name")
585 {
586 name = GenerateName(attValue);
587 }
588 else if(attName == "Z")
589 {
590 Z = eval.Evaluate(attValue);
591 }
592 else if(attName == "state")
593 {
594 if(attValue == "solid")
595 {
596 state = kStateSolid;
597 }
598 else if(attValue == "liquid")
599 {
600 state = kStateLiquid;
601 }
602 else if(attValue == "gas")
603 {
604 state = kStateGas;
605 }
606 }
607 }
608
609 std::size_t nComponents = 0;
610
611 for(xercesc::DOMNode* iter = materialElement->getFirstChild();
612 iter != nullptr; iter = iter->getNextSibling())
613 {
614 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
615 {
616 continue;
617 }
618
619 const xercesc::DOMElement* const child =
620 dynamic_cast<xercesc::DOMElement*>(iter);
621 if(child == nullptr)
622 {
623 G4Exception("G4GDMLReadMaterials::MaterialRead()", "InvalidRead",
624 FatalException, "No child found!");
625 return;
626 }
627 const G4String tag = Transcode(child->getTagName());
628
629 if(tag == "atom")
630 {
631 a = AtomRead(child);
632 }
633 else if(tag == "Dref")
634 {
636 }
637 else if(tag == "Pref")
638 {
640 }
641 else if(tag == "Tref")
642 {
643 T = GetQuantity(GenerateName(RefRead(child)));
644 }
645 else if(tag == "MEEref")
646 {
647 MEE = GetQuantity(GenerateName(RefRead(child)));
648 }
649 else if(tag == "D")
650 {
651 D = DRead(child);
652 }
653 else if(tag == "P")
654 {
655 P = PRead(child);
656 }
657 else if(tag == "T")
658 {
659 T = TRead(child);
660 }
661 else if(tag == "MEE")
662 {
663 MEE = MEERead(child);
664 }
665 else if(tag == "fraction" || tag == "composite")
666 {
667 nComponents++;
668 }
669 }
670
671 G4Material* material = nullptr;
672
673 if(nComponents == 0)
674 {
675 material = new G4Material(Strip(name), Z, a, D, state, T, P);
676 }
677 else
678 {
679 material = new G4Material(Strip(name), D, nComponents, state, T, P);
680 MixtureRead(materialElement, material);
681 }
682 if(MEE != -1) // ionisation potential (mean excitation energy)
683 {
684 material->GetIonisation()->SetMeanExcitationEnergy(MEE);
685 }
686
687 for(xercesc::DOMNode* iter = materialElement->getFirstChild();
688 iter != nullptr; iter = iter->getNextSibling())
689 {
690 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
691 {
692 continue;
693 }
694
695 const xercesc::DOMElement* const child =
696 dynamic_cast<xercesc::DOMElement*>(iter);
697 if(child == nullptr)
698 {
699 G4Exception("G4GDMLReadMaterials::MaterialRead()", "InvalidRead",
700 FatalException, "No child found!");
701 return;
702 }
703 const G4String tag = Transcode(child->getTagName());
704
705 if(tag == "property")
706 {
707 PropertyRead(child, material);
708 }
709 }
710}
G4double D(G4double temp)
G4State
Definition: G4Material.hh:111
@ kStateSolid
Definition: G4Material.hh:111
@ kStateLiquid
Definition: G4Material.hh:111
@ kStateGas
Definition: G4Material.hh:111
@ kStateUndefined
Definition: G4Material.hh:111
static const G4double NTP_Temperature
Definition: G4Material.hh:113
G4double GetQuantity(const G4String &)
G4String RefRead(const xercesc::DOMElement *const)
void PropertyRead(const xercesc::DOMElement *const, G4Material *)
G4double MEERead(const xercesc::DOMElement *const)
G4double DRead(const xercesc::DOMElement *const)
G4double PRead(const xercesc::DOMElement *const)
G4double TRead(const xercesc::DOMElement *const)
string material
Definition: eplot.py:19
int STP_Pressure
Definition: hepunit.py:302
static double P[]

References AtomRead(), D(), DRead(), G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4GDMLRead::GenerateName(), G4GDMLReadDefine::GetQuantity(), kStateGas, kStateLiquid, kStateSolid, kStateUndefined, eplot::material, MEERead(), MixtureRead(), G4InuclParticleNames::name(), NTP_Temperature, P, PRead(), PropertyRead(), G4GDMLReadDefine::RefRead(), source.hepunit::STP_Pressure, G4GDMLRead::Strip(), G4GDMLRead::Transcode(), TRead(), and Z.

Referenced by MaterialsRead().

◆ MaterialsRead()

void G4GDMLReadMaterials::MaterialsRead ( const xercesc::DOMElement * const  materialsElement)
virtual

Implements G4GDMLRead.

Definition at line 882 of file G4GDMLReadMaterials.cc.

884{
885#ifdef G4VERBOSE
886 G4cout << "G4GDML: Reading materials..." << G4endl;
887#endif
888 for(xercesc::DOMNode* iter = materialsElement->getFirstChild();
889 iter != nullptr; iter = iter->getNextSibling())
890 {
891 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
892 {
893 continue;
894 }
895
896 const xercesc::DOMElement* const child =
897 dynamic_cast<xercesc::DOMElement*>(iter);
898 if(child == nullptr)
899 {
900 G4Exception("G4GDMLReadMaterials::MaterialsRead()", "InvalidRead",
901 FatalException, "No child found!");
902 return;
903 }
904 const G4String tag = Transcode(child->getTagName());
905
906 if(tag == "define")
907 {
908 DefineRead(child);
909 }
910 else if(tag == "element")
911 {
912 ElementRead(child);
913 }
914 else if(tag == "isotope")
915 {
916 IsotopeRead(child);
917 }
918 else if(tag == "material")
919 {
920 MaterialRead(child);
921 }
922 else
923 {
924 G4String error_msg = "Unknown tag in materials: " + tag;
925 G4Exception("G4GDMLReadMaterials::MaterialsRead()", "InvalidSetup",
926 FatalException, error_msg);
927 }
928 }
929}
virtual void DefineRead(const xercesc::DOMElement *const)
void ElementRead(const xercesc::DOMElement *const)
void IsotopeRead(const xercesc::DOMElement *const)
void MaterialRead(const xercesc::DOMElement *const)

References G4GDMLReadDefine::DefineRead(), ElementRead(), FatalException, G4cout, G4endl, G4Exception(), IsotopeRead(), MaterialRead(), and G4GDMLRead::Transcode().

◆ MatrixRead()

void G4GDMLReadDefine::MatrixRead ( const xercesc::DOMElement * const  matrixElement)
protectedinherited

Definition at line 255 of file G4GDMLReadDefine.cc.

257{
258 G4String name = "";
259 G4int coldim = 0;
260 G4String values = "";
261
262 const xercesc::DOMNamedNodeMap* const attributes =
263 matrixElement->getAttributes();
264 XMLSize_t attributeCount = attributes->getLength();
265
266 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
267 ++attribute_index)
268 {
269 xercesc::DOMNode* node = attributes->item(attribute_index);
270
271 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
272 {
273 continue;
274 }
275
276 const xercesc::DOMAttr* const attribute =
277 dynamic_cast<xercesc::DOMAttr*>(node);
278 if(attribute == nullptr)
279 {
280 G4Exception("G4GDMLRead::MatrixRead()", "InvalidRead", FatalException,
281 "No attribute found!");
282 return;
283 }
284 const G4String attName = Transcode(attribute->getName());
285 const G4String attValue = Transcode(attribute->getValue());
286
287 if(attName == "name")
288 {
289 name = GenerateName(attValue);
290 }
291 else if(attName == "coldim")
292 {
293 coldim = eval.EvaluateInteger(attValue);
294 }
295 else if(attName == "values")
296 {
297 values = attValue;
298 }
299 }
300
301 std::stringstream MatrixValueStream(values);
302 std::vector<G4double> valueList;
303
304 while(!MatrixValueStream.eof())
305 {
306 G4String MatrixValue;
307 MatrixValueStream >> MatrixValue;
308 valueList.push_back(eval.Evaluate(MatrixValue));
309 }
310
311 eval.DefineMatrix(name, coldim, valueList);
312
313 G4GDMLMatrix matrix(valueList.size() / coldim, coldim);
314
315 for(std::size_t i = 0; i < valueList.size(); ++i)
316 {
317 matrix.Set(i / coldim, i % coldim, valueList[i]);
318 }
319
320 matrixMap[name] = matrix;
321}
void DefineMatrix(const G4String &, G4int, std::vector< G4double >)

References G4GDMLEvaluator::DefineMatrix(), G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), G4GDMLEvaluator::EvaluateInteger(), FatalException, G4Exception(), G4GDMLRead::GenerateName(), G4GDMLReadDefine::matrixMap, G4InuclParticleNames::name(), G4GDMLMatrix::Set(), and G4GDMLRead::Transcode().

Referenced by G4GDMLReadDefine::DefineRead().

◆ MEERead()

G4double G4GDMLReadMaterials::MEERead ( const xercesc::DOMElement * const  PElement)
protected

Definition at line 291 of file G4GDMLReadMaterials.cc.

292{
293 G4double value = -1;
294 G4double unit = eV;
295
296 const xercesc::DOMNamedNodeMap* const attributes = PElement->getAttributes();
297 XMLSize_t attributeCount = attributes->getLength();
298
299 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
300 ++attribute_index)
301 {
302 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
303
304 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
305 {
306 continue;
307 }
308
309 const xercesc::DOMAttr* const attribute =
310 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
311 if(attribute == nullptr)
312 {
313 G4Exception("G4GDMLReadMaterials::MEERead()", "InvalidRead",
314 FatalException, "No attribute found!");
315 return value;
316 }
317 const G4String attName = Transcode(attribute->getName());
318 const G4String attValue = Transcode(attribute->getValue());
319
320 if(attName == "value")
321 {
322 value = eval.Evaluate(attValue);
323 }
324 else if(attName == "unit")
325 {
326 unit = G4UnitDefinition::GetValueOf(attValue);
327 if(G4UnitDefinition::GetCategory(attValue) != "Energy")
328 {
329 G4Exception("G4GDMLReadMaterials::MEERead()", "InvalidRead",
330 FatalException, "Invalid unit for energy!");
331 }
332 }
333 }
334
335 return value * unit;
336}
static constexpr double eV
Definition: G4SIunits.hh:201

References eV, G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4UnitDefinition::GetCategory(), G4UnitDefinition::GetValueOf(), and G4GDMLRead::Transcode().

Referenced by MaterialRead().

◆ MixtureRead() [1/2]

void G4GDMLReadMaterials::MixtureRead ( const xercesc::DOMElement * const  mixtureElement,
G4Element element 
)
protected

Definition at line 713 of file G4GDMLReadMaterials.cc.

715{
716 for(xercesc::DOMNode* iter = mixtureElement->getFirstChild(); iter != nullptr;
717 iter = iter->getNextSibling())
718 {
719 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
720 {
721 continue;
722 }
723
724 const xercesc::DOMElement* const child =
725 dynamic_cast<xercesc::DOMElement*>(iter);
726 if(child == nullptr)
727 {
728 G4Exception("G4GDMLReadMaterials::MixtureRead()", "InvalidRead",
729 FatalException, "No child found!");
730 return;
731 }
732 const G4String tag = Transcode(child->getTagName());
733
734 if(tag == "fraction")
735 {
736 G4String ref;
737 G4double n = FractionRead(child, ref);
738 element->AddIsotope(GetIsotope(GenerateName(ref, true)), n);
739 }
740 }
741}
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:151
G4Isotope * GetIsotope(const G4String &, G4bool verbose=true) const
G4double FractionRead(const xercesc::DOMElement *const, G4String &)

References G4Element::AddIsotope(), FatalException, FractionRead(), G4Exception(), G4GDMLRead::GenerateName(), GetIsotope(), CLHEP::detail::n, and G4GDMLRead::Transcode().

Referenced by ElementRead(), and MaterialRead().

◆ MixtureRead() [2/2]

void G4GDMLReadMaterials::MixtureRead ( const xercesc::DOMElement * const  mixtureElement,
G4Material material 
)
protected

Definition at line 744 of file G4GDMLReadMaterials.cc.

746{
747 for(xercesc::DOMNode* iter = mixtureElement->getFirstChild(); iter != nullptr;
748 iter = iter->getNextSibling())
749 {
750 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
751 {
752 continue;
753 }
754
755 const xercesc::DOMElement* const child =
756 dynamic_cast<xercesc::DOMElement*>(iter);
757 if(child == nullptr)
758 {
759 G4Exception("G4GDMLReadMaterials::MixtureRead()", "InvalidRead",
760 FatalException, "No child found!");
761 return;
762 }
763 const G4String tag = Transcode(child->getTagName());
764
765 if(tag == "fraction")
766 {
767 G4String ref;
768 G4double n = FractionRead(child, ref);
769
770 G4Material* materialPtr = GetMaterial(GenerateName(ref, true), false);
771 G4Element* elementPtr = GetElement(GenerateName(ref, true), false);
772
773 if(elementPtr != nullptr)
774 {
775 material->AddElement(elementPtr, n);
776 }
777 else if(materialPtr != nullptr)
778 {
779 material->AddMaterial(materialPtr, n);
780 }
781
782 if((materialPtr == nullptr) && (elementPtr == nullptr))
783 {
784 G4String error_msg = "Referenced material/element '" +
785 GenerateName(ref, true) + "' was not found!";
786 G4Exception("G4GDMLReadMaterials::MixtureRead()", "InvalidSetup",
787 FatalException, error_msg);
788 }
789 }
790 else if(tag == "composite")
791 {
792 G4String ref;
793 G4int n = CompositeRead(child, ref);
794
795 G4Element* elementPtr = GetElement(GenerateName(ref, true));
796 material->AddElement(elementPtr, n);
797 }
798 }
799}
G4Material * GetMaterial(const G4String &, G4bool verbose=true) const
G4Element * GetElement(const G4String &, G4bool verbose=true) const
G4int CompositeRead(const xercesc::DOMElement *const, G4String &)

References CompositeRead(), FatalException, FractionRead(), G4Exception(), G4GDMLRead::GenerateName(), GetElement(), GetMaterial(), eplot::material, CLHEP::detail::n, and G4GDMLRead::Transcode().

◆ OverlapCheck()

void G4GDMLRead::OverlapCheck ( G4bool  flag)
inherited

Definition at line 64 of file G4GDMLRead.cc.

65{
66 check = flag;
67}
G4bool check
Definition: G4GDMLRead.hh:158

References G4GDMLRead::check.

◆ Paramvol_contentRead()

virtual void G4GDMLRead::Paramvol_contentRead ( const xercesc::DOMElement * const  )
pure virtualinherited

◆ PositionRead()

void G4GDMLReadDefine::PositionRead ( const xercesc::DOMElement * const  positionElement)
protectedinherited

Definition at line 324 of file G4GDMLReadDefine.cc.

326{
327 G4String name = "";
328 G4double unit = 1.0;
329 G4ThreeVector position(0., 0., 0.);
330
331 const xercesc::DOMNamedNodeMap* const attributes =
332 positionElement->getAttributes();
333 XMLSize_t attributeCount = attributes->getLength();
334
335 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
336 ++attribute_index)
337 {
338 xercesc::DOMNode* node = attributes->item(attribute_index);
339
340 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
341 {
342 continue;
343 }
344
345 const xercesc::DOMAttr* const attribute =
346 dynamic_cast<xercesc::DOMAttr*>(node);
347 if(attribute == nullptr)
348 {
349 G4Exception("G4GDMLRead::PositionRead()", "InvalidRead", FatalException,
350 "No attribute found!");
351 return;
352 }
353 const G4String attName = Transcode(attribute->getName());
354 const G4String attValue = Transcode(attribute->getValue());
355
356 if(attName == "name")
357 {
358 name = GenerateName(attValue);
359 }
360 else if(attName == "unit")
361 {
362 unit = G4UnitDefinition::GetValueOf(attValue);
363 if(G4UnitDefinition::GetCategory(attValue) != "Length")
364 {
365 G4Exception("G4GDMLReadDefine::PositionRead()", "InvalidRead",
366 FatalException, "Invalid unit for length!");
367 }
368 }
369 else if(attName == "x")
370 {
371 position.setX(eval.Evaluate(attValue));
372 }
373 else if(attName == "y")
374 {
375 position.setY(eval.Evaluate(attValue));
376 }
377 else if(attName == "z")
378 {
379 position.setZ(eval.Evaluate(attValue));
380 }
381 }
382
383 positionMap[name] = position * unit;
384}
#define position
Definition: xmlparse.cc:622

References G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4GDMLRead::GenerateName(), G4UnitDefinition::GetCategory(), G4UnitDefinition::GetValueOf(), G4InuclParticleNames::name(), position, G4GDMLReadDefine::positionMap, and G4GDMLRead::Transcode().

Referenced by G4GDMLReadDefine::DefineRead().

◆ PRead()

G4double G4GDMLReadMaterials::PRead ( const xercesc::DOMElement * const  PElement)
protected

Definition at line 195 of file G4GDMLReadMaterials.cc.

196{
197 G4double value = STP_Pressure;
198 G4double unit = hep_pascal;
199
200 const xercesc::DOMNamedNodeMap* const attributes = PElement->getAttributes();
201 XMLSize_t attributeCount = attributes->getLength();
202
203 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
204 ++attribute_index)
205 {
206 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
207
208 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
209 {
210 continue;
211 }
212
213 const xercesc::DOMAttr* const attribute =
214 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
215 if(attribute == nullptr)
216 {
217 G4Exception("G4GDMLReadMaterials::PRead()", "InvalidRead", FatalException,
218 "No attribute found!");
219 return value;
220 }
221 const G4String attName = Transcode(attribute->getName());
222 const G4String attValue = Transcode(attribute->getValue());
223
224 if(attName == "value")
225 {
226 value = eval.Evaluate(attValue);
227 }
228 else if(attName == "unit")
229 {
230 unit = G4UnitDefinition::GetValueOf(attValue);
231 if(G4UnitDefinition::GetCategory(attValue) != "Pressure")
232 {
233 G4Exception("G4GDMLReadMaterials::PRead()", "InvalidRead",
234 FatalException, "Invalid unit for pressure!");
235 }
236 }
237 }
238
239 return value * unit;
240}
static constexpr double hep_pascal
Definition: G4SIunits.hh:222

References G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4UnitDefinition::GetCategory(), G4UnitDefinition::GetValueOf(), hep_pascal, source.hepunit::STP_Pressure, and G4GDMLRead::Transcode().

Referenced by MaterialRead().

◆ PropertyRead()

void G4GDMLReadMaterials::PropertyRead ( const xercesc::DOMElement * const  propertyElement,
G4Material material 
)
protected

Definition at line 802 of file G4GDMLReadMaterials.cc.

804{
806 G4String ref;
807 G4GDMLMatrix matrix;
808
809 const xercesc::DOMNamedNodeMap* const attributes =
810 propertyElement->getAttributes();
811 XMLSize_t attributeCount = attributes->getLength();
812
813 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
814 ++attribute_index)
815 {
816 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
817
818 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
819 {
820 continue;
821 }
822
823 const xercesc::DOMAttr* const attribute =
824 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
825 if(attribute == nullptr)
826 {
827 G4Exception("G4GDMLReadMaterials::PropertyRead()", "InvalidRead",
828 FatalException, "No attribute found!");
829 return;
830 }
831 const G4String attName = Transcode(attribute->getName());
832 const G4String attValue = Transcode(attribute->getValue());
833
834 if(attName == "name")
835 {
836 name = GenerateName(attValue);
837 }
838 else if(attName == "ref")
839 {
840 matrix = GetMatrix(ref = attValue);
841 }
842 }
843
844 /*
845 if (matrix.GetCols() != 2)
846 {
847 G4String error_msg = "Referenced matrix '" + ref
848 + "' should have \n two columns as a property table for material: "
849 + material->GetName();
850 G4Exception("G4GDMLReadMaterials::PropertyRead()", "InvalidRead",
851 FatalException, error_msg);
852 }
853 */
854
855 if(matrix.GetRows() == 0)
856 {
857 return;
858 }
859
860 G4MaterialPropertiesTable* matprop = material->GetMaterialPropertiesTable();
861 if(matprop == nullptr)
862 {
863 matprop = new G4MaterialPropertiesTable();
864 material->SetMaterialPropertiesTable(matprop);
865 }
866 if(matrix.GetCols() == 1) // constant property assumed
867 {
868 matprop->AddConstProperty(Strip(name), matrix.Get(0, 0), true);
869 }
870 else // build the material properties vector
871 {
873 for(std::size_t i = 0; i < matrix.GetRows(); ++i)
874 {
875 propvect->InsertValues(matrix.Get(i, 0), matrix.Get(i, 1));
876 }
877 matprop->AddProperty(Strip(name), propvect, true);
878 }
879}
G4PhysicsFreeVector G4MaterialPropertyVector
std::size_t GetCols() const
std::size_t GetRows() const
G4double Get(std::size_t r, std::size_t c) const
G4GDMLMatrix GetMatrix(const G4String &)
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)
void InsertValues(const G4double energy, const G4double value)

References G4MaterialPropertiesTable::AddConstProperty(), G4MaterialPropertiesTable::AddProperty(), FatalException, G4Exception(), G4GDMLRead::GenerateName(), G4GDMLMatrix::Get(), G4GDMLMatrix::GetCols(), G4GDMLReadDefine::GetMatrix(), G4GDMLMatrix::GetRows(), G4PhysicsFreeVector::InsertValues(), eplot::material, G4InuclParticleNames::name(), G4GDMLRead::Strip(), and G4GDMLRead::Transcode().

Referenced by MaterialRead().

◆ QuantityRead()

void G4GDMLReadDefine::QuantityRead ( const xercesc::DOMElement * const  element)
protectedinherited

Definition at line 547 of file G4GDMLReadDefine.cc.

548{
549 G4String name = "";
550 G4double unit = 1.0;
551 G4double value = 0.0;
552
553 const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
554 XMLSize_t attributeCount = attributes->getLength();
555
556 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
557 ++attribute_index)
558 {
559 xercesc::DOMNode* node = attributes->item(attribute_index);
560
561 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
562 {
563 continue;
564 }
565
566 const xercesc::DOMAttr* const attribute =
567 dynamic_cast<xercesc::DOMAttr*>(node);
568 if(attribute == nullptr)
569 {
570 G4Exception("G4GDMLRead::QuantityRead()", "InvalidRead", FatalException,
571 "No attribute found!");
572 return;
573 }
574 const G4String attName = Transcode(attribute->getName());
575 const G4String attValue = Transcode(attribute->getValue());
576
577 if(attName == "name")
578 {
579 name = attValue;
580 }
581 else if(attName == "value")
582 {
583 value = eval.Evaluate(attValue);
584 }
585 else if(attName == "unit")
586 {
587 unit = G4UnitDefinition::GetValueOf(attValue);
588 }
589 }
590
591 quantityMap[name] = value * unit;
592 eval.DefineConstant(name, value * unit);
593}

References G4GDMLEvaluator::DefineConstant(), G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4UnitDefinition::GetValueOf(), G4InuclParticleNames::name(), G4GDMLReadDefine::quantityMap, and G4GDMLRead::Transcode().

Referenced by G4GDMLReadDefine::DefineRead().

◆ Read()

void G4GDMLRead::Read ( const G4String fileName,
G4bool  validation,
G4bool  isModule,
G4bool  strip = true 
)
inherited

Definition at line 422 of file G4GDMLRead.cc.

424{
425 dostrip = strip;
426#ifdef G4VERBOSE
427 if(isModule)
428 {
429 G4cout << "G4GDML: Reading module '" << fileName << "'..." << G4endl;
430 }
431 else
432 {
433 G4cout << "G4GDML: Reading '" << fileName << "'..." << G4endl;
434 }
435#endif
436 inLoop = 0;
437 validate = validation;
438
439 xercesc::ErrorHandler* handler = new G4GDMLErrorHandler(!validate);
440 xercesc::XercesDOMParser* parser = new xercesc::XercesDOMParser;
441
442 if(validate)
443 {
444 parser->setValidationScheme(xercesc::XercesDOMParser::Val_Always);
445 }
446 parser->setValidationSchemaFullChecking(validate);
447 parser->setCreateEntityReferenceNodes(false);
448 // Entities will be automatically resolved by Xerces
449
450 parser->setDoNamespaces(true);
451 parser->setDoSchema(validate);
452 parser->setErrorHandler(handler);
453
454 try
455 {
456 parser->parse(fileName.c_str());
457 } catch(const xercesc::XMLException& e)
458 {
459 G4cout << "G4GDML: " << Transcode(e.getMessage()) << G4endl;
460 } catch(const xercesc::DOMException& e)
461 {
462 G4cout << "G4GDML: " << Transcode(e.getMessage()) << G4endl;
463 }
464
465 xercesc::DOMDocument* doc = parser->getDocument();
466
467 if(doc == nullptr)
468 {
469 G4String error_msg = "Unable to open document: " + fileName;
470 G4Exception("G4GDMLRead::Read()", "InvalidRead", FatalException, error_msg);
471 return;
472 }
473 xercesc::DOMElement* element = doc->getDocumentElement();
474
475 if(element == nullptr )
476 {
477 std::ostringstream message;
478 message << "ERROR - Empty document or unable to validate schema!" << G4endl
479 << " Check Internet connection is ON in case of schema"
480 << G4endl
481 << " validation enabled and location defined as URL in"
482 << G4endl << " the GDML file - " << fileName
483 << " - being imported!" << G4endl
484 << " Otherwise, verify GDML schema server is reachable!";
485 G4Exception("G4GDMLRead::Read()", "InvalidRead", FatalException, message);
486 return;
487 }
488
489 for(xercesc::DOMNode* iter = element->getFirstChild(); iter != nullptr;
490 iter = iter->getNextSibling())
491 {
492 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
493 {
494 continue;
495 }
496
497 const xercesc::DOMElement* const child =
498 dynamic_cast<xercesc::DOMElement*>(iter);
499 if(child == nullptr)
500 {
501 G4Exception("G4GDMLRead::Read()", "InvalidRead", FatalException,
502 "No child found!");
503 return;
504 }
505 const G4String tag = Transcode(child->getTagName());
506
507 if(tag == "define")
508 {
509 DefineRead(child);
510 }
511 else if(tag == "materials")
512 {
513 MaterialsRead(child);
514 }
515 else if(tag == "solids")
516 {
517 SolidsRead(child);
518 }
519 else if(tag == "setup")
520 {
521 SetupRead(child);
522 }
523 else if(tag == "structure")
524 {
525 StructureRead(child);
526 }
527 else if(tag == "userinfo")
528 {
529 UserinfoRead(child);
530 }
531 else if(tag == "extension")
532 {
533 ExtensionRead(child);
534 }
535 else
536 {
537 G4String error_msg = "Unknown tag in gdml: " + tag;
538 G4Exception("G4GDMLRead::Read()", "InvalidRead", FatalException,
539 error_msg);
540 }
541 }
542
543 delete parser;
544 delete handler;
545
546 if(isModule)
547 {
548#ifdef G4VERBOSE
549 G4cout << "G4GDML: Reading module '" << fileName << "' done!" << G4endl;
550#endif
551 }
552 else
553 {
554 G4cout << "G4GDML: Reading '" << fileName << "' done!" << G4endl;
555 if(strip)
556 {
557 StripNames();
558 }
559 }
560}
G4bool validate
Definition: G4GDMLRead.hh:157
G4bool dostrip
Definition: G4GDMLRead.hh:159
virtual void SolidsRead(const xercesc::DOMElement *const)=0
virtual void MaterialsRead(const xercesc::DOMElement *const)=0
virtual void UserinfoRead(const xercesc::DOMElement *const)
Definition: G4GDMLRead.cc:377
virtual void SetupRead(const xercesc::DOMElement *const)=0
virtual void ExtensionRead(const xercesc::DOMElement *const)
Definition: G4GDMLRead.cc:414
virtual void DefineRead(const xercesc::DOMElement *const)=0
virtual void StructureRead(const xercesc::DOMElement *const)=0
void StripNames() const
Definition: G4GDMLRead.cc:122

References G4GDMLRead::DefineRead(), G4GDMLRead::dostrip, G4GDMLRead::ExtensionRead(), FatalException, G4cout, G4endl, G4Exception(), G4GDMLRead::inLoop, G4GDMLRead::MaterialsRead(), geant4_check_module_cycles::parser, G4GDMLRead::SetupRead(), G4GDMLRead::SolidsRead(), G4StrUtil::strip(), G4GDMLRead::StripNames(), G4GDMLRead::StructureRead(), G4GDMLRead::Transcode(), G4GDMLRead::UserinfoRead(), and G4GDMLRead::validate.

Referenced by G4GDMLReadStructure::FileRead().

◆ RefRead()

G4String G4GDMLReadDefine::RefRead ( const xercesc::DOMElement * const  element)
protectedinherited

Definition at line 714 of file G4GDMLReadDefine.cc.

715{
716 G4String ref;
717
718 const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
719 XMLSize_t attributeCount = attributes->getLength();
720
721 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
722 ++attribute_index)
723 {
724 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
725
726 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
727 {
728 continue;
729 }
730
731 const xercesc::DOMAttr* const attribute =
732 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
733 if(attribute == nullptr)
734 {
735 G4Exception("G4GDMLRead::Read()", "InvalidRead", FatalException,
736 "No attribute found!");
737 return ref;
738 }
739 const G4String attName = Transcode(attribute->getName());
740 const G4String attValue = Transcode(attribute->getValue());
741
742 if(attName == "ref")
743 {
744 ref = attValue;
745 }
746 }
747
748 return ref;
749}

References FatalException, G4Exception(), and G4GDMLRead::Transcode().

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadStructure::BorderSurfaceRead(), G4GDMLReadStructure::DivisionvolRead(), MaterialRead(), G4GDMLReadSolids::MultiUnionNodeRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadParamvol::ParamvolRead(), G4GDMLReadStructure::PhysvolRead(), G4GDMLReadStructure::ReplicaRead(), G4GDMLReadStructure::ReplicavolRead(), G4GDMLReadSolids::ScaledSolidRead(), G4GDMLReadSetup::SetupRead(), G4GDMLReadStructure::SkinSurfaceRead(), and G4GDMLReadStructure::VolumeRead().

◆ RotationRead()

void G4GDMLReadDefine::RotationRead ( const xercesc::DOMElement * const  rotationElement)
protectedinherited

Definition at line 387 of file G4GDMLReadDefine.cc.

389{
390 G4String name = "";
391 G4double unit = 1.0;
392 G4ThreeVector rotation(0., 0., 0.);
393
394 const xercesc::DOMNamedNodeMap* const attributes =
395 rotationElement->getAttributes();
396 XMLSize_t attributeCount = attributes->getLength();
397
398 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
399 ++attribute_index)
400 {
401 xercesc::DOMNode* node = attributes->item(attribute_index);
402
403 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
404 {
405 continue;
406 }
407
408 const xercesc::DOMAttr* const attribute =
409 dynamic_cast<xercesc::DOMAttr*>(node);
410 if(attribute == nullptr)
411 {
412 G4Exception("G4GDMLRead::RotationRead()", "InvalidRead", FatalException,
413 "No attribute found!");
414 return;
415 }
416 const G4String attName = Transcode(attribute->getName());
417 const G4String attValue = Transcode(attribute->getValue());
418
419 if(attName == "name")
420 {
421 name = GenerateName(attValue);
422 }
423 else if(attName == "unit")
424 {
425 unit = G4UnitDefinition::GetValueOf(attValue);
426 if(G4UnitDefinition::GetCategory(attValue) != "Angle")
427 {
428 G4Exception("G4GDMLReadDefine::RotationRead()", "InvalidRead",
429 FatalException, "Invalid unit for angle!");
430 }
431 }
432 else if(attName == "x")
433 {
434 rotation.setX(eval.Evaluate(attValue));
435 }
436 else if(attName == "y")
437 {
438 rotation.setY(eval.Evaluate(attValue));
439 }
440 else if(attName == "z")
441 {
442 rotation.setZ(eval.Evaluate(attValue));
443 }
444 }
445
446 rotationMap[name] = rotation * unit;
447}

References G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4GDMLRead::GenerateName(), G4UnitDefinition::GetCategory(), G4UnitDefinition::GetValueOf(), G4InuclParticleNames::name(), G4GDMLReadDefine::rotationMap, CLHEP::Hep3Vector::setX(), CLHEP::Hep3Vector::setY(), CLHEP::Hep3Vector::setZ(), and G4GDMLRead::Transcode().

Referenced by G4GDMLReadDefine::DefineRead().

◆ ScaleRead()

void G4GDMLReadDefine::ScaleRead ( const xercesc::DOMElement * const  scaleElement)
protectedinherited

Definition at line 450 of file G4GDMLReadDefine.cc.

451{
452 G4String name = "";
453 G4ThreeVector scale(1.0, 1.0, 1.0);
454
455 const xercesc::DOMNamedNodeMap* const attributes =
456 scaleElement->getAttributes();
457 XMLSize_t attributeCount = attributes->getLength();
458
459 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
460 ++attribute_index)
461 {
462 xercesc::DOMNode* node = attributes->item(attribute_index);
463
464 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
465 {
466 continue;
467 }
468
469 const xercesc::DOMAttr* const attribute =
470 dynamic_cast<xercesc::DOMAttr*>(node);
471 if(attribute == nullptr)
472 {
473 G4Exception("G4GDMLRead::ScaleRead()", "InvalidRead", FatalException,
474 "No attribute found!");
475 return;
476 }
477 const G4String attName = Transcode(attribute->getName());
478 const G4String attValue = Transcode(attribute->getValue());
479
480 if(attName == "name")
481 {
482 name = GenerateName(attValue);
483 }
484 else if(attName == "x")
485 {
486 scale.setX(eval.Evaluate(attValue));
487 }
488 else if(attName == "y")
489 {
490 scale.setY(eval.Evaluate(attValue));
491 }
492 else if(attName == "z")
493 {
494 scale.setZ(eval.Evaluate(attValue));
495 }
496 }
497
498 scaleMap[name] = scale;
499}

References G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4GDMLRead::GenerateName(), G4InuclParticleNames::name(), G4GDMLReadDefine::scaleMap, CLHEP::Hep3Vector::setX(), CLHEP::Hep3Vector::setY(), CLHEP::Hep3Vector::setZ(), and G4GDMLRead::Transcode().

Referenced by G4GDMLReadDefine::DefineRead().

◆ SetReverseSearch()

void G4GDMLReadDefine::SetReverseSearch ( G4bool  flag)
inlineinherited

Definition at line 81 of file G4GDMLReadDefine.hh.

82 { reverseSearch = flag; }

References G4GDMLReadDefine::reverseSearch.

◆ SetupRead()

virtual void G4GDMLRead::SetupRead ( const xercesc::DOMElement * const  )
pure virtualinherited

Implemented in G4GDMLReadSetup.

Referenced by G4GDMLRead::Read().

◆ SolidsRead()

virtual void G4GDMLRead::SolidsRead ( const xercesc::DOMElement * const  )
pure virtualinherited

◆ Strip()

G4String G4GDMLRead::Strip ( const G4String name) const
protectedinherited

◆ StripName()

void G4GDMLRead::StripName ( G4String name) const
inherited

Definition at line 112 of file G4GDMLRead.cc.

113{
114 auto idx = name.find("0x");
115 if(idx != G4String::npos)
116 {
117 name.erase(idx);
118 }
119}

References G4InuclParticleNames::name().

Referenced by G4GDMLParser::ExportRegions(), G4GDMLRead::GenerateName(), G4GDMLParser::ImportRegions(), G4GDMLRead::Strip(), and G4GDMLRead::StripNames().

◆ StripNames()

void G4GDMLRead::StripNames ( ) const
inherited

Definition at line 122 of file G4GDMLRead.cc.

123{
124 // Strips off names of volumes, solids elements and materials from possible
125 // reference pointers or IDs attached to their original identifiers.
126
130 const G4ElementTable* elements = G4Element::GetElementTable();
132
133 G4cout << "Stripping off GDML names of materials, solids and volumes ..."
134 << G4endl;
135
136 G4String sname;
137 std::size_t i;
138
139 // Solids...
140 //
141 for(i = 0; i < solids->size(); ++i)
142 {
143 G4VSolid* psol = (*solids)[i];
144 sname = psol->GetName();
145 StripName(sname);
146 psol->SetName(sname);
147 }
148 solids->UpdateMap();
149
150 // Logical volumes...
151 //
152 for(i = 0; i < lvols->size(); ++i)
153 {
154 G4LogicalVolume* lvol = (*lvols)[i];
155 sname = lvol->GetName();
156 StripName(sname);
157 lvol->SetName(sname);
158 }
159 lvols->UpdateMap();
160
161 // Physical volumes...
162 //
163 for(i = 0; i < pvols->size(); ++i)
164 {
165 G4VPhysicalVolume* pvol = (*pvols)[i];
166 sname = pvol->GetName();
167 StripName(sname);
168 pvol->SetName(sname);
169 }
170 pvols->UpdateMap();
171
172 // Materials...
173 //
174 for(i = 0; i < materials->size(); ++i)
175 {
176 G4Material* pmat = (*materials)[i];
177 sname = pmat->GetName();
178 StripName(sname);
179 pmat->SetName(sname);
180 }
181
182 // Elements...
183 //
184 for(i = 0; i < elements->size(); ++i)
185 {
186 G4Element* pelm = (*elements)[i];
187 sname = pelm->GetName();
188 StripName(sname);
189 pelm->SetName(sname);
190 }
191}
std::vector< G4Element * > G4ElementTable
std::vector< G4Material * > G4MaterialTable
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:397
void SetName(const G4String &name)
Definition: G4Element.hh:215
const G4String & GetName() const
Definition: G4Element.hh:127
static G4LogicalVolumeStore * GetInstance()
void SetName(const G4String &pName)
void SetName(const G4String &name)
Definition: G4Material.hh:285
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:672
const G4String & GetName() const
Definition: G4Material.hh:173
static G4PhysicalVolumeStore * GetInstance()
void UpdateMap()
static G4SolidStore * GetInstance()
const G4String & GetName() const
G4String GetName() const
void SetName(const G4String &name)
Definition: G4VSolid.cc:127

References G4cout, G4endl, G4Element::GetElementTable(), G4LogicalVolumeStore::GetInstance(), G4PhysicalVolumeStore::GetInstance(), G4SolidStore::GetInstance(), G4Material::GetMaterialTable(), G4LogicalVolume::GetName(), G4VPhysicalVolume::GetName(), G4VSolid::GetName(), G4Element::GetName(), G4Material::GetName(), G4VSolid::SetName(), G4Element::SetName(), G4Material::SetName(), G4LogicalVolume::SetName(), G4VPhysicalVolume::SetName(), G4GDMLRead::StripName(), G4LogicalVolumeStore::UpdateMap(), G4PhysicalVolumeStore::UpdateMap(), and G4SolidStore::UpdateMap().

Referenced by G4GDMLRead::Read().

◆ StructureRead()

virtual void G4GDMLRead::StructureRead ( const xercesc::DOMElement * const  )
pure virtualinherited

◆ Transcode()

G4String G4GDMLRead::Transcode ( const XMLCh * const  toTranscode)
protectedinherited

Definition at line 55 of file G4GDMLRead.cc.

56{
57 char* char_str = xercesc::XMLString::transcode(toTranscode);
58 G4String my_str(char_str);
59 xercesc::XMLString::release(&char_str);
60 return my_str;
61}

Referenced by G4GDMLReadStructure::AssemblyRead(), AtomRead(), G4GDMLRead::AuxiliaryRead(), G4GDMLReadStructure::AxisRead(), G4GDMLReadSolids::BooleanRead(), G4GDMLReadStructure::BorderSurfaceRead(), G4GDMLReadParamvol::Box_dimensionsRead(), G4GDMLReadSolids::BoxRead(), CompositeRead(), G4GDMLReadParamvol::Cone_dimensionsRead(), G4GDMLReadSolids::ConeRead(), G4GDMLReadDefine::ConstantRead(), G4GDMLReadSolids::CutTubeRead(), G4GDMLReadDefine::DefineRead(), G4GDMLReadStructure::DivisionvolRead(), DRead(), G4GDMLReadSolids::ElconeRead(), ElementRead(), G4GDMLReadParamvol::Ellipsoid_dimensionsRead(), G4GDMLReadSolids::EllipsoidRead(), G4GDMLReadSolids::EltubeRead(), G4GDMLReadDefine::ExpressionRead(), G4GDMLReadStructure::FileRead(), FractionRead(), G4GDMLReadSolids::GenericPolyconeRead(), G4GDMLReadSolids::GenericPolyhedraRead(), G4GDMLReadSolids::GenTrapRead(), G4GDMLReadParamvol::Hype_dimensionsRead(), G4GDMLReadSolids::HypeRead(), IsotopeRead(), G4GDMLRead::LoopRead(), MaterialRead(), MaterialsRead(), G4GDMLReadDefine::MatrixRead(), MEERead(), MixtureRead(), G4GDMLReadSolids::MultiUnionNodeRead(), G4GDMLReadSolids::MultiUnionRead(), G4GDMLReadSolids::OpticalSurfaceRead(), G4GDMLReadParamvol::Orb_dimensionsRead(), G4GDMLReadSolids::OrbRead(), G4GDMLReadParamvol::Para_dimensionsRead(), G4GDMLReadSolids::ParaboloidRead(), G4GDMLReadParamvol::ParameterisedRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadParamvol::Paramvol_contentRead(), G4GDMLReadParamvol::ParamvolRead(), G4GDMLReadSolids::ParaRead(), G4GDMLReadStructure::PhysvolRead(), G4GDMLReadParamvol::Polycone_dimensionsRead(), G4GDMLReadSolids::PolyconeRead(), G4GDMLReadParamvol::Polyhedra_dimensionsRead(), G4GDMLReadSolids::PolyhedraRead(), G4GDMLReadDefine::PositionRead(), PRead(), PropertyRead(), G4GDMLReadSolids::PropertyRead(), G4GDMLReadSolids::QuadrangularRead(), G4GDMLReadStructure::QuantityRead(), G4GDMLReadDefine::QuantityRead(), G4GDMLRead::Read(), G4GDMLReadSolids::ReflectedSolidRead(), G4GDMLReadDefine::RefRead(), G4GDMLReadStructure::ReplicaRead(), G4GDMLReadStructure::ReplicavolRead(), G4GDMLReadDefine::RotationRead(), G4GDMLReadSolids::RZPointRead(), G4GDMLReadSolids::ScaledSolidRead(), G4GDMLReadDefine::ScaleRead(), G4GDMLReadSolids::SectionRead(), G4GDMLReadSetup::SetupRead(), G4GDMLReadStructure::SkinSurfaceRead(), G4GDMLReadSolids::SolidsRead(), G4GDMLReadParamvol::Sphere_dimensionsRead(), G4GDMLReadSolids::SphereRead(), G4GDMLReadStructure::StructureRead(), G4GDMLReadSolids::TessellatedRead(), G4GDMLReadSolids::TetRead(), G4GDMLReadParamvol::Torus_dimensionsRead(), G4GDMLReadSolids::TorusRead(), G4GDMLReadParamvol::Trap_dimensionsRead(), G4GDMLReadSolids::TrapRead(), G4GDMLReadParamvol::Trd_dimensionsRead(), G4GDMLReadSolids::TrdRead(), TRead(), G4GDMLReadSolids::TriangularRead(), G4GDMLReadParamvol::Tube_dimensionsRead(), G4GDMLReadSolids::TubeRead(), G4GDMLReadSolids::TwistedboxRead(), G4GDMLReadSolids::TwistedtrapRead(), G4GDMLReadSolids::TwistedtrdRead(), G4GDMLReadSolids::TwistedtubsRead(), G4GDMLReadSolids::TwoDimVertexRead(), G4GDMLRead::UserinfoRead(), G4GDMLReadDefine::VariableRead(), G4GDMLReadDefine::VectorRead(), G4GDMLReadStructure::Volume_contentRead(), G4GDMLReadStructure::VolumeRead(), G4GDMLReadSolids::XtruRead(), and G4GDMLReadSolids::ZplaneRead().

◆ TRead()

G4double G4GDMLReadMaterials::TRead ( const xercesc::DOMElement * const  TElement)
protected

Definition at line 243 of file G4GDMLReadMaterials.cc.

244{
246 G4double unit = kelvin;
247
248 const xercesc::DOMNamedNodeMap* const attributes = TElement->getAttributes();
249 XMLSize_t attributeCount = attributes->getLength();
250
251 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
252 ++attribute_index)
253 {
254 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
255
256 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
257 {
258 continue;
259 }
260
261 const xercesc::DOMAttr* const attribute =
262 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
263 if(attribute == nullptr)
264 {
265 G4Exception("G4GDMLReadMaterials::TRead()", "InvalidRead", FatalException,
266 "No attribute found!");
267 return value;
268 }
269 const G4String attName = Transcode(attribute->getName());
270 const G4String attValue = Transcode(attribute->getValue());
271
272 if(attName == "value")
273 {
274 value = eval.Evaluate(attValue);
275 }
276 else if(attName == "unit")
277 {
278 unit = G4UnitDefinition::GetValueOf(attValue);
279 if(G4UnitDefinition::GetCategory(attValue) != "Temperature")
280 {
281 G4Exception("G4GDMLReadMaterials::TRead()", "InvalidRead",
282 FatalException, "Invalid unit for temperature!");
283 }
284 }
285 }
286
287 return value * unit;
288}
static constexpr double kelvin
Definition: G4SIunits.hh:274

References G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4UnitDefinition::GetCategory(), G4UnitDefinition::GetValueOf(), kelvin, NTP_Temperature, and G4GDMLRead::Transcode().

Referenced by MaterialRead().

◆ UserinfoRead()

void G4GDMLRead::UserinfoRead ( const xercesc::DOMElement * const  userinfoElement)
virtualinherited

Definition at line 377 of file G4GDMLRead.cc.

378{
379#ifdef G4VERBOSE
380 G4cout << "G4GDML: Reading userinfo..." << G4endl;
381#endif
382 for(xercesc::DOMNode* iter = userinfoElement->getFirstChild();
383 iter != nullptr; iter = iter->getNextSibling())
384 {
385 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
386 {
387 continue;
388 }
389
390 const xercesc::DOMElement* const child =
391 dynamic_cast<xercesc::DOMElement*>(iter);
392 if(!child)
393 {
394 G4Exception("G4GDMLRead::UserinfoRead()", "InvalidRead", FatalException,
395 "No child found!");
396 return;
397 }
398 const G4String tag = Transcode(child->getTagName());
399
400 if(tag == "auxiliary")
401 {
402 auxGlobalList.push_back(AuxiliaryRead(child));
403 }
404 else
405 {
406 G4String error_msg = "Unknown tag in structure: " + tag;
407 G4Exception("G4GDMLRead::UserinfoRead()", "ReadError", FatalException,
408 error_msg);
409 }
410 }
411}

References G4GDMLRead::auxGlobalList, G4GDMLRead::AuxiliaryRead(), FatalException, G4cout, G4endl, G4Exception(), and G4GDMLRead::Transcode().

Referenced by G4GDMLRead::Read().

◆ VariableRead()

void G4GDMLReadDefine::VariableRead ( const xercesc::DOMElement * const  variableElement)
protectedinherited

Definition at line 502 of file G4GDMLReadDefine.cc.

504{
505 G4String name = "";
506 G4double value = 0.0;
507
508 const xercesc::DOMNamedNodeMap* const attributes =
509 variableElement->getAttributes();
510 XMLSize_t attributeCount = attributes->getLength();
511
512 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
513 ++attribute_index)
514 {
515 xercesc::DOMNode* node = attributes->item(attribute_index);
516
517 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
518 {
519 continue;
520 }
521
522 const xercesc::DOMAttr* const attribute =
523 dynamic_cast<xercesc::DOMAttr*>(node);
524 if(attribute == nullptr)
525 {
526 G4Exception("G4GDMLRead::VariableRead()", "InvalidRead", FatalException,
527 "No attribute found!");
528 return;
529 }
530 const G4String attName = Transcode(attribute->getName());
531 const G4String attValue = Transcode(attribute->getValue());
532
533 if(attName == "name")
534 {
535 name = attValue;
536 }
537 else if(attName == "value")
538 {
539 value = eval.Evaluate(attValue);
540 }
541 }
542
543 eval.DefineVariable(name, value);
544}
void DefineVariable(const G4String &, G4double)

References G4GDMLEvaluator::DefineVariable(), G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4InuclParticleNames::name(), and G4GDMLRead::Transcode().

Referenced by G4GDMLReadDefine::DefineRead().

◆ VectorRead()

void G4GDMLReadDefine::VectorRead ( const xercesc::DOMElement * const  vectorElement,
G4ThreeVector vec 
)
protectedinherited

Definition at line 662 of file G4GDMLReadDefine.cc.

664{
665 G4double unit = 1.0;
666
667 const xercesc::DOMNamedNodeMap* const attributes =
668 vectorElement->getAttributes();
669 XMLSize_t attributeCount = attributes->getLength();
670
671 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
672 ++attribute_index)
673 {
674 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
675
676 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
677 {
678 continue;
679 }
680
681 const xercesc::DOMAttr* const attribute =
682 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
683 if(attribute == nullptr)
684 {
685 G4Exception("G4GDMLRead::VectorRead()", "InvalidRead", FatalException,
686 "No attribute found!");
687 return;
688 }
689 const G4String attName = Transcode(attribute->getName());
690 const G4String attValue = Transcode(attribute->getValue());
691
692 if(attName == "unit")
693 {
694 unit = G4UnitDefinition::GetValueOf(attValue);
695 }
696 else if(attName == "x")
697 {
698 vec.setX(eval.Evaluate(attValue));
699 }
700 else if(attName == "y")
701 {
702 vec.setY(eval.Evaluate(attValue));
703 }
704 else if(attName == "z")
705 {
706 vec.setZ(eval.Evaluate(attValue));
707 }
708 }
709
710 vec *= unit;
711}
void setY(double)
void setZ(double)
void setX(double)

References G4GDMLRead::eval, G4GDMLEvaluator::Evaluate(), FatalException, G4Exception(), G4UnitDefinition::GetValueOf(), CLHEP::Hep3Vector::setX(), CLHEP::Hep3Vector::setY(), CLHEP::Hep3Vector::setZ(), and G4GDMLRead::Transcode().

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadSolids::MultiUnionNodeRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadStructure::PhysvolRead(), G4GDMLReadStructure::ReplicaRead(), and G4GDMLReadSolids::ScaledSolidRead().

◆ Volume_contentRead()

virtual void G4GDMLRead::Volume_contentRead ( const xercesc::DOMElement * const  )
pure virtualinherited

Field Documentation

◆ auxGlobalList

G4GDMLAuxListType G4GDMLRead::auxGlobalList
privateinherited

Definition at line 164 of file G4GDMLRead.hh.

Referenced by G4GDMLRead::GetAuxList(), and G4GDMLRead::UserinfoRead().

◆ check

G4bool G4GDMLRead::check = false
protectedinherited

◆ dostrip

G4bool G4GDMLRead::dostrip = true
protectedinherited

Definition at line 159 of file G4GDMLRead.hh.

Referenced by G4GDMLReadStructure::GetWorldVolume(), and G4GDMLRead::Read().

◆ eval

G4GDMLEvaluator G4GDMLRead::eval
protectedinherited

Definition at line 156 of file G4GDMLRead.hh.

Referenced by AtomRead(), G4GDMLReadStructure::AxisRead(), G4GDMLReadParamvol::Box_dimensionsRead(), G4GDMLReadSolids::BoxRead(), G4GDMLReadStructure::Clear(), CompositeRead(), G4GDMLReadParamvol::Cone_dimensionsRead(), G4GDMLReadSolids::ConeRead(), G4GDMLReadDefine::ConstantRead(), G4GDMLReadSolids::CutTubeRead(), G4GDMLReadStructure::DivisionvolRead(), DRead(), G4GDMLReadSolids::ElconeRead(), ElementRead(), G4GDMLReadParamvol::Ellipsoid_dimensionsRead(), G4GDMLReadSolids::EllipsoidRead(), G4GDMLReadSolids::EltubeRead(), G4GDMLReadDefine::ExpressionRead(), FractionRead(), G4GDMLRead::GenerateName(), G4GDMLRead::GeneratePhysvolName(), G4GDMLReadSolids::GenericPolyconeRead(), G4GDMLReadSolids::GenericPolyhedraRead(), G4GDMLReadSolids::GenTrapRead(), G4GDMLReadDefine::GetConstant(), G4GDMLReadDefine::GetVariable(), G4GDMLReadParamvol::Hype_dimensionsRead(), G4GDMLReadSolids::HypeRead(), IsotopeRead(), G4GDMLReadDefine::IsValidID(), G4GDMLRead::LoopRead(), MaterialRead(), G4GDMLReadDefine::MatrixRead(), MEERead(), G4GDMLReadSolids::OpticalSurfaceRead(), G4GDMLReadParamvol::Orb_dimensionsRead(), G4GDMLReadSolids::OrbRead(), G4GDMLReadParamvol::Para_dimensionsRead(), G4GDMLReadSolids::ParaboloidRead(), G4GDMLReadParamvol::ParameterisedRead(), G4GDMLReadSolids::ParaRead(), G4GDMLReadStructure::PhysvolRead(), G4GDMLReadParamvol::Polycone_dimensionsRead(), G4GDMLReadSolids::PolyconeRead(), G4GDMLReadParamvol::Polyhedra_dimensionsRead(), G4GDMLReadSolids::PolyhedraRead(), G4GDMLReadDefine::PositionRead(), PRead(), G4GDMLReadStructure::QuantityRead(), G4GDMLReadDefine::QuantityRead(), G4GDMLReadSolids::ReflectedSolidRead(), G4GDMLReadDefine::RotationRead(), G4GDMLReadSolids::RZPointRead(), G4GDMLReadDefine::ScaleRead(), G4GDMLReadSolids::SectionRead(), G4GDMLReadParamvol::Sphere_dimensionsRead(), G4GDMLReadSolids::SphereRead(), G4GDMLReadParamvol::Torus_dimensionsRead(), G4GDMLReadSolids::TorusRead(), G4GDMLReadParamvol::Trap_dimensionsRead(), G4GDMLReadSolids::TrapRead(), G4GDMLReadParamvol::Trd_dimensionsRead(), G4GDMLReadSolids::TrdRead(), TRead(), G4GDMLReadParamvol::Tube_dimensionsRead(), G4GDMLReadSolids::TubeRead(), G4GDMLReadSolids::TwistedboxRead(), G4GDMLReadSolids::TwistedtrapRead(), G4GDMLReadSolids::TwistedtrdRead(), G4GDMLReadSolids::TwistedtubsRead(), G4GDMLReadSolids::TwoDimVertexRead(), G4GDMLReadDefine::VariableRead(), G4GDMLReadDefine::VectorRead(), G4GDMLReadStructure::Volume_contentRead(), and G4GDMLReadSolids::ZplaneRead().

◆ inLoop

G4int G4GDMLRead::inLoop = 0
privateinherited

Definition at line 163 of file G4GDMLRead.hh.

Referenced by G4GDMLRead::GenerateName(), G4GDMLRead::LoopRead(), and G4GDMLRead::Read().

◆ loopCount

G4int G4GDMLRead::loopCount = 0
privateinherited

Definition at line 163 of file G4GDMLRead.hh.

Referenced by G4GDMLRead::LoopRead().

◆ matrixMap

std::map<G4String, G4GDMLMatrix> G4GDMLReadDefine::matrixMap
protectedinherited

◆ positionMap

std::map<G4String, G4ThreeVector> G4GDMLReadDefine::positionMap
protectedinherited

◆ quantityMap

std::map<G4String, G4double> G4GDMLReadDefine::quantityMap
protectedinherited

◆ reverseSearch

G4bool G4GDMLReadDefine::reverseSearch = false
protectedinherited

◆ rotationMap

std::map<G4String, G4ThreeVector> G4GDMLReadDefine::rotationMap
protectedinherited

◆ scaleMap

std::map<G4String, G4ThreeVector> G4GDMLReadDefine::scaleMap
protectedinherited

Definition at line 107 of file G4GDMLReadDefine.hh.

Referenced by G4GDMLReadDefine::GetScale(), and G4GDMLReadDefine::ScaleRead().

◆ validate

G4bool G4GDMLRead::validate = true
protectedinherited

Definition at line 157 of file G4GDMLRead.hh.

Referenced by G4GDMLReadStructure::FileRead(), and G4GDMLRead::Read().


The documentation for this class was generated from the following files: