TGDMLParse.cxx

Go to the documentation of this file.
00001 /* @(#)root/gdml:$Id: TGDMLParse.cxx 37915 2011-01-31 16:41:12Z pcanal $ */
00002 // Author: Ben Lloyd 09/11/06
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 
00013 /*************************************************************************
00014 
00015 ____________________________________________________________________
00016 
00017 TGDMLParse Class
00018 
00019 --------------------------------------------------------------------
00020 
00021  This class contains the implementation of the GDML  parser associated to
00022  all the supported GDML elements. User should never need to explicitely 
00023  instaciate this class. It is internally used by the TGeoManager.
00024 
00025  Each element process has a 'Binding' to ROOT. The 'binding' is specific 
00026  mapping of GDML elements (materials, solids, etc) to specific objects which 
00027  should be instanciated by the converted. In the present case (ROOT) the 
00028  binding is implemented at the near the end of each process function. Most 
00029  bindings follow similar format, dependent on what is being added to the 
00030  geometry.
00031 
00032  This file also contains the implementation of the TGDMLRefl class. This is 
00033  just a small helper class used internally by the 'reflection' method (for 
00034  reflected solids).
00035 
00036  The presently supported list of TGeo classes is the following:
00037 
00038  Materials:
00039  TGeoElement
00040  TGeoMaterial
00041  TGeoMixture
00042 
00043  Solids:
00044  TGeoBBox
00045  TGeoArb8
00046  TGeoTubeSeg
00047  TGeoConeSeg
00048  TGeoCtub
00049  TGeoPcon
00050  TGeoTrap
00051  TGeoGtra
00052  TGeoTrd2
00053  TGeoSphere
00054  TGeoPara
00055  TGeoTorus
00056  TGeoHype
00057  TGeoPgon
00058  TGeoXtru
00059  TGeoEltu
00060  TGeoParaboloid
00061  TGeoCompositeShape (subtraction, union, intersection)
00062 
00063  Approximated Solids:
00064  Ellipsoid (approximated to a TGeoBBox)
00065 
00066  Geometry:
00067  TGeoVolume
00068  TGeoVolumeAssembly
00069  divisions
00070  reflection
00071 
00072 When most solids or volumes are added to the geometry they 
00073 
00074 
00075  Whenever a new element is added to GDML schema, this class needs to be extended.
00076  The appropriate method (process) needs to be implemented, as well as the new
00077  element process then needs to be linked thru the function TGDMLParse
00078 
00079  For any question or remarks concerning this code, please send an email to
00080  ben.lloyd@cern.ch
00081 
00082 ****************************************************************************/
00083 
00084 #include "TGeoManager.h"
00085 #include "TGeoMatrix.h"
00086 #include "TXMLEngine.h"
00087 #include "TGeoVolume.h"
00088 #include "TGeoBBox.h"
00089 #include "TGeoParaboloid.h"
00090 #include "TGeoArb8.h"
00091 #include "TGeoTube.h"
00092 #include "TGeoCone.h"
00093 #include "TGeoTrd2.h"
00094 #include "TGeoPcon.h"
00095 #include "TGeoPgon.h"
00096 #include "TGeoSphere.h"
00097 #include "TGeoTorus.h"
00098 #include "TGeoPara.h"
00099 #include "TGeoHype.h"
00100 #include "TGeoEltu.h"
00101 #include "TGeoXtru.h"
00102 #include "TGeoScaledShape.h"
00103 #include "TGeoVolume.h"
00104 #include "TROOT.h"
00105 #include "TMath.h"
00106 #include "TGeoMaterial.h"
00107 #include "TGeoBoolNode.h"
00108 #include "TGeoMedium.h"
00109 #include "TGeoElement.h"
00110 #include "TGeoShape.h"
00111 #include "TGeoCompositeShape.h"
00112 #include "TGDMLParse.h"
00113 #include <stdlib.h>
00114 #include <string>
00115 
00116 ClassImp(TGDMLParse)
00117 
00118 //_________________________________________________________________
00119 TGeoVolume* TGDMLParse::GDMLReadFile(const char* filename)
00120 {
00121   //creates the new instance of the XMLEngine called 'gdml', using the filename >>
00122   //then parses the file and creates the DOM tree. Then passes the DOM to the 
00123   //next function to translate it. 
00124 
00125    // First create engine
00126    TXMLEngine* gdml = new TXMLEngine;
00127    gdml->SetSkipComments(kTRUE);
00128    
00129    // Now try to parse xml file
00130    XMLDocPointer_t gdmldoc = gdml->ParseFile(filename);
00131    if (gdmldoc==0) {
00132       delete gdml;
00133       return 0;  
00134    }
00135    else {
00136 
00137       // take access to main node   
00138       XMLNodePointer_t mainnode = gdml->DocGetRootElement(gdmldoc);
00139    
00140       fFileEngine[fFILENO] = gdml;
00141       fStartFile = filename;
00142       fCurrentFile = filename;
00143 
00144       // display recursively all nodes and subnodes
00145       ParseGDML(gdml, mainnode);
00146 
00147       // Release memory before exit
00148       gdml->FreeDoc(gdmldoc);
00149       delete gdml;
00150    
00151    }
00152    return fWorld;
00153    
00154 }
00155 
00156 //________________________________________________________________
00157 const char* TGDMLParse::ParseGDML(TXMLEngine* gdml, XMLNodePointer_t node) 
00158 {
00159   //this function recursively moves thru the DOM tree of the GDML file. It checks for
00160   //key words along the way and if a key word is found it calls the corresponding
00161   //function to interpret the node.
00162     
00163    XMLAttrPointer_t attr = gdml->GetFirstAttr(node);  
00164    const char* name = gdml->GetNodeName(node);
00165    XMLNodePointer_t parentn = gdml->GetParent(node);
00166    const char* parent = gdml->GetNodeName(parentn);
00167    
00168    const char* posistr = "position";
00169    const char* setustr = "setup";
00170    const char* consstr = "constant";
00171    const char* varistr = "variable";
00172    const char* rotastr = "rotation";
00173    const char* scalstr = "scale";
00174    const char* elemstr = "element";
00175    const char* istpstr = "isotope";
00176    const char* matestr = "material";
00177    const char* volustr = "volume";
00178    const char* assestr = "assembly";
00179    const char* twtrstr = "twistTrap";
00180    const char* cutTstr = "cutTube";
00181    const char* bboxstr = "box";
00182    const char* xtrustr = "xtru";
00183    const char* arb8str = "arb8";
00184    const char* tubestr = "tube";
00185    const char* conestr = "cone";
00186    const char* polystr = "polycone";
00187    const char* hypestr = "hype";
00188    const char* trapstr = "trap";
00189    const char* trdstr = "trd";
00190    const char* sphestr = "sphere";
00191    const char* orbstr = "orb";
00192    const char* parastr = "para";
00193    const char* torustr = "torus";
00194    const char* hedrstr = "polyhedra";
00195    const char* eltustr = "eltube";
00196    const char* subtstr = "subtraction";
00197    const char* uniostr = "union";
00198    const char* parbstr = "paraboloid";
00199    const char* intestr = "intersection";
00200    const char* reflstr = "reflectedSolid";
00201    const char* ellistr = "ellipsoid";
00202    Bool_t hasIsotopes;
00203    
00204    if ((strcmp(name, posistr)) == 0){ 
00205       node = PosProcess(gdml, node, attr);
00206    } else if ((strcmp(name, rotastr)) == 0){ 
00207       node = RotProcess(gdml, node, attr);
00208    } else if ((strcmp(name, scalstr)) == 0){ 
00209       node = SclProcess(gdml, node, attr);
00210    } else if ((strcmp(name, setustr)) == 0){ 
00211       node = TopProcess(gdml, node);
00212    } else if ((strcmp(name, consstr)) == 0){ 
00213       node = ConProcess(gdml, node, attr);
00214    } else if ((strcmp(name, varistr)) == 0){ 
00215       node = ConProcess(gdml, node, attr);
00216    } else if ((strcmp(name,elemstr)==0) && !gdml->HasAttr(node, "Z")) {
00217       hasIsotopes = kTRUE;
00218       node = EleProcess(gdml, node, parentn, hasIsotopes);   
00219    } else if (((strcmp(name, "atom")) == 0) && ((strcmp(parent, elemstr)) == 0)){
00220       hasIsotopes = kFALSE; 
00221       node = EleProcess(gdml, node, parentn, hasIsotopes);
00222    } else if (((strcmp(name, "atom")) == 0) && ((strcmp(parent, istpstr)) == 0)){ 
00223       node = IsoProcess(gdml, node, parentn);
00224    } else if ((strcmp(name, matestr)) == 0){ 
00225       if(gdml->HasAttr(node, "Z")) {
00226          int z = 1;
00227          node = MatProcess(gdml, node, attr, z);
00228       } else {
00229          int z = 0;
00230          node = MatProcess(gdml, node, attr, z);
00231       }
00232    } else if ((strcmp(name, volustr)) == 0){ 
00233       node = VolProcess(gdml, node);
00234    } else if ((strcmp(name, bboxstr)) == 0){ 
00235       node = Box(gdml, node, attr);
00236    } else if ((strcmp(name, ellistr)) == 0){
00237       node = Ellipsoid(gdml, node, attr);
00238    } else if ((strcmp(name, cutTstr)) == 0){ 
00239       node = CutTube(gdml, node, attr);
00240    } else if ((strcmp(name, arb8str)) == 0){ 
00241       node = Arb8(gdml, node, attr);
00242    } else if ((strcmp(name, tubestr)) == 0){ 
00243       node = Tube(gdml, node, attr);
00244    } else if ((strcmp(name, conestr)) == 0){ 
00245       node = Cone(gdml, node, attr);
00246    } else if ((strcmp(name, polystr)) == 0){ 
00247       node = Polycone(gdml, node, attr);
00248    } else if ((strcmp(name, trapstr)) == 0){ 
00249       node = Trap(gdml, node, attr);
00250    } else if ((strcmp(name, trdstr)) == 0){ 
00251       node = Trd(gdml, node, attr);
00252    } else if ((strcmp(name, sphestr)) == 0){ 
00253       node = Sphere(gdml, node, attr);
00254    } else if ((strcmp(name, xtrustr)) == 0){ 
00255       node = Xtru(gdml, node, attr);
00256    } else if ((strcmp(name, twtrstr)) == 0){ 
00257       node = TwistTrap(gdml, node, attr);
00258    } else if ((strcmp(name, hypestr)) == 0){ 
00259       node = Hype(gdml, node, attr);
00260    } else if ((strcmp(name, orbstr)) == 0){ 
00261       node = Orb(gdml, node, attr);
00262    } else if ((strcmp(name, parastr)) == 0){ 
00263       node = Para(gdml, node, attr);
00264    } else if ((strcmp(name, torustr)) == 0){ 
00265       node = Torus(gdml, node, attr);
00266    } else if ((strcmp(name, eltustr)) == 0){ 
00267       node = ElTube(gdml, node, attr);
00268    } else if ((strcmp(name, hedrstr)) == 0){ 
00269       node = Polyhedra(gdml, node, attr);
00270    } else if ((strcmp(name, parbstr)) == 0){ 
00271       node = Paraboloid(gdml, node, attr); 
00272    } else if ((strcmp(name, subtstr)) == 0){ 
00273       node = BooSolid(gdml, node, attr, 1);
00274    } else if ((strcmp(name, intestr)) == 0){ 
00275       node = BooSolid(gdml, node, attr, 2);
00276    } else if ((strcmp(name, uniostr)) == 0){ 
00277       node = BooSolid(gdml, node, attr, 3);
00278    } else if ((strcmp(name, reflstr)) == 0){ 
00279       node = Reflection(gdml, node, attr);
00280    } else if ((strcmp(name, assestr)) == 0){ 
00281       node = AssProcess(gdml, node);
00282    //CHECK FOR TAGS NOT SUPPORTED
00283    } else if (((strcmp(name, "gdml")) != 0) && ((strcmp(name, "define")) != 0) && 
00284       ((strcmp(name, "element")) != 0) && ((strcmp(name, "materials")) != 0) &&  
00285       ((strcmp(name, "solids")) != 0) &&  ((strcmp(name, "structure")) != 0) &&  
00286       ((strcmp(name, "zplane")) != 0) &&  ((strcmp(name, "first")) != 0) &&
00287       ((strcmp(name, "second")) != 0) &&  ((strcmp(name, "twoDimVertex")) != 0) &&
00288       ((strcmp(name, "firstposition")) != 0) &&  ((strcmp(name, "firstpositionref")) != 0) &&
00289       ((strcmp(name, "firstrotation")) != 0) &&  ((strcmp(name, "firstrotationref")) != 0) &&
00290       ((strcmp(name, "section")) != 0) &&  ((strcmp(name, "world")) != 0) &&
00291       ((strcmp(name, "isotope")) != 0)){
00292       std::cout << "Error: Unsupported GDML Tag Used :" << name << ". Please Check Geometry/Schema." << std::endl;
00293    }
00294    
00295    // Check for Child node - if present call this funct. recursively until no more
00296    
00297    XMLNodePointer_t child = gdml->GetChild(node);
00298    while (child!=0) {
00299       ParseGDML(gdml, child); 
00300       child = gdml->GetNext(child);
00301    }
00302    
00303    return fWorldName;
00304 
00305 }
00306 
00307 //____________________________________________________________
00308 double TGDMLParse::Evaluate(const char* evalline) {
00309 
00310    //takes a string containing a mathematical expression and returns the value of the expression
00311 
00312    return TFormula("TFormula",evalline).Eval(0);
00313 }
00314 
00315 //____________________________________________________________
00316 Int_t TGDMLParse::SetAxis(const char* axisString)
00317 {
00318    //When using the 'divide' process in the geometry this function
00319    //sets the variable 'axis' depending on what is specified.
00320 
00321    Int_t axis = 0;
00322 
00323    if((strcmp(axisString, "kXAxis")) == 0){
00324       axis = 1;
00325    } else if((strcmp(axisString, "kYAxis")) == 0){
00326       axis = 2;
00327    } else if((strcmp(axisString, "kZAxis")) == 0){
00328       axis = 3;
00329    } else if((strcmp(axisString, "kRho")) == 0){
00330       axis = 1;
00331    } else if((strcmp(axisString, "kPhi")) == 0){
00332       axis = 2;
00333    }
00334    
00335    return axis;
00336 }
00337 
00338 //____________________________________________________________
00339 const char* TGDMLParse::NameShort(const char* name)
00340 {
00341    //this function looks thru a string for the chars '0x' next to
00342    //each other, when it finds this, it calls another function to strip
00343    //the hex address.   It does this recursively until the end of the 
00344    //string is reached, returning a string without any hex addresses.
00345    static TString stripped;
00346    stripped = name;
00347    Int_t index = -1;
00348    while ((index = stripped.Index("0x")) >= 0) {
00349       stripped = stripped(0,index)+stripped(index+10, stripped.Length());
00350    }   
00351    return stripped.Data();   
00352 }
00353 
00354 //________________________________________________________
00355 XMLNodePointer_t TGDMLParse::ConProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
00356 {
00357    //In the define section of the GDML file, constants can be declared.
00358    //when the constant keyword is found, this function is called, and the
00359    //name and value of the constant is stored in the "fformvec" vector as
00360    //a TFormula class, representing a constant function
00361 
00362    TString name = "";
00363    TString value = "";
00364    TString tempattr;
00365    
00366    while (attr!=0) {
00367       tempattr = gdml->GetAttrName(attr);
00368       tempattr.ToLower();
00369       
00370       if(tempattr == "name") { 
00371          name = gdml->GetAttrValue(attr);
00372       }
00373       if(tempattr == "value") { 
00374          value = gdml->GetAttrValue(attr);
00375       }      
00376       attr = gdml->GetNextAttr(attr);   
00377    }
00378       
00379    if((strcmp(fCurrentFile,fStartFile)) != 0){
00380       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
00381    }
00382 
00383    fformvec.push_back(new TFormula(name,value));
00384 
00385    return node;
00386 }
00387 //__________________________________________________________
00388 const char* TGDMLParse::GetScale(const char* unit)
00389 {
00390    //Throughout the GDML file, a unit can de specified.   Whether it be
00391    //angular or linear, values can be used as well as abbreviations such as
00392    // 'mm' or 'deg'. This function is passed the specified unit and if it is 
00393    //found, replaces it with the appropriate value.
00394    
00395    const char* retunit = "";
00396    
00397    if(strcmp(unit, "mm") == 0){
00398       retunit = "0.1";
00399    }
00400    else if(strcmp(unit, "milimeter") == 0){
00401       retunit = "0.1";
00402    }
00403    else if(strcmp(unit, "cm") == 0){
00404       retunit = "1.0";
00405    }
00406    else if(strcmp(unit, "centimeter") == 0){
00407       retunit = "1.0";
00408    }
00409    else if(strcmp(unit, "m") == 0){
00410       retunit = "100.0";
00411    }
00412    else if(strcmp(unit, "meter") == 0){
00413       retunit = "100.0";
00414    }
00415    else if(strcmp(unit, "km") == 0){
00416       retunit = "100000.0";
00417    }
00418    else if(strcmp(unit, "kilometer") == 0){
00419       retunit = "100000.0";
00420    }
00421    else if(strcmp(unit, "rad") == 0){
00422       retunit = TString::Format("%f", TMath::RadToDeg());
00423    }
00424    else if(strcmp(unit, "radian") == 0){
00425       retunit = TString::Format("%f", TMath::RadToDeg());
00426    }
00427    else if(strcmp(unit, "deg") == 0){
00428       retunit = "1.0";
00429    }
00430    else if(strcmp(unit, "degree") == 0){
00431       retunit = "1.0";
00432    }
00433    else if(strcmp(unit, "pi") == 0){
00434       retunit = "pi";
00435    }
00436    else if(strcmp(unit, "avogadro") == 0){
00437       retunit = TString::Format("%f", TMath::Na());
00438    }
00439    else{
00440       retunit = "0";
00441    }
00442    return retunit;
00443    
00444 }
00445 
00446 //____________________________________________________________
00447 XMLNodePointer_t TGDMLParse::PosProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
00448 {
00449    //In the define section of the GDML file, positions can be declared.
00450    //when the position keyword is found, this function is called, and the
00451    //name and values of the position are converted into type TGeoPosition 
00452    //and stored in fposmap map using the name as its key. This function 
00453    //can also be called when declaring solids.
00454    
00455    TString lunit = "mm"; 
00456    TString xpos = "0"; 
00457    TString ypos = "0"; 
00458    TString zpos = "0"; 
00459    TString name = "0";
00460    TString tempattr; 
00461    
00462    while (attr!=0) {
00463       
00464       tempattr = gdml->GetAttrName(attr);
00465       tempattr.ToLower();
00466       
00467       if(tempattr == "name") { 
00468          name = gdml->GetAttrValue(attr);
00469       }
00470       else if(tempattr == "x") { 
00471          xpos = gdml->GetAttrValue(attr);
00472       }
00473       else if(tempattr == "y") {
00474          ypos = gdml->GetAttrValue(attr);
00475       }
00476       else if (tempattr == "z") {
00477          zpos = gdml->GetAttrValue(attr);
00478       }
00479       else if (tempattr == "unit") {
00480          lunit = gdml->GetAttrValue(attr);
00481       }
00482       
00483       attr = gdml->GetNextAttr(attr);   
00484    }
00485 
00486    if((strcmp(fCurrentFile,fStartFile)) != 0){
00487       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
00488    }
00489 
00490    TString xline = "";
00491    TString yline = "";
00492    TString zline = "";
00493    TString retunit;
00494    
00495    retunit = GetScale(lunit);
00496    
00497    xline = TString::Format("%s*%s", xpos.Data(), retunit.Data());
00498    yline = TString::Format("%s*%s", ypos.Data(), retunit.Data());
00499    zline = TString::Format("%s*%s", zpos.Data(), retunit.Data());
00500    
00501    TGeoTranslation* pos = new TGeoTranslation(Evaluate(xline),
00502                               Evaluate(yline),
00503                               Evaluate(zline));
00504    
00505    fposmap[name.Data()] = pos;
00506    
00507    return node;
00508    
00509 }
00510 
00511 //___________________________________________________________________
00512 XMLNodePointer_t TGDMLParse::RotProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
00513 {
00514    //In the define section of the GDML file, rotations can be declared.
00515    //when the rotation keyword is found, this function is called, and the
00516    //name and values of the rotation are converted into type TGeoRotation 
00517    //and stored in frotmap map using the name as its key. This function 
00518    //can also be called when declaring solids.
00519 
00520    TString aunit = "rad"; 
00521    TString xpos = "0"; 
00522    TString ypos = "0"; 
00523    TString zpos = "0"; 
00524    TString name = "";
00525    TString tempattr; 
00526    
00527    while (attr!=0) {
00528       
00529       tempattr = gdml->GetAttrName(attr);
00530       tempattr.ToLower();
00531       
00532       if(tempattr == "name") { 
00533          name = gdml->GetAttrValue(attr);
00534       }
00535       else if(tempattr == "x") { 
00536          xpos = gdml->GetAttrValue(attr);
00537       }
00538       else if (tempattr == "y") {
00539          ypos = gdml->GetAttrValue(attr);
00540       }
00541       else if (tempattr == "z") {
00542          zpos = gdml->GetAttrValue(attr);
00543       }
00544       else if (tempattr == "unit") {
00545          aunit = gdml->GetAttrValue(attr);
00546       }
00547       
00548       attr = gdml->GetNextAttr(attr);   
00549    }
00550 
00551    if((strcmp(fCurrentFile,fStartFile)) != 0){
00552       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
00553    }
00554 
00555    TString xline = "";
00556    TString yline = "";
00557    TString zline = "";
00558    TString retunit;
00559    
00560    retunit = GetScale(aunit);
00561    
00562    xline = TString::Format("%s*%s", xpos.Data(), retunit.Data());
00563    yline = TString::Format("%s*%s", ypos.Data(), retunit.Data());
00564    zline = TString::Format("%s*%s", zpos.Data(), retunit.Data());
00565    
00566    TGeoRotation* rot = new TGeoRotation();
00567    
00568    rot->RotateZ(-(Evaluate(zline)));
00569    rot->RotateY(-(Evaluate(yline)));
00570    rot->RotateX(-(Evaluate(xline)));
00571    
00572    frotmap[name.Data()] = rot;
00573    
00574    return node;
00575    
00576 }
00577 
00578 //___________________________________________________________________
00579 XMLNodePointer_t TGDMLParse::SclProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
00580 {
00581    //In the define section of the GDML file, rotations can be declared.
00582    //when the scale keyword is found, this function is called, and the
00583    //name and values of the scale are converted into type TGeoScale
00584    //and stored in fsclmap map using the name as its key. This function 
00585    //can also be called when declaring solids.
00586 
00587    TString xpos = "0"; 
00588    TString ypos = "0"; 
00589    TString zpos = "0"; 
00590    TString name = "";
00591    TString tempattr; 
00592    
00593    while (attr!=0) {
00594       
00595       tempattr = gdml->GetAttrName(attr);
00596       tempattr.ToLower();
00597       
00598       if(tempattr == "name") { 
00599          name = gdml->GetAttrValue(attr);
00600       }
00601       else if(tempattr == "x") { 
00602          xpos = gdml->GetAttrValue(attr);
00603       }
00604       else if(tempattr == "y") {
00605          ypos = gdml->GetAttrValue(attr);
00606       }
00607       else if (tempattr == "z"){
00608          zpos = gdml->GetAttrValue(attr);
00609       }
00610       
00611       attr = gdml->GetNextAttr(attr);   
00612    }
00613 
00614    if((strcmp(fCurrentFile,fStartFile)) != 0){
00615       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
00616    }
00617 
00618    TGeoScale* scl = new TGeoScale(Evaluate(xpos),Evaluate(ypos),Evaluate(zpos));
00619    
00620    fsclmap[name.Data()] = scl;
00621    
00622    return node;
00623 }
00624 
00625 //___________________________________________________________________
00626 XMLNodePointer_t TGDMLParse::IsoProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t parentn)
00627 {   
00628    //In the material section of the GDML file, an isotope may be declared. 
00629    //when the isotope keyword is found, this function is called, and the 
00630    //required parameters are taken and stored, these are then bound and
00631    //converted to type TGeoIsotope and stored in fisomap map using the name 
00632    //as its key.
00633    TString z = "0";
00634    TString name = "";
00635    TString n = "0";
00636    TString atom = "0";
00637    TString tempattr;
00638    
00639    //obtain attributes for the element
00640    
00641    XMLAttrPointer_t attr = gdml->GetFirstAttr(parentn);
00642    
00643    while (attr!=0){    
00644       
00645       tempattr = gdml->GetAttrName(attr);
00646       tempattr.ToLower();
00647       
00648       if(tempattr == "name") { 
00649          name = gdml->GetAttrValue(attr);
00650       }
00651       else if (tempattr == "z") { 
00652          z = gdml->GetAttrValue(attr);
00653       }
00654       else if (tempattr == "n") {
00655          n = gdml->GetAttrValue(attr);
00656       }
00657       
00658       attr = gdml->GetNextAttr(attr);   
00659    }
00660    
00661    //get the atom value for the element
00662    
00663    attr = gdml->GetFirstAttr(node);
00664    
00665    while (attr!=0){      
00666       
00667       tempattr = gdml->GetAttrName(attr);
00668       
00669       if (tempattr == "value") { 
00670          atom = gdml->GetAttrValue(attr);
00671       }
00672       
00673       attr = gdml->GetNextAttr(attr);   
00674    }
00675    
00676    if((strcmp(fCurrentFile,fStartFile)) != 0){
00677       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
00678    }
00679 
00680    Int_t z2 = (Int_t)Evaluate(z);
00681    Int_t n2 = (Int_t)Evaluate(n);
00682    Double_t atom2 = Evaluate(atom);
00683    
00684    TGeoIsotope* iso = new TGeoIsotope(NameShort(name), z2 , n2, atom2);   
00685    fisomap[name.Data()] = iso;
00686    
00687    return node;
00688   
00689 }
00690 
00691 //___________________________________________________________
00692 XMLNodePointer_t TGDMLParse::EleProcess(TXMLEngine* gdml, XMLNodePointer_t node,   XMLNodePointer_t parentn, Bool_t hasIsotopes)
00693 {   
00694    //In the materials section of the GDML file, elements can be declared.
00695    //when the element keyword is found, this function is called, and the
00696    //name and values of the element are converted into type TGeoElement and
00697    //stored in felemap map using the name as its key.
00698 
00699    TString z = "0";
00700    TString name = "";
00701    TString formula = "";
00702    TString atom = "0";
00703    TString tempattr;
00704    Int_t   ncompo = 0;
00705    typedef FracMap::iterator fractions;
00706    FracMap fracmap;
00707    
00708    XMLNodePointer_t child = 0;
00709    
00710    //obtain attributes for the element
00711    
00712    XMLAttrPointer_t attr = gdml->GetFirstAttr(node);
00713    
00714    if (hasIsotopes) {
00715       // Get the name of the element
00716       while (attr!=0){   
00717          tempattr = gdml->GetAttrName(attr);
00718          if(tempattr == "name") { 
00719             name = gdml->GetAttrValue(attr);
00720             if((strcmp(fCurrentFile,fStartFile)) != 0){
00721                name = TString::Format("%s_%s", name.Data(), fCurrentFile);
00722             }
00723             break;
00724          }
00725          attr = gdml->GetNextAttr(attr);
00726       }   
00727       // Get component isotopes. Loop all children.
00728       child = gdml->GetChild(node);
00729       while (child!=0) {
00730          // Check for fraction node name
00731          if((strcmp(gdml->GetNodeName(child), "fraction")) == 0){
00732             Double_t n = 0;
00733             TString ref = ""; 
00734             ncompo = ncompo + 1;
00735             attr = gdml->GetFirstAttr(child);
00736             while (attr!=0){   
00737                tempattr = gdml->GetAttrName(attr);
00738                tempattr.ToLower();
00739                if(tempattr == "n") { 
00740                   n = Evaluate(gdml->GetAttrValue(attr));
00741                }
00742                else if (tempattr == "ref") { 
00743                   ref = gdml->GetAttrValue(attr);
00744                   if((strcmp(fCurrentFile,fStartFile)) != 0){
00745                      ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
00746                   }
00747                }
00748                attr = gdml->GetNextAttr(attr);
00749             } // loop on child attributes
00750             fracmap[ref.Data()] = n; 
00751          }
00752          child = gdml->GetNext(child);
00753       } // loop on childs
00754       // Create TGeoElement
00755       TGeoElement *ele = new TGeoElement(NameShort(name), "", ncompo);
00756       for(fractions f = fracmap.begin(); f != fracmap.end(); f++){
00757          if(fisomap.find(f->first) != fisomap.end()){
00758             ele->AddIsotope((TGeoIsotope*)fisomap[f->first], f->second);
00759          }
00760       }
00761       felemap[name.Data()] = ele;
00762       return child;
00763    }
00764    
00765    attr = gdml->GetFirstAttr(parentn);
00766    while (attr!=0){    
00767       
00768       tempattr = gdml->GetAttrName(attr);
00769       tempattr.ToLower();
00770       
00771       if(tempattr == "name") { 
00772          name = gdml->GetAttrValue(attr);
00773       }
00774       else if(tempattr == "z") { 
00775          z = gdml->GetAttrValue(attr);
00776       }
00777       else if(tempattr == "formula") {
00778          formula = gdml->GetAttrValue(attr);
00779       }
00780       
00781       attr = gdml->GetNextAttr(attr);   
00782    }
00783    
00784    //get the atom value for the element
00785    
00786    attr = gdml->GetFirstAttr(node);
00787    
00788    while (attr!=0){      
00789       
00790       tempattr = gdml->GetAttrName(attr);
00791       tempattr.ToLower();
00792       
00793       if(tempattr == "value") { 
00794          atom = gdml->GetAttrValue(attr);
00795       }
00796       
00797       attr = gdml->GetNextAttr(attr);   
00798    }
00799    
00800    if((strcmp(fCurrentFile,fStartFile)) != 0){
00801       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
00802    }
00803 
00804    Int_t z2 = (Int_t)Evaluate(z);
00805    Double_t atom2 = Evaluate(atom);
00806    
00807    TGeoElement* ele = new TGeoElement(NameShort(name), formula, z2 , atom2);
00808    
00809    felemap[name.Data()] = ele;
00810    
00811    return node;
00812 }
00813 
00814 //_________________________________________________________________________
00815 XMLNodePointer_t TGDMLParse::MatProcess(TXMLEngine* gdml, XMLNodePointer_t node,   XMLAttrPointer_t attr, int z)
00816 {   
00817    //In the materials section of the GDML file, materials can be declared.
00818    //when the material keyword is found, this function is called, and the
00819    //name and values of the material are converted into type TGeoMaterial 
00820    //and stored in fmatmap map using the name as its key. Mixtures can also
00821    // be declared, and they are converted to TGeoMixture and stored in
00822    //fmixmap.   These mixtures and materials are then all converted into one
00823    //common type - TGeoMedium.   The map fmedmap is then built up of all the 
00824    //mixtures and materials.
00825 
00826  //!Map to hold fractions while being processed
00827    typedef FracMap::iterator fractions;
00828    FracMap fracmap;
00829    
00830    static int medid = 0;
00831    XMLNodePointer_t child = gdml->GetChild(node);
00832    TString tempattr = "";
00833    Int_t ncompo = 0, mixflag = 2;
00834    Double_t density = 0;
00835    TString name = "";
00836    TGeoMixture* mix = 0; 
00837    TGeoMaterial* mat = 0;
00838    TString tempconst = "";
00839    Bool_t composite = kFALSE;
00840    
00841    if (z == 1){
00842       Double_t a = 0;
00843       Double_t d = 0;
00844       
00845       while (child!=0) {
00846          attr = gdml->GetFirstAttr(child);
00847          
00848          if((strcmp(gdml->GetNodeName(child), "atom")) == 0){
00849             while (attr!=0){   
00850                tempattr = gdml->GetAttrName(attr);
00851                tempattr.ToLower();
00852        
00853                if(tempattr == "value") { 
00854                   a = Evaluate(gdml->GetAttrValue(attr));
00855                }       
00856                attr = gdml->GetNextAttr(attr);
00857             }          
00858          }
00859          
00860          if((strcmp(gdml->GetNodeName(child), "D")) == 0){
00861             while (attr!=0){   
00862                tempattr = gdml->GetAttrName(attr);
00863                tempattr.ToLower();
00864           
00865                if(tempattr == "value") { 
00866                   d = Evaluate(gdml->GetAttrValue(attr));   
00867                }       
00868                attr = gdml->GetNextAttr(attr);
00869             } 
00870          }         
00871          child = gdml->GetNext(child);
00872       }
00873       
00874       //still in the is Z else...but not in the while..
00875       
00876       name = gdml->GetAttr(node, "name");
00877 
00878       if((strcmp(fCurrentFile,fStartFile)) != 0){
00879          name = TString::Format("%s_%s", name.Data(), fCurrentFile);
00880       }
00881       
00882       //CHECK FOR CONSTANTS    
00883       tempconst = gdml->GetAttr(node, "Z");
00884       
00885       mat = new TGeoMaterial(NameShort(name), a, Evaluate(tempconst), d);      
00886       mixflag = 0;
00887       TGeoElement* mat_ele = new TGeoElement(NameShort(name), "", atoi(tempconst), a);
00888       felemap[name.Data()] = mat_ele;
00889    }
00890    
00891    else if (z == 0){
00892       while (child!=0) {
00893          attr = gdml->GetFirstAttr(child);
00894          if((strcmp(gdml->GetNodeName(child), "fraction")) == 0){
00895             Double_t n = 0;
00896             TString ref = ""; 
00897             ncompo = ncompo + 1;
00898        
00899             while (attr!=0){   
00900                tempattr = gdml->GetAttrName(attr);
00901                tempattr.ToLower();
00902           
00903                if(tempattr == "n") { 
00904                   n = Evaluate(gdml->GetAttrValue(attr));
00905                }
00906                else if(tempattr == "ref") { 
00907                   ref = gdml->GetAttrValue(attr);
00908                   if((strcmp(fCurrentFile,fStartFile)) != 0){
00909                      ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
00910                   }
00911 
00912                }
00913           
00914                attr = gdml->GetNextAttr(attr);
00915             }
00916        
00917             fracmap[ref.Data()] = n; 
00918          }
00919          
00920          else if((strcmp(gdml->GetNodeName(child), "composite")) == 0){
00921             composite = kTRUE;
00922             Double_t n = 0;
00923             TString ref = ""; 
00924             ncompo = ncompo + 1;
00925        
00926             while (attr!=0){   
00927                tempattr = gdml->GetAttrName(attr);
00928                tempattr.ToLower();
00929           
00930                if(tempattr == "n") { 
00931                   n = Evaluate(gdml->GetAttrValue(attr));
00932                }
00933                else if(tempattr == "ref") { 
00934                   ref = gdml->GetAttrValue(attr);
00935                }
00936           
00937                attr = gdml->GetNextAttr(attr);
00938             }
00939        
00940             fracmap[ref.Data()] = n;
00941          }
00942          
00943          else if((strcmp(gdml->GetNodeName(child), "D")) == 0){
00944             while (attr!=0){         
00945                tempattr = gdml->GetAttrName(attr);
00946                tempattr.ToLower();
00947           
00948                if(tempattr == "value") { 
00949                   density = Evaluate(gdml->GetAttrValue(attr));
00950                }
00951           
00952                attr = gdml->GetNextAttr(attr);
00953             }
00954          }
00955          
00956          child = gdml->GetNext(child);       
00957       }
00958       
00959       //still in the not Z else...but not in the while..
00960       
00961       name = gdml->GetAttr(node, "name");
00962       if((strcmp(fCurrentFile,fStartFile)) != 0){
00963          name = TString::Format("%s_%s", name.Data(), fCurrentFile);
00964       }
00965       mix = new TGeoMixture(NameShort(name), ncompo, density);
00966       mixflag = 1;
00967       Int_t natoms;
00968       Double_t weight;
00969       
00970       for(fractions f = fracmap.begin(); f != fracmap.end(); f++){
00971          if(felemap.find(f->first) != felemap.end()){
00972             if (composite) {
00973                natoms = (Int_t)f->second;
00974                mix->AddElement(felemap[f->first], natoms);
00975             } else {
00976                weight = f->second;  
00977                mix->AddElement(felemap[f->first], weight); 
00978             }   
00979          } 
00980          else {
00981        // mix->DefineElement(i, fmixmap[f->first], f->second); BUG IN PYTHON???
00982          }
00983       }
00984       
00985    }//end of not Z else
00986    
00987    medid = medid + 1;
00988    
00989    TGeoMedium* med = 0;
00990    
00991    if(mixflag == 1) {
00992       fmixmap[name.Data()] = mix;
00993       med = new TGeoMedium(NameShort(name), medid, mix);
00994    } 
00995    else if (mixflag == 0) {
00996       fmatmap[name.Data()] = mat;
00997       med = new TGeoMedium(NameShort(name), medid, mat);
00998    }
00999    
01000    fmedmap[name.Data()] = med;
01001    
01002    return child;
01003 }
01004 
01005 //____________________________________________________________
01006 XMLNodePointer_t TGDMLParse::VolProcess(TXMLEngine* gdml, XMLNodePointer_t node)
01007 {   
01008    //In the structure section of the GDML file, volumes can be declared.
01009    //when the volume keyword is found, this function is called, and the
01010    //name and values of the volume are converted into type TGeoVolume and
01011    //stored in fvolmap map using the name as its key. Volumes reference to 
01012    //a solid declared higher up in the solids section of the GDML file. 
01013    //Some volumes reference to other physical volumes to contain inside 
01014    //that volume, declaring positions and rotations within that volume. 
01015    //When each 'physvol' is declared, a matrix for its rotation and 
01016    //translation is built and the 'physvol node' is added to the original 
01017    //volume using TGeoVolume->AddNode.
01018    //volume division is also declared within the volume node, and once the
01019    //values for the division have been collected, using TGeoVolume->divide,
01020    //the division can be applied.
01021 
01022    XMLAttrPointer_t attr;
01023    XMLNodePointer_t subchild;
01024    XMLNodePointer_t child = gdml->GetChild(node);
01025    TString name;
01026    TString solidname = "";
01027    TString tempattr = "";
01028    TGeoShape* solid = 0;
01029    TGeoMedium* medium = 0;
01030    TGeoVolume* vol = 0; 
01031    TGeoVolume* lv = 0;
01032    TGeoShape* reflex = 0;
01033    const Double_t* parentrot = 0;
01034    int yesrefl = 0;
01035    TString reftemp = "";
01036    
01037    while (child!=0) {
01038       if((strcmp(gdml->GetNodeName(child), "solidref")) == 0){
01039 
01040          reftemp = gdml->GetAttr(child, "ref");
01041          if((strcmp(fCurrentFile,fStartFile)) != 0){
01042             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01043          }
01044          if(fsolmap.find(reftemp.Data()) != fsolmap.end()){ 
01045             solid = fsolmap[reftemp.Data()];
01046          } 
01047          else if(freflectmap.find(reftemp.Data()) != freflectmap.end()){
01048             solidname = reftemp;
01049             reflex = fsolmap[freflectmap[reftemp.Data()]];
01050          } 
01051          else {
01052             printf("Solid: %s, Not Yet Defined!\n", reftemp.Data());
01053          }
01054       }
01055       
01056       if((strcmp(gdml->GetNodeName(child), "materialref")) == 0){
01057          reftemp = gdml->GetAttr(child, "ref");
01058          if((strcmp(fCurrentFile,fStartFile)) != 0){
01059             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01060          }
01061          if(fmedmap.find(reftemp.Data()) != fmedmap.end()){ 
01062             medium = fmedmap[reftemp.Data()];
01063          } 
01064          else {
01065             printf("Medium: %s, Not Yet Defined!\n", gdml->GetAttr(child, "ref"));
01066          }
01067       }
01068       
01069       child = gdml->GetNext(child);
01070    }
01071    
01072    name = gdml->GetAttr(node, "name");
01073       
01074    if((strcmp(fCurrentFile,fStartFile)) != 0){
01075       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
01076    }
01077    
01078    if(reflex == 0){
01079       vol = new TGeoVolume(NameShort(name), solid, medium);
01080    } 
01081    else {
01082       vol = new TGeoVolume(NameShort(name), reflex, medium);
01083       freflvolmap[name.Data()] = solidname;
01084       TGDMLRefl* parentrefl = freflsolidmap[solidname.Data()];
01085       parentrot = parentrefl->GetMatrix()->GetRotationMatrix();
01086       yesrefl = 1;
01087    }
01088    
01089    fvolmap[name.Data()] = vol;
01090    
01091    //PHYSVOL - run through child nodes of VOLUME again..
01092    
01093    child = gdml->GetChild(node);
01094    
01095    while (child!=0) {
01096       if((strcmp(gdml->GetNodeName(child), "physvol")) == 0){
01097 
01098          TString volref = "";
01099 
01100          TGeoTranslation* pos = 0;
01101          TGeoRotation* rot = 0;
01102          TGeoScale* scl = 0;
01103         
01104          subchild = gdml->GetChild(child);
01105 
01106          while (subchild!=0){
01107             tempattr = gdml->GetNodeName(subchild);
01108             tempattr.ToLower();
01109     
01110             if(tempattr == "volumeref"){
01111                reftemp = gdml->GetAttr(subchild, "ref");
01112                if((strcmp(fCurrentFile,fStartFile)) != 0){
01113                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01114                }
01115                lv = fvolmap[reftemp.Data()];
01116                volref = reftemp;
01117             } 
01118             else if(tempattr == "file"){
01119 
01120                const char* filevol;
01121                const char* prevfile = fCurrentFile;
01122 
01123                fCurrentFile = gdml->GetAttr(subchild, "name");
01124                filevol = gdml->GetAttr(subchild, "volname");
01125                  
01126                TXMLEngine* gdml2 = new TXMLEngine;
01127                gdml2->SetSkipComments(kTRUE);
01128 
01129                XMLDocPointer_t filedoc1 = gdml2->ParseFile(fCurrentFile);
01130                if (filedoc1==0) {
01131                   Fatal("VolProcess", "Bad filename given %s", fCurrentFile);
01132                } 
01133                // take access to main node   
01134                XMLNodePointer_t mainnode2 = gdml2->DocGetRootElement(filedoc1);
01135                //increase depth counter + add DOM pointer
01136                fFILENO = fFILENO + 1;
01137                fFileEngine[fFILENO] = gdml2;
01138 
01139                if(ffilemap.find(fCurrentFile) != ffilemap.end()){ 
01140                   volref = ffilemap[fCurrentFile];
01141                } 
01142                else {
01143                   volref = ParseGDML(gdml2, mainnode2);
01144                   ffilemap[fCurrentFile] = volref;
01145                }
01146 
01147                if(filevol){
01148                   volref = filevol;
01149                   if((strcmp(fCurrentFile,fStartFile)) != 0){
01150                      volref = TString::Format("%s_%s", volref.Data(), fCurrentFile);
01151                   }
01152                }
01153 
01154                fFILENO = fFILENO - 1;
01155                gdml = fFileEngine[fFILENO];
01156                fCurrentFile = prevfile;
01157                lv = fvolmap[volref.Data()];
01158                //File tree complete - Release memory before exit
01159                gdml->FreeDoc(filedoc1);
01160                delete gdml2;
01161             }
01162             else if(tempattr == "position"){
01163                attr = gdml->GetFirstAttr(subchild);
01164                PosProcess(gdml, subchild, attr);
01165                reftemp = gdml->GetAttr(subchild, "name");
01166                if((strcmp(fCurrentFile,fStartFile)) != 0){
01167                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01168                }
01169                pos = fposmap[reftemp.Data()];
01170             }
01171             else if(tempattr == "positionref"){
01172                reftemp = gdml->GetAttr(subchild, "ref");
01173                if((strcmp(fCurrentFile,fStartFile)) != 0){
01174                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01175                }
01176                if(fposmap.find(reftemp.Data()) != fposmap.end()) pos = fposmap[reftemp.Data()];
01177                else std::cout << "ERROR! Physvol's position " << reftemp << " not found!" << std::endl;
01178             } 
01179             else if(tempattr == "rotation") {
01180                attr = gdml->GetFirstAttr(subchild);
01181                RotProcess(gdml, subchild, attr);
01182                reftemp = gdml->GetAttr(subchild, "name");
01183                if((strcmp(fCurrentFile,fStartFile)) != 0){
01184                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01185                }
01186                rot = frotmap[reftemp.Data()];
01187             }
01188             else if(tempattr == "rotationref"){
01189                reftemp = gdml->GetAttr(subchild, "ref");
01190                if((strcmp(fCurrentFile,fStartFile)) != 0){
01191                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01192                }
01193                if (frotmap.find(reftemp.Data()) != frotmap.end()) rot = frotmap[reftemp.Data()];
01194                else std::cout << "ERROR! Physvol's rotation " << reftemp << " not found!" << std::endl;
01195             }
01196             else if(tempattr =="scale") {
01197                attr = gdml->GetFirstAttr(subchild);
01198                SclProcess(gdml, subchild, attr);
01199                reftemp = gdml->GetAttr(subchild, "name");
01200                if((strcmp(fCurrentFile,fStartFile)) != 0){
01201                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01202                }
01203                scl = fsclmap[reftemp.Data()];
01204             }
01205             else if(tempattr == "scaleref"){
01206                reftemp = gdml->GetAttr(subchild, "ref");
01207                if((strcmp(fCurrentFile,fStartFile)) != 0){
01208                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01209                }
01210                if (fsclmap.find(reftemp.Data()) != fsclmap.end()) scl = fsclmap[reftemp.Data()];
01211                else std::cout << "ERROR! Physvol's scale " << reftemp << " not found!" << std::endl;
01212             }
01213 
01214             subchild = gdml->GetNext(subchild);
01215          }
01216          
01217          //ADD PHYSVOL TO GEOMETRY
01218          fVolID = fVolID + 1;
01219 
01220          TGeoHMatrix *transform = new TGeoHMatrix();         
01221 
01222          if (pos!=0) transform->SetTranslation(pos->GetTranslation());
01223          if (rot!=0) transform->SetRotation(rot->GetRotationMatrix());
01224 
01225          if (scl!=0) { // Scaling must be added to the rotation matrix!
01226 
01227             Double_t scale3x3[9];
01228             memset(scale3x3,0,9*sizeof(Double_t));
01229             const Double_t *diagonal = scl->GetScale();
01230 
01231             scale3x3[0] = diagonal[0];
01232             scale3x3[4] = diagonal[1];
01233             scale3x3[8] = diagonal[2];
01234          
01235             TGeoRotation scaleMatrix;
01236             scaleMatrix.SetMatrix(scale3x3);
01237             transform->Multiply(&scaleMatrix);
01238          }
01239 
01240 // BEGIN: reflectedSolid. Remove lines between if reflectedSolid will be removed from GDML!!!
01241 
01242          if(freflvolmap.find(volref.Data()) != freflvolmap.end()) { 
01243             // if the volume is a reflected volume the matrix needs to be CHANGED
01244             TGDMLRefl* temprefl = freflsolidmap[freflvolmap[volref.Data()]];
01245             transform->Multiply(temprefl->GetMatrix());
01246          }
01247 
01248          if(yesrefl == 1) { 
01249             // reflection is done per solid so that we cancel it if exists in mother volume!!!
01250             TGeoRotation prot;
01251             prot.SetMatrix(parentrot);
01252             transform->MultiplyLeft(&prot);
01253          }
01254 
01255 // END: reflectedSolid
01256 
01257          vol->AddNode(lv,fVolID,transform);
01258       }
01259       else if((strcmp(gdml->GetNodeName(child), "divisionvol")) == 0){
01260    
01261          TString divVolref = "";
01262          Int_t axis = 0;
01263          TString number = "";
01264          TString width = "";
01265          TString offset = "";
01266          TString lunit = "mm";
01267          
01268          attr = gdml->GetFirstAttr(child);
01269          
01270          while (attr!=0) {
01271     
01272             tempattr = gdml->GetAttrName(attr);
01273             tempattr.ToLower();
01274        
01275             if(tempattr == "axis") { 
01276                axis = SetAxis(gdml->GetAttrValue(attr));
01277             }
01278             else if (tempattr == "number") { 
01279                number = gdml->GetAttrValue(attr);
01280             }
01281             else if (tempattr == "width") {
01282                width = gdml->GetAttrValue(attr);
01283             }
01284             else if (tempattr == "offset") {
01285                offset = gdml->GetAttrValue(attr);
01286             }
01287             else if (tempattr == "unit") {
01288                lunit = gdml->GetAttrValue(attr);
01289             }
01290        
01291             attr = gdml->GetNextAttr(attr);
01292        
01293          }
01294          
01295          subchild = gdml->GetChild(child);
01296          
01297          while (subchild!=0){
01298             tempattr = gdml->GetNodeName(subchild);
01299             tempattr.ToLower();
01300        
01301             if(tempattr == "volumeref"){ 
01302                reftemp = gdml->GetAttr(subchild, "ref");
01303                if((strcmp(fCurrentFile,fStartFile)) != 0){
01304                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01305                }
01306                divVolref = reftemp;
01307             }
01308        
01309             subchild = gdml->GetNext(subchild);             
01310          } 
01311     
01312     
01313          TString numberline = "";
01314          TString widthline = "";
01315          TString offsetline = "";
01316          TString retunit;
01317          
01318          retunit = GetScale(lunit);
01319          
01320          numberline = TString::Format("%s", number.Data());
01321          widthline = TString::Format("%s*%s", width.Data(), retunit.Data());
01322          offsetline = TString::Format("%s*%s", offset.Data(), retunit.Data());
01323  
01324          fVolID = fVolID + 1;
01325          Double_t xlo, xhi;
01326          vol->GetShape()->GetAxisRange(axis, xlo, xhi);
01327          Int_t ndiv = (Int_t)Evaluate(numberline);
01328          Double_t start = xlo + (Double_t)Evaluate(offsetline);
01329          Double_t step = (Double_t)Evaluate(widthline);
01330          Int_t numed = 0;
01331          TGeoVolume *old = fvolmap[NameShort(reftemp)];
01332          if (old) {
01333             // We need to recreate the content of the divided volume
01334             old = fvolmap[NameShort(reftemp)];
01335             // medium id
01336             numed = old->GetMedium()->GetId();
01337          }   
01338          TGeoVolume *divvol = vol->Divide(NameShort(reftemp), axis, ndiv, start, step, numed);
01339          if (old && old->GetNdaughters()) {
01340             divvol->ReplayCreation(old);
01341          }
01342          fvolmap[NameShort(reftemp)] = divvol;
01343 
01344       }//end of Division else if
01345       
01346       child = gdml->GetNext(child);
01347    }
01348    
01349    return child;
01350    
01351 }
01352 
01353 //______________________________________________________
01354 XMLNodePointer_t TGDMLParse::BooSolid(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr, int num)
01355 { 
01356    //In the solid section of the GDML file, boolean solids can be 
01357    //declared. when the subtraction, intersection or union   keyword 
01358    //is found, this function is called, and the values (rotation and 
01359    //translation) of the solid are converted into type TGeoCompositeShape
01360    //and stored in fsolmap map using the name as its key.
01361    //
01362    //1 = SUBTRACTION
01363    //2 = INTERSECTION
01364    //3 = UNION
01365    
01366    TString reftemp = "";
01367    TString tempattr = "";
01368    XMLNodePointer_t child = gdml->GetChild(node);
01369 
01370    TGeoShape* first = 0;
01371    TGeoShape* second = 0;
01372 
01373    TGeoTranslation* firstPos = new TGeoTranslation(0,0,0);
01374    TGeoTranslation* secondPos = new TGeoTranslation(0,0,0);
01375 
01376    TGeoRotation* firstRot = new TGeoRotation();
01377    TGeoRotation* secondRot = new TGeoRotation();
01378 
01379    firstRot->RotateZ(0);
01380    firstRot->RotateY(0);
01381    firstRot->RotateX(0);
01382 
01383    secondRot->RotateZ(0);
01384    secondRot->RotateY(0);
01385    secondRot->RotateX(0);
01386 
01387    TString name = gdml->GetAttr(node, "name");
01388 
01389    if((strcmp(fCurrentFile,fStartFile)) != 0)
01390       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
01391    
01392    while (child!=0){
01393       tempattr = gdml->GetNodeName(child);
01394       tempattr.ToLower();
01395       
01396       if(tempattr == "first"){
01397          reftemp = gdml->GetAttr(child, "ref");
01398          if((strcmp(fCurrentFile,fStartFile)) != 0){
01399             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01400          }
01401          if(fsolmap.find(reftemp.Data()) != fsolmap.end()){ 
01402             first = fsolmap[reftemp.Data()];
01403          }
01404       }
01405       else if(tempattr == "second") {
01406          reftemp = gdml->GetAttr(child, "ref");
01407          if((strcmp(fCurrentFile,fStartFile)) != 0){
01408             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01409          }
01410          if(fsolmap.find(reftemp.Data()) != fsolmap.end()){   
01411            second = fsolmap[reftemp.Data()];
01412          }
01413       }
01414       else if(tempattr == "position"){
01415          attr = gdml->GetFirstAttr(child);
01416          PosProcess(gdml, child, attr);
01417          reftemp = gdml->GetAttr(child, "name");
01418          if((strcmp(fCurrentFile,fStartFile)) != 0){
01419             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01420          }
01421          secondPos = fposmap[reftemp.Data()];
01422       }
01423       else if(tempattr == "positionref"){
01424          reftemp = gdml->GetAttr(child, "ref");
01425          if((strcmp(fCurrentFile,fStartFile)) != 0){
01426             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01427          }
01428          if(fposmap.find(reftemp.Data()) != fposmap.end()){ 
01429             secondPos = fposmap[reftemp.Data()];
01430          }
01431       }
01432       else if(tempattr == "rotation"){
01433          attr = gdml->GetFirstAttr(child);
01434          RotProcess(gdml, child, attr);
01435          reftemp = gdml->GetAttr(child, "name");
01436          if((strcmp(fCurrentFile,fStartFile)) != 0){
01437             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01438          }
01439          secondRot = frotmap[reftemp.Data()];
01440       }
01441       else if(tempattr == "rotationref"){
01442          reftemp = gdml->GetAttr(child, "ref");
01443          if((strcmp(fCurrentFile,fStartFile)) != 0){
01444             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01445          }
01446          if(frotmap.find(reftemp.Data()) != frotmap.end()){ 
01447             secondRot = frotmap[reftemp.Data()];
01448          }
01449       } 
01450       else if(tempattr == "firstposition"){
01451          attr = gdml->GetFirstAttr(child);
01452          PosProcess(gdml, child, attr);
01453          reftemp = gdml->GetAttr(child, "name");
01454          if((strcmp(fCurrentFile,fStartFile)) != 0){
01455             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01456          }
01457          firstPos = fposmap[reftemp.Data()];
01458       }
01459       else if(tempattr == "firstpositionref"){
01460          reftemp = gdml->GetAttr(child, "ref");
01461          if((strcmp(fCurrentFile,fStartFile)) != 0){
01462             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01463          }
01464          if(fposmap.find(reftemp.Data()) != fposmap.end()){ 
01465             firstPos = fposmap[reftemp.Data()];
01466          }
01467       }
01468       else if(tempattr == "firstrotation"){
01469          attr = gdml->GetFirstAttr(child);
01470          RotProcess(gdml, child, attr);
01471          reftemp = gdml->GetAttr(child, "name");
01472          if((strcmp(fCurrentFile,fStartFile)) != 0){
01473             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01474          }
01475          firstRot = frotmap[reftemp.Data()];
01476       }
01477       else if(tempattr == "firstrotationref"){
01478          reftemp = gdml->GetAttr(child, "ref");
01479          if((strcmp(fCurrentFile,fStartFile)) != 0){
01480             reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01481          }
01482          if(frotmap.find(reftemp.Data()) != frotmap.end()){ 
01483             firstRot = frotmap[reftemp.Data()];
01484          }
01485       }       
01486       child = gdml->GetNext(child);
01487    }
01488 
01489    TGeoMatrix* firstMatrix = new TGeoCombiTrans(*firstPos,firstRot->Inverse());
01490    TGeoMatrix* secondMatrix = new TGeoCombiTrans(*secondPos,secondRot->Inverse());
01491 
01492    TGeoCompositeShape* boolean = 0;
01493    if (!first || !second) {
01494       Fatal("BooSolid", "Incomplete solid %s, missing shape components", name.Data());
01495       return child;
01496    }   
01497    switch (num) {
01498    case 1: boolean = new TGeoCompositeShape(NameShort(name),new TGeoSubtraction(first,second,firstMatrix,secondMatrix)); break;      // SUBTRACTION
01499    case 2: boolean = new TGeoCompositeShape(NameShort(name),new TGeoIntersection(first,second,firstMatrix,secondMatrix)); break;     // INTERSECTION 
01500    case 3: boolean = new TGeoCompositeShape(NameShort(name),new TGeoUnion(first,second,firstMatrix,secondMatrix)); break;            // UNION
01501    default:
01502     break;
01503    }
01504 
01505    fsolmap[name.Data()] = boolean;
01506 
01507    return child;
01508 }
01509 
01510 //________________________________________________________
01511 XMLNodePointer_t TGDMLParse::AssProcess(TXMLEngine* gdml, XMLNodePointer_t node)
01512 {   
01513    //In the structure section of the GDML file, assembly volumes can be 
01514    //declared. when the assembly keyword is found, this function is called, 
01515    //and the name is converted into type TGeoVolumeAssembly and
01516    //stored in fvolmap map using the name as its key. Some assembly volumes 
01517    //reference to other physical volumes to contain inside that assembly, 
01518    //declaring positions and rotations within that volume. When each 'physvol' 
01519    //is declared, a matrix for its rotation and translation is built and the 
01520    //'physvol node' is added to the original assembly using TGeoVolume->AddNode.
01521 
01522    TString name = gdml->GetAttr(node, "name");
01523    TString reftemp = "";
01524 
01525    if((strcmp(fCurrentFile,fStartFile)) != 0){
01526       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
01527    }
01528 
01529    XMLAttrPointer_t attr;
01530    XMLNodePointer_t subchild;
01531    XMLNodePointer_t child = gdml->GetChild(node);
01532    TString tempattr = "";
01533    TGeoVolume* lv = 0;
01534    TGeoTranslation* pos = 0;
01535    TGeoRotation* rot = 0;
01536    TGeoCombiTrans* matr;
01537    
01538    TGeoVolumeAssembly* assem = new TGeoVolumeAssembly(NameShort(name));
01539 
01540    
01541    //PHYSVOL - run through child nodes of VOLUME again..
01542    
01543 //   child = gdml->GetChild(node);
01544    
01545    while (child!=0) {
01546       if((strcmp(gdml->GetNodeName(child), "physvol")) == 0){
01547          subchild = gdml->GetChild(child);
01548          pos = new TGeoTranslation(0,0,0);
01549          rot = new TGeoRotation();
01550          
01551          while (subchild!=0){
01552             tempattr = gdml->GetNodeName(subchild);
01553             tempattr.ToLower();
01554     
01555             if(tempattr == "volumeref"){
01556                reftemp = gdml->GetAttr(subchild, "ref");
01557                if((strcmp(fCurrentFile,fStartFile)) != 0){
01558                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01559                }
01560                lv = fvolmap[reftemp.Data()];
01561             }       
01562             else if(tempattr == "positionref"){
01563                reftemp = gdml->GetAttr(subchild, "ref");
01564                if((strcmp(fCurrentFile,fStartFile)) != 0){
01565                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01566                }
01567                if(fposmap.find(reftemp.Data()) != fposmap.end()){ 
01568                   pos = fposmap[reftemp.Data()];
01569                }
01570             }
01571             else if(tempattr == "position"){
01572                attr = gdml->GetFirstAttr(subchild);
01573                PosProcess(gdml, subchild, attr);
01574                reftemp = gdml->GetAttr(subchild, "name");
01575                if((strcmp(fCurrentFile,fStartFile)) != 0){
01576                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01577                }
01578                pos = fposmap[reftemp.Data()];
01579             }
01580             else if(tempattr == "rotationref"){
01581                reftemp = gdml->GetAttr(subchild, "ref");
01582                if((strcmp(fCurrentFile,fStartFile)) != 0){
01583                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01584                }
01585                if(frotmap.find(reftemp.Data()) != frotmap.end()){ 
01586                   rot = frotmap[reftemp.Data()];
01587                }
01588             }
01589             else if(tempattr == "rotation"){
01590                attr = gdml->GetFirstAttr(subchild);
01591                RotProcess(gdml, subchild, attr);
01592                reftemp = gdml->GetAttr(subchild, "name");
01593                if((strcmp(fCurrentFile,fStartFile)) != 0){
01594                   reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
01595                }
01596                rot = frotmap[reftemp.Data()];
01597             }
01598        
01599             subchild = gdml->GetNext(subchild);
01600          }
01601          
01602          //ADD PHYSVOL TO GEOMETRY
01603          fVolID = fVolID + 1;
01604          matr = new TGeoCombiTrans(*pos, *rot);
01605          assem->AddNode(lv, fVolID, matr);
01606          
01607       }
01608       child = gdml->GetNext(child);
01609    }
01610 
01611    fvolmap[name.Data()] = assem;
01612    return child;
01613 }
01614 
01615 //________________________________________________________
01616 XMLNodePointer_t   TGDMLParse::TopProcess(TXMLEngine* gdml, XMLNodePointer_t node)
01617 {   
01618    //In the setup section of the GDML file, the top volume need to be 
01619    //declared. when the setup keyword is found, this function is called, 
01620    //and the top volume ref is taken and 'world' is set
01621 
01622    const char* name = gdml->GetAttr(node, "name");
01623    gGeoManager->SetName(name);
01624    XMLNodePointer_t child = gdml->GetChild(node);
01625  
01626    while(child != 0){
01627       
01628       if((strcmp(gdml->GetNodeName(child), "world") == 0)){
01629          const char* reftemp; 
01630          reftemp = gdml->GetAttr(child, "ref");
01631          if((strcmp(fCurrentFile,fStartFile)) != 0){
01632             reftemp = TString::Format("%s_%s", reftemp, fCurrentFile);
01633          }
01634          fWorld = fvolmap[reftemp];
01635          fWorldName = reftemp;
01636       } 
01637       child = gdml->GetNext(child);
01638    }   
01639    return node;
01640 }
01641 
01642 //____________________________________________________retlunit_______________
01643 XMLNodePointer_t TGDMLParse::Box(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
01644 {   
01645    //In the solids section of the GDML file, a box may be declared. 
01646    //when the box keyword is found, this function is called, and the 
01647    //dimensions required are taken and stored, these are then bound and
01648    //converted to type TGeoBBox and stored in fsolmap map using the name 
01649    //as its key.
01650    
01651    TString lunit = "mm"; 
01652    TString xpos = "0"; 
01653    TString ypos = "0"; 
01654    TString zpos = "0"; 
01655    TString name = "";
01656    TString tempattr; 
01657 
01658    while (attr!=0) {
01659       
01660       tempattr = gdml->GetAttrName(attr);
01661       tempattr.ToLower();
01662       
01663       if(tempattr == "name") { 
01664          name = gdml->GetAttrValue(attr);
01665       }
01666       else if(tempattr == "x") { 
01667          xpos = gdml->GetAttrValue(attr);
01668       }
01669       else if(tempattr == "y"){
01670          ypos = gdml->GetAttrValue(attr);
01671       }
01672       else if (tempattr == "z"){
01673          zpos = gdml->GetAttrValue(attr);
01674       }
01675       else if (tempattr == "lunit"){
01676          lunit = gdml->GetAttrValue(attr);
01677       }
01678       
01679       attr = gdml->GetNextAttr(attr);   
01680    }
01681    
01682    if((strcmp(fCurrentFile,fStartFile)) != 0){
01683       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
01684    }
01685 
01686    TString xline = "";
01687    TString yline = "";
01688    TString zline = "";
01689    TString retunit;
01690    
01691    retunit = GetScale(lunit);
01692    
01693    xline = TString::Format("%s*%s", xpos.Data(), retunit.Data());
01694    yline = TString::Format("%s*%s", ypos.Data(), retunit.Data());
01695    zline = TString::Format("%s*%s", zpos.Data(), retunit.Data());
01696 
01697    
01698    TGeoBBox* box = new TGeoBBox(NameShort(name),Evaluate(xline)/2,
01699                         Evaluate(yline)/2,
01700                         Evaluate(zline)/2);
01701    
01702    fsolmap[name.Data()] = box;
01703    
01704    return node;
01705    
01706 }
01707 
01708 //___________________________________________________________________
01709 XMLNodePointer_t TGDMLParse::Ellipsoid(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
01710 {   
01711    //In the solids section of the GDML file, an ellipsoid may be declared. 
01712    //Unfortunately, the ellipsoid is not supported under ROOT so,
01713    //when the ellipsoid keyword is found, this function is called
01714    //to convert it to a simple box with similar dimensions, and the 
01715    //dimensions required are taken and stored, these are then bound and
01716    //converted to type TGeoBBox and stored in fsolmap map using the name 
01717    //as its key.
01718    
01719    TString lunit = "mm"; 
01720    TString ax = "0"; 
01721    TString by = "0"; 
01722    TString cz = "0";
01723    TString zcut1 = "0"; 
01724    TString zcut2 = "0";
01725    TString name = "";
01726    TString tempattr; 
01727 
01728    while (attr!=0) {
01729       
01730       tempattr = gdml->GetAttrName(attr);
01731       tempattr.ToLower();
01732       
01733       if(tempattr == "name"){ 
01734          name = gdml->GetAttrValue(attr);
01735       }
01736       else if(tempattr == "ax"){ 
01737          ax = gdml->GetAttrValue(attr);
01738       }
01739       else if(tempattr == "by"){
01740          by = gdml->GetAttrValue(attr);
01741       }
01742       else if(tempattr == "cz"){
01743          cz = gdml->GetAttrValue(attr);
01744       }
01745       else if(tempattr == "zcut1"){ 
01746          zcut1 = gdml->GetAttrValue(attr);
01747       }
01748       else if(tempattr == "zcut2"){
01749          zcut2 = gdml->GetAttrValue(attr);
01750       }
01751       else if(tempattr == "lunit"){
01752          lunit = gdml->GetAttrValue(attr);
01753       }
01754       
01755       attr = gdml->GetNextAttr(attr);   
01756    }
01757    
01758    if((strcmp(fCurrentFile,fStartFile)) != 0){
01759       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
01760    }
01761 
01762    TString axline = "";
01763    TString byline = "";
01764    TString czline = "";
01765    TString zcut1line = "";
01766    TString zcut2line = "";
01767    TString retunit;
01768    
01769    retunit = GetScale(lunit);
01770    
01771    axline = TString::Format("%s*%s", ax.Data(), retunit.Data());
01772    byline = TString::Format("%s*%s", by.Data(), retunit.Data());
01773    czline = TString::Format("%s*%s", cz.Data(), retunit.Data());
01774    Double_t radius = Evaluate(czline);
01775    Double_t dx = Evaluate(axline);
01776    Double_t dy = Evaluate(byline);
01777    Double_t sx = dx/radius;
01778    Double_t sy = dy/radius;
01779    Double_t sz = 1.;
01780    zcut1line = TString::Format("%s*%s", zcut1.Data(), retunit.Data());
01781    zcut2line = TString::Format("%s*%s", zcut2.Data(), retunit.Data());
01782    Double_t z1 = Evaluate(zcut1line);
01783    Double_t z2 = Evaluate(zcut2line);
01784 
01785    TGeoSphere *sph = new TGeoSphere(0,radius);
01786    TGeoScale *scl = new TGeoScale("",sx,sy,sz);
01787    TGeoScaledShape *shape = new TGeoScaledShape(NameShort(name), sph, scl);
01788    if(z1==0.0 && z2==0.0)
01789    {
01790       fsolmap[name.Data()] = shape;
01791    }
01792    else
01793    {
01794       Double_t origin[3] = {0.,0.,0.};
01795       origin[2] = 0.5*(z1+z2);
01796       Double_t dz = 0.5*(z2-z1);
01797       TGeoBBox *pCutBox = new TGeoBBox("cutBox", dx, dy, dz, origin);
01798       TGeoBoolNode *pBoolNode = new TGeoIntersection(shape,pCutBox,0,0);
01799       TGeoCompositeShape *cs = new TGeoCompositeShape(NameShort(name), pBoolNode);
01800       fsolmap[name.Data()] = cs;
01801    }
01802    
01803    return node;
01804    
01805 }
01806 
01807 //_______________________________________________________
01808 XMLNodePointer_t TGDMLParse::Paraboloid(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
01809 {   
01810    //In the solids section of the GDML file, a Paraboloid may be declared. 
01811    //when the paraboloid keyword is found, this function is called, and the 
01812    //dimensions required are taken and stored, these are then bound and
01813    //converted to type TGeoParaboloid and stored in fsolmap map using the name 
01814    //as its key.
01815 
01816    TString lunit = "mm"; 
01817    TString rlopos = "0"; 
01818    TString rhipos = "0"; 
01819    TString dzpos = "0"; 
01820    TString name = "";
01821    TString tempattr; 
01822 
01823    while (attr!=0) {
01824       
01825       tempattr = gdml->GetAttrName(attr);
01826       tempattr.ToLower();
01827       
01828       if(tempattr == "name") { 
01829          name = gdml->GetAttrValue(attr);
01830       }
01831       else if(tempattr == "rlo") { 
01832          rlopos = gdml->GetAttrValue(attr);
01833       }
01834       else if(tempattr == "rhi"){
01835          rhipos = gdml->GetAttrValue(attr);
01836       }
01837       else if (tempattr == "dz"){
01838          dzpos = gdml->GetAttrValue(attr);
01839       }
01840       else if (tempattr == "lunit"){
01841          lunit = gdml->GetAttrValue(attr);
01842       }
01843       
01844       attr = gdml->GetNextAttr(attr);   
01845    }
01846 
01847    if((strcmp(fCurrentFile,fStartFile)) != 0){
01848       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
01849    }
01850 
01851    TString rloline = "";
01852    TString rhiline = "";
01853    TString dzline = "";
01854    TString retunit;
01855    
01856    retunit = GetScale(lunit);
01857    
01858    rloline = TString::Format("%s*%s", rlopos.Data(), retunit.Data());
01859    rhiline = TString::Format("%s*%s", rhipos.Data(), retunit.Data());
01860    dzline = TString::Format("%s*%s", dzpos.Data(), retunit.Data());
01861    
01862    TGeoParaboloid* paraboloid = new TGeoParaboloid(NameShort(name),Evaluate(rloline),
01863                               Evaluate(rhiline),
01864                               Evaluate(dzline));
01865    
01866    fsolmap[name.Data()] = paraboloid;
01867    
01868    return node;
01869    
01870 }
01871 
01872 //_______________________________________________________
01873 XMLNodePointer_t TGDMLParse::Arb8(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
01874 {   
01875    //In the solids section of the GDML file, an Arb8 may be declared. 
01876    //when the arb8 keyword is found, this function is called, and the 
01877    //dimensions required are taken and stored, these are then bound and
01878    //converted to type TGeoArb8 and stored in fsolmap map using the name 
01879    //as its key.
01880 
01881    TString lunit = "mm"; 
01882    TString v1xpos = "0";
01883    TString v1ypos = "0";
01884    TString v2xpos = "0";
01885    TString v2ypos = "0";
01886    TString v3xpos = "0";
01887    TString v3ypos = "0";
01888    TString v4xpos = "0";
01889    TString v4ypos = "0";
01890    TString v5xpos = "0";
01891    TString v5ypos = "0";
01892    TString v6xpos = "0";
01893    TString v6ypos = "0";
01894    TString v7xpos = "0";
01895    TString v7ypos = "0";
01896    TString v8xpos = "0";
01897    TString v8ypos = "0"; 
01898    TString dzpos = "0"; 
01899    TString name = "";
01900    TString tempattr; 
01901    
01902    while (attr!=0) {
01903       
01904       tempattr = gdml->GetAttrName(attr);
01905       tempattr.ToLower();
01906       
01907       if(tempattr == "name") { 
01908          name = gdml->GetAttrValue(attr);
01909       }
01910       else if(tempattr == "v1x") { 
01911          v1xpos = gdml->GetAttrValue(attr);
01912       }
01913       else if(tempattr == "v1y") {
01914          v1ypos = gdml->GetAttrValue(attr);
01915       }
01916       else if(tempattr == "v2x") { 
01917          v2xpos = gdml->GetAttrValue(attr);
01918       }
01919       else if(tempattr == "v2y") {
01920          v2ypos = gdml->GetAttrValue(attr);
01921       }
01922       else if(tempattr == "v3x") { 
01923          v3xpos = gdml->GetAttrValue(attr);
01924       }
01925       else if(tempattr == "v3y") {
01926          v3ypos = gdml->GetAttrValue(attr);
01927       }
01928       else if(tempattr == "v4x") { 
01929          v4xpos = gdml->GetAttrValue(attr);
01930       }
01931       else if(tempattr == "v4y") {
01932          v4ypos = gdml->GetAttrValue(attr);
01933       }
01934       else if(tempattr == "v5x") { 
01935          v5xpos = gdml->GetAttrValue(attr);
01936       }
01937       else if(tempattr == "v5y") {
01938          v5ypos = gdml->GetAttrValue(attr);
01939       }
01940       else if(tempattr == "v6x") { 
01941          v6xpos = gdml->GetAttrValue(attr);
01942       }
01943       else if(tempattr == "v6y") {
01944          v6ypos = gdml->GetAttrValue(attr);
01945       }
01946       else if(tempattr == "v7x") { 
01947          v7xpos = gdml->GetAttrValue(attr);
01948       }
01949       else if(tempattr == "v7y") {
01950          v7ypos = gdml->GetAttrValue(attr);
01951       }
01952       else if(tempattr == "v8x") { 
01953          v8xpos = gdml->GetAttrValue(attr);
01954       }
01955       else if(tempattr == "v8y") {
01956          v8ypos = gdml->GetAttrValue(attr);
01957       }
01958       else if(tempattr == "dz") { 
01959          dzpos = gdml->GetAttrValue(attr);
01960       }
01961       else if (tempattr == "lunit") {
01962          lunit = gdml->GetAttrValue(attr);
01963       }
01964       
01965       attr = gdml->GetNextAttr(attr);   
01966    }
01967 
01968    if((strcmp(fCurrentFile,fStartFile)) != 0){
01969       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
01970    }
01971 
01972    TString v1xline = ""; 
01973    TString v1yline = "";
01974    TString v2xline = "";
01975    TString v2yline   = "";
01976    TString v3xline = "";
01977    TString v3yline = "";
01978    TString v4xline = "";
01979    TString v4yline   = "";
01980    TString v5xline = "";
01981    TString v5yline = "";
01982    TString v6xline = "";
01983    TString v6yline   = "";
01984    TString v7xline = "";
01985    TString v7yline = "";
01986    TString v8xline = "";
01987    TString v8yline   = "";
01988    TString dzline = "";
01989    
01990    TString retunit;
01991    
01992    retunit = GetScale(lunit);
01993    
01994    v1xline = TString::Format("%s*%s", v1xpos.Data(), retunit.Data());
01995    v1yline = TString::Format("%s*%s", v1ypos.Data(), retunit.Data());
01996    v2xline = TString::Format("%s*%s", v2xpos.Data(), retunit.Data());
01997    v2yline = TString::Format("%s*%s", v2ypos.Data(), retunit.Data());
01998    v3xline = TString::Format("%s*%s", v3xpos.Data(), retunit.Data());
01999    v3yline = TString::Format("%s*%s", v3ypos.Data(), retunit.Data());
02000    v4xline = TString::Format("%s*%s", v4xpos.Data(), retunit.Data());
02001    v4yline = TString::Format("%s*%s", v4ypos.Data(), retunit.Data());
02002    v5xline = TString::Format("%s*%s", v5xpos.Data(), retunit.Data());
02003    v5yline = TString::Format("%s*%s", v5ypos.Data(), retunit.Data());
02004    v6xline = TString::Format("%s*%s", v6xpos.Data(), retunit.Data());
02005    v6yline = TString::Format("%s*%s", v6ypos.Data(), retunit.Data());
02006    v7xline = TString::Format("%s*%s", v7xpos.Data(), retunit.Data());
02007    v7yline = TString::Format("%s*%s", v7ypos.Data(), retunit.Data());
02008    v8xline = TString::Format("%s*%s", v8xpos.Data(), retunit.Data());
02009    v8yline = TString::Format("%s*%s", v8ypos.Data(), retunit.Data());
02010    dzline  = TString::Format("%s*%s", dzpos.Data(),  retunit.Data());
02011 
02012    
02013    TGeoArb8* arb8 = new TGeoArb8(NameShort(name), Evaluate(dzline));
02014 
02015    arb8->SetVertex(0, Evaluate(v1xline),Evaluate(v1yline));
02016    arb8->SetVertex(1, Evaluate(v2xline),Evaluate(v2yline));
02017    arb8->SetVertex(2, Evaluate(v3xline),Evaluate(v3yline));
02018    arb8->SetVertex(3, Evaluate(v4xline),Evaluate(v4yline));
02019    arb8->SetVertex(4, Evaluate(v5xline),Evaluate(v5yline));
02020    arb8->SetVertex(5, Evaluate(v6xline),Evaluate(v6yline));
02021    arb8->SetVertex(6, Evaluate(v7xline),Evaluate(v7yline));
02022    arb8->SetVertex(7, Evaluate(v8xline),Evaluate(v8yline));                   
02023 
02024    fsolmap[name.Data()] = arb8;
02025    
02026    return node;
02027 
02028 }
02029 
02030 //_______________________________________________________
02031 XMLNodePointer_t TGDMLParse::Tube(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
02032 {   
02033    //In the solids section of the GDML file, a Tube may be declared. 
02034    //when the tube keyword is found, this function is called, and the 
02035    //dimensions required are taken and stored, these are then bound and
02036    //converted to type TGeoTubeSeg and stored in fsolmap map using the name 
02037    //as its key.
02038 
02039    TString lunit = "mm"; 
02040    TString aunit = "rad";
02041    TString rmin = "0"; 
02042    TString rmax = "0"; 
02043    TString z = "0";
02044    TString startphi = "0";
02045    TString deltaphi = "0";
02046    TString name = "";
02047    TString tempattr; 
02048    
02049    while (attr!=0) {
02050       
02051       tempattr = gdml->GetAttrName(attr);
02052       tempattr.ToLower();
02053       
02054       if(tempattr == "name") { 
02055          name = gdml->GetAttrValue(attr);
02056       }
02057       else if(tempattr == "rmin") { 
02058          rmin = gdml->GetAttrValue(attr);
02059       }
02060       else if(tempattr == "rmax") {
02061          rmax = gdml->GetAttrValue(attr);
02062       }
02063       else if (tempattr == "z") {
02064          z = gdml->GetAttrValue(attr);
02065       }
02066       else if (tempattr == "lunit") {
02067          lunit = gdml->GetAttrValue(attr);
02068       }
02069       else if (tempattr == "aunit") {
02070          aunit = gdml->GetAttrValue(attr);
02071       }
02072       else if (tempattr == "startphi") {
02073          startphi = gdml->GetAttrValue(attr);
02074       }
02075       else if (tempattr == "deltaphi") {
02076          deltaphi = gdml->GetAttrValue(attr);
02077       }
02078       
02079       attr = gdml->GetNextAttr(attr);   
02080    }
02081 
02082    if((strcmp(fCurrentFile,fStartFile)) != 0){
02083       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
02084    }
02085    
02086    TString rminline = "";
02087    TString rmaxline= "";
02088    TString zline = "";
02089    TString startphiline = "";
02090    TString deltaphiline = "";
02091    
02092    TString retlunit; 
02093    TString retaunit;
02094 
02095    retlunit = GetScale(lunit);
02096    retaunit = GetScale(aunit);
02097 
02098    rminline = TString::Format("%s*%s", rmin.Data(), retlunit.Data());
02099    rmaxline = TString::Format("%s*%s", rmax.Data(), retlunit.Data());
02100    zline = TString::Format("%s*%s", z.Data(), retlunit.Data());
02101    startphiline = TString::Format("%s*%s", startphi.Data(), retaunit.Data());
02102    deltaphiline = TString::Format("(%s*%s) + %s", deltaphi.Data(), retaunit.Data(), startphiline.Data());
02103 
02104    TGeoTubeSeg* tube = new TGeoTubeSeg(NameShort(name),Evaluate(rminline),
02105                            Evaluate(rmaxline),
02106                            Evaluate(zline)/2, 
02107                            Evaluate(startphiline),
02108                            Evaluate(deltaphiline));
02109 
02110    fsolmap[name.Data()] = tube;
02111    
02112    return node;
02113    
02114 }
02115 
02116 //_______________________________________________________
02117 XMLNodePointer_t TGDMLParse::CutTube(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
02118 {   
02119    //In the solids section of the GDML file, a Cut Tube may be declared. 
02120    //when the cutTube keyword is found, this function is called, and the 
02121    //dimensions required are taken and stored, these are then bound and
02122    //converted to type TGeoCtub and stored in fsolmap map using the name 
02123    //as its key.
02124 
02125    TString lunit = "mm"; 
02126    TString aunit = "rad";
02127    TString rmin = "0"; 
02128    TString rmax = "0"; 
02129    TString z = "0";
02130    TString startphi = "0";
02131    TString deltaphi = "0";
02132    TString lowX = "0";
02133    TString lowY = "0";
02134    TString lowZ = "0";
02135    TString highX = "0";
02136    TString highY = "0";
02137    TString highZ = "0";
02138    TString name = "";
02139    TString tempattr; 
02140    
02141    while (attr!=0) {
02142       
02143       tempattr = gdml->GetAttrName(attr);
02144       tempattr.ToLower();
02145       
02146       if(tempattr == "name") { 
02147          name = gdml->GetAttrValue(attr);
02148       }
02149       else if(tempattr == "rmin") { 
02150          rmin = gdml->GetAttrValue(attr);
02151       }
02152       else if(tempattr == "rmax"){
02153          rmax = gdml->GetAttrValue(attr);
02154       }
02155       else if (tempattr == "z") {
02156          z = gdml->GetAttrValue(attr);
02157       }
02158       else if (tempattr == "lunit") {
02159          lunit = gdml->GetAttrValue(attr);
02160       }
02161       else if (tempattr == "aunit") {
02162          aunit = gdml->GetAttrValue(attr);
02163       }
02164       else if (tempattr == "startphi") {
02165          startphi = gdml->GetAttrValue(attr);
02166       }
02167       else if (tempattr == "deltaphi") {
02168          deltaphi = gdml->GetAttrValue(attr);
02169       }
02170       else if (tempattr == "lowx") {
02171          lowX = gdml->GetAttrValue(attr);
02172       }
02173       else if (tempattr == "lowy") {
02174          lowY = gdml->GetAttrValue(attr);
02175       }
02176       else if (tempattr == "lowz") {
02177          lowZ = gdml->GetAttrValue(attr);
02178       }
02179       else if (tempattr == "highx") {
02180          highX = gdml->GetAttrValue(attr);
02181       }
02182       else if (tempattr == "highy") {
02183          highY = gdml->GetAttrValue(attr);
02184       }
02185       else if (tempattr == "highz") {
02186          highZ = gdml->GetAttrValue(attr);
02187       }
02188 
02189       attr = gdml->GetNextAttr(attr);   
02190    }
02191 
02192    if((strcmp(fCurrentFile,fStartFile)) != 0){
02193       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
02194    }
02195 
02196    TString rminline = "";
02197    TString rmaxline = "";
02198    TString zline = "";
02199    TString startphiline = "";
02200    TString deltaphiline = "";
02201    TString lowXline = "";
02202    TString lowYline = "";
02203    TString lowZline = "";
02204    TString highXline = "";
02205    TString highYline = "";
02206    TString highZline = "";
02207 
02208    TString retlunit; 
02209    TString retaunit;
02210    
02211    retlunit = GetScale(lunit);
02212    retaunit = GetScale(aunit);
02213    
02214    rminline = TString::Format("%s*%s", rmin.Data(), retlunit.Data());
02215    rmaxline = TString::Format("%s*%s", rmax.Data(), retlunit.Data());
02216    zline = TString::Format("%s*%s", z.Data(), retlunit.Data());
02217    startphiline = TString::Format("%s*%s", startphi.Data(), retaunit.Data());
02218    deltaphiline = TString::Format("(%s*%s) + %s", deltaphi.Data(), retaunit.Data(), startphiline.Data());
02219    lowXline = TString::Format("%s*%s", lowX.Data(), retlunit.Data());
02220    lowYline = TString::Format("%s*%s", lowY.Data(), retlunit.Data());
02221    lowZline = TString::Format("%s*%s", lowZ.Data(), retlunit.Data());
02222    highXline = TString::Format("%s*%s", highX.Data(), retlunit.Data());
02223    highYline = TString::Format("%s*%s", highY.Data(), retlunit.Data());
02224    highZline = TString::Format("%s*%s", highZ.Data(), retlunit.Data());
02225 
02226    
02227    TGeoCtub* cuttube = new TGeoCtub(NameShort(name),Evaluate(rminline),
02228                       Evaluate(rmaxline),
02229                       Evaluate(zline)/2, 
02230                       Evaluate(startphiline),
02231                       Evaluate(deltaphiline),
02232                       Evaluate(lowXline),
02233                       Evaluate(lowYline),
02234                       Evaluate(lowZline),
02235                       Evaluate(highXline),
02236                       Evaluate(highYline),
02237                       Evaluate(highZline));
02238    
02239 
02240    fsolmap[name.Data()] = cuttube;
02241    
02242    return node;
02243 
02244 }
02245 
02246 //_______________________________________________________
02247 XMLNodePointer_t TGDMLParse::Cone(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
02248 {   
02249    //In the solids section of the GDML file, a cone may be declared. 
02250    //when the cone keyword is found, this function is called, and the 
02251    //dimensions required are taken and stored, these are then bound and
02252    //converted to type TGeoConSeg and stored in fsolmap map using the name 
02253    //as its key.
02254 
02255    TString lunit = "mm"; 
02256    TString aunit = "rad";
02257    TString rmin1 = "0"; 
02258    TString rmax1 = "0"; 
02259    TString rmin2 = "0"; 
02260    TString rmax2 = "0"; 
02261    TString z = "0";
02262    TString startphi = "0";
02263    TString deltaphi = "0";
02264    TString name = "";
02265    TString tempattr; 
02266    
02267    while (attr!=0) {
02268       
02269       tempattr = gdml->GetAttrName(attr);
02270       tempattr.ToLower();
02271       
02272       if(tempattr == "name") { 
02273          name = gdml->GetAttrValue(attr);
02274       }
02275       else if(tempattr == "rmin1") { 
02276          rmin1 = gdml->GetAttrValue(attr);
02277       }
02278       else if(tempattr == "rmax1"){
02279          rmax1 = gdml->GetAttrValue(attr);
02280       }
02281       else if(tempattr == "rmin2") {
02282          rmin2 = gdml->GetAttrValue(attr);
02283       }
02284       else if(tempattr == "rmax2"){
02285          rmax2 = gdml->GetAttrValue(attr);
02286       }
02287       else if (tempattr == "z"){
02288          z = gdml->GetAttrValue(attr);
02289       }
02290       else if (tempattr == "lunit"){
02291          lunit = gdml->GetAttrValue(attr);
02292       }
02293       else if (tempattr == "aunit"){
02294          aunit = gdml->GetAttrValue(attr);
02295       }
02296       else if (tempattr == "startphi"){
02297          startphi = gdml->GetAttrValue(attr);
02298       }
02299       else if (tempattr == "deltaphi"){
02300          deltaphi = gdml->GetAttrValue(attr);
02301       }
02302       
02303       attr = gdml->GetNextAttr(attr);   
02304    }
02305 
02306    if((strcmp(fCurrentFile,fStartFile)) != 0){
02307       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
02308    }
02309 
02310    TString rmin1line = "";
02311    TString rmax1line = "";
02312    TString rmin2line = "";
02313    TString rmax2line = "";
02314    TString zline = "";
02315    TString startphiline = "";
02316    TString deltaphiline = "";
02317    TString retlunit; 
02318    TString retaunit;
02319    
02320    retlunit = GetScale(lunit);
02321    retaunit = GetScale(aunit);
02322    
02323    rmin1line = TString::Format("%s*%s", rmin1.Data(), retlunit.Data());
02324    rmax1line = TString::Format("%s*%s", rmax1.Data(), retlunit.Data());
02325    rmin2line = TString::Format("%s*%s", rmin2.Data(), retlunit.Data());
02326    rmax2line = TString::Format("%s*%s", rmax2.Data(), retlunit.Data());
02327    zline = TString::Format("%s*%s", z.Data(), retlunit.Data());
02328    startphiline = TString::Format("%s*%s", startphi.Data(), retaunit.Data());
02329    deltaphiline = TString::Format("%s*%s", deltaphi.Data(), retaunit.Data());
02330    Double_t sphi = Evaluate(startphiline);
02331    Double_t ephi = sphi + Evaluate(deltaphiline);
02332 
02333       
02334    TGeoConeSeg* cone = new TGeoConeSeg(NameShort(name),Evaluate(zline)/2,
02335                            Evaluate(rmin1line),
02336                            Evaluate(rmax1line),
02337                            Evaluate(rmin2line),
02338                            Evaluate(rmax2line),
02339                            sphi, ephi);
02340                    
02341    fsolmap[name.Data()] = cone;
02342    
02343    return node;
02344 
02345 }
02346 
02347 //_______________________________________________________
02348 XMLNodePointer_t TGDMLParse::Trap(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
02349 {   
02350    //In the solids section of the GDML file, a Trap may be declared. 
02351    //when the trap keyword is found, this function is called, and the 
02352    //dimensions required are taken and stored, these are then bound and
02353    //converted to type TGeoTrap and stored in fsolmap map using the name 
02354    //as its key.
02355 
02356    TString lunit = "mm"; 
02357    TString aunit = "rad";
02358    TString x1 = "0"; 
02359    TString x2 = "0"; 
02360    TString x3 = "0"; 
02361    TString x4 = "0"; 
02362    TString y1 = "0"; 
02363    TString y2 = "0";
02364    TString z = "0";
02365    TString phi = "0";
02366    TString theta = "0";
02367    TString alpha1 = "0"; 
02368    TString alpha2 = "0"; 
02369    TString name = "";
02370    TString tempattr; 
02371    
02372    while (attr!=0) {
02373       
02374       tempattr = gdml->GetAttrName(attr);
02375       tempattr.ToLower();
02376       
02377       if(tempattr == "name") { 
02378          name = gdml->GetAttrValue(attr);
02379       }
02380       else if(tempattr == "x1") {
02381          x1 = gdml->GetAttrValue(attr);
02382       }
02383       else if(tempattr == "x2") {
02384          x2 = gdml->GetAttrValue(attr);
02385       }
02386       else if(tempattr == "x3") { 
02387          x3 = gdml->GetAttrValue(attr);
02388       }
02389       else if(tempattr == "x4") {
02390          x4 = gdml->GetAttrValue(attr);
02391       }
02392       else if(tempattr == "y1") { 
02393          y1 = gdml->GetAttrValue(attr);
02394       }
02395       else if(tempattr == "y2") {
02396          y2 = gdml->GetAttrValue(attr);
02397       }
02398       else if (tempattr == "z") {
02399          z = gdml->GetAttrValue(attr);
02400       }
02401       else if (tempattr == "lunit") {
02402          lunit = gdml->GetAttrValue(attr);
02403       }
02404       else if (tempattr == "aunit"){
02405          aunit = gdml->GetAttrValue(attr);
02406       }
02407       else if (tempattr == "phi"){
02408          phi = gdml->GetAttrValue(attr);
02409       }
02410       else if (tempattr == "theta"){
02411          theta = gdml->GetAttrValue(attr);
02412       }
02413       else if(tempattr == "alpha1") { 
02414          alpha1 = gdml->GetAttrValue(attr);
02415       }
02416       else if(tempattr == "alpha2"){
02417          alpha2 = gdml->GetAttrValue(attr);
02418       }
02419       
02420       attr = gdml->GetNextAttr(attr);   
02421    }
02422 
02423    if((strcmp(fCurrentFile,fStartFile)) != 0){
02424       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
02425    }
02426 
02427    TString x1line = ""; 
02428    TString x2line = ""; 
02429    TString x3line    = ""; 
02430    TString x4line = ""; 
02431    TString y1line = ""; 
02432    TString y2line = ""; 
02433    TString zline = ""; 
02434    TString philine = ""; 
02435    TString thetaline = ""; 
02436    TString alpha1line = ""; 
02437    TString alpha2line = ""; 
02438    TString retlunit; 
02439    TString retaunit;
02440    
02441    retlunit = GetScale(lunit);
02442    retaunit = GetScale(aunit);
02443    
02444    x1line = TString::Format("%s*%s", x1.Data(), retlunit.Data());
02445    x2line = TString::Format("%s*%s", x2.Data(), retlunit.Data());
02446    x3line = TString::Format("%s*%s", x3.Data(), retlunit.Data());
02447    x4line = TString::Format("%s*%s", x4.Data(), retlunit.Data());
02448    y1line = TString::Format("%s*%s", y1.Data(), retlunit.Data());
02449    y2line = TString::Format("%s*%s", y2.Data(), retlunit.Data());
02450    zline = TString::Format("%s*%s", z.Data(), retlunit.Data());
02451    philine = TString::Format("%s*%s", phi.Data(), retaunit.Data());
02452    thetaline = TString::Format("%s*%s", theta.Data(), retaunit.Data());
02453    alpha1line = TString::Format("%s*%s", alpha1.Data(), retaunit.Data());
02454    alpha2line = TString::Format("%s*%s", alpha2.Data(), retaunit.Data());
02455    
02456    TGeoTrap* trap = new TGeoTrap(NameShort(name),Evaluate(zline)/2,
02457                   Evaluate(thetaline),
02458                   Evaluate(philine),
02459                   Evaluate(y1line)/2,
02460                   Evaluate(x1line)/2,
02461                   Evaluate(x2line)/2,
02462                   Evaluate(alpha1line),
02463                   Evaluate(y2line)/2,
02464                   Evaluate(x3line)/2,
02465                   Evaluate(x4line)/2,
02466                   Evaluate(alpha2line));
02467    
02468    fsolmap[name.Data()] = trap;
02469    
02470    return node;
02471    
02472 }
02473 
02474 //_______________________________________________________
02475 XMLNodePointer_t TGDMLParse::Trd(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
02476 {   
02477    //In the solids section of the GDML file, a Trd may be declared. 
02478    //when the trd keyword is found, this function is called, and the 
02479    //dimensions required are taken and stored, these are then bound and
02480    //converted to type TGeoTrd2 and stored in fsolmap map using the name 
02481    //as its key.
02482 
02483    TString lunit = "mm"; 
02484    TString x1 = "0"; 
02485    TString x2 = "0";   
02486    TString y1 = "0"; 
02487    TString y2 = "0";
02488    TString z = "0";
02489    TString name = "";
02490    TString tempattr; 
02491    
02492    while (attr!=0) {
02493       
02494       tempattr = gdml->GetAttrName(attr);
02495       tempattr.ToLower();
02496       
02497       if(tempattr == "name") { 
02498          name = gdml->GetAttrValue(attr);
02499       }
02500       else if(tempattr == "x1") { 
02501          x1 = gdml->GetAttrValue(attr);
02502       }
02503       else if(tempattr == "x2"){
02504          x2 = gdml->GetAttrValue(attr);
02505       }
02506       else if(tempattr == "y1") { 
02507          y1 = gdml->GetAttrValue(attr);
02508       }
02509       else if(tempattr == "y2"){
02510          y2 = gdml->GetAttrValue(attr);
02511       }
02512       else if (tempattr == "z"){
02513          z = gdml->GetAttrValue(attr);
02514       }
02515       else if (tempattr == "lunit"){
02516          lunit = gdml->GetAttrValue(attr);
02517       }
02518       
02519       attr = gdml->GetNextAttr(attr);   
02520    }
02521    
02522    if((strcmp(fCurrentFile,fStartFile)) != 0){
02523       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
02524    }
02525 
02526    TString x1line = "";
02527    TString x2line = "";
02528    TString y1line = "";
02529    TString y2line = "";
02530    TString zline = "";
02531    TString retlunit; 
02532    
02533    retlunit = GetScale(lunit);
02534    
02535    x1line = TString::Format("%s*%s", x1.Data(), retlunit.Data());
02536    x2line = TString::Format("%s*%s", x2.Data(), retlunit.Data());
02537    y1line = TString::Format("%s*%s", y1.Data(), retlunit.Data());
02538    y2line = TString::Format("%s*%s", y2.Data(), retlunit.Data());
02539    zline = TString::Format("%s*%s", z.Data(), retlunit.Data());
02540    
02541    TGeoTrd2* trd = new TGeoTrd2(NameShort(name),
02542                         Evaluate(x1line)/2,
02543                         Evaluate(x2line)/2,
02544                         Evaluate(y1line)/2,
02545                         Evaluate(y2line)/2,
02546                         Evaluate(zline)/2);
02547                    
02548    fsolmap[name.Data()] = trd;
02549    
02550    return node;
02551 
02552 }
02553 
02554 //_______________________________________________________
02555 XMLNodePointer_t TGDMLParse::Polycone(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
02556 {   
02557    //In the solids section of the GDML file, a Polycone may be declared. 
02558    //when the polycone keyword is found, this function is called, and the 
02559    //dimensions required are taken and stored, these are then bound and
02560    //converted to type TGeoPCon and stored in fsolmap map using the name 
02561    //as its key. Polycone has Zplanes, planes along the z axis specifying 
02562    //the rmin, rmax dimenstions at that point along z.
02563 
02564    TString lunit = "mm"; 
02565    TString aunit = "rad";
02566    TString rmin = "0"; 
02567    TString rmax = "0"; 
02568    TString z = "0";
02569    TString startphi = "0";
02570    TString deltaphi = "0";
02571    TString name = "";
02572    TString tempattr; 
02573    
02574    while (attr!=0) {
02575       
02576       tempattr = gdml->GetAttrName(attr);
02577       tempattr.ToLower();
02578       
02579       if(tempattr == "name") { 
02580          name = gdml->GetAttrValue(attr);
02581       } else if (tempattr == "lunit") {
02582          lunit = gdml->GetAttrValue(attr);
02583       } else if (tempattr == "aunit") {
02584          aunit = gdml->GetAttrValue(attr);
02585       } else if (tempattr == "startphi") {
02586          startphi = gdml->GetAttrValue(attr);
02587       } else if (tempattr == "deltaphi") {
02588          deltaphi = gdml->GetAttrValue(attr);
02589       }
02590       attr = gdml->GetNextAttr(attr);   
02591    } 
02592    
02593    if((strcmp(fCurrentFile,fStartFile)) != 0){
02594       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
02595    }
02596 
02597    TString retlunit; 
02598    TString retaunit;
02599    
02600    retlunit = GetScale(lunit);
02601    retaunit = GetScale(aunit);
02602    
02603    //START TO LOOK THRU CHILD (ZPLANE) NODES... 
02604 
02605    XMLNodePointer_t child = gdml->GetChild(node);
02606    int numplanes = 0;
02607 
02608    while (child!=0){
02609       numplanes = numplanes + 1;
02610       child = gdml->GetNext(child);
02611    }
02612    
02613    int cols;
02614    int i;
02615    cols = 3;
02616    double ** table = new double*[numplanes];
02617    for(i = 0; i < numplanes; i++) {
02618       table[i] = new double[cols];
02619    }
02620    
02621    child = gdml->GetChild(node);
02622    int planeno = 0;
02623    
02624    while (child!=0) {
02625       if(strcmp(gdml->GetNodeName(child), "zplane")==0) {
02626          //removed original dec
02627          TString rminline = "";
02628          TString rmaxline = "";
02629          TString zline = "";
02630          
02631          attr = gdml->GetFirstAttr(child);
02632          
02633          while (attr!=0) {
02634             tempattr = gdml->GetAttrName(attr);
02635             tempattr.ToLower();
02636        
02637             if(tempattr == "rmin") { 
02638                rmin = gdml->GetAttrValue(attr);
02639                rminline = TString::Format("%s*%s", rmin.Data(), retlunit.Data());
02640                table[planeno][0] = Evaluate(rminline);
02641             } else if(tempattr == "rmax") {
02642                rmax = gdml->GetAttrValue(attr);
02643                rmaxline = TString::Format("%s*%s", rmax.Data(), retlunit.Data());
02644                table[planeno][1] = Evaluate(rmaxline);
02645             } else if (tempattr == "z") {
02646                z = gdml->GetAttrValue(attr);
02647                zline = TString::Format("%s*%s", z.Data(), retlunit.Data());
02648                table[planeno][2] = Evaluate(zline);
02649             }
02650             attr = gdml->GetNextAttr(attr);
02651          }
02652       }
02653       planeno = planeno + 1;
02654       child = gdml->GetNext(child);
02655    }
02656    
02657    TString startphiline = "";
02658    TString deltaphiline = "";
02659    
02660    startphiline = TString::Format("%s*%s", startphi.Data(), retaunit.Data());
02661    deltaphiline = TString::Format("%s*%s", deltaphi.Data(), retaunit.Data());
02662 
02663    TGeoPcon* poly = new TGeoPcon(NameShort(name), 
02664                   Evaluate(startphiline), 
02665                   Evaluate(deltaphiline), 
02666                   numplanes);
02667    Int_t zno = 0;
02668    
02669    for (int j = 0; j < numplanes; j++) {
02670       poly->DefineSection(zno, table[j][2], table[j][0], table[j][1]);
02671       zno = zno + 1;
02672    }
02673    
02674    fsolmap[name.Data()] = poly;
02675    for(i = 0; i < numplanes; i++) {
02676       delete [] table[i];
02677    }
02678    delete [] table;
02679    
02680    return node;
02681 }
02682 
02683 //_______________________________________________________
02684 XMLNodePointer_t TGDMLParse::Polyhedra(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
02685 {   
02686    //In the solids section of the GDML file, a Polyhedra may be declared. 
02687    //when the polyhedra keyword is found, this function is called, and the 
02688    //dimensions required are taken and stored, these are then bound and
02689    //converted to type TGeoPgon and stored in fsolmap map using the name 
02690    //as its key. Polycone has Zplanes, planes along the z axis specifying 
02691    //the rmin, rmax dimenstions at that point along z.
02692 
02693    TString lunit = "mm"; 
02694    TString aunit = "rad";
02695    TString rmin = "0"; 
02696    TString rmax = "0"; 
02697    TString z = "0";
02698    TString startphi = "0";
02699    TString deltaphi = "0";
02700    TString numsides = "1";
02701    TString name = "";
02702    TString tempattr; 
02703    
02704    while (attr!=0) {
02705       
02706       tempattr = gdml->GetAttrName(attr);
02707       tempattr.ToLower();
02708       
02709       if(tempattr == "name") { 
02710          name = gdml->GetAttrValue(attr);
02711       }
02712       else if (tempattr == "lunit"){
02713          lunit = gdml->GetAttrValue(attr);
02714       }
02715       else if (tempattr == "aunit"){
02716          aunit = gdml->GetAttrValue(attr);
02717       }
02718       else if (tempattr == "startphi"){
02719          startphi = gdml->GetAttrValue(attr);
02720       }
02721       else if (tempattr == "deltaphi"){
02722          deltaphi = gdml->GetAttrValue(attr);
02723       }
02724       else if (tempattr == "numsides"){
02725          numsides = gdml->GetAttrValue(attr);
02726       }
02727       
02728       attr = gdml->GetNextAttr(attr);   
02729    } 
02730    
02731    if((strcmp(fCurrentFile,fStartFile)) != 0){
02732       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
02733    }
02734 
02735    TString retlunit; 
02736    TString retaunit;
02737    
02738    retlunit = GetScale(lunit);
02739    retaunit = GetScale(aunit);
02740    
02741    //START TO LOOK THRU CHILD (ZPLANE) NODES... 
02742 
02743    XMLNodePointer_t child = gdml->GetChild(node);
02744    int numplanes = 0;
02745 
02746    while (child!=0){
02747       numplanes = numplanes + 1;
02748       child = gdml->GetNext(child);
02749    }
02750    
02751    int cols;
02752    int i;
02753    cols = 3;
02754    double ** table = new double*[numplanes];
02755    for(i = 0; i < numplanes; i++){
02756       table[i] = new double[cols];
02757    }
02758    
02759    child = gdml->GetChild(node);
02760    int planeno = 0;
02761    
02762    while (child!=0) {
02763       if (strcmp(gdml->GetNodeName(child), "zplane")==0){
02764     
02765          TString rminline = "";
02766          TString rmaxline = "";
02767          TString zline = "";
02768          attr = gdml->GetFirstAttr(child);
02769     
02770          while (attr!=0){
02771             tempattr = gdml->GetAttrName(attr);
02772             tempattr.ToLower();
02773        
02774             if(tempattr == "rmin") { 
02775                rmin = gdml->GetAttrValue(attr);
02776                rminline = TString::Format("%s*%s", rmin.Data(), retlunit.Data());
02777                table[planeno][0] = Evaluate(rminline);
02778             }
02779             else if(tempattr == "rmax"){
02780                rmax = gdml->GetAttrValue(attr);
02781                rmaxline = TString::Format("%s*%s", rmax.Data(), retlunit.Data());
02782                table[planeno][1] = Evaluate(rmaxline);
02783             }
02784             else if (tempattr == "z"){
02785                z = gdml->GetAttrValue(attr);
02786                zline = TString::Format("%s*%s", z.Data(), retlunit.Data());
02787                table[planeno][2] = Evaluate(zline);
02788             }
02789        
02790             attr = gdml->GetNextAttr(attr);
02791          }
02792       }
02793       planeno = planeno + 1;
02794       child = gdml->GetNext(child);
02795    }
02796    
02797    TString startphiline = "";
02798    TString deltaphiline = "";
02799    TString numsidesline = "";
02800 
02801    startphiline = TString::Format("%s*%s", startphi.Data(), retaunit.Data());
02802    deltaphiline = TString::Format("%s*%s", deltaphi.Data(), retaunit.Data());
02803    numsidesline = TString::Format("%s", numsides.Data());
02804 
02805    TGeoPgon* polyg = new TGeoPgon(NameShort(name), 
02806                   Evaluate(startphiline), 
02807                   Evaluate(deltaphiline), 
02808                   (int)Evaluate(numsidesline),
02809                   numplanes);
02810    Int_t zno = 0;
02811 
02812    for (int j = 0; j < numplanes; j++){
02813       polyg->DefineSection(zno, table[j][2], table[j][0], table[j][1]);
02814       zno = zno + 1;
02815    }
02816    
02817    fsolmap[name.Data()] = polyg;
02818    for(i = 0; i < numplanes; i++){
02819       delete [] table[i];
02820    }
02821    delete [] table;
02822    
02823    return node;
02824 
02825 }
02826 
02827 //_______________________________________________________
02828 XMLNodePointer_t TGDMLParse::Sphere(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
02829 {   
02830    //In the solids section of the GDML file, a Sphere may be declared. 
02831    //when the sphere keyword is found, this function is called, and the 
02832    //dimensions required are taken and stored, these are then bound and
02833    //converted to type TGeoSphere and stored in fsolmap map using the name 
02834    //as its key.
02835 
02836    TString lunit = "mm"; 
02837    TString aunit = "rad";
02838    TString rmin = "0"; 
02839    TString rmax = "0"; 
02840    TString startphi = "0";
02841    TString deltaphi = "0";
02842    TString starttheta = "0";
02843    TString deltatheta = "0";
02844    TString name = "";
02845    TString tempattr; 
02846    
02847    while (attr!=0) {
02848       tempattr = gdml->GetAttrName(attr);
02849       tempattr.ToLower();
02850       
02851       if(tempattr == "name") { 
02852          name = gdml->GetAttrValue(attr);
02853       }
02854       else if(tempattr == "rmin") { 
02855          rmin = gdml->GetAttrValue(attr);
02856       }
02857       else if(tempattr == "rmax") {
02858          rmax = gdml->GetAttrValue(attr);
02859       }
02860       else if (tempattr == "lunit"){
02861          lunit = gdml->GetAttrValue(attr);
02862       }
02863       else if (tempattr == "aunit"){
02864          aunit = gdml->GetAttrValue(attr);
02865       }
02866       else if (tempattr == "startphi"){
02867          startphi = gdml->GetAttrValue(attr);
02868       }
02869       else if (tempattr == "deltaphi"){
02870          deltaphi = gdml->GetAttrValue(attr);
02871       }
02872       else if (tempattr == "starttheta"){
02873          starttheta = gdml->GetAttrValue(attr);
02874       }
02875       else if (tempattr == "deltatheta"){
02876          deltatheta = gdml->GetAttrValue(attr);
02877       }
02878       
02879       attr = gdml->GetNextAttr(attr);   
02880    }
02881 
02882    if((strcmp(fCurrentFile,fStartFile)) != 0){
02883       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
02884    }
02885 
02886    TString rminline = "";
02887    TString rmaxline = "";
02888    TString startphiline = "";
02889    TString deltaphiline = "";
02890    TString startthetaline = "";
02891    TString deltathetaline = "";
02892    TString retlunit; 
02893    TString retaunit;
02894    
02895    retlunit = GetScale(lunit);
02896    retaunit = GetScale(aunit);
02897    
02898    rminline = TString::Format("%s*%s", rmin.Data(), retlunit.Data());
02899    rmaxline = TString::Format("%s*%s", rmax.Data(), retlunit.Data());
02900    startphiline = TString::Format("%s*%s", startphi.Data(), retaunit.Data());
02901    deltaphiline = TString::Format("(%s*%s) + %s", deltaphi.Data(), retaunit.Data(), startphiline.Data());
02902    startthetaline = TString::Format("%s*%s", starttheta.Data(), retaunit.Data());
02903    deltathetaline = TString::Format("(%s*%s) + %s", deltatheta.Data(), retaunit.Data(), startthetaline.Data()); 
02904 
02905    TGeoSphere* sphere = new TGeoSphere(NameShort(name),
02906                            Evaluate(rminline),
02907                            Evaluate(rmaxline),
02908                            Evaluate(startthetaline),
02909                            Evaluate(deltathetaline),
02910                            Evaluate(startphiline),
02911                            Evaluate(deltaphiline));
02912                    
02913    fsolmap[name.Data()] = sphere;
02914    
02915    return node;
02916 
02917 }
02918 
02919 //_______________________________________________________
02920 XMLNodePointer_t TGDMLParse::Torus(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
02921 {   
02922    //In the solids section of the GDML file, a Torus may be declared. 
02923    //when the torus keyword is found, this function is called, and the 
02924    //dimensions required are taken and stored, these are then bound and
02925    //converted to type TGeoTorus and stored in fsolmap map using the name 
02926    //as its key.
02927    
02928    TString lunit = "mm"; 
02929    TString aunit = "rad";
02930    TString rmin = "0"; 
02931    TString rmax = "0"; 
02932    TString rtor = "0";
02933    TString startphi = "0";
02934    TString deltaphi = "0";
02935    TString name = "";
02936    TString tempattr; 
02937    
02938    while (attr!=0) {
02939       
02940       tempattr = gdml->GetAttrName(attr);
02941       tempattr.ToLower();
02942       
02943       if(tempattr == "name") { 
02944          name = gdml->GetAttrValue(attr);
02945       }
02946       else if(tempattr == "rmin") { 
02947          rmin = gdml->GetAttrValue(attr);
02948       }
02949       else if(tempattr == "rmax"){
02950          rmax = gdml->GetAttrValue(attr);
02951       }
02952       else if (tempattr == "rtor"){
02953          rtor = gdml->GetAttrValue(attr);
02954       }
02955       else if (tempattr == "lunit"){
02956          lunit = gdml->GetAttrValue(attr);
02957       }
02958       else if (tempattr == "aunit"){
02959          aunit = gdml->GetAttrValue(attr);
02960       }
02961       else if (tempattr == "startphi"){
02962          startphi = gdml->GetAttrValue(attr);
02963       }
02964       else if (tempattr == "deltaphi"){
02965          deltaphi = gdml->GetAttrValue(attr);
02966       }
02967       
02968       attr = gdml->GetNextAttr(attr);   
02969    }
02970 
02971    if((strcmp(fCurrentFile,fStartFile)) != 0){
02972       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
02973    }
02974 
02975    TString rminline = "";
02976    TString rmaxline = "";
02977    TString rtorline = "";
02978    TString startphiline = "";
02979    TString deltaphiline = "";
02980    TString retlunit; 
02981    TString retaunit;
02982    
02983    retlunit = GetScale(lunit);
02984    retaunit = GetScale(aunit);
02985    
02986    rminline = TString::Format("%s*%s", rmin.Data(), retlunit.Data());
02987    rmaxline = TString::Format("%s*%s", rmax.Data(), retlunit.Data());
02988    rtorline = TString::Format("%s*%s", rtor.Data(), retlunit.Data());
02989    startphiline = TString::Format("%s*%s", startphi.Data(), retaunit.Data());
02990    deltaphiline = TString::Format("%s*%s", deltaphi.Data(), retaunit.Data());
02991 
02992       
02993    TGeoTorus* torus = new TGeoTorus(NameShort(name),Evaluate(rtorline),
02994                            Evaluate(rminline),
02995                            Evaluate(rmaxline),
02996                            Evaluate(startphiline),
02997                            Evaluate(deltaphiline));
02998                    
02999    fsolmap[name.Data()] = torus;
03000    
03001    return node;
03002 
03003 }
03004 
03005 //_______________________________________________________
03006 XMLNodePointer_t TGDMLParse::Hype(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
03007 {
03008    //In the solids section of the GDML file, a Hype may be declared. 
03009    //when the hype keyword is found, this function is called, and the 
03010    //dimensions required are taken and stored, these are then bound and
03011    //converted to type TGeoHype and stored in fsolmap map using the name 
03012    //as its key.
03013 
03014    TString lunit = "mm"; 
03015    TString aunit = "rad";
03016    TString rmin = "0"; 
03017    TString rmax = "0"; 
03018    TString z = "0";
03019    TString inst = "0";
03020    TString outst = "0";
03021    TString name = "";
03022    TString tempattr; 
03023    
03024    while (attr!=0) {
03025       tempattr = gdml->GetAttrName(attr);
03026       tempattr.ToLower();
03027       
03028       if(tempattr == "name") { 
03029          name = gdml->GetAttrValue(attr);
03030       }
03031       else if(tempattr == "rmin") { 
03032          rmin = gdml->GetAttrValue(attr);
03033       }
03034       else if(tempattr == "rmax"){
03035          rmax = gdml->GetAttrValue(attr);
03036       }
03037       else if (tempattr == "z"){
03038          z = gdml->GetAttrValue(attr);
03039       }
03040       else if (tempattr == "lunit"){
03041          lunit = gdml->GetAttrValue(attr);
03042       }
03043       else if (tempattr == "aunit"){
03044          aunit = gdml->GetAttrValue(attr);
03045       }
03046       else if (tempattr == "inst"){
03047          inst = gdml->GetAttrValue(attr);
03048       }
03049       else if (tempattr == "outst"){
03050          outst = gdml->GetAttrValue(attr);
03051       }
03052       
03053       attr = gdml->GetNextAttr(attr);   
03054    }
03055 
03056    if((strcmp(fCurrentFile,fStartFile)) != 0){
03057       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
03058    }
03059 
03060    TString rminline = "";
03061    TString rmaxline = "";
03062    TString zline = "";
03063    TString instline = "";
03064    TString outstline = "";
03065    TString retlunit; 
03066    TString retaunit;
03067    
03068    retlunit = GetScale(lunit);
03069    retaunit = GetScale(aunit);
03070    
03071    rminline = TString::Format("%s*%s", rmin.Data(), retlunit.Data());
03072    rmaxline = TString::Format("%s*%s", rmax.Data(), retlunit.Data());
03073    zline = TString::Format("%s*%s", z.Data(), retlunit.Data());
03074    instline = TString::Format("%s*%s", inst.Data(), retaunit.Data());
03075    outstline = TString::Format("%s*%s", outst.Data(), retaunit.Data());
03076 
03077       
03078    TGeoHype* hype = new TGeoHype(NameShort(name),
03079                   Evaluate(rminline),
03080                   Evaluate(instline),
03081                   Evaluate(rmaxline),
03082                   Evaluate(outstline),
03083                   Evaluate(zline)/2);
03084                    
03085    fsolmap[name.Data()] = hype;
03086    
03087    return node;
03088 
03089 }
03090 
03091 //_______________________________________________________
03092 XMLNodePointer_t TGDMLParse::Para(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
03093 {
03094    //In the solids section of the GDML file, a Para may be declared. 
03095    //when the para keyword is found, this function is called, and the 
03096    //dimensions required are taken and stored, these are then bound and
03097    //converted to type TGeoPara and stored in fsolmap map using the name 
03098    //as its key.
03099 
03100    TString lunit = "mm"; 
03101    TString aunit = "rad";
03102    TString x = "0"; 
03103    TString y = "0"; 
03104    TString z = "0";
03105    TString phi = "0";
03106    TString theta = "0";
03107    TString alpha = "0";
03108    TString name = "";
03109    TString tempattr; 
03110    
03111    while (attr!=0) {
03112       
03113       tempattr = gdml->GetAttrName(attr);
03114       tempattr.ToLower();
03115       
03116       if(tempattr == "name") { 
03117          name = gdml->GetAttrValue(attr);
03118       }
03119       else if(tempattr == "x") {
03120          x = gdml->GetAttrValue(attr);
03121       }
03122       else if(tempattr == "y"){
03123          y = gdml->GetAttrValue(attr);
03124       }
03125       else if (tempattr == "z"){
03126          z = gdml->GetAttrValue(attr);
03127       }
03128       else if (tempattr == "lunit"){
03129          lunit = gdml->GetAttrValue(attr);
03130       }
03131       else if (tempattr == "aunit"){
03132          aunit = gdml->GetAttrValue(attr);
03133       }
03134       else if (tempattr == "phi"){
03135          phi = gdml->GetAttrValue(attr);
03136       }
03137       else if (tempattr == "theta"){
03138          theta = gdml->GetAttrValue(attr);
03139       }
03140       else if (tempattr == "alpha"){
03141          alpha = gdml->GetAttrValue(attr);
03142       }
03143       
03144       attr = gdml->GetNextAttr(attr);   
03145    }
03146 
03147    if((strcmp(fCurrentFile,fStartFile)) != 0){
03148       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
03149    }
03150 
03151    TString xline = "";
03152    TString yline = "";
03153    TString zline = "";
03154    TString philine = "";
03155    TString alphaline = "";
03156    TString thetaline = "";
03157    TString retlunit = ""; 
03158    TString retaunit = "";
03159    
03160    retlunit = GetScale(lunit);
03161    retaunit = GetScale(aunit);
03162    
03163    xline = TString::Format("%s*%s", x.Data(), retlunit.Data());
03164    yline = TString::Format("%s*%s", y.Data(), retlunit.Data());
03165    zline = TString::Format("%s*%s", z.Data(), retlunit.Data());
03166    philine = TString::Format("%s*%s", phi.Data(), retaunit.Data());
03167    alphaline = TString::Format("%s*%s", alpha.Data(), retaunit.Data());
03168    thetaline = TString::Format("%s*%s", theta.Data(), retaunit.Data());
03169 
03170 
03171    TGeoPara* para = new TGeoPara(NameShort(name),
03172                   Evaluate(xline),
03173                   Evaluate(yline),
03174                   Evaluate(zline),
03175                   Evaluate(alphaline),
03176                   Evaluate(thetaline),
03177                   Evaluate(philine));
03178                    
03179    fsolmap[name.Data()] = para;
03180    
03181    return node;
03182 
03183 }
03184 
03185 //_______________________________________________________
03186 XMLNodePointer_t TGDMLParse::TwistTrap(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
03187 {   
03188    //In the solids section of the GDML file, a TwistTrap may be declared. 
03189    //when the twistedtrap keyword is found, this function is called, and the 
03190    //dimensions required are taken and stored, these are then bound and
03191    //converted to type TGeoGTra and stored in fsolmap map using the name 
03192    //as its key.
03193 
03194    TString lunit = "mm"; 
03195    TString aunit = "rad";
03196    TString x1 = "0"; 
03197    TString x2 = "0"; 
03198    TString x3 = "0"; 
03199    TString x4 = "0"; 
03200    TString y1 = "0"; 
03201    TString y2 = "0";
03202    TString z = "0";
03203    TString phi = "0";
03204    TString theta = "0";
03205    TString alpha1 = "0"; 
03206    TString alpha2 = "0"; 
03207    TString twist = "0";
03208    TString name = "";
03209    TString tempattr; 
03210    
03211    while (attr!=0) {
03212       
03213       tempattr = gdml->GetAttrName(attr);
03214       tempattr.ToLower();
03215       
03216       if(tempattr == "name") { 
03217          name = gdml->GetAttrValue(attr);
03218       }
03219       else if(tempattr == "x1") { 
03220          x1 = gdml->GetAttrValue(attr);
03221       }
03222       else if(tempattr == "x2"){
03223          x2 = gdml->GetAttrValue(attr);
03224       }
03225       else if(tempattr == "x3") { 
03226          x3 = gdml->GetAttrValue(attr);
03227       }
03228       else if(tempattr == "x4"){
03229          x4 = gdml->GetAttrValue(attr);
03230       }
03231       else if(tempattr == "y1") { 
03232          y1 = gdml->GetAttrValue(attr);
03233       }
03234       else if(tempattr == "y2"){
03235          y2 = gdml->GetAttrValue(attr);
03236       }
03237       else if (tempattr == "z"){
03238          z = gdml->GetAttrValue(attr);
03239       }
03240       else if (tempattr == "lunit"){
03241          lunit = gdml->GetAttrValue(attr);
03242       }
03243       else if (tempattr == "aunit"){
03244          aunit = gdml->GetAttrValue(attr);
03245       }
03246       else if (tempattr == "phi"){
03247          phi = gdml->GetAttrValue(attr);
03248       }
03249       else if (tempattr == "theta") {
03250          theta = gdml->GetAttrValue(attr);
03251       }
03252       else if(tempattr == "alpha1")   { 
03253          alpha1 = gdml->GetAttrValue(attr);
03254       }
03255       else if(tempattr == "alpha2"){
03256          alpha2 = gdml->GetAttrValue(attr);
03257       }
03258       else if(tempattr == "twist") {
03259          twist = gdml->GetAttrValue(attr);
03260       }
03261       
03262       attr = gdml->GetNextAttr(attr);   
03263    }
03264  
03265    if((strcmp(fCurrentFile,fStartFile)) != 0){
03266       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
03267    }
03268 
03269    TString x1line = "";
03270    TString x2line = "";
03271    TString x3line = "";
03272    TString x4line = "";
03273    TString y1line = "";
03274    TString y2line = "";
03275    TString zline = "";
03276    TString philine = "";
03277    TString thetaline = "";
03278    TString alpha1line = "";
03279    TString alpha2line = "";
03280    TString twistline = "";
03281    TString retlunit; 
03282    TString retaunit;
03283    
03284    retlunit = GetScale(lunit);
03285    retaunit = GetScale(aunit);
03286    
03287    x1line = TString::Format("%s*%s", x1.Data(), retlunit.Data());
03288    x2line = TString::Format("%s*%s", x2.Data(), retlunit.Data());
03289    x3line = TString::Format("%s*%s", x3.Data(), retlunit.Data());
03290    x4line = TString::Format("%s*%s", x4.Data(), retlunit.Data());
03291    y1line = TString::Format("%s*%s", y1.Data(), retlunit.Data());
03292    y2line = TString::Format("%s*%s", y2.Data(), retlunit.Data());
03293    zline  = TString::Format("%s*%s", z.Data(), retlunit.Data());
03294    philine = TString::Format("%s*%s", phi.Data(), retaunit.Data());
03295    thetaline = TString::Format("%s*%s", theta.Data(), retaunit.Data());
03296    alpha1line = TString::Format("%s*%s", alpha1.Data(), retaunit.Data());
03297    alpha2line = TString::Format("%s*%s", alpha2.Data(), retaunit.Data());
03298    twistline = TString::Format("%s*%s", twist.Data(), retaunit.Data());
03299 
03300       
03301    TGeoGtra* twtrap = new TGeoGtra(NameShort(name),Evaluate(zline)/2,
03302                   Evaluate(thetaline),
03303                   Evaluate(philine),
03304                   Evaluate(twistline),
03305                   Evaluate(y1line)/2,
03306                   Evaluate(x1line)/2,
03307                   Evaluate(x2line)/2,
03308                   Evaluate(alpha1line),
03309                   Evaluate(y2line)/2,
03310                   Evaluate(x3line)/2,
03311                   Evaluate(x4line)/2,
03312                   Evaluate(alpha2line));
03313                    
03314    fsolmap[name.Data()] = twtrap;
03315    
03316    return node;
03317 
03318 }
03319 
03320 
03321 //___________________________________________________________________
03322 XMLNodePointer_t TGDMLParse::ElTube(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
03323 {   
03324    //In the solids section of the GDML file, a ElTube may be declared. 
03325    //when the eltube keyword is found, this function is called, and the 
03326    //dimensions required are taken and stored, these are then bound and
03327    //converted to type TGeoEltu and stored in fsolmap map using the name 
03328    //as its key.
03329 
03330    TString lunit = "mm"; 
03331    TString xpos = "0"; 
03332    TString ypos = "0"; 
03333    TString zpos = "0"; 
03334    TString name = "";
03335    TString tempattr; 
03336    
03337    while (attr!=0) {
03338       
03339       tempattr = gdml->GetAttrName(attr);
03340       tempattr.ToLower();
03341       
03342       if(tempattr == "name") { 
03343          name = gdml->GetAttrValue(attr);
03344       }
03345       else if(tempattr == "dx") { 
03346          xpos = gdml->GetAttrValue(attr);
03347       }
03348       else if(tempattr == "dy") {
03349          ypos = gdml->GetAttrValue(attr);
03350       }
03351       else if (tempattr == "dz"){
03352          zpos = gdml->GetAttrValue(attr);
03353       }
03354       else if (tempattr == "lunit"){
03355          lunit = gdml->GetAttrValue(attr);
03356       }
03357       
03358       attr = gdml->GetNextAttr(attr);   
03359    }
03360 
03361    if((strcmp(fCurrentFile,fStartFile)) != 0){
03362       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
03363    }
03364 
03365    TString xline = "";
03366    TString yline = "";
03367    TString zline = "";
03368    TString retunit;
03369    
03370    retunit = GetScale(lunit);
03371    
03372    xline = TString::Format("%s*%s", xpos.Data(), retunit.Data());
03373    yline = TString::Format("%s*%s", ypos.Data(), retunit.Data());
03374    zline = TString::Format("%s*%s", zpos.Data(), retunit.Data());
03375 
03376    TGeoEltu* eltu = new TGeoEltu(NameShort(name),Evaluate(xline),
03377                         Evaluate(yline),
03378                         Evaluate(zline));
03379 
03380    fsolmap[name.Data()] = eltu;
03381    
03382    return node;
03383 
03384 }
03385 //___________________________________________________________________
03386 XMLNodePointer_t TGDMLParse::Orb(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
03387 {   
03388    //In the solids section of the GDML file, an Orb may be declared. 
03389    //when the orb keyword is found, this function is called, and the 
03390    //dimensions required are taken and stored, these are then bound and
03391    //converted to type TGeoSphere and stored in fsolmap map using the name 
03392    //as its key.
03393 
03394    TString lunit = "mm"; 
03395    TString r = "0"; 
03396    TString name = "";
03397    TString tempattr; 
03398    
03399    while (attr!=0) {
03400       
03401       tempattr = gdml->GetAttrName(attr);
03402       tempattr.ToLower();
03403       
03404       if(tempattr == "name") { 
03405          name = gdml->GetAttrValue(attr);
03406       }
03407       else if(tempattr == "r") { 
03408          r = gdml->GetAttrValue(attr);
03409       }
03410       else if (tempattr == "lunit"){
03411          lunit = gdml->GetAttrValue(attr);
03412       }
03413       
03414       attr = gdml->GetNextAttr(attr);   
03415    }
03416 
03417    if((strcmp(fCurrentFile,fStartFile)) != 0){
03418       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
03419    }
03420 
03421    TString rline = "";
03422    TString retunit;
03423    
03424    retunit = GetScale(lunit);
03425    
03426    rline = TString::Format("%s*%s", r.Data(), retunit.Data());
03427    
03428    TGeoSphere* orb = new TGeoSphere(NameShort(name), 0, Evaluate(rline), 0, 180, 0, 360);
03429 
03430    fsolmap[name.Data()] = orb;
03431    
03432    return node;
03433 
03434 }
03435 
03436 
03437 //_______________________________________________________
03438 XMLNodePointer_t TGDMLParse::Xtru(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
03439 {   
03440    //In the solids section of the GDML file, an Xtru may be declared. 
03441    //when the xtru keyword is found, this function is called, and the 
03442    //dimensions required are taken and stored, these are then bound and
03443    //converted to type TGeoXtru and stored in fsolmap map using the name 
03444    //as its key. The xtru has child nodes of either 'twoDimVertex'or 
03445    //'section'.   These two nodes define the real structure of the shape.
03446    //The twoDimVertex's define the x,y sizes of a vertice. The section links
03447    //the vertice to a position within the xtru. 
03448 
03449    TString lunit = "mm"; 
03450 //   TString aunit = "rad";
03451    TString x = "0"; 
03452    TString y = "0"; 
03453    TString zorder = "0";
03454    TString zpos = "0";
03455    TString xoff = "0";
03456    TString yoff = "0";
03457    TString scale = "0";
03458    TString name = "";
03459    TString tempattr; 
03460 
03461    while (attr!=0) {
03462       
03463       tempattr = gdml->GetAttrName(attr);
03464       tempattr.ToLower();
03465       
03466       if(tempattr == "name") { 
03467          name = gdml->GetAttrValue(attr);
03468       }
03469       else if (tempattr == "lunit"){
03470          lunit = gdml->GetAttrValue(attr);
03471       }
03472       
03473       attr = gdml->GetNextAttr(attr);   
03474    } 
03475 
03476    if((strcmp(fCurrentFile,fStartFile)) != 0){
03477       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
03478    }
03479 
03480    TString retlunit; 
03481    
03482    retlunit = GetScale(lunit);
03483    
03484    //START TO LOOK THRU CHILD NODES... 
03485 
03486    XMLNodePointer_t child = gdml->GetChild(node);
03487    int nosects = 0;
03488    int noverts = 0;
03489 
03490    while (child!=0){
03491       tempattr = gdml->GetNodeName(child);
03492       
03493       if(tempattr == "twoDimVertex"){
03494          noverts = noverts + 1;
03495       }
03496       else if(tempattr == "section"){ 
03497          nosects = nosects + 1;
03498       }
03499       
03500       child = gdml->GetNext(child);
03501    }
03502    
03503    //Build the dynamic arrays..
03504    int cols;
03505    int i;
03506    double *vertx = new double[noverts];
03507    double *verty = new double[noverts];
03508    cols = 5;
03509    double ** section = new double*[nosects];
03510    for(i = 0; i < nosects; i++){
03511       section[i] = new double[cols];
03512    }
03513    
03514    child = gdml->GetChild(node);
03515    int sect = 0;
03516    int vert = 0;
03517 
03518    while (child!=0) {
03519       if(strcmp(gdml->GetNodeName(child), "twoDimVertex")==0){
03520          TString xline = ""; 
03521          TString yline = "";
03522          
03523          attr = gdml->GetFirstAttr(child);
03524          
03525          while (attr!=0){
03526             tempattr = gdml->GetAttrName(attr);
03527     
03528             if(tempattr == "x") { 
03529                x = gdml->GetAttrValue(attr);
03530                xline = TString::Format("%s*%s", x.Data(), retlunit.Data());
03531                vertx[vert] = Evaluate(xline);
03532             }
03533             else if(tempattr == "y"){
03534                y = gdml->GetAttrValue(attr);
03535                yline = TString::Format("%s*%s", y.Data(), retlunit.Data());
03536                verty[vert] = Evaluate(yline);
03537             }
03538        
03539             attr = gdml->GetNextAttr(attr);
03540          }
03541 
03542          vert = vert + 1;
03543       }
03544       
03545       else if(strcmp(gdml->GetNodeName(child), "section") == 0){
03546 
03547          TString zposline = "";
03548          TString xoffline = "";
03549          TString yoffline = "";
03550          
03551          attr = gdml->GetFirstAttr(child);
03552          
03553          while (attr!=0){
03554             tempattr = gdml->GetAttrName(attr);
03555     
03556             if(tempattr == "zOrder") { 
03557                zorder = gdml->GetAttrValue(attr);
03558                section[sect][0] = Evaluate(zorder);
03559             }
03560             else if(tempattr == "zPosition"){
03561                zpos = gdml->GetAttrValue(attr);
03562                zposline = TString::Format("%s*%s", zpos.Data(), retlunit.Data());
03563                section[sect][1] = Evaluate(zposline);
03564             }
03565             else if (tempattr == "xOffset"){
03566                xoff = gdml->GetAttrValue(attr);
03567                xoffline = TString::Format("%s*%s", xoff.Data(), retlunit.Data());
03568                section[sect][2] = Evaluate(xoffline);
03569             }
03570             else if (tempattr == "yOffset"){
03571                yoff = gdml->GetAttrValue(attr);
03572                yoffline = TString::Format("%s*%s", yoff.Data(), retlunit.Data());
03573                section[sect][3] = Evaluate(yoffline);
03574             }
03575             else if (tempattr == "scalingFactor"){
03576                scale = gdml->GetAttrValue(attr);
03577                section[sect][4] = Evaluate(scale);
03578             }
03579        
03580             attr = gdml->GetNextAttr(attr);
03581          }
03582                 
03583          sect = sect + 1; 
03584       }      
03585       child = gdml->GetNext(child);
03586    }
03587    
03588    TGeoXtru* xtru = new TGeoXtru(nosects);
03589    xtru->SetName(NameShort(name));
03590    xtru->DefinePolygon(vert, vertx, verty);
03591    
03592    for (int j = 0; j < sect; j++){
03593       xtru->DefineSection((int)section[j][0], section[j][1], section[j][2], section[j][3], section[j][4]);
03594    }
03595   
03596    fsolmap[name.Data()] = xtru;
03597    delete [] vertx;
03598    delete [] verty;
03599    for(i = 0; i < nosects; i++){
03600       delete [] section[i];
03601    }
03602    delete [] section;
03603    return node;
03604 }
03605 
03606 //____________________________________________________________
03607 XMLNodePointer_t TGDMLParse::Reflection(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
03608 {
03609    //In the solids section of the GDML file, a Reflected Solid may be 
03610    //declared when the ReflectedSolid keyword is found, this function 
03611    //is called. The rotation, position and scale for the reflection are 
03612    //applied to a matrix that is then stored in the class object 
03613    //TGDMLRefl.   This is then stored in the map freflsolidmap, with 
03614    //the reflection name as a reference. also the name of the solid to 
03615    //be reflected is stored in a map called freflectmap with the reflection 
03616    //name as a reference.
03617 
03618    std::cout << "WARNING! The reflectedSolid is obsolete! Use scale transformation instead!" << std::endl;
03619 
03620    TString sx = "0"; 
03621    TString sy = "0"; 
03622    TString sz = "0"; 
03623    TString rx = "0"; 
03624    TString ry = "0"; 
03625    TString rz = "0"; 
03626    TString dx = "0"; 
03627    TString dy = "0"; 
03628    TString dz = "0"; 
03629    TString name = "0";
03630    TString solid = "0";
03631    TString tempattr; 
03632    
03633    while (attr!=0) {
03634       
03635       tempattr = gdml->GetAttrName(attr);
03636       tempattr.ToLower();
03637       
03638       if(tempattr == "name") { 
03639          name = gdml->GetAttrValue(attr);
03640       }
03641       else if(tempattr == "sx") { 
03642          sx = gdml->GetAttrValue(attr);
03643       }
03644       else if(tempattr == "sy"){
03645          sy = gdml->GetAttrValue(attr);
03646       }
03647       else if (tempattr == "sz"){
03648          sz = gdml->GetAttrValue(attr);
03649       }
03650       else if(tempattr == "rx") { 
03651          rx = gdml->GetAttrValue(attr);
03652       }
03653       else if(tempattr == "ry"){
03654          ry = gdml->GetAttrValue(attr);
03655       }
03656       else if (tempattr == "rz"){
03657          rz = gdml->GetAttrValue(attr);
03658       }
03659       else if(tempattr == "dx") { 
03660          dx = gdml->GetAttrValue(attr);
03661       }
03662       else if(tempattr == "dy"){
03663          dy = gdml->GetAttrValue(attr);
03664       }
03665       else if (tempattr == "dz"){
03666          dz = gdml->GetAttrValue(attr);
03667       }
03668       else if (tempattr == "solid"){
03669          solid = gdml->GetAttrValue(attr);
03670       }
03671       attr = gdml->GetNextAttr(attr);   
03672    }
03673    
03674    if((strcmp(fCurrentFile,fStartFile)) != 0){
03675       name = TString::Format("%s_%s", name.Data(), fCurrentFile);
03676    }
03677    if((strcmp(fCurrentFile,fStartFile)) != 0){
03678       solid = TString::Format("%s_%s", solid.Data(), fCurrentFile);
03679    }
03680 
03681    TGeoRotation* rot = new TGeoRotation();
03682    rot->RotateZ(-(Evaluate(rz)));
03683    rot->RotateY(-(Evaluate(ry)));
03684    rot->RotateX(-(Evaluate(rx)));
03685 
03686    if(atoi(sx) == -1) {
03687       rot->ReflectX(kTRUE);
03688    }
03689    if(atoi(sy) == -1) {
03690       rot->ReflectY(kTRUE);
03691    }
03692    if(atoi(sz) == -1) {
03693       rot->ReflectZ(kTRUE);
03694    }
03695 
03696    TGeoCombiTrans* relf_matx = new TGeoCombiTrans(Evaluate(dx), Evaluate(dy), Evaluate(dz), rot);
03697 
03698    TGDMLRefl* reflsol = new TGDMLRefl(NameShort(name), solid, relf_matx);
03699    freflsolidmap[name.Data()] = reflsol;
03700    freflectmap[name.Data()] = solid;
03701 
03702    return node;
03703 }
03704 
03705 
03706 
03707 //===================================================================
03708 
03709 ClassImp(TGDMLRefl)
03710 
03711 /******************************************************************
03712 ____________________________________________________________
03713 
03714 TGDMLRefl Class
03715 
03716 ------------------------------------------------------------
03717 
03718 This class is a helper class for TGDMLParse.   It assists in the 
03719 reflection process.   This process takes a previously defined solid 
03720 and can reflect the matrix of it. This class stores the name of the 
03721 reflected solid, along with the name of the solid that is being 
03722 reflected, and finally the reflected solid's matrix.   This is then 
03723 recalled when the volume is used in the structure part of the gdml 
03724 file.
03725 
03726 ******************************************************************/
03727 
03728 //___________________________________________________________________
03729 TGDMLRefl::TGDMLRefl(const char* name, const char* solid, TGeoMatrix* matrix)
03730 {   
03731    //this constructor method stores the values brought in as params.
03732 
03733    fNameS = name;
03734    fSolid = solid;
03735    fMatrix = matrix; 
03736 }
03737 
03738 //_________________________________________________________________
03739 TGeoMatrix* TGDMLRefl::GetMatrix()
03740 {
03741    //this accessor method returns the matrix.
03742 
03743    return fMatrix;
03744 }

Generated on Tue Jul 5 14:12:09 2011 for ROOT_528-00b_version by  doxygen 1.5.1