CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GsfVertexWeightCalculator.cc
Go to the documentation of this file.
3 
4 #include <cfloat>
5 
7  const RefCountedLinearizedTrackState track, double cov) const
8 {
9  double previousWeight = oldVertex.weightInMixture() * track->weightInMixture();
10  // Jacobians
11  const AlgebraicMatrixN3 & a = track->positionJacobian();
12  const AlgebraicMatrixNM & b = track->momentumJacobian();
13 
14  //track information
15  AlgebraicVectorN trackParameters = track->predictedStateParameters();
16  AlgebraicSymMatrixNN trackParametersError = track->predictedStateError();
17  //vertex information
18  AlgebraicSymMatrix33 oldVertexError = oldVertex.error().matrix_new();
19  //Vertex position
20  GlobalPoint oldVertexPosition = oldVertex.position();
21  AlgebraicVector3 oldVertexCoord;
22  oldVertexCoord[0] = oldVertexPosition.x();
23  oldVertexCoord[1] = oldVertexPosition.y();
24  oldVertexCoord[2] = oldVertexPosition.z();
25 
26  // prior momentum information
27  AlgebraicVector3 priorMomentum = track->predictedStateMomentumParameters();
28 
29  AlgebraicSymMatrix33 priorMomentumCov;
30  priorMomentumCov(0,0) = 1.0E-9;
31  priorMomentumCov(1,1) = 1.0E-6;
32  priorMomentumCov(2,2) = 1.0E-6;
33  priorMomentumCov *= cov;
34 
35  AlgebraicVectorN diff = trackParameters - track->constantTerm() -
36  a*oldVertexCoord -b*priorMomentum;
37  track->checkParameters(diff);
38  AlgebraicSymMatrixNN sigmaM = trackParametersError +
39  ROOT::Math::Similarity(a,oldVertexError) +
40  ROOT::Math::Similarity(b,priorMomentumCov);
41 
42  double sigmaDet;
43  sigmaM.Det(sigmaDet);
44  int ifail = ! sigmaM.Invert();
45  if(ifail != 0) {
46  edm::LogWarning("GsfVertexWeightCalculator") << "S matrix inversion failed";
47  return -1.;
48  }
49 
50 
51  double chi = ROOT::Math::Similarity(diff,sigmaM);; //SigmaM is now inverted !!!
52  double weight = pow(2. * M_PI, -0.5 * 5) * sqrt(1./sigmaDet) * exp(-0.5 * chi);
53 
54  if (std::isnan(weight) || sigmaDet<=0.) {
55  edm::LogWarning("GsfVertexWeightCalculator") << "Weight is NaN";
56  return -1.;
57  }
58 
59  return weight*previousWeight;
60 
61 }
LinearizedTrackState< 5 >::AlgebraicMatrixNM AlgebraicMatrixNM
T y() const
Definition: PV3DBase.h:62
GlobalPoint position() const
Definition: VertexState.h:29
const AlgebraicSymMatrix33 & matrix_new() const
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
double weightInMixture() const
Definition: VertexState.h:49
bool isnan(float x)
Definition: math.h:13
T sqrt(T t)
Definition: SSEVec.h:46
T z() const
Definition: PV3DBase.h:63
ROOT::Math::SVector< double, 3 > AlgebraicVector3
double calculate(const VertexState &oldVertex, const RefCountedLinearizedTrackState track, double cov) const
LinearizedTrackState< 5 >::AlgebraicMatrixN3 AlgebraicMatrixN3
#define M_PI
Definition: BFit3D.cc:3
LinearizedTrackState< 5 >::AlgebraicSymMatrixNN AlgebraicSymMatrixNN
double b
Definition: hdecay.h:120
LinearizedTrackState< 5 >::AlgebraicVectorN AlgebraicVectorN
double a
Definition: hdecay.h:121
GlobalError error() const
Definition: VertexState.h:34
T x() const
Definition: PV3DBase.h:61
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40