Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:24

0001 #ifndef DETECTOR_DESCRIPTION_CORE_DDTRANSFORM_H
0002 #define DETECTOR_DESCRIPTION_CORE_DDTRANSFORM_H
0003 
0004 #include "DetectorDescription/Core/interface/DDBase.h"
0005 #include "DetectorDescription/Core/interface/DDName.h"
0006 #include "DetectorDescription/Core/interface/DDRotationMatrix.h"
0007 #include <memory>
0008 
0009 class DDRotation;
0010 
0011 std::ostream &operator<<(std::ostream &, const DDRotation &);
0012 
0013 //! Definition of a uniquely identifiable rotation matrix named by DDName \a name
0014 /** DDrot() returns a reference-object DDRotation representing the rotation matrix \a rot.
0015     
0016     The user must not free memory allocated for \a rot!
0017 */
0018 DDRotation DDrot(const DDName &name, std::unique_ptr<DDRotationMatrix> rot);
0019 
0020 std::unique_ptr<DDRotation> DDrotPtr(const DDName &name, std::unique_ptr<DDRotationMatrix> rot);
0021 
0022 //! Definition of a uniquely identifiable rotation matrix named by DDName \a name in the GEANT3 style
0023 /** DDrot() returns a reference-object DDRotation representing the rotation matrix.
0024 */
0025 DDRotation DDrot(const DDName &name, double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ);
0026 
0027 //! Defines a rotation-reflection in the Geant3 way.
0028 /** The resulting matrix MUST be a LEFThanded orthonormal system, otherwise
0029     a DDException will be thrown!
0030 */
0031 DDRotation DDrotReflect(
0032     const DDName &name, double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ);
0033 
0034 DDRotation DDrotReflect(const DDName &name, DDRotationMatrix *rot);
0035 
0036 //! Defines a anonymous rotation or rotation-reflection matrix.
0037 /** It can't be addressed by a unique DDName. Once created, it's the
0038     users responsibility to keep the reference object DDRotation!
0039     Will be mostly used by algorithmic positioning.
0040 */
0041 DDRotation DDanonymousRot(std::unique_ptr<DDRotationMatrix> rot);
0042 
0043 //! create a new DDRotationMatrix in the GEANT3 style.
0044 /** The Matrix must be orthonormal - left or right handed - otherwise a DDException is thrown; 
0045     memory of the returned pointer belongs to the caller
0046 */
0047 std::unique_ptr<DDRotationMatrix> DDcreateRotationMatrix(
0048     double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ);
0049 
0050 //! Represents a uniquely identifyable rotation matrix
0051 /** An object of this class is a reference-object and thus leightweighted.
0052     It is uniquely identified by its DDName. Further details concerning
0053     reference-objects can be found in the documentation of DDLogicalPart.
0054     
0055     DDRotation encapsulates ROOT Rotation3D.
0056 */
0057 class DDRotation : public DDBase<DDName, std::unique_ptr<DDRotationMatrix>> {
0058   friend DDRotation DDrot(const DDName &, std::unique_ptr<DDRotationMatrix>);
0059   friend std::unique_ptr<DDRotation> DDrotPtr(const DDName &, std::unique_ptr<DDRotationMatrix>);
0060   friend DDRotation DDrotReflect(const DDName &, double, double, double, double, double, double);
0061   friend DDRotation DDanonymousRot(std::unique_ptr<DDRotationMatrix>);
0062 
0063 public:
0064   //! refers to the unit-rotation (no rotation at all)
0065   DDRotation();
0066 
0067   //! Creates a initialized reference-object or a reference to an allready defined rotation.
0068   /**
0069      A reference-object to a defined rotation is created if a rotation was already defined usind DDrot(). 
0070      Otherwise a (default) initialized reference-object named \a name is created. At any later stage the rotation matrix
0071      can be defined using DDrot(). All initialized-reference object referring to the same \a name will 
0072      then immidialtely refere to the matrix created by DDrot().
0073      
0074      DDRotation is a lightweighted reference-object. For further details concerning reference-object
0075      refere to the documentation of DDLogicalPart.
0076   */
0077   DDRotation(const DDName &name);
0078 
0079   DDRotation(const DDName &, std::unique_ptr<DDRotationMatrix>);
0080   //! Returns the read-only rotation-matrix
0081   const DDRotationMatrix &rotation() const { return rep(); }
0082 
0083   DDRotationMatrix &rotation() { return rep(); }
0084 
0085   DDRotationMatrix &matrix() { return rotation(); }
0086 
0087 private:
0088   DDRotation(std::unique_ptr<DDRotationMatrix>);
0089 };
0090 
0091 #endif