ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GDMLReadParamvol.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4GDMLReadParamvol.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // class G4GDMLReadParamvol Implementation
28 //
29 // History:
30 // - Created. Zoltan Torzsok, November 2007
31 // -------------------------------------------------------------------------
32 
33 #include "G4GDMLReadParamvol.hh"
34 #include "G4GDMLReadSolids.hh"
35 #include "G4LogicalVolume.hh"
36 #include "G4PVParameterised.hh"
37 #include "G4PVPlacement.hh"
38 #include "G4VPhysicalVolume.hh"
39 #include "G4UnitsTable.hh"
40 
42  : G4GDMLReadSetup(), parameterisation(0)
43 {
44 }
45 
47 {
48 }
49 
51 Box_dimensionsRead( const xercesc::DOMElement* const element,
53 {
54  G4double lunit = 1.0;
55 
56  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
57  XMLSize_t attributeCount = attributes->getLength();
58 
59  for (XMLSize_t attribute_index=0;
60  attribute_index<attributeCount; attribute_index++)
61  {
62  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
63 
64  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
65  { continue; }
66 
67  const xercesc::DOMAttr* const attribute
68  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
69  if (!attribute)
70  {
71  G4Exception("G4GDMLReadParamvol::Box_dimensionsRead()",
72  "InvalidRead", FatalException, "No attribute found!");
73  return;
74  }
75  const G4String attName = Transcode(attribute->getName());
76  const G4String attValue = Transcode(attribute->getValue());
77 
78  if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue);
79  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
80  G4Exception("G4GDMLReadParamvol::Box_dimensionsRead()", "InvalidRead",
81  FatalException, "Invalid unit for length!"); }
82  } else
83  if (attName=="x") { parameter.dimension[0] = eval.Evaluate(attValue); } else
84  if (attName=="y") { parameter.dimension[1] = eval.Evaluate(attValue); } else
85  if (attName=="z") { parameter.dimension[2] = eval.Evaluate(attValue); }
86  }
87 
88  parameter.dimension[0] *= 0.5*lunit;
89  parameter.dimension[1] *= 0.5*lunit;
90  parameter.dimension[2] *= 0.5*lunit;
91 }
92 
94 Trd_dimensionsRead( const xercesc::DOMElement* const element,
96 {
97  G4double lunit = 1.0;
98 
99  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
100  XMLSize_t attributeCount = attributes->getLength();
101 
102  for (XMLSize_t attribute_index=0;
103  attribute_index<attributeCount; attribute_index++)
104  {
105  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
106 
107  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
108  { continue; }
109 
110  const xercesc::DOMAttr* const attribute
111  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
112  if (!attribute)
113  {
114  G4Exception("G4GDMLReadParamvol::Trd_dimensionsRead()",
115  "InvalidRead", FatalException, "No attribute found!");
116  return;
117  }
118  const G4String attName = Transcode(attribute->getName());
119  const G4String attValue = Transcode(attribute->getValue());
120 
121  if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue);
122  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
123  G4Exception("G4GDMLReadParamvol::Trd_dimensionsRead()", "InvalidRead",
124  FatalException, "Invalid unit for length!"); }
125  } else
126  if (attName=="x1") { parameter.dimension[0]=eval.Evaluate(attValue); } else
127  if (attName=="x2") { parameter.dimension[1]=eval.Evaluate(attValue); } else
128  if (attName=="y1") { parameter.dimension[2]=eval.Evaluate(attValue); } else
129  if (attName=="y2") { parameter.dimension[3]=eval.Evaluate(attValue); } else
130  if (attName=="z") { parameter.dimension[4]=eval.Evaluate(attValue); }
131  }
132 
133  parameter.dimension[0] *= 0.5*lunit;
134  parameter.dimension[1] *= 0.5*lunit;
135  parameter.dimension[2] *= 0.5*lunit;
136  parameter.dimension[3] *= 0.5*lunit;
137  parameter.dimension[4] *= 0.5*lunit;
138 }
139 
141 Trap_dimensionsRead( const xercesc::DOMElement* const element,
143 {
144  G4double lunit = 1.0;
145  G4double aunit = 1.0;
146 
147  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
148  XMLSize_t attributeCount = attributes->getLength();
149 
150  for (XMLSize_t attribute_index=0;
151  attribute_index<attributeCount; attribute_index++)
152  {
153  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
154 
155  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
156  { continue; }
157 
158  const xercesc::DOMAttr* const attribute
159  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
160  if (!attribute)
161  {
162  G4Exception("G4GDMLReadParamvol::Trap_dimensionsRead()",
163  "InvalidRead", FatalException, "No attribute found!");
164  return;
165  }
166  const G4String attName = Transcode(attribute->getName());
167  const G4String attValue = Transcode(attribute->getValue());
168 
169  if (attName=="lunit")
170  { lunit = G4UnitDefinition::GetValueOf(attValue);
171  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
172  G4Exception("G4GDMLReadParamvol::Trap_dimensionsRead()", "InvalidRead",
173  FatalException, "Invalid unit for length!"); }
174  } else
175  if (attName=="aunit")
176  { aunit = G4UnitDefinition::GetValueOf(attValue);
177  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
178  G4Exception("G4GDMLReadParamvol::Trap_dimensionsRead()", "InvalidRead",
179  FatalException, "Invalid unit for angle!"); }
180  } else
181  if (attName=="z")
182  { parameter.dimension[0] = eval.Evaluate(attValue); } else
183  if (attName=="theta")
184  { parameter.dimension[1] = eval.Evaluate(attValue); } else
185  if (attName=="phi")
186  { parameter.dimension[2] = eval.Evaluate(attValue); } else
187  if (attName=="y1")
188  { parameter.dimension[3] = eval.Evaluate(attValue); } else
189  if (attName=="x1")
190  { parameter.dimension[4] = eval.Evaluate(attValue); } else
191  if (attName=="x2")
192  { parameter.dimension[5] = eval.Evaluate(attValue); } else
193  if (attName=="alpha1")
194  { parameter.dimension[6] = eval.Evaluate(attValue); } else
195  if (attName=="y2")
196  { parameter.dimension[7] = eval.Evaluate(attValue); } else
197  if (attName=="x3")
198  { parameter.dimension[8] = eval.Evaluate(attValue); } else
199  if (attName=="x4")
200  { parameter.dimension[9] = eval.Evaluate(attValue); } else
201  if (attName=="alpha2")
202  { parameter.dimension[10] = eval.Evaluate(attValue); }
203  }
204 
205  parameter.dimension[0] *= 0.5*lunit;
206  parameter.dimension[1] *= aunit;
207  parameter.dimension[2] *= aunit;
208  parameter.dimension[3] *= 0.5*lunit;
209  parameter.dimension[4] *= 0.5*lunit;
210  parameter.dimension[5] *= 0.5*lunit;
211  parameter.dimension[6] *= aunit;
212  parameter.dimension[7] *= 0.5*lunit;
213  parameter.dimension[8] *= 0.5*lunit;
214  parameter.dimension[9] *= 0.5*lunit;
215  parameter.dimension[10] *= aunit;
216 }
217 
219 Tube_dimensionsRead( const xercesc::DOMElement* const element,
221 {
222  G4double lunit = 1.0;
223  G4double aunit = 1.0;
224 
225  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
226  XMLSize_t attributeCount = attributes->getLength();
227 
228  for (XMLSize_t attribute_index=0;
229  attribute_index<attributeCount; attribute_index++)
230  {
231  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
232 
233  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
234  { continue; }
235 
236  const xercesc::DOMAttr* const attribute
237  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
238  if (!attribute)
239  {
240  G4Exception("G4GDMLReadParamvol::Tube_dimensionsRead()",
241  "InvalidRead", FatalException, "No attribute found!");
242  return;
243  }
244  const G4String attName = Transcode(attribute->getName());
245  const G4String attValue = Transcode(attribute->getValue());
246 
247  if (attName=="lunit")
248  { lunit = G4UnitDefinition::GetValueOf(attValue);
249  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
250  G4Exception("G4GDMLReadParamvol::Tube_dimensionsRead()", "InvalidRead",
251  FatalException, "Invalid unit for length!"); }
252  } else
253  if (attName=="aunit")
254  { aunit = G4UnitDefinition::GetValueOf(attValue);
255  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
256  G4Exception("G4GDMLReadParamvol::Tube_dimensionsRead()", "InvalidRead",
257  FatalException, "Invalid unit for angle!"); }
258  } else
259  if (attName=="InR")
260  { parameter.dimension[0] = eval.Evaluate(attValue); } else
261  if (attName=="OutR")
262  { parameter.dimension[1] = eval.Evaluate(attValue); } else
263  if (attName=="hz")
264  { parameter.dimension[2] = eval.Evaluate(attValue); } else
265  if (attName=="StartPhi")
266  { parameter.dimension[3] = eval.Evaluate(attValue); } else
267  if (attName=="DeltaPhi")
268  { parameter.dimension[4] = eval.Evaluate(attValue); }
269  }
270 
271  parameter.dimension[0] *= lunit;
272  parameter.dimension[1] *= lunit;
273  parameter.dimension[2] *= 0.5*lunit;
274  parameter.dimension[3] *= aunit;
275  parameter.dimension[4] *= aunit;
276 }
277 
279 Cone_dimensionsRead( const xercesc::DOMElement* const element,
281 {
282  G4double lunit = 1.0;
283  G4double aunit = 1.0;
284 
285  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
286  XMLSize_t attributeCount = attributes->getLength();
287 
288  for (XMLSize_t attribute_index=0;
289  attribute_index<attributeCount; attribute_index++)
290  {
291  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
292 
293  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
294  { continue; }
295 
296  const xercesc::DOMAttr* const attribute
297  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
298  if (!attribute)
299  {
300  G4Exception("G4GDMLReadParamvol::Cone_dimensionsRead()",
301  "InvalidRead", FatalException, "No attribute found!");
302  return;
303  }
304  const G4String attName = Transcode(attribute->getName());
305  const G4String attValue = Transcode(attribute->getValue());
306 
307  if (attName=="lunit")
308  { lunit = G4UnitDefinition::GetValueOf(attValue);
309  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
310  G4Exception("G4GDMLReadParamvol::Cone_dimensionsRead()", "InvalidRead",
311  FatalException, "Invalid unit for length!"); }
312  } else
313  if (attName=="aunit")
314  { aunit = G4UnitDefinition::GetValueOf(attValue);
315  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
316  G4Exception("G4GDMLReadParamvol::Cone_dimensions()", "InvalidRead",
317  FatalException, "Invalid unit for angle!"); }
318  } else
319  if (attName=="rmin1")
320  { parameter.dimension[0] = eval.Evaluate(attValue); } else
321  if (attName=="rmax1")
322  { parameter.dimension[1] = eval.Evaluate(attValue); } else
323  if (attName=="rmin2")
324  { parameter.dimension[2] = eval.Evaluate(attValue); } else
325  if (attName=="rmax2")
326  { parameter.dimension[3] = eval.Evaluate(attValue); } else
327  if (attName=="z")
328  { parameter.dimension[4] = eval.Evaluate(attValue); } else
329  if (attName=="startphi")
330  { parameter.dimension[5] = eval.Evaluate(attValue); } else
331  if (attName=="deltaphi")
332  { parameter.dimension[6] = eval.Evaluate(attValue); }
333  }
334 
335  parameter.dimension[0] *= lunit;
336  parameter.dimension[1] *= lunit;
337  parameter.dimension[2] *= lunit;
338  parameter.dimension[3] *= lunit;
339  parameter.dimension[4] *= 0.5*lunit;
340  parameter.dimension[5] *= aunit;
341  parameter.dimension[6] *= aunit;
342 }
343 
345 Sphere_dimensionsRead( const xercesc::DOMElement* const element,
347 {
348  G4double lunit = 1.0;
349  G4double aunit = 1.0;
350 
351  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
352  XMLSize_t attributeCount = attributes->getLength();
353 
354  for (XMLSize_t attribute_index=0;
355  attribute_index<attributeCount; attribute_index++)
356  {
357  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
358 
359  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
360  { continue; }
361 
362  const xercesc::DOMAttr* const attribute
363  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
364  if (!attribute)
365  {
366  G4Exception("G4GDMLReadParamvol::Sphere_dimensionsRead()",
367  "InvalidRead", FatalException, "No attribute found!");
368  return;
369  }
370  const G4String attName = Transcode(attribute->getName());
371  const G4String attValue = Transcode(attribute->getValue());
372 
373  if (attName=="lunit")
374  { lunit = G4UnitDefinition::GetValueOf(attValue);
375  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
376  G4Exception("G4GDMLReadParamvol::Sphere_dimensionsRead()", "InvalidRead",
377  FatalException, "Invalid unit for length!"); }
378  } else
379  if (attName=="aunit")
380  { aunit = G4UnitDefinition::GetValueOf(attValue);
381  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
382  G4Exception("G4GDMLReadParamvol::Sphere_dimensionsRead()", "InvalidRead",
383  FatalException, "Invalid unit for angle!"); }
384  } else
385  if (attName=="rmin")
386  { parameter.dimension[0] = eval.Evaluate(attValue); } else
387  if (attName=="rmax")
388  { parameter.dimension[1] = eval.Evaluate(attValue); } else
389  if (attName=="startphi")
390  { parameter.dimension[2] = eval.Evaluate(attValue); } else
391  if (attName=="deltaphi")
392  { parameter.dimension[3] = eval.Evaluate(attValue); } else
393  if (attName=="starttheta")
394  { parameter.dimension[4] = eval.Evaluate(attValue); } else
395  if (attName=="deltatheta")
396  { parameter.dimension[5] = eval.Evaluate(attValue); }
397  }
398 
399  parameter.dimension[0] *= lunit;
400  parameter.dimension[1] *= lunit;
401  parameter.dimension[2] *= aunit;
402  parameter.dimension[3] *= aunit;
403  parameter.dimension[4] *= aunit;
404  parameter.dimension[5] *= aunit;
405 }
406 
408 Orb_dimensionsRead( const xercesc::DOMElement* const element,
410 {
411  G4double lunit = 1.0;
412 
413  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
414  XMLSize_t attributeCount = attributes->getLength();
415 
416  for (XMLSize_t attribute_index=0;
417  attribute_index<attributeCount; attribute_index++)
418  {
419  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
420 
421  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
422  { continue; }
423 
424  const xercesc::DOMAttr* const attribute
425  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
426  if (!attribute)
427  {
428  G4Exception("G4GDMLReadParamvol::Orb_dimensionsRead()",
429  "InvalidRead", FatalException, "No attribute found!");
430  return;
431  }
432  const G4String attName = Transcode(attribute->getName());
433  const G4String attValue = Transcode(attribute->getValue());
434 
435  if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); }
436  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
437  G4Exception("G4GDMLReadParamvol::Orb_dimensionsRead()", "InvalidRead",
438  FatalException, "Invalid unit for length!"); }
439  else
440  if (attName=="r") { parameter.dimension[0] = eval.Evaluate(attValue); }
441  }
442 
443  parameter.dimension[0] *= lunit;
444 }
445 
447 Torus_dimensionsRead( const xercesc::DOMElement* const element,
449 {
450  G4double lunit = 1.0;
451  G4double aunit = 1.0;
452 
453  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
454  XMLSize_t attributeCount = attributes->getLength();
455 
456  for (XMLSize_t attribute_index=0;
457  attribute_index<attributeCount; attribute_index++)
458  {
459  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
460 
461  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
462  { continue; }
463 
464  const xercesc::DOMAttr* const attribute
465  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
466  if (!attribute)
467  {
468  G4Exception("G4GDMLReadParamvol::Torus_dimensionsRead()",
469  "InvalidRead", FatalException, "No attribute found!");
470  return;
471  }
472  const G4String attName = Transcode(attribute->getName());
473  const G4String attValue = Transcode(attribute->getValue());
474 
475  if (attName=="lunit")
476  { lunit = G4UnitDefinition::GetValueOf(attValue);
477  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
478  G4Exception("G4GDMLReadParamvol::Torus_dimensionsRead()", "InvalidRead",
479  FatalException, "Invalid unit for length!"); }
480  } else
481  if (attName=="aunit")
482  { aunit = G4UnitDefinition::GetValueOf(attValue);
483  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
484  G4Exception("G4GDMLReadParamvol::Torus_dimensionsRead()", "InvalidRead",
485  FatalException, "Invalid unit for angle!"); }
486  } else
487  if (attName=="rmin")
488  { parameter.dimension[0] = eval.Evaluate(attValue); } else
489  if (attName=="rmax")
490  { parameter.dimension[1] = eval.Evaluate(attValue); } else
491  if (attName=="rtor")
492  { parameter.dimension[2] = eval.Evaluate(attValue); } else
493  if (attName=="startphi")
494  { parameter.dimension[3] = eval.Evaluate(attValue); } else
495  if (attName=="deltaphi")
496  { parameter.dimension[4] = eval.Evaluate(attValue); }
497  }
498 
499  parameter.dimension[0] *= lunit;
500  parameter.dimension[1] *= lunit;
501  parameter.dimension[2] *= lunit;
502  parameter.dimension[3] *= aunit;
503  parameter.dimension[4] *= aunit;
504 }
505 
507 Ellipsoid_dimensionsRead( const xercesc::DOMElement* const element,
509 {
510  G4double lunit = 1.0;
511  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
512  XMLSize_t attributeCount = attributes->getLength();
513 
514  for (XMLSize_t attribute_index=0;
515  attribute_index<attributeCount; attribute_index++)
516  {
517  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
518 
519  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
520  { continue; }
521 
522  const xercesc::DOMAttr* const attribute
523  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
524  if (!attribute)
525  {
526  G4Exception("G4GDMLReadParamvol::Ellipsoid_dimensionsRead()",
527  "InvalidRead", FatalException, "No attribute found!");
528  return;
529  }
530  const G4String attName = Transcode(attribute->getName());
531  const G4String attValue = Transcode(attribute->getValue());
532 
533  if (attName=="lunit")
534  { lunit = G4UnitDefinition::GetValueOf(attValue);
535  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
536  G4Exception("G4GDMLReadParamvol::Ellipsoid_dimensionsRead()", "InvalidRead",
537  FatalException, "Invalid unit for length!"); }
538  } else
539  if (attName=="ax")
540  { parameter.dimension[0] = eval.Evaluate(attValue); } else
541  if (attName=="by")
542  { parameter.dimension[1] = eval.Evaluate(attValue); } else
543  if (attName=="cz")
544  { parameter.dimension[2] = eval.Evaluate(attValue); } else
545  if (attName=="zcut1")
546  { parameter.dimension[3] = eval.Evaluate(attValue); } else
547  if (attName=="zcut2")
548  { parameter.dimension[4] = eval.Evaluate(attValue); }
549  }
550 
551  parameter.dimension[0] *= lunit;
552  parameter.dimension[1] *= lunit;
553  parameter.dimension[2] *= lunit;
554  parameter.dimension[3] *= lunit;
555  parameter.dimension[4] *= lunit;
556 }
557 
559 Para_dimensionsRead( const xercesc::DOMElement* const element,
561 {
562  G4double lunit = 1.0;
563  G4double aunit = 1.0;
564 
565  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
566  XMLSize_t attributeCount = attributes->getLength();
567 
568  for (XMLSize_t attribute_index=0;
569  attribute_index<attributeCount; attribute_index++)
570  {
571  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
572 
573  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
574  { continue; }
575 
576  const xercesc::DOMAttr* const attribute
577  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
578  if (!attribute)
579  {
580  G4Exception("G4GDMLReadParamvol::Para_dimensionsRead()",
581  "InvalidRead", FatalException, "No attribute found!");
582  return;
583  }
584  const G4String attName = Transcode(attribute->getName());
585  const G4String attValue = Transcode(attribute->getValue());
586 
587  if (attName=="lunit")
588  { lunit = G4UnitDefinition::GetValueOf(attValue);
589  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
590  G4Exception("G4GDMLReadParamvol::Para_dimensionsRead()", "InvalidRead",
591  FatalException, "Invalid unit for length!"); }
592  } else
593  if (attName=="aunit")
594  { aunit = G4UnitDefinition::GetValueOf(attValue);
595  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
596  G4Exception("G4GDMLReadParamvol::Para_dimensionsRead()", "InvalidRead",
597  FatalException, "Invalid unit for angle!"); }
598  } else
599  if (attName=="x")
600  { parameter.dimension[0] = eval.Evaluate(attValue); } else
601  if (attName=="y")
602  { parameter.dimension[1] = eval.Evaluate(attValue); } else
603  if (attName=="z")
604  { parameter.dimension[2] = eval.Evaluate(attValue); } else
605  if (attName=="alpha")
606  { parameter.dimension[3] = eval.Evaluate(attValue); } else
607  if (attName=="theta")
608  { parameter.dimension[4] = eval.Evaluate(attValue); } else
609  if (attName=="phi")
610  { parameter.dimension[5] = eval.Evaluate(attValue); }
611  }
612 
613  parameter.dimension[0] = 0.5*lunit;
614  parameter.dimension[1] = 0.5*lunit;
615  parameter.dimension[2] = 0.5*lunit;
616  parameter.dimension[3] = aunit;
617  parameter.dimension[4] = aunit;
618  parameter.dimension[5] = aunit;
619 }
620 
622 Hype_dimensionsRead( const xercesc::DOMElement* const element,
624 {
625  G4double lunit = 1.0;
626  G4double aunit = 1.0;
627 
628  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
629  XMLSize_t attributeCount = attributes->getLength();
630 
631  for (XMLSize_t attribute_index=0;
632  attribute_index<attributeCount; attribute_index++)
633  {
634  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
635 
636  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
637  { continue; }
638 
639  const xercesc::DOMAttr* const attribute
640  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
641  if (!attribute)
642  {
643  G4Exception("G4GDMLReadParamvol::Hype_dimensionsRead()",
644  "InvalidRead", FatalException, "No attribute found!");
645  return;
646  }
647  const G4String attName = Transcode(attribute->getName());
648  const G4String attValue = Transcode(attribute->getValue());
649 
650  if (attName=="lunit")
651  { lunit = G4UnitDefinition::GetValueOf(attValue);
652  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
653  G4Exception("G4GDMLReadParamvol::Hype_dimensionsRead()", "InvalidRead",
654  FatalException, "Invalid unit for length!"); }
655  } else
656  if (attName=="aunit")
657  { aunit = G4UnitDefinition::GetValueOf(attValue);
658  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
659  G4Exception("G4GDMLReadParamvol::Hype_dimensionsRead()", "InvalidRead",
660  FatalException, "Invalid unit for angle!"); }
661  } else
662  if (attName=="rmin")
663  { parameter.dimension[0] = eval.Evaluate(attValue); } else
664  if (attName=="rmax")
665  { parameter.dimension[1] = eval.Evaluate(attValue); } else
666  if (attName=="inst")
667  { parameter.dimension[2] = eval.Evaluate(attValue); } else
668  if (attName=="outst")
669  { parameter.dimension[3] = eval.Evaluate(attValue); } else
670  if (attName=="z")
671  { parameter.dimension[4] = eval.Evaluate(attValue); }
672  }
673 
674  parameter.dimension[0] = lunit;
675  parameter.dimension[1] = lunit;
676  parameter.dimension[2] = aunit;
677  parameter.dimension[3] = aunit;
678  parameter.dimension[4] = 0.5*lunit;
679 }
680 
682 Polycone_dimensionsRead( const xercesc::DOMElement* const element,
684 {
685  G4double lunit = 1.0;
686  G4double aunit = 1.0;
687 
688  std::vector<zplaneType> zplaneList;
689 
690  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
691  XMLSize_t attributeCount = attributes->getLength();
692 
693  for (XMLSize_t attribute_index=0;
694  attribute_index<attributeCount; attribute_index++)
695  {
696  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
697 
698  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
699  { continue; }
700 
701  const xercesc::DOMAttr* const attribute
702  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
703  if (!attribute)
704  {
705  G4Exception("G4GDMLReadParamvol::Polycone_dimensionsRead()",
706  "InvalidRead", FatalException, "No attribute found!");
707  return;
708  }
709  const G4String attName = Transcode(attribute->getName());
710  const G4String attValue = Transcode(attribute->getValue());
711 
712  if (attName=="lunit")
713  { lunit = G4UnitDefinition::GetValueOf(attValue);
714  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
715  G4Exception("G4GDMLReadParamvol::Polycone_dimensionsRead()", "InvalidRead",
716  FatalException, "Invalid unit for length!"); }
717  } else
718  if (attName=="aunit")
719  { aunit = G4UnitDefinition::GetValueOf(attValue);
720  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
721  G4Exception("G4GDMLReadParamvol::Polycone_dimensionsRead()", "InvalidRead",
722  FatalException, "Invalid unit for angle!"); }
723  } else
724  if (attName=="startPhi")
725  { parameter.dimension[0] = eval.Evaluate(attValue); } else
726  if (attName=="openPhi")
727  { parameter.dimension[1] = eval.Evaluate(attValue); } else
728  if (attName=="numRZ")
729  { parameter.dimension[2] = eval.Evaluate(attValue); }
730  }
731 
732  parameter.dimension[0] *= aunit;
733  parameter.dimension[1] *= aunit;
734 
735  for (xercesc::DOMNode* iter = element->getFirstChild();
736  iter != 0; iter = iter->getNextSibling())
737  {
738  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
739 
740  const xercesc::DOMElement* const child
741  = dynamic_cast<xercesc::DOMElement*>(iter);
742  if (!child)
743  {
744  G4Exception("G4GDMLReadParamVol::Polycone_dimensionsRead()",
745  "InvalidRead", FatalException, "No child found!");
746  return;
747  }
748  const G4String tag = Transcode(child->getTagName());
749 
750  if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); }
751  }
752 
753  G4int numZPlanes = zplaneList.size();
754  for (G4int i=0; i<numZPlanes; i++)
755  {
756  parameter.dimension[3+i*3] = zplaneList[i].rmin*lunit;
757  parameter.dimension[4+i*3] = zplaneList[i].rmax*lunit;
758  parameter.dimension[5+i*3] = zplaneList[i].z*lunit;
759  }
760 }
761 
763 Polyhedra_dimensionsRead( const xercesc::DOMElement* const element,
765 {
766  G4double lunit = 1.0;
767  G4double aunit = 1.0;
768 
769  std::vector<zplaneType> zplaneList;
770 
771  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
772  XMLSize_t attributeCount = attributes->getLength();
773 
774  for (XMLSize_t attribute_index=0;
775  attribute_index<attributeCount; attribute_index++)
776  {
777  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
778 
779  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
780  { continue; }
781 
782  const xercesc::DOMAttr* const attribute
783  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
784  if (!attribute)
785  {
786  G4Exception("G4GDMLReadParamvol::Polycone_dimensionsRead()",
787  "InvalidRead", FatalException, "No attribute found!");
788  return;
789  }
790  const G4String attName = Transcode(attribute->getName());
791  const G4String attValue = Transcode(attribute->getValue());
792 
793  if (attName=="lunit")
794  { lunit = G4UnitDefinition::GetValueOf(attValue);
795  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
796  G4Exception("G4GDMLReadParamvol::Polyhedra_dimensionsRead()", "InvalidRead",
797  FatalException, "Invalid unit for length!"); }
798  } else
799  if (attName=="aunit")
800  { aunit = G4UnitDefinition::GetValueOf(attValue);
801  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
802  G4Exception("G4GDMLReadParamvol::Polyhedra_dimensionsRead()", "InvalidRead",
803  FatalException, "Invalid unit for angle!"); }
804  } else
805  if (attName=="startPhi")
806  { parameter.dimension[0] = eval.Evaluate(attValue); } else
807  if (attName=="openPhi")
808  { parameter.dimension[1] = eval.Evaluate(attValue); } else
809  if (attName=="numRZ")
810  { parameter.dimension[2] = eval.Evaluate(attValue); } else
811  if (attName=="numSide")
812  { parameter.dimension[3] = eval.Evaluate(attValue); }
813  }
814 
815  parameter.dimension[0] *= aunit;
816  parameter.dimension[1] *= aunit;
817 
818  for (xercesc::DOMNode* iter = element->getFirstChild();
819  iter != 0; iter = iter->getNextSibling())
820  {
821  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
822 
823  const xercesc::DOMElement* const child
824  = dynamic_cast<xercesc::DOMElement*>(iter);
825  if (!child)
826  {
827  G4Exception("G4GDMLReadParamvo::PolyhedraRead()",
828  "InvalidRead", FatalException, "No child found!");
829  return;
830  }
831  const G4String tag = Transcode(child->getTagName());
832 
833  if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); }
834  }
835 
836  G4int numZPlanes = zplaneList.size();
837  for (G4int i=0; i<numZPlanes; i++)
838  {
839  parameter.dimension[4+i*3] = zplaneList[i].rmin*lunit;
840  parameter.dimension[5+i*3] = zplaneList[i].rmax*lunit;
841  parameter.dimension[6+i*3] = zplaneList[i].z*lunit;
842  }
843 }
844 
846 ParametersRead(const xercesc::DOMElement* const element)
847 {
848  G4ThreeVector rotation(0.0,0.0,0.0);
849  G4ThreeVector position(0.0,0.0,0.0);
850 
852 
853  for (xercesc::DOMNode* iter = element->getFirstChild();
854  iter != 0; iter = iter->getNextSibling())
855  {
856  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
857 
858  const xercesc::DOMElement* const child
859  = dynamic_cast<xercesc::DOMElement*>(iter);
860  if (!child)
861  {
862  G4Exception("G4GDMLReadParamvol::ParametersRead()",
863  "InvalidRead", FatalException, "No child found!");
864  return;
865  }
866  const G4String tag = Transcode(child->getTagName());
867  if (tag=="rotation") { VectorRead(child,rotation); } else
868  if (tag=="position") { VectorRead(child,position); } else
869  if (tag=="positionref")
870  { position = GetPosition(GenerateName(RefRead(child))); } else
871  if (tag=="rotationref")
872  { rotation = GetRotation(GenerateName(RefRead(child))); } else
873  if (tag=="box_dimensions") { Box_dimensionsRead(child,parameter); } else
874  if (tag=="trd_dimensions") { Trd_dimensionsRead(child,parameter); } else
875  if (tag=="trap_dimensions") { Trap_dimensionsRead(child,parameter); } else
876  if (tag=="tube_dimensions") { Tube_dimensionsRead(child,parameter); } else
877  if (tag=="cone_dimensions") { Cone_dimensionsRead(child,parameter); } else
878  if (tag=="sphere_dimensions") { Sphere_dimensionsRead(child,parameter); } else
879  if (tag=="orb_dimensions") { Orb_dimensionsRead(child,parameter); } else
880  if (tag=="torus_dimensions") { Torus_dimensionsRead(child,parameter); } else
881  if (tag=="ellipsoid_dimensions") { Ellipsoid_dimensionsRead(child,parameter); } else
882  if (tag=="para_dimensions") { Para_dimensionsRead(child,parameter); } else
883  if (tag=="polycone_dimensions") { Polycone_dimensionsRead(child,parameter); } else
884  if (tag=="polyhedra_dimensions") { Polyhedra_dimensionsRead(child,parameter); } else
885  if (tag=="hype_dimensions") { Hype_dimensionsRead(child,parameter); }
886  else
887  {
888  G4String error_msg = "Unknown tag in parameters: " + tag;
889  G4Exception("G4GDMLReadParamvol::ParametersRead()", "ReadError",
890  FatalException, error_msg);
891  }
892  }
893 
894  parameter.pRot = new G4RotationMatrix();
895 
896  parameter.pRot->rotateX(rotation.x());
897  parameter.pRot->rotateY(rotation.y());
898  parameter.pRot->rotateZ(rotation.z());
899 
900  parameter.position = position;
901 
902  parameterisation->AddParameter(parameter);
903 }
904 
906 ParameterisedRead(const xercesc::DOMElement* const element)
907 {
908  for (xercesc::DOMNode* iter = element->getFirstChild();
909  iter != 0; iter = iter->getNextSibling())
910  {
911  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
912 
913  const xercesc::DOMElement* const child
914  = dynamic_cast<xercesc::DOMElement*>(iter);
915  if (!child)
916  {
917  G4Exception("G4GDMLReadParamvol::ParameterisedRead()",
918  "InvalidRead", FatalException, "No child found!");
919  return;
920  }
921  const G4String tag = Transcode(child->getTagName());
922 
923  if (tag=="parameters")
924  {
925  const xercesc::DOMNamedNodeMap* const attributes
926  = element->getAttributes();
927  XMLSize_t attributeCount = attributes->getLength();
928  for (XMLSize_t attribute_index=0;
929  attribute_index<attributeCount; attribute_index++)
930  {
931  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
932 
933  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
934  { continue; }
935 
936  const xercesc::DOMAttr* const attribute
937  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
938  if (!attribute)
939  {
940  G4Exception("G4GDMLReadParamvol::ParameterisedRead()",
941  "InvalidRead", FatalException, "No attribute found!");
942  return;
943  }
944  const G4String attName = Transcode(attribute->getName());
945  const G4String attValue = Transcode(attribute->getValue());
946 
947  if (attName=="number") { eval.Evaluate(attValue); }
948  }
949  ParametersRead(child);
950  }
951  else
952  {
953  if (tag=="loop") { LoopRead(child,&G4GDMLRead::Paramvol_contentRead); }
954  }
955  }
956 }
957 
959 Paramvol_contentRead(const xercesc::DOMElement* const element)
960 {
961  for (xercesc::DOMNode* iter = element->getFirstChild();
962  iter != 0; iter = iter->getNextSibling())
963  {
964  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
965 
966  const xercesc::DOMElement* const child
967  = dynamic_cast<xercesc::DOMElement*>(iter);
968  if (!child)
969  {
970  G4Exception("G4GDMLReadParamvol::Paramvol_contentRead()", "InvalidRead",
971  FatalException, "No child found!");
972  return;
973  }
974  const G4String tag = Transcode(child->getTagName());
975  if (tag=="parameterised_position_size") { ParameterisedRead(child); }else
976  if (tag=="loop") { LoopRead(child,&G4GDMLRead::Paramvol_contentRead); }
977  }
978 }
979 
981 ParamvolRead(const xercesc::DOMElement* const element, G4LogicalVolume* mother)
982 {
983  G4String volumeref;
984 
986  for (xercesc::DOMNode* iter = element->getFirstChild();
987  iter != 0; iter = iter->getNextSibling())
988  {
989  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
990 
991  const xercesc::DOMElement* const child
992  = dynamic_cast<xercesc::DOMElement*>(iter);
993  if (!child)
994  {
995  G4Exception("G4GDMLReadParamvol::ParamvolRead()", "InvalidRead",
996  FatalException, "No child found!");
997  return;
998  }
999  const G4String tag = Transcode(child->getTagName());
1000 
1001  if (tag=="volumeref") { volumeref = RefRead(child); }
1002 
1003  }
1004 
1005  Paramvol_contentRead(element);
1006 
1007  G4LogicalVolume* logvol = GetVolume(GenerateName(volumeref));
1008 
1009  if (parameterisation->GetSize()==0)
1010  {
1011  G4Exception("G4GDMLReadParamvol::ParamvolRead()",
1012  "ReadError", FatalException,
1013  "No parameters are defined in parameterised volume!");
1014  }
1015  G4String pv_name = logvol->GetName() + "_param";
1016  new G4PVParameterised(pv_name, logvol, mother, kUndefined,
1018 }