#include "TGeoManager.h"
#include "TGeoMatrix.h"
#include "TXMLEngine.h"
#include "TGeoVolume.h"
#include "TGeoBBox.h"
#include "TGeoParaboloid.h"
#include "TGeoArb8.h"
#include "TGeoTube.h"
#include "TGeoCone.h"
#include "TGeoTrd2.h"
#include "TGeoPcon.h"
#include "TGeoPgon.h"
#include "TGeoSphere.h"
#include "TGeoTorus.h"
#include "TGeoPara.h"
#include "TGeoHype.h"
#include "TGeoEltu.h"
#include "TGeoXtru.h"
#include "TGeoScaledShape.h"
#include "TGeoVolume.h"
#include "TROOT.h"
#include "TMath.h"
#include "TMap.h"
#include "TObjString.h"
#include "TGeoExtension.h"
#include "TGeoMaterial.h"
#include "TGeoBoolNode.h"
#include "TGeoMedium.h"
#include "TGeoElement.h"
#include "TGeoShape.h"
#include "TGeoCompositeShape.h"
#include "TGDMLParse.h"
#include <stdlib.h>
#include <string>
ClassImp(TGDMLParse)
TGeoVolume* TGDMLParse::GDMLReadFile(const char* filename)
{
TXMLEngine* gdml = new TXMLEngine;
gdml->SetSkipComments(kTRUE);
XMLDocPointer_t gdmldoc = gdml->ParseFile(filename);
if (gdmldoc == 0) {
delete gdml;
return 0;
} else {
XMLNodePointer_t mainnode = gdml->DocGetRootElement(gdmldoc);
fFileEngine[fFILENO] = gdml;
fStartFile = filename;
fCurrentFile = filename;
ParseGDML(gdml, mainnode);
gdml->FreeDoc(gdmldoc);
delete gdml;
}
return fWorld;
}
const char* TGDMLParse::ParseGDML(TXMLEngine* gdml, XMLNodePointer_t node)
{
XMLAttrPointer_t attr = gdml->GetFirstAttr(node);
const char* name = gdml->GetNodeName(node);
XMLNodePointer_t parentn = gdml->GetParent(node);
const char* parent = gdml->GetNodeName(parentn);
XMLNodePointer_t childtmp = 0;
const char* posistr = "position";
const char* setustr = "setup";
const char* consstr = "constant";
const char* varistr = "variable";
const char* rotastr = "rotation";
const char* scalstr = "scale";
const char* elemstr = "element";
const char* istpstr = "isotope";
const char* matestr = "material";
const char* volustr = "volume";
const char* assestr = "assembly";
const char* twtrstr = "twistedtrap";
const char* cutTstr = "cutTube";
const char* bboxstr = "box";
const char* xtrustr = "xtru";
const char* arb8str = "arb8";
const char* tubestr = "tube";
const char* conestr = "cone";
const char* polystr = "polycone";
const char* hypestr = "hype";
const char* trapstr = "trap";
const char* trdstr = "trd";
const char* sphestr = "sphere";
const char* orbstr = "orb";
const char* parastr = "para";
const char* torustr = "torus";
const char* hedrstr = "polyhedra";
const char* eltustr = "eltube";
const char* subtstr = "subtraction";
const char* uniostr = "union";
const char* parbstr = "paraboloid";
const char* intestr = "intersection";
const char* reflstr = "reflectedSolid";
const char* ellistr = "ellipsoid";
const char* elcnstr = "elcone";
Bool_t hasIsotopes;
Bool_t hasIsotopesExtended;
if ((strcmp(name, posistr)) == 0) {
node = PosProcess(gdml, node, attr);
} else if ((strcmp(name, rotastr)) == 0) {
node = RotProcess(gdml, node, attr);
} else if ((strcmp(name, scalstr)) == 0) {
node = SclProcess(gdml, node, attr);
} else if ((strcmp(name, setustr)) == 0) {
node = TopProcess(gdml, node);
} else if ((strcmp(name, consstr)) == 0) {
node = ConProcess(gdml, node, attr);
} else if ((strcmp(name, varistr)) == 0) {
node = ConProcess(gdml, node, attr);
}
else if (((strcmp(name, "atom")) == 0) && ((strcmp(parent, elemstr)) == 0)) {
hasIsotopes = kFALSE;
hasIsotopesExtended = kFALSE;
node = EleProcess(gdml, node, parentn, hasIsotopes, hasIsotopesExtended);
}
else if ((strcmp(name, elemstr) == 0) && !gdml->HasAttr(node, "Z")) {
hasIsotopes = kTRUE;
hasIsotopesExtended = kFALSE;
node = EleProcess(gdml, node, parentn, hasIsotopes, hasIsotopesExtended);
}
else if ((strcmp(name, elemstr) == 0) && gdml->HasAttr(node, "Z")) {
childtmp = gdml->GetChild(node);
if ((strcmp(gdml->GetNodeName(childtmp), "fraction") == 0) ){
hasIsotopes = kFALSE;
hasIsotopesExtended = kTRUE;
node = EleProcess(gdml, node, parentn, hasIsotopes, hasIsotopesExtended);}
}
else if (((strcmp(name, "atom")) == 0) && ((strcmp(parent, istpstr)) == 0)) {
node = IsoProcess(gdml, node, parentn);
}
else if ((strcmp(name, matestr)) == 0 && gdml->HasAttr(node, "Z")) {
childtmp = gdml->GetChild(node);
Bool_t atom = kFALSE;
while(childtmp) {
atom = strcmp(gdml->GetNodeName(childtmp),"atom")==0;
gdml->ShiftToNext(childtmp);
}
int z = (atom) ? 1 : 0;
node = MatProcess(gdml, node, attr, z);
}
else if ((strcmp(name, matestr)) == 0 && !gdml->HasAttr(node, "Z")) {
int z = 0;
node = MatProcess(gdml, node, attr, z);
}
else if ((strcmp(name, volustr)) == 0) {
node = VolProcess(gdml, node);
} else if ((strcmp(name, bboxstr)) == 0) {
node = Box(gdml, node, attr);
} else if ((strcmp(name, ellistr)) == 0) {
node = Ellipsoid(gdml, node, attr);
} else if ((strcmp(name, elcnstr)) == 0) {
node = ElCone(gdml, node, attr);
} else if ((strcmp(name, cutTstr)) == 0) {
node = CutTube(gdml, node, attr);
} else if ((strcmp(name, arb8str)) == 0) {
node = Arb8(gdml, node, attr);
} else if ((strcmp(name, tubestr)) == 0) {
node = Tube(gdml, node, attr);
} else if ((strcmp(name, conestr)) == 0) {
node = Cone(gdml, node, attr);
} else if ((strcmp(name, polystr)) == 0) {
node = Polycone(gdml, node, attr);
} else if ((strcmp(name, trapstr)) == 0) {
node = Trap(gdml, node, attr);
} else if ((strcmp(name, trdstr)) == 0) {
node = Trd(gdml, node, attr);
} else if ((strcmp(name, sphestr)) == 0) {
node = Sphere(gdml, node, attr);
} else if ((strcmp(name, xtrustr)) == 0) {
node = Xtru(gdml, node, attr);
} else if ((strcmp(name, twtrstr)) == 0) {
node = TwistTrap(gdml, node, attr);
} else if ((strcmp(name, hypestr)) == 0) {
node = Hype(gdml, node, attr);
} else if ((strcmp(name, orbstr)) == 0) {
node = Orb(gdml, node, attr);
} else if ((strcmp(name, parastr)) == 0) {
node = Para(gdml, node, attr);
} else if ((strcmp(name, torustr)) == 0) {
node = Torus(gdml, node, attr);
} else if ((strcmp(name, eltustr)) == 0) {
node = ElTube(gdml, node, attr);
} else if ((strcmp(name, hedrstr)) == 0) {
node = Polyhedra(gdml, node, attr);
} else if ((strcmp(name, parbstr)) == 0) {
node = Paraboloid(gdml, node, attr);
} else if ((strcmp(name, subtstr)) == 0) {
node = BooSolid(gdml, node, attr, 1);
} else if ((strcmp(name, intestr)) == 0) {
node = BooSolid(gdml, node, attr, 2);
} else if ((strcmp(name, uniostr)) == 0) {
node = BooSolid(gdml, node, attr, 3);
} else if ((strcmp(name, reflstr)) == 0) {
node = Reflection(gdml, node, attr);
} else if ((strcmp(name, assestr)) == 0) {
node = AssProcess(gdml, node);
} else if (((strcmp(name, "gdml")) != 0) && ((strcmp(name, "define")) != 0) &&
((strcmp(name, "element")) != 0) && ((strcmp(name, "materials")) != 0) &&
((strcmp(name, "solids")) != 0) && ((strcmp(name, "structure")) != 0) &&
((strcmp(name, "zplane")) != 0) && ((strcmp(name, "first")) != 0) &&
((strcmp(name, "second")) != 0) && ((strcmp(name, "twoDimVertex")) != 0) &&
((strcmp(name, "firstposition")) != 0) && ((strcmp(name, "firstpositionref")) != 0) &&
((strcmp(name, "firstrotation")) != 0) && ((strcmp(name, "firstrotationref")) != 0) &&
((strcmp(name, "section")) != 0) && ((strcmp(name, "world")) != 0) &&
((strcmp(name, "isotope")) != 0)) {
std::cout << "Error: Unsupported GDML Tag Used :" << name << ". Please Check Geometry/Schema." << std::endl;
}
XMLNodePointer_t child = gdml->GetChild(node);
while (child != 0) {
ParseGDML(gdml, child);
child = gdml->GetNext(child);
}
return fWorldName;
}
double TGDMLParse::Evaluate(const char* evalline)
{
return TFormula("TFormula", evalline).Eval(0);
}
Int_t TGDMLParse::SetAxis(const char* axisString)
{
Int_t axis = 0;
if ((strcmp(axisString, "kXAxis")) == 0) {
axis = 1;
} else if ((strcmp(axisString, "kYAxis")) == 0) {
axis = 2;
} else if ((strcmp(axisString, "kZAxis")) == 0) {
axis = 3;
} else if ((strcmp(axisString, "kRho")) == 0) {
axis = 1;
} else if ((strcmp(axisString, "kPhi")) == 0) {
axis = 2;
}
return axis;
}
const char* TGDMLParse::NameShort(const char* name)
{
static TString stripped;
stripped = name;
Int_t index = stripped.Index("0x");
if (index >= 0) stripped = stripped(0, index);
return stripped.Data();
}
XMLNodePointer_t TGDMLParse::ConProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString name = "";
TString value = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
}
if (tempattr == "value") {
value = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
fformvec.push_back(new TFormula(name, value));
return node;
}
TString TGDMLParse::GetScale(const char* unit)
{
TString retunit = "";
if (strcmp(unit, "mm") == 0) {
retunit = "0.1";
} else if (strcmp(unit, "milimeter") == 0) {
retunit = "0.1";
} else if (strcmp(unit, "cm") == 0) {
retunit = "1.0";
} else if (strcmp(unit, "centimeter") == 0) {
retunit = "1.0";
} else if (strcmp(unit, "m") == 0) {
retunit = "100.0";
} else if (strcmp(unit, "meter") == 0) {
retunit = "100.0";
} else if (strcmp(unit, "km") == 0) {
retunit = "100000.0";
} else if (strcmp(unit, "kilometer") == 0) {
retunit = "100000.0";
} else if (strcmp(unit, "rad") == 0) {
retunit = TString::Format("%.12f", TMath::RadToDeg());
} else if (strcmp(unit, "radian") == 0) {
retunit = TString::Format("%.12f", TMath::RadToDeg());
} else if (strcmp(unit, "deg") == 0) {
retunit = "1.0";
} else if (strcmp(unit, "degree") == 0) {
retunit = "1.0";
} else if (strcmp(unit, "pi") == 0) {
retunit = "pi";
} else if (strcmp(unit, "avogadro") == 0) {
retunit = TString::Format("%.12g", TMath::Na());
} else {
Fatal("GetScale", "Unit <%s> not known", unit);
retunit = "0";
}
return retunit;
}
Double_t TGDMLParse::GetScaleVal(const char* unit)
{
Double_t retunit = 0.;
if (strcmp(unit, "mm") == 0) {
retunit = 0.1;
} else if (strcmp(unit, "milimeter") == 0) {
retunit = 0.1;
} else if (strcmp(unit, "cm") == 0) {
retunit = 1.0;
} else if (strcmp(unit, "centimeter") == 0) {
retunit = 1.0;
} else if (strcmp(unit, "m") == 0) {
retunit = 100.0;
} else if (strcmp(unit, "meter") == 0) {
retunit = 100.0;
} else if (strcmp(unit, "km") == 0) {
retunit = 100000.0;
} else if (strcmp(unit, "kilometer") == 0) {
retunit = 100000.0;
} else if (strcmp(unit, "rad") == 0) {
retunit = TMath::RadToDeg();
} else if (strcmp(unit, "radian") == 0) {
retunit = TMath::RadToDeg();
} else if (strcmp(unit, "deg") == 0) {
retunit = 1.0;
} else if (strcmp(unit, "degree") == 0) {
retunit = 1.0;
} else if (strcmp(unit, "pi") == 0) {
retunit = TMath::Pi();
} else if (strcmp(unit, "avogadro") == 0) {
retunit = TMath::Na();
} else {
Fatal("GetScaleVal", "Unit <%s> not known", unit);
retunit = 0;
}
return retunit;
}
Double_t TGDMLParse::Value(const char* svalue) const
{
static TString s;
s = svalue;
return s.Atof();
}
XMLNodePointer_t TGDMLParse::PosProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString xpos = "0";
TString ypos = "0";
TString zpos = "0";
TString name = "0";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "x") {
xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "y") {
ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
zpos = gdml->GetAttrValue(attr);
} else if (tempattr == "unit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retunit = GetScaleVal(lunit);
Double_t xline = Value(xpos)*retunit;
Double_t yline = Value(ypos)*retunit;
Double_t zline = Value(zpos)*retunit;
TGeoTranslation* pos = new TGeoTranslation(xline, yline, zline);
fposmap[name.Data()] = pos;
return node;
}
XMLNodePointer_t TGDMLParse::RotProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString aunit = "rad";
TString xpos = "0";
TString ypos = "0";
TString zpos = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "x") {
xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "y") {
ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
zpos = gdml->GetAttrValue(attr);
} else if (tempattr == "unit") {
aunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retunit = GetScaleVal(aunit);
Double_t xline = Value(xpos)*retunit;
Double_t yline = Value(ypos)*retunit;
Double_t zline = Value(zpos)*retunit;
TGeoRotation* rot = new TGeoRotation();
rot->RotateZ(-zline);
rot->RotateY(-yline);
rot->RotateX(-xline);
frotmap[name.Data()] = rot;
return node;
}
XMLNodePointer_t TGDMLParse::SclProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString xpos = "0";
TString ypos = "0";
TString zpos = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "x") {
xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "y") {
ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
zpos = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
TGeoScale* scl = new TGeoScale(Value(xpos), Value(ypos), Value(zpos));
fsclmap[name.Data()] = scl;
return node;
}
XMLNodePointer_t TGDMLParse::IsoProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t parentn)
{
TString z = "0";
TString name = "";
TString n = "0";
TString atom = "0";
TString tempattr;
XMLAttrPointer_t attr = gdml->GetFirstAttr(parentn);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "n") {
n = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
attr = gdml->GetFirstAttr(node);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
if (tempattr == "value") {
atom = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Int_t z2 = (Int_t)Value(z);
Int_t n2 = (Int_t)Value(n);
Double_t atom2 = Value(atom);
TGeoIsotope* iso = new TGeoIsotope(NameShort(name), z2 , n2, atom2);
fisomap[name.Data()] = iso;
return node;
}
XMLNodePointer_t TGDMLParse::EleProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLNodePointer_t parentn, Bool_t hasIsotopes, Bool_t hasIsotopesExtended)
{
TString z = "0";
TString name = "";
TString formula = "";
TString atom = "0";
TString tempattr;
Int_t ncompo = 0;
typedef FracMap::iterator fractions;
FracMap fracmap;
XMLNodePointer_t child = 0;
XMLAttrPointer_t attr = gdml->GetFirstAttr(node);
if (hasIsotopes) {
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
break;
}
attr = gdml->GetNextAttr(attr);
}
child = gdml->GetChild(node);
while (child != 0) {
if ((strcmp(gdml->GetNodeName(child), "fraction")) == 0) {
Double_t n = 0;
TString ref = "";
ncompo = ncompo + 1;
attr = gdml->GetFirstAttr(child);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "n") {
n = Value(gdml->GetAttrValue(attr));
} else if (tempattr == "ref") {
ref = gdml->GetAttrValue(attr);
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
}
}
attr = gdml->GetNextAttr(attr);
}
fracmap[ref.Data()] = n;
}
child = gdml->GetNext(child);
}
TGeoElement *ele = new TGeoElement(NameShort(name), NameShort(name), ncompo);
for (fractions f = fracmap.begin(); f != fracmap.end(); f++) {
if (fisomap.find(f->first) != fisomap.end()) {
ele->AddIsotope((TGeoIsotope*)fisomap[f->first], f->second);
}
}
felemap[name.Data()] = ele;
return child;
}
if (hasIsotopesExtended) {
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
break;
}
attr = gdml->GetNextAttr(attr);
}
child = gdml->GetChild(node);
while (child != 0) {
if ((strcmp(gdml->GetNodeName(child), "fraction")) == 0) {
Double_t n = 0;
TString ref = "";
ncompo = ncompo + 1;
attr = gdml->GetFirstAttr(child);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "n") {
n = Value(gdml->GetAttrValue(attr));
} else if (tempattr == "ref") {
ref = gdml->GetAttrValue(attr);
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
}
}
attr = gdml->GetNextAttr(attr);
}
fracmap[ref.Data()] = n;
}
child = gdml->GetNext(child);
}
TGeoElement *ele = new TGeoElement(NameShort(name), NameShort(name), ncompo);
for (fractions f = fracmap.begin(); f != fracmap.end(); f++) {
if (fisomap.find(f->first) != fisomap.end()) {
ele->AddIsotope((TGeoIsotope*)fisomap[f->first], f->second);
}
}
felemap[name.Data()] = ele;
return child;
}
attr = gdml->GetFirstAttr(parentn);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "formula") {
formula = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
attr = gdml->GetFirstAttr(node);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "value") {
atom = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Int_t z2 = (Int_t)Value(z);
Double_t atom2 = Value(atom);
TGeoElement* ele = new TGeoElement(formula, NameShort(name), z2 , atom2);
felemap[name.Data()] = ele;
return node;
}
XMLNodePointer_t TGDMLParse::MatProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr, int z)
{
typedef FracMap::iterator fractions;
FracMap fracmap;
static int medid = 0;
XMLNodePointer_t child = gdml->GetChild(node);
TString tempattr = "";
Int_t ncompo = 0, mixflag = 2;
Double_t density = 0;
TString name = "";
TGeoMixture* mix = 0;
TGeoMaterial* mat = 0;
TString tempconst = "";
TString matname;
Bool_t composite = kFALSE;
if (z == 1) {
Double_t a = 0;
Double_t d = 0;
while (child != 0) {
attr = gdml->GetFirstAttr(child);
if ((strcmp(gdml->GetNodeName(child), "atom")) == 0) {
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "value") {
a = Value(gdml->GetAttrValue(attr));
}
attr = gdml->GetNextAttr(attr);
}
}
if ((strcmp(gdml->GetNodeName(child), "D")) == 0) {
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "value") {
d = Value(gdml->GetAttrValue(attr));
}
attr = gdml->GetNextAttr(attr);
}
}
child = gdml->GetNext(child);
}
name = gdml->GetAttr(node, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
tempconst = gdml->GetAttr(node, "Z");
Double_t valZ = Value(tempconst);
TString tmpname = name;
tmpname.ToLower();
if (tmpname == "vacuum") {
valZ = 0;
}
mat = new TGeoMaterial(NameShort(name), a, valZ, d);
mixflag = 0;
TGeoElement* mat_ele = new TGeoElement(NameShort(name), NameShort(name), atoi(tempconst), a);
felemap[name.Data()] = mat_ele;
}
else if (z == 0) {
while (child != 0) {
attr = gdml->GetFirstAttr(child);
if ((strcmp(gdml->GetNodeName(child), "fraction")) == 0) {
Double_t n = 0;
TString ref = "";
ncompo = ncompo + 1;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "n") {
n = Value(gdml->GetAttrValue(attr));
} else if (tempattr == "ref") {
ref = gdml->GetAttrValue(attr);
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
}
}
attr = gdml->GetNextAttr(attr);
}
fracmap[ref.Data()] = n;
}
else if ((strcmp(gdml->GetNodeName(child), "composite")) == 0) {
composite = kTRUE;
Double_t n = 0;
TString ref = "";
ncompo = ncompo + 1;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "n") {
n = Value(gdml->GetAttrValue(attr));
} else if (tempattr == "ref") {
ref = gdml->GetAttrValue(attr);
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
}
}
attr = gdml->GetNextAttr(attr);
}
fracmap[ref.Data()] = n;
}
else if ((strcmp(gdml->GetNodeName(child), "D")) == 0) {
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "value") {
density = Value(gdml->GetAttrValue(attr));
}
attr = gdml->GetNextAttr(attr);
}
}
child = gdml->GetNext(child);
}
name = gdml->GetAttr(node, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
mix = new TGeoMixture(NameShort(name), ncompo, density);
mixflag = 1;
Int_t natoms;
Double_t weight;
for (fractions f = fracmap.begin(); f != fracmap.end(); f++) {
matname = f->first;
matname = NameShort(matname);
TGeoMaterial *mattmp = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->FindObject(matname);
if (mattmp || (felemap.find(f->first) != felemap.end())) {
if (composite) {
natoms = (Int_t)f->second;
mix->AddElement(felemap[f->first], natoms);
}
else {
weight = f->second;
if (mattmp){
mix->AddElement(mattmp, weight);
}
else{
mix->AddElement(felemap[f->first], weight);
}
}
}
}
}
medid = medid + 1;
TGeoMedium* med = 0;
if (mixflag == 1) {
fmixmap[name.Data()] = mix;
med = new TGeoMedium(NameShort(name), medid, mix);
} else if (mixflag == 0) {
fmatmap[name.Data()] = mat;
med = new TGeoMedium(NameShort(name), medid, mat);
}
fmedmap[name.Data()] = med;
return child;
}
XMLNodePointer_t TGDMLParse::VolProcess(TXMLEngine* gdml, XMLNodePointer_t node)
{
XMLAttrPointer_t attr;
XMLNodePointer_t subchild;
XMLNodePointer_t subsubchild;
XMLNodePointer_t child = gdml->GetChild(node);
TString name;
TString solidname = "";
TString tempattr = "";
TGeoShape* solid = 0;
TGeoMedium* medium = 0;
TGeoVolume* vol = 0;
TGeoVolume* lv = 0;
TGeoShape* reflex = 0;
const Double_t* parentrot = 0;
int yesrefl = 0;
TString reftemp = "";
TMap *auxmap = 0;
while (child != 0) {
if ((strcmp(gdml->GetNodeName(child), "solidref")) == 0) {
reftemp = gdml->GetAttr(child, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (fsolmap.find(reftemp.Data()) != fsolmap.end()) {
solid = fsolmap[reftemp.Data()];
} else if (freflectmap.find(reftemp.Data()) != freflectmap.end()) {
solidname = reftemp;
reflex = fsolmap[freflectmap[reftemp.Data()]];
} else {
printf("Solid: %s, Not Yet Defined!\n", reftemp.Data());
}
}
if ((strcmp(gdml->GetNodeName(child), "materialref")) == 0) {
reftemp = gdml->GetAttr(child, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (fmedmap.find(reftemp.Data()) != fmedmap.end()) {
medium = fmedmap[reftemp.Data()];
} else {
printf("Medium: %s, Not Yet Defined!\n", gdml->GetAttr(child, "ref"));
}
}
child = gdml->GetNext(child);
}
name = gdml->GetAttr(node, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
if (reflex == 0) {
vol = new TGeoVolume(NameShort(name), solid, medium);
} else {
vol = new TGeoVolume(NameShort(name), reflex, medium);
freflvolmap[name.Data()] = solidname;
TGDMLRefl* parentrefl = freflsolidmap[solidname.Data()];
parentrot = parentrefl->GetMatrix()->GetRotationMatrix();
yesrefl = 1;
}
fvolmap[name.Data()] = vol;
child = gdml->GetChild(node);
while (child != 0) {
if ((strcmp(gdml->GetNodeName(child), "physvol")) == 0) {
TString volref = "";
TGeoTranslation* pos = 0;
TGeoRotation* rot = 0;
TGeoScale* scl = 0;
subchild = gdml->GetChild(child);
while (subchild != 0) {
tempattr = gdml->GetNodeName(subchild);
tempattr.ToLower();
if (tempattr == "volumeref") {
reftemp = gdml->GetAttr(subchild, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
lv = fvolmap[reftemp.Data()];
volref = reftemp;
}
else if (tempattr == "file") {
const char* filevol;
const char* prevfile = fCurrentFile;
fCurrentFile = gdml->GetAttr(subchild, "name");
filevol = gdml->GetAttr(subchild, "volname");
TXMLEngine* gdml2 = new TXMLEngine;
gdml2->SetSkipComments(kTRUE);
XMLDocPointer_t filedoc1 = gdml2->ParseFile(fCurrentFile);
if (filedoc1 == 0) {
Fatal("VolProcess", "Bad filename given %s", fCurrentFile);
}
XMLNodePointer_t mainnode2 = gdml2->DocGetRootElement(filedoc1);
fFILENO = fFILENO + 1;
fFileEngine[fFILENO] = gdml2;
if (ffilemap.find(fCurrentFile) != ffilemap.end()) {
volref = ffilemap[fCurrentFile];
} else {
volref = ParseGDML(gdml2, mainnode2);
ffilemap[fCurrentFile] = volref;
}
if (filevol) {
volref = filevol;
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
volref = TString::Format("%s_%s", volref.Data(), fCurrentFile);
}
}
fFILENO = fFILENO - 1;
gdml = fFileEngine[fFILENO];
fCurrentFile = prevfile;
lv = fvolmap[volref.Data()];
gdml->FreeDoc(filedoc1);
delete gdml2;
}
else if (tempattr == "position") {
attr = gdml->GetFirstAttr(subchild);
PosProcess(gdml, subchild, attr);
reftemp = gdml->GetAttr(subchild, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
pos = fposmap[reftemp.Data()];
} else if (tempattr == "positionref") {
reftemp = gdml->GetAttr(subchild, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (fposmap.find(reftemp.Data()) != fposmap.end()) pos = fposmap[reftemp.Data()];
else std::cout << "ERROR! Physvol's position " << reftemp << " not found!" << std::endl;
} else if (tempattr == "rotation") {
attr = gdml->GetFirstAttr(subchild);
RotProcess(gdml, subchild, attr);
reftemp = gdml->GetAttr(subchild, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
rot = frotmap[reftemp.Data()];
} else if (tempattr == "rotationref") {
reftemp = gdml->GetAttr(subchild, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (frotmap.find(reftemp.Data()) != frotmap.end()) rot = frotmap[reftemp.Data()];
else std::cout << "ERROR! Physvol's rotation " << reftemp << " not found!" << std::endl;
} else if (tempattr == "scale") {
attr = gdml->GetFirstAttr(subchild);
SclProcess(gdml, subchild, attr);
reftemp = gdml->GetAttr(subchild, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
scl = fsclmap[reftemp.Data()];
} else if (tempattr == "scaleref") {
reftemp = gdml->GetAttr(subchild, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (fsclmap.find(reftemp.Data()) != fsclmap.end()) scl = fsclmap[reftemp.Data()];
else std::cout << "ERROR! Physvol's scale " << reftemp << " not found!" << std::endl;
}
subchild = gdml->GetNext(subchild);
}
fVolID = fVolID + 1;
TGeoHMatrix *transform = new TGeoHMatrix();
if (pos != 0) transform->SetTranslation(pos->GetTranslation());
if (rot != 0) transform->SetRotation(rot->GetRotationMatrix());
if (scl != 0) {
Double_t scale3x3[9];
memset(scale3x3, 0, 9 * sizeof(Double_t));
const Double_t *diagonal = scl->GetScale();
scale3x3[0] = diagonal[0];
scale3x3[4] = diagonal[1];
scale3x3[8] = diagonal[2];
TGeoRotation scaleMatrix;
scaleMatrix.SetMatrix(scale3x3);
transform->Multiply(&scaleMatrix);
}
if (freflvolmap.find(volref.Data()) != freflvolmap.end()) {
TGDMLRefl* temprefl = freflsolidmap[freflvolmap[volref.Data()]];
transform->Multiply(temprefl->GetMatrix());
}
if (yesrefl == 1) {
TGeoRotation prot;
prot.SetMatrix(parentrot);
transform->MultiplyLeft(&prot);
}
vol->AddNode(lv, fVolID, transform);
} else if ((strcmp(gdml->GetNodeName(child), "divisionvol")) == 0) {
TString divVolref = "";
Int_t axis = 0;
TString number = "";
TString width = "";
TString offset = "";
TString lunit = "mm";
attr = gdml->GetFirstAttr(child);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "axis") {
axis = SetAxis(gdml->GetAttrValue(attr));
} else if (tempattr == "number") {
number = gdml->GetAttrValue(attr);
} else if (tempattr == "width") {
width = gdml->GetAttrValue(attr);
} else if (tempattr == "offset") {
offset = gdml->GetAttrValue(attr);
} else if (tempattr == "unit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
subchild = gdml->GetChild(child);
while (subchild != 0) {
tempattr = gdml->GetNodeName(subchild);
tempattr.ToLower();
if (tempattr == "volumeref") {
reftemp = gdml->GetAttr(subchild, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
divVolref = reftemp;
}
subchild = gdml->GetNext(subchild);
}
Double_t numberline = Value(number);
Double_t retunit = GetScaleVal(lunit);
Double_t step = Value(width) * retunit;
Double_t offsetline = Value(offset) * retunit;
fVolID = fVolID + 1;
Double_t xlo, xhi;
vol->GetShape()->GetAxisRange(axis, xlo, xhi);
Int_t ndiv = (Int_t)numberline;
Double_t start = xlo + offsetline;
Int_t numed = 0;
TGeoVolume *old = fvolmap[NameShort(reftemp)];
if (old) {
old = fvolmap[NameShort(reftemp)];
numed = old->GetMedium()->GetId();
}
TGeoVolume *divvol = vol->Divide(NameShort(reftemp), axis, ndiv, start, step, numed);
if (!divvol) {
Fatal("VolProcess", "Cannot divide volume %s", vol->GetName());
return child;
}
if (old && old->GetNdaughters()) {
divvol->ReplayCreation(old);
}
fvolmap[NameShort(reftemp)] = divvol;
}
else if ((strcmp(gdml->GetNodeName(child), "replicavol")) == 0) {
TString divVolref = "";
Int_t axis = 0;
TString number = "";
TString width = "";
TString offset = "";
TString wunit = "mm";
TString ounit = "mm";
Double_t wvalue = 0;
Double_t ovalue = 0;
attr = gdml->GetFirstAttr(child);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "number") {
number = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
subchild = gdml->GetChild(child);
while (subchild != 0) {
tempattr = gdml->GetNodeName(subchild);
tempattr.ToLower();
if (tempattr == "volumeref") {
reftemp = gdml->GetAttr(subchild, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
divVolref = reftemp;
}
if (tempattr == "replicate_along_axis") {
subsubchild = gdml->GetChild(subchild);
while (subsubchild != 0) {
if ((strcmp(gdml->GetNodeName(subsubchild), "width")) == 0) {
attr = gdml->GetFirstAttr(subsubchild);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "value") {
wvalue = Value(gdml->GetAttrValue(attr));
}
else if (tempattr == "unit"){
wunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
}
else if ((strcmp(gdml->GetNodeName(subsubchild), "offset")) == 0) {
attr = gdml->GetFirstAttr(subsubchild);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "value") {
ovalue = Value(gdml->GetAttrValue(attr));
}
else if (tempattr == "unit"){
ounit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
}
else if ((strcmp(gdml->GetNodeName(subsubchild), "direction")) == 0) {
attr = gdml->GetFirstAttr(subsubchild);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "x") {
axis = 1;
}
else if (tempattr == "y"){
axis = 2;
}
else if (tempattr == "z"){
axis = 3;
}
else if (tempattr == "rho"){
axis = 1;
}
else if (tempattr == "phi"){
axis = 2;
}
attr = gdml->GetNextAttr(attr);
}
}
subsubchild = gdml->GetNext(subsubchild);
}
}
subchild = gdml->GetNext(subchild);
}
Double_t retwunit = GetScaleVal(wunit);
Double_t retounit = GetScaleVal(ounit);
Double_t numberline = Value(number);
Double_t widthline = wvalue*retwunit;
Double_t offsetline = ovalue*retounit;
fVolID = fVolID + 1;
Double_t xlo, xhi;
vol->GetShape()->GetAxisRange(axis, xlo, xhi);
Int_t ndiv = (Int_t)numberline;
Double_t start = xlo + offsetline;
Double_t step = widthline;
Int_t numed = 0;
TGeoVolume *old = fvolmap[NameShort(reftemp)];
if (old) {
old = fvolmap[NameShort(reftemp)];
numed = old->GetMedium()->GetId();
}
TGeoVolume *divvol = vol->Divide(NameShort(reftemp), axis, ndiv, start, step, numed);
if (!divvol) {
Fatal("VolProcess", "Cannot divide volume %s", vol->GetName());
return child;
}
if (old && old->GetNdaughters()) {
divvol->ReplayCreation(old);
}
fvolmap[NameShort(reftemp)] = divvol;
}
else if (strcmp(gdml->GetNodeName(child), "auxiliary") == 0) {
if(!auxmap) {
printf("Auxiliary values for volume %s\n",vol->GetName());
auxmap = new TMap();
vol->SetUserExtension(new TGeoRCExtension(auxmap));
}
attr = gdml->GetFirstAttr(child);
while(attr) {
if(strcmp(gdml->GetAttrName(attr),"auxtype")) Fatal("VolProcess","Expecting auxtype, found %s",
gdml->GetAttrName(attr));
const char *auxType = gdml->GetAttrValue(attr);
attr = gdml->GetNextAttr(attr);
if(strcmp(gdml->GetAttrName(attr),"auxvalue")) Fatal("VolProcess","Expecting auxvalue, found %s",
gdml->GetAttrName(attr));
const char *auxValue = gdml->GetAttrValue(attr);
printf("%s = %s\n",auxType, auxValue);
auxmap->Add(new TObjString(auxType),new TObjString(auxValue));
attr = gdml->GetNextAttr(attr);
}
}
child = gdml->GetNext(child);
}
return child;
}
XMLNodePointer_t TGDMLParse::BooSolid(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr, int num)
{
TString reftemp = "";
TString tempattr = "";
XMLNodePointer_t child = gdml->GetChild(node);
TGeoShape* first = 0;
TGeoShape* second = 0;
TGeoTranslation* firstPos = new TGeoTranslation(0, 0, 0);
TGeoTranslation* secondPos = new TGeoTranslation(0, 0, 0);
TGeoRotation* firstRot = new TGeoRotation();
TGeoRotation* secondRot = new TGeoRotation();
firstRot->RotateZ(0);
firstRot->RotateY(0);
firstRot->RotateX(0);
secondRot->RotateZ(0);
secondRot->RotateY(0);
secondRot->RotateX(0);
TString name = gdml->GetAttr(node, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0)
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
while (child != 0) {
tempattr = gdml->GetNodeName(child);
tempattr.ToLower();
if (tempattr == "first") {
reftemp = gdml->GetAttr(child, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (fsolmap.find(reftemp.Data()) != fsolmap.end()) {
first = fsolmap[reftemp.Data()];
}
} else if (tempattr == "second") {
reftemp = gdml->GetAttr(child, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (fsolmap.find(reftemp.Data()) != fsolmap.end()) {
second = fsolmap[reftemp.Data()];
}
} else if (tempattr == "position") {
attr = gdml->GetFirstAttr(child);
PosProcess(gdml, child, attr);
reftemp = gdml->GetAttr(child, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
secondPos = fposmap[reftemp.Data()];
} else if (tempattr == "positionref") {
reftemp = gdml->GetAttr(child, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (fposmap.find(reftemp.Data()) != fposmap.end()) {
secondPos = fposmap[reftemp.Data()];
}
} else if (tempattr == "rotation") {
attr = gdml->GetFirstAttr(child);
RotProcess(gdml, child, attr);
reftemp = gdml->GetAttr(child, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
secondRot = frotmap[reftemp.Data()];
} else if (tempattr == "rotationref") {
reftemp = gdml->GetAttr(child, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (frotmap.find(reftemp.Data()) != frotmap.end()) {
secondRot = frotmap[reftemp.Data()];
}
} else if (tempattr == "firstposition") {
attr = gdml->GetFirstAttr(child);
PosProcess(gdml, child, attr);
reftemp = gdml->GetAttr(child, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
firstPos = fposmap[reftemp.Data()];
} else if (tempattr == "firstpositionref") {
reftemp = gdml->GetAttr(child, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (fposmap.find(reftemp.Data()) != fposmap.end()) {
firstPos = fposmap[reftemp.Data()];
}
} else if (tempattr == "firstrotation") {
attr = gdml->GetFirstAttr(child);
RotProcess(gdml, child, attr);
reftemp = gdml->GetAttr(child, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
firstRot = frotmap[reftemp.Data()];
} else if (tempattr == "firstrotationref") {
reftemp = gdml->GetAttr(child, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (frotmap.find(reftemp.Data()) != frotmap.end()) {
firstRot = frotmap[reftemp.Data()];
}
}
child = gdml->GetNext(child);
}
TGeoMatrix* firstMatrix = new TGeoCombiTrans(*firstPos, firstRot->Inverse());
TGeoMatrix* secondMatrix = new TGeoCombiTrans(*secondPos, secondRot->Inverse());
TGeoCompositeShape* boolean = 0;
if (!first || !second) {
Fatal("BooSolid", "Incomplete solid %s, missing shape components", name.Data());
return child;
}
switch (num) {
case 1:
boolean = new TGeoCompositeShape(NameShort(name), new TGeoSubtraction(first, second, firstMatrix, secondMatrix));
break;
case 2:
boolean = new TGeoCompositeShape(NameShort(name), new TGeoIntersection(first, second, firstMatrix, secondMatrix));
break;
case 3:
boolean = new TGeoCompositeShape(NameShort(name), new TGeoUnion(first, second, firstMatrix, secondMatrix));
break;
default:
break;
}
fsolmap[name.Data()] = boolean;
return child;
}
XMLNodePointer_t TGDMLParse::AssProcess(TXMLEngine* gdml, XMLNodePointer_t node)
{
TString name = gdml->GetAttr(node, "name");
TString reftemp = "";
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
XMLAttrPointer_t attr;
XMLNodePointer_t subchild;
XMLNodePointer_t child = gdml->GetChild(node);
TString tempattr = "";
TGeoVolume* lv = 0;
TGeoTranslation* pos = 0;
TGeoRotation* rot = 0;
TGeoCombiTrans* matr;
TGeoVolumeAssembly* assem = new TGeoVolumeAssembly(NameShort(name));
while (child != 0) {
if ((strcmp(gdml->GetNodeName(child), "physvol")) == 0) {
subchild = gdml->GetChild(child);
pos = new TGeoTranslation(0, 0, 0);
rot = new TGeoRotation();
while (subchild != 0) {
tempattr = gdml->GetNodeName(subchild);
tempattr.ToLower();
if (tempattr == "volumeref") {
reftemp = gdml->GetAttr(subchild, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
lv = fvolmap[reftemp.Data()];
} else if (tempattr == "positionref") {
reftemp = gdml->GetAttr(subchild, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (fposmap.find(reftemp.Data()) != fposmap.end()) {
pos = fposmap[reftemp.Data()];
}
} else if (tempattr == "position") {
attr = gdml->GetFirstAttr(subchild);
PosProcess(gdml, subchild, attr);
reftemp = gdml->GetAttr(subchild, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
pos = fposmap[reftemp.Data()];
} else if (tempattr == "rotationref") {
reftemp = gdml->GetAttr(subchild, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
if (frotmap.find(reftemp.Data()) != frotmap.end()) {
rot = frotmap[reftemp.Data()];
}
} else if (tempattr == "rotation") {
attr = gdml->GetFirstAttr(subchild);
RotProcess(gdml, subchild, attr);
reftemp = gdml->GetAttr(subchild, "name");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
rot = frotmap[reftemp.Data()];
}
subchild = gdml->GetNext(subchild);
}
fVolID = fVolID + 1;
matr = new TGeoCombiTrans(*pos, *rot);
assem->AddNode(lv, fVolID, matr);
}
child = gdml->GetNext(child);
}
fvolmap[name.Data()] = assem;
return child;
}
XMLNodePointer_t TGDMLParse::TopProcess(TXMLEngine* gdml, XMLNodePointer_t node)
{
const char* name = gdml->GetAttr(node, "name");
gGeoManager->SetName(name);
XMLNodePointer_t child = gdml->GetChild(node);
TString reftemp = "";
while (child != 0) {
if ((strcmp(gdml->GetNodeName(child), "world") == 0)) {
reftemp = gdml->GetAttr(child, "ref");
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
}
fWorld = fvolmap[reftemp.Data()];
fWorldName = reftemp.Data();
}
child = gdml->GetNext(child);
}
return node;
}
XMLNodePointer_t TGDMLParse::Box(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString xpos = "0";
TString ypos = "0";
TString zpos = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "x") {
xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "y") {
ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
zpos = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retunit = GetScaleVal(lunit);
Double_t xline = 0.5*Value(xpos)*retunit;
Double_t yline = 0.5*Value(ypos)*retunit;
Double_t zline = 0.5*Value(zpos)*retunit;
TGeoBBox* box = new TGeoBBox(NameShort(name), xline, yline, zline);
fsolmap[name.Data()] = box;
return node;
}
XMLNodePointer_t TGDMLParse::Ellipsoid(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString ax = "0";
TString by = "0";
TString cz = "0";
TString zcut1 = "";
TString zcut2 = "";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "ax") {
ax = gdml->GetAttrValue(attr);
} else if (tempattr == "by") {
by = gdml->GetAttrValue(attr);
} else if (tempattr == "cz") {
cz = gdml->GetAttrValue(attr);
} else if (tempattr == "zcut1") {
zcut1 = gdml->GetAttrValue(attr);
} else if (tempattr == "zcut2") {
zcut2 = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retunit = GetScaleVal(lunit);
Double_t dx = Value(ax)*retunit;
Double_t dy = Value(by)*retunit;
Double_t radius = Value(cz)*retunit;
Double_t sx = dx / radius;
Double_t sy = dy / radius;
Double_t sz = 1.;
Double_t z1, z2;
if (zcut1 == "") {
z1 = -radius;
} else {
z1 = Value(zcut1)*retunit;
}
if (zcut2 == "") {
z2 = radius;
} else {
z2 = Value(zcut2)*retunit;
}
TGeoSphere *sph = new TGeoSphere(0, radius);
TGeoScale *scl = new TGeoScale("", sx, sy, sz);
TGeoScaledShape *shape = new TGeoScaledShape(NameShort(name), sph, scl);
Double_t origin[3] = {0., 0., 0.};
origin[2] = 0.5 * (z1 + z2);
Double_t dz = 0.5 * (z2 - z1);
TGeoBBox *pCutBox = new TGeoBBox("cutBox", dx, dy, dz, origin);
TGeoBoolNode *pBoolNode = new TGeoIntersection(shape, pCutBox, 0, 0);
TGeoCompositeShape *cs = new TGeoCompositeShape(NameShort(name), pBoolNode);
fsolmap[name.Data()] = cs;
return node;
}
XMLNodePointer_t TGDMLParse::ElCone(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString dx = "0";
TString dy = "0";
TString zmax = "0";
TString zcut = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "dx") {
dx = gdml->GetAttrValue(attr);
} else if (tempattr == "dy") {
dy = gdml->GetAttrValue(attr);
} else if (tempattr == "zmax") {
zmax = gdml->GetAttrValue(attr);
} else if (tempattr == "zcut") {
zcut = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retunit = GetScaleVal(lunit);
Double_t dxratio = Value(dx);
Double_t dyratio = Value(dy);
Double_t z = Value(zmax)*retunit;
Double_t z1 = Value(zcut)*retunit;
if (z1 <= 0) {
Info("ElCone", "ERROR! Parameter zcut = %.12g is not set properly, elcone will not be imported.", z1);
return node;
}
if (z1 > z){
z1 = z;
}
Double_t rx1 = (z + z1) * dxratio;
Double_t ry1 = (z + z1) * dyratio;
Double_t rx2 = (z - z1) * dxratio;
Double_t sx = 1.;
Double_t sy = ry1 / rx1;
Double_t sz = 1.;
TGeoCone *con = new TGeoCone(z1, 0, rx1, 0, rx2);
TGeoScale *scl = new TGeoScale("", sx, sy, sz);
TGeoScaledShape *shape = new TGeoScaledShape(NameShort(name), con, scl);
fsolmap[name.Data()] = shape;
return node;
}
XMLNodePointer_t TGDMLParse::Paraboloid(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString rlopos = "0";
TString rhipos = "0";
TString dzpos = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "rlo") {
rlopos = gdml->GetAttrValue(attr);
} else if (tempattr == "rhi") {
rhipos = gdml->GetAttrValue(attr);
} else if (tempattr == "dz") {
dzpos = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retunit = GetScaleVal(lunit);
Double_t rlo = Value(rlopos)*retunit;
Double_t rhi = Value(rhipos)*retunit;
Double_t dz = Value(dzpos)*retunit;
TGeoParaboloid* paraboloid = new TGeoParaboloid(NameShort(name), rlo, rhi, dz);
fsolmap[name.Data()] = paraboloid;
return node;
}
XMLNodePointer_t TGDMLParse::Arb8(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString v1xpos = "0";
TString v1ypos = "0";
TString v2xpos = "0";
TString v2ypos = "0";
TString v3xpos = "0";
TString v3ypos = "0";
TString v4xpos = "0";
TString v4ypos = "0";
TString v5xpos = "0";
TString v5ypos = "0";
TString v6xpos = "0";
TString v6ypos = "0";
TString v7xpos = "0";
TString v7ypos = "0";
TString v8xpos = "0";
TString v8ypos = "0";
TString dzpos = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "v1x") {
v1xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "v1y") {
v1ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "v2x") {
v2xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "v2y") {
v2ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "v3x") {
v3xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "v3y") {
v3ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "v4x") {
v4xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "v4y") {
v4ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "v5x") {
v5xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "v5y") {
v5ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "v6x") {
v6xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "v6y") {
v6ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "v7x") {
v7xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "v7y") {
v7ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "v8x") {
v8xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "v8y") {
v8ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "dz") {
dzpos = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retunit = GetScaleVal(lunit);
Double_t v1x = Value(v1xpos)*retunit;
Double_t v1y = Value(v1ypos)*retunit;
Double_t v2x = Value(v2xpos)*retunit;
Double_t v2y = Value(v2ypos)*retunit;
Double_t v3x = Value(v3xpos)*retunit;
Double_t v3y = Value(v3ypos)*retunit;
Double_t v4x = Value(v4xpos)*retunit;
Double_t v4y = Value(v4ypos)*retunit;
Double_t v5x = Value(v5xpos)*retunit;
Double_t v5y = Value(v5ypos)*retunit;
Double_t v6x = Value(v6xpos)*retunit;
Double_t v6y = Value(v6ypos)*retunit;
Double_t v7x = Value(v7xpos)*retunit;
Double_t v7y = Value(v7ypos)*retunit;
Double_t v8x = Value(v8xpos)*retunit;
Double_t v8y = Value(v8ypos)*retunit;
Double_t dz = Value(dzpos)*retunit;
TGeoArb8* arb8 = new TGeoArb8(NameShort(name), dz);
arb8->SetVertex(0, v1x, v1y);
arb8->SetVertex(1, v2x, v2y);
arb8->SetVertex(2, v3x, v3y);
arb8->SetVertex(3, v4x, v4y);
arb8->SetVertex(4, v5x, v5y);
arb8->SetVertex(5, v6x, v6y);
arb8->SetVertex(6, v7x, v7y);
arb8->SetVertex(7, v8x, v8y);
fsolmap[name.Data()] = arb8;
return node;
}
XMLNodePointer_t TGDMLParse::Tube(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString rmin = "0";
TString rmax = "0";
TString z = "0";
TString startphi = "0";
TString deltaphi = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "rmin") {
rmin = gdml->GetAttrValue(attr);
} else if (tempattr == "rmax") {
rmax = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "startphi") {
startphi = gdml->GetAttrValue(attr);
} else if (tempattr == "deltaphi") {
deltaphi = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
Double_t rminline = Value(rmin)*retlunit;
Double_t rmaxline = Value(rmax)*retlunit;
Double_t zline = Value(z)*retlunit;
Double_t startphideg = Value(startphi)*retaunit;
Double_t deltaphideg = Value(deltaphi)*retaunit;
Double_t endphideg = startphideg + deltaphideg;
TGeoShape *tube = 0;
if (deltaphideg < 360.)
tube = new TGeoTubeSeg(NameShort(name), rminline,
rmaxline,
zline / 2,
startphideg,
endphideg);
else
tube = new TGeoTube(NameShort(name), rminline,
rmaxline,
zline / 2);
fsolmap[name.Data()] = tube;
return node;
}
XMLNodePointer_t TGDMLParse::CutTube(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString rmin = "0";
TString rmax = "0";
TString z = "0";
TString startphi = "0";
TString deltaphi = "0";
TString lowX = "0";
TString lowY = "0";
TString lowZ = "0";
TString highX = "0";
TString highY = "0";
TString highZ = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "rmin") {
rmin = gdml->GetAttrValue(attr);
} else if (tempattr == "rmax") {
rmax = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "startphi") {
startphi = gdml->GetAttrValue(attr);
} else if (tempattr == "deltaphi") {
deltaphi = gdml->GetAttrValue(attr);
} else if (tempattr == "lowx") {
lowX = gdml->GetAttrValue(attr);
} else if (tempattr == "lowy") {
lowY = gdml->GetAttrValue(attr);
} else if (tempattr == "lowz") {
lowZ = gdml->GetAttrValue(attr);
} else if (tempattr == "highx") {
highX = gdml->GetAttrValue(attr);
} else if (tempattr == "highy") {
highY = gdml->GetAttrValue(attr);
} else if (tempattr == "highz") {
highZ = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
Double_t rminline = Value(rmin)*retlunit;
Double_t rmaxline = Value(rmax)*retlunit;
Double_t zline = Value(z)*retlunit;
Double_t startphiline = Value(startphi)*retaunit;
Double_t deltaphiline = Value(deltaphi)*retaunit + startphiline;
Double_t lowXline = Value(lowX)*retlunit;
Double_t lowYline = Value(lowY)*retlunit;
Double_t lowZline = Value(lowZ)*retlunit;
Double_t highXline = Value(highX)*retlunit;
Double_t highYline = Value(highY)*retlunit;
Double_t highZline = Value(highZ)*retlunit;
TGeoCtub* cuttube = new TGeoCtub(NameShort(name), rminline,
rmaxline,
zline / 2,
startphiline,
deltaphiline,
lowXline,
lowYline,
lowZline,
highXline,
highYline,
highZline);
fsolmap[name.Data()] = cuttube;
return node;
}
XMLNodePointer_t TGDMLParse::Cone(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString rmin1 = "0";
TString rmax1 = "0";
TString rmin2 = "0";
TString rmax2 = "0";
TString z = "0";
TString startphi = "0";
TString deltaphi = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "rmin1") {
rmin1 = gdml->GetAttrValue(attr);
} else if (tempattr == "rmax1") {
rmax1 = gdml->GetAttrValue(attr);
} else if (tempattr == "rmin2") {
rmin2 = gdml->GetAttrValue(attr);
} else if (tempattr == "rmax2") {
rmax2 = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "startphi") {
startphi = gdml->GetAttrValue(attr);
} else if (tempattr == "deltaphi") {
deltaphi = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
Double_t rmin1line = Value(rmin1)*retlunit;
Double_t rmax1line = Value(rmax1)*retlunit;
Double_t rmin2line = Value(rmin2)*retlunit;
Double_t rmax2line = Value(rmax2)*retlunit;
Double_t zline = Value(z)*retlunit;
Double_t sphi = Value(startphi)*retaunit;
Double_t dphi = Value(deltaphi)*retaunit;
Double_t ephi = sphi + dphi;
TGeoShape *cone = 0;
if (dphi < 360.)
cone = new TGeoConeSeg(NameShort(name), zline / 2,
rmin1line,
rmax1line,
rmin2line,
rmax2line,
sphi, ephi);
else
cone = new TGeoCone(NameShort(name), zline / 2,
rmin1line,
rmax1line,
rmin2line,
rmax2line);
fsolmap[name.Data()] = cone;
return node;
}
XMLNodePointer_t TGDMLParse::Trap(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString x1 = "0";
TString x2 = "0";
TString x3 = "0";
TString x4 = "0";
TString y1 = "0";
TString y2 = "0";
TString z = "0";
TString phi = "0";
TString theta = "0";
TString alpha1 = "0";
TString alpha2 = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "x1") {
x1 = gdml->GetAttrValue(attr);
} else if (tempattr == "x2") {
x2 = gdml->GetAttrValue(attr);
} else if (tempattr == "x3") {
x3 = gdml->GetAttrValue(attr);
} else if (tempattr == "x4") {
x4 = gdml->GetAttrValue(attr);
} else if (tempattr == "y1") {
y1 = gdml->GetAttrValue(attr);
} else if (tempattr == "y2") {
y2 = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "phi") {
phi = gdml->GetAttrValue(attr);
} else if (tempattr == "theta") {
theta = gdml->GetAttrValue(attr);
} else if (tempattr == "alpha1") {
alpha1 = gdml->GetAttrValue(attr);
} else if (tempattr == "alpha2") {
alpha2 = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
Double_t x1line = Value(x1)*retlunit;
Double_t x2line = Value(x2)*retlunit;
Double_t x3line = Value(x3)*retlunit;
Double_t x4line = Value(x4)*retlunit;
Double_t y1line = Value(y1)*retlunit;
Double_t y2line = Value(y2)*retlunit;
Double_t zline = Value(z)*retlunit;
Double_t philine = Value(phi)*retaunit;
Double_t thetaline = Value(theta)*retaunit;
Double_t alpha1line = Value(alpha1)*retaunit;
Double_t alpha2line = Value(alpha2)*retaunit;
TGeoTrap* trap = new TGeoTrap(NameShort(name), zline / 2,
thetaline,
philine,
y1line / 2,
x1line / 2,
x2line / 2,
alpha1line,
y2line / 2,
x3line / 2,
x4line / 2,
alpha2line);
fsolmap[name.Data()] = trap;
return node;
}
XMLNodePointer_t TGDMLParse::Trd(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString x1 = "0";
TString x2 = "0";
TString y1 = "0";
TString y2 = "0";
TString z = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "x1") {
x1 = gdml->GetAttrValue(attr);
} else if (tempattr == "x2") {
x2 = gdml->GetAttrValue(attr);
} else if (tempattr == "y1") {
y1 = gdml->GetAttrValue(attr);
} else if (tempattr == "y2") {
y2 = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t x1line = Value(x1)*retlunit;
Double_t x2line = Value(x2)*retlunit;
Double_t y1line = Value(y1)*retlunit;
Double_t y2line = Value(y2)*retlunit;
Double_t zline = Value(z)*retlunit;
TGeoTrd2* trd = new TGeoTrd2(NameShort(name),
x1line / 2,
x2line / 2,
y1line / 2,
y2line / 2,
zline / 2);
fsolmap[name.Data()] = trd;
return node;
}
XMLNodePointer_t TGDMLParse::Polycone(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString rmin = "0";
TString rmax = "0";
TString z = "0";
TString startphi = "0";
TString deltaphi = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "startphi") {
startphi = gdml->GetAttrValue(attr);
} else if (tempattr == "deltaphi") {
deltaphi = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
XMLNodePointer_t child = gdml->GetChild(node);
int numplanes = 0;
while (child != 0) {
numplanes = numplanes + 1;
child = gdml->GetNext(child);
}
int cols;
int i;
cols = 3;
double ** table = new double*[numplanes];
for (i = 0; i < numplanes; i++) {
table[i] = new double[cols];
}
child = gdml->GetChild(node);
int planeno = 0;
while (child != 0) {
if (strcmp(gdml->GetNodeName(child), "zplane") == 0) {
Double_t rminline = 0;
Double_t rmaxline = 0;
Double_t zline = 0;
attr = gdml->GetFirstAttr(child);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "rmin") {
rmin = gdml->GetAttrValue(attr);
rminline = Value(rmin)*retlunit;
table[planeno][0] = rminline;
} else if (tempattr == "rmax") {
rmax = gdml->GetAttrValue(attr);
rmaxline = Value(rmax)*retlunit;
table[planeno][1] = rmaxline;
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
zline = Value(z)*retlunit;
table[planeno][2] = zline;
}
attr = gdml->GetNextAttr(attr);
}
}
planeno = planeno + 1;
child = gdml->GetNext(child);
}
Double_t startphiline = Value(startphi)*retaunit;
Double_t deltaphiline = Value(deltaphi)*retaunit;
TGeoPcon* poly = new TGeoPcon(NameShort(name),
startphiline,
deltaphiline,
numplanes);
Int_t zno = 0;
for (int j = 0; j < numplanes; j++) {
poly->DefineSection(zno, table[j][2], table[j][0], table[j][1]);
zno = zno + 1;
}
fsolmap[name.Data()] = poly;
for (i = 0; i < numplanes; i++) {
delete [] table[i];
}
delete [] table;
return node;
}
XMLNodePointer_t TGDMLParse::Polyhedra(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString rmin = "0";
TString rmax = "0";
TString z = "0";
TString startphi = "0";
TString deltaphi = "0";
TString numsides = "1";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "startphi") {
startphi = gdml->GetAttrValue(attr);
} else if (tempattr == "deltaphi") {
deltaphi = gdml->GetAttrValue(attr);
} else if (tempattr == "numsides") {
numsides = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
XMLNodePointer_t child = gdml->GetChild(node);
int numplanes = 0;
while (child != 0) {
numplanes = numplanes + 1;
child = gdml->GetNext(child);
}
int cols;
int i;
cols = 3;
double ** table = new double*[numplanes];
for (i = 0; i < numplanes; i++) {
table[i] = new double[cols];
}
child = gdml->GetChild(node);
int planeno = 0;
while (child != 0) {
if (strcmp(gdml->GetNodeName(child), "zplane") == 0) {
Double_t rminline = 0;
Double_t rmaxline = 0;
Double_t zline = 0;
attr = gdml->GetFirstAttr(child);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "rmin") {
rmin = gdml->GetAttrValue(attr);
rminline = Value(rmin)*retlunit;
table[planeno][0] = rminline;
} else if (tempattr == "rmax") {
rmax = gdml->GetAttrValue(attr);
rmaxline = Value(rmax)*retlunit;
table[planeno][1] = rmaxline;
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
zline = Value(z)*retlunit;
table[planeno][2] = zline;
}
attr = gdml->GetNextAttr(attr);
}
}
planeno = planeno + 1;
child = gdml->GetNext(child);
}
Double_t startphiline = Value(startphi)*retaunit;
Double_t deltaphiline = Value(deltaphi)*retaunit;
Int_t numsidesline = (int)Value(numsides);
TGeoPgon* polyg = new TGeoPgon(NameShort(name),
startphiline,
deltaphiline,
numsidesline,
numplanes);
Int_t zno = 0;
for (int j = 0; j < numplanes; j++) {
polyg->DefineSection(zno, table[j][2], table[j][0], table[j][1]);
zno = zno + 1;
}
fsolmap[name.Data()] = polyg;
for (i = 0; i < numplanes; i++) {
delete [] table[i];
}
delete [] table;
return node;
}
XMLNodePointer_t TGDMLParse::Sphere(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString rmin = "0";
TString rmax = "0";
TString startphi = "0";
TString deltaphi = "0";
TString starttheta = "0";
TString deltatheta = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "rmin") {
rmin = gdml->GetAttrValue(attr);
} else if (tempattr == "rmax") {
rmax = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "startphi") {
startphi = gdml->GetAttrValue(attr);
} else if (tempattr == "deltaphi") {
deltaphi = gdml->GetAttrValue(attr);
} else if (tempattr == "starttheta") {
starttheta = gdml->GetAttrValue(attr);
} else if (tempattr == "deltatheta") {
deltatheta = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
Double_t rminline = Value(rmin)*retlunit;
Double_t rmaxline = Value(rmax)*retlunit;
Double_t startphiline = Value(startphi)*retaunit;
Double_t deltaphiline = startphiline+ Value(deltaphi)*retaunit;
Double_t startthetaline = Value(starttheta)*retaunit;
Double_t deltathetaline = startthetaline + Value(deltatheta)*retaunit;
TGeoSphere* sphere = new TGeoSphere(NameShort(name),
rminline,
rmaxline,
startthetaline,
deltathetaline,
startphiline,
deltaphiline);
fsolmap[name.Data()] = sphere;
return node;
}
XMLNodePointer_t TGDMLParse::Torus(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString rmin = "0";
TString rmax = "0";
TString rtor = "0";
TString startphi = "0";
TString deltaphi = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "rmin") {
rmin = gdml->GetAttrValue(attr);
} else if (tempattr == "rmax") {
rmax = gdml->GetAttrValue(attr);
} else if (tempattr == "rtor") {
rtor = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "startphi") {
startphi = gdml->GetAttrValue(attr);
} else if (tempattr == "deltaphi") {
deltaphi = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
Double_t rminline = Value(rmin)*retlunit;
Double_t rmaxline = Value(rmax)*retlunit;
Double_t rtorline = Value(rtor)*retlunit;
Double_t startphiline = Value(startphi)*retaunit;
Double_t deltaphiline = Value(deltaphi)*retaunit;
TGeoTorus* torus = new TGeoTorus(NameShort(name), rtorline,
rminline,
rmaxline,
startphiline,
deltaphiline);
fsolmap[name.Data()] = torus;
return node;
}
XMLNodePointer_t TGDMLParse::Hype(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString rmin = "0";
TString rmax = "0";
TString z = "0";
TString inst = "0";
TString outst = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "rmin") {
rmin = gdml->GetAttrValue(attr);
} else if (tempattr == "rmax") {
rmax = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "inst") {
inst = gdml->GetAttrValue(attr);
} else if (tempattr == "outst") {
outst = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
Double_t rminline = Value(rmin)*retlunit;
Double_t rmaxline = Value(rmax)*retlunit;
Double_t zline = Value(z)*retlunit;
Double_t instline = Value(inst)*retaunit;
Double_t outstline = Value(outst)*retaunit;
TGeoHype* hype = new TGeoHype(NameShort(name),
rminline,
instline,
rmaxline,
outstline,
zline / 2);
fsolmap[name.Data()] = hype;
return node;
}
XMLNodePointer_t TGDMLParse::Para(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString x = "0";
TString y = "0";
TString z = "0";
TString phi = "0";
TString theta = "0";
TString alpha = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "x") {
x = gdml->GetAttrValue(attr);
} else if (tempattr == "y") {
y = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "phi") {
phi = gdml->GetAttrValue(attr);
} else if (tempattr == "theta") {
theta = gdml->GetAttrValue(attr);
} else if (tempattr == "alpha") {
alpha = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
Double_t xline = Value(x)*retlunit;
Double_t yline = Value(y)*retlunit;
Double_t zline = Value(z)*retlunit;
Double_t philine = Value(phi)*retaunit;
Double_t alphaline = Value(alpha)*retaunit;
Double_t thetaline = Value(theta)*retaunit;
TGeoPara* para = new TGeoPara(NameShort(name),
xline / 2,
yline / 2,
zline / 2,
alphaline,
thetaline,
philine);
fsolmap[name.Data()] = para;
return node;
}
XMLNodePointer_t TGDMLParse::TwistTrap(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString aunit = "rad";
TString x1 = "0";
TString x2 = "0";
TString x3 = "0";
TString x4 = "0";
TString y1 = "0";
TString y2 = "0";
TString z = "0";
TString phi = "0";
TString theta = "0";
TString alpha1 = "0";
TString alpha2 = "0";
TString twist = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "x1") {
x1 = gdml->GetAttrValue(attr);
} else if (tempattr == "x2") {
x2 = gdml->GetAttrValue(attr);
} else if (tempattr == "x3") {
x3 = gdml->GetAttrValue(attr);
} else if (tempattr == "x4") {
x4 = gdml->GetAttrValue(attr);
} else if (tempattr == "y1") {
y1 = gdml->GetAttrValue(attr);
} else if (tempattr == "y2") {
y2 = gdml->GetAttrValue(attr);
} else if (tempattr == "z") {
z = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
} else if (tempattr == "aunit") {
aunit = gdml->GetAttrValue(attr);
} else if (tempattr == "phi") {
phi = gdml->GetAttrValue(attr);
} else if (tempattr == "theta") {
theta = gdml->GetAttrValue(attr);
} else if (tempattr == "alph") {
alpha1 = gdml->GetAttrValue(attr);
alpha2 = alpha1;
} else if (tempattr == "phitwist") {
twist = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
Double_t retaunit = GetScaleVal(aunit);
Double_t x1line = Value(x1)*retlunit;
Double_t x2line = Value(x2)*retlunit;
Double_t x3line = Value(x3)*retlunit;
Double_t x4line = Value(x4)*retlunit;
Double_t y1line = Value(y1)*retlunit;
Double_t y2line = Value(y2)*retlunit;
Double_t zline = Value(z)*retlunit;
Double_t philine = Value(phi)*retaunit;
Double_t thetaline = Value(theta)*retaunit;
Double_t alpha1line = Value(alpha1)*retaunit;
Double_t alpha2line = Value(alpha2)*retaunit;
Double_t twistline = Value(twist)*retaunit;
TGeoGtra* twtrap = new TGeoGtra(NameShort(name), zline / 2,
thetaline,
philine,
twistline,
y1line / 2,
x1line / 2,
x2line / 2,
alpha1line,
y2line / 2,
x3line / 2,
x4line / 2,
alpha2line);
fsolmap[name.Data()] = twtrap;
return node;
}
XMLNodePointer_t TGDMLParse::ElTube(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString xpos = "0";
TString ypos = "0";
TString zpos = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "dx") {
xpos = gdml->GetAttrValue(attr);
} else if (tempattr == "dy") {
ypos = gdml->GetAttrValue(attr);
} else if (tempattr == "dz") {
zpos = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retunit = GetScaleVal(lunit);
Double_t xline = Value(xpos)*retunit;
Double_t yline = Value(ypos)*retunit;
Double_t zline = Value(zpos)*retunit;
TGeoEltu* eltu = new TGeoEltu(NameShort(name), xline,
yline,
zline);
fsolmap[name.Data()] = eltu;
return node;
}
XMLNodePointer_t TGDMLParse::Orb(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString r = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "r") {
r = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retunit = GetScaleVal(lunit);
Double_t rline = Value(r)*retunit;
TGeoSphere* orb = new TGeoSphere(NameShort(name), 0, rline, 0, 180, 0, 360);
fsolmap[name.Data()] = orb;
return node;
}
XMLNodePointer_t TGDMLParse::Xtru(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
TString lunit = "mm";
TString x = "0";
TString y = "0";
TString zorder = "0";
TString zpos = "0";
TString xoff = "0";
TString yoff = "0";
TString scale = "0";
TString name = "";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "lunit") {
lunit = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
Double_t retlunit = GetScaleVal(lunit);
XMLNodePointer_t child = gdml->GetChild(node);
int nosects = 0;
int noverts = 0;
while (child != 0) {
tempattr = gdml->GetNodeName(child);
if (tempattr == "twoDimVertex") {
noverts = noverts + 1;
} else if (tempattr == "section") {
nosects = nosects + 1;
}
child = gdml->GetNext(child);
}
int cols;
int i;
double *vertx = new double[noverts];
double *verty = new double[noverts];
cols = 5;
double ** section = new double*[nosects];
for (i = 0; i < nosects; i++) {
section[i] = new double[cols];
}
child = gdml->GetChild(node);
int sect = 0;
int vert = 0;
while (child != 0) {
if (strcmp(gdml->GetNodeName(child), "twoDimVertex") == 0) {
Double_t xline = 0;
Double_t yline = 0;
attr = gdml->GetFirstAttr(child);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
if (tempattr == "x") {
x = gdml->GetAttrValue(attr);
xline = Value(x)*retlunit;
vertx[vert] = xline;
} else if (tempattr == "y") {
y = gdml->GetAttrValue(attr);
yline = Value(y)*retlunit;
verty[vert] = yline;
}
attr = gdml->GetNextAttr(attr);
}
vert = vert + 1;
}
else if (strcmp(gdml->GetNodeName(child), "section") == 0) {
Double_t zposline = 0;
Double_t xoffline = 0;
Double_t yoffline = 0;
attr = gdml->GetFirstAttr(child);
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
if (tempattr == "zOrder") {
zorder = gdml->GetAttrValue(attr);
section[sect][0] = Value(zorder);
} else if (tempattr == "zPosition") {
zpos = gdml->GetAttrValue(attr);
zposline = Value(zpos)*retlunit;
section[sect][1] = zposline;
} else if (tempattr == "xOffset") {
xoff = gdml->GetAttrValue(attr);
xoffline = Value(xoff)*retlunit;
section[sect][2] = xoffline;
} else if (tempattr == "yOffset") {
yoff = gdml->GetAttrValue(attr);
yoffline = Value(yoff)*retlunit;
section[sect][3] = yoffline;
} else if (tempattr == "scalingFactor") {
scale = gdml->GetAttrValue(attr);
section[sect][4] = Value(scale);
}
attr = gdml->GetNextAttr(attr);
}
sect = sect + 1;
}
child = gdml->GetNext(child);
}
TGeoXtru* xtru = new TGeoXtru(nosects);
xtru->SetName(NameShort(name));
xtru->DefinePolygon(vert, vertx, verty);
for (int j = 0; j < sect; j++) {
xtru->DefineSection((int)section[j][0], section[j][1], section[j][2], section[j][3], section[j][4]);
}
fsolmap[name.Data()] = xtru;
delete [] vertx;
delete [] verty;
for (i = 0; i < nosects; i++) {
delete [] section[i];
}
delete [] section;
return node;
}
XMLNodePointer_t TGDMLParse::Reflection(TXMLEngine* gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
{
std::cout << "WARNING! The reflectedSolid is obsolete! Use scale transformation instead!" << std::endl;
TString sx = "0";
TString sy = "0";
TString sz = "0";
TString rx = "0";
TString ry = "0";
TString rz = "0";
TString dx = "0";
TString dy = "0";
TString dz = "0";
TString name = "0";
TString solid = "0";
TString tempattr;
while (attr != 0) {
tempattr = gdml->GetAttrName(attr);
tempattr.ToLower();
if (tempattr == "name") {
name = gdml->GetAttrValue(attr);
} else if (tempattr == "sx") {
sx = gdml->GetAttrValue(attr);
} else if (tempattr == "sy") {
sy = gdml->GetAttrValue(attr);
} else if (tempattr == "sz") {
sz = gdml->GetAttrValue(attr);
} else if (tempattr == "rx") {
rx = gdml->GetAttrValue(attr);
} else if (tempattr == "ry") {
ry = gdml->GetAttrValue(attr);
} else if (tempattr == "rz") {
rz = gdml->GetAttrValue(attr);
} else if (tempattr == "dx") {
dx = gdml->GetAttrValue(attr);
} else if (tempattr == "dy") {
dy = gdml->GetAttrValue(attr);
} else if (tempattr == "dz") {
dz = gdml->GetAttrValue(attr);
} else if (tempattr == "solid") {
solid = gdml->GetAttrValue(attr);
}
attr = gdml->GetNextAttr(attr);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
name = TString::Format("%s_%s", name.Data(), fCurrentFile);
}
if ((strcmp(fCurrentFile, fStartFile)) != 0) {
solid = TString::Format("%s_%s", solid.Data(), fCurrentFile);
}
TGeoRotation* rot = new TGeoRotation();
rot->RotateZ(-(Value(rz)));
rot->RotateY(-(Value(ry)));
rot->RotateX(-(Value(rx)));
if (atoi(sx) == -1) {
rot->ReflectX(kTRUE);
}
if (atoi(sy) == -1) {
rot->ReflectY(kTRUE);
}
if (atoi(sz) == -1) {
rot->ReflectZ(kTRUE);
}
TGeoCombiTrans* relf_matx = new TGeoCombiTrans(Value(dx), Value(dy), Value(dz), rot);
TGDMLRefl* reflsol = new TGDMLRefl(NameShort(name), solid, relf_matx);
freflsolidmap[name.Data()] = reflsol;
freflectmap[name.Data()] = solid;
return node;
}
ClassImp(TGDMLRefl)
TGDMLRefl::TGDMLRefl(const char* name, const char* solid, TGeoMatrix* matrix)
{
fNameS = name;
fSolid = solid;
fMatrix = matrix;
}
TGeoMatrix* TGDMLRefl::GetMatrix()
{
return fMatrix;
}