diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/Axis.h b/GeoModelTools/GDMLtoGM/GDMLInterface/Axis.h new file mode 100644 index 0000000000000000000000000000000000000000..511bcaf42db89bc1564718cc6d2ec9810065125e --- /dev/null +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/Axis.h @@ -0,0 +1,6 @@ +#ifndef Axis_H +#define Axis_H + +enum Axis {PHI_axis,X_axis,Y_axis,Z_axis}; + +#endif diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/GDMLController.h b/GeoModelTools/GDMLtoGM/GDMLInterface/GDMLController.h index 5a30816d3d18450c2ea51dbe7b95c21d9de40a00..d9e1c6972cda1fc2384f469e3bdb2b5b04613223 100644 --- a/GeoModelTools/GDMLtoGM/GDMLInterface/GDMLController.h +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/GDMLController.h @@ -16,7 +16,7 @@ class GeoMaterial; class GeoLogVol; class GeoPhysVol; -typedef std::pair<GeoLogVol*,GeoPhysVol*> GeoVolume; +typedef std::pair<GeoLogVol*,GeoPhysVol* > GeoVolume; typedef std::map<std::string, GeoShape*, std::less<std::string> > solidStore; diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/directionHandler.h b/GeoModelTools/GDMLtoGM/GDMLInterface/directionHandler.h new file mode 100644 index 0000000000000000000000000000000000000000..cc1983d6c06f93620cc1a8dc2ff7197ec200d725 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/directionHandler.h @@ -0,0 +1,24 @@ + +#ifndef directionHandler_H +#define directionHandler_H + +// + +#include "GDMLInterface/GDMLHandler.h" +#include "GDMLInterface/GDMLController.h" +#include "GDMLInterface/Axis.h" + +#include <string> +#include <iostream> + +class directionHandler:public GDMLHandler { +public: + directionHandler(std::string n, GDMLController* c); + void ElementHandle(); + Axis getAxis(); +private: + Axis axis; +}; + + +#endif /* end of include guard: */ diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/offsetHandler.h b/GeoModelTools/GDMLtoGM/GDMLInterface/offsetHandler.h new file mode 100644 index 0000000000000000000000000000000000000000..4135d4add85b7ffa51cb7855b3e8df963397b61b --- /dev/null +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/offsetHandler.h @@ -0,0 +1,24 @@ + +#ifndef offsetHandler_H +#define offsetHandler_H + +// + +#include "GDMLInterface/GDMLHandler.h" +#include "GDMLInterface/GDMLController.h" +#include <string> +#include <iostream> + +class offsetHandler:public GDMLHandler { +public: + offsetHandler(std::string n, GDMLController* c); + void ElementHandle(); + double getOffset(); +private: + double unit; + double value; + double offset; +}; + + +#endif /* end of include guard: */ diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/physvolHandler.h b/GeoModelTools/GDMLtoGM/GDMLInterface/physvolHandler.h index 26fdd6e178888da583dc577dab42fed4d6a7f2b8..b3e96c4a0ed1efd4653ece5bc33e351dddc57c36 100644 --- a/GeoModelTools/GDMLtoGM/GDMLInterface/physvolHandler.h +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/physvolHandler.h @@ -6,7 +6,6 @@ #include <string> -class GDMLHandler; class GeoPhysVol; class GeoTransform; diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/replicaHandler.h b/GeoModelTools/GDMLtoGM/GDMLInterface/replicaHandler.h index 153a94d524710a030a7d53e58b885b46dab291a0..7ce66093f334ce1e7e0542839a856d5baf855375 100644 --- a/GeoModelTools/GDMLtoGM/GDMLInterface/replicaHandler.h +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/replicaHandler.h @@ -1,85 +1,31 @@ -#ifndef physvolHandler_H -#define physvolHandler_H - -#include "GeoModelXMLParser/XercesParser.h" +#pragma once #include "GDMLInterface/GDMLHandler.h" -#include "GDMLInterface/GDMLController.h" -#include "GDMLInterface/volumerefHandler.h" -#include "GDMLInterface/positionHandler.h" -#include "GDMLInterface/rotationHandler.h" - -#include "GeoModelKernel/GeoPhysVol.h" -#include "GeoModelKernel/GeoDefinitions.h" -#include "GeoModelKernel/GeoTransform.h" -class physvolHandler:public GDMLHandler { -public: +class GDMLController; - physvolHandler(std::string n, GDMLController* c): GDMLHandler(n,c) {} - void ElementHandle() { - thePhysicalVolume=0; - - name=getAttributeAsString("name"); - //std::cout<<" this is physvolHandler: name "<<name<<std::endl; +#include <string> +#include <vector> - StopLoop(true); - xercesc::DOMNode *child; - - //GeoTrf::TransformRT pVTransform=GeoTrf::Transform3D::Identity(); - GeoTrf::Transform3D pVRotation=GeoTrf::Transform3D::Identity(); - GeoTrf::Vector3D pVTranslation=GeoTrf::Vector3D(0,0,0); +class GeoPhysVol; +class GeoTransform; - for (child=XercesParser::GetCurrentElement()->getFirstChild();child!=0;child=child->getNextSibling()) - { - if (child->getNodeType()==xercesc::DOMNode::ELEMENT_NODE) { - XercesParser::elementLoop(child); - XMLHandler *h=theController->XMLStore()->GetHandler(child); - if(h){ - std::string nH=h->GetName(); - //std::cout<<" handler name "<<nH<<std::endl; - if (nH=="volumeref") { - volumerefHandler* vH=dynamic_cast<volumerefHandler*>(h); - if (!vH) std::cout<<" something is wrong! can not retrieve volumerefHandler!!!"<<std::endl; - else thePhysicalVolume=(vH->getVolume()).second; - } - else if (nH=="positionref" || nH=="position") { - positionHandler* pH=dynamic_cast<positionHandler*>(h); - if (!pH) std::cout<<" something is wrong! can not retrieve positionHandler!!!"<<std::endl; - else { - pVTranslation=pH->getPosition().v3d; - } - - } - else if (nH=="rotationref" || nH=="rotation" ) { - rotationHandler* rH=dynamic_cast<rotationHandler*>(h); - if (!rH) std::cout<<" something is wrong! can not retrieve rotationHandler!!!"<<std::endl; - else { - rotation r=rH->getRotation(); - pVRotation=GeoTrf::RotateX3D(-r.rotx)*GeoTrf::RotateY3D(-r.roty)*GeoTrf::RotateZ3D(-r.rotz); - } - } - else std::cout<<" Name of the handler not defined "<<nH<<std::endl; - } - else std::cout<<"WARNING: handler not defined.. continuing"<<std::endl; - - } - - } - trf=new GeoTransform(GeoTrf::Translate3D(pVTranslation.x(),pVTranslation.y(),pVTranslation.z())*pVRotation); +class replicaHandler:public GDMLHandler { +public: - } - GeoPhysVol* getPhysicalVolume() {return thePhysicalVolume;} - GeoTransform* getTransform() {return trf;} - void postLoopHandling() - { - } + replicaHandler(std::string n, GDMLController* c); + void ElementHandle(); + GeoPhysVol* getPhysicalVolume(int); + GeoTransform* getTransform(int); + int getNCopies(); + void postLoopHandling(); private: std::string name; - GeoPhysVol* thePhysicalVolume=0; - GeoTransform* trf=0; + int nCopies=0; + std::vector<GeoPhysVol*> thePhysicalVolumes; + std::vector<GeoTransform*> transforms; }; -#endif /* end of include guard: */ +/* end of include guard: */ diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/replicate_axisHandler.h b/GeoModelTools/GDMLtoGM/GDMLInterface/replicate_axisHandler.h new file mode 100644 index 0000000000000000000000000000000000000000..ebd06f6e6f68ca379258bb1e42a4765eae322a9a --- /dev/null +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/replicate_axisHandler.h @@ -0,0 +1,24 @@ + +#ifndef replicate_axisHandler_H +#define replicate_axisHandler_H + +#include "GDMLInterface/GDMLHandler.h" + +#include <string> + +class GDMLHandler; +class GeoPhysVol; +class GeoTransform; + +class replicate_axisHandler:public GDMLHandler { +public: + + replicate_axisHandler(std::string n, GDMLController* c); + void ElementHandle(); + +private: + +}; + + +#endif /* end of include guard: */ diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/solidsHandler.h b/GeoModelTools/GDMLtoGM/GDMLInterface/solidsHandler.h index 253d139a17eb55abcf35035daeceedf54330326c..67a3961546ef2f4edd85aefd15cd2e424e0da7c8 100644 --- a/GeoModelTools/GDMLtoGM/GDMLInterface/solidsHandler.h +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/solidsHandler.h @@ -3,15 +3,17 @@ #define solidsHandler_H #include "GDMLInterface/GDMLHandler.h" -#include "GDMLInterface/GDMLController.h" + + #include <string> -#include <iostream> + +class GDMLController; class solidsHandler:public GDMLHandler { public: - solidsHandler(std::string n, GDMLController* c):GDMLHandler(n,c) {} - void ElementHandle() {;} - void postLoopHandling() {;} + solidsHandler(std::string n, GDMLController* c); + void ElementHandle(); + void postLoopHandling(); }; diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/widthHandler.h b/GeoModelTools/GDMLtoGM/GDMLInterface/widthHandler.h new file mode 100644 index 0000000000000000000000000000000000000000..6b6885939eaaccacbefb6aac56005f0c2f926354 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/widthHandler.h @@ -0,0 +1,24 @@ + +#ifndef widthHandler_H +#define widthHandler_H + +// + +#include "GDMLInterface/GDMLHandler.h" +#include "GDMLInterface/GDMLController.h" +#include <string> +#include <iostream> + +class widthHandler:public GDMLHandler { +public: + widthHandler(std::string n, GDMLController* c); + void ElementHandle(); + double getWidth(); +private: + double unit; + double value; + double width; +}; + + +#endif /* end of include guard: */ diff --git a/GeoModelTools/GDMLtoGM/src/GDMLController.cxx b/GeoModelTools/GDMLtoGM/src/GDMLController.cxx index bfcc90c5388d7c73b7637298a9acc86a934f2a17..51a41512fdc46bd4037adb0887d1fab8dc5295a8 100644 --- a/GeoModelTools/GDMLtoGM/src/GDMLController.cxx +++ b/GeoModelTools/GDMLtoGM/src/GDMLController.cxx @@ -200,8 +200,6 @@ GeoVolume GDMLController::retrieveLogicalVolume(std::string name) } #include "GDMLInterface/defineHandler.h" -#include "GDMLInterface/boxHandler.h" -#include "GDMLInterface/tubeHandler.h" #include "GDMLInterface/topTreeHandler.h" #include "GDMLInterface/materialsHandler.h" #include "GDMLInterface/solidsHandler.h" @@ -224,35 +222,13 @@ GeoVolume GDMLController::retrieveLogicalVolume(std::string name) #include "GDMLInterface/setupHandler.h" #include "GDMLInterface/worldHandler.h" #include "GDMLInterface/physvolHandler.h" -#include "GDMLInterface/coneHandler.h" -#include "GDMLInterface/eltubeHandler.h" -#include "GDMLInterface/paraHandler.h" -#include "GDMLInterface/torusHandler.h" -#include "GDMLInterface/trdHandler.h" -#include "GDMLInterface/polyconeHandler.h" -#include "GDMLInterface/polyhedraHandler.h" -#include "GDMLInterface/zplaneHandler.h" -#include "GDMLInterface/unionHandler.h" -#include "GDMLInterface/subtractionHandler.h" -#include "GDMLInterface/intersectionHandler.h" -#include "GDMLInterface/booleanHandler.h" -#include "GDMLInterface/trapHandler.h" -#include "GDMLInterface/twistedTrapHandler.h" -#include "GDMLInterface/tessellatedHandler.h" -#include "GDMLInterface/triangularHandler.h" -#include "GDMLInterface/quadrangularHandler.h" -#include "GDMLInterface/xtruHandler.h" -#include "GDMLInterface/arb8Handler.h" -#include "GDMLInterface/sectionHandler.h" -#include "GDMLInterface/twoDimVertexHandler.h" -#include "GDMLInterface/unidentifiedShapeHandler.h" + void GDMLController::registerHandlers() { //std::cout << "This is GDMLController::registerHandlers()" << std::endl; new defineHandler("define",this); - new boxHandler("box",this); - new tubeHandler("tube",this); + new topTreeHandler("gdml",this); new materialsHandler("materials",this); new solidsHandler("solids",this); @@ -280,27 +256,5 @@ void GDMLController::registerHandlers() new physvolHandler("physvol",this); new setupHandler("setup",this); new worldHandler("world",this); - new coneHandler("cone",this); - new eltubeHandler("eltube",this); - new paraHandler("para",this); - new torusHandler("torus",this); - new trdHandler("trd",this); - new polyconeHandler("polycone",this); - new polyhedraHandler("polyhedra",this); - new zplaneHandler("zplane",this); - new booleanHandler("first",this); - new booleanHandler("second",this); - new unionHandler("union",this); - new subtractionHandler("subtraction",this); - new intersectionHandler("intersection",this); - new trapHandler("trap",this); - new twistedTrapHandler("twistedtrap",this); - new tessellatedHandler("tessellated",this); - new triangularHandler("triangular",this); - new quadrangularHandler("quadrangular",this); - new xtruHandler("xtru",this); - new arb8Handler("arb8",this); - new twoDimVertexHandler("twoDimVertex",this); - new sectionHandler("section",this); - new unidentifiedShapeHandler("cutTube",this); + } diff --git a/GeoModelTools/GDMLtoGM/src/directionHandler.cxx b/GeoModelTools/GDMLtoGM/src/directionHandler.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4be21588da6b70fd527a446d36c7bcf5436d9c52 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/src/directionHandler.cxx @@ -0,0 +1,18 @@ +#include "GDMLInterface/directionHandler.h" +#include "GDMLInterface/Axis.h" + +directionHandler::directionHandler(std::string n, GDMLController* c): GDMLHandler(n,c) +{ +} +void directionHandler::ElementHandle() +{ + int value=0; + if ((value=getAttributeAsDouble("phi",0))) axis=PHI_axis; + else if ((value=getAttributeAsDouble("x",0))) axis=X_axis; + else if ((value=getAttributeAsDouble("y",0))) axis=Y_axis; + else if ((value=getAttributeAsDouble("z",0))) axis=Z_axis; +} +Axis directionHandler::getAxis() +{ + return axis; +} diff --git a/GeoModelTools/GDMLtoGM/src/offsetHandler.cxx b/GeoModelTools/GDMLtoGM/src/offsetHandler.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2f6269d4106d602e2f8dd73c08e3040c22920623 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/src/offsetHandler.cxx @@ -0,0 +1,18 @@ +#include "GDMLInterface/offsetHandler.h" +#include "GeoModelKernel/Units.h" + +offsetHandler::offsetHandler(std::string n, GDMLController* c): GDMLHandler(n,c) +{ +} +void offsetHandler::ElementHandle() +{ + unit=value=offset=0; + unit=getAttributeAsDouble("unit",GeoModelKernelUnits::g/GeoModelKernelUnits::mole); + value=getAttributeAsDouble("value"); + offset=unit*value; + // std::cout<<" this is offsetHandler: offset= "<<offset<<std::endl; +} +double offsetHandler::getOffset() +{ + return offset; +} diff --git a/GeoModelTools/GDMLtoGM/src/replicaHandler.cxx b/GeoModelTools/GDMLtoGM/src/replicaHandler.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ae1456d7fa66c3c07efee35032a38e32ddd5d128 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/src/replicaHandler.cxx @@ -0,0 +1,41 @@ +#include "GDMLInterface/replicaHandler.h" + +#include "GDMLInterface/GDMLController.h" + +#include "GDMLInterface/volumerefHandler.h" +#include "GDMLInterface/positionHandler.h" +#include "GDMLInterface/rotationHandler.h" + +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoDefinitions.h" +#include "GeoModelKernel/GeoTransform.h" + +#include "GDMLInterface/replicate_axisHandler.h" + +replicaHandler::replicaHandler(std::string n, GDMLController* c): GDMLHandler(n,c) +{ + new replicate_axisHandler("replicate_along_axis",c); +} +void replicaHandler::ElementHandle() +{ + std::cout<<"this is replicaHandler::ElementHandle() "<<std::endl; + nCopies=getAttributeAsInt("number"); + + + +} +GeoPhysVol* replicaHandler::getPhysicalVolume(int i) +{ + return thePhysicalVolumes[i]; +} +GeoTransform* replicaHandler::getTransform(int i) +{ + return transforms[i]; +} +void replicaHandler::postLoopHandling() +{ +} +int replicaHandler::getNCopies() +{ + return nCopies; +} diff --git a/GeoModelTools/GDMLtoGM/src/replicate_axis.cxx b/GeoModelTools/GDMLtoGM/src/replicate_axis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..96735ab0b63123f2be2812745fbac11e7f1e06e4 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/src/replicate_axis.cxx @@ -0,0 +1,65 @@ +#include "GDMLInterface/replicate_axisHandler.h" + +#include "GeoModelXMLParser/XercesParser.h" + +#include "GDMLInterface/GDMLHandler.h" +#include "GDMLInterface/GDMLController.h" +#include "GDMLInterface/directionHandler.h" +#include "GDMLInterface/widthHandler.h" +#include "GDMLInterface/offsetHandler.h" + +replicate_axisHandler::replicate_axisHandler(std::string n, GDMLController* c): GDMLHandler(n,c) +{ + new widthHandler("width",c); + new offsetHandler("offset",c); + new directionHandler("direction",c); +} +void replicate_axisHandler::ElementHandle() { + //std::cout<<" this is replicate_axisHandler"<<std::endl; + + StopLoop(true); + xercesc::DOMNode *child; + + for (child=XercesParser::GetCurrentElement()->getFirstChild();child!=0;child=child->getNextSibling()) + { + if (child->getNodeType()==xercesc::DOMNode::ELEMENT_NODE) + { + XercesParser::elementLoop(child); + XMLHandler *h=theController->XMLStore()->GetHandler(child); + if(h){ + std::string nH=h->GetName(); + //std::cout<<" handler name "<<nH<<std::endl; + if (nH=="direction") { + directionHandler* dH=dynamic_cast<directionHandler*>(h); + if (!dH) std::cout<<" something is wrong! can not retrieve directionHandler!!!"<<std::endl; + else ; + } + else if (nH=="width") + { + widthHandler* wH=dynamic_cast<widthHandler*>(h); + if (!wH) std::cout<<" something is wrong! can not retrieve widthHandler!!!"<<std::endl; + else + { + ; + } + + } + else if (nH=="offset") + { + offsetHandler* oH=dynamic_cast<offsetHandler*>(h); + if (!oH) std::cout<<" something is wrong! can not retrieve offsetHandler!!!"<<std::endl; + else + { + ; + } + } + else std::cout<<" Name of the handler not defined "<<nH<<std::endl; + } + else std::cout<<"WARNING: handler not defined.. continuing"<<std::endl; + + } + + } + +} + diff --git a/GeoModelTools/GDMLtoGM/src/solidsHandler.cxx b/GeoModelTools/GDMLtoGM/src/solidsHandler.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5c7ab16bc89734492993d84bb5cf25d6f47b9f30 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/src/solidsHandler.cxx @@ -0,0 +1,63 @@ +#include "GDMLInterface/solidsHandler.h" +#include "GDMLInterface/GDMLController.h" + +// handlers being created here +#include "GDMLInterface/boxHandler.h" +#include "GDMLInterface/tubeHandler.h" +#include "GDMLInterface/coneHandler.h" +#include "GDMLInterface/eltubeHandler.h" +#include "GDMLInterface/paraHandler.h" +#include "GDMLInterface/torusHandler.h" +#include "GDMLInterface/trdHandler.h" +#include "GDMLInterface/polyconeHandler.h" +#include "GDMLInterface/polyhedraHandler.h" +#include "GDMLInterface/zplaneHandler.h" +#include "GDMLInterface/unionHandler.h" +#include "GDMLInterface/subtractionHandler.h" +#include "GDMLInterface/intersectionHandler.h" +#include "GDMLInterface/booleanHandler.h" +#include "GDMLInterface/trapHandler.h" +#include "GDMLInterface/twistedTrapHandler.h" +#include "GDMLInterface/tessellatedHandler.h" +#include "GDMLInterface/triangularHandler.h" +#include "GDMLInterface/quadrangularHandler.h" +#include "GDMLInterface/xtruHandler.h" +#include "GDMLInterface/arb8Handler.h" +#include "GDMLInterface/sectionHandler.h" +#include "GDMLInterface/twoDimVertexHandler.h" +#include "GDMLInterface/unidentifiedShapeHandler.h" + +solidsHandler::solidsHandler(std::string n, GDMLController* c):GDMLHandler(n,c) +{ + new boxHandler("box",c); + new tubeHandler("tube",c); + new coneHandler("cone",c); + new eltubeHandler("eltube",c); + new paraHandler("para",c); + new torusHandler("torus",c); + new trdHandler("trd",c); + new polyconeHandler("polycone",c); + new polyhedraHandler("polyhedra",c); + new zplaneHandler("zplane",c); + new booleanHandler("first",c); + new booleanHandler("second",c); + new unionHandler("union",c); + new subtractionHandler("subtraction",c); + new intersectionHandler("intersection",c); + new trapHandler("trap",c); + new twistedTrapHandler("twistedtrap",c); + new tessellatedHandler("tessellated",c); + new triangularHandler("triangular",c); + new quadrangularHandler("quadrangular",c); + new xtruHandler("xtru",c); + new arb8Handler("arb8",c); + new twoDimVertexHandler("twoDimVertex",c); + new sectionHandler("section",c); + new unidentifiedShapeHandler("cutTube",c); +} +void solidsHandler::ElementHandle() +{ +} +void solidsHandler::postLoopHandling() +{ +} diff --git a/GeoModelTools/GDMLtoGM/src/volumeHandler.cxx b/GeoModelTools/GDMLtoGM/src/volumeHandler.cxx index d495b5a8b46ef5ac5fa3ebd3cc9b84f35e49ab96..2166169b04ac3d304768754ef0ff5d0deddf73b8 100644 --- a/GeoModelTools/GDMLtoGM/src/volumeHandler.cxx +++ b/GeoModelTools/GDMLtoGM/src/volumeHandler.cxx @@ -2,10 +2,14 @@ #include "GeoModelXMLParser/XercesParser.h" +#include "GDMLInterface/replicaHandler.h" + #include "GeoModelKernel/GeoTransform.h" + volumeHandler::volumeHandler(std::string n, GDMLController* c): GDMLHandler(n,c) { + new replicaHandler("replicavol",c); } void volumeHandler::ElementHandle() @@ -27,32 +31,40 @@ void volumeHandler::ElementHandle() if (child->getNodeType()==xercesc::DOMNode::ELEMENT_NODE) { XercesParser::elementLoop(child); XMLHandler *h=theController->XMLStore()->GetHandler(child); - if (h){ - std::string nH=h->GetName(); - //std::cout<<" handler name "<<nH<<std::endl; - if (nH=="materialref") { - materialrefHandler* mH=dynamic_cast<materialrefHandler*>(h); - if (!mH) std::cout<<" something is wrong! can not retrieve materialrefHandler!!!"<<std::endl; - else material=mH->getMaterial(); - } - else if (nH=="solidref") { - solidrefHandler* sH=dynamic_cast<solidrefHandler*>(h); - if (!sH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl; - else shape=sH->getSolid(); - } - else if (nH=="physvol") { - physvolHandler* pH=dynamic_cast<physvolHandler*>(h); - if (!pH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl; - else - { - tempPhys.push_back(pH->getPhysicalVolume()); - tempTransform.push_back(pH->getTransform()); - } - } - else std::cout<<" handler name not defined "<<nH<<std::endl; - } + if (h){ + std::string nH=h->GetName(); + //std::cout<<" handler name "<<nH<<std::endl; + if (nH=="materialref") { + materialrefHandler* mH=dynamic_cast<materialrefHandler*>(h); + if (!mH) std::cout<<" something is wrong! can not retrieve materialrefHandler!!!"<<std::endl; + else material=mH->getMaterial(); + } + else if (nH=="solidref") { + solidrefHandler* sH=dynamic_cast<solidrefHandler*>(h); + if (!sH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl; + else shape=sH->getSolid(); + } + else if (nH=="physvol") { + physvolHandler* pH=dynamic_cast<physvolHandler*>(h); + if (!pH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl; + else + { + tempPhys.push_back(pH->getPhysicalVolume()); + tempTransform.push_back(pH->getTransform()); + } + } + else if (nH=="replicavol") { + replicaHandler* rH=dynamic_cast<replicaHandler*>(h); + if (!rH) std::cout<<" something is wrong! can not retrieve replicaHandler!!!"<<std::endl; + else + { + std::cout<<" from replicaHandler: nCopies="<<rH->getNCopies()<<std::endl; + } + } + else std::cout<<" handler name not defined "<<nH<<std::endl; + } - } //else std::cout<<"WARNING: handler not defined.. continuing"<<std::endl; + } //else std::cout<<"WARNING: handler not defined.. continuing"<<std::endl; } //std::cout << "Creating logical volume "<<name<<" shape "<<shape<<" mat "<<material<<std::endl; GeoLogVol* tempLV=new GeoLogVol(name,shape,material); diff --git a/GeoModelTools/GDMLtoGM/src/widthHandler.cxx b/GeoModelTools/GDMLtoGM/src/widthHandler.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8508c539edd4292b4771520640cb55b18c611b10 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/src/widthHandler.cxx @@ -0,0 +1,18 @@ +#include "GDMLInterface/widthHandler.h" +#include "GeoModelKernel/Units.h" + +widthHandler::widthHandler(std::string n, GDMLController* c): GDMLHandler(n,c) +{ +} +void widthHandler::ElementHandle() +{ + unit=value=width=0; + unit=getAttributeAsDouble("unit",GeoModelKernelUnits::g/GeoModelKernelUnits::mole); + value=getAttributeAsDouble("value"); + width=unit*value; + // std::cout<<" this is widthHandler: width= "<<width<<std::endl; +} +double widthHandler::getWidth() +{ + return width; +}