Commit 7e7fea0e authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'agddHandlers' into 'master'

Use Eigen instead of CLHEP in AGDD handlers (1)

See merge request !35394
parents c9ecb380 e451439b
......@@ -7,14 +7,12 @@
#include "AGDDKernel/AGDDDetectorPositioner.h"
#include "AGDDKernel/AGDDDetector.h"
#include "GeoModelKernel/Units.h"
#include "GaudiKernel/MsgStream.h"
#include "AthenaKernel/getMessageSvc.h"
#include "GeoPrimitives/CLHEPtoEigenConverter.h"
#include <iostream>
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Geometry/Transform3D.h"
chamberPositionerHandler::chamberPositionerHandler(std::string s):XMLHandler(s)
{
}
......@@ -22,14 +20,13 @@ chamberPositionerHandler::chamberPositionerHandler(std::string s):XMLHandler(s)
void chamberPositionerHandler::ElementHandle()
{
std::string volume=getAttributeAsString("volume");
//AGDDVolume* theVol=AGDDVolumeStore::GetVolumeStore()->GetVolume(volume);
AGDDDetector* mCham=(AGDDDetectorStore::GetDetectorStore())->GetDetector(volume);
std::string subType;
if (!mCham)
{
std::cout<<"chamberPositionerHandler: something wrong! returning..."<<std::endl;
MsgStream log(Athena::getMessageSvc(),"chamberPositionerHandler");
log<<MSG::WARNING<<"ElementHandle() - Could not retrieve volume "<<volume<<" from DetectorStore!"<<endmsg;
return;
}
else
......@@ -49,35 +46,27 @@ void chamberPositionerHandler::ElementHandle()
int etaIndex=getAttributeAsInt("etaIndex",0);
double dPhi=360./iWedge;
if (iSectors.size()!= (unsigned int) iWedge) throw;
// std::cout<<" =============>> this is chamberPositionerHandler::ElementHandle() "<<volume<<" "<<subType<<std::endl;
for (int i=0;i<iWedge;i++)
{
if (iSectors[i]=='0') continue;
if (zLayout!="Z_NEGATIVE")
{
double Wedge=dPhi*i+phi0;
CLHEP::Hep3Vector cvec;
CLHEP::HepRotation crot;
GeoTrf::Transform3D crot = GeoTrf::Transform3D::Identity();
if (type=="ENDCAP")
{
// fix to ensure right order of planes
crot.rotateZ(180.*GeoModelKernelUnits::degree);
//
crot.rotateY(90*GeoModelKernelUnits::degree);
crot.rotateZ(Wedge*GeoModelKernelUnits::degree);
crot = crot*GeoTrf::RotateZ3D(Wedge*GeoModelKernelUnits::degree)*GeoTrf::RotateY3D(90*GeoModelKernelUnits::degree)*GeoTrf::RotateZ3D(180.*GeoModelKernelUnits::degree);
}
else
crot.rotateZ(Wedge*GeoModelKernelUnits::degree);
double x=radius*cos(Wedge*GeoModelKernelUnits::degree);
double y=radius*sin(Wedge*GeoModelKernelUnits::degree);
else crot = crot*GeoTrf::RotateZ3D(Wedge*GeoModelKernelUnits::degree);
double x=radius*std::cos(Wedge*GeoModelKernelUnits::degree);
double y=radius*std::sin(Wedge*GeoModelKernelUnits::degree);
double zpos=zPos;
cvec=CLHEP::Hep3Vector(x,y,zpos);
GeoTrf::Vector3D cvec=GeoTrf::Vector3D(x,y,zpos);
AGDDDetectorPositioner *p __attribute__((__unused__));
p=new AGDDDetectorPositioner(volume,crot,cvec);
p=new AGDDDetectorPositioner(volume,Amg::EigenTransformToCLHEP(GeoTrf::Translation3D(cvec)*crot));
p->SensitiveDetector(true);
p->ID.phiIndex=i;
p->ID.sideIndex=1;
......@@ -95,25 +84,19 @@ void chamberPositionerHandler::ElementHandle()
if (zLayout!="Z_POSITIVE")
{
double Wedge=dPhi*i+phi0;
CLHEP::Hep3Vector cvec;
CLHEP::HepRotation crot;
GeoTrf::Transform3D crot = GeoTrf::Transform3D::Identity();
if (type=="ENDCAP")
{
// fix to ensure right order of planes
crot.rotateZ(180.*GeoModelKernelUnits::degree);
//
crot.rotateY(90*GeoModelKernelUnits::degree);
crot.rotateZ(-Wedge*GeoModelKernelUnits::degree);
crot.rotateX(180.*GeoModelKernelUnits::degree);
crot = crot*GeoTrf::RotateX3D(180.*GeoModelKernelUnits::degree)*GeoTrf::RotateZ3D(-Wedge*GeoModelKernelUnits::degree)*GeoTrf::RotateY3D(90*GeoModelKernelUnits::degree)*GeoTrf::RotateZ3D(180.*GeoModelKernelUnits::degree);
}
else
crot.rotateZ(Wedge*GeoModelKernelUnits::degree);
double x=radius*cos(Wedge*GeoModelKernelUnits::degree);
double y=radius*sin(Wedge*GeoModelKernelUnits::degree);
else crot = crot*GeoTrf::RotateZ3D(Wedge*GeoModelKernelUnits::degree);
double x=radius*std::cos(Wedge*GeoModelKernelUnits::degree);
double y=radius*std::sin(Wedge*GeoModelKernelUnits::degree);
double zpos=zPos;
cvec=CLHEP::Hep3Vector(x,y,-zpos);
GeoTrf::Vector3D cvec=GeoTrf::Vector3D(x,y,-zpos);
AGDDDetectorPositioner *p __attribute__((__unused__));
p=new AGDDDetectorPositioner(volume,crot,cvec);
p=new AGDDDetectorPositioner(volume,Amg::EigenTransformToCLHEP(GeoTrf::Translation3D(cvec)*crot));
p->SensitiveDetector(true);
p->ID.phiIndex=i;
p->ID.sideIndex=-1;
......
......@@ -5,14 +5,12 @@
#include "AGDDHandlers/mposPhiHandler.h"
#include "AGDDKernel/AGDDPositioner.h"
#include "GeoModelKernel/Units.h"
#include "GaudiKernel/MsgStream.h"
#include "AthenaKernel/getMessageSvc.h"
#include "GeoPrimitives/CLHEPtoEigenConverter.h"
#include <iostream>
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Vector/TwoVector.h"
#include "CLHEP/Geometry/Transform3D.h"
mposPhiHandler::mposPhiHandler(std::string s):XMLHandler(s),p(0)
{
}
......@@ -33,7 +31,8 @@ void mposPhiHandler::ElementHandle()
dphi=360./icopy;
else
{
std::cout<<"mposPhiHandler: both icopy and dphi are null!! volume "<<volume<<" cannot continue!"<<std::endl;
MsgStream log(Athena::getMessageSvc(),"mposPhiHandler");
log<<MSG::WARNING<<"ElementHandle() - both icopy and dphi are nullptr!! volume "<<volume<<" cannot continue!"<<endmsg;
return;
}
}
......@@ -52,31 +51,27 @@ void mposPhiHandler::ElementHandle()
zpos=vvv[1];
}
CLHEP::Hep3Vector cvec;
CLHEP::HepRotation crot;
GeoTrf::Transform3D crot = GeoTrf::Transform3D::Identity();
vvv=getAttributeAsVector("rot",res);
if (res)
{
crot.rotateX(vvv[0]*GeoModelKernelUnits::degree);
crot.rotateY(vvv[1]*GeoModelKernelUnits::degree);
crot.rotateZ(vvv[2]*GeoModelKernelUnits::degree);
crot = crot*GeoTrf::RotateZ3D(vvv[2]*GeoModelKernelUnits::degree)*GeoTrf::RotateY3D(vvv[1]*GeoModelKernelUnits::degree)*GeoTrf::RotateX3D(vvv[0]*GeoModelKernelUnits::degree);
}
for (int i=0;i<icopy;i++)
{
CLHEP::Hep2Vector position(rad,lateral_displacement);
CLHEP::Hep3Vector cvec;
GeoTrf::Vector2D position(rad,lateral_displacement);
double phi=phi0+dphi*i;
position.rotate(phi*GeoModelKernelUnits::degree);
position = Eigen::Rotation2Dd(phi*GeoModelKernelUnits::degree)*position;
double x=position.x();
double y=position.y();
cvec=CLHEP::Hep3Vector(x,y,zpos);
if (s!="false"&&i>0) crot.rotateZ(dphi*GeoModelKernelUnits::degree);
if (s!="false"&&i==0) crot.rotateZ(phi0*GeoModelKernelUnits::degree);
GeoTrf::Vector3D cvec=GeoTrf::Vector3D(x,y,zpos);
if (s!="false"&&i>0) crot = GeoTrf::RotateZ3D(dphi*GeoModelKernelUnits::degree)*crot;
else if (s!="false"&&i==0) crot = GeoTrf::RotateZ3D(phi0*GeoModelKernelUnits::degree)*crot;
p=new AGDDPositioner(volume,crot,cvec);
p=new AGDDPositioner(volume,Amg::EigenTransformToCLHEP(GeoTrf::Translation3D(cvec)*crot));
}
}
......@@ -5,12 +5,10 @@
#include "AGDDHandlers/mposWedgeHandler.h"
#include "AGDDKernel/AGDDPositioner.h"
#include "GeoModelKernel/Units.h"
#include "GeoPrimitives/CLHEPtoEigenConverter.h"
#include <iostream>
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Geometry/Transform3D.h"
#include <vector>
mposWedgeHandler::mposWedgeHandler(std::string s):XMLHandler(s),p(0)
{
......@@ -22,25 +20,20 @@ void mposWedgeHandler::ElementHandle()
std::string volume=getAttributeAsString("volume",res);
int iWedge=getAttributeAsInt("wedge_number",8);
std::vector<double> iSectors=getAttributeAsVector("sectors",res);
double dWedge=360./iWedge;
CLHEP::Hep3Vector cvec;
CLHEP::HepRotation crot;
double radius=0;
for (int i=0;i<iWedge;i++)
{
double Wedge=dWedge*i;
if ((int)iSectors[i]==0) continue;
CLHEP::Hep3Vector cvec;
CLHEP::HepRotation crot;
crot.rotateZ(Wedge*GeoModelKernelUnits::degree);
double x=radius*cos(Wedge*GeoModelKernelUnits::degree);
double y=radius*sin(Wedge*GeoModelKernelUnits::degree);
GeoTrf::Transform3D crot = GeoTrf::RotateZ3D(Wedge*GeoModelKernelUnits::degree);
double x=radius*std::cos(Wedge*GeoModelKernelUnits::degree);
double y=radius*std::sin(Wedge*GeoModelKernelUnits::degree);
double zpos=0;
cvec=CLHEP::Hep3Vector(x,y,zpos);
GeoTrf::Vector3D cvec=GeoTrf::Vector3D(x,y,zpos);
p=new AGDDPositioner(volume,crot,cvec);
p=new AGDDPositioner(volume,Amg::EigenTransformToCLHEP(GeoTrf::Translation3D(cvec)*crot));
}
}
......@@ -5,12 +5,10 @@
#include "AGDDHandlers/posRPhiZHandler.h"
#include "AGDDKernel/AGDDPositioner.h"
#include "GeoModelKernel/Units.h"
#include "GeoPrimitives/CLHEPtoEigenConverter.h"
#include <iostream>
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Geometry/Transform3D.h"
#include <vector>
posRPhiZHandler::posRPhiZHandler(std::string s):XMLHandler(s),p(0)
{
......@@ -18,32 +16,24 @@ posRPhiZHandler::posRPhiZHandler(std::string s):XMLHandler(s),p(0)
void posRPhiZHandler::ElementHandle()
{
bool res;
bool res=false;
std::string volume=getAttributeAsString("volume",res);
std::vector<double> vvv=getAttributeAsVector("R_Phi_Z",res);
double radius,phi,zpos;
radius=vvv[0];
phi=vvv[1];
zpos=vvv[2];
CLHEP::Hep3Vector cvec;
CLHEP::HepRotation crot;
double radius=vvv[0];
double phi=vvv[1];
double zpos=vvv[2];
GeoTrf::Transform3D crot = GeoTrf::Transform3D::Identity();
vvv=getAttributeAsVector("rot",res);
if (res)
{
crot=CLHEP::HepRotation();
crot.rotateX(vvv[0]*GeoModelKernelUnits::degree);
crot.rotateY(vvv[1]*GeoModelKernelUnits::degree);
crot.rotateZ(vvv[2]*GeoModelKernelUnits::degree);
crot = crot*GeoTrf::RotateZ3D(vvv[2]*GeoModelKernelUnits::degree)*GeoTrf::RotateY3D(vvv[1]*GeoModelKernelUnits::degree)*GeoTrf::RotateX3D(vvv[0]*GeoModelKernelUnits::degree);
}
crot.rotateZ(phi*GeoModelKernelUnits::degree);
double x=radius*cos(phi*GeoModelKernelUnits::degree);
double y=radius*sin(phi*GeoModelKernelUnits::degree);
cvec=CLHEP::Hep3Vector(x,y,zpos);
crot = GeoTrf::RotateZ3D(phi*GeoModelKernelUnits::degree)*crot;
double x=radius*std::cos(phi*GeoModelKernelUnits::degree);
double y=radius*std::sin(phi*GeoModelKernelUnits::degree);
GeoTrf::Vector3D cvec=GeoTrf::Vector3D(x,y,zpos);
p=new AGDDPositioner(volume,crot,cvec);
p=new AGDDPositioner(volume,Amg::EigenTransformToCLHEP(GeoTrf::Translation3D(cvec)*crot));
}
......@@ -45,6 +45,6 @@ void posXYZHandler::ElementHandle()
if (rotRet) std::cout<<" rot= ("<<rot[0]<<";"<<rot[1]<<";"<<rot[2]<<")";
std::cout<<std::endl;
}
AGDDPositioner *p=new AGDDPositioner(volume,crot,cvec);
AGDDPositioner *p=new AGDDPositioner(volume,HepGeom::Transform3D(crot,cvec));
globals::currentPositioner=p;
}
......@@ -42,7 +42,6 @@ struct DetectorPositionParameters {
class AGDDDetectorPositioner:public AGDDPositioner {
public:
AGDDDetectorPositioner(std::string n,HepGeom::Transform3D t);
AGDDDetectorPositioner(std::string n,CLHEP::HepRotation r,CLHEP::Hep3Vector v);
Identifiers ID;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef AGDDPositioner_H
......@@ -8,6 +8,8 @@
#include "CLHEP/Geometry/Transform3D.h"
#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Vector/Rotation.h"
#include "GeoModelKernel/GeoDefinitions.h"
#include <string>
class AGDDVolume;
......@@ -15,7 +17,6 @@ class AGDDVolume;
class AGDDPositioner {
public:
AGDDPositioner(std::string n,HepGeom::Transform3D t);
AGDDPositioner(std::string n,CLHEP::HepRotation r,CLHEP::Hep3Vector v);
virtual ~AGDDPositioner() {;}
std::string Volume();
AGDDVolume *GetVolume();
......
......@@ -13,8 +13,4 @@
AGDDDetectorPositioner::AGDDDetectorPositioner(std::string n,HepGeom::Transform3D t):AGDDPositioner(n,t),theDetector(0),theVolume(0)
{
}
AGDDDetectorPositioner::AGDDDetectorPositioner(std::string n,CLHEP::HepRotation r,CLHEP::Hep3Vector v):AGDDPositioner(n,r,v),theDetector(0),theVolume(0)
{
}
}
\ No newline at end of file
......@@ -16,12 +16,6 @@ AGDDPositioner::AGDDPositioner(std::string n,HepGeom::Transform3D t):m_isSensiti
AGDDPositionerStore::GetPositionerStore()->RegisterPositioner(this);
m_theVolume=AGDDVolumeStore::GetVolumeStore()->GetVolume(Volume());
}
AGDDPositioner::AGDDPositioner(std::string n,CLHEP::HepRotation r,CLHEP::Hep3Vector v):m_isSensitiveDetector(false),m_volume(n)
{
AGDDPositionerStore::GetPositionerStore()->RegisterPositioner(this);
m_transform=HepGeom::Transform3D(r,v);
m_theVolume=AGDDVolumeStore::GetVolumeStore()->GetVolume(Volume());
}
std::string AGDDPositioner::Volume()
{
return m_volume;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment