CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/RecoMuon/GlobalTrackingTools/src/StateSegmentMatcher.cc

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