CMS 3D CMS Logo

KFUpdator.cc
Go to the documentation of this file.
9 
10 namespace {
11 
12 template <unsigned int D>
14  const TrackingRecHit& aRecHit) {
15 
16  typedef typename AlgebraicROOTObject<D,5>::Matrix MatD5;
17  typedef typename AlgebraicROOTObject<5,D>::Matrix Mat5D;
18  typedef typename AlgebraicROOTObject<D,D>::SymMatrix SMatDD;
19  typedef typename AlgebraicROOTObject<D>::Vector VecD;
20  using ROOT::Math::SMatrixNoInit;
21  double pzSign = tsos.localParameters().pzSign();
22 
23  auto && x = tsos.localParameters().vector();
24  auto && C = tsos.localError().matrix();
25 
26  // projection matrix (assume element of "H" to be just 0 or 1)
28 
29  // Measurement matrix
30  VecD r, rMeas;
31  SMatDD V(SMatrixNoInit{}), VMeas(SMatrixNoInit{});
32 
33  KfComponentsHolder holder;
34  holder.template setup<D>(&r, &V, &pf, &rMeas, &VMeas, x, C);
35  aRecHit.getKfComponents(holder);
36 
37  r -= rMeas;
38 
39  // and covariance matrix of residuals
40  SMatDD R = V + VMeas;
41  bool ok = invertPosDefMatrix(R);
42 
43  // Compute Kalman gain matrix
45  Mat5D K = C*pf.project(R);
46  pf.projectAndSubtractFrom(M,K);
47 
48 
49  // Compute local filtered state vector
50  AlgebraicVector5 fsv = x + K * r;
51  // Compute covariance matrix of local filtered state vector
52  AlgebraicSymMatrix55 fse = ROOT::Math::Similarity(M, C) + ROOT::Math::Similarity(K, V);
53 
54 
55  /*
56  // expanded similariy
57  AlgebraicSymMatrix55 fse;
58  ROOT::Math::AssignSym::Evaluate(fse, (M* C) * ( ROOT::Math::Transpose(M)));
59  AlgebraicSymMatrix55 tmp;
60  ROOT::Math::AssignSym::Evaluate(tmp, (K*V) * (ROOT::Math::Transpose(K)));
61  fse += tmp;
62  */
63 
64  if (ok) {
66  LocalTrajectoryError(fse), tsos.surface(),&(tsos.globalParameters().magneticField()), tsos.surfaceSide() );
67  }else {
68  edm::LogError("KFUpdator")<<" could not invert martix:\n"<< (V+VMeas);
69  return TrajectoryStateOnSurface();
70  }
71 
72 }
73 }
74 
76  const TrackingRecHit& aRecHit) const {
77  switch (aRecHit.dimension()) {
78  case 1: return lupdate<1>(tsos,aRecHit);
79  case 2: return lupdate<2>(tsos,aRecHit);
80  case 3: return lupdate<3>(tsos,aRecHit);
81  case 4: return lupdate<4>(tsos,aRecHit);
82  case 5: return lupdate<5>(tsos,aRecHit);
83  }
84  throw cms::Exception("Rec hit of invalid dimension (not 1,2,3,4,5)") <<
85  "The value was " << aRecHit.dimension() <<
86  ", type is " << typeid(aRecHit).name() << "\n";
87 }
88 
virtual void getKfComponents(KfComponentsHolder &holder) const
ROOT::Math::SMatrix< double, D1, D1, ROOT::Math::MatRepSym< double, D1 > > SymMatrix
const LocalTrajectoryParameters & localParameters() const
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
AlgebraicVector5 vector() const
ROOT::Math::SMatrix< double, D1, D2, ROOT::Math::MatRepStd< double, D1, D2 > > Matrix
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
Definition: KFUpdator.cc:75
const SurfaceType & surface() const
virtual int dimension() const =0
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
ROOT::Math::SVector< double, D1 > Vector
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const GlobalTrajectoryParameters & globalParameters() const
const MagneticField & magneticField() const
float pzSign() const
Sign of the z-component of the momentum in the local frame.
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55