[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 | // |
---|
[1347] | 26 | // $Id: G4GDMLReadParamvol.cc,v 1.14 2010/10/14 16:19:40 gcosmo Exp $ |
---|
| 27 | // GEANT4 tag $Name: gdml-V09-03-09 $ |
---|
[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 | |
---|
[1347] | 42 | G4GDMLReadParamvol::G4GDMLReadParamvol() |
---|
| 43 | : G4GDMLReadSetup(), parameterisation(0) |
---|
[1228] | 44 | { |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | G4GDMLReadParamvol::~G4GDMLReadParamvol() |
---|
| 48 | { |
---|
| 49 | } |
---|
| 50 | |
---|
[987] | 51 | void G4GDMLReadParamvol:: |
---|
| 52 | Box_dimensionsRead( const xercesc::DOMElement* const element, |
---|
| 53 | G4GDMLParameterisation::PARAMETER& parameter ) |
---|
| 54 | { |
---|
| 55 | G4double lunit = 1.0; |
---|
| 56 | |
---|
| 57 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); |
---|
| 58 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 59 | |
---|
| 60 | for (XMLSize_t attribute_index=0; |
---|
| 61 | attribute_index<attributeCount; attribute_index++) |
---|
| 62 | { |
---|
| 63 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 64 | |
---|
| 65 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 66 | { continue; } |
---|
| 67 | |
---|
| 68 | const xercesc::DOMAttr* const attribute |
---|
| 69 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 70 | if (!attribute) |
---|
| 71 | { |
---|
| 72 | G4Exception("G4GDMLReadParamvol::Box_dimensionsRead()", |
---|
| 73 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 74 | return; |
---|
| 75 | } |
---|
[987] | 76 | const G4String attName = Transcode(attribute->getName()); |
---|
| 77 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 78 | |
---|
| 79 | if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else |
---|
| 80 | if (attName=="x") { parameter.dimension[0] = eval.Evaluate(attValue); } else |
---|
| 81 | if (attName=="y") { parameter.dimension[1] = eval.Evaluate(attValue); } else |
---|
| 82 | if (attName=="z") { parameter.dimension[2] = eval.Evaluate(attValue); } |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | parameter.dimension[0] *= 0.5*lunit; |
---|
| 86 | parameter.dimension[1] *= 0.5*lunit; |
---|
| 87 | parameter.dimension[2] *= 0.5*lunit; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | void G4GDMLReadParamvol:: |
---|
| 91 | Trd_dimensionsRead( const xercesc::DOMElement* const element, |
---|
| 92 | G4GDMLParameterisation::PARAMETER& parameter ) |
---|
| 93 | { |
---|
| 94 | G4double lunit = 1.0; |
---|
| 95 | |
---|
| 96 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); |
---|
| 97 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 98 | |
---|
| 99 | for (XMLSize_t attribute_index=0; |
---|
| 100 | attribute_index<attributeCount; attribute_index++) |
---|
| 101 | { |
---|
| 102 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 103 | |
---|
| 104 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 105 | { continue; } |
---|
| 106 | |
---|
| 107 | const xercesc::DOMAttr* const attribute |
---|
| 108 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 109 | if (!attribute) |
---|
| 110 | { |
---|
| 111 | G4Exception("G4GDMLReadParamvol::Trd_dimensionsRead()", |
---|
| 112 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 113 | return; |
---|
| 114 | } |
---|
[987] | 115 | const G4String attName = Transcode(attribute->getName()); |
---|
| 116 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 117 | |
---|
| 118 | if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else |
---|
| 119 | if (attName=="x1") { parameter.dimension[0]=eval.Evaluate(attValue); } else |
---|
| 120 | if (attName=="x2") { parameter.dimension[1]=eval.Evaluate(attValue); } else |
---|
| 121 | if (attName=="y1") { parameter.dimension[2]=eval.Evaluate(attValue); } else |
---|
| 122 | if (attName=="y2") { parameter.dimension[3]=eval.Evaluate(attValue); } else |
---|
| 123 | if (attName=="z") { parameter.dimension[4]=eval.Evaluate(attValue); } |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | parameter.dimension[0] *= 0.5*lunit; |
---|
| 127 | parameter.dimension[1] *= 0.5*lunit; |
---|
| 128 | parameter.dimension[2] *= 0.5*lunit; |
---|
| 129 | parameter.dimension[3] *= 0.5*lunit; |
---|
| 130 | parameter.dimension[4] *= 0.5*lunit; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | void G4GDMLReadParamvol:: |
---|
| 134 | Trap_dimensionsRead( const xercesc::DOMElement* const element, |
---|
| 135 | G4GDMLParameterisation::PARAMETER& parameter ) |
---|
| 136 | { |
---|
| 137 | G4double lunit = 1.0; |
---|
| 138 | G4double aunit = 1.0; |
---|
| 139 | |
---|
| 140 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); |
---|
| 141 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 142 | |
---|
| 143 | for (XMLSize_t attribute_index=0; |
---|
| 144 | attribute_index<attributeCount; attribute_index++) |
---|
| 145 | { |
---|
| 146 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 147 | |
---|
| 148 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 149 | { continue; } |
---|
| 150 | |
---|
| 151 | const xercesc::DOMAttr* const attribute |
---|
| 152 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 153 | if (!attribute) |
---|
| 154 | { |
---|
| 155 | G4Exception("G4GDMLReadParamvol::Trap_dimensionsRead()", |
---|
| 156 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 157 | return; |
---|
| 158 | } |
---|
[987] | 159 | const G4String attName = Transcode(attribute->getName()); |
---|
| 160 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 161 | |
---|
| 162 | if (attName=="lunit") |
---|
| 163 | { lunit = eval.Evaluate(attValue); } else |
---|
| 164 | if (attName=="aunit") |
---|
| 165 | { aunit = eval.Evaluate(attValue); } else |
---|
| 166 | if (attName=="z") |
---|
| 167 | { parameter.dimension[0] = eval.Evaluate(attValue); } else |
---|
| 168 | if (attName=="theta") |
---|
| 169 | { parameter.dimension[1] = eval.Evaluate(attValue); } else |
---|
| 170 | if (attName=="phi") |
---|
| 171 | { parameter.dimension[2] = eval.Evaluate(attValue); } else |
---|
| 172 | if (attName=="y1") |
---|
| 173 | { parameter.dimension[3] = eval.Evaluate(attValue); } else |
---|
| 174 | if (attName=="x1") |
---|
| 175 | { parameter.dimension[4] = eval.Evaluate(attValue); } else |
---|
| 176 | if (attName=="x2") |
---|
| 177 | { parameter.dimension[5] = eval.Evaluate(attValue); } else |
---|
| 178 | if (attName=="alpha1") |
---|
| 179 | { parameter.dimension[6] = eval.Evaluate(attValue); } else |
---|
| 180 | if (attName=="y2") |
---|
| 181 | { parameter.dimension[7] = eval.Evaluate(attValue); } else |
---|
| 182 | if (attName=="x3") |
---|
| 183 | { parameter.dimension[8] = eval.Evaluate(attValue); } else |
---|
| 184 | if (attName=="x4") |
---|
| 185 | { parameter.dimension[9] = eval.Evaluate(attValue); } else |
---|
| 186 | if (attName=="alpha2") |
---|
| 187 | { parameter.dimension[10] = eval.Evaluate(attValue); } |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | parameter.dimension[0] *= 0.5*lunit; |
---|
| 191 | parameter.dimension[1] *= aunit; |
---|
| 192 | parameter.dimension[2] *= aunit; |
---|
| 193 | parameter.dimension[3] *= 0.5*lunit; |
---|
| 194 | parameter.dimension[4] *= 0.5*lunit; |
---|
| 195 | parameter.dimension[5] *= 0.5*lunit; |
---|
| 196 | parameter.dimension[6] *= aunit; |
---|
| 197 | parameter.dimension[7] *= 0.5*lunit; |
---|
| 198 | parameter.dimension[8] *= 0.5*lunit; |
---|
| 199 | parameter.dimension[9] *= 0.5*lunit; |
---|
| 200 | parameter.dimension[10] *= aunit; |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | void G4GDMLReadParamvol:: |
---|
| 204 | Tube_dimensionsRead( const xercesc::DOMElement* const element, |
---|
| 205 | G4GDMLParameterisation::PARAMETER& parameter ) |
---|
| 206 | { |
---|
| 207 | G4double lunit = 1.0; |
---|
| 208 | G4double aunit = 1.0; |
---|
| 209 | |
---|
| 210 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); |
---|
| 211 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 212 | |
---|
| 213 | for (XMLSize_t attribute_index=0; |
---|
| 214 | attribute_index<attributeCount; attribute_index++) |
---|
| 215 | { |
---|
| 216 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 217 | |
---|
| 218 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 219 | { continue; } |
---|
| 220 | |
---|
| 221 | const xercesc::DOMAttr* const attribute |
---|
| 222 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 223 | if (!attribute) |
---|
| 224 | { |
---|
| 225 | G4Exception("G4GDMLReadParamvol::Tube_dimensionsRead()", |
---|
| 226 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 227 | return; |
---|
| 228 | } |
---|
[987] | 229 | const G4String attName = Transcode(attribute->getName()); |
---|
| 230 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 231 | |
---|
| 232 | if (attName=="lunit") |
---|
| 233 | { lunit = eval.Evaluate(attValue); } else |
---|
| 234 | if (attName=="aunit") |
---|
| 235 | { aunit = eval.Evaluate(attValue); } else |
---|
| 236 | if (attName=="InR") |
---|
| 237 | { parameter.dimension[0] = eval.Evaluate(attValue); } else |
---|
| 238 | if (attName=="OutR") |
---|
| 239 | { parameter.dimension[1] = eval.Evaluate(attValue); } else |
---|
| 240 | if (attName=="hz") |
---|
| 241 | { parameter.dimension[2] = eval.Evaluate(attValue); } else |
---|
| 242 | if (attName=="StartPhi") |
---|
| 243 | { parameter.dimension[3] = eval.Evaluate(attValue); } else |
---|
| 244 | if (attName=="DeltaPhi") |
---|
| 245 | { parameter.dimension[4] = eval.Evaluate(attValue); } |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | parameter.dimension[0] *= lunit; |
---|
| 249 | parameter.dimension[1] *= lunit; |
---|
| 250 | parameter.dimension[2] *= 0.5*lunit; |
---|
| 251 | parameter.dimension[3] *= aunit; |
---|
| 252 | parameter.dimension[4] *= aunit; |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | void G4GDMLReadParamvol:: |
---|
| 256 | Cone_dimensionsRead( const xercesc::DOMElement* const element, |
---|
| 257 | G4GDMLParameterisation::PARAMETER& parameter ) |
---|
| 258 | { |
---|
| 259 | G4double lunit = 1.0; |
---|
| 260 | G4double aunit = 1.0; |
---|
| 261 | |
---|
| 262 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); |
---|
| 263 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 264 | |
---|
| 265 | for (XMLSize_t attribute_index=0; |
---|
| 266 | attribute_index<attributeCount; attribute_index++) |
---|
| 267 | { |
---|
| 268 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 269 | |
---|
| 270 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 271 | { continue; } |
---|
| 272 | |
---|
| 273 | const xercesc::DOMAttr* const attribute |
---|
| 274 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 275 | if (!attribute) |
---|
| 276 | { |
---|
| 277 | G4Exception("G4GDMLReadParamvol::Cone_dimensionsRead()", |
---|
| 278 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 279 | return; |
---|
| 280 | } |
---|
[987] | 281 | const G4String attName = Transcode(attribute->getName()); |
---|
| 282 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 283 | |
---|
| 284 | if (attName=="lunit") |
---|
| 285 | { lunit = eval.Evaluate(attValue); } else |
---|
| 286 | if (attName=="aunit") |
---|
| 287 | { aunit = eval.Evaluate(attValue); } else |
---|
| 288 | if (attName=="rmin1") |
---|
| 289 | { parameter.dimension[0] = eval.Evaluate(attValue); } else |
---|
| 290 | if (attName=="rmax1") |
---|
| 291 | { parameter.dimension[1] = eval.Evaluate(attValue); } else |
---|
| 292 | if (attName=="rmin2") |
---|
| 293 | { parameter.dimension[2] = eval.Evaluate(attValue); } else |
---|
| 294 | if (attName=="rmax2") |
---|
| 295 | { parameter.dimension[3] = eval.Evaluate(attValue); } else |
---|
| 296 | if (attName=="z") |
---|
| 297 | { parameter.dimension[4] = eval.Evaluate(attValue); } else |
---|
| 298 | if (attName=="startphi") |
---|
| 299 | { parameter.dimension[5] = eval.Evaluate(attValue); } else |
---|
| 300 | if (attName=="deltaphi") |
---|
| 301 | { parameter.dimension[6] = eval.Evaluate(attValue); } |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | parameter.dimension[0] *= lunit; |
---|
| 305 | parameter.dimension[1] *= lunit; |
---|
| 306 | parameter.dimension[2] *= lunit; |
---|
| 307 | parameter.dimension[3] *= lunit; |
---|
| 308 | parameter.dimension[4] *= 0.5*lunit; |
---|
| 309 | parameter.dimension[5] *= aunit; |
---|
| 310 | parameter.dimension[6] *= aunit; |
---|
| 311 | } |
---|
| 312 | |
---|
| 313 | void G4GDMLReadParamvol:: |
---|
| 314 | Sphere_dimensionsRead( const xercesc::DOMElement* const element, |
---|
| 315 | G4GDMLParameterisation::PARAMETER& parameter ) |
---|
| 316 | { |
---|
| 317 | G4double lunit = 1.0; |
---|
| 318 | G4double aunit = 1.0; |
---|
| 319 | |
---|
| 320 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); |
---|
| 321 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 322 | |
---|
| 323 | for (XMLSize_t attribute_index=0; |
---|
| 324 | attribute_index<attributeCount; attribute_index++) |
---|
| 325 | { |
---|
| 326 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 327 | |
---|
| 328 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 329 | { continue; } |
---|
| 330 | |
---|
| 331 | const xercesc::DOMAttr* const attribute |
---|
| 332 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 333 | if (!attribute) |
---|
| 334 | { |
---|
| 335 | G4Exception("G4GDMLReadParamvol::Sphere_dimensionsRead()", |
---|
| 336 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 337 | return; |
---|
| 338 | } |
---|
[987] | 339 | const G4String attName = Transcode(attribute->getName()); |
---|
| 340 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 341 | |
---|
| 342 | if (attName=="lunit") |
---|
| 343 | { lunit = eval.Evaluate(attValue); } else |
---|
| 344 | if (attName=="aunit") |
---|
| 345 | { aunit = eval.Evaluate(attValue); } else |
---|
| 346 | if (attName=="rmin") |
---|
| 347 | { parameter.dimension[0] = eval.Evaluate(attValue); } else |
---|
| 348 | if (attName=="rmax") |
---|
| 349 | { parameter.dimension[1] = eval.Evaluate(attValue); } else |
---|
| 350 | if (attName=="startphi") |
---|
| 351 | { parameter.dimension[2] = eval.Evaluate(attValue); } else |
---|
| 352 | if (attName=="deltaphi") |
---|
| 353 | { parameter.dimension[3] = eval.Evaluate(attValue); } else |
---|
| 354 | if (attName=="starttheta") |
---|
| 355 | { parameter.dimension[4] = eval.Evaluate(attValue); } else |
---|
| 356 | if (attName=="deltatheta") |
---|
| 357 | { parameter.dimension[5] = eval.Evaluate(attValue); } |
---|
| 358 | } |
---|
| 359 | |
---|
| 360 | parameter.dimension[0] *= lunit; |
---|
| 361 | parameter.dimension[1] *= lunit; |
---|
| 362 | parameter.dimension[2] *= aunit; |
---|
| 363 | parameter.dimension[3] *= aunit; |
---|
| 364 | parameter.dimension[4] *= aunit; |
---|
| 365 | parameter.dimension[5] *= aunit; |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | void G4GDMLReadParamvol:: |
---|
| 369 | Orb_dimensionsRead( const xercesc::DOMElement* const element, |
---|
| 370 | G4GDMLParameterisation::PARAMETER& parameter ) |
---|
| 371 | { |
---|
| 372 | G4double lunit = 1.0; |
---|
| 373 | |
---|
| 374 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); |
---|
| 375 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 376 | |
---|
| 377 | for (XMLSize_t attribute_index=0; |
---|
| 378 | attribute_index<attributeCount; attribute_index++) |
---|
| 379 | { |
---|
| 380 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 381 | |
---|
| 382 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 383 | { continue; } |
---|
| 384 | |
---|
| 385 | const xercesc::DOMAttr* const attribute |
---|
| 386 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 387 | if (!attribute) |
---|
| 388 | { |
---|
| 389 | G4Exception("G4GDMLReadParamvol::Orb_dimensionsRead()", |
---|
| 390 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 391 | return; |
---|
| 392 | } |
---|
[987] | 393 | const G4String attName = Transcode(attribute->getName()); |
---|
| 394 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 395 | |
---|
| 396 | if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else |
---|
| 397 | if (attName=="r") { parameter.dimension[0] = eval.Evaluate(attValue); } |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | parameter.dimension[0] *= lunit; |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | void G4GDMLReadParamvol:: |
---|
| 404 | Torus_dimensionsRead( const xercesc::DOMElement* const element, |
---|
| 405 | G4GDMLParameterisation::PARAMETER& parameter ) |
---|
| 406 | { |
---|
| 407 | G4double lunit = 1.0; |
---|
| 408 | G4double aunit = 1.0; |
---|
| 409 | |
---|
| 410 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); |
---|
| 411 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 412 | |
---|
| 413 | for (XMLSize_t attribute_index=0; |
---|
| 414 | attribute_index<attributeCount; attribute_index++) |
---|
| 415 | { |
---|
| 416 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 417 | |
---|
| 418 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 419 | { continue; } |
---|
| 420 | |
---|
| 421 | const xercesc::DOMAttr* const attribute |
---|
| 422 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 423 | if (!attribute) |
---|
| 424 | { |
---|
| 425 | G4Exception("G4GDMLReadParamvol::Torus_dimensionsRead()", |
---|
| 426 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 427 | return; |
---|
| 428 | } |
---|
[987] | 429 | const G4String attName = Transcode(attribute->getName()); |
---|
| 430 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 431 | |
---|
| 432 | if (attName=="lunit") |
---|
| 433 | { lunit = eval.Evaluate(attValue); } else |
---|
| 434 | if (attName=="aunit") |
---|
| 435 | { aunit = eval.Evaluate(attValue); } else |
---|
| 436 | if (attName=="rmin") |
---|
| 437 | { parameter.dimension[0] = eval.Evaluate(attValue); } else |
---|
| 438 | if (attName=="rmax") |
---|
| 439 | { parameter.dimension[1] = eval.Evaluate(attValue); } else |
---|
| 440 | if (attName=="rtor") |
---|
| 441 | { parameter.dimension[2] = eval.Evaluate(attValue); } else |
---|
| 442 | if (attName=="startphi") |
---|
| 443 | { parameter.dimension[3] = eval.Evaluate(attValue); } else |
---|
| 444 | if (attName=="deltaphi") |
---|
| 445 | { parameter.dimension[4] = eval.Evaluate(attValue); } |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | parameter.dimension[0] *= lunit; |
---|
| 449 | parameter.dimension[1] *= lunit; |
---|
| 450 | parameter.dimension[2] *= lunit; |
---|
| 451 | parameter.dimension[3] *= aunit; |
---|
| 452 | parameter.dimension[4] *= aunit; |
---|
| 453 | } |
---|
| 454 | |
---|
| 455 | void G4GDMLReadParamvol:: |
---|
| 456 | Para_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); |
---|
[1347] | 475 | if (!attribute) |
---|
| 476 | { |
---|
| 477 | G4Exception("G4GDMLReadParamvol::Para_dimensionsRead()", |
---|
| 478 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 479 | return; |
---|
| 480 | } |
---|
[987] | 481 | const G4String attName = Transcode(attribute->getName()); |
---|
| 482 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 483 | |
---|
| 484 | if (attName=="lunit") |
---|
| 485 | { lunit = eval.Evaluate(attValue); } else |
---|
| 486 | if (attName=="aunit") |
---|
| 487 | { aunit = eval.Evaluate(attValue); } else |
---|
| 488 | if (attName=="x") |
---|
| 489 | { parameter.dimension[0] = eval.Evaluate(attValue); } else |
---|
| 490 | if (attName=="y") |
---|
| 491 | { parameter.dimension[1] = eval.Evaluate(attValue); } else |
---|
| 492 | if (attName=="z") |
---|
| 493 | { parameter.dimension[2] = eval.Evaluate(attValue); } else |
---|
| 494 | if (attName=="alpha") |
---|
| 495 | { parameter.dimension[3] = eval.Evaluate(attValue); } else |
---|
| 496 | if (attName=="theta") |
---|
| 497 | { parameter.dimension[4] = eval.Evaluate(attValue); } else |
---|
| 498 | if (attName=="phi") |
---|
| 499 | { parameter.dimension[5] = eval.Evaluate(attValue); } |
---|
| 500 | } |
---|
| 501 | |
---|
| 502 | parameter.dimension[0] = 0.5*lunit; |
---|
| 503 | parameter.dimension[1] = 0.5*lunit; |
---|
| 504 | parameter.dimension[2] = 0.5*lunit; |
---|
| 505 | parameter.dimension[3] = aunit; |
---|
| 506 | parameter.dimension[4] = aunit; |
---|
| 507 | parameter.dimension[5] = aunit; |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | void G4GDMLReadParamvol:: |
---|
| 511 | Hype_dimensionsRead( const xercesc::DOMElement* const element, |
---|
| 512 | G4GDMLParameterisation::PARAMETER& parameter ) |
---|
| 513 | { |
---|
| 514 | G4double lunit = 1.0; |
---|
| 515 | G4double aunit = 1.0; |
---|
| 516 | |
---|
| 517 | const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); |
---|
| 518 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 519 | |
---|
| 520 | for (XMLSize_t attribute_index=0; |
---|
| 521 | attribute_index<attributeCount; attribute_index++) |
---|
| 522 | { |
---|
| 523 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 524 | |
---|
| 525 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 526 | { continue; } |
---|
| 527 | |
---|
| 528 | const xercesc::DOMAttr* const attribute |
---|
| 529 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 530 | if (!attribute) |
---|
| 531 | { |
---|
| 532 | G4Exception("G4GDMLReadParamvol::Hype_dimensionsRead()", |
---|
| 533 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 534 | return; |
---|
| 535 | } |
---|
[987] | 536 | const G4String attName = Transcode(attribute->getName()); |
---|
| 537 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 538 | |
---|
| 539 | if (attName=="lunit") |
---|
| 540 | { lunit = eval.Evaluate(attValue); } else |
---|
| 541 | if (attName=="aunit") |
---|
| 542 | { aunit = eval.Evaluate(attValue); } else |
---|
| 543 | if (attName=="rmin") |
---|
| 544 | { parameter.dimension[0] = eval.Evaluate(attValue); } else |
---|
| 545 | if (attName=="rmax") |
---|
| 546 | { parameter.dimension[1] = eval.Evaluate(attValue); } else |
---|
| 547 | if (attName=="inst") |
---|
| 548 | { parameter.dimension[2] = eval.Evaluate(attValue); } else |
---|
| 549 | if (attName=="outst") |
---|
| 550 | { parameter.dimension[3] = eval.Evaluate(attValue); } else |
---|
| 551 | if (attName=="z") |
---|
| 552 | { parameter.dimension[4] = eval.Evaluate(attValue); } |
---|
| 553 | } |
---|
| 554 | |
---|
| 555 | parameter.dimension[0] = lunit; |
---|
| 556 | parameter.dimension[1] = lunit; |
---|
| 557 | parameter.dimension[2] = aunit; |
---|
| 558 | parameter.dimension[3] = aunit; |
---|
| 559 | parameter.dimension[4] = 0.5*lunit; |
---|
| 560 | } |
---|
| 561 | |
---|
| 562 | void G4GDMLReadParamvol:: |
---|
| 563 | ParametersRead(const xercesc::DOMElement* const element) { |
---|
| 564 | |
---|
| 565 | G4ThreeVector rotation(0.0,0.0,0.0); |
---|
| 566 | G4ThreeVector position(0.0,0.0,0.0); |
---|
| 567 | |
---|
| 568 | G4GDMLParameterisation::PARAMETER parameter; |
---|
| 569 | |
---|
| 570 | for (xercesc::DOMNode* iter = element->getFirstChild(); |
---|
| 571 | iter != 0; iter = iter->getNextSibling()) |
---|
| 572 | { |
---|
| 573 | if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } |
---|
| 574 | |
---|
| 575 | const xercesc::DOMElement* const child |
---|
| 576 | = dynamic_cast<xercesc::DOMElement*>(iter); |
---|
[1347] | 577 | if (!child) |
---|
| 578 | { |
---|
| 579 | G4Exception("G4GDMLReadParamvol::ParametersRead()", |
---|
| 580 | "InvalidRead", FatalException, "No child found!"); |
---|
| 581 | return; |
---|
| 582 | } |
---|
[987] | 583 | const G4String tag = Transcode(child->getTagName()); |
---|
| 584 | if (tag=="rotation") { VectorRead(child,rotation); } else |
---|
| 585 | if (tag=="position") { VectorRead(child,position); } else |
---|
| 586 | if (tag=="positionref") |
---|
| 587 | { position = GetPosition(GenerateName(RefRead(child))); } else |
---|
| 588 | if (tag=="rotationref") |
---|
| 589 | { rotation = GetRotation(GenerateName(RefRead(child))); } else |
---|
| 590 | if (tag=="box_dimensions") { Box_dimensionsRead(child,parameter); } else |
---|
| 591 | if (tag=="trd_dimensions") { Trd_dimensionsRead(child,parameter); } else |
---|
| 592 | if (tag=="trap_dimensions") { Trap_dimensionsRead(child,parameter); } else |
---|
| 593 | if (tag=="tube_dimensions") { Tube_dimensionsRead(child,parameter); } else |
---|
| 594 | if (tag=="cone_dimensions") { Cone_dimensionsRead(child,parameter); } else |
---|
| 595 | if (tag=="sphere_dimensions") { Cone_dimensionsRead(child,parameter); } else |
---|
| 596 | if (tag=="orb_dimensions") { Cone_dimensionsRead(child,parameter); } else |
---|
| 597 | if (tag=="torus_dimensions") { Cone_dimensionsRead(child,parameter); } else |
---|
| 598 | if (tag=="para_dimensions") { Cone_dimensionsRead(child,parameter); } else |
---|
| 599 | if (tag=="hype_dimensions") { Hype_dimensionsRead(child,parameter); } |
---|
| 600 | else |
---|
| 601 | { |
---|
| 602 | G4String error_msg = "Unknown tag in parameters: " + tag; |
---|
| 603 | G4Exception("G4GDMLReadParamvol::ParametersRead()", "ReadError", |
---|
| 604 | FatalException, error_msg); |
---|
| 605 | } |
---|
| 606 | } |
---|
| 607 | |
---|
| 608 | parameter.pRot = new G4RotationMatrix(); |
---|
| 609 | |
---|
| 610 | parameter.pRot->rotateX(rotation.x()); |
---|
| 611 | parameter.pRot->rotateY(rotation.y()); |
---|
| 612 | parameter.pRot->rotateZ(rotation.z()); |
---|
| 613 | |
---|
| 614 | parameter.position = position; |
---|
| 615 | |
---|
| 616 | parameterisation->AddParameter(parameter); |
---|
| 617 | } |
---|
| 618 | |
---|
| 619 | void G4GDMLReadParamvol:: |
---|
| 620 | ParameterisedRead(const xercesc::DOMElement* const element) |
---|
| 621 | { |
---|
| 622 | for (xercesc::DOMNode* iter = element->getFirstChild(); |
---|
| 623 | iter != 0; iter = iter->getNextSibling()) |
---|
| 624 | { |
---|
| 625 | if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } |
---|
| 626 | |
---|
| 627 | const xercesc::DOMElement* const child |
---|
| 628 | = dynamic_cast<xercesc::DOMElement*>(iter); |
---|
[1347] | 629 | if (!child) |
---|
| 630 | { |
---|
| 631 | G4Exception("G4GDMLReadParamvol::ParameterisedRead()", |
---|
| 632 | "InvalidRead", FatalException, "No child found!"); |
---|
| 633 | return; |
---|
| 634 | } |
---|
[987] | 635 | const G4String tag = Transcode(child->getTagName()); |
---|
| 636 | |
---|
| 637 | if (tag=="parameters") |
---|
| 638 | { |
---|
| 639 | G4double number = 1; |
---|
| 640 | const xercesc::DOMNamedNodeMap* const attributes |
---|
| 641 | = element->getAttributes(); |
---|
| 642 | XMLSize_t attributeCount = attributes->getLength(); |
---|
| 643 | for (XMLSize_t attribute_index=0; |
---|
| 644 | attribute_index<attributeCount; attribute_index++) |
---|
| 645 | { |
---|
| 646 | xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
---|
| 647 | |
---|
| 648 | if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
---|
| 649 | { continue; } |
---|
| 650 | |
---|
| 651 | const xercesc::DOMAttr* const attribute |
---|
| 652 | = dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
---|
[1347] | 653 | if (!attribute) |
---|
| 654 | { |
---|
| 655 | G4Exception("G4GDMLReadParamvol::ParameterisedRead()", |
---|
| 656 | "InvalidRead", FatalException, "No attribute found!"); |
---|
| 657 | return; |
---|
| 658 | } |
---|
[987] | 659 | const G4String attName = Transcode(attribute->getName()); |
---|
| 660 | const G4String attValue = Transcode(attribute->getValue()); |
---|
| 661 | |
---|
| 662 | if (attName=="number") { number = eval.Evaluate(attValue); } |
---|
| 663 | } |
---|
| 664 | ParametersRead(child); |
---|
| 665 | } |
---|
| 666 | else |
---|
| 667 | { |
---|
| 668 | if (tag=="loop") { LoopRead(child,&G4GDMLRead::Paramvol_contentRead); } |
---|
| 669 | } |
---|
| 670 | } |
---|
| 671 | } |
---|
| 672 | |
---|
| 673 | void G4GDMLReadParamvol:: |
---|
| 674 | Paramvol_contentRead(const xercesc::DOMElement* const element) |
---|
| 675 | { |
---|
| 676 | for (xercesc::DOMNode* iter = element->getFirstChild(); |
---|
| 677 | iter != 0; iter = iter->getNextSibling()) |
---|
| 678 | { |
---|
| 679 | if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } |
---|
| 680 | |
---|
| 681 | const xercesc::DOMElement* const child |
---|
| 682 | = dynamic_cast<xercesc::DOMElement*>(iter); |
---|
[1347] | 683 | if (!child) |
---|
| 684 | { |
---|
| 685 | G4Exception("G4GDMLReadParamvol::Paramvol_contentRead()", "InvalidRead", |
---|
| 686 | FatalException, "No child found!"); |
---|
| 687 | return; |
---|
| 688 | } |
---|
[987] | 689 | const G4String tag = Transcode(child->getTagName()); |
---|
| 690 | if (tag=="parameterised_position_size") { ParameterisedRead(child); }else |
---|
| 691 | if (tag=="loop") { LoopRead(child,&G4GDMLRead::Paramvol_contentRead); } |
---|
| 692 | } |
---|
| 693 | } |
---|
| 694 | |
---|
| 695 | void G4GDMLReadParamvol:: |
---|
| 696 | ParamvolRead(const xercesc::DOMElement* const element, G4LogicalVolume* mother) |
---|
| 697 | { |
---|
| 698 | G4String volumeref; |
---|
| 699 | |
---|
| 700 | parameterisation = new G4GDMLParameterisation(); |
---|
| 701 | |
---|
| 702 | for (xercesc::DOMNode* iter = element->getFirstChild(); |
---|
| 703 | iter != 0; iter = iter->getNextSibling()) |
---|
| 704 | { |
---|
| 705 | if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } |
---|
| 706 | |
---|
| 707 | const xercesc::DOMElement* const child |
---|
| 708 | = dynamic_cast<xercesc::DOMElement*>(iter); |
---|
[1347] | 709 | if (!child) |
---|
| 710 | { |
---|
| 711 | G4Exception("G4GDMLReadParamvol::ParamvolRead()", "InvalidRead", |
---|
| 712 | FatalException, "No child found!"); |
---|
| 713 | return; |
---|
| 714 | } |
---|
[987] | 715 | const G4String tag = Transcode(child->getTagName()); |
---|
| 716 | |
---|
| 717 | if (tag=="volumeref") { volumeref = RefRead(child); } |
---|
| 718 | |
---|
| 719 | } |
---|
| 720 | |
---|
| 721 | Paramvol_contentRead(element); |
---|
| 722 | |
---|
| 723 | G4LogicalVolume* logvol = GetVolume(GenerateName(volumeref)); |
---|
| 724 | |
---|
| 725 | if (parameterisation->GetSize()==0) |
---|
| 726 | { |
---|
| 727 | G4Exception("G4GDMLReadParamvol::ParamvolRead()", |
---|
| 728 | "ReadError", FatalException, |
---|
| 729 | "No parameters are defined in parameterised volume!"); |
---|
| 730 | } |
---|
| 731 | G4String pv_name = logvol->GetName() + "_param"; |
---|
| 732 | new G4PVParameterised(pv_name, logvol, mother, kUndefined, |
---|
| 733 | parameterisation->GetSize(), parameterisation, check); |
---|
| 734 | } |
---|