CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
KalmanVertexTrackUpdator.cc
Go to the documentation of this file.
3 //#include "Utilities/GenUtil/interface/ReferenceCountingPointer.h"
8 
9 #include<iostream>
10 
11 
12 template <unsigned int N>
15  (const CachingVertex<N> & vertex , RefCountedVertexTrack track) const
16 
17 {
18  trackMatrixPair thePair =
19  trackRefit(vertex.vertexState(), track->linearizedTrack(), track->weight() );
20 
21  VertexState rVert = updator.positionUpdate (vertex.vertexState(), track->linearizedTrack(),
22  track->weight(), -1);
23 
24  std::pair<bool, double> result = helper.trackParameterChi2(track->linearizedTrack(), thePair.first);
25  float smoothedChi2 = helper.vertexChi2(rVert, vertex.vertexState()) + result.second;
26 
27  return theVTFactory.vertexTrack(track->linearizedTrack(),
28  vertex.vertexState(), thePair.first, smoothedChi2, thePair.second,
29  track->weight());
30 }
31 
32 template <unsigned int N>
36  float weight) const
37 {
38  typedef ROOT::Math::SVector<double,N> AlgebraicVectorN;
39  typedef ROOT::Math::SVector<double,N-2> AlgebraicVectorM;
40  typedef ROOT::Math::SMatrix<double,N,3,ROOT::Math::MatRepStd<double,N,3> > AlgebraicMatrixN3;
41  typedef ROOT::Math::SMatrix<double,3,N,ROOT::Math::MatRepStd<double,3,N> > AlgebraicMatrix3N;
42  typedef ROOT::Math::SMatrix<double,3,N-2,ROOT::Math::MatRepStd<double,3,N-2> > AlgebraicMatrix3M;
43  typedef ROOT::Math::SMatrix<double,N,N-2,ROOT::Math::MatRepStd<double,N,N-2> > AlgebraicMatrixNM;
44  typedef ROOT::Math::SMatrix<double,N-2,3,ROOT::Math::MatRepStd<double,N-2,3> > AlgebraicMatrixM3;
45  typedef ROOT::Math::SMatrix<double,N,N,ROOT::Math::MatRepSym<double,N> > AlgebraicSymMatrixNN;
46 // typedef ROOT::Math::SMatrix<double,N+1,N+1,ROOT::Math::MatRepSym<double,N+1> > AlgebraicSymMatrixOO;
47  typedef ROOT::Math::SMatrix<double,N+1,N+1,ROOT::Math::MatRepStd<double,N+1,N+1> > AlgebraicMatrixOO;
48  typedef ROOT::Math::SMatrix<double,N-2,N-2,ROOT::Math::MatRepSym<double,N-2> > AlgebraicSymMatrixMM;
49 
50  //Vertex position
51  GlobalPoint vertexPosition = vertex.position();
52 
53  AlgebraicVector3 vertexCoord;
54  vertexCoord(0) = vertexPosition.x();
55  vertexCoord(1) = vertexPosition.y();
56  vertexCoord(2) = vertexPosition.z();
57  const AlgebraicSymMatrix33 vertexErrorMatrix = vertex.error().matrix_new();
58 
59 //track information
60  const AlgebraicMatrixN3 a = linTrackState->positionJacobian();
61  const AlgebraicMatrixNM b = linTrackState->momentumJacobian();
62 
63 // AlgebraicVectorN trackParameters =
64 // linTrackState->predictedStateParameters();
65 
66  int ifail;
67  AlgebraicSymMatrixNN trackParametersWeight =
68  linTrackState->predictedStateWeight(ifail);
69 
70  AlgebraicSymMatrixMM s = ROOT::Math::SimilarityT(b,trackParametersWeight);
71 
72  if (!invertPosDefMatrix(s))
73  throw VertexException
74  ("KalmanVertexTrackUpdator::S matrix inversion failed");
75 
76  // NN NM MM
77  AlgebraicMatrixNM twbs = trackParametersWeight * b * s;
78 
79 
80  AlgebraicVectorN vv =
81  linTrackState->predictedStateParameters() - linTrackState->constantTerm() - a*vertexCoord;
82  // MM MN NN
83  // AlgebraicVectorM newTrackMomentumP = s * (ROOT::Math::Transpose(b)) * trackParametersWeight * vv;
84  AlgebraicVectorM newTrackMomentumP = ROOT::Math::Transpose(twbs) * vv;
85 
86  //AlgebraicMatrix3M refittedPositionMomentumConvariance =
87  // 33 3N NN NM MM
88  // -vertexErrorMatrix * (ROOT::Math::Transpose(a)) * trackParametersWeight * b * s;
89 
90  AlgebraicMatrix3N tmpM1 = -vertexErrorMatrix * (ROOT::Math::Transpose(a));
91  AlgebraicMatrix3M refittedPositionMomentumConvariance = tmpM1 * twbs;
92 
93  AlgebraicSymMatrixMM refittedMomentumConvariance = s/weight +
94  ROOT::Math::SimilarityT(refittedPositionMomentumConvariance, vertex.weight().matrix_new());
95 
96 
97  // int matrixSize = 3+3; //refittedMomentumConvariance.num_col();
98  AlgebraicMatrixOO covMatrix; //(matrixSize, matrixSize);
99  covMatrix.Place_at(refittedPositionMomentumConvariance, 0, 3);
100  covMatrix.Place_at(ROOT::Math::Transpose(refittedPositionMomentumConvariance), 3, 0);
101  covMatrix.Place_at(vertexErrorMatrix, 0, 0);
102  covMatrix.Place_at(refittedMomentumConvariance, 3 ,3);
103 
104  AlgebraicSymMatrixOO covSymMatrix(covMatrix.LowerBlock());
105 
106  RefCountedRefittedTrackState refittedTrackState = linTrackState->
107  createRefittedTrackState(vertexPosition, newTrackMomentumP, covSymMatrix);
108 
109  return trackMatrixPair(refittedTrackState, covSymMatrix);
110 // (refittedTrackState, refittedPositionMomentumConvariance);
111 }
112 
113 template class KalmanVertexTrackUpdator<5>;
114 template class KalmanVertexTrackUpdator<6>;
Common base class.
VertexState const & vertexState() const
Definition: CachingVertex.h:85
T y() const
Definition: PV3DBase.h:63
GlobalPoint position() const
Definition: VertexState.h:50
const AlgebraicSymMatrix33 & matrix_new() const
ROOT::Math::SMatrix< double, N+1, N+1, ROOT::Math::MatRepSym< double, N+1 > > AlgebraicSymMatrixOO
std::pair< RefCountedRefittedTrackState, AlgebraicSymMatrixOO > trackMatrixPair
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
ROOT::Math::SVector< double, 3 > AlgebraicVector3
GlobalWeight weight() const
Definition: VertexState.h:60
#define N
Definition: blowfish.cc:9
ROOT::Math::SMatrix< double, 3, N-2, ROOT::Math::MatRepStd< double, 3, N-2 > > AlgebraicMatrix3M
double b
Definition: hdecay.h:120
RefCountedVertexTrack update(const CachingVertex< N > &vertex, RefCountedVertexTrack track) const
double a
Definition: hdecay.h:121
trackMatrixPair trackRefit(const VertexState &vertex, RefCountedLinearizedTrackState linTrackState, float weight) const
GlobalError error() const
Definition: VertexState.h:55
T x() const
Definition: PV3DBase.h:62