CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/TrackingTools/KalmanUpdators/src/Chi2StripEstimator.cc

Go to the documentation of this file.
00001 #include "TrackingTools/KalmanUpdators/interface/Chi2StripEstimator.h"
00002 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00003 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00004 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "DataFormats/Math/interface/invertPosDefMatrix.h"
00007 
00008 using namespace std;
00009 
00010 pair<bool,double>
00011 Chi2StripEstimator::estimate(const TrajectoryStateOnSurface& state,
00012                              const TransientTrackingRecHit& hit) const {
00013 
00014   if(//hit.isMatched() || 
00015      hit.detUnit()->type().isTrackerPixel()) {
00016     return HitReturnType(false,0);
00017   }
00018 
00019   const StripTopology* topology = 
00020     dynamic_cast<const StripTopology*>(&(hit.detUnit()->topology())); 
00021 
00022   MeasurementPoint mp;
00023   MeasurementError me;
00024 
00025   AlgebraicVector2 m;
00026   mp = topology->measurementPosition(hit.localPosition());
00027   m[0] = mp.x();
00028   m[1] = mp.y();
00029   
00030   AlgebraicSymMatrix22 V;
00031   me = topology->measurementError(hit.localPosition(),
00032                                   hit.localPositionError());
00033  
00034   V(0,0) = me.uu();
00035   V(1,0) = me.uv();
00036   V(1,1) = me.vv();
00037 
00038   AlgebraicVector2 x;
00039   mp = topology->measurementPosition(state.localPosition());
00040   m[0] = mp.x();
00041   m[1] = mp.y();
00042   
00043   AlgebraicSymMatrix22 C;
00044   me = topology->measurementError(state.localPosition(),
00045                                   state.localError().positionError());
00046   C(0,0) = me.uu();
00047   C(1,0) = me.uv();
00048   C(1,1) = me.vv();
00049 
00050   AlgebraicVector2 r(m - x);
00051   AlgebraicSymMatrix22 R(V+C);
00052   bool ierr =  !invertPosDefMatrix(R);
00053   if (ierr) {
00054     edm::LogError("Chi2StripEstimator")<<" could not invert matrix:\n"<<(V+C);
00055     return returnIt( 0.0 );
00056   }
00057 
00058   double est = max(ROOT::Math::Similarity(r, R), 0.000001); // avoid exact zero
00059 
00060   return returnIt( est);
00061 }
00062