ATLAS Offline Software
CLHEPtoEigenConverter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
20 #ifndef CLHEPTOEIGENCONVERTER_H_
21 #define CLHEPTOEIGENCONVERTER_H_
22 
24 
25 #include "CLHEP/Geometry/Transform3D.h"
26 #include "CLHEP/Geometry/Point3D.h"
27 #include "CLHEP/Vector/Rotation.h"
28 #include "CLHEP/Vector/ThreeVector.h"
29 
30 namespace Amg {
31 
39  const HepGeom::Transform3D& CLHEPtransf) {
41  //loop unrolled for performance
42  t(0, 0) = CLHEPtransf(0, 0);
43  t(0, 1) = CLHEPtransf(0, 1);
44  t(0, 2) = CLHEPtransf(0, 2);
45  t(1, 0) = CLHEPtransf(1, 0);
46  t(1, 1) = CLHEPtransf(1, 1);
47  t(1, 2) = CLHEPtransf(1, 2);
48  t(2, 0) = CLHEPtransf(2, 0);
49  t(2, 1) = CLHEPtransf(2, 1);
50  t(2, 2) = CLHEPtransf(2, 2);
51  t(0, 3) = CLHEPtransf(0, 3);
52  t(1, 3) = CLHEPtransf(1, 3);
53  t(2, 3) = CLHEPtransf(2, 3);
54  return t;
55  }
56 
64  const CLHEP::HepRotation& CLHEProtation) {
66 
67  t(0, 0) = CLHEProtation(0, 0);
68  t(0, 1) = CLHEProtation(0, 1);
69  t(0, 2) = CLHEProtation(0, 2);
70  t(1, 0) = CLHEProtation(1, 0);
71  t(1, 1) = CLHEProtation(1, 1);
72  t(1, 2) = CLHEProtation(1, 2);
73  t(2, 0) = CLHEProtation(2, 0);
74  t(2, 1) = CLHEProtation(2, 1);
75  t(2, 2) = CLHEProtation(2, 2);
76  return t;
77  }
78 
86  const CLHEP::Hep3Vector& CLHEPtranslation) {
87  return Amg::Translation3D(
88  Vector3D(CLHEPtranslation[0], CLHEPtranslation[1],
89  CLHEPtranslation[2]));
90  }
91 
92 
100  const HepGeom::Translate3D& CLHEPtranslate3D)
101  {
102  // from: http://proj-clhep.web.cern.ch/proj-clhep/doc/CLHEP_2_0_4_7/doxygen/html/classHepGeom_1_1Translate3D.html#f2df65781931c7df9cc2858de2c89151
103  //Amg::Transform3D(1, 0, 0, CLHEPtranslate3D[0],
104  // 0, 1, 0, CLHEPtranslate3D[1],
105  // 0, 0, 1, CLHEPtranslate3D[2]);
107  t.setIdentity();
108  t(0, 3) = CLHEPtranslate3D(0, 3);
109  t(1, 3) = CLHEPtranslate3D(1, 3);
110  t(2, 3) = CLHEPtranslate3D(2, 3);
111  return t;
112  }
113 
121  const Amg::Transform3D& eigenTransf) {
122  CLHEP::HepRotation rotation(
123  CLHEP::Hep3Vector(eigenTransf(0, 0), eigenTransf(1, 0), eigenTransf(2, 0)),
124  CLHEP::Hep3Vector(eigenTransf(0, 1), eigenTransf(1, 1), eigenTransf(2, 1)),
125  CLHEP::Hep3Vector(eigenTransf(0, 2), eigenTransf(1, 2), eigenTransf(2, 2)));
126  CLHEP::Hep3Vector translation(eigenTransf(0, 3), eigenTransf(1, 3), eigenTransf(2, 3));
127  HepGeom::Transform3D t(rotation, translation);
128  return t;
129  }
130 
137  inline Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector& CLHEPvector) {
138  return Amg::Vector3D(CLHEPvector[0], CLHEPvector[1], CLHEPvector[2]);
139  }
140 
147  inline CLHEP::Hep3Vector EigenToHep3Vector(const Amg::Vector3D& eigenvector) {
148  return CLHEP::Hep3Vector(eigenvector[0], eigenvector[1], eigenvector[2]);
149  }
150 }
151 
152 #endif
Amg::EigenToHep3Vector
CLHEP::Hep3Vector EigenToHep3Vector(const Amg::Vector3D &eigenvector)
Converts an Eigen-based Amg::Vector3D into a CLHEP-based CLHEP::Hep3Vector.
Definition: CLHEPtoEigenConverter.h:147
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Amg::CLHEPTranslationToEigen
Amg::Translation3D CLHEPTranslationToEigen(const CLHEP::Hep3Vector &CLHEPtranslation)
Converts a CLHEP::Hep3Vector into an Eigen-based Amg::Translation3D.
Definition: CLHEPtoEigenConverter.h:85
Amg::Hep3VectorToEigen
Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector &CLHEPvector)
Converts a CLHEP-based CLHEP::Hep3Vector into an Eigen-based Amg::Vector3D.
Definition: CLHEPtoEigenConverter.h:137
GeoPrimitives.h
xAOD::rotation
rotation
Definition: TrackSurface_v1.cxx:15
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Amg::CLHEPRotationToEigen
RotationMatrix3D CLHEPRotationToEigen(const CLHEP::HepRotation &CLHEProtation)
Converts a CLHEP::HepRotation into an Eigen-based Amg::RotationMatrix3D.
Definition: CLHEPtoEigenConverter.h:63
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Amg::CLHEPTranslate3DToEigen
Amg::Transform3D CLHEPTranslate3DToEigen(const HepGeom::Translate3D &CLHEPtranslate3D)
Converts a CLHEP-based HepGeom::Translate3 into an Eigen-based Amg::Transform3D.
Definition: CLHEPtoEigenConverter.h:99
Amg::CLHEPTransformToEigen
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Definition: CLHEPtoEigenConverter.h:38
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
Amg::EigenTransformToCLHEP
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Definition: CLHEPtoEigenConverter.h:120