00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef CLHEPTOEIGENCONVERTER_H_
00011 #define CLHEPTOEIGENCONVERTER_H_
00012
00013
00014 #ifdef XAOD_STANDALONE
00015 #error "This header is not meant to be used in standalone mode"
00016 #endif // XAOD_STANDALONE
00017
00018 #include "GeoPrimitives/GeoPrimitives.h"
00019 #include "CLHEP/Geometry/Transform3D.h"
00020 #include "CLHEP/Geometry/Point3D.h"
00021 #include "CLHEP/Vector/Rotation.h"
00022 #include "CLHEP/Vector/ThreeVector.h"
00023
00024 namespace Amg {
00025
00026 inline Amg::Transform3D CLHEPTransformToEigen(
00027 const HepGeom::Transform3D& CLHEPtransf) {
00028 Amg::Transform3D t = Amg::Transform3D();
00029
00030 t(0, 0) = CLHEPtransf(0, 0);
00031 t(0, 1) = CLHEPtransf(0, 1);
00032 t(0, 2) = CLHEPtransf(0, 2);
00033 t(1, 0) = CLHEPtransf(1, 0);
00034 t(1, 1) = CLHEPtransf(1, 1);
00035 t(1, 2) = CLHEPtransf(1, 2);
00036 t(2, 0) = CLHEPtransf(2, 0);
00037 t(2, 1) = CLHEPtransf(2, 1);
00038 t(2, 2) = CLHEPtransf(2, 2);
00039 t(0, 3) = CLHEPtransf(0, 3);
00040 t(1, 3) = CLHEPtransf(1, 3);
00041 t(2, 3) = CLHEPtransf(2, 3);
00042 return t;
00043 }
00044
00045 inline RotationMatrix3D CLHEPRotationToEigen(
00046 const CLHEP::HepRotation& CLHEProtation) {
00047 Amg::RotationMatrix3D t;
00048
00049 t(0, 0) = CLHEProtation(0, 0);
00050 t(0, 1) = CLHEProtation(0, 1);
00051 t(0, 2) = CLHEProtation(0, 2);
00052 t(1, 0) = CLHEProtation(1, 0);
00053 t(1, 1) = CLHEProtation(1, 1);
00054 t(1, 2) = CLHEProtation(1, 2);
00055 t(2, 0) = CLHEProtation(2, 0);
00056 t(2, 1) = CLHEProtation(2, 1);
00057 t(2, 2) = CLHEProtation(2, 2);
00058 return t;
00059 }
00060 inline Translation3D CLHEPTranslationToEigen(
00061 const CLHEP::Hep3Vector& CLHEPtranslation) {
00062 return Translation3D(
00063 Vector3D(CLHEPtranslation[0], CLHEPtranslation[1],
00064 CLHEPtranslation[2]));
00065 }
00066
00067
00068
00069
00070
00071
00072 inline Amg::Transform3D CLHEPTranslate3DToEigen(
00073 const HepGeom::Translate3D& CLHEPtranslate3D)
00074 {
00075 Amg::Transform3D t = Amg::Transform3D();
00076 t.setIdentity();
00077 t(0, 3) = CLHEPtranslate3D(0, 3);
00078 t(1, 3) = CLHEPtranslate3D(1, 3);
00079 t(2, 3) = CLHEPtranslate3D(2, 3);
00080 return t;
00081 }
00082
00083 inline HepGeom::Transform3D EigenTransformToCLHEP(
00084 const Amg::Transform3D& eigenTransf) {
00085 CLHEP::HepRotation rotation(
00086 CLHEP::Hep3Vector(eigenTransf(0, 0), eigenTransf(1, 0), eigenTransf(2, 0)),
00087 CLHEP::Hep3Vector(eigenTransf(0, 1), eigenTransf(1, 1), eigenTransf(2, 1)),
00088 CLHEP::Hep3Vector(eigenTransf(0, 2), eigenTransf(1, 2), eigenTransf(2, 2)));
00089 CLHEP::Hep3Vector translation(eigenTransf(0, 3), eigenTransf(1, 3), eigenTransf(2, 3));
00090 HepGeom::Transform3D t(rotation, translation);
00091 return t;
00092 }
00093
00094 inline Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector& CLHEPvector) {
00095 return Vector3D(CLHEPvector[0], CLHEPvector[1], CLHEPvector[2]);
00096 }
00097
00098 inline CLHEP::Hep3Vector EigenToHep3Vector(const Amg::Vector3D& eigenvector) {
00099 return CLHEP::Hep3Vector(eigenvector[0], eigenvector[1], eigenvector[2]);
00100 }
00101 }
00102
00103 #endif