Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:58:02

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DD4HEP_MATRIXHELPERS_H
0014 #define DD4HEP_MATRIXHELPERS_H
0015 
0016 // Framework include files
0017 #include <DD4hep/Objects.h>
0018 
0019 // Forward declarations
0020 class TGeoTranslation;
0021 class TGeoRotation;
0022 class TGeoHMatrix;
0023 class TGeoMatrix;
0024 
0025 /// Namespace for the AIDA detector description toolkit
0026 namespace dd4hep {
0027 
0028   /// Namespace for the AIDA detector description implementation details
0029   namespace detail   {
0030 
0031     /// Namespace for the AIDA detector description matrix helpers
0032     namespace matrix {
0033 
0034       /// Access the TGeo identity transformation                                               \ingroup DD4HEP \ingroup DD4HEP_CORE
0035       TGeoIdentity*    _identity();
0036       /// Extract the scale part of a TGeoMatrix                                                \ingroup DD4HEP \ingroup DD4HEP_CORE
0037       ROOT::Math::XYZVector _scale(const TGeoMatrix* matrix);
0038       /// Extract the scale part of a TGeoMatrix                                                \ingroup DD4HEP \ingroup DD4HEP_CORE
0039       ROOT::Math::XYZVector _scale(const TGeoMatrix& matrix);
0040 
0041       /// Convert a Position object to a TGeoTranslation                                        \ingroup DD4HEP \ingroup DD4HEP_CORE
0042       TGeoTranslation* _translation(const Position& pos);
0043       /// Extract the translational component of a TGeoMatrix as a Position                     \ingroup DD4HEP \ingroup DD4HEP_CORE
0044       Position         _translation(const TGeoMatrix* matrix);
0045       /// Extract the translational component of a TGeoMatrix as a Position                     \ingroup DD4HEP \ingroup DD4HEP_CORE
0046       Position         _translation(const TGeoMatrix& matrix);
0047 
0048       /// Convert a RotationZYX object to a newly created TGeoRotation                          \ingroup DD4HEP \ingroup DD4HEP_CORE
0049       TGeoRotation*    _rotationZYX(const RotationZYX& rot);
0050       /// Convert a Rotation3D object to a  newly createdTGeoRotation                           \ingroup DD4HEP \ingroup DD4HEP_CORE
0051       TGeoRotation*    _rotation3D(const Rotation3D& rot);
0052       /// Extract the rotational part of a TGeoMatrix as a Rotation3D                           \ingroup DD4HEP \ingroup DD4HEP_CORE
0053       Rotation3D       _rotation3D(const TGeoMatrix* matrix);
0054       /// Extract the rotational part of a TGeoMatrix as a Rotation3D                           \ingroup DD4HEP \ingroup DD4HEP_CORE
0055       Rotation3D       _rotation3D(const TGeoMatrix& matrix);
0056       
0057       /// Convert a Transform3D object to a newly created TGeoHMatrix                           \ingroup DD4HEP \ingroup DD4HEP_CORE
0058       TGeoHMatrix*     _transform(const Transform3D& trans);
0059       /// Convert a Position object to a newly created TGeoHMatrix                              \ingroup DD4HEP \ingroup DD4HEP_CORE
0060       TGeoHMatrix*     _transform(const Position& pos);
0061       /// Convert a RotationZYX object to a newly created TGeoHMatrix                           \ingroup DD4HEP \ingroup DD4HEP_CORE
0062       TGeoHMatrix*     _transform(const RotationZYX& rot);
0063       /// Convert a Rotation3D object to a newly created TGeoHMatrix                            \ingroup DD4HEP \ingroup DD4HEP_CORE
0064       TGeoHMatrix*     _transform(const Rotation3D& rot3D);
0065       /// Convert a Position followed by a RotationZYX to a newly created TGeoHMatrix           \ingroup DD4HEP \ingroup DD4HEP_CORE
0066       TGeoHMatrix*     _transform(const Position& pos, const RotationZYX& rot);
0067 
0068       /// Set a Transform3D object to a TGeoHMatrix                                             \ingroup DD4HEP \ingroup DD4HEP_CORE
0069       TGeoHMatrix&     _transform(TGeoHMatrix& mat, const Transform3D& trans);
0070       /// Set a Position object (translation) to a TGeoHMatrix                                  \ingroup DD4HEP \ingroup DD4HEP_CORE
0071       TGeoHMatrix&     _transform(TGeoHMatrix& mat, const Position& pos);
0072       /// Set a RotationZYX object to a TGeoHMatrix                                             \ingroup DD4HEP \ingroup DD4HEP_CORE
0073       TGeoHMatrix&     _transform(TGeoHMatrix& mat, const RotationZYX& rot);
0074       /// Set a Rotation3D object to a TGeoHMatrix                                              \ingroup DD4HEP \ingroup DD4HEP_CORE
0075       TGeoHMatrix&     _transform(TGeoHMatrix& mat, const Rotation3D& rot3D);
0076       /// Set a Position followed by a RotationZYX to a TGeoHMatrix                             \ingroup DD4HEP \ingroup DD4HEP_CORE
0077       TGeoHMatrix&     _transform(TGeoHMatrix& mat, const Position& pos, const RotationZYX& rot);
0078 
0079       /// Convert a TGeoMatrix object to a generic Transform3D                                  \ingroup DD4HEP \ingroup DD4HEP_CORE
0080       Transform3D      _transform(const TGeoMatrix* matrix);
0081       Transform3D      _transform(const TGeoMatrix& matrix);
0082       /// Convert a generic ROOT Matrix into a generic transformation Transform3D             \ingroup DD4HEP \ingroup DD4HEP_CORE
0083       void             _transform(const TGeoMatrix* matrix, Transform3D& trafo);
0084       /// Convert a generic ROOT Matrix into a generic transformation Transform3D             \ingroup DD4HEP \ingroup DD4HEP_CORE
0085       void             _transform(const TGeoMatrix& matrix, Transform3D& trafo);
0086 
0087       /// Decompose a generic ROOT Matrix into a translation (Position) and a Rotation3D        \ingroup DD4HEP \ingroup DD4HEP_CORE
0088       void _decompose(const TGeoMatrix& matrix, Position& pos, Rotation3D& rot);
0089       /// Decompose a generic ROOT Matrix into a translation (Position) and a RotationZYX       \ingroup DD4HEP \ingroup DD4HEP_CORE
0090       void _decompose(const TGeoMatrix& matrix, Position& pos, RotationZYX& rot);
0091       /// Decompose a generic ROOT Matrix into a translation (Position) and XYZAngles           \ingroup DD4HEP \ingroup DD4HEP_CORE
0092       void _decompose(const TGeoMatrix& matrix, Position& pos, XYZAngles& rot);
0093       /// Decompose a generic Transform3D into a translation (Position) and a Rotation3D        \ingroup DD4HEP \ingroup DD4HEP_CORE
0094       void _decompose(const Transform3D& matrix, Position& pos, Rotation3D& rot);
0095       /// Decompose a generic Transform3D into a translation (Position) and a RotationZYX       \ingroup DD4HEP \ingroup DD4HEP_CORE
0096       void _decompose(const Transform3D& matrix, Position& pos, RotationZYX& rot);
0097       /// Decompose a generic Transform3D into a translation (Position) and XYZAngles \ingroup DD4HEP \ingroup DD4HEP_CORE
0098       void _decompose(const Transform3D& matrix, Position& pos, XYZAngles& rot);
0099       /// Decompose a generic Transform3D into a translation (Translation3D) and a RotationZYX  \ingroup DD4HEP \ingroup DD4HEP_CORE
0100       void _decompose(const Transform3D& matrix, Translation3D& pos, RotationZYX& rot);
0101       /// Decompose a generic Transform3D into a translation (Translation3D) and XYZAngles      \ingroup DD4HEP \ingroup DD4HEP_CORE
0102       void _decompose(const Transform3D& matrix, Translation3D& pos, XYZAngles& rot);
0103       /// Decompose a Rotation3D into a 3 orthogonal unit vectors.
0104       void _decompose(const Rotation3D&  rot, Position& x, Position& y, Position& z);
0105 
0106       /// Convert a 3x3 rotation matrix to XYZAngles                                            \ingroup DD4HEP \ingroup DD4HEP_CORE
0107       XYZAngles _xyzAngles(const double* matrix);
0108       /// Convert a the rotation part of a TGeoMatrix to XYZAngles                              \ingroup DD4HEP \ingroup DD4HEP_CORE
0109       XYZAngles _xyzAngles(const TGeoMatrix* matrix);
0110 
0111       /// Access determinant of rotation component (0 if no rotation present)
0112       double determinant(const TGeoMatrix* matrix);
0113       /// Access determinant of rotation component (0 if no rotation present)
0114       double determinant(const TGeoMatrix& matrix);
0115       /// Access determinant of the rotation component of a Transform3D
0116       double determinant(const Transform3D& trafo);
0117       /// Access determinant of a Rotation3D
0118       double determinant(const Rotation3D& rot);
0119 
0120       enum MatrixEqualityCode  {
0121         MATRICES_EQUAL = 1,
0122         MATRICES_DIFFER_TRANSLATION = 2,
0123         MATRICES_DIFFER_ROTATION = 4
0124       };
0125       /// Check matrices for equality
0126       /** Return codes:
0127        *  MATRICES_EQUAL:                matrices left and right are equal
0128        *  MATRICES_DIFFER_TRANSLATION:   matrices differ in translation
0129        *  MATRICES_DIFFER_ROTATION:      matrices differ in rotation
0130        *  or combination: MATRICES_DIFFER_TRANSLATION|MATRICES_DIFFER_ROTATION
0131        */
0132       int _matrixEqual(const TGeoMatrix& left, const TGeoMatrix& right);
0133     }
0134   }
0135 }       /* End namespace dd4hep            */
0136 
0137 #endif // DD4HEP_MATRIXHELPERS_H