| [987] | 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 | //
|
|---|
| [1228] | 26 | // $Id: G4GDMLReadParamvol.cc,v 1.13 2009/04/24 15:34:20 gcosmo Exp $
|
|---|
| 27 | // GEANT4 tag $Name: geant4-09-03 $
|
|---|
| [987] | 28 | //
|
|---|
| 29 | // class G4GDMLReadParamvol Implementation
|
|---|
| 30 | //
|
|---|
| 31 | // History:
|
|---|
| 32 | // - Created. Zoltan Torzsok, November 2007
|
|---|
| 33 | // -------------------------------------------------------------------------
|
|---|
| 34 |
|
|---|
| 35 | #include "G4GDMLReadParamvol.hh"
|
|---|
| 36 |
|
|---|
| [1228] | 37 | #include "G4LogicalVolume.hh"
|
|---|
| 38 | #include "G4PVParameterised.hh"
|
|---|
| 39 | #include "G4PVPlacement.hh"
|
|---|
| 40 | #include "G4VPhysicalVolume.hh"
|
|---|
| 41 |
|
|---|
| 42 | G4GDMLReadParamvol::G4GDMLReadParamvol() : G4GDMLReadSetup()
|
|---|
| 43 | {
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | G4GDMLReadParamvol::~G4GDMLReadParamvol()
|
|---|
| 47 | {
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| [987] | 50 | void G4GDMLReadParamvol::
|
|---|
| 51 | Box_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 52 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 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 | const G4String attName = Transcode(attribute->getName());
|
|---|
| 70 | const G4String attValue = Transcode(attribute->getValue());
|
|---|
| 71 |
|
|---|
| 72 | if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
|
|---|
| 73 | if (attName=="x") { parameter.dimension[0] = eval.Evaluate(attValue); } else
|
|---|
| 74 | if (attName=="y") { parameter.dimension[1] = eval.Evaluate(attValue); } else
|
|---|
| 75 | if (attName=="z") { parameter.dimension[2] = eval.Evaluate(attValue); }
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | parameter.dimension[0] *= 0.5*lunit;
|
|---|
| 79 | parameter.dimension[1] *= 0.5*lunit;
|
|---|
| 80 | parameter.dimension[2] *= 0.5*lunit;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | void G4GDMLReadParamvol::
|
|---|
| 84 | Trd_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 85 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 86 | {
|
|---|
| 87 | G4double lunit = 1.0;
|
|---|
| 88 |
|
|---|
| 89 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
|---|
| 90 | XMLSize_t attributeCount = attributes->getLength();
|
|---|
| 91 |
|
|---|
| 92 | for (XMLSize_t attribute_index=0;
|
|---|
| 93 | attribute_index<attributeCount; attribute_index++)
|
|---|
| 94 | {
|
|---|
| 95 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
|---|
| 96 |
|
|---|
| 97 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
|
|---|
| 98 | { continue; }
|
|---|
| 99 |
|
|---|
| 100 | const xercesc::DOMAttr* const attribute
|
|---|
| 101 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
|---|
| 102 | const G4String attName = Transcode(attribute->getName());
|
|---|
| 103 | const G4String attValue = Transcode(attribute->getValue());
|
|---|
| 104 |
|
|---|
| 105 | if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
|
|---|
| 106 | if (attName=="x1") { parameter.dimension[0]=eval.Evaluate(attValue); } else
|
|---|
| 107 | if (attName=="x2") { parameter.dimension[1]=eval.Evaluate(attValue); } else
|
|---|
| 108 | if (attName=="y1") { parameter.dimension[2]=eval.Evaluate(attValue); } else
|
|---|
| 109 | if (attName=="y2") { parameter.dimension[3]=eval.Evaluate(attValue); } else
|
|---|
| 110 | if (attName=="z") { parameter.dimension[4]=eval.Evaluate(attValue); }
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | parameter.dimension[0] *= 0.5*lunit;
|
|---|
| 114 | parameter.dimension[1] *= 0.5*lunit;
|
|---|
| 115 | parameter.dimension[2] *= 0.5*lunit;
|
|---|
| 116 | parameter.dimension[3] *= 0.5*lunit;
|
|---|
| 117 | parameter.dimension[4] *= 0.5*lunit;
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | void G4GDMLReadParamvol::
|
|---|
| 121 | Trap_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 122 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 123 | {
|
|---|
| 124 | G4double lunit = 1.0;
|
|---|
| 125 | G4double aunit = 1.0;
|
|---|
| 126 |
|
|---|
| 127 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
|---|
| 128 | XMLSize_t attributeCount = attributes->getLength();
|
|---|
| 129 |
|
|---|
| 130 | for (XMLSize_t attribute_index=0;
|
|---|
| 131 | attribute_index<attributeCount; attribute_index++)
|
|---|
| 132 | {
|
|---|
| 133 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
|---|
| 134 |
|
|---|
| 135 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
|
|---|
| 136 | { continue; }
|
|---|
| 137 |
|
|---|
| 138 | const xercesc::DOMAttr* const attribute
|
|---|
| 139 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
|---|
| 140 | const G4String attName = Transcode(attribute->getName());
|
|---|
| 141 | const G4String attValue = Transcode(attribute->getValue());
|
|---|
| 142 |
|
|---|
| 143 | if (attName=="lunit")
|
|---|
| 144 | { lunit = eval.Evaluate(attValue); } else
|
|---|
| 145 | if (attName=="aunit")
|
|---|
| 146 | { aunit = eval.Evaluate(attValue); } else
|
|---|
| 147 | if (attName=="z")
|
|---|
| 148 | { parameter.dimension[0] = eval.Evaluate(attValue); } else
|
|---|
| 149 | if (attName=="theta")
|
|---|
| 150 | { parameter.dimension[1] = eval.Evaluate(attValue); } else
|
|---|
| 151 | if (attName=="phi")
|
|---|
| 152 | { parameter.dimension[2] = eval.Evaluate(attValue); } else
|
|---|
| 153 | if (attName=="y1")
|
|---|
| 154 | { parameter.dimension[3] = eval.Evaluate(attValue); } else
|
|---|
| 155 | if (attName=="x1")
|
|---|
| 156 | { parameter.dimension[4] = eval.Evaluate(attValue); } else
|
|---|
| 157 | if (attName=="x2")
|
|---|
| 158 | { parameter.dimension[5] = eval.Evaluate(attValue); } else
|
|---|
| 159 | if (attName=="alpha1")
|
|---|
| 160 | { parameter.dimension[6] = eval.Evaluate(attValue); } else
|
|---|
| 161 | if (attName=="y2")
|
|---|
| 162 | { parameter.dimension[7] = eval.Evaluate(attValue); } else
|
|---|
| 163 | if (attName=="x3")
|
|---|
| 164 | { parameter.dimension[8] = eval.Evaluate(attValue); } else
|
|---|
| 165 | if (attName=="x4")
|
|---|
| 166 | { parameter.dimension[9] = eval.Evaluate(attValue); } else
|
|---|
| 167 | if (attName=="alpha2")
|
|---|
| 168 | { parameter.dimension[10] = eval.Evaluate(attValue); }
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | parameter.dimension[0] *= 0.5*lunit;
|
|---|
| 172 | parameter.dimension[1] *= aunit;
|
|---|
| 173 | parameter.dimension[2] *= aunit;
|
|---|
| 174 | parameter.dimension[3] *= 0.5*lunit;
|
|---|
| 175 | parameter.dimension[4] *= 0.5*lunit;
|
|---|
| 176 | parameter.dimension[5] *= 0.5*lunit;
|
|---|
| 177 | parameter.dimension[6] *= aunit;
|
|---|
| 178 | parameter.dimension[7] *= 0.5*lunit;
|
|---|
| 179 | parameter.dimension[8] *= 0.5*lunit;
|
|---|
| 180 | parameter.dimension[9] *= 0.5*lunit;
|
|---|
| 181 | parameter.dimension[10] *= aunit;
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | void G4GDMLReadParamvol::
|
|---|
| 185 | Tube_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 186 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 187 | {
|
|---|
| 188 | G4double lunit = 1.0;
|
|---|
| 189 | G4double aunit = 1.0;
|
|---|
| 190 |
|
|---|
| 191 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
|---|
| 192 | XMLSize_t attributeCount = attributes->getLength();
|
|---|
| 193 |
|
|---|
| 194 | for (XMLSize_t attribute_index=0;
|
|---|
| 195 | attribute_index<attributeCount; attribute_index++)
|
|---|
| 196 | {
|
|---|
| 197 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
|---|
| 198 |
|
|---|
| 199 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
|
|---|
| 200 | { continue; }
|
|---|
| 201 |
|
|---|
| 202 | const xercesc::DOMAttr* const attribute
|
|---|
| 203 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
|---|
| 204 | const G4String attName = Transcode(attribute->getName());
|
|---|
| 205 | const G4String attValue = Transcode(attribute->getValue());
|
|---|
| 206 |
|
|---|
| 207 | if (attName=="lunit")
|
|---|
| 208 | { lunit = eval.Evaluate(attValue); } else
|
|---|
| 209 | if (attName=="aunit")
|
|---|
| 210 | { aunit = eval.Evaluate(attValue); } else
|
|---|
| 211 | if (attName=="InR")
|
|---|
| 212 | { parameter.dimension[0] = eval.Evaluate(attValue); } else
|
|---|
| 213 | if (attName=="OutR")
|
|---|
| 214 | { parameter.dimension[1] = eval.Evaluate(attValue); } else
|
|---|
| 215 | if (attName=="hz")
|
|---|
| 216 | { parameter.dimension[2] = eval.Evaluate(attValue); } else
|
|---|
| 217 | if (attName=="StartPhi")
|
|---|
| 218 | { parameter.dimension[3] = eval.Evaluate(attValue); } else
|
|---|
| 219 | if (attName=="DeltaPhi")
|
|---|
| 220 | { parameter.dimension[4] = eval.Evaluate(attValue); }
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | parameter.dimension[0] *= lunit;
|
|---|
| 224 | parameter.dimension[1] *= lunit;
|
|---|
| 225 | parameter.dimension[2] *= 0.5*lunit;
|
|---|
| 226 | parameter.dimension[3] *= aunit;
|
|---|
| 227 | parameter.dimension[4] *= aunit;
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | void G4GDMLReadParamvol::
|
|---|
| 231 | Cone_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 232 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 233 | {
|
|---|
| 234 | G4double lunit = 1.0;
|
|---|
| 235 | G4double aunit = 1.0;
|
|---|
| 236 |
|
|---|
| 237 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
|---|
| 238 | XMLSize_t attributeCount = attributes->getLength();
|
|---|
| 239 |
|
|---|
| 240 | for (XMLSize_t attribute_index=0;
|
|---|
| 241 | attribute_index<attributeCount; attribute_index++)
|
|---|
| 242 | {
|
|---|
| 243 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
|---|
| 244 |
|
|---|
| 245 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
|
|---|
| 246 | { continue; }
|
|---|
| 247 |
|
|---|
| 248 | const xercesc::DOMAttr* const attribute
|
|---|
| 249 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
|---|
| 250 | const G4String attName = Transcode(attribute->getName());
|
|---|
| 251 | const G4String attValue = Transcode(attribute->getValue());
|
|---|
| 252 |
|
|---|
| 253 | if (attName=="lunit")
|
|---|
| 254 | { lunit = eval.Evaluate(attValue); } else
|
|---|
| 255 | if (attName=="aunit")
|
|---|
| 256 | { aunit = eval.Evaluate(attValue); } else
|
|---|
| 257 | if (attName=="rmin1")
|
|---|
| 258 | { parameter.dimension[0] = eval.Evaluate(attValue); } else
|
|---|
| 259 | if (attName=="rmax1")
|
|---|
| 260 | { parameter.dimension[1] = eval.Evaluate(attValue); } else
|
|---|
| 261 | if (attName=="rmin2")
|
|---|
| 262 | { parameter.dimension[2] = eval.Evaluate(attValue); } else
|
|---|
| 263 | if (attName=="rmax2")
|
|---|
| 264 | { parameter.dimension[3] = eval.Evaluate(attValue); } else
|
|---|
| 265 | if (attName=="z")
|
|---|
| 266 | { parameter.dimension[4] = eval.Evaluate(attValue); } else
|
|---|
| 267 | if (attName=="startphi")
|
|---|
| 268 | { parameter.dimension[5] = eval.Evaluate(attValue); } else
|
|---|
| 269 | if (attName=="deltaphi")
|
|---|
| 270 | { parameter.dimension[6] = eval.Evaluate(attValue); }
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | parameter.dimension[0] *= lunit;
|
|---|
| 274 | parameter.dimension[1] *= lunit;
|
|---|
| 275 | parameter.dimension[2] *= lunit;
|
|---|
| 276 | parameter.dimension[3] *= lunit;
|
|---|
| 277 | parameter.dimension[4] *= 0.5*lunit;
|
|---|
| 278 | parameter.dimension[5] *= aunit;
|
|---|
| 279 | parameter.dimension[6] *= aunit;
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | void G4GDMLReadParamvol::
|
|---|
| 283 | Sphere_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 284 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 285 | {
|
|---|
| 286 | G4double lunit = 1.0;
|
|---|
| 287 | G4double aunit = 1.0;
|
|---|
| 288 |
|
|---|
| 289 | const xercesc::DOMNamedNodeMap* const attributes = element->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=="lunit")
|
|---|
| 306 | { lunit = eval.Evaluate(attValue); } else
|
|---|
| 307 | if (attName=="aunit")
|
|---|
| 308 | { aunit = eval.Evaluate(attValue); } else
|
|---|
| 309 | if (attName=="rmin")
|
|---|
| 310 | { parameter.dimension[0] = eval.Evaluate(attValue); } else
|
|---|
| 311 | if (attName=="rmax")
|
|---|
| 312 | { parameter.dimension[1] = eval.Evaluate(attValue); } else
|
|---|
| 313 | if (attName=="startphi")
|
|---|
| 314 | { parameter.dimension[2] = eval.Evaluate(attValue); } else
|
|---|
| 315 | if (attName=="deltaphi")
|
|---|
| 316 | { parameter.dimension[3] = eval.Evaluate(attValue); } else
|
|---|
| 317 | if (attName=="starttheta")
|
|---|
| 318 | { parameter.dimension[4] = eval.Evaluate(attValue); } else
|
|---|
| 319 | if (attName=="deltatheta")
|
|---|
| 320 | { parameter.dimension[5] = eval.Evaluate(attValue); }
|
|---|
| 321 | }
|
|---|
| 322 |
|
|---|
| 323 | parameter.dimension[0] *= lunit;
|
|---|
| 324 | parameter.dimension[1] *= lunit;
|
|---|
| 325 | parameter.dimension[2] *= aunit;
|
|---|
| 326 | parameter.dimension[3] *= aunit;
|
|---|
| 327 | parameter.dimension[4] *= aunit;
|
|---|
| 328 | parameter.dimension[5] *= aunit;
|
|---|
| 329 | }
|
|---|
| 330 |
|
|---|
| 331 | void G4GDMLReadParamvol::
|
|---|
| 332 | Orb_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 333 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 334 | {
|
|---|
| 335 | G4double lunit = 1.0;
|
|---|
| 336 |
|
|---|
| 337 | const xercesc::DOMNamedNodeMap* const attributes = element->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=="lunit") { lunit = eval.Evaluate(attValue); } else
|
|---|
| 354 | if (attName=="r") { parameter.dimension[0] = eval.Evaluate(attValue); }
|
|---|
| 355 | }
|
|---|
| 356 |
|
|---|
| 357 | parameter.dimension[0] *= lunit;
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 | void G4GDMLReadParamvol::
|
|---|
| 361 | Torus_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 362 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 363 | {
|
|---|
| 364 | G4double lunit = 1.0;
|
|---|
| 365 | G4double aunit = 1.0;
|
|---|
| 366 |
|
|---|
| 367 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
|---|
| 368 | XMLSize_t attributeCount = attributes->getLength();
|
|---|
| 369 |
|
|---|
| 370 | for (XMLSize_t attribute_index=0;
|
|---|
| 371 | attribute_index<attributeCount; attribute_index++)
|
|---|
| 372 | {
|
|---|
| 373 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
|---|
| 374 |
|
|---|
| 375 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
|
|---|
| 376 | { continue; }
|
|---|
| 377 |
|
|---|
| 378 | const xercesc::DOMAttr* const attribute
|
|---|
| 379 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
|---|
| 380 | const G4String attName = Transcode(attribute->getName());
|
|---|
| 381 | const G4String attValue = Transcode(attribute->getValue());
|
|---|
| 382 |
|
|---|
| 383 | if (attName=="lunit")
|
|---|
| 384 | { lunit = eval.Evaluate(attValue); } else
|
|---|
| 385 | if (attName=="aunit")
|
|---|
| 386 | { aunit = eval.Evaluate(attValue); } else
|
|---|
| 387 | if (attName=="rmin")
|
|---|
| 388 | { parameter.dimension[0] = eval.Evaluate(attValue); } else
|
|---|
| 389 | if (attName=="rmax")
|
|---|
| 390 | { parameter.dimension[1] = eval.Evaluate(attValue); } else
|
|---|
| 391 | if (attName=="rtor")
|
|---|
| 392 | { parameter.dimension[2] = eval.Evaluate(attValue); } else
|
|---|
| 393 | if (attName=="startphi")
|
|---|
| 394 | { parameter.dimension[3] = eval.Evaluate(attValue); } else
|
|---|
| 395 | if (attName=="deltaphi")
|
|---|
| 396 | { parameter.dimension[4] = eval.Evaluate(attValue); }
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | parameter.dimension[0] *= lunit;
|
|---|
| 400 | parameter.dimension[1] *= lunit;
|
|---|
| 401 | parameter.dimension[2] *= lunit;
|
|---|
| 402 | parameter.dimension[3] *= aunit;
|
|---|
| 403 | parameter.dimension[4] *= aunit;
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | void G4GDMLReadParamvol::
|
|---|
| 407 | Para_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 408 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 409 | {
|
|---|
| 410 | G4double lunit = 1.0;
|
|---|
| 411 | G4double aunit = 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 | const G4String attName = Transcode(attribute->getName());
|
|---|
| 427 | const G4String attValue = Transcode(attribute->getValue());
|
|---|
| 428 |
|
|---|
| 429 | if (attName=="lunit")
|
|---|
| 430 | { lunit = eval.Evaluate(attValue); } else
|
|---|
| 431 | if (attName=="aunit")
|
|---|
| 432 | { aunit = eval.Evaluate(attValue); } else
|
|---|
| 433 | if (attName=="x")
|
|---|
| 434 | { parameter.dimension[0] = eval.Evaluate(attValue); } else
|
|---|
| 435 | if (attName=="y")
|
|---|
| 436 | { parameter.dimension[1] = eval.Evaluate(attValue); } else
|
|---|
| 437 | if (attName=="z")
|
|---|
| 438 | { parameter.dimension[2] = eval.Evaluate(attValue); } else
|
|---|
| 439 | if (attName=="alpha")
|
|---|
| 440 | { parameter.dimension[3] = eval.Evaluate(attValue); } else
|
|---|
| 441 | if (attName=="theta")
|
|---|
| 442 | { parameter.dimension[4] = eval.Evaluate(attValue); } else
|
|---|
| 443 | if (attName=="phi")
|
|---|
| 444 | { parameter.dimension[5] = eval.Evaluate(attValue); }
|
|---|
| 445 | }
|
|---|
| 446 |
|
|---|
| 447 | parameter.dimension[0] = 0.5*lunit;
|
|---|
| 448 | parameter.dimension[1] = 0.5*lunit;
|
|---|
| 449 | parameter.dimension[2] = 0.5*lunit;
|
|---|
| 450 | parameter.dimension[3] = aunit;
|
|---|
| 451 | parameter.dimension[4] = aunit;
|
|---|
| 452 | parameter.dimension[5] = aunit;
|
|---|
| 453 | }
|
|---|
| 454 |
|
|---|
| 455 | void G4GDMLReadParamvol::
|
|---|
| 456 | Hype_dimensionsRead( const xercesc::DOMElement* const element,
|
|---|
| 457 | G4GDMLParameterisation::PARAMETER& parameter )
|
|---|
| 458 | {
|
|---|
| 459 | G4double lunit = 1.0;
|
|---|
| 460 | G4double aunit = 1.0;
|
|---|
| 461 |
|
|---|
| 462 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
|---|
| 463 | XMLSize_t attributeCount = attributes->getLength();
|
|---|
| 464 |
|
|---|
| 465 | for (XMLSize_t attribute_index=0;
|
|---|
| 466 | attribute_index<attributeCount; attribute_index++)
|
|---|
| 467 | {
|
|---|
| 468 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
|---|
| 469 |
|
|---|
| 470 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
|
|---|
| 471 | { continue; }
|
|---|
| 472 |
|
|---|
| 473 | const xercesc::DOMAttr* const attribute
|
|---|
| 474 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
|---|
| 475 | const G4String attName = Transcode(attribute->getName());
|
|---|
| 476 | const G4String attValue = Transcode(attribute->getValue());
|
|---|
| 477 |
|
|---|
| 478 | if (attName=="lunit")
|
|---|
| 479 | { lunit = eval.Evaluate(attValue); } else
|
|---|
| 480 | if (attName=="aunit")
|
|---|
| 481 | { aunit = eval.Evaluate(attValue); } else
|
|---|
| 482 | if (attName=="rmin")
|
|---|
| 483 | { parameter.dimension[0] = eval.Evaluate(attValue); } else
|
|---|
| 484 | if (attName=="rmax")
|
|---|
| 485 | { parameter.dimension[1] = eval.Evaluate(attValue); } else
|
|---|
| 486 | if (attName=="inst")
|
|---|
| 487 | { parameter.dimension[2] = eval.Evaluate(attValue); } else
|
|---|
| 488 | if (attName=="outst")
|
|---|
| 489 | { parameter.dimension[3] = eval.Evaluate(attValue); } else
|
|---|
| 490 | if (attName=="z")
|
|---|
| 491 | { parameter.dimension[4] = eval.Evaluate(attValue); }
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| 494 | parameter.dimension[0] = lunit;
|
|---|
| 495 | parameter.dimension[1] = lunit;
|
|---|
| 496 | parameter.dimension[2] = aunit;
|
|---|
| 497 | parameter.dimension[3] = aunit;
|
|---|
| 498 | parameter.dimension[4] = 0.5*lunit;
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | void G4GDMLReadParamvol::
|
|---|
| 502 | ParametersRead(const xercesc::DOMElement* const element) {
|
|---|
| 503 |
|
|---|
| 504 | G4ThreeVector rotation(0.0,0.0,0.0);
|
|---|
| 505 | G4ThreeVector position(0.0,0.0,0.0);
|
|---|
| 506 |
|
|---|
| 507 | G4GDMLParameterisation::PARAMETER parameter;
|
|---|
| 508 |
|
|---|
| 509 | for (xercesc::DOMNode* iter = element->getFirstChild();
|
|---|
| 510 | iter != 0; iter = iter->getNextSibling())
|
|---|
| 511 | {
|
|---|
| 512 | if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
|
|---|
| 513 |
|
|---|
| 514 | const xercesc::DOMElement* const child
|
|---|
| 515 | = dynamic_cast<xercesc::DOMElement*>(iter);
|
|---|
| 516 | const G4String tag = Transcode(child->getTagName());
|
|---|
| 517 | if (tag=="rotation") { VectorRead(child,rotation); } else
|
|---|
| 518 | if (tag=="position") { VectorRead(child,position); } else
|
|---|
| 519 | if (tag=="positionref")
|
|---|
| 520 | { position = GetPosition(GenerateName(RefRead(child))); } else
|
|---|
| 521 | if (tag=="rotationref")
|
|---|
| 522 | { rotation = GetRotation(GenerateName(RefRead(child))); } else
|
|---|
| 523 | if (tag=="box_dimensions") { Box_dimensionsRead(child,parameter); } else
|
|---|
| 524 | if (tag=="trd_dimensions") { Trd_dimensionsRead(child,parameter); } else
|
|---|
| 525 | if (tag=="trap_dimensions") { Trap_dimensionsRead(child,parameter); } else
|
|---|
| 526 | if (tag=="tube_dimensions") { Tube_dimensionsRead(child,parameter); } else
|
|---|
| 527 | if (tag=="cone_dimensions") { Cone_dimensionsRead(child,parameter); } else
|
|---|
| 528 | if (tag=="sphere_dimensions") { Cone_dimensionsRead(child,parameter); } else
|
|---|
| 529 | if (tag=="orb_dimensions") { Cone_dimensionsRead(child,parameter); } else
|
|---|
| 530 | if (tag=="torus_dimensions") { Cone_dimensionsRead(child,parameter); } else
|
|---|
| 531 | if (tag=="para_dimensions") { Cone_dimensionsRead(child,parameter); } else
|
|---|
| 532 | if (tag=="hype_dimensions") { Hype_dimensionsRead(child,parameter); }
|
|---|
| 533 | else
|
|---|
| 534 | {
|
|---|
| 535 | G4String error_msg = "Unknown tag in parameters: " + tag;
|
|---|
| 536 | G4Exception("G4GDMLReadParamvol::ParametersRead()", "ReadError",
|
|---|
| 537 | FatalException, error_msg);
|
|---|
| 538 | }
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | parameter.pRot = new G4RotationMatrix();
|
|---|
| 542 |
|
|---|
| 543 | parameter.pRot->rotateX(rotation.x());
|
|---|
| 544 | parameter.pRot->rotateY(rotation.y());
|
|---|
| 545 | parameter.pRot->rotateZ(rotation.z());
|
|---|
| 546 |
|
|---|
| 547 | parameter.position = position;
|
|---|
| 548 |
|
|---|
| 549 | parameterisation->AddParameter(parameter);
|
|---|
| 550 | }
|
|---|
| 551 |
|
|---|
| 552 | void G4GDMLReadParamvol::
|
|---|
| 553 | ParameterisedRead(const xercesc::DOMElement* const element)
|
|---|
| 554 | {
|
|---|
| 555 | for (xercesc::DOMNode* iter = element->getFirstChild();
|
|---|
| 556 | iter != 0; iter = iter->getNextSibling())
|
|---|
| 557 | {
|
|---|
| 558 | if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
|
|---|
| 559 |
|
|---|
| 560 | const xercesc::DOMElement* const child
|
|---|
| 561 | = dynamic_cast<xercesc::DOMElement*>(iter);
|
|---|
| 562 | const G4String tag = Transcode(child->getTagName());
|
|---|
| 563 |
|
|---|
| 564 | if (tag=="parameters")
|
|---|
| 565 | {
|
|---|
| 566 | G4double number = 1;
|
|---|
| 567 | const xercesc::DOMNamedNodeMap* const attributes
|
|---|
| 568 | = element->getAttributes();
|
|---|
| 569 | XMLSize_t attributeCount = attributes->getLength();
|
|---|
| 570 | for (XMLSize_t attribute_index=0;
|
|---|
| 571 | attribute_index<attributeCount; attribute_index++)
|
|---|
| 572 | {
|
|---|
| 573 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
|---|
| 574 |
|
|---|
| 575 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
|
|---|
| 576 | { continue; }
|
|---|
| 577 |
|
|---|
| 578 | const xercesc::DOMAttr* const attribute
|
|---|
| 579 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
|---|
| 580 | const G4String attName = Transcode(attribute->getName());
|
|---|
| 581 | const G4String attValue = Transcode(attribute->getValue());
|
|---|
| 582 |
|
|---|
| 583 | if (attName=="number") { number = eval.Evaluate(attValue); }
|
|---|
| 584 | }
|
|---|
| 585 | ParametersRead(child);
|
|---|
| 586 | }
|
|---|
| 587 | else
|
|---|
| 588 | {
|
|---|
| 589 | if (tag=="loop") { LoopRead(child,&G4GDMLRead::Paramvol_contentRead); }
|
|---|
| 590 | }
|
|---|
| 591 | }
|
|---|
| 592 | }
|
|---|
| 593 |
|
|---|
| 594 | void G4GDMLReadParamvol::
|
|---|
| 595 | Paramvol_contentRead(const xercesc::DOMElement* const element)
|
|---|
| 596 | {
|
|---|
| 597 | for (xercesc::DOMNode* iter = element->getFirstChild();
|
|---|
| 598 | iter != 0; iter = iter->getNextSibling())
|
|---|
| 599 | {
|
|---|
| 600 | if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
|
|---|
| 601 |
|
|---|
| 602 | const xercesc::DOMElement* const child
|
|---|
| 603 | = dynamic_cast<xercesc::DOMElement*>(iter);
|
|---|
| 604 | const G4String tag = Transcode(child->getTagName());
|
|---|
| 605 | if (tag=="parameterised_position_size") { ParameterisedRead(child); }else
|
|---|
| 606 | if (tag=="loop") { LoopRead(child,&G4GDMLRead::Paramvol_contentRead); }
|
|---|
| 607 | }
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | void G4GDMLReadParamvol::
|
|---|
| 611 | ParamvolRead(const xercesc::DOMElement* const element, G4LogicalVolume* mother)
|
|---|
| 612 | {
|
|---|
| 613 | G4String volumeref;
|
|---|
| 614 |
|
|---|
| 615 | parameterisation = new G4GDMLParameterisation();
|
|---|
| 616 |
|
|---|
| 617 | for (xercesc::DOMNode* iter = element->getFirstChild();
|
|---|
| 618 | iter != 0; iter = iter->getNextSibling())
|
|---|
| 619 | {
|
|---|
| 620 | if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
|
|---|
| 621 |
|
|---|
| 622 | const xercesc::DOMElement* const child
|
|---|
| 623 | = dynamic_cast<xercesc::DOMElement*>(iter);
|
|---|
| 624 | const G4String tag = Transcode(child->getTagName());
|
|---|
| 625 |
|
|---|
| 626 | if (tag=="volumeref") { volumeref = RefRead(child); }
|
|---|
| 627 |
|
|---|
| 628 | }
|
|---|
| 629 |
|
|---|
| 630 | Paramvol_contentRead(element);
|
|---|
| 631 |
|
|---|
| 632 | G4LogicalVolume* logvol = GetVolume(GenerateName(volumeref));
|
|---|
| 633 |
|
|---|
| 634 | if (parameterisation->GetSize()==0)
|
|---|
| 635 | {
|
|---|
| 636 | G4Exception("G4GDMLReadParamvol::ParamvolRead()",
|
|---|
| 637 | "ReadError", FatalException,
|
|---|
| 638 | "No parameters are defined in parameterised volume!");
|
|---|
| 639 | }
|
|---|
| 640 | G4String pv_name = logvol->GetName() + "_param";
|
|---|
| 641 | new G4PVParameterised(pv_name, logvol, mother, kUndefined,
|
|---|
| 642 | parameterisation->GetSize(), parameterisation, check);
|
|---|
| 643 | }
|
|---|