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"
7 
8 
9 template <unsigned int N>
12  (const CachingVertex<N> & vertex , RefCountedVertexTrack track) const
13 
14 {
15  trackMatrixPair thePair =
16  trackRefit(vertex.vertexState(), track->linearizedTrack(), track->weight() );
17 
18  VertexState rVert = updator.positionUpdate (vertex.vertexState(), track->linearizedTrack(),
19  track->weight(), -1);
20 
21  std::pair<bool, double> result = helper.trackParameterChi2(track->linearizedTrack(), thePair.first);
22  float smoothedChi2 = helper.vertexChi2(rVert, vertex.vertexState()) + result.second;
23 
24  return theVTFactory.vertexTrack(track->linearizedTrack(),
25  vertex.vertexState(), thePair.first, smoothedChi2, thePair.second,
26  track->weight());
27 }
28 
29 template <unsigned int N>
33  float weight) const
34 
35 {
36  typedef ROOT::Math::SVector<double,N> AlgebraicVectorN;
37  typedef ROOT::Math::SVector<double,N-2> AlgebraicVectorM;
38  typedef ROOT::Math::SMatrix<double,N,3,ROOT::Math::MatRepStd<double,N,3> > AlgebraicMatrixN3;
39  typedef ROOT::Math::SMatrix<double,N,N-2,ROOT::Math::MatRepStd<double,N,N-2> > AlgebraicMatrixNM;
40  typedef ROOT::Math::SMatrix<double,N-2,3,ROOT::Math::MatRepStd<double,N-2,3> > AlgebraicMatrixM3;
41  typedef ROOT::Math::SMatrix<double,N,N,ROOT::Math::MatRepSym<double,N> > AlgebraicSymMatrixNN;
42 // typedef ROOT::Math::SMatrix<double,N+1,N+1,ROOT::Math::MatRepSym<double,N+1> > AlgebraicSymMatrixOO;
43  typedef ROOT::Math::SMatrix<double,N+1,N+1,ROOT::Math::MatRepStd<double,N+1,N+1> > AlgebraicMatrixOO;
44  typedef ROOT::Math::SMatrix<double,N-2,N-2,ROOT::Math::MatRepSym<double,N-2> > AlgebraicSymMatrixMM;
45 
46  //Vertex position
47  GlobalPoint vertexPosition = vertex.position();
48 
49  AlgebraicVector3 vertexCoord;
50  vertexCoord(0) = vertexPosition.x();
51  vertexCoord(1) = vertexPosition.y();
52  vertexCoord(2) = vertexPosition.z();
53  AlgebraicSymMatrix33 vertexErrorMatrix = vertex.error().matrix_new();
54 
55 //track information
56  const AlgebraicMatrixN3 & a = linTrackState->positionJacobian();
57  const AlgebraicMatrixNM & b = linTrackState->momentumJacobian();
58 
59 // AlgebraicVectorN trackParameters =
60 // linTrackState->predictedStateParameters();
61 
62  int ifail;
63  AlgebraicSymMatrixNN trackParametersWeight =
64  linTrackState->predictedStateWeight(ifail);
65 
66  AlgebraicSymMatrixMM s = ROOT::Math::SimilarityT(b,trackParametersWeight);
67 
68  ifail = ! s.Invert();
69  if(ifail !=0) throw VertexException
70  ("KalmanVertexTrackUpdator::S matrix inversion failed");
71 
72  AlgebraicVectorM newTrackMomentumP = s * (ROOT::Math::Transpose(b)) * trackParametersWeight *
73  (linTrackState->predictedStateParameters() - linTrackState->constantTerm() - a*vertexCoord);
74 
75  AlgebraicMatrix3M refittedPositionMomentumConvariance =
76  -vertexErrorMatrix * (ROOT::Math::Transpose(a)) * trackParametersWeight * b * s;
77 
78  AlgebraicSymMatrixMM refittedMomentumConvariance = s/weight +
79  ROOT::Math::SimilarityT(refittedPositionMomentumConvariance, vertex.weight().matrix_new());
80 
81 
82  // int matrixSize = 3+3; //refittedMomentumConvariance.num_col();
83  AlgebraicMatrixOO covMatrix; //(matrixSize, matrixSize);
84  covMatrix.Place_at(refittedPositionMomentumConvariance, 0, 3);
85  covMatrix.Place_at(ROOT::Math::Transpose(refittedPositionMomentumConvariance), 3, 0);
86  covMatrix.Place_at(vertexErrorMatrix, 0, 0);
87  covMatrix.Place_at(refittedMomentumConvariance, 3 ,3);
88 
89  AlgebraicSymMatrixOO covSymMatrix(covMatrix.LowerBlock());
90 
91  RefCountedRefittedTrackState refittedTrackState = linTrackState->
92  createRefittedTrackState(vertexPosition, newTrackMomentumP, covSymMatrix);
93 
94  return trackMatrixPair(refittedTrackState, covSymMatrix);
95 // (refittedTrackState, refittedPositionMomentumConvariance);
96 }
97 
98 template class KalmanVertexTrackUpdator<5>;
99 template class KalmanVertexTrackUpdator<6>;
VertexState vertexState() const
Definition: CachingVertex.h:85
Common base class.
T y() const
Definition: PV3DBase.h:62
GlobalPoint position() const
Definition: VertexState.h:29
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:63
tuple result
Definition: query.py:137
ROOT::Math::SVector< double, 3 > AlgebraicVector3
GlobalWeight weight() const
Definition: VertexState.h:39
#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:34
T x() const
Definition: PV3DBase.h:61