diff --git a/DDAlign/src/AlignmentParser.cpp b/DDAlign/src/AlignmentParser.cpp index b1855fd2f371bd60ba7fdc2c2e838ee759e9ec01..9b0b9ba180f4dc2535867373a0b00160aac23684 100644 --- a/DDAlign/src/AlignmentParser.cpp +++ b/DDAlign/src/AlignmentParser.cpp @@ -59,6 +59,8 @@ namespace DD4hep { using namespace std; using namespace DD4hep; using namespace DD4hep::Alignments; +using DD4hep::Geometry::Position; +using DD4hep::Geometry::Translation3D; /** Convert rotation objects * diff --git a/DDAlign/src/AlignmentWriter.cpp b/DDAlign/src/AlignmentWriter.cpp index a3af11a8b3da43681c4c1bfbb2a5e916f2f79968..829590d7b239cd8d735780f27955ebe63452e639 100644 --- a/DDAlign/src/AlignmentWriter.cpp +++ b/DDAlign/src/AlignmentWriter.cpp @@ -31,6 +31,8 @@ #include <stdexcept> namespace DetectorTools = DD4hep::Geometry::DetectorTools; +using DD4hep::Geometry::Position; +using DD4hep::Geometry::Translation3D; using namespace DD4hep::Alignments; using namespace DD4hep; using namespace std; @@ -90,7 +92,7 @@ void AlignmentWriter::addNode(XML::Element elt, GlobalAlignment a) const { elt.append(e); } if ( mat.IsRotation() ) { - XYZAngles rot = _XYZangles(&mat); + Geometry::XYZAngles rot = Geometry::_XYZangles(&mat); if ( fabs(rot.X()) > numeric_limits<double>::epsilon() || fabs(rot.Y()) > numeric_limits<double>::epsilon() || fabs(rot.Z()) > numeric_limits<double>::epsilon() ) { diff --git a/DDAlign/src/DetectorAlignment.cpp b/DDAlign/src/DetectorAlignment.cpp index c14b778bd4a125591689206ad77ee27f184791a6..7f0e605153be1873da05c6b5b5825f582f274f79 100644 --- a/DDAlign/src/DetectorAlignment.cpp +++ b/DDAlign/src/DetectorAlignment.cpp @@ -159,22 +159,22 @@ const vector<GlobalAlignment>& DetectorAlignment::volumeAlignments() const { /// Align the PhysicalNode of the placement of the detector element (translation only) GlobalAlignment DetectorAlignment::align(const Position& pos, bool chk, double overlap) { - return align(_transform(pos),chk,overlap); + return align(Geometry::_transform(pos),chk,overlap); } /// Align the PhysicalNode of the placement of the detector element (rotation only) GlobalAlignment DetectorAlignment::align(const RotationZYX& rot, bool chk, double overlap) { - return align(_transform(rot),chk,overlap); + return align(Geometry::_transform(rot),chk,overlap); } /// Align the PhysicalNode of the placement of the detector element (translation + rotation) GlobalAlignment DetectorAlignment::align(const Position& pos, const RotationZYX& rot, bool chk, double overlap) { - return align(_transform(pos,rot),chk,overlap); + return align(Geometry::_transform(pos,rot),chk,overlap); } /// Align the physical node according to a generic Transform3D GlobalAlignment DetectorAlignment::align(const Transform3D& transform, bool chk, double overlap) { - return align(_transform(transform),chk,overlap); + return align(Geometry::_transform(transform),chk,overlap); } /// Align the physical node according to a generic TGeo matrix @@ -184,23 +184,23 @@ GlobalAlignment DetectorAlignment::align(TGeoHMatrix* matrix, bool chk, double o /// Align the PhysicalNode of the placement of the detector element (translation only) GlobalAlignment DetectorAlignment::align(const string& elt_path, const Position& pos, bool chk, double overlap) { - return align(elt_path,_transform(pos),chk,overlap); + return align(elt_path,Geometry::_transform(pos),chk,overlap); } /// Align the PhysicalNode of the placement of the detector element (rotation only) GlobalAlignment DetectorAlignment::align(const string& elt_path, const RotationZYX& rot, bool chk, double overlap) { - return align(elt_path,_transform(rot),chk,overlap); + return align(elt_path,Geometry::_transform(rot),chk,overlap); } /// Align the PhysicalNode of the placement of the detector element (translation + rotation) GlobalAlignment DetectorAlignment::align(const string& elt_path, const Position& pos, const RotationZYX& rot, bool chk, double overlap) { - return align(elt_path,_transform(pos,rot),chk,overlap); + return align(elt_path,Geometry::_transform(pos,rot),chk,overlap); } /// Align the physical node according to a generic Transform3D GlobalAlignment DetectorAlignment::align(const string& elt_path, const Transform3D& transform, bool chk, double overlap) { - return align(elt_path,_transform(transform),chk,overlap); + return align(elt_path,Geometry::_transform(transform),chk,overlap); } /// Align the physical node according to a generic TGeo matrix diff --git a/DDCond/include/DDCond/ConditionsTest.h b/DDCond/include/DDCond/ConditionsTest.h index c4e43fd4a6499e143939073fb2af59621ccdc4a8..a2153ad7112be0fb97169fd801bde74ca8b4d071 100644 --- a/DDCond/include/DDCond/ConditionsTest.h +++ b/DDCond/include/DDCond/ConditionsTest.h @@ -37,6 +37,7 @@ namespace DD4hep { namespace Test { using Geometry::LCDD; + using Geometry::Position; using Geometry::DetElement; struct TestEnv { diff --git a/DDCond/src/plugins/ConditionsExample.cpp b/DDCond/src/plugins/ConditionsExample.cpp index c6702911593668d4bab8e94ee61399546759af98..cbd8a38eabd9b9e8b5ab77ca6062400c0403fdb6 100644 --- a/DDCond/src/plugins/ConditionsExample.cpp +++ b/DDCond/src/plugins/ConditionsExample.cpp @@ -19,6 +19,7 @@ using namespace std; using namespace DD4hep; using namespace DD4hep::Conditions; using Geometry::LCDD; +using Geometry::Position; using Geometry::DetElement; namespace { diff --git a/DDCore/include/DD4hep/AlignmentData.h b/DDCore/include/DD4hep/AlignmentData.h index 14b04f30e5ed03bddf869b9d465d1d72d8a5c5e3..b61d13eb8ecb8f7181fb1dd9879e7be4bd93e9e6 100644 --- a/DDCore/include/DD4hep/AlignmentData.h +++ b/DDCore/include/DD4hep/AlignmentData.h @@ -30,6 +30,9 @@ namespace DD4hep { // The DetElement is a central object. We alias it here. using Geometry::DetElement; + using Geometry::RotationZYX; + using Geometry::Transform3D; + using Geometry::Position; using Geometry::LCDD; // Forward declarations diff --git a/DDCore/include/DD4hep/GlobalAlignment.h b/DDCore/include/DD4hep/GlobalAlignment.h index 7036e777fc80e989514dc4aaa3470a10c26ed6e8..75cc59b909e38a2711fcafeb664e1490655e2977 100644 --- a/DDCore/include/DD4hep/GlobalAlignment.h +++ b/DDCore/include/DD4hep/GlobalAlignment.h @@ -37,6 +37,11 @@ namespace DD4hep { * \ingroup DD4HEP_ALIGN */ class GlobalAlignment: public Handle<TGeoPhysicalNode> { + + typedef Geometry::RotationZYX RotationZYX; + typedef Geometry::Transform3D Transform3D; + typedef Geometry::Position Position; + public: /// Default constructor GlobalAlignment(); diff --git a/DDCore/include/DD4hep/MatrixHelpers.h b/DDCore/include/DD4hep/MatrixHelpers.h index 15658c18d76047619ff967cae7635e5441d59439..66abdcfa0c3b0dd8de94973edaacefd352ee4657 100644 --- a/DDCore/include/DD4hep/MatrixHelpers.h +++ b/DDCore/include/DD4hep/MatrixHelpers.h @@ -26,44 +26,48 @@ class TGeoMatrix; /// Namespace for the AIDA detector description toolkit namespace DD4hep { + /// Namespace for the geometry part of the AIDA detector description toolkit + namespace Geometry { - typedef Position XYZAngles; - /// Access the TGeo identity transformation \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - TGeoIdentity* identityTransform(); - /// Convert a Position object to a TGeoTranslation \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - TGeoTranslation* _translation(const Position& pos); - /// Convert a RotationZYX object to a TGeoRotation \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - TGeoRotation* _rotationZYX(const RotationZYX& rot); - /// Convert a Rotation3D object to a TGeoRotation \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - TGeoRotation* _rotation3D(const Rotation3D& rot); - /// Convert a Transform3D object to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - TGeoHMatrix* _transform(const Transform3D& trans); - /// Convert a Position object to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - TGeoHMatrix* _transform(const Position& pos); - /// Convert a RotationZYX object to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - TGeoHMatrix* _transform(const RotationZYX& rot); - /// Convert a Rotation3D object to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - TGeoHMatrix* _transform(const Rotation3D& rot3D); - /// Convert a Position followed by a RotationZYX to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - TGeoHMatrix* _transform(const Position& pos, const RotationZYX& rot); + typedef Position XYZAngles; + + /// Access the TGeo identity transformation \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + TGeoIdentity* identityTransform(); + /// Convert a Position object to a TGeoTranslation \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + TGeoTranslation* _translation(const Geometry::Position& pos); + /// Convert a RotationZYX object to a TGeoRotation \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + TGeoRotation* _rotationZYX(const Geometry::RotationZYX& rot); + /// Convert a Rotation3D object to a TGeoRotation \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + TGeoRotation* _rotation3D(const Geometry::Rotation3D& rot); + /// Convert a Transform3D object to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + TGeoHMatrix* _transform(const Geometry::Transform3D& trans); + /// Convert a Position object to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + TGeoHMatrix* _transform(const Geometry::Position& pos); + /// Convert a RotationZYX object to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + TGeoHMatrix* _transform(const Geometry::RotationZYX& rot); + /// Convert a Rotation3D object to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + TGeoHMatrix* _transform(const Geometry::Rotation3D& rot3D); + /// Convert a Position followed by a RotationZYX to a TGeoHMatrix \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + TGeoHMatrix* _transform(const Geometry::Position& pos, const Geometry::RotationZYX& rot); - /// Convert a TGeoMatrix object to a generic Transform3D \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - Transform3D _transform(const TGeoMatrix* matrix); + /// Convert a TGeoMatrix object to a generic Transform3D \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + Geometry::Transform3D _transform(const TGeoMatrix* matrix); - /// Decompose a generic Transform3D into a translation (Position) and a RotationZYX \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - void _decompose(const Transform3D& trafo, Position& pos, RotationZYX& rot); - /// Decompose a generic Transform3D into a translation (Position) and XYZAngles \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - void _decompose(const Transform3D& trafo, Position& pos, XYZAngles& rot); - /// Decompose a generic Transform3D into a translation (Translation3D) and a RotationZYX \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - void _decompose(const Transform3D& trafo, Translation3D& pos, RotationZYX& rot); - /// Decompose a generic Transform3D into a translation (Translation3D) and XYZAngles \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - void _decompose(const Transform3D& trafo, Translation3D& pos, XYZAngles& rot); + /// Decompose a generic Transform3D into a translation (Position) and a RotationZYX \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + void _decompose(const Geometry::Transform3D& trafo, Geometry::Position& pos, Geometry::RotationZYX& rot); + /// Decompose a generic Transform3D into a translation (Geometry::Position) and XYZAngles \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + void _decompose(const Geometry::Transform3D& trafo, Geometry::Position& pos, XYZAngles& rot); + /// Decompose a generic Transform3D into a translation (Translation3D) and a RotationZYX \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + void _decompose(const Geometry::Transform3D& trafo, Geometry::Translation3D& pos, Geometry::RotationZYX& rot); + /// Decompose a generic Transform3D into a translation (Translation3D) and XYZAngles \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + void _decompose(const Geometry::Transform3D& trafo, Geometry::Translation3D& pos, XYZAngles& rot); - /// Convert a 3x3 rotation matrix to XYZAngles \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - XYZAngles _XYZangles(const double* matrix); - /// Convert a the rotation part of a TGeoMatrix to XYZAngles \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY - XYZAngles _XYZangles(const TGeoMatrix* matrix); + /// Convert a 3x3 rotation matrix to XYZAngles \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + XYZAngles _XYZangles(const double* matrix); + /// Convert a the rotation part of a TGeoMatrix to XYZAngles \ingroup DD4HEP \ingroup DD4HEP_GEOMETRY + XYZAngles _XYZangles(const TGeoMatrix* matrix); + } /* End namespace Geometry */ } /* End namespace DD4hep */ #endif // DD4HEP_IMP_MATRIXHELPERS_H diff --git a/DDCore/include/DD4hep/Objects.h b/DDCore/include/DD4hep/Objects.h index a47463e1bc99b4ee298f9c9e02c0522e6a5721da..da5fa5c3d76facc6793f1165e12ec7a4a099b967 100644 --- a/DDCore/include/DD4hep/Objects.h +++ b/DDCore/include/DD4hep/Objects.h @@ -64,46 +64,6 @@ class TGeoIdentity; /// Namespace for the AIDA detector description toolkit namespace DD4hep { - typedef ROOT::Math::XYZVector Position; - template <class V> V RotateX(const V& v, double a) { - return ROOT::Math::VectorUtil::RotateX(v, a); - } - template <class V> V RotateY(const V& v, double a) { - return ROOT::Math::VectorUtil::RotateY(v, a); - } - template <class V> V RotateZ(const V& v, double a) { - return ROOT::Math::VectorUtil::RotateZ(v, a); - } - - /** Rotation class with the (3D) rotation represented by - * angles describing first a rotation of - * an angle phi (yaw) about the Z axis, - * followed by a rotation of an angle theta (pitch) about the new Y' axis, - * followed by a third rotation of an angle psi (roll) about the final X'' axis. - * This is sometimes referred to as the Euler 321 sequence. - * It has not to be confused with the typical Goldstein definition of the Euler Angles - * (Z-X-Z or 313 sequence) which is used by the ROOT::Math::EulerAngles class. - * \see http://root.cern.ch/root/html/ROOT__Math__RotationZYX.html - */ - typedef ROOT::Math::RotationZYX RotationZYX; - /** \see http://root.cern.ch/root/html/ROOT__Math__RotationZ.html */ - typedef ROOT::Math::RotationZ RotationZ; - /** \see http://root.cern.ch/root/html/ROOT__Math__RotationY.html */ - typedef ROOT::Math::RotationY RotationY; - /** \see http://root.cern.ch/root/html/ROOT__Math__RotationX.html */ - typedef ROOT::Math::RotationX RotationX; - /** \see http://root.cern.ch/root/html/ROOT__Math__Rotation3D.html */ - typedef ROOT::Math::Rotation3D Rotation3D; - /** \see http://root.cern.ch/root/html/ROOT__Math__EulerAngels.html */ - typedef ROOT::Math::EulerAngles EulerAngles; - /** \see http://root.cern.ch/root/html/ROOT__Math__Transform3D.html */ - typedef ROOT::Math::Transform3D Transform3D; - /** \see http://root.cern.ch/root/html/ROOT__Math__Translations3D.html */ - typedef ROOT::Math::Translation3D Translation3D; - - /** Access to identity transformation */ - TGeoIdentity* identityTransform(); - /// Namespace for the geometry part of the AIDA detector description toolkit namespace Geometry { @@ -116,6 +76,47 @@ namespace DD4hep { class RegionObject; class LimitSetObject; + typedef ROOT::Math::XYZVector Position; + template <class V> V RotateX(const V& v, double a) { + return ROOT::Math::VectorUtil::RotateX(v, a); + } + template <class V> V RotateY(const V& v, double a) { + return ROOT::Math::VectorUtil::RotateY(v, a); + } + template <class V> V RotateZ(const V& v, double a) { + return ROOT::Math::VectorUtil::RotateZ(v, a); + } + + /** Rotation class with the (3D) rotation represented by + * angles describing first a rotation of + * an angle phi (yaw) about the Z axis, + * followed by a rotation of an angle theta (pitch) about the new Y' axis, + * followed by a third rotation of an angle psi (roll) about the final X'' axis. + * This is sometimes referred to as the Euler 321 sequence. + * It has not to be confused with the typical Goldstein definition of the Euler Angles + * (Z-X-Z or 313 sequence) which is used by the ROOT::Math::EulerAngles class. + * \see http://root.cern.ch/root/html/ROOT__Math__RotationZYX.html + */ + typedef ROOT::Math::RotationZYX RotationZYX; + /** \see http://root.cern.ch/root/html/ROOT__Math__RotationZ.html */ + typedef ROOT::Math::RotationZ RotationZ; + /** \see http://root.cern.ch/root/html/ROOT__Math__RotationY.html */ + typedef ROOT::Math::RotationY RotationY; + /** \see http://root.cern.ch/root/html/ROOT__Math__RotationX.html */ + typedef ROOT::Math::RotationX RotationX; + /** \see http://root.cern.ch/root/html/ROOT__Math__Rotation3D.html */ + typedef ROOT::Math::Rotation3D Rotation3D; + /** \see http://root.cern.ch/root/html/ROOT__Math__EulerAngels.html */ + typedef ROOT::Math::EulerAngles EulerAngles; + /** \see http://root.cern.ch/root/html/ROOT__Math__Transform3D.html */ + typedef ROOT::Math::Transform3D Transform3D; + /** \see http://root.cern.ch/root/html/ROOT__Math__Translations3D.html */ + typedef ROOT::Math::Translation3D Translation3D; + + /** Access to identity transformation */ + TGeoIdentity* identityTransform(); + + /// Handle class describing an author entity /** * \author M.Frank @@ -565,7 +566,7 @@ namespace DD4hep { namespace ROOT { namespace Math { - typedef DD4hep::Position Position; + typedef DD4hep::Geometry::Position Position; /// Dot product of 3-vectors. inline double operator *(const Position& l, const Position& r) { return std::sqrt(l.X() * r.X() + l.Y() * r.Y() + l.Z() * r.Z()); diff --git a/DDCore/src/AlignmentTools.cpp b/DDCore/src/AlignmentTools.cpp index e5e149a36f91738038683926676d520910ff6a39..548bbc0375a8fa4357468b185e11c4573b85fa35 100644 --- a/DDCore/src/AlignmentTools.cpp +++ b/DDCore/src/AlignmentTools.cpp @@ -44,7 +44,7 @@ void DD4hep::Alignments::AlignmentTools::computeIdeal(Alignment alignment) { } a->worldTrafo = parent.nominal()->worldTrafo; a->worldTrafo.MultiplyLeft(&a->detectorTrafo); - a->trToWorld = _transform(&a->worldTrafo); + a->trToWorld = Geometry::_transform(&a->worldTrafo); a->placement = a->detector.placement(); mask.set(AlignmentData::IDEAL); } @@ -71,7 +71,7 @@ void DD4hep::Alignments::AlignmentTools::computeIdeal(Alignment alignment, a->placement = det->placement; } a->worldTrafo.MultiplyLeft(&(a->detector.nominal()->worldTrafo)); - a->trToWorld = _transform(&a->worldTrafo); + a->trToWorld = Geometry::_transform(&a->worldTrafo); mask.set(AlignmentData::IDEAL); } @@ -95,7 +95,7 @@ void DD4hep::Alignments::AlignmentTools::computeSurvey(Alignment alignment) } a->worldTrafo = parent.survey()->worldTrafo; a->worldTrafo.MultiplyLeft(&a->detectorTrafo); - a->trToWorld = _transform(&a->worldTrafo); + a->trToWorld = Geometry::_transform(&a->worldTrafo); a->placement = a->detector.placement(); } mask.set(AlignmentData::SURVEY); diff --git a/DDCore/src/GlobalAlignment.cpp b/DDCore/src/GlobalAlignment.cpp index 048f73ac263bc3d830e23c06c555cf131622ad3c..cb2625850098058c03b0e3b57b3ae6f1bbd6b617 100644 --- a/DDCore/src/GlobalAlignment.cpp +++ b/DDCore/src/GlobalAlignment.cpp @@ -92,13 +92,13 @@ PlacedVolume GlobalAlignment::motherPlacement(int level_up) const { } /// Access the currently applied alignment/placement matrix -Transform3D GlobalAlignment::toGlobal(int level) const { +GlobalAlignment::Transform3D GlobalAlignment::toGlobal(int level) const { CheckHandle verify_handle(*this); - return _transform(ptr()->GetMatrix(level)); + return Geometry::_transform(ptr()->GetMatrix(level)); } /// Transform a point from local coordinates of a given level to global coordinates -Position GlobalAlignment::toGlobal(const Position& localPoint, int level) const { +GlobalAlignment::Position GlobalAlignment::toGlobal(const Position& localPoint, int level) const { CheckHandle verify_handle(*this); Position result; TGeoHMatrix* m = ptr()->GetMatrix(level); @@ -107,7 +107,7 @@ Position GlobalAlignment::toGlobal(const Position& localPoint, int level) const } /// Transform a point from local coordinates of a given level to global coordinates -Position GlobalAlignment::globalToLocal(const Position& globalPoint, int level) const { +GlobalAlignment::Position GlobalAlignment::globalToLocal(const Position& globalPoint, int level) const { CheckHandle verify_handle(*this); Position result; TGeoHMatrix* m = ptr()->GetMatrix(level); @@ -116,35 +116,35 @@ Position GlobalAlignment::globalToLocal(const Position& globalPoint, int level) } /// Access the currently applied alignment/placement matrix -Transform3D GlobalAlignment::toMother(int level) const { +GlobalAlignment::Transform3D GlobalAlignment::toMother(int level) const { CheckHandle verify_handle(*this); - return _transform(ptr()->GetNode(level)->GetMatrix()); + return Geometry::_transform(ptr()->GetNode(level)->GetMatrix()); } /// Access the currently applied alignment/placement matrix -Transform3D GlobalAlignment::nominal() const { +GlobalAlignment::Transform3D GlobalAlignment::nominal() const { CheckHandle verify_handle(*this); - return _transform(ptr()->GetOriginalMatrix()); + return Geometry::_transform(ptr()->GetOriginalMatrix()); } /// Access the currently applied correction matrix (delta) -Transform3D GlobalAlignment::delta() const { +GlobalAlignment::Transform3D GlobalAlignment::delta() const { // It may be useful at some point to cache some of these matrices.... CheckHandle verify_handle(*this); TGeoPhysicalNode* n = ptr(); // T = T_0 * Delta -> Delta = T_0^-1 * T TGeoHMatrix mat(n->GetOriginalMatrix()->Inverse()); mat.Multiply(n->GetNode()->GetMatrix()); - return _transform(&mat); + return Geometry::_transform(&mat); } /// Access the inverse of the currently applied correction matrix (delta) (mother to daughter) -Transform3D GlobalAlignment::invDelta() const { +GlobalAlignment::Transform3D GlobalAlignment::invDelta() const { // It may be useful at some point to cache some of these matrices.... CheckHandle verify_handle(*this); TGeoPhysicalNode* n = ptr(); // T = T_0 * Delta -> Delta^-1 = T^-1 * T_0 TGeoHMatrix mat(n->GetNode()->GetMatrix()->Inverse()); mat.Multiply(n->GetOriginalMatrix()); - return _transform(&mat); + return Geometry::_transform(&mat); } diff --git a/DDCore/src/MatrixHelpers.cpp b/DDCore/src/MatrixHelpers.cpp index 57b13090234d8c3c3aaa01b412e2aafaa3876edf..64bf2d70dfe7a6e14edfc2bf9d526d35edf14dbf 100644 --- a/DDCore/src/MatrixHelpers.cpp +++ b/DDCore/src/MatrixHelpers.cpp @@ -18,24 +18,26 @@ // ROOT includes #include "TGeoMatrix.h" -TGeoIdentity* DD4hep::identityTransform() { +using namespace DD4hep::Geometry; + +TGeoIdentity* DD4hep::Geometry::identityTransform() { return gGeoIdentity; } -TGeoTranslation* DD4hep::_translation(const Position& pos) { +TGeoTranslation* DD4hep::Geometry::_translation(const Position& pos) { return new TGeoTranslation("", pos.X(), pos.Y(), pos.Z()); } -TGeoRotation* DD4hep::_rotationZYX(const RotationZYX& rot) { +TGeoRotation* DD4hep::Geometry::_rotationZYX(const RotationZYX& rot) { return new TGeoRotation("", rot.Phi() * RAD_2_DEGREE, rot.Theta() * RAD_2_DEGREE, rot.Psi() * RAD_2_DEGREE); } -TGeoRotation* DD4hep::_rotation3D(const Rotation3D& rot3D) { +TGeoRotation* DD4hep::Geometry::_rotation3D(const Rotation3D& rot3D) { EulerAngles rot(rot3D); return new TGeoRotation("", rot.Phi() * RAD_2_DEGREE, rot.Theta() * RAD_2_DEGREE, rot.Psi() * RAD_2_DEGREE); } -TGeoHMatrix* DD4hep::_transform(const Position& pos) { +TGeoHMatrix* DD4hep::Geometry::_transform(const Position& pos) { double t[3]; TGeoHMatrix *tr = new TGeoHMatrix(); pos.GetCoordinates(t); @@ -45,7 +47,7 @@ TGeoHMatrix* DD4hep::_transform(const Position& pos) { return tr; } -TGeoHMatrix* DD4hep::_transform(const RotationZYX& rot) { +TGeoHMatrix* DD4hep::Geometry::_transform(const RotationZYX& rot) { TGeoHMatrix *tr = new TGeoHMatrix(); tr->RotateZ(rot.Phi() * RAD_2_DEGREE); tr->RotateY(rot.Theta() * RAD_2_DEGREE); @@ -53,21 +55,21 @@ TGeoHMatrix* DD4hep::_transform(const RotationZYX& rot) { return tr; } -TGeoHMatrix* DD4hep::_transform(const Rotation3D& rot) { +TGeoHMatrix* DD4hep::Geometry::_transform(const Rotation3D& rot) { TGeoHMatrix *tr = new TGeoHMatrix(); Double_t* r = tr->GetRotationMatrix(); rot.GetComponents(r); return tr; } -TGeoHMatrix* DD4hep::_transform(const Transform3D& trans) { +TGeoHMatrix* DD4hep::Geometry::_transform(const Transform3D& trans) { Position pos; RotationZYX rot; trans.GetDecomposition(rot, pos); return _transform(pos,rot); } -TGeoHMatrix* DD4hep::_transform(const Position& pos, const RotationZYX& rot) { +TGeoHMatrix* DD4hep::Geometry::_transform(const Position& pos, const RotationZYX& rot) { double t[3]; TGeoHMatrix *tr = _transform(rot); pos.GetCoordinates(t); @@ -77,7 +79,7 @@ TGeoHMatrix* DD4hep::_transform(const Position& pos, const RotationZYX& rot) { return tr; } -DD4hep::Transform3D DD4hep::_transform(const TGeoMatrix* matrix) { +Transform3D DD4hep::Geometry::_transform(const TGeoMatrix* matrix) { const Double_t* t = matrix->GetTranslation(); if ( matrix->IsRotation() ) { const Double_t* r = matrix->GetRotationMatrix(); @@ -95,11 +97,11 @@ DD4hep::Transform3D DD4hep::_transform(const TGeoMatrix* matrix) { 0e0,0e0,0e0,t[2]*MM_2_CM); } -DD4hep::XYZAngles DD4hep::_XYZangles(const TGeoMatrix* m) { +DD4hep::Geometry::XYZAngles DD4hep::Geometry::_XYZangles(const TGeoMatrix* m) { return m->IsRotation() ? _XYZangles(m->GetRotationMatrix()) : XYZAngles(0,0,0); } -DD4hep::XYZAngles DD4hep::_XYZangles(const double* r) { +DD4hep::Geometry::XYZAngles DD4hep::Geometry::_XYZangles(const double* r) { Double_t cosb = std::sqrt(r[0]*r[0] + r[1]*r[1]); if (cosb > 0.00001) { return XYZAngles(atan2(r[5], r[8]), atan2(-r[2], cosb), atan2(r[1], r[0])); @@ -107,21 +109,21 @@ DD4hep::XYZAngles DD4hep::_XYZangles(const double* r) { return XYZAngles(atan2(-r[7], r[4]),atan2(-r[2], cosb),0); } -void DD4hep::_decompose(const Transform3D& trafo, Translation3D& pos, RotationZYX& rot) { +void DD4hep::Geometry::_decompose(const Transform3D& trafo, Translation3D& pos, RotationZYX& rot) { trafo.GetDecomposition(rot,pos); } -void DD4hep::_decompose(const Transform3D& trafo, Translation3D& pos, XYZAngles& rot) { +void DD4hep::Geometry::_decompose(const Transform3D& trafo, Translation3D& pos, XYZAngles& rot) { EulerAngles r; trafo.GetDecomposition(r,pos); rot.SetXYZ(r.Psi(),r.Theta(),r.Phi()); } -void DD4hep::_decompose(const Transform3D& trafo, Position& pos, RotationZYX& rot) { +void DD4hep::Geometry::_decompose(const Transform3D& trafo, Position& pos, RotationZYX& rot) { trafo.GetDecomposition(rot,pos); } -void DD4hep::_decompose(const Transform3D& trafo, Position& pos, XYZAngles& rot) { +void DD4hep::Geometry::_decompose(const Transform3D& trafo, Position& pos, XYZAngles& rot) { EulerAngles r; trafo.GetDecomposition(r,pos); rot.SetXYZ(r.Psi(),r.Theta(),r.Phi()); diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 87c6c4d86b1910657184c7d0100bbcfa5a8899ed..6ff311e07c82cbb0045e235f3ed8caa84bb3f7b0 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -495,7 +495,7 @@ static PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, TGeoMatrix* TGeoVolume* parent = par; TObjArray* a = parent->GetNodes(); Int_t id = a ? a->GetEntries() : 0; - if (transform && transform != DD4hep::identityTransform()) { + if (transform && transform != identityTransform()) { string nam = string(daughter->GetName()) + "_placement"; transform->SetName(nam.c_str()); } @@ -523,7 +523,7 @@ PlacedVolume Volume::placeVolume(const Volume& volume, const Transform3D& trans) /// Place daughter volume. The position and rotation are the identity PlacedVolume Volume::placeVolume(const Volume& volume) const { - return _addNode(m_element, volume, DD4hep::identityTransform()); + return _addNode(m_element, volume, identityTransform()); } /// Place un-rotated daughter volume at the given position. diff --git a/DDDB/include/DDDB/DDDBConversion.h b/DDDB/include/DDDB/DDDBConversion.h index d793eaa7717551aeea2aa252002086d8d96fd806..6a4298440fe5151cbc8e4eb5fe4fe9ef8adb013d 100644 --- a/DDDB/include/DDDB/DDDBConversion.h +++ b/DDDB/include/DDDB/DDDBConversion.h @@ -44,6 +44,10 @@ namespace DD4hep { class Document; using Geometry::DetElement; + using Geometry::Rotation3D; + using Geometry::RotationZYX; + using Geometry::Transform3D; + using Geometry::Position; using Geometry::LCDD; /// Basic named object diff --git a/DDDetectors/src/LayeringExtensionPlugin.cpp b/DDDetectors/src/LayeringExtensionPlugin.cpp index f151903ec3b7b3af7610c891b97a3a84dabadf58..deb50e63411b38f157212e9cc00440f9be3e206a 100644 --- a/DDDetectors/src/LayeringExtensionPlugin.cpp +++ b/DDDetectors/src/LayeringExtensionPlugin.cpp @@ -32,7 +32,7 @@ namespace { det.addExtension<LayeringExtension>(e); for(std::map<int,DetElement>::const_iterator i=layers.begin(); i!=layers.end();++i) { DetElement de = (*i).second; - e->setLayer(de.id(), de, DD4hep::Position(0,0,1)); + e->setLayer(de.id(), de, Position(0,0,1)); std::cout << " Add layer:" << de.name() << " ID: " << de.id() << " Parent:" << de.parent().name() << std::endl; diff --git a/DDEve/src/HitActors.cpp b/DDEve/src/HitActors.cpp index 36ac980d834d7e62fa104e3bec88a5d7ebc82d7a..8dcbe6f73ca48139cfd883f692805de4604d4c9b 100644 --- a/DDEve/src/HitActors.cpp +++ b/DDEve/src/HitActors.cpp @@ -29,7 +29,7 @@ using namespace DD4hep; /// Action callback of this functor: void EtaPhiHistogramActor::operator()(const DDEveHit& hit) { - const Position pos(hit.x/MM_2_CM,hit.y/MM_2_CM,hit.z/MM_2_CM); + const Geometry::Position pos(hit.x/MM_2_CM,hit.y/MM_2_CM,hit.z/MM_2_CM); histogram->Fill(pos.Eta(),pos.Phi(),hit.deposit); } diff --git a/DDG4/include/DDG4/Defs.h b/DDG4/include/DDG4/Defs.h index 40cc5884883110902222b2145874c62180cf5bbf..499e61b323306dd8bea52917b04477140a2d6aaf 100644 --- a/DDG4/include/DDG4/Defs.h +++ b/DDG4/include/DDG4/Defs.h @@ -24,7 +24,9 @@ namespace DD4hep { /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit namespace Simulation { - using DD4hep::Position; + using Geometry::Transform3D; + using Geometry::RotationZYX; + using Geometry::Position; using Geometry::LCDD; using Geometry::Readout; using Geometry::DetElement; diff --git a/DDG4/plugins/Geant4MaterialScanner.cpp b/DDG4/plugins/Geant4MaterialScanner.cpp index 0fb5725c22fda0233272e027b2ba9ddfb5368893..64ea8294ee44de79d603414372848bbac2299e72 100644 --- a/DDG4/plugins/Geant4MaterialScanner.cpp +++ b/DDG4/plugins/Geant4MaterialScanner.cpp @@ -14,6 +14,7 @@ // Framework include files #include "DD4hep/Objects.h" +#include "DDG4/Defs.h" #include "DDG4/Geant4SteppingAction.h" // Forward declarations diff --git a/DDRec/include/DDRec/API/Exceptions.h b/DDRec/include/DDRec/API/Exceptions.h index ffedadb3d66b6429ccedd9bcbc1904ba0cab36a3..8710524abec4c0095da7dad943bdbe270fe2d9a7 100644 --- a/DDRec/include/DDRec/API/Exceptions.h +++ b/DDRec/include/DDRec/API/Exceptions.h @@ -39,11 +39,11 @@ private: class invalid_position: public std::invalid_argument { public: - invalid_position(const std::string& msg, const Position& position) : + invalid_position(const std::string& msg, const Geometry::Position& position) : std::invalid_argument(createMsg(msg, position)) { } private: - static std::string createMsg(const std::string& msg, const Position& position) { + static std::string createMsg(const std::string& msg, const Geometry::Position& position) { std::stringstream s; s << "Invalid position: " << msg << " " << position; return s.str(); diff --git a/DDRec/include/DDRec/API/IDDecoder.h b/DDRec/include/DDRec/API/IDDecoder.h index 41f8c1d0fe2fec7fb51f54dfcc21c3cf5c88bfde..32184247276e37d10a8bea9f6f4e9363d4e41b05 100644 --- a/DDRec/include/DDRec/API/IDDecoder.h +++ b/DDRec/include/DDRec/API/IDDecoder.h @@ -75,46 +75,46 @@ public: virtual ~IDDecoder() {}; /// Returns the cell ID from the local position in the given volume ID. - CellID cellIDFromLocal(const Position& local, const VolumeID volumeID) const; + CellID cellIDFromLocal(const Geometry::Position& local, const VolumeID volumeID) const; /// Returns the global cell ID from a given global position - CellID cellID(const Position& global) const; + CellID cellID(const Geometry::Position& global) const; /// Returns the global position from a given cell ID - Position position(const CellID& cellID) const; + Geometry::Position position(const CellID& cellID) const; /// Returns the local position from a given cell ID - Position localPosition(const CellID& cellID) const; + Geometry::Position localPosition(const CellID& cellID) const; /// Returns the volume ID of a given cell ID VolumeID volumeID(const CellID& cellID) const; /// Returns the volume ID of a given global position - VolumeID volumeID(const Position& global) const; + VolumeID volumeID(const Geometry::Position& global) const; /// Returns the placement for a given cell ID Geometry::PlacedVolume placement(const CellID& cellID) const; /// Returns the placement for a given global position - Geometry::PlacedVolume placement(const Position& global) const; + Geometry::PlacedVolume placement(const Geometry::Position& global) const; /// Returns the subdetector for a given cell ID Geometry::DetElement subDetector(const CellID& cellID) const; /// Returns the subdetector for a given global position - Geometry::DetElement subDetector(const Position& global) const; + Geometry::DetElement subDetector(const Geometry::Position& global) const; /// Returns the closest detector element in the hierarchy for a given cell ID Geometry::DetElement detectorElement(const CellID& cellID) const; /// Returns the closest detector element in the hierarchy for a given global position - Geometry::DetElement detectorElement(const Position& global) const; + Geometry::DetElement detectorElement(const Geometry::Position& global) const; /// Access to the Readout object for a given cell ID Geometry::Readout readout(const CellID& cellID) const; /// Access to the Readout object for a given global position - Geometry::Readout readout(const Position& global) const; + Geometry::Readout readout(const Geometry::Position& global) const; /// Calculates the neighbours of the given cell ID and adds them to the list of neighbours void neighbours(const CellID& cellID, std::set<CellID>& neighbours) const; @@ -151,7 +151,7 @@ protected: Geometry::Readout findReadout(const Geometry::DetElement& det) const; /// Helper method to get the closest daughter DetElement to the position starting from the given DetElement - static Geometry::DetElement getClosestDaughter(const Geometry::DetElement& det, const Position& position); + static Geometry::DetElement getClosestDaughter(const Geometry::DetElement& det, const Geometry::Position& position); private: /// Default constructor diff --git a/DDRec/include/DDRec/Extensions/LayeringExtensionImpl.h b/DDRec/include/DDRec/Extensions/LayeringExtensionImpl.h index 795ec60ba4aa3b17bdbad7fe037b8716c4418849..447c5a76b8561d6fed44667a902493a3a3a2fda0 100644 --- a/DDRec/include/DDRec/Extensions/LayeringExtensionImpl.h +++ b/DDRec/include/DDRec/Extensions/LayeringExtensionImpl.h @@ -27,11 +27,14 @@ namespace DDRec { class LayeringExtensionImpl: public LayeringExtension { public: + /// Shortcut to use geometrical positions + typedef Geometry::Position Position; + /// Default constructor LayeringExtensionImpl(); /// Copy constructor - LayeringExtensionImpl(const LayeringExtensionImpl& /*e*/, const Geometry::DetElement& /*d*/) {}; + LayeringExtensionImpl(const LayeringExtensionImpl& /*e*/, const Geometry::DetElement& /*d*/) {}; /// Destructor virtual ~LayeringExtensionImpl(); diff --git a/DDRec/src/IDDecoder.cpp b/DDRec/src/IDDecoder.cpp index 5bb217f8dd707988c5265b0aa3d7b322e273de8e..4ce1186d70093103db6103dfbed4e465f4f90bb6 100644 --- a/DDRec/src/IDDecoder.cpp +++ b/DDRec/src/IDDecoder.cpp @@ -21,6 +21,7 @@ using Geometry::Readout; using Geometry::Solid; using Geometry::VolumeManager; using Geometry::Volume; +using Geometry::Position; using std::set; IDDecoder& IDDecoder::getInstance() { diff --git a/DDRec/src/SubdetectorExtensionImpl.cpp b/DDRec/src/SubdetectorExtensionImpl.cpp index c5e9f183e32519c696f0f9d88b6730e19c0d8d30..a1983da6287ed41c701095db2a9966d45a7cd1df 100644 --- a/DDRec/src/SubdetectorExtensionImpl.cpp +++ b/DDRec/src/SubdetectorExtensionImpl.cpp @@ -14,6 +14,7 @@ namespace DD4hep { namespace DDRec { using Geometry::DetElement; +using Geometry::Position; /// Constructor using a top level DetElement SubdetectorExtensionImpl::SubdetectorExtensionImpl(const Geometry::DetElement& det_elt) { diff --git a/examples/DDDB/scripts/extract_dddb.sh b/examples/DDDB/scripts/extract_dddb.sh index 7beb5e577617a2976d69f622af5cdeb6f96044ef..5a1fabe4f21af958613c0ce6d450a17c9391a84b 100755 --- a/examples/DDDB/scripts/extract_dddb.sh +++ b/examples/DDDB/scripts/extract_dddb.sh @@ -18,8 +18,12 @@ echo "+ ------------------------------------------------------------------+"; echo "| Starting DDDB extraction from tar file |"; echo "+ ------------------------------------------------------------------+"; # +if test -z "$USER"; then + target=/tmp/$USER; +else + target=/tmp; +fi; source=${DD4hepINSTALL}/examples/DDDB/DDDB.tar.gz; -target=/tmp/$USER; clean="NO"; # # Check for arguments: diff --git a/examples/DDDB/scripts/run_dddb.sh b/examples/DDDB/scripts/run_dddb.sh index 13eadfc41d89600ee0ced186d9a3b118b9021a9f..c36cd2c6292601f58e894c669ac74eddad949480 100755 --- a/examples/DDDB/scripts/run_dddb.sh +++ b/examples/DDDB/scripts/run_dddb.sh @@ -15,14 +15,19 @@ # #========================================================================== echo "+ ------------------------------------------------------------------+"; -echo "| |"; +#echo "| |"; echo "| Starting DDDB plugin executor.... |"; -echo "| |"; +#echo "| |"; echo "+ ------------------------------------------------------------------+"; # +if test -z "$USER"; then + target=/tmp/$USER; +else + target=/tmp; +fi; # # Check for arguments: -DDDB_DIR=/tmp/${USER}/DDDB; +DDDB_DIR=${target}/DDDB; loader="-loader DDDB_FileReader"; params="-params file:${DDDB_DIR}/Parameters.xml"; input="-input file:${DDDB_DIR}/DDDB/lhcb.xml";