Go to the documentation of this file.00001 #include "RecoVertex/GaussianSumVertexFit/interface/GsfVertexWeightCalculator.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003
00004 #include <cfloat>
00005
00006 double GsfVertexWeightCalculator::calculate(const VertexState & oldVertex,
00007 const RefCountedLinearizedTrackState track, double cov) const
00008 {
00009 double previousWeight = oldVertex.weightInMixture() * track->weightInMixture();
00010
00011 const AlgebraicMatrixN3 & a = track->positionJacobian();
00012 const AlgebraicMatrixNM & b = track->momentumJacobian();
00013
00014
00015 AlgebraicVectorN trackParameters = track->predictedStateParameters();
00016 AlgebraicSymMatrixNN trackParametersError = track->predictedStateError();
00017
00018 AlgebraicSymMatrix33 oldVertexError = oldVertex.error().matrix_new();
00019 AlgebraicSymMatrix33 oldVertexWeight = oldVertex.weight().matrix_new();
00020
00021 GlobalPoint oldVertexPosition = oldVertex.position();
00022 AlgebraicVector3 oldVertexCoord;
00023 oldVertexCoord[0] = oldVertexPosition.x();
00024 oldVertexCoord[1] = oldVertexPosition.y();
00025 oldVertexCoord[2] = oldVertexPosition.z();
00026
00027
00028 AlgebraicVector3 priorMomentum = track->predictedStateMomentumParameters();
00029
00030 AlgebraicSymMatrix33 priorMomentumCov;
00031 priorMomentumCov(0,0) = 1.0E-9;
00032 priorMomentumCov(1,1) = 1.0E-6;
00033 priorMomentumCov(2,2) = 1.0E-6;
00034 priorMomentumCov *= cov;
00035
00036 AlgebraicVectorN diff = trackParameters - track->constantTerm() -
00037 a*oldVertexCoord -b*priorMomentum;
00038 track->checkParameters(diff);
00039 AlgebraicSymMatrixNN sigmaM = trackParametersError +
00040 ROOT::Math::Similarity(a,oldVertexError) +
00041 ROOT::Math::Similarity(b,priorMomentumCov);
00042
00043 double sigmaDet;
00044 sigmaM.Det(sigmaDet);
00045 int ifail = ! sigmaM.Invert();
00046 if(ifail != 0) {
00047 edm::LogWarning("GsfVertexWeightCalculator") << "S matrix inversion failed";
00048 return -1.;
00049 }
00050
00051
00052 double chi = ROOT::Math::Similarity(diff,sigmaM);;
00053 double weight = pow(2. * M_PI, -0.5 * 5) * sqrt(1./sigmaDet) * exp(-0.5 * chi);
00054
00055 if (std::isnan(weight) || sigmaDet<=0.) {
00056 edm::LogWarning("GsfVertexWeightCalculator") << "Weight is NaN";
00057 return -1.;
00058 }
00059
00060 return weight*previousWeight;
00061
00062 }