Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:28

0001 /****************************************************************************
0002  *
0003  * This is a part of CMS-TOTEM PPS offline software.
0004  * Authors:
0005  *  Jan Kašpar (jan.kaspar@gmail.com)
0006  *  Helena Malbouisson
0007  *  Clemencia Mora Herrera
0008  *
0009  ****************************************************************************/
0010 
0011 #ifndef CondFormats_PPSObjects_CTPPSRPAlignmentCorrectionData
0012 #define CondFormats_PPSObjects_CTPPSRPAlignmentCorrectionData
0013 
0014 #include "CondFormats/Serialization/interface/Serializable.h"
0015 
0016 #include "DataFormats/Math/interface/Vector3D.h"
0017 #include <Math/Rotation3D.h>
0018 #include <Math/RotationZYX.h>
0019 
0020 #include <vector>
0021 
0022 /**
0023  *\brief Alignment correction for an element of the CT-PPS detector.
0024  * Within the geometry description, every sensor (more generally every element) is given
0025  * its <b>translation</b> and <b>rotation</b>. These two quantities shall be understood in
0026  * <b>local-to-global</b> coordinate transform. That is, if r_l is a point in local
0027  * coordinate system and x_g in global, then it holds
0028  \verbatim
0029     x_g = rotation * x_l + translation
0030  \endverbatim
0031  *
0032  * This class presents an alignment correction to the translation and rotation. It follows
0033  * these formulae:
0034  \verbatim
0035     translation_final = translation_correction + translation_original
0036     rotation_final = rotation_correction * rotation_original
0037  \endverbatim
0038  *
0039  * Alignment corrections can be added, following this prescription:
0040  \verbatim
0041     translation_final = translation_added + translation_original
0042     rotation_final = rotation_added * rotation_original
0043  \endverbatim
0044  *
0045  * NB: As follows from the above definitions, all translations are in the global space. This
0046  * means that the rotations do not act on them.
0047  *
0048  * Besides the values of rotations and translations, this class contains also uncertainties
0049  * for these paramaters (the _unc data memebers).
0050  *
0051  * The rotation is parameterized by 3 rotation parameters, the matrix is obtained by calling
0052  * ROOT::Math::RotationZYX(r_z, r_y, r_x), which corresponds to:
0053   \verbatim
0054       | 1     0        0    |   | cos r_y  0  +sin r_y |   | cos r_z  -sin r_z  0 |
0055   R = | 0 cos r_x  -sin r_x | * |    0     1     0     | * | sin r_z  cos r_z   0 |
0056       | 0 sin r_x  cos r_x  |   |-sin r_y  0  cos r_y  |   |    0        0      1 |
0057   \endverbatim
0058  **/
0059 class CTPPSRPAlignmentCorrectionData {
0060 protected:
0061   /// shift in mm; in global XYZ frame, which is not affected by (alignment) rotations!
0062   /// "_unc" denotes the shift uncertainties
0063   double sh_x, sh_y, sh_z;
0064   double sh_x_unc, sh_y_unc, sh_z_unc;
0065 
0066   /// the three rotation angles
0067   /// in rad
0068   double rot_x, rot_y, rot_z;
0069   double rot_x_unc, rot_y_unc, rot_z_unc;
0070 
0071 public:
0072   CTPPSRPAlignmentCorrectionData()
0073       : sh_x(0.),
0074         sh_y(0.),
0075         sh_z(0.),
0076         sh_x_unc(0.),
0077         sh_y_unc(0.),
0078         sh_z_unc(0.),
0079         rot_x(0.),
0080         rot_y(0.),
0081         rot_z(0.),
0082         rot_x_unc(0.),
0083         rot_y_unc(0.),
0084         rot_z_unc(0.) {}
0085 
0086   /// full constructor, shifts in mm, rotations in rad
0087   CTPPSRPAlignmentCorrectionData(double _sh_x,
0088                                  double _sh_x_u,
0089                                  double _sh_y,
0090                                  double _sh_y_u,
0091                                  double _sh_z,
0092                                  double _sh_z_u,
0093                                  double _rot_x,
0094                                  double _rot_x_u,
0095                                  double _rot_y,
0096                                  double _rot_y_u,
0097                                  double _rot_z,
0098                                  double _rot_z_u);
0099 
0100   /// no uncertainty constructor, shifts in mm, rotation in rad
0101   CTPPSRPAlignmentCorrectionData(double _sh_x, double _sh_y, double _sh_z, double _rot_x, double _rot_y, double rot_z);
0102 
0103   inline double getShX() const { return sh_x; }
0104   inline void setShX(const double &v) { sh_x = v; }
0105 
0106   inline double getShXUnc() const { return sh_x_unc; }
0107   inline void setShXUnc(const double &v) { sh_x_unc = v; }
0108 
0109   inline double getShY() const { return sh_y; }
0110   inline void setShY(const double &v) { sh_y = v; }
0111 
0112   inline double getShYUnc() const { return sh_y_unc; }
0113   inline void setShYUnc(const double &v) { sh_y_unc = v; }
0114 
0115   inline double getShZ() const { return sh_z; }
0116   inline void setShZ(const double &v) { sh_z = v; }
0117 
0118   inline double getShZUnc() const { return sh_z_unc; }
0119   inline void setShZUnc(const double &v) { sh_z_unc = v; }
0120 
0121   inline double getRotX() const { return rot_x; }
0122   inline void setRotX(const double &v) { rot_x = v; }
0123 
0124   inline double getRotXUnc() const { return rot_x_unc; }
0125   inline void setRotXUnc(const double &v) { rot_x_unc = v; }
0126 
0127   inline double getRotY() const { return rot_y; }
0128   inline void setRotY(const double &v) { rot_y = v; }
0129 
0130   inline double getRotYUnc() const { return rot_y_unc; }
0131   inline void setRotYUnc(const double &v) { rot_y_unc = v; }
0132 
0133   inline double getRotZ() const { return rot_z; }
0134   inline void setRotZ(const double &v) { rot_z = v; }
0135 
0136   inline double getRotZUnc() const { return rot_z_unc; }
0137   inline void setRotZUnc(const double &v) { rot_z_unc = v; }
0138 
0139   math::XYZVectorD getTranslation() const { return math::XYZVectorD(sh_x, sh_y, sh_z); }
0140 
0141   math::XYZVectorD getTranslationUncertainty() const { return math::XYZVectorD(sh_x_unc, sh_y_unc, sh_z_unc); }
0142 
0143   ROOT::Math::Rotation3D getRotationMatrix() const {
0144     return ROOT::Math::Rotation3D(ROOT::Math::RotationZYX(rot_z, rot_y, rot_x));
0145   }
0146 
0147   /// merges (cumulates) alignements
0148   /// \param sumErrors if true, uncertainties are summed in quadrature, otherwise the uncertainties of this are not changed
0149   /// With the add... switches one can control which corrections are added.
0150   void add(const CTPPSRPAlignmentCorrectionData &, bool sumErrors = true, bool addSh = true, bool addRot = true);
0151 
0152   COND_SERIALIZABLE;
0153 };
0154 
0155 std::ostream &operator<<(std::ostream &s, const CTPPSRPAlignmentCorrectionData &corr);
0156 
0157 #endif