Skip to content
Snippets Groups Projects
Commit 2349b208 authored by Andrea Dell'Acqua's avatar Andrea Dell'Acqua
Browse files

temporary commit to save changes

parent 77303871
Branches
Tags
No related merge requests found
......@@ -10,7 +10,6 @@ class eltubeHandler:public GDMLHandler {
public:
eltubeHandler(std::string, GDMLController*);
void ElementHandle();
};
......
......@@ -16,14 +16,14 @@ public:
replicaHandler(std::string n, GDMLController* c);
void ElementHandle();
GeoPhysVol* getPhysicalVolume(int);
GeoPhysVol* getPhysicalVolume();
GeoTransform* getTransform(int);
int getNCopies();
void postLoopHandling();
private:
std::string name;
int nCopies=0;
std::vector<GeoPhysVol*> thePhysicalVolumes;
GeoPhysVol* thePhysicalVolume;
std::vector<GeoTransform*> transforms;
};
......
......@@ -3,6 +3,7 @@
#define replicate_axisHandler_H
#include "GDMLInterface/GDMLHandler.h"
#include "GDMLInterface/Axis.h"
#include <string>
......@@ -10,14 +11,19 @@ class GDMLHandler;
class GeoPhysVol;
class GeoTransform;
struct axis_params {double w;double o; Axis a;};
class replicate_axisHandler:public GDMLHandler {
public:
replicate_axisHandler(std::string n, GDMLController* c);
void ElementHandle();
axis_params getAxisParameters() {return parameters;}
private:
axis_params parameters;
};
......
......@@ -23,8 +23,7 @@ void physvolHandler::ElementHandle() {
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);
......@@ -34,43 +33,39 @@ void physvolHandler::ElementHandle() {
{
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")
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" )
{
positionHandler* pH=dynamic_cast<positionHandler*>(h);
if (!pH) std::cout<<" something is wrong! can not retrieve positionHandler!!!"<<std::endl;
else
rotationHandler* rH=dynamic_cast<rotationHandler*>(h);
if (!rH) std::cout<<" something is wrong! can not retrieve rotationHandler!!!"<<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;
}
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);
}
GeoPhysVol* physvolHandler::getPhysicalVolume()
{
......
#include "GDMLInterface/replicaHandler.h"
#include "GeoModelXMLParser/XercesParser.h"
#include "GDMLInterface/GDMLController.h"
#include "GDMLInterface/volumerefHandler.h"
......@@ -11,6 +13,7 @@
#include "GeoModelKernel/GeoTransform.h"
#include "GDMLInterface/replicate_axisHandler.h"
#include "GDMLInterface/Axis.h"
replicaHandler::replicaHandler(std::string n, GDMLController* c): GDMLHandler(n,c)
{
......@@ -18,15 +21,79 @@ replicaHandler::replicaHandler(std::string n, GDMLController* c): GDMLHandler(n,
}
void replicaHandler::ElementHandle()
{
std::cout<<"this is replicaHandler::ElementHandle() "<<std::endl;
nCopies=getAttributeAsInt("number");
std::cout<<"this is replicaHandler::ElementHandle() "<<std::endl;
nCopies=getAttributeAsInt("number");
StopLoop(true);
xercesc::DOMNode *child;
GeoTrf::Transform3D pVRotation=GeoTrf::Transform3D::Identity();
GeoTrf::Vector3D pVTranslation=GeoTrf::Vector3D(0,0,0);
axis_params p;
GeoPhysVol* DaughterPV=0;
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=="replicate_along_axis") {
replicate_axisHandler* rH=dynamic_cast<replicate_axisHandler*>(h);
if (!rH) std::cout<<" something is wrong! can not retrieve replicate_axisHandler!!!"<<std::endl;
else p=rH->getAxisParameters();
}
else if (nH=="volumeref") {
volumerefHandler* vH=dynamic_cast<volumerefHandler*>(h);
if (!vH) std::cout<<" something is wrong! can not retrieve volumerefHandler!!!"<<std::endl;
else DaughterPV=(vH->getVolume()).second;
thePhysicalVolume=DaughterPV;
}
}
}
}
std::cout<< " replicaHandler"<<p.w<<" "<<p.o<<std::endl;
double pStartXYZ,pStartPhi, pCurrent;
GeoTransform *tr;
pStartXYZ=-nCopies*p.w+p.o/2.;
pStartPhi=p.o;
for (int i=0;i<nCopies;i++)
{
switch (p.a)
{
case PHI_axis:
pCurrent=pStartPhi + 2*i*p.w + p.w;
tr=new GeoTransform(GeoTrf::RotateZ3D(pCurrent));
break;
case X_axis:
pCurrent=pStartXYZ+2*i*p.w + p.w;
tr=new GeoTransform(GeoTrf::TranslateX3D(pCurrent));
break;
case Y_axis:
pCurrent=pStartXYZ+2*i*p.w + p.w;
tr=new GeoTransform(GeoTrf::TranslateY3D(pCurrent));
break;
case Z_axis:
pCurrent=pStartXYZ+2*i*p.w + p.w;
tr=new GeoTransform(GeoTrf::TranslateZ3D(pCurrent));
break;
default:
std::cout<< " WARNING - GDMLtoGM::replicaHandle: unknown axis!"<<std::endl;
}
transforms.push_back(tr);
}
}
GeoPhysVol* replicaHandler::getPhysicalVolume(int i)
GeoPhysVol* replicaHandler::getPhysicalVolume()
{
return thePhysicalVolumes[i];
return thePhysicalVolume;
}
GeoTransform* replicaHandler::getTransform(int i)
{
......
......@@ -26,40 +26,38 @@ void replicate_axisHandler::ElementHandle() {
{
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;
}
}
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 parameters.a=dH->getAxis();
}
else if (nH=="width")
{
widthHandler* wH=dynamic_cast<widthHandler*>(h);
if (!wH) std::cout<<" something is wrong! can not retrieve widthHandler!!!"<<std::endl;
else
{
parameters.w=wH->getWidth();
}
}
else if (nH=="offset")
{
offsetHandler* oH=dynamic_cast<offsetHandler*>(h);
if (!oH) std::cout<<" something is wrong! can not retrieve offsetHandler!!!"<<std::endl;
else
{
parameters.o=oH->getOffset();
}
}
else std::cout<<" Name of the handler not defined "<<nH<<std::endl;
}
else std::cout<<"WARNING: handler not defined.. continuing"<<std::endl;
}
}
std::cout << " this is the handle : "<<parameters.w<<" "<<parameters.o<< std::endl;
}
......@@ -44,7 +44,7 @@ void volumeHandler::ElementHandle()
if (!sH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl;
else shape=sH->getSolid();
}
else if (nH=="physvol") {
else if (nH=="physvol") {
physvolHandler* pH=dynamic_cast<physvolHandler*>(h);
if (!pH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl;
else
......@@ -53,18 +53,23 @@ void volumeHandler::ElementHandle()
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 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;
for (int i=0;i<rH->getNCopies();i++)
{
tempPhys.push_back(rH->getPhysicalVolume());
tempTransform.push_back(rH->getTransform(i));
}
}
}
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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment