Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/persistency/gdml/src/G4GDMLReadMaterials.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/G4GDMLReadMaterials.cc (Version 11.3.0) and /persistency/gdml/src/G4GDMLReadMaterials.cc (Version 9.3.p2)


  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 // G4GDMLReadMaterials implementation          << 
 27 //                                                 26 //
 28 // Author: Zoltan Torzsok, November 2007       <<  27 // $Id: G4GDMLReadMaterials.cc,v 1.20 2009/04/24 15:34:20 gcosmo Exp $
                                                   >>  28 // GEANT4 tag $ Name:$
                                                   >>  29 //
                                                   >>  30 // class G4GDMLReadMaterials Implementation
                                                   >>  31 //
                                                   >>  32 // Original author: Zoltan Torzsok, November 2007
                                                   >>  33 //
 29 // -------------------------------------------     34 // --------------------------------------------------------------------
 30                                                    35 
 31 #include "G4GDMLReadMaterials.hh"                  36 #include "G4GDMLReadMaterials.hh"
 32                                                    37 
 33 #include "G4PhysicalConstants.hh"              << 
 34 #include "G4SystemOfUnits.hh"                  << 
 35 #include "G4UnitsTable.hh"                     << 
 36 #include "G4Element.hh"                            38 #include "G4Element.hh"
 37 #include "G4Isotope.hh"                            39 #include "G4Isotope.hh"
 38 #include "G4Material.hh"                           40 #include "G4Material.hh"
 39 #include "G4NistManager.hh"                        41 #include "G4NistManager.hh"
 40                                                    42 
 41 // ------------------------------------------- <<  43 G4GDMLReadMaterials::G4GDMLReadMaterials() : G4GDMLReadDefine()
 42 G4GDMLReadMaterials::G4GDMLReadMaterials()     << 
 43   : G4GDMLReadDefine()                         << 
 44 {                                                  44 {
 45 }                                                  45 }
 46                                                    46 
 47 // ------------------------------------------- << 
 48 G4GDMLReadMaterials::~G4GDMLReadMaterials()        47 G4GDMLReadMaterials::~G4GDMLReadMaterials()
 49 {                                                  48 {
 50 }                                                  49 }
 51                                                    50 
 52 // ------------------------------------------- <<  51 G4double
 53 G4double G4GDMLReadMaterials::AtomRead(        <<  52 G4GDMLReadMaterials::AtomRead(const xercesc::DOMElement* const atomElement)
 54   const xercesc::DOMElement* const atomElement << 
 55 {                                              << 
 56   G4double value = 0.0;                        << 
 57   G4double unit  = g / mole;                   << 
 58                                                << 
 59   const xercesc::DOMNamedNodeMap* const attrib << 
 60     atomElement->getAttributes();              << 
 61   XMLSize_t attributeCount = attributes->getLe << 
 62                                                << 
 63   for(XMLSize_t attribute_index = 0; attribute << 
 64       ++attribute_index)                       << 
 65   {                                            << 
 66     xercesc::DOMNode* attribute_node = attribu << 
 67                                                << 
 68     if(attribute_node->getNodeType() != xerces << 
 69     {                                          << 
 70       continue;                                << 
 71     }                                          << 
 72                                                << 
 73     const xercesc::DOMAttr* const attribute =  << 
 74       dynamic_cast<xercesc::DOMAttr*>(attribut << 
 75     if(attribute == nullptr)                   << 
 76     {                                          << 
 77       G4Exception("G4GDMLReadMaterials::AtomRe << 
 78                   FatalException, "No attribut << 
 79       return value;                            << 
 80     }                                          << 
 81     const G4String attName  = Transcode(attrib << 
 82     const G4String attValue = Transcode(attrib << 
 83                                                << 
 84     if(attName == "value")                     << 
 85     {                                          << 
 86       value = eval.Evaluate(attValue);         << 
 87     }                                          << 
 88     else if(attName == "unit")                 << 
 89     {                                          << 
 90       unit = G4UnitDefinition::GetValueOf(attV << 
 91       if(G4UnitDefinition::GetCategory(attValu << 
 92       {                                        << 
 93         G4Exception("G4GDMLReadMaterials::Atom << 
 94                     FatalException, "Invalid u << 
 95       }                                        << 
 96     }                                          << 
 97   }                                            << 
 98                                                << 
 99   return value * unit;                         << 
100 }                                              << 
101                                                << 
102 // ------------------------------------------- << 
103 G4int G4GDMLReadMaterials::CompositeRead(      << 
104   const xercesc::DOMElement* const compositeEl << 
105 {                                              << 
106   G4int n = 0;                                 << 
107                                                << 
108   const xercesc::DOMNamedNodeMap* const attrib << 
109     compositeElement->getAttributes();         << 
110   XMLSize_t attributeCount = attributes->getLe << 
111                                                << 
112   for(XMLSize_t attribute_index = 0; attribute << 
113       ++attribute_index)                       << 
114   {                                            << 
115     xercesc::DOMNode* attribute_node = attribu << 
116                                                << 
117     if(attribute_node->getNodeType() != xerces << 
118     {                                          << 
119       continue;                                << 
120     }                                          << 
121                                                << 
122     const xercesc::DOMAttr* const attribute =  << 
123       dynamic_cast<xercesc::DOMAttr*>(attribut << 
124     if(attribute == nullptr)                   << 
125     {                                          << 
126       G4Exception("G4GDMLReadMaterials::Compos << 
127                   FatalException, "No attribut << 
128       return n;                                << 
129     }                                          << 
130     const G4String attName  = Transcode(attrib << 
131     const G4String attValue = Transcode(attrib << 
132                                                << 
133     if(attName == "n")                         << 
134     {                                          << 
135       n = eval.EvaluateInteger(attValue);      << 
136     }                                          << 
137     else if(attName == "ref")                  << 
138     {                                          << 
139       ref = attValue;                          << 
140     }                                          << 
141   }                                            << 
142                                                << 
143   return n;                                    << 
144 }                                              << 
145                                                << 
146 // ------------------------------------------- << 
147 G4double G4GDMLReadMaterials::DRead(const xerc << 
148 {                                                  53 {
149   G4double value = 0.0;                        <<  54    G4double value = 0.0;
150   G4double unit  = g / cm3;                    <<  55    G4double unit = g/mole;
151                                                    56 
152   const xercesc::DOMNamedNodeMap* const attrib <<  57    const xercesc::DOMNamedNodeMap* const attributes
153   XMLSize_t attributeCount                     <<  58          = atomElement->getAttributes();
                                                   >>  59    XMLSize_t attributeCount = attributes->getLength();
154                                                    60 
155   for(XMLSize_t attribute_index = 0; attribute <<  61    for (XMLSize_t attribute_index=0;
156       ++attribute_index)                       <<  62         attribute_index<attributeCount; attribute_index++)
157   {                                            <<  63    {
158     xercesc::DOMNode* attribute_node = attribu <<  64       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
159                                                << 
160     if(attribute_node->getNodeType() != xerces << 
161     {                                          << 
162       continue;                                << 
163     }                                          << 
164                                                << 
165     const xercesc::DOMAttr* const attribute =  << 
166       dynamic_cast<xercesc::DOMAttr*>(attribut << 
167     if(attribute == nullptr)                   << 
168     {                                          << 
169       G4Exception("G4GDMLReadMaterials::DRead( << 
170                   "No attribute found!");      << 
171       return value;                            << 
172     }                                          << 
173     const G4String attName  = Transcode(attrib << 
174     const G4String attValue = Transcode(attrib << 
175                                                << 
176     if(attName == "value")                     << 
177     {                                          << 
178       value = eval.Evaluate(attValue);         << 
179     }                                          << 
180     else if(attName == "unit")                 << 
181     {                                          << 
182       unit = G4UnitDefinition::GetValueOf(attV << 
183       if(G4UnitDefinition::GetCategory(attValu << 
184       {                                        << 
185         G4Exception("G4GDMLReadMaterials::DRea << 
186                     FatalException, "Invalid u << 
187       }                                        << 
188     }                                          << 
189   }                                            << 
190                                                << 
191   return value * unit;                         << 
192 }                                              << 
193                                                    65 
194 // ------------------------------------------- <<  66       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
195 G4double G4GDMLReadMaterials::PRead(const xerc <<  67       { continue; }
196 {                                              << 
197   G4double value = STP_Pressure;               << 
198   G4double unit  = hep_pascal;                 << 
199                                                    68 
200   const xercesc::DOMNamedNodeMap* const attrib <<  69       const xercesc::DOMAttr* const attribute
201   XMLSize_t attributeCount                     <<  70             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >>  71       const G4String attName = Transcode(attribute->getName());
                                                   >>  72       const G4String attValue = Transcode(attribute->getValue());
202                                                    73 
203   for(XMLSize_t attribute_index = 0; attribute <<  74       if (attName=="value") { value = eval.Evaluate(attValue); } else
204       ++attribute_index)                       <<  75       if (attName=="unit")  { unit = eval.Evaluate(attValue); }
205   {                                            <<  76    }
206     xercesc::DOMNode* attribute_node = attribu << 
207                                                << 
208     if(attribute_node->getNodeType() != xerces << 
209     {                                          << 
210       continue;                                << 
211     }                                          << 
212                                                << 
213     const xercesc::DOMAttr* const attribute =  << 
214       dynamic_cast<xercesc::DOMAttr*>(attribut << 
215     if(attribute == nullptr)                   << 
216     {                                          << 
217       G4Exception("G4GDMLReadMaterials::PRead( << 
218                   "No attribute found!");      << 
219       return value;                            << 
220     }                                          << 
221     const G4String attName  = Transcode(attrib << 
222     const G4String attValue = Transcode(attrib << 
223                                                << 
224     if(attName == "value")                     << 
225     {                                          << 
226       value = eval.Evaluate(attValue);         << 
227     }                                          << 
228     else if(attName == "unit")                 << 
229     {                                          << 
230       unit = G4UnitDefinition::GetValueOf(attV << 
231       if(G4UnitDefinition::GetCategory(attValu << 
232       {                                        << 
233         G4Exception("G4GDMLReadMaterials::PRea << 
234                     FatalException, "Invalid u << 
235       }                                        << 
236     }                                          << 
237   }                                            << 
238                                                    77 
239   return value * unit;                         <<  78    return value*unit;
240 }                                                  79 }
241                                                    80 
242 // ------------------------------------------- <<  81 G4int G4GDMLReadMaterials::
243 G4double G4GDMLReadMaterials::TRead(const xerc <<  82 CompositeRead(const xercesc::DOMElement* const compositeElement,G4String& ref)
244 {                                                  83 {
245   G4double value = NTP_Temperature;            <<  84    G4int n = 0;
246   G4double unit  = kelvin;                     << 
247                                                << 
248   const xercesc::DOMNamedNodeMap* const attrib << 
249   XMLSize_t attributeCount                     << 
250                                                << 
251   for(XMLSize_t attribute_index = 0; attribute << 
252       ++attribute_index)                       << 
253   {                                            << 
254     xercesc::DOMNode* attribute_node = attribu << 
255                                                << 
256     if(attribute_node->getNodeType() != xerces << 
257     {                                          << 
258       continue;                                << 
259     }                                          << 
260                                                << 
261     const xercesc::DOMAttr* const attribute =  << 
262       dynamic_cast<xercesc::DOMAttr*>(attribut << 
263     if(attribute == nullptr)                   << 
264     {                                          << 
265       G4Exception("G4GDMLReadMaterials::TRead( << 
266                   "No attribute found!");      << 
267       return value;                            << 
268     }                                          << 
269     const G4String attName  = Transcode(attrib << 
270     const G4String attValue = Transcode(attrib << 
271                                                << 
272     if(attName == "value")                     << 
273     {                                          << 
274       value = eval.Evaluate(attValue);         << 
275     }                                          << 
276     else if(attName == "unit")                 << 
277     {                                          << 
278       unit = G4UnitDefinition::GetValueOf(attV << 
279       if(G4UnitDefinition::GetCategory(attValu << 
280       {                                        << 
281         G4Exception("G4GDMLReadMaterials::TRea << 
282                     FatalException, "Invalid u << 
283       }                                        << 
284     }                                          << 
285   }                                            << 
286                                                    85 
287   return value * unit;                         <<  86    const xercesc::DOMNamedNodeMap* const attributes
288 }                                              <<  87          = compositeElement->getAttributes();
                                                   >>  88    XMLSize_t attributeCount = attributes->getLength();
289                                                    89 
290 // ------------------------------------------- <<  90    for (XMLSize_t attribute_index=0;
291 G4double G4GDMLReadMaterials::MEERead(const xe <<  91         attribute_index<attributeCount; attribute_index++)
292 {                                              <<  92    {
293   G4double value = -1;                         <<  93       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
294   G4double unit  = eV;                         << 
295                                                    94 
296   const xercesc::DOMNamedNodeMap* const attrib <<  95       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
297   XMLSize_t attributeCount                     <<  96       { continue; }
298                                                    97 
299   for(XMLSize_t attribute_index = 0; attribute <<  98       const xercesc::DOMAttr* const attribute
300       ++attribute_index)                       <<  99             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
301   {                                            << 100       const G4String attName = Transcode(attribute->getName());
302     xercesc::DOMNode* attribute_node = attribu << 101       const G4String attValue = Transcode(attribute->getValue());
303                                                << 
304     if(attribute_node->getNodeType() != xerces << 
305     {                                          << 
306       continue;                                << 
307     }                                          << 
308                                                << 
309     const xercesc::DOMAttr* const attribute =  << 
310       dynamic_cast<xercesc::DOMAttr*>(attribut << 
311     if(attribute == nullptr)                   << 
312     {                                          << 
313       G4Exception("G4GDMLReadMaterials::MEERea << 
314                   FatalException, "No attribut << 
315       return value;                            << 
316     }                                          << 
317     const G4String attName  = Transcode(attrib << 
318     const G4String attValue = Transcode(attrib << 
319                                                << 
320     if(attName == "value")                     << 
321     {                                          << 
322       value = eval.Evaluate(attValue);         << 
323     }                                          << 
324     else if(attName == "unit")                 << 
325     {                                          << 
326       unit = G4UnitDefinition::GetValueOf(attV << 
327       if(G4UnitDefinition::GetCategory(attValu << 
328       {                                        << 
329         G4Exception("G4GDMLReadMaterials::MEER << 
330                     FatalException, "Invalid u << 
331       }                                        << 
332     }                                          << 
333   }                                            << 
334                                                   102 
335   return value * unit;                         << 103       if (attName=="n")  { n = eval.EvaluateInteger(attValue); } else
336 }                                              << 104       if (attName=="ref") { ref = attValue; }
                                                   >> 105    }
337                                                   106 
338 // ------------------------------------------- << 107    return n;
339 void G4GDMLReadMaterials::ElementRead(         << 
340   const xercesc::DOMElement* const elementElem << 
341 {                                              << 
342   G4String name;                               << 
343   G4String formula;                            << 
344   G4double a = 0.0;                            << 
345   G4double Z = 0.0;                            << 
346                                                << 
347   const xercesc::DOMNamedNodeMap* const attrib << 
348     elementElement->getAttributes();           << 
349   XMLSize_t attributeCount = attributes->getLe << 
350                                                << 
351   for(XMLSize_t attribute_index = 0; attribute << 
352       ++attribute_index)                       << 
353   {                                            << 
354     xercesc::DOMNode* attribute_node = attribu << 
355                                                << 
356     if(attribute_node->getNodeType() != xerces << 
357     {                                          << 
358       continue;                                << 
359     }                                          << 
360                                                << 
361     const xercesc::DOMAttr* const attribute =  << 
362       dynamic_cast<xercesc::DOMAttr*>(attribut << 
363     if(attribute == nullptr)                   << 
364     {                                          << 
365       G4Exception("G4GDMLReadMaterials::Elemen << 
366                   FatalException, "No attribut << 
367       return;                                  << 
368     }                                          << 
369     const G4String attName  = Transcode(attrib << 
370     const G4String attValue = Transcode(attrib << 
371                                                << 
372     if(attName == "name")                      << 
373     {                                          << 
374       name = GenerateName(attValue);           << 
375     }                                          << 
376     else if(attName == "formula")              << 
377     {                                          << 
378       formula = attValue;                      << 
379     }                                          << 
380     else if(attName == "Z")                    << 
381     {                                          << 
382       Z = eval.Evaluate(attValue);             << 
383     }                                          << 
384   }                                            << 
385                                                << 
386   G4int nComponents = 0;                       << 
387                                                << 
388   for(xercesc::DOMNode* iter = elementElement- << 
389       iter                   = iter->getNextSi << 
390   {                                            << 
391     if(iter->getNodeType() != xercesc::DOMNode << 
392     {                                          << 
393       continue;                                << 
394     }                                          << 
395                                                << 
396     const xercesc::DOMElement* const child =   << 
397       dynamic_cast<xercesc::DOMElement*>(iter) << 
398     if(child == nullptr)                       << 
399     {                                          << 
400       G4Exception("G4GDMLReadMaterials::Elemen << 
401                   FatalException, "No child fo << 
402       return;                                  << 
403     }                                          << 
404     const G4String tag = Transcode(child->getT << 
405                                                << 
406     if(tag == "atom")                          << 
407     {                                          << 
408       a = AtomRead(child);                     << 
409     }                                          << 
410     else if(tag == "fraction")                 << 
411     {                                          << 
412       nComponents++;                           << 
413     }                                          << 
414   }                                            << 
415                                                << 
416   if(nComponents > 0)                          << 
417   {                                            << 
418     MixtureRead(elementElement,                << 
419                 new G4Element(Strip(name), for << 
420   }                                            << 
421   else                                         << 
422   {                                            << 
423     new G4Element(Strip(name), formula, Z, a); << 
424   }                                            << 
425 }                                                 108 }
426                                                   109 
427 // ------------------------------------------- << 110 G4double G4GDMLReadMaterials::DRead(const xercesc::DOMElement* const DElement)
428 G4double G4GDMLReadMaterials::FractionRead(    << 
429   const xercesc::DOMElement* const fractionEle << 
430 {                                                 111 {
431   G4double n = 0.0;                            << 112    G4double value = 0.0;
432                                                << 113    G4double unit = g/cm3;
433   const xercesc::DOMNamedNodeMap* const attrib << 
434     fractionElement->getAttributes();          << 
435   XMLSize_t attributeCount = attributes->getLe << 
436                                                << 
437   for(XMLSize_t attribute_index = 0; attribute << 
438       ++attribute_index)                       << 
439   {                                            << 
440     xercesc::DOMNode* attribute_node = attribu << 
441                                                << 
442     if(attribute_node->getNodeType() != xerces << 
443     {                                          << 
444       continue;                                << 
445     }                                          << 
446                                                << 
447     const xercesc::DOMAttr* const attribute =  << 
448       dynamic_cast<xercesc::DOMAttr*>(attribut << 
449     if(attribute == nullptr)                   << 
450     {                                          << 
451       G4Exception("G4GDMLReadMaterials::Fracti << 
452                   FatalException, "No attribut << 
453       return n;                                << 
454     }                                          << 
455     const G4String attName  = Transcode(attrib << 
456     const G4String attValue = Transcode(attrib << 
457                                                << 
458     if(attName == "n")                         << 
459     {                                          << 
460       n = eval.Evaluate(attValue);             << 
461     }                                          << 
462     else if(attName == "ref")                  << 
463     {                                          << 
464       ref = attValue;                          << 
465     }                                          << 
466   }                                            << 
467                                                   114 
468   return n;                                    << 115    const xercesc::DOMNamedNodeMap* const attributes
469 }                                              << 116          = DElement->getAttributes();
470                                                << 117    XMLSize_t attributeCount = attributes->getLength();
471 // ------------------------------------------- << 118 
472 void G4GDMLReadMaterials::IsotopeRead(         << 119    for (XMLSize_t attribute_index=0;
473   const xercesc::DOMElement* const isotopeElem << 120         attribute_index<attributeCount; attribute_index++)
474 {                                              << 121    {
475   G4String name;                               << 122       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
476   G4int Z    = 0;                              << 123 
477   G4int N    = 0;                              << 124       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
478   G4double a = 0.0;                            << 125       { continue; }
479                                                << 126 
480   const xercesc::DOMNamedNodeMap* const attrib << 127       const xercesc::DOMAttr* const attribute
481     isotopeElement->getAttributes();           << 128             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
482   XMLSize_t attributeCount = attributes->getLe << 129       const G4String attName = Transcode(attribute->getName());
483                                                << 130       const G4String attValue = Transcode(attribute->getValue());
484   for(XMLSize_t attribute_index = 0; attribute << 131 
485       ++attribute_index)                       << 132       if (attName=="value") { value = eval.Evaluate(attValue); } else
486   {                                            << 133       if (attName=="unit")  { unit = eval.Evaluate(attValue); }
487     xercesc::DOMNode* attribute_node = attribu << 134    }
488                                                << 
489     if(attribute_node->getNodeType() != xerces << 
490     {                                          << 
491       continue;                                << 
492     }                                          << 
493                                                << 
494     const xercesc::DOMAttr* const attribute =  << 
495       dynamic_cast<xercesc::DOMAttr*>(attribut << 
496     if(attribute == nullptr)                   << 
497     {                                          << 
498       G4Exception("G4GDMLReadMaterials::Isotop << 
499                   FatalException, "No attribut << 
500       return;                                  << 
501     }                                          << 
502     const G4String attName  = Transcode(attrib << 
503     const G4String attValue = Transcode(attrib << 
504                                                << 
505     if(attName == "name")                      << 
506     {                                          << 
507       name = GenerateName(attValue);           << 
508     }                                          << 
509     else if(attName == "Z")                    << 
510     {                                          << 
511       Z = eval.EvaluateInteger(attValue);      << 
512     }                                          << 
513     else if(attName == "N")                    << 
514     {                                          << 
515       N = eval.EvaluateInteger(attValue);      << 
516     }                                          << 
517   }                                            << 
518                                                << 
519   for(xercesc::DOMNode* iter = isotopeElement- << 
520       iter                   = iter->getNextSi << 
521   {                                            << 
522     if(iter->getNodeType() != xercesc::DOMNode << 
523     {                                          << 
524       continue;                                << 
525     }                                          << 
526                                                << 
527     const xercesc::DOMElement* const child =   << 
528       dynamic_cast<xercesc::DOMElement*>(iter) << 
529     if(child == nullptr)                       << 
530     {                                          << 
531       G4Exception("G4GDMLReadMaterials::Isotop << 
532                   FatalException, "No child fo << 
533       return;                                  << 
534     }                                          << 
535     const G4String tag = Transcode(child->getT << 
536                                                << 
537     if(tag == "atom")                          << 
538     {                                          << 
539       a = AtomRead(child);                     << 
540     }                                          << 
541   }                                            << 
542                                                   135 
543   new G4Isotope(Strip(name), Z, N, a);         << 136    return value*unit;
544 }                                                 137 }
545                                                   138 
546 // ------------------------------------------- << 139 G4double G4GDMLReadMaterials::PRead(const xercesc::DOMElement* const PElement)
547 void G4GDMLReadMaterials::MaterialRead(        << 
548   const xercesc::DOMElement* const materialEle << 
549 {                                                 140 {
550   G4String name;                               << 141    G4double value = STP_Pressure;
551   G4double Z    = 0.0;                         << 142    G4double unit = pascal;
552   G4double a    = 0.0;                         << 
553   G4double D    = 0.0;                         << 
554   G4State state = kStateUndefined;             << 
555   G4double T    = NTP_Temperature;             << 
556   G4double P    = STP_Pressure;                << 
557   G4double MEE  = -1.0;                        << 
558                                                << 
559   const xercesc::DOMNamedNodeMap* const attrib << 
560     materialElement->getAttributes();          << 
561   XMLSize_t attributeCount = attributes->getLe << 
562                                                << 
563   for(XMLSize_t attribute_index = 0; attribute << 
564       ++attribute_index)                       << 
565   {                                            << 
566     xercesc::DOMNode* attribute_node = attribu << 
567                                                << 
568     if(attribute_node->getNodeType() != xerces << 
569     {                                          << 
570       continue;                                << 
571     }                                          << 
572                                                << 
573     const xercesc::DOMAttr* const attribute =  << 
574       dynamic_cast<xercesc::DOMAttr*>(attribut << 
575     if(attribute == nullptr)                   << 
576     {                                          << 
577       G4Exception("G4GDMLReadMaterials::Materi << 
578                   FatalException, "No attribut << 
579       return;                                  << 
580     }                                          << 
581     const G4String attName  = Transcode(attrib << 
582     const G4String attValue = Transcode(attrib << 
583                                                << 
584     if(attName == "name")                      << 
585     {                                          << 
586       name = GenerateName(attValue);           << 
587     }                                          << 
588     else if(attName == "Z")                    << 
589     {                                          << 
590       Z = eval.Evaluate(attValue);             << 
591     }                                          << 
592     else if(attName == "state")                << 
593     {                                          << 
594       if(attValue == "solid")                  << 
595       {                                        << 
596         state = kStateSolid;                   << 
597       }                                        << 
598       else if(attValue == "liquid")            << 
599       {                                        << 
600         state = kStateLiquid;                  << 
601       }                                        << 
602       else if(attValue == "gas")               << 
603       {                                        << 
604         state = kStateGas;                     << 
605       }                                        << 
606     }                                          << 
607   }                                            << 
608                                                   143 
609   std::size_t nComponents = 0;                 << 144    const xercesc::DOMNamedNodeMap* const attributes = PElement->getAttributes();
                                                   >> 145    XMLSize_t attributeCount = attributes->getLength();
610                                                   146 
611   for(xercesc::DOMNode* iter = materialElement << 147    for (XMLSize_t attribute_index=0;
612                         iter != nullptr; iter  << 148         attribute_index<attributeCount; attribute_index++)
613   {                                            << 149    {
614     if(iter->getNodeType() != xercesc::DOMNode << 150       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
615     {                                          << 151 
616       continue;                                << 152       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
617     }                                          << 153       { continue; }
618                                                << 154 
619     const xercesc::DOMElement* const child =   << 155       const xercesc::DOMAttr* const attribute
620       dynamic_cast<xercesc::DOMElement*>(iter) << 156             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
621     if(child == nullptr)                       << 157       const G4String attName = Transcode(attribute->getName());
622     {                                          << 158       const G4String attValue = Transcode(attribute->getValue());
623       G4Exception("G4GDMLReadMaterials::Materi << 159 
624                   FatalException, "No child fo << 160       if (attName=="value") { value = eval.Evaluate(attValue); } else
625       return;                                  << 161       if (attName=="unit")  { unit = eval.Evaluate(attValue); }
626     }                                          << 162    }
627     const G4String tag = Transcode(child->getT << 
628                                                << 
629     if(tag == "atom")                          << 
630     {                                          << 
631       a = AtomRead(child);                     << 
632     }                                          << 
633     else if(tag == "Dref")                     << 
634     {                                          << 
635       D = GetQuantity(GenerateName(RefRead(chi << 
636     }                                          << 
637     else if(tag == "Pref")                     << 
638     {                                          << 
639       P = GetQuantity(GenerateName(RefRead(chi << 
640     }                                          << 
641     else if(tag == "Tref")                     << 
642     {                                          << 
643       T = GetQuantity(GenerateName(RefRead(chi << 
644     }                                          << 
645     else if(tag == "MEEref")                   << 
646     {                                          << 
647       MEE = GetQuantity(GenerateName(RefRead(c << 
648     }                                          << 
649     else if(tag == "D")                        << 
650     {                                          << 
651       D = DRead(child);                        << 
652     }                                          << 
653     else if(tag == "P")                        << 
654     {                                          << 
655       P = PRead(child);                        << 
656     }                                          << 
657     else if(tag == "T")                        << 
658     {                                          << 
659       T = TRead(child);                        << 
660     }                                          << 
661     else if(tag == "MEE")                      << 
662     {                                          << 
663       MEE = MEERead(child);                    << 
664     }                                          << 
665     else if(tag == "fraction" || tag == "compo << 
666     {                                          << 
667       nComponents++;                           << 
668     }                                          << 
669   }                                            << 
670                                                << 
671   G4Material* material = nullptr;              << 
672                                                << 
673   if(nComponents == 0)                         << 
674   {                                            << 
675     material = new G4Material(Strip(name), Z,  << 
676   }                                            << 
677   else                                         << 
678   {                                            << 
679     material = new G4Material(Strip(name), D,  << 
680     MixtureRead(materialElement, material);    << 
681   }                                            << 
682   if(MEE != -1)  // ionisation potential (mean << 
683   {                                            << 
684     material->GetIonisation()->SetMeanExcitati << 
685   }                                            << 
686                                                << 
687   for(xercesc::DOMNode* iter = materialElement << 
688                         iter != nullptr; iter  << 
689   {                                            << 
690     if(iter->getNodeType() != xercesc::DOMNode << 
691     {                                          << 
692       continue;                                << 
693     }                                          << 
694                                                << 
695     const xercesc::DOMElement* const child =   << 
696       dynamic_cast<xercesc::DOMElement*>(iter) << 
697     if(child == nullptr)                       << 
698     {                                          << 
699       G4Exception("G4GDMLReadMaterials::Materi << 
700                   FatalException, "No child fo << 
701       return;                                  << 
702     }                                          << 
703     const G4String tag = Transcode(child->getT << 
704                                                << 
705     if(tag == "property")                      << 
706     {                                          << 
707       PropertyRead(child, material);           << 
708     }                                          << 
709   }                                            << 
710 }                                              << 
711                                                   163 
712 // ------------------------------------------- << 164    return value*unit;
713 void G4GDMLReadMaterials::MixtureRead(         << 
714   const xercesc::DOMElement* const mixtureElem << 
715 {                                              << 
716   for(xercesc::DOMNode* iter = mixtureElement- << 
717       iter                   = iter->getNextSi << 
718   {                                            << 
719     if(iter->getNodeType() != xercesc::DOMNode << 
720     {                                          << 
721       continue;                                << 
722     }                                          << 
723                                                << 
724     const xercesc::DOMElement* const child =   << 
725       dynamic_cast<xercesc::DOMElement*>(iter) << 
726     if(child == nullptr)                       << 
727     {                                          << 
728       G4Exception("G4GDMLReadMaterials::Mixtur << 
729                   FatalException, "No child fo << 
730       return;                                  << 
731     }                                          << 
732     const G4String tag = Transcode(child->getT << 
733                                                << 
734     if(tag == "fraction")                      << 
735     {                                          << 
736       G4String ref;                            << 
737       G4double n = FractionRead(child, ref);   << 
738       element->AddIsotope(GetIsotope(GenerateN << 
739     }                                          << 
740   }                                            << 
741 }                                                 165 }
742                                                   166 
743 // ------------------------------------------- << 167 G4double G4GDMLReadMaterials::TRead(const xercesc::DOMElement* const TElement)
744 void G4GDMLReadMaterials::MixtureRead(         << 
745   const xercesc::DOMElement* const mixtureElem << 
746 {                                                 168 {
747   for(xercesc::DOMNode* iter = mixtureElement- << 169    G4double value = STP_Temperature;
748       iter                   = iter->getNextSi << 170    G4double unit = kelvin;
749   {                                            << 
750     if(iter->getNodeType() != xercesc::DOMNode << 
751     {                                          << 
752       continue;                                << 
753     }                                          << 
754                                                << 
755     const xercesc::DOMElement* const child =   << 
756       dynamic_cast<xercesc::DOMElement*>(iter) << 
757     if(child == nullptr)                       << 
758     {                                          << 
759       G4Exception("G4GDMLReadMaterials::Mixtur << 
760                   FatalException, "No child fo << 
761       return;                                  << 
762     }                                          << 
763     const G4String tag = Transcode(child->getT << 
764                                                << 
765     if(tag == "fraction")                      << 
766     {                                          << 
767       G4String ref;                            << 
768       G4double n = FractionRead(child, ref);   << 
769                                                << 
770       G4Material* materialPtr = GetMaterial(Ge << 
771       G4Element* elementPtr   = GetElement(Gen << 
772                                                   171 
773       if(elementPtr != nullptr)                << 172    const xercesc::DOMNamedNodeMap* const attributes = TElement->getAttributes();
774       {                                        << 173    XMLSize_t attributeCount = attributes->getLength();
775         material->AddElement(elementPtr, n);   << 
776       }                                        << 
777       else if(materialPtr != nullptr)          << 
778       {                                        << 
779         material->AddMaterial(materialPtr, n); << 
780       }                                        << 
781                                                   174 
782       if((materialPtr == nullptr) && (elementP << 175    for (XMLSize_t attribute_index=0;
                                                   >> 176         attribute_index<attributeCount; attribute_index++)
                                                   >> 177    {
                                                   >> 178       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 179 
                                                   >> 180       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 181       { continue; }
                                                   >> 182 
                                                   >> 183       const xercesc::DOMAttr* const attribute
                                                   >> 184             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 185       const G4String attName = Transcode(attribute->getName());
                                                   >> 186       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 187 
                                                   >> 188       if (attName=="value") { value = eval.Evaluate(attValue); } else
                                                   >> 189       if (attName=="unit")  { unit = eval.Evaluate(attValue); }
                                                   >> 190    }
                                                   >> 191 
                                                   >> 192    return value*unit;
                                                   >> 193 }
                                                   >> 194 
                                                   >> 195 void G4GDMLReadMaterials::
                                                   >> 196 ElementRead(const xercesc::DOMElement* const elementElement) 
                                                   >> 197 {
                                                   >> 198    G4String name;
                                                   >> 199    G4String formula;
                                                   >> 200    G4double a = 0.0;
                                                   >> 201    G4double Z = 0.0;
                                                   >> 202 
                                                   >> 203    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 204          = elementElement->getAttributes();
                                                   >> 205    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 206 
                                                   >> 207    for (XMLSize_t attribute_index=0;
                                                   >> 208         attribute_index<attributeCount; attribute_index++)
                                                   >> 209    {
                                                   >> 210       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 211 
                                                   >> 212       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 213       { continue; }
                                                   >> 214 
                                                   >> 215       const xercesc::DOMAttr* const attribute
                                                   >> 216             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 217       const G4String attName = Transcode(attribute->getName());
                                                   >> 218       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 219 
                                                   >> 220       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 221       if (attName=="formula") { formula = attValue; } else
                                                   >> 222       if (attName=="Z") { Z = eval.Evaluate(attValue); }
                                                   >> 223    }
                                                   >> 224 
                                                   >> 225    G4int nComponents = 0;
                                                   >> 226 
                                                   >> 227    for (xercesc::DOMNode* iter = elementElement->getFirstChild();
                                                   >> 228         iter != 0; iter = iter->getNextSibling())
                                                   >> 229    {
                                                   >> 230       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 231 
                                                   >> 232       const xercesc::DOMElement* const child
                                                   >> 233             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 234       const G4String tag = Transcode(child->getTagName());
                                                   >> 235 
                                                   >> 236       if (tag=="atom") { a = AtomRead(child); }  else
                                                   >> 237       if (tag=="fraction") { nComponents++; }
                                                   >> 238    }
                                                   >> 239 
                                                   >> 240    if (nComponents>0)
                                                   >> 241    {
                                                   >> 242      MixtureRead(elementElement,
                                                   >> 243                  new G4Element(Strip(name),formula,nComponents));
                                                   >> 244    }
                                                   >> 245    else
                                                   >> 246    {
                                                   >> 247      new G4Element(Strip(name),formula,Z,a);
                                                   >> 248    }
                                                   >> 249 }
                                                   >> 250 
                                                   >> 251 G4double G4GDMLReadMaterials::
                                                   >> 252 FractionRead(const xercesc::DOMElement* const fractionElement, G4String& ref)
                                                   >> 253 {
                                                   >> 254    G4double n = 0.0;
                                                   >> 255 
                                                   >> 256    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 257          = fractionElement->getAttributes();
                                                   >> 258    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 259 
                                                   >> 260    for (XMLSize_t attribute_index=0;
                                                   >> 261         attribute_index<attributeCount; attribute_index++)
                                                   >> 262    {
                                                   >> 263       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 264 
                                                   >> 265       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 266       { continue; }
                                                   >> 267 
                                                   >> 268       const xercesc::DOMAttr* const attribute
                                                   >> 269             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 270       const G4String attName = Transcode(attribute->getName());
                                                   >> 271       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 272 
                                                   >> 273       if (attName=="n")   { n = eval.Evaluate(attValue); } else
                                                   >> 274       if (attName=="ref") { ref = attValue; }
                                                   >> 275    }
                                                   >> 276 
                                                   >> 277    return n;
                                                   >> 278 }
                                                   >> 279 
                                                   >> 280 void G4GDMLReadMaterials::
                                                   >> 281 IsotopeRead(const xercesc::DOMElement* const isotopeElement)
                                                   >> 282 {
                                                   >> 283    G4String name;
                                                   >> 284    G4int Z = 0;
                                                   >> 285    G4int N = 0;
                                                   >> 286    G4double a = 0.0;
                                                   >> 287 
                                                   >> 288    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 289          = isotopeElement->getAttributes();
                                                   >> 290    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 291 
                                                   >> 292    for (XMLSize_t attribute_index=0;
                                                   >> 293         attribute_index<attributeCount;attribute_index++)
                                                   >> 294    {
                                                   >> 295       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 296 
                                                   >> 297       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 298       { continue; }
                                                   >> 299 
                                                   >> 300       const xercesc::DOMAttr* const attribute
                                                   >> 301             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 302       const G4String attName = Transcode(attribute->getName());
                                                   >> 303       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 304 
                                                   >> 305       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 306       if (attName=="Z") { Z = eval.EvaluateInteger(attValue); } else
                                                   >> 307       if (attName=="N") { N = eval.EvaluateInteger(attValue); }
                                                   >> 308    }
                                                   >> 309 
                                                   >> 310    for (xercesc::DOMNode* iter = isotopeElement->getFirstChild();
                                                   >> 311         iter != 0; iter = iter->getNextSibling())
                                                   >> 312    {
                                                   >> 313       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 314 
                                                   >> 315       const xercesc::DOMElement* const child
                                                   >> 316             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 317       const G4String tag = Transcode(child->getTagName());
                                                   >> 318 
                                                   >> 319       if (tag=="atom")  { a = AtomRead(child); }
                                                   >> 320    }
                                                   >> 321 
                                                   >> 322    new G4Isotope(Strip(name),Z,N,a);
                                                   >> 323 }
                                                   >> 324 
                                                   >> 325 void G4GDMLReadMaterials::
                                                   >> 326 MaterialRead(const xercesc::DOMElement* const materialElement)
                                                   >> 327 {
                                                   >> 328    G4String name;
                                                   >> 329    G4double Z = 0.0;
                                                   >> 330    G4double a = 0.0;
                                                   >> 331    G4double D = 0.0;
                                                   >> 332    G4State state = kStateUndefined;
                                                   >> 333    G4double T = STP_Temperature;
                                                   >> 334    G4double P = STP_Pressure;
                                                   >> 335 
                                                   >> 336    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 337          = materialElement->getAttributes();
                                                   >> 338    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 339 
                                                   >> 340    for (XMLSize_t attribute_index=0;
                                                   >> 341         attribute_index<attributeCount; attribute_index++)
                                                   >> 342    {
                                                   >> 343       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 344 
                                                   >> 345       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 346       { continue; }
                                                   >> 347 
                                                   >> 348       const xercesc::DOMAttr* const attribute
                                                   >> 349             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 350       const G4String attName = Transcode(attribute->getName());
                                                   >> 351       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 352 
                                                   >> 353       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 354       if (attName=="Z") { Z = eval.Evaluate(attValue); } else
                                                   >> 355       if (attName=="state")
                                                   >> 356       {
                                                   >> 357          if (attValue=="solid")  { state = kStateSolid;  } else
                                                   >> 358          if (attValue=="liquid") { state = kStateLiquid; } else
                                                   >> 359          if (attValue=="gas")    { state = kStateGas; }
                                                   >> 360       }
                                                   >> 361    }
                                                   >> 362 
                                                   >> 363    size_t nComponents = 0;
                                                   >> 364 
                                                   >> 365    for (xercesc::DOMNode* iter = materialElement->getFirstChild();
                                                   >> 366         iter != 0; iter = iter->getNextSibling())
                                                   >> 367    {
                                                   >> 368       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 369 
                                                   >> 370       const xercesc::DOMElement* const child
                                                   >> 371             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 372       const G4String tag = Transcode(child->getTagName());
                                                   >> 373 
                                                   >> 374       if (tag=="atom") { a = AtomRead(child); } else
                                                   >> 375       if (tag=="Dref") { D = GetQuantity(GenerateName(RefRead(child))); } else
                                                   >> 376       if (tag=="Pref") { P = GetQuantity(GenerateName(RefRead(child))); } else
                                                   >> 377       if (tag=="Tref") { T = GetQuantity(GenerateName(RefRead(child))); } else
                                                   >> 378       if (tag=="D") { D = DRead(child); } else
                                                   >> 379       if (tag=="P") { P = PRead(child); } else
                                                   >> 380       if (tag=="T") { T = TRead(child); } else
                                                   >> 381       if (tag=="fraction" || tag=="composite")  { nComponents++; }
                                                   >> 382    }
                                                   >> 383 
                                                   >> 384    G4Material* material =  0;
                                                   >> 385 
                                                   >> 386    if (nComponents==0)
                                                   >> 387    {
                                                   >> 388      material = new G4Material(Strip(name),Z,a,D,state,T,P);
                                                   >> 389    }
                                                   >> 390    else
                                                   >> 391    {
                                                   >> 392      material = new G4Material(Strip(name),D,nComponents,state,T,P);
                                                   >> 393      MixtureRead(materialElement, material);
                                                   >> 394    }
                                                   >> 395 
                                                   >> 396    for (xercesc::DOMNode* iter = materialElement->getFirstChild();
                                                   >> 397         iter != 0; iter = iter->getNextSibling())
                                                   >> 398    {
                                                   >> 399       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 400 
                                                   >> 401       const xercesc::DOMElement* const child
                                                   >> 402             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 403       const G4String tag = Transcode(child->getTagName());
                                                   >> 404 
                                                   >> 405       if (tag=="property") { PropertyRead(child,material); }
                                                   >> 406    }
                                                   >> 407 }
                                                   >> 408 
                                                   >> 409 void G4GDMLReadMaterials::
                                                   >> 410 MixtureRead(const xercesc::DOMElement *const mixtureElement, G4Element *element)
                                                   >> 411 {
                                                   >> 412    for (xercesc::DOMNode* iter = mixtureElement->getFirstChild();
                                                   >> 413         iter != 0; iter = iter->getNextSibling())
                                                   >> 414    {
                                                   >> 415       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 416 
                                                   >> 417       const xercesc::DOMElement* const child
                                                   >> 418             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 419       const G4String tag = Transcode(child->getTagName());
                                                   >> 420 
                                                   >> 421       if (tag=="fraction")
                                                   >> 422       {
                                                   >> 423          G4String ref;
                                                   >> 424          G4double n = FractionRead(child,ref);
                                                   >> 425          element->AddIsotope(GetIsotope(GenerateName(ref,true)),n);
                                                   >> 426       }
                                                   >> 427    }
                                                   >> 428 }
                                                   >> 429 
                                                   >> 430 void G4GDMLReadMaterials::
                                                   >> 431 MixtureRead(const xercesc::DOMElement *const mixtureElement,
                                                   >> 432             G4Material *material)
                                                   >> 433 {
                                                   >> 434    for (xercesc::DOMNode* iter = mixtureElement->getFirstChild();
                                                   >> 435         iter != 0; iter = iter->getNextSibling())
                                                   >> 436    {
                                                   >> 437       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 438 
                                                   >> 439       const xercesc::DOMElement* const child
                                                   >> 440             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 441       const G4String tag = Transcode(child->getTagName());
                                                   >> 442 
                                                   >> 443       if (tag=="fraction")
                                                   >> 444       {
                                                   >> 445          G4String ref;
                                                   >> 446          G4double n = FractionRead(child,ref);
                                                   >> 447          
                                                   >> 448          G4Material *materialPtr = GetMaterial(GenerateName(ref,true), false);
                                                   >> 449          G4Element *elementPtr = GetElement(GenerateName(ref,true), false);
                                                   >> 450 
                                                   >> 451          if (materialPtr != 0) { material->AddMaterial(materialPtr,n); } else
                                                   >> 452          if (elementPtr != 0)  { material->AddElement(elementPtr,n); }
                                                   >> 453 
                                                   >> 454          if ((materialPtr == 0) && (elementPtr == 0))
                                                   >> 455          {
                                                   >> 456             G4String error_msg = "Referenced material/element '"
                                                   >> 457                                + GenerateName(ref,true) + "' was not found!";
                                                   >> 458             G4Exception("G4GDMLReadMaterials::MixtureRead()", "InvalidSetup",
                                                   >> 459                         FatalException, error_msg);   
                                                   >> 460          }
                                                   >> 461       } 
                                                   >> 462       else if (tag=="composite")
                                                   >> 463       {
                                                   >> 464          G4String ref;
                                                   >> 465          G4int n = CompositeRead(child,ref);
                                                   >> 466 
                                                   >> 467          G4Element *elementPtr = GetElement(GenerateName(ref,true));
                                                   >> 468          material->AddElement(elementPtr,n);
                                                   >> 469       }
                                                   >> 470    }
                                                   >> 471 }
                                                   >> 472 
                                                   >> 473 void G4GDMLReadMaterials::
                                                   >> 474 PropertyRead(const xercesc::DOMElement* const propertyElement,
                                                   >> 475              G4Material* material)
                                                   >> 476 {
                                                   >> 477    G4String name;
                                                   >> 478    G4String ref;
                                                   >> 479    G4GDMLMatrix matrix;
                                                   >> 480 
                                                   >> 481    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 482          = propertyElement->getAttributes();
                                                   >> 483    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 484 
                                                   >> 485    for (XMLSize_t attribute_index=0;
                                                   >> 486         attribute_index<attributeCount; attribute_index++)
                                                   >> 487    {
                                                   >> 488       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 489 
                                                   >> 490       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 491       { continue; }
                                                   >> 492 
                                                   >> 493       const xercesc::DOMAttr* const attribute
                                                   >> 494             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 495       const G4String attName = Transcode(attribute->getName());
                                                   >> 496       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 497 
                                                   >> 498       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 499       if (attName=="ref")  { matrix = GetMatrix(ref=attValue); }
                                                   >> 500    }
                                                   >> 501 
                                                   >> 502    if (matrix.GetCols() != 2)
                                                   >> 503    {
                                                   >> 504      G4String error_msg = "Referenced matrix '" + ref
                                                   >> 505             + "' should have \n two columns as a property table for material: "
                                                   >> 506             + material->GetName();
                                                   >> 507      G4Exception("G4GDMLReadMaterials::PropertyRead()", "InvalidRead",
                                                   >> 508                  FatalException, error_msg);
                                                   >> 509    }
                                                   >> 510    if (matrix.GetRows() == 0) { return; }
                                                   >> 511 
                                                   >> 512    G4MaterialPropertiesTable* matprop=material->GetMaterialPropertiesTable();
                                                   >> 513    if (!matprop)
                                                   >> 514    {
                                                   >> 515      matprop = new G4MaterialPropertiesTable();
                                                   >> 516      material->SetMaterialPropertiesTable(matprop);
                                                   >> 517    }
                                                   >> 518    if (matrix.GetCols() == 1)  // constant property assumed
                                                   >> 519    {
                                                   >> 520      matprop->AddConstProperty(Strip(name), matrix.Get(0,0));
                                                   >> 521    }
                                                   >> 522    else  // build the material properties vector
                                                   >> 523    {
                                                   >> 524      G4MaterialPropertyVector* propvect = new G4MaterialPropertyVector(0,0,0);
                                                   >> 525      for (size_t i=0; i<matrix.GetRows(); i++)
                                                   >> 526      {
                                                   >> 527        propvect->AddElement(matrix.Get(i,0),matrix.Get(i,1));
                                                   >> 528      }
                                                   >> 529      matprop->AddProperty(Strip(name),propvect);
                                                   >> 530    }
                                                   >> 531 }
                                                   >> 532 
                                                   >> 533 void G4GDMLReadMaterials::
                                                   >> 534 MaterialsRead(const xercesc::DOMElement* const materialsElement)
                                                   >> 535 {
                                                   >> 536    G4cout << "G4GDML: Reading materials..." << G4endl;
                                                   >> 537 
                                                   >> 538    for (xercesc::DOMNode* iter = materialsElement->getFirstChild();
                                                   >> 539         iter != 0; iter = iter->getNextSibling())
                                                   >> 540    {
                                                   >> 541       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 542 
                                                   >> 543       const xercesc::DOMElement* const child
                                                   >> 544             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 545       const G4String tag = Transcode(child->getTagName());
                                                   >> 546       
                                                   >> 547       if (tag=="define")   { DefineRead(child);  }  else 
                                                   >> 548       if (tag=="element")  { ElementRead(child); }  else 
                                                   >> 549       if (tag=="isotope")  { IsotopeRead(child); }  else 
                                                   >> 550       if (tag=="material") { MaterialRead(child); }
                                                   >> 551       else
783       {                                           552       {
784         G4String error_msg = "Referenced mater << 553         G4String error_msg = "Unknown tag in materials: " + tag;
785                              GenerateName(ref, << 554         G4Exception("G4GDMLReadMaterials::MaterialsRead()", "InvalidSetup",
786         G4Exception("G4GDMLReadMaterials::Mixt << 
787                     FatalException, error_msg)    555                     FatalException, error_msg);
788       }                                           556       }
789     }                                          << 557    }
790     else if(tag == "composite")                << 
791     {                                          << 
792       G4String ref;                            << 
793       G4int n = CompositeRead(child, ref);     << 
794                                                << 
795       G4Element* elementPtr = GetElement(Gener << 
796       material->AddElement(elementPtr, n);     << 
797     }                                          << 
798   }                                            << 
799 }                                              << 
800                                                << 
801 // ------------------------------------------- << 
802 void G4GDMLReadMaterials::PropertyRead(        << 
803   const xercesc::DOMElement* const propertyEle << 
804 {                                              << 
805   G4String name;                               << 
806   G4String ref;                                << 
807   G4GDMLMatrix matrix;                         << 
808                                                << 
809   const xercesc::DOMNamedNodeMap* const attrib << 
810     propertyElement->getAttributes();          << 
811   XMLSize_t attributeCount = attributes->getLe << 
812                                                << 
813   for(XMLSize_t attribute_index = 0; attribute << 
814       ++attribute_index)                       << 
815   {                                            << 
816     xercesc::DOMNode* attribute_node = attribu << 
817                                                << 
818     if(attribute_node->getNodeType() != xerces << 
819     {                                          << 
820       continue;                                << 
821     }                                          << 
822                                                << 
823     const xercesc::DOMAttr* const attribute =  << 
824       dynamic_cast<xercesc::DOMAttr*>(attribut << 
825     if(attribute == nullptr)                   << 
826     {                                          << 
827       G4Exception("G4GDMLReadMaterials::Proper << 
828                   FatalException, "No attribut << 
829       return;                                  << 
830     }                                          << 
831     const G4String attName  = Transcode(attrib << 
832     const G4String attValue = Transcode(attrib << 
833                                                << 
834     if(attName == "name")                      << 
835     {                                          << 
836       name = GenerateName(attValue);           << 
837     }                                          << 
838     else if(attName == "ref")                  << 
839     {                                          << 
840       matrix = GetMatrix(ref = attValue);      << 
841     }                                          << 
842   }                                            << 
843                                                << 
844   /*                                           << 
845   if (matrix.GetCols() != 2)                   << 
846   {                                            << 
847     G4String error_msg = "Referenced matrix '" << 
848            + "' should have \n two columns as  << 
849            + material->GetName();              << 
850     G4Exception("G4GDMLReadMaterials::Property << 
851                 FatalException, error_msg);    << 
852   }                                            << 
853   */                                           << 
854                                                << 
855   if(matrix.GetRows() == 0)                    << 
856   {                                            << 
857     return;                                    << 
858   }                                            << 
859                                                << 
860   G4MaterialPropertiesTable* matprop = materia << 
861   if(matprop == nullptr)                       << 
862   {                                            << 
863     matprop = new G4MaterialPropertiesTable(); << 
864     material->SetMaterialPropertiesTable(matpr << 
865   }                                            << 
866   if(matrix.GetCols() == 1)  // constant prope << 
867   {                                            << 
868     matprop->AddConstProperty(Strip(name), mat << 
869   }                                            << 
870   else  // build the material properties vecto << 
871   {                                            << 
872     G4MaterialPropertyVector* propvect = new G << 
873     for(std::size_t i = 0; i < matrix.GetRows( << 
874     {                                          << 
875       propvect->InsertValues(matrix.Get(i, 0), << 
876     }                                          << 
877     matprop->AddProperty(Strip(name), propvect << 
878   }                                            << 
879 }                                                 558 }
880                                                   559 
881 // ------------------------------------------- << 560 G4Element* G4GDMLReadMaterials::
882 void G4GDMLReadMaterials::MaterialsRead(       << 561 GetElement(const G4String& ref, G4bool verbose) const
883   const xercesc::DOMElement* const materialsEl << 
884 {                                                 562 {
885 #ifdef G4VERBOSE                               << 563    G4Element* elementPtr = G4Element::GetElement(ref,false);
886   G4cout << "G4GDML: Reading materials..." <<  << 
887 #endif                                         << 
888   for(xercesc::DOMNode* iter = materialsElemen << 
889                         iter != nullptr; iter  << 
890   {                                            << 
891     if(iter->getNodeType() != xercesc::DOMNode << 
892     {                                          << 
893       continue;                                << 
894     }                                          << 
895                                                << 
896     const xercesc::DOMElement* const child =   << 
897       dynamic_cast<xercesc::DOMElement*>(iter) << 
898     if(child == nullptr)                       << 
899     {                                          << 
900       G4Exception("G4GDMLReadMaterials::Materi << 
901                   FatalException, "No child fo << 
902       return;                                  << 
903     }                                          << 
904     const G4String tag = Transcode(child->getT << 
905                                                << 
906     if(tag == "define")                        << 
907     {                                          << 
908       DefineRead(child);                       << 
909     }                                          << 
910     else if(tag == "element")                  << 
911     {                                          << 
912       ElementRead(child);                      << 
913     }                                          << 
914     else if(tag == "isotope")                  << 
915     {                                          << 
916       IsotopeRead(child);                      << 
917     }                                          << 
918     else if(tag == "material")                 << 
919     {                                          << 
920       MaterialRead(child);                     << 
921     }                                          << 
922     else                                       << 
923     {                                          << 
924       G4String error_msg = "Unknown tag in mat << 
925       G4Exception("G4GDMLReadMaterials::Materi << 
926                   FatalException, error_msg);  << 
927     }                                          << 
928   }                                            << 
929 }                                              << 
930                                                   564 
931 // ------------------------------------------- << 565    if (!elementPtr)
932 G4Element* G4GDMLReadMaterials::GetElement(con << 566    {
933                                            G4b << 567      elementPtr = G4NistManager::Instance()->FindOrBuildElement(ref);
934 {                                              << 568    }
935   G4Element* elementPtr = G4Element::GetElemen << 
936                                                   569 
937   if(elementPtr == nullptr)                    << 570    if (verbose && !elementPtr)
938   {                                            << 571    {
939     elementPtr = G4NistManager::Instance()->Fi << 572      G4String error_msg = "Referenced element '" + ref + "' was not found!";
940   }                                            << 573      G4Exception("G4GDMLReadMaterials::GetElement()", "InvalidRead",
941                                                << 574                  FatalException, error_msg);
942   if(verbose && elementPtr == nullptr)         << 575    }
943   {                                            << 
944     G4String error_msg = "Referenced element ' << 
945     G4Exception("G4GDMLReadMaterials::GetEleme << 
946                 FatalException, error_msg);    << 
947   }                                            << 
948                                                   576 
949   return elementPtr;                           << 577    return elementPtr;
950 }                                                 578 }
951                                                   579 
952 // ------------------------------------------- << 
953 G4Isotope* G4GDMLReadMaterials::GetIsotope(con    580 G4Isotope* G4GDMLReadMaterials::GetIsotope(const G4String& ref,
954                                            G4b    581                                            G4bool verbose) const
955 {                                                 582 {
956   G4Isotope* isotopePtr = G4Isotope::GetIsotop << 583    G4Isotope* isotopePtr = G4Isotope::GetIsotope(ref,false);
957                                                   584 
958   if(verbose && isotopePtr == nullptr)         << 585    if (verbose && !isotopePtr)
959   {                                            << 586    {
960     G4String error_msg = "Referenced isotope ' << 587      G4String error_msg = "Referenced isotope '" + ref + "' was not found!";
961     G4Exception("G4GDMLReadMaterials::GetIsoto << 588      G4Exception("G4GDMLReadMaterials::GetIsotope()", "InvalidRead",
962                 FatalException, error_msg);    << 589                  FatalException, error_msg);
963   }                                            << 590    }
964                                                   591 
965   return isotopePtr;                           << 592    return isotopePtr;
966 }                                                 593 }
967                                                   594 
968 // ------------------------------------------- << 
969 G4Material* G4GDMLReadMaterials::GetMaterial(c    595 G4Material* G4GDMLReadMaterials::GetMaterial(const G4String& ref,
970                                              G    596                                              G4bool verbose) const
971 {                                                 597 {
972   G4Material* materialPtr = G4Material::GetMat << 598    G4Material *materialPtr = G4Material::GetMaterial(ref,false);
973                                                   599 
974   if(materialPtr == nullptr)                   << 600    if (!materialPtr)
975   {                                            << 601    {
976     materialPtr = G4NistManager::Instance()->F << 602      materialPtr = G4NistManager::Instance()->FindOrBuildMaterial(ref);
977   }                                            << 603    }
978                                                << 604 
979   if(verbose && materialPtr == nullptr)        << 605    if (verbose && !materialPtr)
980   {                                            << 606    {
981     G4String error_msg = "Referenced material  << 607      G4String error_msg = "Referenced material '" + ref + "' was not found!";
982     G4Exception("G4GDMLReadMaterials::GetMater << 608      G4Exception("G4GDMLReadMaterials::GetMaterial()", "InvalidRead",
983                 FatalException, error_msg);    << 609                  FatalException, error_msg);
984   }                                            << 610    }
985                                                   611 
986   return materialPtr;                          << 612    return materialPtr;
987 }                                                 613 }
988                                                   614