Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/persistency/gdml/src/G4GDMLWriteParamvol.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 ]

  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 // G4GDMLParamVol implementation
 27 //
 28 // Author: Zoltan Torzsok, November 2007
 29 // --------------------------------------------------------------------
 30 
 31 #include "G4GDMLWriteParamvol.hh"
 32 #include "G4GDMLWriteSolids.hh"
 33 
 34 #include "G4SystemOfUnits.hh"
 35 #include "G4Box.hh"
 36 #include "G4Trd.hh"
 37 #include "G4Trap.hh"
 38 #include "G4Tubs.hh"
 39 #include "G4Cons.hh"
 40 #include "G4Sphere.hh"
 41 #include "G4Orb.hh"
 42 #include "G4Torus.hh"
 43 #include "G4Ellipsoid.hh"
 44 #include "G4Para.hh"
 45 #include "G4Hype.hh"
 46 #include "G4Polycone.hh"
 47 #include "G4Polyhedra.hh"
 48 #include "G4LogicalVolume.hh"
 49 #include "G4VPhysicalVolume.hh"
 50 #include "G4PVParameterised.hh"
 51 #include "G4VPVParameterisation.hh"
 52 
 53 // --------------------------------------------------------------------
 54 G4GDMLWriteParamvol::G4GDMLWriteParamvol()
 55   : G4GDMLWriteSetup()
 56 {
 57 }
 58 
 59 // --------------------------------------------------------------------
 60 G4GDMLWriteParamvol::~G4GDMLWriteParamvol()
 61 {
 62 }
 63 
 64 // --------------------------------------------------------------------
 65 void G4GDMLWriteParamvol::Box_dimensionsWrite(
 66   xercesc::DOMElement* parametersElement, const G4Box* const box)
 67 {
 68   xercesc::DOMElement* box_dimensionsElement = NewElement("box_dimensions");
 69   box_dimensionsElement->setAttributeNode(
 70     NewAttribute("x", 2.0 * box->GetXHalfLength() / mm));
 71   box_dimensionsElement->setAttributeNode(
 72     NewAttribute("y", 2.0 * box->GetYHalfLength() / mm));
 73   box_dimensionsElement->setAttributeNode(
 74     NewAttribute("z", 2.0 * box->GetZHalfLength() / mm));
 75   box_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
 76   parametersElement->appendChild(box_dimensionsElement);
 77 }
 78 
 79 // --------------------------------------------------------------------
 80 void G4GDMLWriteParamvol::Trd_dimensionsWrite(
 81   xercesc::DOMElement* parametersElement, const G4Trd* const trd)
 82 {
 83   xercesc::DOMElement* trd_dimensionsElement = NewElement("trd_dimensions");
 84   trd_dimensionsElement->setAttributeNode(
 85     NewAttribute("x1", 2.0 * trd->GetXHalfLength1() / mm));
 86   trd_dimensionsElement->setAttributeNode(
 87     NewAttribute("x2", 2.0 * trd->GetXHalfLength2() / mm));
 88   trd_dimensionsElement->setAttributeNode(
 89     NewAttribute("y1", 2.0 * trd->GetYHalfLength1() / mm));
 90   trd_dimensionsElement->setAttributeNode(
 91     NewAttribute("y2", 2.0 * trd->GetYHalfLength2() / mm));
 92   trd_dimensionsElement->setAttributeNode(
 93     NewAttribute("z", 2.0 * trd->GetZHalfLength() / mm));
 94   trd_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
 95   parametersElement->appendChild(trd_dimensionsElement);
 96 }
 97 
 98 // --------------------------------------------------------------------
 99 void G4GDMLWriteParamvol::Trap_dimensionsWrite(
100   xercesc::DOMElement* parametersElement, const G4Trap* const trap)
101 {
102   const G4ThreeVector simaxis = trap->GetSymAxis();
103   const G4double phi =
104     (simaxis.z() != 1.0) ? (std::atan(simaxis.y() / simaxis.x())) : (0.0);
105   const G4double theta  = std::acos(simaxis.z());
106   const G4double alpha1 = std::atan(trap->GetTanAlpha1());
107   const G4double alpha2 = std::atan(trap->GetTanAlpha2());
108 
109   xercesc::DOMElement* trap_dimensionsElement = NewElement("trap");
110   trap_dimensionsElement->setAttributeNode(
111     NewAttribute("z", 2.0 * trap->GetZHalfLength() / mm));
112   trap_dimensionsElement->setAttributeNode(
113     NewAttribute("theta", theta / degree));
114   trap_dimensionsElement->setAttributeNode(NewAttribute("phi", phi / degree));
115   trap_dimensionsElement->setAttributeNode(
116     NewAttribute("y1", 2.0 * trap->GetYHalfLength1() / mm));
117   trap_dimensionsElement->setAttributeNode(
118     NewAttribute("x1", 2.0 * trap->GetXHalfLength1() / mm));
119   trap_dimensionsElement->setAttributeNode(
120     NewAttribute("x2", 2.0 * trap->GetXHalfLength2() / mm));
121   trap_dimensionsElement->setAttributeNode(
122     NewAttribute("alpha1", alpha1 / degree));
123   trap_dimensionsElement->setAttributeNode(
124     NewAttribute("y2", 2.0 * trap->GetYHalfLength2() / mm));
125   trap_dimensionsElement->setAttributeNode(
126     NewAttribute("x3", 2.0 * trap->GetXHalfLength3() / mm));
127   trap_dimensionsElement->setAttributeNode(
128     NewAttribute("x4", 2.0 * trap->GetXHalfLength4() / mm));
129   trap_dimensionsElement->setAttributeNode(
130     NewAttribute("alpha2", alpha2 / degree));
131   trap_dimensionsElement->setAttributeNode(NewAttribute("aunit", "deg"));
132   trap_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
133   parametersElement->appendChild(trap_dimensionsElement);
134 }
135 
136 // --------------------------------------------------------------------
137 void G4GDMLWriteParamvol::Tube_dimensionsWrite(
138   xercesc::DOMElement* parametersElement, const G4Tubs* const tube)
139 {
140   xercesc::DOMElement* tube_dimensionsElement = NewElement("tube_dimensions");
141   tube_dimensionsElement->setAttributeNode(
142     NewAttribute("InR", tube->GetInnerRadius() / mm));
143   tube_dimensionsElement->setAttributeNode(
144     NewAttribute("OutR", tube->GetOuterRadius() / mm));
145   tube_dimensionsElement->setAttributeNode(
146     NewAttribute("hz", 2.0 * tube->GetZHalfLength() / mm));
147   tube_dimensionsElement->setAttributeNode(
148     NewAttribute("StartPhi", tube->GetStartPhiAngle() / degree));
149   tube_dimensionsElement->setAttributeNode(
150     NewAttribute("DeltaPhi", tube->GetDeltaPhiAngle() / degree));
151   tube_dimensionsElement->setAttributeNode(NewAttribute("aunit", "deg"));
152   tube_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
153   parametersElement->appendChild(tube_dimensionsElement);
154 }
155 
156 // --------------------------------------------------------------------
157 void G4GDMLWriteParamvol::Cone_dimensionsWrite(
158   xercesc::DOMElement* parametersElement, const G4Cons* const cone)
159 {
160   xercesc::DOMElement* cone_dimensionsElement = NewElement("cone_dimensions");
161   cone_dimensionsElement->setAttributeNode(
162     NewAttribute("rmin1", cone->GetInnerRadiusMinusZ() / mm));
163   cone_dimensionsElement->setAttributeNode(
164     NewAttribute("rmax1", cone->GetOuterRadiusMinusZ() / mm));
165   cone_dimensionsElement->setAttributeNode(
166     NewAttribute("rmin2", cone->GetInnerRadiusPlusZ() / mm));
167   cone_dimensionsElement->setAttributeNode(
168     NewAttribute("rmax2", cone->GetOuterRadiusPlusZ() / mm));
169   cone_dimensionsElement->setAttributeNode(
170     NewAttribute("z", 2.0 * cone->GetZHalfLength() / mm));
171   cone_dimensionsElement->setAttributeNode(
172     NewAttribute("startphi", cone->GetStartPhiAngle() / degree));
173   cone_dimensionsElement->setAttributeNode(
174     NewAttribute("deltaphi", cone->GetDeltaPhiAngle() / degree));
175   cone_dimensionsElement->setAttributeNode(NewAttribute("aunit", "deg"));
176   cone_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
177   parametersElement->appendChild(cone_dimensionsElement);
178 }
179 
180 // --------------------------------------------------------------------
181 void G4GDMLWriteParamvol::Sphere_dimensionsWrite(
182   xercesc::DOMElement* parametersElement, const G4Sphere* const sphere)
183 {
184   xercesc::DOMElement* sphere_dimensionsElement =
185     NewElement("sphere_dimensions");
186   sphere_dimensionsElement->setAttributeNode(
187     NewAttribute("rmin", sphere->GetInnerRadius() / mm));
188   sphere_dimensionsElement->setAttributeNode(
189     NewAttribute("rmax", sphere->GetOuterRadius() / mm));
190   sphere_dimensionsElement->setAttributeNode(
191     NewAttribute("startphi", sphere->GetStartPhiAngle() / degree));
192   sphere_dimensionsElement->setAttributeNode(
193     NewAttribute("deltaphi", sphere->GetDeltaPhiAngle() / degree));
194   sphere_dimensionsElement->setAttributeNode(
195     NewAttribute("starttheta", sphere->GetStartThetaAngle() / degree));
196   sphere_dimensionsElement->setAttributeNode(
197     NewAttribute("deltatheta", sphere->GetDeltaThetaAngle() / degree));
198   sphere_dimensionsElement->setAttributeNode(NewAttribute("aunit", "deg"));
199   sphere_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
200   parametersElement->appendChild(sphere_dimensionsElement);
201 }
202 
203 // --------------------------------------------------------------------
204 void G4GDMLWriteParamvol::Orb_dimensionsWrite(
205   xercesc::DOMElement* parametersElement, const G4Orb* const orb)
206 {
207   xercesc::DOMElement* orb_dimensionsElement = NewElement("orb_dimensions");
208   orb_dimensionsElement->setAttributeNode(
209     NewAttribute("r", orb->GetRadius() / mm));
210   orb_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
211   parametersElement->appendChild(orb_dimensionsElement);
212 }
213 
214 // --------------------------------------------------------------------
215 void G4GDMLWriteParamvol::Torus_dimensionsWrite(
216   xercesc::DOMElement* parametersElement, const G4Torus* const torus)
217 {
218   xercesc::DOMElement* torus_dimensionsElement = NewElement("torus_dimensions");
219   torus_dimensionsElement->setAttributeNode(
220     NewAttribute("rmin", torus->GetRmin() / mm));
221   torus_dimensionsElement->setAttributeNode(
222     NewAttribute("rmax", torus->GetRmax() / mm));
223   torus_dimensionsElement->setAttributeNode(
224     NewAttribute("rtor", torus->GetRtor() / mm));
225   torus_dimensionsElement->setAttributeNode(
226     NewAttribute("startphi", torus->GetSPhi() / degree));
227   torus_dimensionsElement->setAttributeNode(
228     NewAttribute("deltaphi", torus->GetDPhi() / degree));
229   torus_dimensionsElement->setAttributeNode(NewAttribute("aunit", "deg"));
230   torus_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
231   parametersElement->appendChild(torus_dimensionsElement);
232 }
233 
234 // --------------------------------------------------------------------
235 void G4GDMLWriteParamvol::Ellipsoid_dimensionsWrite(
236   xercesc::DOMElement* parametersElement, const G4Ellipsoid* const ellipsoid)
237 {
238   xercesc::DOMElement* ellipsoid_dimensionsElement =
239     NewElement("ellipsoid_dimensions");
240   ellipsoid_dimensionsElement->setAttributeNode(
241     NewAttribute("ax", ellipsoid->GetSemiAxisMax(0) / mm));
242   ellipsoid_dimensionsElement->setAttributeNode(
243     NewAttribute("by", ellipsoid->GetSemiAxisMax(1) / mm));
244   ellipsoid_dimensionsElement->setAttributeNode(
245     NewAttribute("cz", ellipsoid->GetSemiAxisMax(2) / mm));
246   ellipsoid_dimensionsElement->setAttributeNode(
247     NewAttribute("zcut1", ellipsoid->GetZBottomCut() / mm));
248   ellipsoid_dimensionsElement->setAttributeNode(
249     NewAttribute("zcut2", ellipsoid->GetZTopCut() / mm));
250   ellipsoid_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
251   parametersElement->appendChild(ellipsoid_dimensionsElement);
252 }
253 
254 // --------------------------------------------------------------------
255 void G4GDMLWriteParamvol::Para_dimensionsWrite(
256   xercesc::DOMElement* parametersElement, const G4Para* const para)
257 {
258   const G4ThreeVector simaxis = para->GetSymAxis();
259 
260   const G4double alpha = std::atan(para->GetTanAlpha());
261   const G4double theta = std::acos(simaxis.z());
262   const G4double phi =
263     (simaxis.z() != 1.0) ? (std::atan(simaxis.y() / simaxis.x())) : (0.0);
264 
265   xercesc::DOMElement* para_dimensionsElement = NewElement("para_dimensions");
266   para_dimensionsElement->setAttributeNode(
267     NewAttribute("x", 2.0 * para->GetXHalfLength() / mm));
268   para_dimensionsElement->setAttributeNode(
269     NewAttribute("y", 2.0 * para->GetYHalfLength() / mm));
270   para_dimensionsElement->setAttributeNode(
271     NewAttribute("z", 2.0 * para->GetZHalfLength() / mm));
272   para_dimensionsElement->setAttributeNode(
273     NewAttribute("alpha", alpha / degree));
274   para_dimensionsElement->setAttributeNode(
275     NewAttribute("theta", theta / degree));
276   para_dimensionsElement->setAttributeNode(NewAttribute("phi", phi / degree));
277   para_dimensionsElement->setAttributeNode(NewAttribute("aunit", "deg"));
278   para_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
279   parametersElement->appendChild(para_dimensionsElement);
280 }
281 
282 // --------------------------------------------------------------------
283 void G4GDMLWriteParamvol::Hype_dimensionsWrite(
284   xercesc::DOMElement* parametersElement, const G4Hype* const hype)
285 {
286   xercesc::DOMElement* hype_dimensionsElement = NewElement("hype_dimensions");
287   hype_dimensionsElement->setAttributeNode(
288     NewAttribute("rmin", hype->GetInnerRadius() / mm));
289   hype_dimensionsElement->setAttributeNode(
290     NewAttribute("rmax", hype->GetOuterRadius() / mm));
291   hype_dimensionsElement->setAttributeNode(
292     NewAttribute("inst", hype->GetInnerStereo() / degree));
293   hype_dimensionsElement->setAttributeNode(
294     NewAttribute("outst", hype->GetOuterStereo() / degree));
295   hype_dimensionsElement->setAttributeNode(
296     NewAttribute("z", 2.0 * hype->GetZHalfLength() / mm));
297   hype_dimensionsElement->setAttributeNode(NewAttribute("aunit", "deg"));
298   hype_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
299   parametersElement->appendChild(hype_dimensionsElement);
300 }
301 
302 // --------------------------------------------------------------------
303 void G4GDMLWriteParamvol::Polycone_dimensionsWrite(
304   xercesc::DOMElement* parametersElement, const G4Polycone* const pcone)
305 {
306   xercesc::DOMElement* pcone_dimensionsElement =
307     NewElement("polycone_dimensions");
308 
309   pcone_dimensionsElement->setAttributeNode(
310     NewAttribute("numRZ", pcone->GetOriginalParameters()->Num_z_planes));
311   pcone_dimensionsElement->setAttributeNode(NewAttribute(
312     "startPhi", pcone->GetOriginalParameters()->Start_angle / degree));
313   pcone_dimensionsElement->setAttributeNode(NewAttribute(
314     "openPhi", pcone->GetOriginalParameters()->Opening_angle / degree));
315   pcone_dimensionsElement->setAttributeNode(NewAttribute("aunit", "deg"));
316   pcone_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
317 
318   parametersElement->appendChild(pcone_dimensionsElement);
319   const size_t num_zplanes   = pcone->GetOriginalParameters()->Num_z_planes;
320   const G4double* z_array    = pcone->GetOriginalParameters()->Z_values;
321   const G4double* rmin_array = pcone->GetOriginalParameters()->Rmin;
322   const G4double* rmax_array = pcone->GetOriginalParameters()->Rmax;
323 
324   for(std::size_t i = 0; i < num_zplanes; ++i)
325   {
326     ZplaneWrite(pcone_dimensionsElement, z_array[i], rmin_array[i],
327                 rmax_array[i]);
328   }
329 }
330 
331 // --------------------------------------------------------------------
332 void G4GDMLWriteParamvol::Polyhedra_dimensionsWrite(
333   xercesc::DOMElement* parametersElement, const G4Polyhedra* const polyhedra)
334 {
335   xercesc::DOMElement* polyhedra_dimensionsElement =
336     NewElement("polyhedra_dimensions");
337 
338   polyhedra_dimensionsElement->setAttributeNode(
339     NewAttribute("numRZ", polyhedra->GetOriginalParameters()->Num_z_planes));
340   polyhedra_dimensionsElement->setAttributeNode(
341     NewAttribute("numSide", polyhedra->GetOriginalParameters()->numSide));
342   polyhedra_dimensionsElement->setAttributeNode(NewAttribute(
343     "startPhi", polyhedra->GetOriginalParameters()->Start_angle / degree));
344   polyhedra_dimensionsElement->setAttributeNode(NewAttribute(
345     "openPhi", polyhedra->GetOriginalParameters()->Opening_angle / degree));
346   polyhedra_dimensionsElement->setAttributeNode(NewAttribute("aunit", "deg"));
347   polyhedra_dimensionsElement->setAttributeNode(NewAttribute("lunit", "mm"));
348 
349   parametersElement->appendChild(polyhedra_dimensionsElement);
350   const size_t num_zplanes   = polyhedra->GetOriginalParameters()->Num_z_planes;
351   const G4double* z_array    = polyhedra->GetOriginalParameters()->Z_values;
352   const G4double* rmin_array = polyhedra->GetOriginalParameters()->Rmin;
353   const G4double* rmax_array = polyhedra->GetOriginalParameters()->Rmax;
354 
355   for(std::size_t i = 0; i < num_zplanes; ++i)
356   {
357     ZplaneWrite(polyhedra_dimensionsElement, z_array[i], rmin_array[i],
358                 rmax_array[i]);
359   }
360 }
361 
362 // --------------------------------------------------------------------
363 void G4GDMLWriteParamvol::ParametersWrite(xercesc::DOMElement* paramvolElement,
364                    const G4VPhysicalVolume* const paramvol, const G4int& index)
365 {
366   paramvol->GetParameterisation()->ComputeTransformation(
367     index, const_cast<G4VPhysicalVolume*>(paramvol));
368   G4ThreeVector Angles;
369   G4String name = GenerateName(paramvol->GetName(), paramvol);
370   std::stringstream os;
371   os.precision(15);
372   os << index;
373   G4String sncopie = os.str();
374 
375   xercesc::DOMElement* parametersElement = NewElement("parameters");
376   parametersElement->setAttributeNode(NewAttribute("number", index + 1));
377 
378   PositionWrite(parametersElement, name + sncopie + "_pos",
379                 paramvol->GetObjectTranslation());
380   Angles = GetAngles(paramvol->GetObjectRotationValue());
381   if(Angles.mag2() > DBL_EPSILON)
382   {
383     RotationWrite(parametersElement, name + sncopie + "_rot",
384                   GetAngles(paramvol->GetObjectRotationValue()));
385   }
386   paramvolElement->appendChild(parametersElement);
387 
388   G4VSolid* solid = paramvol->GetLogicalVolume()->GetSolid();
389 
390   if(G4Box* box = dynamic_cast<G4Box*>(solid))
391   {
392     paramvol->GetParameterisation()->ComputeDimensions(
393       *box, index, const_cast<G4VPhysicalVolume*>(paramvol));
394     Box_dimensionsWrite(parametersElement, box);
395   }
396   else if(G4Trd* trd = dynamic_cast<G4Trd*>(solid))
397   {
398     paramvol->GetParameterisation()->ComputeDimensions(
399       *trd, index, const_cast<G4VPhysicalVolume*>(paramvol));
400     Trd_dimensionsWrite(parametersElement, trd);
401   }
402   else if(G4Trap* trap = dynamic_cast<G4Trap*>(solid))
403   {
404     paramvol->GetParameterisation()->ComputeDimensions(
405       *trap, index, const_cast<G4VPhysicalVolume*>(paramvol));
406     Trap_dimensionsWrite(parametersElement, trap);
407   }
408   else if(G4Tubs* tube = dynamic_cast<G4Tubs*>(solid))
409   {
410     paramvol->GetParameterisation()->ComputeDimensions(
411       *tube, index, const_cast<G4VPhysicalVolume*>(paramvol));
412     Tube_dimensionsWrite(parametersElement, tube);
413   }
414   else if(G4Cons* cone = dynamic_cast<G4Cons*>(solid))
415   {
416     paramvol->GetParameterisation()->ComputeDimensions(
417       *cone, index, const_cast<G4VPhysicalVolume*>(paramvol));
418     Cone_dimensionsWrite(parametersElement, cone);
419   }
420   else if(G4Sphere* sphere = dynamic_cast<G4Sphere*>(solid))
421   {
422     paramvol->GetParameterisation()->ComputeDimensions(
423       *sphere, index, const_cast<G4VPhysicalVolume*>(paramvol));
424     Sphere_dimensionsWrite(parametersElement, sphere);
425   }
426   else if(G4Orb* orb = dynamic_cast<G4Orb*>(solid))
427   {
428     paramvol->GetParameterisation()->ComputeDimensions(
429       *orb, index, const_cast<G4VPhysicalVolume*>(paramvol));
430     Orb_dimensionsWrite(parametersElement, orb);
431   }
432   else if(G4Torus* torus = dynamic_cast<G4Torus*>(solid))
433   {
434     paramvol->GetParameterisation()->ComputeDimensions(
435       *torus, index, const_cast<G4VPhysicalVolume*>(paramvol));
436     Torus_dimensionsWrite(parametersElement, torus);
437   }
438   else if(G4Ellipsoid* ellipsoid = dynamic_cast<G4Ellipsoid*>(solid))
439   {
440     paramvol->GetParameterisation()->ComputeDimensions(
441       *ellipsoid, index, const_cast<G4VPhysicalVolume*>(paramvol));
442     Ellipsoid_dimensionsWrite(parametersElement, ellipsoid);
443   }
444   else if(G4Para* para = dynamic_cast<G4Para*>(solid))
445   {
446     paramvol->GetParameterisation()->ComputeDimensions(
447       *para, index, const_cast<G4VPhysicalVolume*>(paramvol));
448     Para_dimensionsWrite(parametersElement, para);
449   }
450   else if(G4Hype* hype = dynamic_cast<G4Hype*>(solid))
451   {
452     paramvol->GetParameterisation()->ComputeDimensions(
453       *hype, index, const_cast<G4VPhysicalVolume*>(paramvol));
454     Hype_dimensionsWrite(parametersElement, hype);
455   }
456   else if(G4Polycone* pcone = dynamic_cast<G4Polycone*>(solid))
457   {
458     paramvol->GetParameterisation()->ComputeDimensions(
459       *pcone, index, const_cast<G4VPhysicalVolume*>(paramvol));
460     Polycone_dimensionsWrite(parametersElement, pcone);
461   }
462   else if(G4Polyhedra* polyhedra = dynamic_cast<G4Polyhedra*>(solid))
463   {
464     paramvol->GetParameterisation()->ComputeDimensions(
465       *polyhedra, index, const_cast<G4VPhysicalVolume*>(paramvol));
466     Polyhedra_dimensionsWrite(parametersElement, polyhedra);
467   }
468   else
469   {
470     G4String error_msg = "Solid '" + solid->GetName() +
471                          "' cannot be used in parameterised volume!";
472     G4Exception("G4GDMLWriteParamvol::ParametersWrite()", "InvalidSetup",
473                 FatalException, error_msg);
474   }
475 }
476 
477 // --------------------------------------------------------------------
478 void G4GDMLWriteParamvol::ParamvolWrite(xercesc::DOMElement* volumeElement,
479                                         const G4VPhysicalVolume* const paramvol)
480 {
481   const G4String volumeref = GenerateName(
482     paramvol->GetLogicalVolume()->GetName(), paramvol->GetLogicalVolume());
483   xercesc::DOMElement* paramvolElement = NewElement("paramvol");
484   paramvolElement->setAttributeNode(
485     NewAttribute("ncopies", paramvol->GetMultiplicity()));
486   xercesc::DOMElement* volumerefElement = NewElement("volumeref");
487   volumerefElement->setAttributeNode(NewAttribute("ref", volumeref));
488 
489   xercesc::DOMElement* algorithmElement =
490     NewElement("parameterised_position_size");
491   paramvolElement->appendChild(volumerefElement);
492   paramvolElement->appendChild(algorithmElement);
493   ParamvolAlgorithmWrite(algorithmElement, paramvol);
494   volumeElement->appendChild(paramvolElement);
495 }
496 
497 // --------------------------------------------------------------------
498 void G4GDMLWriteParamvol::ParamvolAlgorithmWrite(
499   xercesc::DOMElement* paramvolElement, const G4VPhysicalVolume* const paramvol)
500 {
501   const G4String volumeref = GenerateName(
502     paramvol->GetLogicalVolume()->GetName(), paramvol->GetLogicalVolume());
503 
504   const G4int parameterCount = paramvol->GetMultiplicity();
505 
506   for(G4int i = 0; i < parameterCount; ++i)
507   {
508     ParametersWrite(paramvolElement, paramvol, i);
509   }
510 }
511