38 :
m(0), rows(0), cols(0)
44 if ((rows0==0) || (cols0==0))
46 G4Exception(
"G4GDMLMatrix::G4GDMLMatrix(r,c)",
"InvalidSetup",
55 :
m(0), rows(0), cols(0)
62 for (
size_t i=0; i<
rows*
cols; i++) {
m[i] = rhs.
m[i]; }
70 if (
this == &rhs) {
return *
this; }
79 for (
size_t i=0; i<
rows*
cols; i++) {
m[i] = rhs.
m[i]; }
151 const xercesc::DOMNamedNodeMap*
const attributes
152 = constantElement->getAttributes();
153 XMLSize_t attributeCount = attributes->getLength();
155 for (XMLSize_t attribute_index=0;
156 attribute_index<attributeCount; attribute_index++)
158 xercesc::DOMNode* node = attributes->item(attribute_index);
160 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
162 const xercesc::DOMAttr*
const attribute
163 =
dynamic_cast<xercesc::DOMAttr*
>(node);
166 G4Exception(
"G4GDMLRead::ConstantRead()",
"InvalidRead",
173 if (attName==
"name") { name = attValue; }
else
174 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
186 const xercesc::DOMNamedNodeMap*
const attributes
187 = expElement->getAttributes();
188 XMLSize_t attributeCount = attributes->getLength();
190 for (XMLSize_t attribute_index=0;
191 attribute_index<attributeCount; attribute_index++)
193 xercesc::DOMNode* node = attributes->item(attribute_index);
195 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
197 const xercesc::DOMAttr*
const attribute
198 =
dynamic_cast<xercesc::DOMAttr*
>(node);
201 G4Exception(
"G4GDMLRead::ExpressionRead()",
"InvalidRead",
208 if (attName==
"name") { name = attValue; }
223 const xercesc::DOMNamedNodeMap*
const attributes
224 = matrixElement->getAttributes();
225 XMLSize_t attributeCount = attributes->getLength();
227 for (XMLSize_t attribute_index=0;
228 attribute_index<attributeCount; attribute_index++)
230 xercesc::DOMNode* node = attributes->item(attribute_index);
232 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
234 const xercesc::DOMAttr*
const attribute
235 =
dynamic_cast<xercesc::DOMAttr*
>(node);
238 G4Exception(
"G4GDMLRead::MatrixRead()",
"InvalidRead",
245 if (attName==
"name") { name =
GenerateName(attValue); }
else
247 if (attName==
"values") { values = attValue; }
250 std::stringstream MatrixValueStream(values);
251 std::vector<G4double> valueList;
253 while (!MatrixValueStream.eof())
256 MatrixValueStream >> MatrixValue;
264 for (
size_t i=0;i<valueList.size();i++)
266 matrix.
Set(i/coldim,i%coldim,valueList[i]);
279 const xercesc::DOMNamedNodeMap*
const attributes
280 = positionElement->getAttributes();
281 XMLSize_t attributeCount = attributes->getLength();
283 for (XMLSize_t attribute_index=0;
284 attribute_index<attributeCount; attribute_index++)
286 xercesc::DOMNode* node = attributes->item(attribute_index);
288 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
290 const xercesc::DOMAttr*
const attribute
291 =
dynamic_cast<xercesc::DOMAttr*
>(node);
294 G4Exception(
"G4GDMLRead::PositionRead()",
"InvalidRead",
301 if (attName==
"name") { name =
GenerateName(attValue); }
else
304 G4Exception(
"G4GDMLReadDefine::PositionRead()",
"InvalidRead",
322 const xercesc::DOMNamedNodeMap*
const attributes
323 = rotationElement->getAttributes();
324 XMLSize_t attributeCount = attributes->getLength();
326 for (XMLSize_t attribute_index=0;
327 attribute_index<attributeCount; attribute_index++)
329 xercesc::DOMNode* node = attributes->item(attribute_index);
331 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
333 const xercesc::DOMAttr*
const attribute
334 =
dynamic_cast<xercesc::DOMAttr*
>(node);
337 G4Exception(
"G4GDMLRead::RotationRead()",
"InvalidRead",
344 if (attName==
"name") { name =
GenerateName(attValue); }
else
347 G4Exception(
"G4GDMLReadDefine::RotationRead()",
"InvalidRead",
363 const xercesc::DOMNamedNodeMap*
const attributes
364 = scaleElement->getAttributes();
365 XMLSize_t attributeCount = attributes->getLength();
367 for (XMLSize_t attribute_index=0;
368 attribute_index<attributeCount; attribute_index++)
370 xercesc::DOMNode* node = attributes->item(attribute_index);
372 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
374 const xercesc::DOMAttr*
const attribute
375 =
dynamic_cast<xercesc::DOMAttr*
>(node);
378 G4Exception(
"G4GDMLRead::ScaleRead()",
"InvalidRead",
385 if (attName==
"name") { name =
GenerateName(attValue); }
else
400 const xercesc::DOMNamedNodeMap*
const attributes
401 = variableElement->getAttributes();
402 XMLSize_t attributeCount = attributes->getLength();
404 for (XMLSize_t attribute_index=0;
405 attribute_index<attributeCount; attribute_index++)
407 xercesc::DOMNode* node = attributes->item(attribute_index);
409 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
411 const xercesc::DOMAttr*
const attribute
412 =
dynamic_cast<xercesc::DOMAttr*
>(node);
415 G4Exception(
"G4GDMLRead::VariableRead()",
"InvalidRead",
422 if (attName==
"name") { name = attValue; }
else
423 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
435 const xercesc::DOMNamedNodeMap*
const attributes
436 = element->getAttributes();
437 XMLSize_t attributeCount = attributes->getLength();
439 for (XMLSize_t attribute_index=0;
440 attribute_index<attributeCount; attribute_index++)
442 xercesc::DOMNode* node = attributes->item(attribute_index);
444 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
446 const xercesc::DOMAttr*
const attribute
447 =
dynamic_cast<xercesc::DOMAttr*
>(node);
450 G4Exception(
"G4GDMLRead::QuantityRead()",
"InvalidRead",
457 if (attName==
"name") { name = attValue; }
else
458 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
else
472 for (xercesc::DOMNode* iter = defineElement->getFirstChild();
473 iter != 0;iter = iter->getNextSibling())
475 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
477 const xercesc::DOMElement*
const child
478 =
dynamic_cast<xercesc::DOMElement*
>(iter);
481 G4Exception(
"G4GDMLRead::DefineRead()",
"InvalidRead",
488 if (tag==
"matrix") {
MatrixRead(child); }
else
491 if (tag==
"scale") {
ScaleRead(child); }
else
497 G4String error_msg =
"Unknown tag in define: "+tag;
498 G4Exception(
"G4GDMLReadDefine::defineRead()",
"ReadError",
510 const xercesc::DOMNamedNodeMap*
const attributes
511 = vectorElement->getAttributes();
512 XMLSize_t attributeCount = attributes->getLength();
514 for (XMLSize_t attribute_index=0;
515 attribute_index<attributeCount; attribute_index++)
517 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
519 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
522 const xercesc::DOMAttr*
const attribute
523 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
526 G4Exception(
"G4GDMLRead::VectorRead()",
"InvalidRead",
546 const xercesc::DOMNamedNodeMap*
const attributes = element->getAttributes();
547 XMLSize_t attributeCount = attributes->getLength();
549 for (XMLSize_t attribute_index=0;
550 attribute_index<attributeCount; attribute_index++)
552 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
554 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
557 const xercesc::DOMAttr*
const attribute
558 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
568 if (attName==
"ref") { ref = attValue; }
593 G4String error_msg =
"Quantity '"+ref+
"' was not found!";
594 G4Exception(
"G4GDMLReadDefine::getQuantity()",
"ReadError",
604 G4String error_msg =
"Position '"+ref+
"' was not found!";
605 G4Exception(
"G4GDMLReadDefine::getPosition()",
"ReadError",
615 G4String error_msg =
"Rotation '"+ref+
"' was not found!";
616 G4Exception(
"G4GDMLReadDefine::getRotation()",
"ReadError",
626 G4String error_msg =
"Scale '"+ref+
"' was not found!";
627 G4Exception(
"G4GDMLReadDefine::getScale()",
"ReadError",
637 G4String error_msg =
"Matrix '"+ref+
"' was not found!";
638 G4Exception(
"G4GDMLReadDefine::getMatrix()",
"ReadError",
void DefineVariable(const G4String &, G4double)
std::vector< ExP01TrackerHit * > a
G4double GetQuantity(const G4String &)
G4String GenerateName(const G4String &name, G4bool strip=false)
G4double Evaluate(const G4String &)
void QuantityRead(const xercesc::DOMElement *const)
void VectorRead(const xercesc::DOMElement *const, G4ThreeVector &)
void ConstantRead(const xercesc::DOMElement *const)
G4double GetConstant(const G4String &)
std::map< G4String, G4double > quantityMap
void VariableRead(const xercesc::DOMElement *const)
std::map< G4String, G4ThreeVector > scaleMap
G4GDMLMatrix & operator=(const G4GDMLMatrix &rhs)
static constexpr double m
G4String RefRead(const xercesc::DOMElement *const)
virtual void DefineRead(const xercesc::DOMElement *const)
G4double GetVariable(const G4String &)
const XML_Char int const XML_Char * value
G4String Transcode(const XMLCh *const)
G4bool IsValidID(const G4String &) const
G4ThreeVector GetScale(const G4String &)
G4RotationMatrix GetRotationMatrix(const G4ThreeVector &)
static G4double GetValueOf(const G4String &)
void ScaleRead(const xercesc::DOMElement *const)
std::map< G4String, G4GDMLMatrix > matrixMap
void PositionRead(const xercesc::DOMElement *const)
void ExpressionRead(const xercesc::DOMElement *const)
G4double GetConstant(const G4String &)
void DefineConstant(const G4String &, G4double)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
HepRotation & rotateY(double delta)
void DefineMatrix(const G4String &, G4int, std::vector< G4double >)
void Set(size_t r, size_t c, G4double a)
G4double GetVariable(const G4String &)
HepRotation & rotateZ(double delta)
void RotationRead(const xercesc::DOMElement *const)
std::map< G4String, G4ThreeVector > positionMap
G4GLOB_DLL std::ostream G4cout
G4double Get(size_t r, size_t c) const
G4bool IsVariable(const G4String &) const
static G4String GetCategory(const G4String &)
G4GDMLMatrix GetMatrix(const G4String &)
G4int EvaluateInteger(const G4String &)
G4ThreeVector GetPosition(const G4String &)
std::map< G4String, G4ThreeVector > rotationMap
HepRotation & rotateX(double delta)
void MatrixRead(const xercesc::DOMElement *const)
virtual ~G4GDMLReadDefine()
G4ThreeVector GetRotation(const G4String &)