diff --git a/DDCore/include/DD4hep/MatrixHelpers.h b/DDCore/include/DD4hep/MatrixHelpers.h index 68cf39f242dd76628e033b1fa4241c03ff3849f2..78e801e4b008d0c08188627b189e880ac0d13228 100644 --- a/DDCore/include/DD4hep/MatrixHelpers.h +++ b/DDCore/include/DD4hep/MatrixHelpers.h @@ -63,6 +63,7 @@ namespace dd4hep { /// Convert a TGeoMatrix object to a generic Transform3D \ingroup DD4HEP \ingroup DD4HEP_CORE Transform3D _transform(const TGeoMatrix* matrix); + Transform3D _transform(const TGeoMatrix& matrix); /// Decompose a generic Transform3D into a translation (Position) and a RotationZYX \ingroup DD4HEP \ingroup DD4HEP_CORE void _decompose(const Transform3D& trafo, Position& pos, RotationZYX& rot); diff --git a/DDCore/src/MatrixHelpers.cpp b/DDCore/src/MatrixHelpers.cpp index fb4eabfb7ed10ba6f0b14ea90964673030718182..8b16d136e5a1a5f8122771f40460c8294a412dbb 100644 --- a/DDCore/src/MatrixHelpers.cpp +++ b/DDCore/src/MatrixHelpers.cpp @@ -112,6 +112,19 @@ Transform3D dd4hep::detail::matrix::_transform(const TGeoMatrix* matrix) { 0e0,0e0,0e0,t[1]*MM_2_CM, 0e0,0e0,0e0,t[2]*MM_2_CM); } +// add another implementation that takes const reference +Transform3D dd4hep::detail::matrix::_transform(const TGeoMatrix& matrix) { + const Double_t* t = matrix.GetTranslation(); + if ( matrix.IsRotation() ) { + const Double_t* r = matrix.GetRotationMatrix(); + return Transform3D(r[0],r[1],r[2],t[0]*MM_2_CM, + r[3],r[4],r[5],t[1]*MM_2_CM, + r[6],r[7],r[8],t[2]*MM_2_CM); + } + return Transform3D(0e0,0e0,0e0,t[0]*MM_2_CM, + 0e0,0e0,0e0,t[1]*MM_2_CM, + 0e0,0e0,0e0,t[2]*MM_2_CM); +} dd4hep::XYZAngles dd4hep::detail::matrix::_xyzAngles(const TGeoMatrix* m) { return m->IsRotation() ? _xyzAngles(m->GetRotationMatrix()) : XYZAngles(0,0,0); diff --git a/DDCore/src/plugins/LCDDConverter.cpp b/DDCore/src/plugins/LCDDConverter.cpp index da74cd441e3a6cd3e945f8e1b79add516c11ce2d..df32ff5a772cb6111ec1789d28b3b30de3e32585 100644 --- a/DDCore/src/plugins/LCDDConverter.cpp +++ b/DDCore/src/plugins/LCDDConverter.cpp @@ -549,7 +549,7 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con obj.setAttr(_U(unit), "cm"); } if (lm->IsRotation()) { - TGeoMatrix& linv = lm->Inverse(); + TGeoMatrix const & linv = lm->Inverse(); XYZRotation rot = getXYZangles(linv.GetRotationMatrix()); if ((rot.X() != 0.0) || (rot.Y() != 0.0) || (rot.Z() != 0.0)) { first_solid.append(obj = xml_elt_t(geo.doc, _U(firstrotation))); @@ -568,7 +568,7 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con solid.setRef(_U(positionref), pos.name()); } if (rm->IsRotation()) { - TGeoMatrix& rinv = rm->Inverse(); + TGeoMatrix const & rinv = rm->Inverse(); XYZRotation rot = getXYZangles(rinv.GetRotationMatrix()); if ((rot.X() != 0.0) || (rot.Y() != 0.0) || (rot.Z() != 0.0)) { xml_ref_t xml_rot = handleRotation(rnam+"_rot", &rinv);