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.4.p3)


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