Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:49

0001 /**
0002  *  Class: StateSegmentMatcher, Tsos4D, Tsos2DPhi, Tsos2DZed
0003  *
0004  *  Description:
0005  *  utility classes for the dynamical truncation algorithm
0006  *
0007  *  Authors :
0008  *  D. Pagano & G. Bruno - UCL Louvain
0009  *
0010  **/
0011 
0012 #include "RecoMuon/GlobalTrackingTools/interface/StateSegmentMatcher.h"
0013 
0014 using namespace std;
0015 
0016 StateSegmentMatcher::StateSegmentMatcher(TrajectoryStateOnSurface const &tsos,
0017                                          DTRecSegment4D const &dtseg4d,
0018                                          LocalError const &apeLoc) {
0019   if (dtseg4d.hasPhi() && dtseg4d.hasZed()) {
0020     setAPE4d(apeLoc);
0021     match2D = false;
0022     AlgebraicVector dtseg = dtseg4d.parameters();
0023     v1[0] = dtseg[0];
0024     v1[1] = dtseg[1];
0025     v1[2] = dtseg[2];
0026     v1[3] = dtseg[3];
0027 
0028     AlgebraicSymMatrix rhErr_vect = dtseg4d.parametersError();
0029     m1(0, 0) = rhErr_vect(1, 1);
0030     m1(0, 1) = rhErr_vect(1, 2);
0031     m1(0, 2) = rhErr_vect(1, 3);
0032     m1(0, 3) = rhErr_vect(1, 4);
0033     m1(1, 0) = rhErr_vect(2, 1);
0034     m1(1, 1) = rhErr_vect(2, 2);
0035     m1(1, 2) = rhErr_vect(2, 3);
0036     m1(1, 3) = rhErr_vect(2, 4);
0037     m1(2, 0) = rhErr_vect(3, 1);
0038     m1(2, 1) = rhErr_vect(3, 2);
0039     m1(2, 2) = rhErr_vect(3, 3);
0040     m1(2, 3) = rhErr_vect(3, 4);
0041     m1(3, 0) = rhErr_vect(4, 1);
0042     m1(3, 1) = rhErr_vect(4, 2);
0043     m1(3, 2) = rhErr_vect(4, 3);
0044     m1(3, 3) = rhErr_vect(4, 4);
0045 
0046     Tsos4D tsos4d = Tsos4D(tsos);
0047     v2 = tsos4d.paramVector();
0048     m2 = tsos4d.errorMatrix();
0049   } else {
0050     setAPE2d(apeLoc);
0051     match2D = true;
0052     AlgebraicVector dtseg = dtseg4d.parameters();
0053     v1_2d[0] = dtseg[0];
0054     v1_2d[1] = dtseg[1];
0055 
0056     AlgebraicSymMatrix rhErr_vect = dtseg4d.parametersError();
0057     m1_2d(0, 0) = rhErr_vect(1, 1);
0058     m1_2d(0, 1) = rhErr_vect(1, 2);
0059     m1_2d(1, 0) = rhErr_vect(2, 1);
0060     m1_2d(1, 1) = rhErr_vect(2, 2);
0061 
0062     if (dtseg4d.hasPhi()) {
0063       Tsos2DPhi tsos2d = Tsos2DPhi(tsos);
0064       v2_2d = tsos2d.paramVector();
0065       m2_2d = tsos2d.errorMatrix();
0066     }
0067 
0068     if (dtseg4d.hasZed()) {
0069       Tsos2DZed tsos2d = Tsos2DZed(tsos);
0070       v2_2d = tsos2d.paramVector();
0071       m2_2d = tsos2d.errorMatrix();
0072     }
0073   }
0074 }
0075 
0076 StateSegmentMatcher::StateSegmentMatcher(TrajectoryStateOnSurface const &tsos,
0077                                          CSCSegment const &cscseg4d,
0078                                          LocalError const &apeLoc) {
0079   setAPE4d(apeLoc);
0080   match2D = false;
0081   AlgebraicVector cscseg = cscseg4d.parameters();
0082   v1[0] = cscseg[0];
0083   v1[1] = cscseg[1];
0084   v1[2] = cscseg[2];
0085   v1[3] = cscseg[3];
0086 
0087   AlgebraicSymMatrix rhErr_vect = cscseg4d.parametersError();
0088   m1(0, 0) = rhErr_vect(1, 1);
0089   m1(0, 1) = rhErr_vect(1, 2);
0090   m1(0, 2) = rhErr_vect(1, 3);
0091   m1(0, 3) = rhErr_vect(1, 4);
0092   m1(1, 0) = rhErr_vect(2, 1);
0093   m1(1, 1) = rhErr_vect(2, 2);
0094   m1(1, 2) = rhErr_vect(2, 3);
0095   m1(1, 3) = rhErr_vect(2, 4);
0096   m1(2, 0) = rhErr_vect(3, 1);
0097   m1(2, 1) = rhErr_vect(3, 2);
0098   m1(2, 2) = rhErr_vect(3, 3);
0099   m1(2, 3) = rhErr_vect(3, 4);
0100   m1(3, 0) = rhErr_vect(4, 1);
0101   m1(3, 1) = rhErr_vect(4, 2);
0102   m1(3, 2) = rhErr_vect(4, 3);
0103   m1(3, 3) = rhErr_vect(4, 4);
0104 
0105   Tsos4D tsos4d = Tsos4D(tsos);
0106   v2 = tsos4d.paramVector();
0107   m2 = tsos4d.errorMatrix();
0108 }
0109 
0110 double StateSegmentMatcher::value() {
0111   if (match2D) {
0112     AlgebraicVector2 v3(v1_2d - v2_2d);
0113     AlgebraicSymMatrix22 m3(m1_2d + m2_2d + ape_2d);
0114     bool m3i = !m3.Invert();
0115     if (m3i) {
0116       return 1e7;
0117     } else {
0118       estValue = ROOT::Math::Similarity(v3, m3);
0119     }
0120 
0121   } else {
0122     AlgebraicVector4 v3(v1 - v2);
0123     AlgebraicSymMatrix44 m3(m1 + m2 + ape);
0124     bool m3i = !m3.Invert();
0125     if (m3i) {
0126       return 1e7;
0127     } else {
0128       estValue = ROOT::Math::Similarity(v3, m3);
0129     }
0130   }
0131   return estValue;
0132 }
0133 
0134 Tsos4D::Tsos4D(TrajectoryStateOnSurface const &tsos) {
0135   AlgebraicVector5 tsos_v = tsos.localParameters().vector();
0136   tsos_4d[0] = tsos_v[1];
0137   tsos_4d[1] = tsos_v[2];
0138   tsos_4d[2] = tsos_v[3];
0139   tsos_4d[3] = tsos_v[4];
0140 
0141   AlgebraicSymMatrix55 E = tsos.localError().matrix();
0142   tsosErr_44(0, 0) = E(1, 1);
0143   tsosErr_44(0, 1) = E(1, 2);
0144   tsosErr_44(0, 2) = E(1, 3);
0145   tsosErr_44(0, 3) = E(1, 4);
0146   tsosErr_44(1, 0) = E(2, 1);
0147   tsosErr_44(1, 1) = E(2, 2);
0148   tsosErr_44(1, 2) = E(2, 3);
0149   tsosErr_44(1, 3) = E(2, 4);
0150   tsosErr_44(2, 0) = E(3, 1);
0151   tsosErr_44(2, 1) = E(3, 2);
0152   tsosErr_44(2, 2) = E(3, 3);
0153   tsosErr_44(2, 3) = E(3, 4);
0154   tsosErr_44(3, 0) = E(4, 1);
0155   tsosErr_44(3, 1) = E(4, 2);
0156   tsosErr_44(3, 2) = E(4, 3);
0157   tsosErr_44(3, 3) = E(4, 4);
0158 }
0159 
0160 AlgebraicVector4 Tsos4D::paramVector() const { return tsos_4d; }
0161 
0162 AlgebraicSymMatrix44 Tsos4D::errorMatrix() const { return tsosErr_44; }
0163 
0164 Tsos2DPhi::Tsos2DPhi(TrajectoryStateOnSurface const &tsos) {
0165   AlgebraicVector5 tsos_v = tsos.localParameters().vector();
0166   tsos_2d_phi[0] = tsos_v[1];
0167   tsos_2d_phi[1] = tsos_v[3];
0168 
0169   AlgebraicSymMatrix55 E = tsos.localError().matrix();
0170   tsosErr_22_phi(0, 0) = E(1, 1);
0171   tsosErr_22_phi(0, 1) = E(1, 3);
0172   tsosErr_22_phi(1, 0) = E(3, 1);
0173   tsosErr_22_phi(1, 1) = E(3, 3);
0174 }
0175 
0176 AlgebraicVector2 Tsos2DPhi::paramVector() const { return tsos_2d_phi; }
0177 
0178 AlgebraicSymMatrix22 Tsos2DPhi::errorMatrix() const { return tsosErr_22_phi; }
0179 
0180 Tsos2DZed::Tsos2DZed(TrajectoryStateOnSurface const &tsos) {
0181   AlgebraicVector5 tsos_v = tsos.localParameters().vector();
0182   tsos_2d_zed[0] = tsos_v[2];
0183   tsos_2d_zed[1] = tsos_v[4];
0184 
0185   AlgebraicSymMatrix55 E = tsos.localError().matrix();
0186   tsosErr_22_zed(0, 0) = E(2, 2);
0187   tsosErr_22_zed(0, 1) = E(2, 4);
0188   tsosErr_22_zed(1, 0) = E(4, 2);
0189   tsosErr_22_zed(1, 1) = E(4, 4);
0190 }
0191 
0192 AlgebraicVector2 Tsos2DZed::paramVector() const { return tsos_2d_zed; }
0193 
0194 AlgebraicSymMatrix22 Tsos2DZed::errorMatrix() const { return tsosErr_22_zed; }