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.6.p1)


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