Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/persistency/gdml/src/G4GDMLReadDefine.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /persistency/gdml/src/G4GDMLReadDefine.cc (Version 11.3.0) and /persistency/gdml/src/G4GDMLReadDefine.cc (Version 10.7)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4GDMLReadDefine implementation                 26 // G4GDMLReadDefine implementation
 27 //                                                 27 //
 28 // Author: Zoltan Torzsok, November 2007           28 // Author: Zoltan Torzsok, November 2007
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4GDMLReadDefine.hh"                     31 #include "G4GDMLReadDefine.hh"
 32 #include "G4UnitsTable.hh"                         32 #include "G4UnitsTable.hh"
 33                                                    33 
 34 // G4GDMLMatrix ------------------------------     34 // G4GDMLMatrix -------------------------------------------------------
 35                                                    35 
 36 // -------------------------------------------     36 // --------------------------------------------------------------------
 37 G4GDMLMatrix::G4GDMLMatrix()                       37 G4GDMLMatrix::G4GDMLMatrix()
 38 {                                                  38 {
 39 }                                                  39 }
 40                                                    40 
 41 // -------------------------------------------     41 // --------------------------------------------------------------------
 42 G4GDMLMatrix::G4GDMLMatrix(std::size_t rows0,      42 G4GDMLMatrix::G4GDMLMatrix(std::size_t rows0, std::size_t cols0)
 43 {                                                  43 {
 44   if((rows0 == 0) || (cols0 == 0))                 44   if((rows0 == 0) || (cols0 == 0))
 45   {                                                45   {
 46     G4Exception("G4GDMLMatrix::G4GDMLMatrix(r,     46     G4Exception("G4GDMLMatrix::G4GDMLMatrix(r,c)", "InvalidSetup",
 47                 FatalException, "Zero indices      47                 FatalException, "Zero indices as arguments!?");
 48   }                                                48   }
 49   rows = rows0;                                    49   rows = rows0;
 50   cols = cols0;                                    50   cols = cols0;
 51   m    = new G4double[rows * cols];                51   m    = new G4double[rows * cols];
 52 }                                                  52 }
 53                                                    53 
 54 // -------------------------------------------     54 // --------------------------------------------------------------------
 55 G4GDMLMatrix::G4GDMLMatrix(const G4GDMLMatrix&     55 G4GDMLMatrix::G4GDMLMatrix(const G4GDMLMatrix& rhs)
 56 {                                                  56 {
 57   if(rhs.m)                                        57   if(rhs.m)
 58   {                                                58   {
 59     rows = rhs.rows;                               59     rows = rhs.rows;
 60     cols = rhs.cols;                               60     cols = rhs.cols;
 61     m    = new G4double[rows * cols];              61     m    = new G4double[rows * cols];
 62     for(std::size_t i = 0; i < rows * cols; ++     62     for(std::size_t i = 0; i < rows * cols; ++i)
 63     {                                              63     {
 64       m[i] = rhs.m[i];                             64       m[i] = rhs.m[i];
 65     }                                              65     }
 66   }                                                66   }
 67 }                                                  67 }
 68                                                    68 
 69 // -------------------------------------------     69 // --------------------------------------------------------------------
 70 G4GDMLMatrix& G4GDMLMatrix::operator=(const G4     70 G4GDMLMatrix& G4GDMLMatrix::operator=(const G4GDMLMatrix& rhs)
 71 {                                                  71 {
 72   // Check assignment to self                      72   // Check assignment to self
 73   //                                               73   //
 74   if(this == &rhs)                                 74   if(this == &rhs)
 75   {                                                75   {
 76     return *this;                                  76     return *this;
 77   }                                                77   }
 78                                                    78 
 79   // Copy data                                     79   // Copy data
 80   //                                               80   //
 81   rows = rhs.rows;                                 81   rows = rhs.rows;
 82   cols = rhs.cols;                                 82   cols = rhs.cols;
 83   if(rhs.m)                                        83   if(rhs.m)
 84   {                                                84   {
 85     m = new G4double[rows * cols];                 85     m = new G4double[rows * cols];
 86     for(std::size_t i = 0; i < rows * cols; ++     86     for(std::size_t i = 0; i < rows * cols; ++i)
 87     {                                              87     {
 88       m[i] = rhs.m[i];                             88       m[i] = rhs.m[i];
 89     }                                              89     }
 90   }                                                90   }
 91   else                                             91   else
 92   {                                                92   {
 93     m = nullptr;                                   93     m = nullptr;
 94   }                                                94   }
 95                                                    95 
 96   return *this;                                    96   return *this;
 97 }                                                  97 }
 98                                                    98 
 99 // -------------------------------------------     99 // --------------------------------------------------------------------
100 G4GDMLMatrix::~G4GDMLMatrix()                     100 G4GDMLMatrix::~G4GDMLMatrix()
101 {                                                 101 {
102   delete[] m;                                     102   delete[] m;
103 }                                                 103 }
104                                                   104 
105 // -------------------------------------------    105 // --------------------------------------------------------------------
106 void G4GDMLMatrix::Set(std::size_t r, std::siz    106 void G4GDMLMatrix::Set(std::size_t r, std::size_t c, G4double a)
107 {                                                 107 {
108   if(r >= rows || c >= cols)                      108   if(r >= rows || c >= cols)
109   {                                               109   {
110     G4Exception("G4GDMLMatrix::set()", "Invali    110     G4Exception("G4GDMLMatrix::set()", "InvalidSetup", FatalException,
111                 "Index out of range!");           111                 "Index out of range!");
112   }                                               112   }
113   m[cols * r + c] = a;                            113   m[cols * r + c] = a;
114 }                                                 114 }
115                                                   115 
116 // -------------------------------------------    116 // --------------------------------------------------------------------
117 G4double G4GDMLMatrix::Get(std::size_t r, std:    117 G4double G4GDMLMatrix::Get(std::size_t r, std::size_t c) const
118 {                                                 118 {
119   if(r >= rows || c >= cols)                      119   if(r >= rows || c >= cols)
120   {                                               120   {
121     G4Exception("G4GDMLMatrix::get()", "Invali    121     G4Exception("G4GDMLMatrix::get()", "InvalidSetup", FatalException,
122                 "Index out of range!");           122                 "Index out of range!");
123   }                                               123   }
124   return m[cols * r + c];                         124   return m[cols * r + c];
125 }                                                 125 }
126                                                   126 
127 // -------------------------------------------    127 // --------------------------------------------------------------------
128 std::size_t G4GDMLMatrix::GetRows() const         128 std::size_t G4GDMLMatrix::GetRows() const
129 {                                                 129 {
130   return rows;                                    130   return rows;
131 }                                                 131 }
132                                                   132 
133 // -------------------------------------------    133 // --------------------------------------------------------------------
134 std::size_t G4GDMLMatrix::GetCols() const         134 std::size_t G4GDMLMatrix::GetCols() const
135 {                                                 135 {
136   return cols;                                    136   return cols;
137 }                                                 137 }
138                                                   138 
139 // G4GDMLReadDefine --------------------------    139 // G4GDMLReadDefine ---------------------------------------------------
140                                                   140 
141 // -------------------------------------------    141 // --------------------------------------------------------------------
142 G4GDMLReadDefine::G4GDMLReadDefine()              142 G4GDMLReadDefine::G4GDMLReadDefine()
143   : G4GDMLRead()                                  143   : G4GDMLRead()
144 {                                                 144 {
145 }                                                 145 }
146                                                   146 
147 // -------------------------------------------    147 // --------------------------------------------------------------------
148 G4GDMLReadDefine::~G4GDMLReadDefine()             148 G4GDMLReadDefine::~G4GDMLReadDefine()
149 {                                                 149 {
150 }                                                 150 }
151                                                   151 
152 // -------------------------------------------    152 // --------------------------------------------------------------------
153 G4RotationMatrix G4GDMLReadDefine::GetRotation    153 G4RotationMatrix G4GDMLReadDefine::GetRotationMatrix(
154   const G4ThreeVector& angles)                    154   const G4ThreeVector& angles)
155 {                                                 155 {
156   G4RotationMatrix rot;                           156   G4RotationMatrix rot;
157                                                   157 
158   rot.rotateX(angles.x());                        158   rot.rotateX(angles.x());
159   rot.rotateY(angles.y());                        159   rot.rotateY(angles.y());
160   rot.rotateZ(angles.z());                        160   rot.rotateZ(angles.z());
161   rot.rectify();  // Rectify matrix from possi    161   rot.rectify();  // Rectify matrix from possible roundoff errors
162                                                   162 
163   return rot;                                     163   return rot;
164 }                                                 164 }
165                                                   165 
166 // -------------------------------------------    166 // --------------------------------------------------------------------
167 void G4GDMLReadDefine::ConstantRead(              167 void G4GDMLReadDefine::ConstantRead(
168   const xercesc::DOMElement* const constantEle    168   const xercesc::DOMElement* const constantElement)
169 {                                                 169 {
170   G4String name  = "";                            170   G4String name  = "";
171   G4double value = 0.0;                           171   G4double value = 0.0;
172                                                   172 
173   const xercesc::DOMNamedNodeMap* const attrib    173   const xercesc::DOMNamedNodeMap* const attributes =
174     constantElement->getAttributes();             174     constantElement->getAttributes();
175   XMLSize_t attributeCount = attributes->getLe    175   XMLSize_t attributeCount = attributes->getLength();
176                                                   176 
177   for(XMLSize_t attribute_index = 0; attribute    177   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
178       ++attribute_index)                          178       ++attribute_index)
179   {                                               179   {
180     xercesc::DOMNode* node = attributes->item(    180     xercesc::DOMNode* node = attributes->item(attribute_index);
181                                                   181 
182     if(node->getNodeType() != xercesc::DOMNode    182     if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
183     {                                             183     {
184       continue;                                   184       continue;
185     }                                             185     }
186                                                   186 
187     const xercesc::DOMAttr* const attribute =     187     const xercesc::DOMAttr* const attribute =
188       dynamic_cast<xercesc::DOMAttr*>(node);      188       dynamic_cast<xercesc::DOMAttr*>(node);
189     if(attribute == nullptr)                      189     if(attribute == nullptr)
190     {                                             190     {
191       G4Exception("G4GDMLRead::ConstantRead()"    191       G4Exception("G4GDMLRead::ConstantRead()", "InvalidRead", FatalException,
192                   "No attribute found!");         192                   "No attribute found!");
193       return;                                     193       return;
194     }                                             194     }
195     const G4String attName  = Transcode(attrib    195     const G4String attName  = Transcode(attribute->getName());
196     const G4String attValue = Transcode(attrib    196     const G4String attValue = Transcode(attribute->getValue());
197                                                   197 
198     if(attName == "name")                         198     if(attName == "name")
199     {                                             199     {
200       name = attValue;                            200       name = attValue;
201     }                                             201     }
202     else if(attName == "value")                   202     else if(attName == "value")
203     {                                             203     {
204       value = eval.Evaluate(attValue);            204       value = eval.Evaluate(attValue);
205     }                                             205     }
206   }                                               206   }
207                                                   207 
208   eval.DefineConstant(name, value);               208   eval.DefineConstant(name, value);
209 }                                                 209 }
210                                                   210 
211 // -------------------------------------------    211 // --------------------------------------------------------------------
212 void G4GDMLReadDefine::ExpressionRead(            212 void G4GDMLReadDefine::ExpressionRead(
213   const xercesc::DOMElement* const expElement)    213   const xercesc::DOMElement* const expElement)
214 {                                                 214 {
215   G4String name  = "";                            215   G4String name  = "";
216   G4double value = 0.0;                           216   G4double value = 0.0;
217                                                   217 
218   const xercesc::DOMNamedNodeMap* const attrib    218   const xercesc::DOMNamedNodeMap* const attributes =
219     expElement->getAttributes();                  219     expElement->getAttributes();
220   XMLSize_t attributeCount = attributes->getLe    220   XMLSize_t attributeCount = attributes->getLength();
221                                                   221 
222   for(XMLSize_t attribute_index = 0; attribute    222   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
223       ++attribute_index)                          223       ++attribute_index)
224   {                                               224   {
225     xercesc::DOMNode* node = attributes->item(    225     xercesc::DOMNode* node = attributes->item(attribute_index);
226                                                   226 
227     if(node->getNodeType() != xercesc::DOMNode    227     if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
228     {                                             228     {
229       continue;                                   229       continue;
230     }                                             230     }
231                                                   231 
232     const xercesc::DOMAttr* const attribute =     232     const xercesc::DOMAttr* const attribute =
233       dynamic_cast<xercesc::DOMAttr*>(node);      233       dynamic_cast<xercesc::DOMAttr*>(node);
234     if(attribute == nullptr)                      234     if(attribute == nullptr)
235     {                                             235     {
236       G4Exception("G4GDMLRead::ExpressionRead(    236       G4Exception("G4GDMLRead::ExpressionRead()", "InvalidRead", FatalException,
237                   "No attribute found!");         237                   "No attribute found!");
238       return;                                     238       return;
239     }                                             239     }
240     const G4String attName  = Transcode(attrib    240     const G4String attName  = Transcode(attribute->getName());
241     const G4String attValue = Transcode(attrib    241     const G4String attValue = Transcode(attribute->getValue());
242                                                   242 
243     if(attName == "name")                         243     if(attName == "name")
244     {                                             244     {
245       name = attValue;                            245       name = attValue;
246     }                                             246     }
247   }                                               247   }
248                                                   248 
249   const G4String expValue = Transcode(expEleme    249   const G4String expValue = Transcode(expElement->getTextContent());
250   value                   = eval.Evaluate(expV    250   value                   = eval.Evaluate(expValue);
251   eval.DefineConstant(name, value);               251   eval.DefineConstant(name, value);
252 }                                                 252 }
253                                                   253 
254 // -------------------------------------------    254 // --------------------------------------------------------------------
255 void G4GDMLReadDefine::MatrixRead(                255 void G4GDMLReadDefine::MatrixRead(
256   const xercesc::DOMElement* const matrixEleme    256   const xercesc::DOMElement* const matrixElement)
257 {                                                 257 {
258   G4String name   = "";                           258   G4String name   = "";
259   G4int coldim    = 0;                            259   G4int coldim    = 0;
260   G4String values = "";                           260   G4String values = "";
261                                                   261 
262   const xercesc::DOMNamedNodeMap* const attrib    262   const xercesc::DOMNamedNodeMap* const attributes =
263     matrixElement->getAttributes();               263     matrixElement->getAttributes();
264   XMLSize_t attributeCount = attributes->getLe    264   XMLSize_t attributeCount = attributes->getLength();
265                                                   265 
266   for(XMLSize_t attribute_index = 0; attribute    266   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
267       ++attribute_index)                          267       ++attribute_index)
268   {                                               268   {
269     xercesc::DOMNode* node = attributes->item(    269     xercesc::DOMNode* node = attributes->item(attribute_index);
270                                                   270 
271     if(node->getNodeType() != xercesc::DOMNode    271     if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
272     {                                             272     {
273       continue;                                   273       continue;
274     }                                             274     }
275                                                   275 
276     const xercesc::DOMAttr* const attribute =     276     const xercesc::DOMAttr* const attribute =
277       dynamic_cast<xercesc::DOMAttr*>(node);      277       dynamic_cast<xercesc::DOMAttr*>(node);
278     if(attribute == nullptr)                      278     if(attribute == nullptr)
279     {                                             279     {
280       G4Exception("G4GDMLRead::MatrixRead()",     280       G4Exception("G4GDMLRead::MatrixRead()", "InvalidRead", FatalException,
281                   "No attribute found!");         281                   "No attribute found!");
282       return;                                     282       return;
283     }                                             283     }
284     const G4String attName  = Transcode(attrib    284     const G4String attName  = Transcode(attribute->getName());
285     const G4String attValue = Transcode(attrib    285     const G4String attValue = Transcode(attribute->getValue());
286                                                   286 
287     if(attName == "name")                         287     if(attName == "name")
288     {                                             288     {
289       name = GenerateName(attValue);              289       name = GenerateName(attValue);
290     }                                             290     }
291     else if(attName == "coldim")                  291     else if(attName == "coldim")
292     {                                             292     {
293       coldim = eval.EvaluateInteger(attValue);    293       coldim = eval.EvaluateInteger(attValue);
294     }                                             294     }
295     else if(attName == "values")                  295     else if(attName == "values")
296     {                                             296     {
297       values = attValue;                          297       values = attValue;
298     }                                             298     }
299   }                                               299   }
300                                                   300 
301   std::stringstream MatrixValueStream(values);    301   std::stringstream MatrixValueStream(values);
302   std::vector<G4double> valueList;                302   std::vector<G4double> valueList;
303                                                   303 
304   while(!MatrixValueStream.eof())                 304   while(!MatrixValueStream.eof())
305   {                                               305   {
306     G4String MatrixValue;                         306     G4String MatrixValue;
307     MatrixValueStream >> MatrixValue;             307     MatrixValueStream >> MatrixValue;
308     valueList.push_back(eval.Evaluate(MatrixVa    308     valueList.push_back(eval.Evaluate(MatrixValue));
309   }                                               309   }
310                                                   310 
311   eval.DefineMatrix(name, coldim, valueList);     311   eval.DefineMatrix(name, coldim, valueList);
312                                                   312 
313   G4GDMLMatrix matrix(valueList.size() / coldi    313   G4GDMLMatrix matrix(valueList.size() / coldim, coldim);
314                                                   314 
315   for(std::size_t i = 0; i < valueList.size();    315   for(std::size_t i = 0; i < valueList.size(); ++i)
316   {                                               316   {
317     matrix.Set(i / coldim, i % coldim, valueLi    317     matrix.Set(i / coldim, i % coldim, valueList[i]);
318   }                                               318   }
319                                                   319 
320   matrixMap[name] = matrix;                       320   matrixMap[name] = matrix;
321 }                                                 321 }
322                                                   322 
323 // -------------------------------------------    323 // --------------------------------------------------------------------
324 void G4GDMLReadDefine::PositionRead(              324 void G4GDMLReadDefine::PositionRead(
325   const xercesc::DOMElement* const positionEle    325   const xercesc::DOMElement* const positionElement)
326 {                                                 326 {
327   G4String name = "";                             327   G4String name = "";
328   G4double unit = 1.0;                            328   G4double unit = 1.0;
329   G4ThreeVector position(0., 0., 0.);             329   G4ThreeVector position(0., 0., 0.);
330                                                   330 
331   const xercesc::DOMNamedNodeMap* const attrib    331   const xercesc::DOMNamedNodeMap* const attributes =
332     positionElement->getAttributes();             332     positionElement->getAttributes();
333   XMLSize_t attributeCount = attributes->getLe    333   XMLSize_t attributeCount = attributes->getLength();
334                                                   334 
335   for(XMLSize_t attribute_index = 0; attribute    335   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
336       ++attribute_index)                          336       ++attribute_index)
337   {                                               337   {
338     xercesc::DOMNode* node = attributes->item(    338     xercesc::DOMNode* node = attributes->item(attribute_index);
339                                                   339 
340     if(node->getNodeType() != xercesc::DOMNode    340     if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
341     {                                             341     {
342       continue;                                   342       continue;
343     }                                             343     }
344                                                   344 
345     const xercesc::DOMAttr* const attribute =     345     const xercesc::DOMAttr* const attribute =
346       dynamic_cast<xercesc::DOMAttr*>(node);      346       dynamic_cast<xercesc::DOMAttr*>(node);
347     if(attribute == nullptr)                      347     if(attribute == nullptr)
348     {                                             348     {
349       G4Exception("G4GDMLRead::PositionRead()"    349       G4Exception("G4GDMLRead::PositionRead()", "InvalidRead", FatalException,
350                   "No attribute found!");         350                   "No attribute found!");
351       return;                                     351       return;
352     }                                             352     }
353     const G4String attName  = Transcode(attrib    353     const G4String attName  = Transcode(attribute->getName());
354     const G4String attValue = Transcode(attrib    354     const G4String attValue = Transcode(attribute->getValue());
355                                                   355 
356     if(attName == "name")                         356     if(attName == "name")
357     {                                             357     {
358       name = GenerateName(attValue);              358       name = GenerateName(attValue);
359     }                                             359     }
360     else if(attName == "unit")                    360     else if(attName == "unit")
361     {                                             361     {
362       unit = G4UnitDefinition::GetValueOf(attV    362       unit = G4UnitDefinition::GetValueOf(attValue);
363       if(G4UnitDefinition::GetCategory(attValu    363       if(G4UnitDefinition::GetCategory(attValue) != "Length")
364       {                                           364       {
365         G4Exception("G4GDMLReadDefine::Positio    365         G4Exception("G4GDMLReadDefine::PositionRead()", "InvalidRead",
366                     FatalException, "Invalid u    366                     FatalException, "Invalid unit for length!");
367       }                                           367       }
368     }                                             368     }
369     else if(attName == "x")                       369     else if(attName == "x")
370     {                                             370     {
371       position.setX(eval.Evaluate(attValue));     371       position.setX(eval.Evaluate(attValue));
372     }                                             372     }
373     else if(attName == "y")                       373     else if(attName == "y")
374     {                                             374     {
375       position.setY(eval.Evaluate(attValue));     375       position.setY(eval.Evaluate(attValue));
376     }                                             376     }
377     else if(attName == "z")                       377     else if(attName == "z")
378     {                                             378     {
379       position.setZ(eval.Evaluate(attValue));     379       position.setZ(eval.Evaluate(attValue));
380     }                                             380     }
381   }                                               381   }
382                                                   382 
383   positionMap[name] = position * unit;            383   positionMap[name] = position * unit;
384 }                                                 384 }
385                                                   385 
386 // -------------------------------------------    386 // --------------------------------------------------------------------
387 void G4GDMLReadDefine::RotationRead(              387 void G4GDMLReadDefine::RotationRead(
388   const xercesc::DOMElement* const rotationEle    388   const xercesc::DOMElement* const rotationElement)
389 {                                                 389 {
390   G4String name = "";                             390   G4String name = "";
391   G4double unit = 1.0;                            391   G4double unit = 1.0;
392   G4ThreeVector rotation(0., 0., 0.);             392   G4ThreeVector rotation(0., 0., 0.);
393                                                   393 
394   const xercesc::DOMNamedNodeMap* const attrib    394   const xercesc::DOMNamedNodeMap* const attributes =
395     rotationElement->getAttributes();             395     rotationElement->getAttributes();
396   XMLSize_t attributeCount = attributes->getLe    396   XMLSize_t attributeCount = attributes->getLength();
397                                                   397 
398   for(XMLSize_t attribute_index = 0; attribute    398   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
399       ++attribute_index)                          399       ++attribute_index)
400   {                                               400   {
401     xercesc::DOMNode* node = attributes->item(    401     xercesc::DOMNode* node = attributes->item(attribute_index);
402                                                   402 
403     if(node->getNodeType() != xercesc::DOMNode    403     if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
404     {                                             404     {
405       continue;                                   405       continue;
406     }                                             406     }
407                                                   407 
408     const xercesc::DOMAttr* const attribute =     408     const xercesc::DOMAttr* const attribute =
409       dynamic_cast<xercesc::DOMAttr*>(node);      409       dynamic_cast<xercesc::DOMAttr*>(node);
410     if(attribute == nullptr)                      410     if(attribute == nullptr)
411     {                                             411     {
412       G4Exception("G4GDMLRead::RotationRead()"    412       G4Exception("G4GDMLRead::RotationRead()", "InvalidRead", FatalException,
413                   "No attribute found!");         413                   "No attribute found!");
414       return;                                     414       return;
415     }                                             415     }
416     const G4String attName  = Transcode(attrib    416     const G4String attName  = Transcode(attribute->getName());
417     const G4String attValue = Transcode(attrib    417     const G4String attValue = Transcode(attribute->getValue());
418                                                   418 
419     if(attName == "name")                         419     if(attName == "name")
420     {                                             420     {
421       name = GenerateName(attValue);              421       name = GenerateName(attValue);
422     }                                             422     }
423     else if(attName == "unit")                    423     else if(attName == "unit")
424     {                                             424     {
425       unit = G4UnitDefinition::GetValueOf(attV    425       unit = G4UnitDefinition::GetValueOf(attValue);
426       if(G4UnitDefinition::GetCategory(attValu    426       if(G4UnitDefinition::GetCategory(attValue) != "Angle")
427       {                                           427       {
428         G4Exception("G4GDMLReadDefine::Rotatio    428         G4Exception("G4GDMLReadDefine::RotationRead()", "InvalidRead",
429                     FatalException, "Invalid u    429                     FatalException, "Invalid unit for angle!");
430       }                                           430       }
431     }                                             431     }
432     else if(attName == "x")                       432     else if(attName == "x")
433     {                                             433     {
434       rotation.setX(eval.Evaluate(attValue));     434       rotation.setX(eval.Evaluate(attValue));
435     }                                             435     }
436     else if(attName == "y")                       436     else if(attName == "y")
437     {                                             437     {
438       rotation.setY(eval.Evaluate(attValue));     438       rotation.setY(eval.Evaluate(attValue));
439     }                                             439     }
440     else if(attName == "z")                       440     else if(attName == "z")
441     {                                             441     {
442       rotation.setZ(eval.Evaluate(attValue));     442       rotation.setZ(eval.Evaluate(attValue));
443     }                                             443     }
444   }                                               444   }
445                                                   445 
446   rotationMap[name] = rotation * unit;            446   rotationMap[name] = rotation * unit;
447 }                                                 447 }
448                                                   448 
449 // -------------------------------------------    449 // --------------------------------------------------------------------
450 void G4GDMLReadDefine::ScaleRead(const xercesc    450 void G4GDMLReadDefine::ScaleRead(const xercesc::DOMElement* const scaleElement)
451 {                                                 451 {
452   G4String name = "";                             452   G4String name = "";
453   G4ThreeVector scale(1.0, 1.0, 1.0);             453   G4ThreeVector scale(1.0, 1.0, 1.0);
454                                                   454 
455   const xercesc::DOMNamedNodeMap* const attrib    455   const xercesc::DOMNamedNodeMap* const attributes =
456     scaleElement->getAttributes();                456     scaleElement->getAttributes();
457   XMLSize_t attributeCount = attributes->getLe    457   XMLSize_t attributeCount = attributes->getLength();
458                                                   458 
459   for(XMLSize_t attribute_index = 0; attribute    459   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
460       ++attribute_index)                          460       ++attribute_index)
461   {                                               461   {
462     xercesc::DOMNode* node = attributes->item(    462     xercesc::DOMNode* node = attributes->item(attribute_index);
463                                                   463 
464     if(node->getNodeType() != xercesc::DOMNode    464     if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
465     {                                             465     {
466       continue;                                   466       continue;
467     }                                             467     }
468                                                   468 
469     const xercesc::DOMAttr* const attribute =     469     const xercesc::DOMAttr* const attribute =
470       dynamic_cast<xercesc::DOMAttr*>(node);      470       dynamic_cast<xercesc::DOMAttr*>(node);
471     if(attribute == nullptr)                      471     if(attribute == nullptr)
472     {                                             472     {
473       G4Exception("G4GDMLRead::ScaleRead()", "    473       G4Exception("G4GDMLRead::ScaleRead()", "InvalidRead", FatalException,
474                   "No attribute found!");         474                   "No attribute found!");
475       return;                                     475       return;
476     }                                             476     }
477     const G4String attName  = Transcode(attrib    477     const G4String attName  = Transcode(attribute->getName());
478     const G4String attValue = Transcode(attrib    478     const G4String attValue = Transcode(attribute->getValue());
479                                                   479 
480     if(attName == "name")                         480     if(attName == "name")
481     {                                             481     {
482       name = GenerateName(attValue);              482       name = GenerateName(attValue);
483     }                                             483     }
484     else if(attName == "x")                       484     else if(attName == "x")
485     {                                             485     {
486       scale.setX(eval.Evaluate(attValue));        486       scale.setX(eval.Evaluate(attValue));
487     }                                             487     }
488     else if(attName == "y")                       488     else if(attName == "y")
489     {                                             489     {
490       scale.setY(eval.Evaluate(attValue));        490       scale.setY(eval.Evaluate(attValue));
491     }                                             491     }
492     else if(attName == "z")                       492     else if(attName == "z")
493     {                                             493     {
494       scale.setZ(eval.Evaluate(attValue));        494       scale.setZ(eval.Evaluate(attValue));
495     }                                             495     }
496   }                                               496   }
497                                                   497 
498   scaleMap[name] = scale;                         498   scaleMap[name] = scale;
499 }                                                 499 }
500                                                   500 
501 // -------------------------------------------    501 // --------------------------------------------------------------------
502 void G4GDMLReadDefine::VariableRead(              502 void G4GDMLReadDefine::VariableRead(
503   const xercesc::DOMElement* const variableEle    503   const xercesc::DOMElement* const variableElement)
504 {                                                 504 {
505   G4String name  = "";                            505   G4String name  = "";
506   G4double value = 0.0;                           506   G4double value = 0.0;
507                                                   507 
508   const xercesc::DOMNamedNodeMap* const attrib    508   const xercesc::DOMNamedNodeMap* const attributes =
509     variableElement->getAttributes();             509     variableElement->getAttributes();
510   XMLSize_t attributeCount = attributes->getLe    510   XMLSize_t attributeCount = attributes->getLength();
511                                                   511 
512   for(XMLSize_t attribute_index = 0; attribute    512   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
513       ++attribute_index)                          513       ++attribute_index)
514   {                                               514   {
515     xercesc::DOMNode* node = attributes->item(    515     xercesc::DOMNode* node = attributes->item(attribute_index);
516                                                   516 
517     if(node->getNodeType() != xercesc::DOMNode    517     if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
518     {                                             518     {
519       continue;                                   519       continue;
520     }                                             520     }
521                                                   521 
522     const xercesc::DOMAttr* const attribute =     522     const xercesc::DOMAttr* const attribute =
523       dynamic_cast<xercesc::DOMAttr*>(node);      523       dynamic_cast<xercesc::DOMAttr*>(node);
524     if(attribute == nullptr)                      524     if(attribute == nullptr)
525     {                                             525     {
526       G4Exception("G4GDMLRead::VariableRead()"    526       G4Exception("G4GDMLRead::VariableRead()", "InvalidRead", FatalException,
527                   "No attribute found!");         527                   "No attribute found!");
528       return;                                     528       return;
529     }                                             529     }
530     const G4String attName  = Transcode(attrib    530     const G4String attName  = Transcode(attribute->getName());
531     const G4String attValue = Transcode(attrib    531     const G4String attValue = Transcode(attribute->getValue());
532                                                   532 
533     if(attName == "name")                         533     if(attName == "name")
534     {                                             534     {
535       name = attValue;                            535       name = attValue;
536     }                                             536     }
537     else if(attName == "value")                   537     else if(attName == "value")
538     {                                             538     {
539       value = eval.Evaluate(attValue);            539       value = eval.Evaluate(attValue);
540     }                                             540     }
541   }                                               541   }
542                                                   542 
543   eval.DefineVariable(name, value);               543   eval.DefineVariable(name, value);
544 }                                                 544 }
545                                                   545 
546 // -------------------------------------------    546 // --------------------------------------------------------------------
547 void G4GDMLReadDefine::QuantityRead(const xerc    547 void G4GDMLReadDefine::QuantityRead(const xercesc::DOMElement* const element)
548 {                                                 548 {
549   G4String name  = "";                            549   G4String name  = "";
550   G4double unit  = 1.0;                           550   G4double unit  = 1.0;
551   G4double value = 0.0;                           551   G4double value = 0.0;
552                                                   552 
553   const xercesc::DOMNamedNodeMap* const attrib    553   const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
554   XMLSize_t attributeCount                        554   XMLSize_t attributeCount                         = attributes->getLength();
555                                                   555 
556   for(XMLSize_t attribute_index = 0; attribute    556   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
557       ++attribute_index)                          557       ++attribute_index)
558   {                                               558   {
559     xercesc::DOMNode* node = attributes->item(    559     xercesc::DOMNode* node = attributes->item(attribute_index);
560                                                   560 
561     if(node->getNodeType() != xercesc::DOMNode    561     if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
562     {                                             562     {
563       continue;                                   563       continue;
564     }                                             564     }
565                                                   565 
566     const xercesc::DOMAttr* const attribute =     566     const xercesc::DOMAttr* const attribute =
567       dynamic_cast<xercesc::DOMAttr*>(node);      567       dynamic_cast<xercesc::DOMAttr*>(node);
568     if(attribute == nullptr)                      568     if(attribute == nullptr)
569     {                                             569     {
570       G4Exception("G4GDMLRead::QuantityRead()"    570       G4Exception("G4GDMLRead::QuantityRead()", "InvalidRead", FatalException,
571                   "No attribute found!");         571                   "No attribute found!");
572       return;                                     572       return;
573     }                                             573     }
574     const G4String attName  = Transcode(attrib    574     const G4String attName  = Transcode(attribute->getName());
575     const G4String attValue = Transcode(attrib    575     const G4String attValue = Transcode(attribute->getValue());
576                                                   576 
577     if(attName == "name")                         577     if(attName == "name")
578     {                                             578     {
579       name = attValue;                            579       name = attValue;
580     }                                             580     }
581     else if(attName == "value")                   581     else if(attName == "value")
582     {                                             582     {
583       value = eval.Evaluate(attValue);            583       value = eval.Evaluate(attValue);
584     }                                             584     }
585     else if(attName == "unit")                    585     else if(attName == "unit")
586     {                                             586     {
587       unit = G4UnitDefinition::GetValueOf(attV    587       unit = G4UnitDefinition::GetValueOf(attValue);
588     }                                             588     }
589   }                                               589   }
590                                                   590 
591   quantityMap[name] = value * unit;               591   quantityMap[name] = value * unit;
592   eval.DefineConstant(name, value * unit);        592   eval.DefineConstant(name, value * unit);
593 }                                                 593 }
594                                                   594 
595 // -------------------------------------------    595 // --------------------------------------------------------------------
596 void G4GDMLReadDefine::DefineRead(                596 void G4GDMLReadDefine::DefineRead(
597   const xercesc::DOMElement* const defineEleme    597   const xercesc::DOMElement* const defineElement)
598 {                                                 598 {
599 #ifdef G4VERBOSE                                  599 #ifdef G4VERBOSE
600   G4cout << "G4GDML: Reading definitions..." <    600   G4cout << "G4GDML: Reading definitions..." << G4endl;
601 #endif                                            601 #endif
602   for(xercesc::DOMNode* iter = defineElement->    602   for(xercesc::DOMNode* iter = defineElement->getFirstChild(); iter != nullptr;
603       iter                   = iter->getNextSi    603       iter                   = iter->getNextSibling())
604   {                                               604   {
605     if(iter->getNodeType() != xercesc::DOMNode    605     if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
606     {                                             606     {
607       continue;                                   607       continue;
608     }                                             608     }
609                                                   609 
610     const xercesc::DOMElement* const child =      610     const xercesc::DOMElement* const child =
611       dynamic_cast<xercesc::DOMElement*>(iter)    611       dynamic_cast<xercesc::DOMElement*>(iter);
612     if(child == nullptr)                          612     if(child == nullptr)
613     {                                             613     {
614       G4Exception("G4GDMLRead::DefineRead()",     614       G4Exception("G4GDMLRead::DefineRead()", "InvalidRead", FatalException,
615                   "No child found!");             615                   "No child found!");
616       return;                                     616       return;
617     }                                             617     }
618     const G4String tag = Transcode(child->getT    618     const G4String tag = Transcode(child->getTagName());
619                                                   619 
620     if(tag == "constant")                         620     if(tag == "constant")
621     {                                             621     {
622       ConstantRead(child);                        622       ConstantRead(child);
623     }                                             623     }
624     else if(tag == "matrix")                      624     else if(tag == "matrix")
625     {                                             625     {
626       MatrixRead(child);                          626       MatrixRead(child);
627     }                                             627     }
628     else if(tag == "position")                    628     else if(tag == "position")
629     {                                             629     {
630       PositionRead(child);                        630       PositionRead(child);
631     }                                             631     }
632     else if(tag == "rotation")                    632     else if(tag == "rotation")
633     {                                             633     {
634       RotationRead(child);                        634       RotationRead(child);
635     }                                             635     }
636     else if(tag == "scale")                       636     else if(tag == "scale")
637     {                                             637     {
638       ScaleRead(child);                           638       ScaleRead(child);
639     }                                             639     }
640     else if(tag == "variable")                    640     else if(tag == "variable")
641     {                                             641     {
642       VariableRead(child);                        642       VariableRead(child);
643     }                                             643     }
644     else if(tag == "quantity")                    644     else if(tag == "quantity")
645     {                                             645     {
646       QuantityRead(child);                        646       QuantityRead(child);
647     }                                             647     }
648     else if(tag == "expression")                  648     else if(tag == "expression")
649     {                                             649     {
650       ExpressionRead(child);                      650       ExpressionRead(child);
651     }                                             651     }
652     else                                          652     else
653     {                                             653     {
654       G4String error_msg = "Unknown tag in def    654       G4String error_msg = "Unknown tag in define: " + tag;
655       G4Exception("G4GDMLReadDefine::defineRea    655       G4Exception("G4GDMLReadDefine::defineRead()", "ReadError", FatalException,
656                   error_msg);                     656                   error_msg);
657     }                                             657     }
658   }                                               658   }
659 }                                                 659 }
660                                                   660 
661 // -------------------------------------------    661 // --------------------------------------------------------------------
662 void G4GDMLReadDefine::VectorRead(                662 void G4GDMLReadDefine::VectorRead(
663   const xercesc::DOMElement* const vectorEleme    663   const xercesc::DOMElement* const vectorElement, G4ThreeVector& vec)
664 {                                                 664 {
665   G4double unit = 1.0;                            665   G4double unit = 1.0;
666                                                   666 
667   const xercesc::DOMNamedNodeMap* const attrib    667   const xercesc::DOMNamedNodeMap* const attributes =
668     vectorElement->getAttributes();               668     vectorElement->getAttributes();
669   XMLSize_t attributeCount = attributes->getLe    669   XMLSize_t attributeCount = attributes->getLength();
670                                                   670 
671   for(XMLSize_t attribute_index = 0; attribute    671   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
672       ++attribute_index)                          672       ++attribute_index)
673   {                                               673   {
674     xercesc::DOMNode* attribute_node = attribu    674     xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
675                                                   675 
676     if(attribute_node->getNodeType() != xerces    676     if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
677     {                                             677     {
678       continue;                                   678       continue;
679     }                                             679     }
680                                                   680 
681     const xercesc::DOMAttr* const attribute =     681     const xercesc::DOMAttr* const attribute =
682       dynamic_cast<xercesc::DOMAttr*>(attribut    682       dynamic_cast<xercesc::DOMAttr*>(attribute_node);
683     if(attribute == nullptr)                      683     if(attribute == nullptr)
684     {                                             684     {
685       G4Exception("G4GDMLRead::VectorRead()",     685       G4Exception("G4GDMLRead::VectorRead()", "InvalidRead", FatalException,
686                   "No attribute found!");         686                   "No attribute found!");
687       return;                                     687       return;
688     }                                             688     }
689     const G4String attName  = Transcode(attrib    689     const G4String attName  = Transcode(attribute->getName());
690     const G4String attValue = Transcode(attrib    690     const G4String attValue = Transcode(attribute->getValue());
691                                                   691 
692     if(attName == "unit")                         692     if(attName == "unit")
693     {                                             693     {
694       unit = G4UnitDefinition::GetValueOf(attV    694       unit = G4UnitDefinition::GetValueOf(attValue);
695     }                                             695     }
696     else if(attName == "x")                       696     else if(attName == "x")
697     {                                             697     {
698       vec.setX(eval.Evaluate(attValue));          698       vec.setX(eval.Evaluate(attValue));
699     }                                             699     }
700     else if(attName == "y")                       700     else if(attName == "y")
701     {                                             701     {
702       vec.setY(eval.Evaluate(attValue));          702       vec.setY(eval.Evaluate(attValue));
703     }                                             703     }
704     else if(attName == "z")                       704     else if(attName == "z")
705     {                                             705     {
706       vec.setZ(eval.Evaluate(attValue));          706       vec.setZ(eval.Evaluate(attValue));
707     }                                             707     }
708   }                                               708   }
709                                                   709 
710   vec *= unit;                                    710   vec *= unit;
711 }                                                 711 }
712                                                   712 
713 // -------------------------------------------    713 // --------------------------------------------------------------------
714 G4String G4GDMLReadDefine::RefRead(const xerce    714 G4String G4GDMLReadDefine::RefRead(const xercesc::DOMElement* const element)
715 {                                                 715 {
716   G4String ref;                                   716   G4String ref;
717                                                   717 
718   const xercesc::DOMNamedNodeMap* const attrib    718   const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
719   XMLSize_t attributeCount                        719   XMLSize_t attributeCount                         = attributes->getLength();
720                                                   720 
721   for(XMLSize_t attribute_index = 0; attribute    721   for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
722       ++attribute_index)                          722       ++attribute_index)
723   {                                               723   {
724     xercesc::DOMNode* attribute_node = attribu    724     xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
725                                                   725 
726     if(attribute_node->getNodeType() != xerces    726     if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
727     {                                             727     {
728       continue;                                   728       continue;
729     }                                             729     }
730                                                   730 
731     const xercesc::DOMAttr* const attribute =     731     const xercesc::DOMAttr* const attribute =
732       dynamic_cast<xercesc::DOMAttr*>(attribut    732       dynamic_cast<xercesc::DOMAttr*>(attribute_node);
733     if(attribute == nullptr)                      733     if(attribute == nullptr)
734     {                                             734     {
735       G4Exception("G4GDMLRead::Read()", "Inval    735       G4Exception("G4GDMLRead::Read()", "InvalidRead", FatalException,
736                   "No attribute found!");         736                   "No attribute found!");
737       return ref;                                 737       return ref;
738     }                                             738     }
739     const G4String attName  = Transcode(attrib    739     const G4String attName  = Transcode(attribute->getName());
740     const G4String attValue = Transcode(attrib    740     const G4String attValue = Transcode(attribute->getValue());
741                                                   741 
742     if(attName == "ref")                          742     if(attName == "ref")
743     {                                             743     {
744       ref = attValue;                             744       ref = attValue;
745     }                                             745     }
746   }                                               746   }
747                                                   747 
748   return ref;                                     748   return ref;
749 }                                                 749 }
750                                                   750 
751 // -------------------------------------------    751 // --------------------------------------------------------------------
752 G4bool G4GDMLReadDefine::IsValidID(const G4Str    752 G4bool G4GDMLReadDefine::IsValidID(const G4String& ref) const
753 {                                                 753 {
754   return eval.IsVariable(ref);                    754   return eval.IsVariable(ref);
755 }                                                 755 }
756                                                   756 
757 // -------------------------------------------    757 // --------------------------------------------------------------------
758 G4double G4GDMLReadDefine::GetConstant(const G    758 G4double G4GDMLReadDefine::GetConstant(const G4String& ref)
759 {                                                 759 {
760   return eval.GetConstant(ref);                   760   return eval.GetConstant(ref);
761 }                                                 761 }
762                                                   762 
763 // -------------------------------------------    763 // --------------------------------------------------------------------
764 G4double G4GDMLReadDefine::GetVariable(const G    764 G4double G4GDMLReadDefine::GetVariable(const G4String& ref)
765 {                                                 765 {
766   return eval.GetVariable(ref);                   766   return eval.GetVariable(ref);
767 }                                                 767 }
768                                                   768 
769 // -------------------------------------------    769 // --------------------------------------------------------------------
770 G4double G4GDMLReadDefine::GetQuantity(const G    770 G4double G4GDMLReadDefine::GetQuantity(const G4String& ref)
771 {                                                 771 {
772   if(quantityMap.find(ref) == quantityMap.cend    772   if(quantityMap.find(ref) == quantityMap.cend())
773   {                                               773   {
774     G4String error_msg = "Quantity '" + ref +     774     G4String error_msg = "Quantity '" + ref + "' was not found!";
775     G4Exception("G4GDMLReadDefine::getQuantity    775     G4Exception("G4GDMLReadDefine::getQuantity()", "ReadError", FatalException,
776                 error_msg);                       776                 error_msg);
777   }                                               777   }
778   return quantityMap[ref];                        778   return quantityMap[ref];
779 }                                                 779 }
780                                                   780 
781 // -------------------------------------------    781 // --------------------------------------------------------------------
782 G4ThreeVector G4GDMLReadDefine::GetPosition(co    782 G4ThreeVector G4GDMLReadDefine::GetPosition(const G4String& ref)
783 {                                                 783 {
784   if(positionMap.find(ref) == positionMap.cend    784   if(positionMap.find(ref) == positionMap.cend())
785   {                                               785   {
786     G4String error_msg = "Position '" + ref +     786     G4String error_msg = "Position '" + ref + "' was not found!";
787     G4Exception("G4GDMLReadDefine::getPosition    787     G4Exception("G4GDMLReadDefine::getPosition()", "ReadError", FatalException,
788                 error_msg);                       788                 error_msg);
789   }                                               789   }
790   return positionMap[ref];                        790   return positionMap[ref];
791 }                                                 791 }
792                                                   792 
793 // -------------------------------------------    793 // --------------------------------------------------------------------
794 G4ThreeVector G4GDMLReadDefine::GetRotation(co    794 G4ThreeVector G4GDMLReadDefine::GetRotation(const G4String& ref)
795 {                                                 795 {
796   if(rotationMap.find(ref) == rotationMap.cend    796   if(rotationMap.find(ref) == rotationMap.cend())
797   {                                               797   {
798     G4String error_msg = "Rotation '" + ref +     798     G4String error_msg = "Rotation '" + ref + "' was not found!";
799     G4Exception("G4GDMLReadDefine::getRotation    799     G4Exception("G4GDMLReadDefine::getRotation()", "ReadError", FatalException,
800                 error_msg);                       800                 error_msg);
801   }                                               801   }
802   return rotationMap[ref];                        802   return rotationMap[ref];
803 }                                                 803 }
804                                                   804 
805 // -------------------------------------------    805 // --------------------------------------------------------------------
806 G4ThreeVector G4GDMLReadDefine::GetScale(const    806 G4ThreeVector G4GDMLReadDefine::GetScale(const G4String& ref)
807 {                                                 807 {
808   if(scaleMap.find(ref) == scaleMap.end())        808   if(scaleMap.find(ref) == scaleMap.end())
809   {                                               809   {
810     G4String error_msg = "Scale '" + ref + "'     810     G4String error_msg = "Scale '" + ref + "' was not found!";
811     G4Exception("G4GDMLReadDefine::getScale()"    811     G4Exception("G4GDMLReadDefine::getScale()", "ReadError", FatalException,
812                 error_msg);                       812                 error_msg);
813   }                                               813   }
814   return scaleMap[ref];                           814   return scaleMap[ref];
815 }                                                 815 }
816                                                   816 
817 // -------------------------------------------    817 // --------------------------------------------------------------------
818 G4GDMLMatrix G4GDMLReadDefine::GetMatrix(const    818 G4GDMLMatrix G4GDMLReadDefine::GetMatrix(const G4String& ref)
819 {                                                 819 {
820   if(matrixMap.find(ref) == matrixMap.end())      820   if(matrixMap.find(ref) == matrixMap.end())
821   {                                               821   {
822     G4String error_msg = "Matrix '" + ref + "'    822     G4String error_msg = "Matrix '" + ref + "' was not found!";
823     G4Exception("G4GDMLReadDefine::getMatrix()    823     G4Exception("G4GDMLReadDefine::getMatrix()", "ReadError", FatalException,
824                 error_msg);                       824                 error_msg);
825   }                                               825   }
826   return matrixMap[ref];                          826   return matrixMap[ref];
827 }                                                 827 }
828                                                   828