diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/constantHandler.h b/GeoModelTools/GDMLtoGM/GDMLInterface/constantHandler.h new file mode 100644 index 0000000000000000000000000000000000000000..c7bcd09a1a2a2d172d4a98692078433eb3628e08 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/constantHandler.h @@ -0,0 +1,17 @@ + +#ifndef constantHandler_H +#define constantHandler_H + +#include "GDMLInterface/GDMLHandler.h" +#include "GDMLInterface/GDMLController.h" +#include <string> + +class constantHandler:public GDMLHandler { +public: + constantHandler(std::string, GDMLController*); + void ElementHandle(); + +}; + + +#endif /* end of include guard: */ diff --git a/GeoModelTools/GDMLtoGM/GDMLInterface/variableHandler.h b/GeoModelTools/GDMLtoGM/GDMLInterface/variableHandler.h new file mode 100644 index 0000000000000000000000000000000000000000..c75e1a787ab41e580e92ec3cf34822599b8b1f47 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/GDMLInterface/variableHandler.h @@ -0,0 +1,17 @@ + +#ifndef variableHandler_H +#define variableHandler_H + +#include "GDMLInterface/GDMLHandler.h" +#include "GDMLInterface/GDMLController.h" +#include <string> + +class variableHandler:public GDMLHandler { +public: + variableHandler(std::string, GDMLController*); + void ElementHandle(); + +}; + + +#endif /* end of include guard: */ diff --git a/GeoModelTools/GDMLtoGM/src/GDMLController.cxx b/GeoModelTools/GDMLtoGM/src/GDMLController.cxx index 3a8f7048159b8ce469997f2347cf2a0396b1db60..4e010014f8cde7878860ded99cca8cb1163fa194 100644 --- a/GeoModelTools/GDMLtoGM/src/GDMLController.cxx +++ b/GeoModelTools/GDMLtoGM/src/GDMLController.cxx @@ -246,6 +246,8 @@ GeoVolume GDMLController::retrieveLogicalVolume(std::string name) #include "GDMLInterface/setupHandler.h" #include "GDMLInterface/worldHandler.h" #include "GDMLInterface/physvolHandler.h" +#include "GDMLInterface/variableHandler.h" +#include "GDMLInterface/constantHandler.h" void GDMLController::registerHandlers() @@ -282,5 +284,7 @@ void GDMLController::registerHandlers() new physvolHandler("physvol",this); new setupHandler("setup",this); new worldHandler("world",this); - + new variableHandler("variable",this); + new constantHandler("constant",this); + new constantHandler("quantity",this); } diff --git a/GeoModelTools/GDMLtoGM/src/constantHandler.cxx b/GeoModelTools/GDMLtoGM/src/constantHandler.cxx new file mode 100644 index 0000000000000000000000000000000000000000..24eca07545a8ee736a2bd7b4c8d2729685540f17 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/src/constantHandler.cxx @@ -0,0 +1,26 @@ +#include "GDMLInterface/constantHandler.h" +#include "GDMLInterface/GDMLHandler.h" +#include <iostream> + + +constantHandler::constantHandler(std::string s,GDMLController* g):GDMLHandler(s,g) +{ + // std::cout<<"constructing constantHandler!"<<std::endl; +} + +void constantHandler::ElementHandle() +{ + std::string name=getAttributeAsString("name"); + double value=getAttributeAsDouble("value"); + + double lunit=1.; + if (this->GetName()=="quantity") + { + bool unitTest=true; + lunit=getAttributeAsDouble("unit",unitTest); + if (!unitTest) + std::cout<<" Warning, <quantity /> tag requires an unit attribute to be defined!!!!"<<std::endl; + std::string type=getAttributeAsString("type","density"); + } + ExpressionEvaluator::GetEvaluator()->RegisterConstant(name,value*lunit); +} diff --git a/GeoModelTools/GDMLtoGM/src/variableHandler.cxx b/GeoModelTools/GDMLtoGM/src/variableHandler.cxx new file mode 100644 index 0000000000000000000000000000000000000000..fa6b2b2132d438e0a9b89bb677494d2e237a44f1 --- /dev/null +++ b/GeoModelTools/GDMLtoGM/src/variableHandler.cxx @@ -0,0 +1,22 @@ +#include "GDMLInterface/variableHandler.h" +#include "GDMLInterface/GDMLHandler.h" +#include <iostream> + + + +variableHandler::variableHandler(std::string s,GDMLController* g):GDMLHandler(s,g) +{ + // std::cout<<"variableHandler!"<<std::endl; +} + +void variableHandler::ElementHandle() +{ + + std::string name=getAttributeAsString("name"); + + //std::cout << "handling for variable: name "<< name <<'\n'; + + double value=getAttributeAsDouble("value"); + + Evaluator()->RegisterVariable(name,value); +}