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 #include "FWCore/Utilities/interface/Exception.h"
0012 
0013 #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionData.h"
0014 
0015 #include <Math/RotationZYX.h>
0016 
0017 using namespace std;
0018 
0019 //----------------------------------------------------------------------------------------------------
0020 
0021 CTPPSRPAlignmentCorrectionData::CTPPSRPAlignmentCorrectionData(double _sh_x,
0022                                                                double _sh_x_u,
0023                                                                double _sh_y,
0024                                                                double _sh_y_u,
0025                                                                double _sh_z,
0026                                                                double _sh_z_u,
0027                                                                double _rot_x,
0028                                                                double _rot_x_u,
0029                                                                double _rot_y,
0030                                                                double _rot_y_u,
0031                                                                double _rot_z,
0032                                                                double _rot_z_u)
0033     : sh_x(_sh_x),
0034       sh_y(_sh_y),
0035       sh_z(_sh_z),
0036       sh_x_unc(_sh_x_u),
0037       sh_y_unc(_sh_y_u),
0038       sh_z_unc(_sh_z_u),
0039       rot_x(_rot_x),
0040       rot_y(_rot_y),
0041       rot_z(_rot_z),
0042       rot_x_unc(_rot_x_u),
0043       rot_y_unc(_rot_y_u),
0044       rot_z_unc(_rot_z_u) {}
0045 
0046 //----------------------------------------------------------------------------------------------------
0047 
0048 CTPPSRPAlignmentCorrectionData::CTPPSRPAlignmentCorrectionData(
0049     double _sh_x, double _sh_y, double _sh_z, double _rot_x, double _rot_y, double _rot_z)
0050     : sh_x(_sh_x), sh_y(_sh_y), sh_z(_sh_z), rot_x(_rot_x), rot_y(_rot_y), rot_z(_rot_z) {}
0051 
0052 //----------------------------------------------------------------------------------------------------
0053 
0054 void CTPPSRPAlignmentCorrectionData::add(const CTPPSRPAlignmentCorrectionData& a,
0055                                          bool sumErrors,
0056                                          bool addSh,
0057                                          bool addRot) {
0058   if (addSh) {
0059     sh_x += a.sh_x;
0060     sh_y += a.sh_y;
0061     sh_z += a.sh_z;
0062 
0063     if (sumErrors) {
0064       sh_x_unc = sqrt(sh_x_unc * sh_x_unc + a.sh_x_unc * a.sh_x_unc);
0065       sh_y_unc = sqrt(sh_y_unc * sh_y_unc + a.sh_y_unc * a.sh_y_unc);
0066       sh_z_unc = sqrt(sh_z_unc * sh_z_unc + a.sh_z_unc * a.sh_z_unc);
0067     }
0068   }
0069 
0070   if (addRot) {
0071     rot_x += a.rot_x;
0072     rot_y += a.rot_y;
0073     rot_z += a.rot_z;
0074 
0075     if (sumErrors) {
0076       rot_x_unc = sqrt(rot_x_unc * rot_x_unc + a.rot_x_unc * a.rot_x_unc);
0077       rot_y_unc = sqrt(rot_y_unc * rot_y_unc + a.rot_y_unc * a.rot_y_unc);
0078       rot_z_unc = sqrt(rot_z_unc * rot_z_unc + a.rot_z_unc * a.rot_z_unc);
0079     }
0080   }
0081 }
0082 
0083 //----------------------------------------------------------------------------------------------------
0084 
0085 std::ostream& operator<<(std::ostream& s, const CTPPSRPAlignmentCorrectionData& corr) {
0086   s << fixed << "shift (um) " << std::setprecision(1) << "x = " << corr.getShX() * 1E3 << " +- "
0087     << corr.getShXUnc() * 1E3 << ", y = " << corr.getShY() * 1E3 << " +- " << corr.getShYUnc() * 1E3
0088     << ", z = " << corr.getShZ() * 1E3 << " +- " << corr.getShZUnc() * 1E3 << ", rotation (mrad) "
0089     << std::setprecision(1) << "x = " << corr.getRotX() * 1E3 << " +- " << corr.getRotXUnc() * 1E3
0090     << ", y = " << corr.getRotY() * 1E3 << " +- " << corr.getRotYUnc() * 1E3 << ", z = " << corr.getRotZ() * 1E3
0091     << " +- " << corr.getRotZUnc() * 1E3;
0092 
0093   return s;
0094 }