Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef ErrorFrameTransformer_H
0002 #define ErrorFrameTransformer_H
0003 
0004 #include "DataFormats/GeometrySurface/interface/Surface.h"
0005 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0006 #include "DataFormats/GeometryCommonDetAlgo/interface/LocalErrorExtended.h"
0007 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
0008 #include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
0009 
0010 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0011 
0012 struct ErrorFrameTransformer {
0013   typedef Surface::Scalar Scalar;
0014 
0015   //old version 1
0016   static GlobalError transform(const LocalError& le, const Surface& surf) {
0017     // the GlobalError is a sym matrix, initialisation takes only
0018     // 6 T because GlobalError is stored as a lower triangular matrix.
0019     Scalar cxx = le.xx();
0020     Scalar cxy = le.xy();
0021     Scalar cyy = le.yy();
0022 
0023     Surface::RotationType r = surf.rotation();
0024 
0025     return GlobalError(r.xx() * (r.xx() * cxx + r.yx() * cxy) + r.yx() * (r.xx() * cxy + r.yx() * cyy),
0026                        r.xx() * (r.xy() * cxx + r.yy() * cxy) + r.yx() * (r.xy() * cxy + r.yy() * cyy),
0027                        r.xy() * (r.xy() * cxx + r.yy() * cxy) + r.yy() * (r.xy() * cxy + r.yy() * cyy),
0028                        r.xx() * (r.xz() * cxx + r.yz() * cxy) + r.yx() * (r.xz() * cxy + r.yz() * cyy),
0029                        r.xy() * (r.xz() * cxx + r.yz() * cxy) + r.yy() * (r.xz() * cxy + r.yz() * cyy),
0030                        r.xz() * (r.xz() * cxx + r.yz() * cxy) + r.yz() * (r.xz() * cxy + r.yz() * cyy));
0031   }
0032 
0033   static LocalError transform(const GlobalError& ge, const Surface& surf) {
0034     Scalar cxx = ge.cxx();
0035     Scalar cyx = ge.cyx();
0036     Scalar cyy = ge.cyy();
0037     Scalar czx = ge.czx();
0038     Scalar czy = ge.czy();
0039     Scalar czz = ge.czz();
0040 
0041     Surface::RotationType r = surf.rotation();
0042 
0043     Scalar l11 = r.xx() * (r.xx() * cxx + r.xy() * cyx + r.xz() * czx) +
0044                  r.xy() * (r.xx() * cyx + r.xy() * cyy + r.xz() * czy) +
0045                  r.xz() * (r.xx() * czx + r.xy() * czy + r.xz() * czz);
0046     Scalar l12 = r.yx() * (r.xx() * cxx + r.xy() * cyx + r.xz() * czx) +
0047                  r.yy() * (r.xx() * cyx + r.xy() * cyy + r.xz() * czy) +
0048                  r.yz() * (r.xx() * czx + r.xy() * czy + r.xz() * czz);
0049     Scalar l22 = r.yx() * (r.yx() * cxx + r.yy() * cyx + r.yz() * czx) +
0050                  r.yy() * (r.yx() * cyx + r.yy() * cyy + r.yz() * czy) +
0051                  r.yz() * (r.yx() * czx + r.yy() * czy + r.yz() * czz);
0052 
0053     return LocalError(l11, l12, l22);
0054   }
0055 
0056   //new Jacobian for 6x6 APE in muon code
0057   static LocalErrorExtended transform46(const GlobalErrorExtended& ge,
0058                                         const AlgebraicVector& positions,
0059                                         const AlgebraicVector& directions) {
0060     const AlgebraicSymMatrix66& as(ge.matrix());
0061 
0062     AlgebraicMatrix46 jacobian46;
0063     jacobian46[0][0] = 1.;
0064     jacobian46[0][1] = 0.;
0065     jacobian46[0][2] = -directions[0];
0066     jacobian46[0][3] = -positions[1] * directions[0];
0067     jacobian46[0][4] = positions[0] * directions[0];
0068     jacobian46[0][5] = -positions[1];
0069 
0070     jacobian46[1][0] = 0.;
0071     jacobian46[1][1] = 1.;
0072     jacobian46[1][2] = -directions[1];
0073     jacobian46[1][3] = -positions[1] * directions[1];
0074     jacobian46[1][4] = positions[0] * directions[1];
0075     jacobian46[1][5] = positions[0];
0076 
0077     jacobian46[2][0] = 0.;
0078     jacobian46[2][1] = 0.;
0079     jacobian46[2][2] = 0.;
0080     jacobian46[2][3] = -directions[1] * directions[0];
0081     jacobian46[2][4] = 1. + directions[0] * directions[0];
0082     jacobian46[2][5] = -directions[1];
0083 
0084     jacobian46[3][0] = 0.;
0085     jacobian46[3][1] = 0.;
0086     jacobian46[3][2] = 0.;
0087     jacobian46[3][3] = -1. - directions[1] * directions[1];
0088     jacobian46[3][4] = directions[0] * directions[1];
0089     jacobian46[3][5] = directions[0];
0090 
0091     AlgebraicSymMatrix44 out = ROOT::Math::Similarity(jacobian46, as);
0092 
0093     LocalErrorExtended newError(out);
0094 
0095     return newError;
0096   }
0097 };
0098 
0099 #endif