Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:29

0001 #ifndef GlobalErrorExtendedType_H
0002 #define GlobalErrorExtendedType_H
0003 
0004 #include "DataFormats/GeometryCommonDetAlgo/interface/DeepCopyPointer.h"
0005 #include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
0006 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0007 //
0008 // Exceptions
0009 //
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 
0012 template <class T, class ErrorWeightType>
0013 class GlobalErrorBaseExtended {
0014 public:
0015   /// Tag to request a null error matrix
0016   class NullMatrix {};
0017 
0018   GlobalErrorBaseExtended() {}
0019   GlobalErrorBaseExtended(const NullMatrix&) {}
0020 
0021   /**
0022    * Constructor.
0023    * The symmetric matrix stored as a lower triangular matrix
0024    */
0025   GlobalErrorBaseExtended(T c11,
0026                           T c21,
0027                           T c31,
0028                           T c41,
0029                           T c51,
0030                           T c61,
0031                           T c22,
0032                           T c32,
0033                           T c42,
0034                           T c52,
0035                           T c62,
0036                           T c33,
0037                           T c43,
0038                           T c53,
0039                           T c63,
0040                           T c44,
0041                           T c54,
0042                           T c64,
0043                           T c55,
0044                           T c65,
0045                           T c66) {
0046     theCartesianError(0, 0) = c11;
0047     theCartesianError(1, 0) = c21;
0048     theCartesianError(2, 0) = c31;
0049     theCartesianError(3, 0) = c41;
0050     theCartesianError(4, 0) = c51;
0051     theCartesianError(5, 0) = c61;
0052 
0053     theCartesianError(1, 1) = c22;
0054     theCartesianError(2, 1) = c32;
0055     theCartesianError(3, 1) = c42;
0056     theCartesianError(4, 1) = c52;
0057     theCartesianError(5, 1) = c62;
0058 
0059     theCartesianError(2, 2) = c33;
0060     theCartesianError(3, 2) = c43;
0061     theCartesianError(4, 2) = c53;
0062     theCartesianError(5, 2) = c63;
0063 
0064     theCartesianError(3, 3) = c44;
0065     theCartesianError(4, 3) = c54;
0066     theCartesianError(5, 3) = c64;
0067 
0068     theCartesianError(4, 4) = c55;
0069     theCartesianError(5, 4) = c65;
0070 
0071     theCartesianError(5, 5) = c66;
0072   }
0073 
0074   GlobalErrorBaseExtended(const AlgebraicSymMatrix66& err) : theCartesianError(err) {}
0075 
0076   GlobalErrorBaseExtended(const AlgebraicSymMatrix33& err) {
0077     theCartesianError(0, 0) = err[0][0];
0078     theCartesianError(1, 0) = err[1][0];
0079     theCartesianError(2, 0) = err[2][0];
0080     theCartesianError(3, 0) = 0;
0081     theCartesianError(4, 0) = 0;
0082     theCartesianError(5, 0) = 0;
0083 
0084     theCartesianError(1, 1) = err[1][1];
0085     theCartesianError(2, 1) = err[2][1];
0086     theCartesianError(3, 1) = 0;
0087     theCartesianError(4, 1) = 0;
0088     theCartesianError(5, 1) = 0;
0089 
0090     theCartesianError(2, 2) = err[2][2];
0091     theCartesianError(3, 2) = 0;
0092     theCartesianError(4, 2) = 0;
0093     theCartesianError(5, 2) = 0;
0094 
0095     theCartesianError(3, 3) = 0;
0096     theCartesianError(4, 3) = 0;
0097     theCartesianError(5, 3) = 0;
0098 
0099     theCartesianError(4, 4) = 0;
0100     theCartesianError(5, 4) = 0;
0101 
0102     theCartesianError(5, 5) = 0;
0103   }
0104 
0105   ~GlobalErrorBaseExtended() {}
0106 
0107   T cxx() const { return theCartesianError(0, 0); }
0108 
0109   T cyx() const { return theCartesianError(1, 0); }
0110 
0111   T czx() const { return theCartesianError(2, 0); }
0112 
0113   T cphixx() const { return theCartesianError(3, 0); }
0114 
0115   T cphiyx() const { return theCartesianError(4, 0); }
0116 
0117   T cphizx() const { return theCartesianError(5, 0); }
0118 
0119   T cyy() const { return theCartesianError(1, 1); }
0120 
0121   T czy() const { return theCartesianError(2, 1); }
0122 
0123   T cphixy() const { return theCartesianError(3, 1); }
0124 
0125   T cphiyy() const { return theCartesianError(4, 1); }
0126 
0127   T cphizy() const { return theCartesianError(5, 1); }
0128 
0129   T czz() const { return theCartesianError(2, 2); }
0130 
0131   T cphixz() const { return theCartesianError(3, 2); }
0132 
0133   T cphiyz() const { return theCartesianError(4, 2); }
0134 
0135   T cphizz() const { return theCartesianError(5, 2); }
0136 
0137   T cphixphix() const { return theCartesianError(3, 3); }
0138 
0139   T cphiyphix() const { return theCartesianError(4, 3); }
0140 
0141   T cphizphix() const { return theCartesianError(5, 3); }
0142 
0143   T cphiyphiy() const { return theCartesianError(4, 4); }
0144 
0145   T cphizphiy() const { return theCartesianError(5, 4); }
0146 
0147   T cphizphiz() const { return theCartesianError(5, 5); }
0148 
0149   /**
0150    * Access method to the matrix,
0151    * /return The SymMatrix
0152    */
0153   const AlgebraicSymMatrix66& matrix() const { return theCartesianError; }
0154   const AlgebraicSymMatrix66& matrix_new() const { return theCartesianError; }
0155 
0156   //FIXME to be reimplemented
0157   T rerr(const GlobalPoint& aPoint) const {
0158     T r2 = aPoint.perp2();
0159     T x2 = aPoint.x() * aPoint.x();
0160     T y2 = aPoint.y() * aPoint.y();
0161     T xy = aPoint.x() * aPoint.y();
0162     if (r2 != 0)
0163       return std::max<T>(0, (1. / r2) * (x2 * cxx() + 2. * xy * cyx() + y2 * cyy()));
0164     else
0165       return 0.5 * (cxx() + cyy());
0166   }
0167 
0168   //FIXME to be reimplemented
0169   T phierr(const GlobalPoint& aPoint) const {
0170     T r2 = aPoint.perp2();
0171     T x2 = aPoint.x() * aPoint.x();
0172     T y2 = aPoint.y() * aPoint.y();
0173     T xy = aPoint.x() * aPoint.y();
0174     if (r2 != 0)
0175       return std::max<T>(0, (1. / (r2 * r2)) * (y2 * cxx() - 2. * xy * cyx() + x2 * cyy()));
0176     else
0177       return 0;
0178   }
0179 
0180   GlobalErrorBaseExtended operator+(const GlobalErrorBaseExtended& err) const {
0181     return GlobalErrorBaseExtended(theCartesianError + err.theCartesianError);
0182   }
0183   GlobalErrorBaseExtended operator-(const GlobalErrorBaseExtended& err) const {
0184     return GlobalErrorBaseExtended(theCartesianError - err.theCartesianError);
0185   }
0186 
0187 private:
0188   AlgebraicSymMatrix66 theCartesianError;
0189 };
0190 
0191 #endif