CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoVertex/GhostTrackFitter/src/VertexGhostTrackState.cc

Go to the documentation of this file.
00001 #include <cmath>
00002 
00003 #include <Math/SMatrix.h>
00004 #include <Math/MatrixFunctions.h>
00005 
00006 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00007 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00008 
00009 #include "RecoVertex/GhostTrackFitter/interface/GhostTrackPrediction.h"
00010 
00011 #include "RecoVertex/GhostTrackFitter/interface/VertexGhostTrackState.h"
00012 
00013 using namespace reco;
00014 
00015 namespace {
00016         static inline double sqr(double arg) { return arg * arg; }
00017 
00018         using namespace ROOT::Math;
00019 
00020         typedef SVector<double, 3> Vector3;
00021 
00022         typedef SMatrix<double, 3, 3, MatRepSym<double, 3> > Matrix3S;
00023         typedef SMatrix<double, 6, 6, MatRepSym<double, 6> > Matrix6S;
00024         typedef SMatrix<double, 3, 3> Matrix33;
00025         typedef SMatrix<double, 3, 6> Matrix36;
00026 
00027         static inline Vector3 conv(const GlobalVector &vec)
00028         {
00029                 Vector3 result;
00030                 result[0] = vec.x();
00031                 result[1] = vec.y();
00032                 result[2] = vec.z();
00033                 return result;
00034         }
00035 }
00036 
00037 BasicGhostTrackState::Vertex VertexGhostTrackState::vertexStateOnGhostTrack(
00038         const GhostTrackPrediction &pred, bool withMeasurementError) const
00039 {
00040         using namespace ROOT::Math;
00041 
00042         GlobalPoint origin = pred.origin();
00043         GlobalVector direction = pred.direction();
00044 
00045         double rho2 = pred.rho2();
00046         double rho = std::sqrt(rho2);
00047         double lambda = (position_ - origin) * direction / rho2;
00048         GlobalPoint pos = origin + lambda * direction;
00049 
00050         Vector3 b = conv(direction) / rho;
00051         Vector3 ca = conv(position_ - pos);
00052 
00053         Matrix33 pA = TensorProd(b, b);
00054         Matrix33 pB = TensorProd(b, ca);
00055 
00056         Matrix36 jacobian;
00057         jacobian.Place_at(-pA + Matrix33(SMatrixIdentity()), 0, 0);
00058         jacobian.Place_at(pB / rho, 0, 3);
00059         Matrix3S error = Similarity(jacobian, pred.cartesianError(lambda));
00060 
00061         if (withMeasurementError)
00062                 error += Similarity(pA, covariance_);
00063 
00064         return Vertex(pos, error);
00065 }
00066 
00067 BasicGhostTrackState::Vertex VertexGhostTrackState::vertexStateOnMeasurement(
00068         const GhostTrackPrediction &pred, bool withGhostTrackError) const
00069 {
00070         return Vertex(position_, covariance_);
00071 }