00001 00015 #include "RecoMuon/GlobalTrackingTools/interface/StateSegmentMatcher.h" 00016 00017 using namespace std; 00018 00019 00020 00021 StateSegmentMatcher::StateSegmentMatcher(TrajectoryStateOnSurface* tsos, DTRecSegment4D* dtseg4d) 00022 { 00023 if (dtseg4d->hasPhi() && dtseg4d->hasZed()) { 00024 00025 match2D = false; 00026 AlgebraicVector dtseg = dtseg4d->parameters(); 00027 v1[0] = dtseg[0]; 00028 v1[1] = dtseg[1]; 00029 v1[2] = dtseg[2]; 00030 v1[3] = dtseg[3]; 00031 00032 AlgebraicSymMatrix rhErr_vect = dtseg4d->parametersError(); 00033 m1(0,0) = rhErr_vect(1,1); m1(0,1) = rhErr_vect(1,2); m1(0,2) = rhErr_vect(1,3);m1(0,3) = rhErr_vect(1,4); 00034 m1(1,0) = rhErr_vect(2,1); m1(1,1) = rhErr_vect(2,2); m1(1,2) = rhErr_vect(2,3);m1(1,3) = rhErr_vect(2,4); 00035 m1(2,0) = rhErr_vect(3,1); m1(2,1) = rhErr_vect(3,2); m1(2,2) = rhErr_vect(3,3);m1(2,3) = rhErr_vect(3,4); 00036 m1(3,0) = rhErr_vect(4,1); m1(3,1) = rhErr_vect(4,2); m1(3,2) = rhErr_vect(4,3);m1(3,3) = rhErr_vect(4,4); 00037 00038 Tsos4D tsos4d = Tsos4D(tsos); 00039 v2 = tsos4d.paramVector(); 00040 m2 = tsos4d.errorMatrix(); 00041 00042 } else { 00043 00044 match2D = true; 00045 AlgebraicVector dtseg = dtseg4d->parameters(); 00046 v1_2d[0] = dtseg[0]; 00047 v1_2d[1] = dtseg[1]; 00048 00049 AlgebraicSymMatrix rhErr_vect = dtseg4d->parametersError(); 00050 m1_2d(0,0) = rhErr_vect(1,1); m1_2d(0,1) = rhErr_vect(1,2); 00051 m1_2d(1,0) = rhErr_vect(2,1); m1_2d(1,1) = rhErr_vect(2,2); 00052 00053 00054 if (dtseg4d->hasPhi()) { 00055 Tsos2DPhi tsos2d = Tsos2DPhi(tsos); 00056 v2_2d = tsos2d.paramVector(); 00057 m2_2d = tsos2d.errorMatrix(); 00058 } 00059 00060 if (dtseg4d->hasZed()) { 00061 Tsos2DZed tsos2d = Tsos2DZed(tsos); 00062 v2_2d = tsos2d.paramVector(); 00063 m2_2d = tsos2d.errorMatrix(); 00064 } 00065 } 00066 } 00067 00068 00069 00070 StateSegmentMatcher::StateSegmentMatcher(TrajectoryStateOnSurface* tsos, CSCSegment* cscseg4d) 00071 { 00072 match2D = false; 00073 AlgebraicVector cscseg = cscseg4d->parameters(); 00074 v1[0] = cscseg[0]; 00075 v1[1] = cscseg[1]; 00076 v1[2] = cscseg[2]; 00077 v1[3] = cscseg[3]; 00078 00079 AlgebraicSymMatrix rhErr_vect = cscseg4d->parametersError(); 00080 m1(0,0) = rhErr_vect(1,1);m1(0,1) = rhErr_vect(1,2);m1(0,2) = rhErr_vect(1,3);m1(0,3) = rhErr_vect(1,4); 00081 m1(1,0) = rhErr_vect(2,1);m1(1,1) = rhErr_vect(2,2);m1(1,2) = rhErr_vect(2,3);m1(1,3) = rhErr_vect(2,4); 00082 m1(2,0) = rhErr_vect(3,1);m1(2,1) = rhErr_vect(3,2);m1(2,2) = rhErr_vect(3,3);m1(2,3) = rhErr_vect(3,4); 00083 m1(3,0) = rhErr_vect(4,1);m1(3,1) = rhErr_vect(4,2);m1(3,2) = rhErr_vect(4,3);m1(3,3) = rhErr_vect(4,4); 00084 00085 00086 Tsos4D tsos4d = Tsos4D(tsos); 00087 v2 = tsos4d.paramVector(); 00088 m2 = tsos4d.errorMatrix(); 00089 } 00090 00091 00092 00093 double StateSegmentMatcher::value() 00094 { 00095 if (match2D) { 00096 AlgebraicVector2 v3(v1_2d - v2_2d); 00097 AlgebraicSymMatrix22 m3(m1_2d + m2_2d); 00098 bool m3i = !m3.Invert(); 00099 if ( m3i ) { 00100 return 1e7; 00101 } else { 00102 estValue = ROOT::Math::Similarity(v3,m3); 00103 } 00104 00105 } else { 00106 AlgebraicVector4 v3(v1 - v2); 00107 AlgebraicSymMatrix44 m3(m1 + m2); 00108 bool m3i = !m3.Invert(); 00109 if ( m3i ) { 00110 return 1e7; 00111 } else { 00112 estValue = ROOT::Math::Similarity(v3,m3); 00113 } 00114 } 00115 return estValue; 00116 } 00117 00118 00119 Tsos4D::Tsos4D(TrajectoryStateOnSurface* tsos) 00120 { 00121 AlgebraicVector5 tsos_v = tsos->localParameters().vector(); 00122 tsos_4d[0] = tsos_v[1]; 00123 tsos_4d[1] = tsos_v[2]; 00124 tsos_4d[2] = tsos_v[3]; 00125 tsos_4d[3] = tsos_v[4]; 00126 00127 AlgebraicSymMatrix55 E = tsos->localError().matrix(); 00128 tsosErr_44(0,0) = E(1,1);tsosErr_44(0,1) = E(1,2);tsosErr_44(0,2) = E(1,3);tsosErr_44(0,3) = E(1,4); 00129 tsosErr_44(1,0) = E(2,1);tsosErr_44(1,1) = E(2,2);tsosErr_44(1,2) = E(2,3);tsosErr_44(1,3) = E(2,4); 00130 tsosErr_44(2,0) = E(3,1);tsosErr_44(2,1) = E(3,2);tsosErr_44(2,2) = E(3,3);tsosErr_44(2,3) = E(3,4); 00131 tsosErr_44(3,0) = E(4,1);tsosErr_44(3,1) = E(4,2);tsosErr_44(3,2) = E(4,3);tsosErr_44(3,3) = E(4,4); 00132 } 00133 00134 00135 AlgebraicVector4 Tsos4D::paramVector() const {return tsos_4d;} 00136 00137 00138 AlgebraicSymMatrix44 Tsos4D::errorMatrix() const {return tsosErr_44;} 00139 00140 00141 00142 Tsos2DPhi::Tsos2DPhi(TrajectoryStateOnSurface* tsos) 00143 { 00144 AlgebraicVector5 tsos_v = tsos->localParameters().vector(); 00145 tsos_2d_phi[0] = tsos_v[1]; 00146 tsos_2d_phi[1] = tsos_v[3]; 00147 00148 AlgebraicSymMatrix55 E = tsos->localError().matrix(); 00149 tsosErr_22_phi(0,0) = E(1,1);tsosErr_22_phi(0,1) = E(1,3); 00150 tsosErr_22_phi(1,0) = E(3,1);tsosErr_22_phi(1,1) = E(3,3); 00151 } 00152 00153 00154 AlgebraicVector2 Tsos2DPhi::paramVector() const {return tsos_2d_phi;} 00155 00156 00157 AlgebraicSymMatrix22 Tsos2DPhi::errorMatrix() const {return tsosErr_22_phi;} 00158 00159 00160 00161 Tsos2DZed::Tsos2DZed(TrajectoryStateOnSurface* tsos) 00162 { 00163 AlgebraicVector5 tsos_v = tsos->localParameters().vector(); 00164 tsos_2d_zed[0] = tsos_v[2]; 00165 tsos_2d_zed[1] = tsos_v[4]; 00166 00167 AlgebraicSymMatrix55 E = tsos->localError().matrix(); 00168 tsosErr_22_zed(0,0) = E(2,2);tsosErr_22_zed(0,1) = E(2,4); 00169 tsosErr_22_zed(1,0) = E(4,2);tsosErr_22_zed(1,1) = E(4,4); 00170 } 00171 00172 00173 AlgebraicVector2 Tsos2DZed::paramVector() const {return tsos_2d_zed;} 00174 00175 00176 AlgebraicSymMatrix22 Tsos2DZed::errorMatrix() const {return tsosErr_22_zed;}