CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Attributes
KalmanVertexUpdator< N > Class Template Reference

#include <KalmanVertexUpdator.h>

Inheritance diagram for KalmanVertexUpdator< N >:
VertexUpdator< N >

Public Types

typedef VertexTrack< N >::RefCountedLinearizedTrackState RefCountedLinearizedTrackState
 
typedef CachingVertex< N >::RefCountedVertexTrack RefCountedVertexTrack
 
- Public Types inherited from VertexUpdator< N >
typedef CachingVertex< N >::RefCountedVertexTrack RefCountedVertexTrack
 

Public Member Functions

CachingVertex< Nadd (const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track) const override
 
std::pair< bool, double > chi2Increment (const VertexState &oldVertex, const VertexState &newVertexState, const RefCountedLinearizedTrackState linearizedTrack, float weight) const
 
VertexUpdator< N > * clone () const override
 
VertexState positionUpdate (const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
 
CachingVertex< Nremove (const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track) const override
 
CachingVertex< Nupdate (const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track, float weight, int sign) const
 
- Public Member Functions inherited from VertexUpdator< N >
virtual CachingVertex< Nadd (const CachingVertex< N > &v, const typename CachingVertex< N >::RefCountedVertexTrack t) const =0
 
virtual CachingVertex< Nremove (const CachingVertex< N > &v, const typename CachingVertex< N >::RefCountedVertexTrack t) const =0
 
 VertexUpdator ()
 
virtual ~VertexUpdator ()
 

Private Types

typedef ROOT::Math::SMatrix< double, N - 2, 3, ROOT::Math::MatRepStd< double, N - 2, 3 > > AlgebraicMatrixM3
 
typedef ROOT::Math::SMatrix< double, N, 3, ROOT::Math::MatRepStd< double, N, 3 > > AlgebraicMatrixN3
 
typedef ROOT::Math::SMatrix< double, N, N - 2, ROOT::Math::MatRepStd< double, N, N - 2 > > AlgebraicMatrixNM
 
typedef ROOT::Math::SMatrix< double, N+1, N+1, ROOT::Math::MatRepStd< double, N+1, N+1 > > AlgebraicMatrixOO
 
typedef ROOT::Math::SMatrix< double, N - 2, N - 2, ROOT::Math::MatRepSym< double, N - 2 > > AlgebraicSymMatrixMM
 
typedef ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > AlgebraicSymMatrixNN
 
typedef ROOT::Math::SMatrix< double, N+1, N+1, ROOT::Math::MatRepSym< double, N+1 > > AlgebraicSymMatrixOO
 
typedef ROOT::Math::SVector< double, N - 2 > AlgebraicVectorM
 
typedef ROOT::Math::SVector< double, NAlgebraicVectorN
 

Private Attributes

KVFHelper< Nhelper
 

Detailed Description

template<unsigned int N>
class KalmanVertexUpdator< N >

Vertex updator for the Kalman vertex filter. (c.f. R. Fruewirth et.al., Comp.Phys.Comm 96 (1996) 189

Definition at line 13 of file KalmanVertexUpdator.h.

Member Typedef Documentation

◆ AlgebraicMatrixM3

template<unsigned int N>
typedef ROOT::Math::SMatrix<double, N - 2, 3, ROOT::Math::MatRepStd<double, N - 2, 3> > KalmanVertexUpdator< N >::AlgebraicMatrixM3
private

Definition at line 62 of file KalmanVertexUpdator.h.

◆ AlgebraicMatrixN3

template<unsigned int N>
typedef ROOT::Math::SMatrix<double, N, 3, ROOT::Math::MatRepStd<double, N, 3> > KalmanVertexUpdator< N >::AlgebraicMatrixN3
private

Definition at line 60 of file KalmanVertexUpdator.h.

◆ AlgebraicMatrixNM

template<unsigned int N>
typedef ROOT::Math::SMatrix<double, N, N - 2, ROOT::Math::MatRepStd<double, N, N - 2> > KalmanVertexUpdator< N >::AlgebraicMatrixNM
private

Definition at line 61 of file KalmanVertexUpdator.h.

◆ AlgebraicMatrixOO

template<unsigned int N>
typedef ROOT::Math::SMatrix<double, N + 1, N + 1, ROOT::Math::MatRepStd<double, N + 1, N + 1> > KalmanVertexUpdator< N >::AlgebraicMatrixOO
private

Definition at line 65 of file KalmanVertexUpdator.h.

◆ AlgebraicSymMatrixMM

template<unsigned int N>
typedef ROOT::Math::SMatrix<double, N - 2, N - 2, ROOT::Math::MatRepSym<double, N - 2> > KalmanVertexUpdator< N >::AlgebraicSymMatrixMM
private

Definition at line 66 of file KalmanVertexUpdator.h.

◆ AlgebraicSymMatrixNN

template<unsigned int N>
typedef ROOT::Math::SMatrix<double, N, N, ROOT::Math::MatRepSym<double, N> > KalmanVertexUpdator< N >::AlgebraicSymMatrixNN
private

Definition at line 63 of file KalmanVertexUpdator.h.

◆ AlgebraicSymMatrixOO

template<unsigned int N>
typedef ROOT::Math::SMatrix<double, N + 1, N + 1, ROOT::Math::MatRepSym<double, N + 1> > KalmanVertexUpdator< N >::AlgebraicSymMatrixOO
private

Definition at line 64 of file KalmanVertexUpdator.h.

◆ AlgebraicVectorM

template<unsigned int N>
typedef ROOT::Math::SVector<double, N - 2> KalmanVertexUpdator< N >::AlgebraicVectorM
private

Definition at line 59 of file KalmanVertexUpdator.h.

◆ AlgebraicVectorN

template<unsigned int N>
typedef ROOT::Math::SVector<double, N> KalmanVertexUpdator< N >::AlgebraicVectorN
private

Definition at line 58 of file KalmanVertexUpdator.h.

◆ RefCountedLinearizedTrackState

Definition at line 16 of file KalmanVertexUpdator.h.

◆ RefCountedVertexTrack

Definition at line 15 of file KalmanVertexUpdator.h.

Member Function Documentation

◆ add()

template<unsigned int N>
CachingVertex< N > KalmanVertexUpdator< N >::add ( const CachingVertex< N > &  oldVertex,
const RefCountedVertexTrack  track 
) const
override

Method to add a track to an existing CachingVertex An invalid vertex is returned in case of problems during the update.

Definition at line 56 of file KalmanVertexUpdator.cc.

57  {
58  float weight = track->weight();
59  return update(oldVertex, track, weight, +1);
60 }

Referenced by GsfVertexUpdator::add(), and counter.Counter::register().

◆ chi2Increment()

template<unsigned int N>
std::pair< bool, double > KalmanVertexUpdator< N >::chi2Increment ( const VertexState oldVertex,
const VertexState newVertexState,
const RefCountedLinearizedTrackState  linearizedTrack,
float  weight 
) const

Definition at line 129 of file KalmanVertexUpdator.cc.

132  {
133  int error;
134  GlobalPoint newVertexPosition = newVertexState.position();
135 
136  if (!linearizedTrack->isValid())
137  return std::pair<bool, double>(false, -1.);
138 
139  AlgebraicVector3 newVertexPositionV;
140  newVertexPositionV(0) = newVertexPosition.x();
141  newVertexPositionV(1) = newVertexPosition.y();
142  newVertexPositionV(2) = newVertexPosition.z();
143 
144  const AlgebraicMatrixN3& a = linearizedTrack->positionJacobian();
145  const AlgebraicMatrixNM& b = linearizedTrack->momentumJacobian();
146 
147  AlgebraicVectorN trackParameters = linearizedTrack->predictedStateParameters();
148 
149  AlgebraicSymMatrixNN trackParametersWeight = linearizedTrack->predictedStateWeight(error);
150  if (error != 0) {
151  edm::LogWarning("KalmanVertexUpdator")
152  << "predictedState error matrix inversion failed. An invalid vertex will be returned.";
153  return std::pair<bool, double>(false, -1.);
154  }
155 
156  AlgebraicSymMatrixMM s = ROOT::Math::SimilarityT(b, trackParametersWeight);
157  if (!invertPosDefMatrix(s)) {
158  edm::LogWarning("KalmanVertexUpdator") << "S matrix inversion failed. An invalid vertex will be returned.";
159  return std::pair<bool, double>(false, -1.);
160  }
161 
162  const AlgebraicVectorN& theResidual = linearizedTrack->constantTerm();
163  AlgebraicVectorN vv = trackParameters - theResidual - a * newVertexPositionV;
164  AlgebraicVectorM newTrackMomentumP = s * ROOT::Math::Transpose(b) * trackParametersWeight * vv;
165 
166  // AlgebraicVectorN rtp = ( theResidual + a * newVertexPositionV + b * newTrackMomentumP);
167 
168  AlgebraicVectorN parameterResiduals = vv - b * newTrackMomentumP;
169  linearizedTrack->checkParameters(parameterResiduals);
170 
171  double chi2 = weight * ROOT::Math::Similarity(parameterResiduals, trackParametersWeight);
172 
173  // chi2 += vertexPositionChi2(oldVertex, newVertexPosition);
174  chi2 += helper.vertexChi2(oldVertex, newVertexState);
175 
176  return std::pair<bool, double>(true, chi2);
177 }

Referenced by GsfVertexUpdator::createNewComponent().

◆ clone()

template<unsigned int N>
VertexUpdator<N>* KalmanVertexUpdator< N >::clone ( void  ) const
inlineoverridevirtual

Clone method

Implements VertexUpdator< N >.

Definition at line 36 of file KalmanVertexUpdator.h.

36 { return new KalmanVertexUpdator(*this); }

◆ positionUpdate()

template<unsigned int N>
VertexState KalmanVertexUpdator< N >::positionUpdate ( const VertexState oldVertex,
const RefCountedLinearizedTrackState  linearizedTrack,
const float  weight,
int  sign 
) const

Definition at line 70 of file KalmanVertexUpdator.cc.

73  {
74  int error;
75 
76  if (!linearizedTrack->isValid())
77  return VertexState();
78 
79  const AlgebraicMatrixN3& a = linearizedTrack->positionJacobian();
80  const AlgebraicMatrixNM& b = linearizedTrack->momentumJacobian();
81 
82  // AlgebraicVectorN trackParameters =
83  // linearizedTrack->predictedStateParameters();
84 
85  AlgebraicSymMatrixNN trackParametersWeight = linearizedTrack->predictedStateWeight(error);
86  if (error != 0) {
87  edm::LogWarning("KalmanVertexUpdator")
88  << "predictedState error matrix inversion failed. An invalid vertex will be returned.";
89  return VertexState();
90  }
91 
92  // Jacobians
93  // edm::LogInfo("RecoVertex/KalmanVertexUpdator")
94  // << "Now updating position" << "\n";
95 
96  //vertex information
97  // AlgebraicSymMatrix33 oldVertexWeight = oldVertex.weight().matrix();
98  AlgebraicSymMatrixMM s = ROOT::Math::SimilarityT(b, trackParametersWeight);
99  if (!invertPosDefMatrix(s)) {
100  edm::LogWarning("KalmanVertexUpdator") << "S matrix inversion failed. An invalid vertex will be returned.";
101  return VertexState();
102  }
103 
105  trackParametersWeight - ROOT::Math::Similarity(trackParametersWeight, ROOT::Math::Similarity(b, s));
106 
107  // Getting the new covariance matrix of the vertex.
108 
109  AlgebraicSymMatrix33 newVertexWeight = oldVertex.weight().matrix() + (weight * sign) * ROOT::Math::SimilarityT(a, gB);
110  // edm::LogInfo("RecoVertex/KalmanVertexUpdator")
111  // << "weight matrix" << newVertexWeight << "\n";
112 
113  AlgebraicVector3 newSwr =
114  oldVertex.weightTimesPosition() +
115  (weight * sign) * ((ROOT::Math::Transpose(a) * gB) *
116  (linearizedTrack->predictedStateParameters() - linearizedTrack->constantTerm()));
117  // edm::LogInfo("RecoVertex/KalmanVertexUpdator")
118  // << "weighttimespos" << newSwr << "\n";
119 
120  VertexState newpos(newSwr, GlobalWeight(newVertexWeight), 1.0);
121 
122  // edm::LogInfo("RecoVertex/KalmanVertexUpdator")
123  // << "pos" << newpos.position() << "\n";
124 
125  return newpos;
126 }

Referenced by GsfVertexUpdator::createNewComponent(), and GsfVertexSmoother::createNewComponent().

◆ remove()

template<unsigned int N>
CachingVertex< N > KalmanVertexUpdator< N >::remove ( const CachingVertex< N > &  oldVertex,
const RefCountedVertexTrack  track 
) const
override

Method removing already used VertexTrack from existing CachingVertex An invalid vertex is returned in case of problems during the update.

Definition at line 63 of file KalmanVertexUpdator.cc.

64  {
65  float weight = track->weight();
66  return update(oldVertex, track, weight, -1);
67 }

◆ update()

template<unsigned int N>
CachingVertex< N > KalmanVertexUpdator< N >::update ( const CachingVertex< N > &  oldVertex,
const RefCountedVertexTrack  track,
float  weight,
int  sign 
) const

The methode which actually does the vertex update. An invalid vertex is returned in case of problems during the update.

Definition at line 13 of file KalmanVertexUpdator.cc.

16  {
17  if (abs(sign) != 1)
18  throw VertexException("KalmanVertexUpdator::abs(sign) not equal to 1");
19 
20  VertexState newVertexState = positionUpdate(oldVertex.vertexState(), track->linearizedTrack(), weight, sign);
21  if (!newVertexState.isValid())
22  return CachingVertex<N>();
23 
24  float chi1 = oldVertex.totalChiSquared();
25  std::pair<bool, double> chi2P =
26  chi2Increment(oldVertex.vertexState(), newVertexState, track->linearizedTrack(), weight);
27  if (!chi2P.first)
28  return CachingVertex<N>(); // return invalid vertex
29 
30  chi1 += sign * chi2P.second;
31 
32  //adding or removing track from the CachingVertex::VertexTracks
33  std::vector<RefCountedVertexTrack> newVertexTracks = oldVertex.tracks();
34 
35  if (sign > 0) {
36  newVertexTracks.push_back(track);
37  } else {
38  typename std::vector<RefCountedVertexTrack>::iterator pos =
39  find(newVertexTracks.begin(), newVertexTracks.end(), track);
40  if (pos != newVertexTracks.end()) {
41  newVertexTracks.erase(pos);
42  } else {
43  std::cout << "KalmanVertexUpdator::Unable to find requested track in the current vertex" << std::endl;
44  throw VertexException("KalmanVertexUpdator::Unable to find requested track in the current vertex");
45  }
46  }
47 
48  if (oldVertex.hasPrior()) {
49  return CachingVertex<N>(oldVertex.priorVertexState(), newVertexState, newVertexTracks, chi1);
50  } else {
51  return CachingVertex<N>(newVertexState, newVertexTracks, chi1);
52  }
53 }

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

Member Data Documentation

◆ helper

template<unsigned int N>
KVFHelper<N> KalmanVertexUpdator< N >::helper
private

Definition at line 68 of file KalmanVertexUpdator.h.

VertexState::isValid
bool isValid() const
Make the ReferenceCountingProxy method to check validity public.
Definition: VertexState.h:93
AlgebraicVector3
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Definition: AlgebraicROOTObjects.h:12
KalmanVertexUpdator
Definition: KalmanVertexUpdator.h:13
AlgebraicSymMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
Definition: AlgebraicROOTObjects.h:21
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
VertexException
Common base class.
Definition: VertexException.h:12
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
KalmanVertexUpdator::update
CachingVertex< N > update(const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track, float weight, int sign) const
Definition: KalmanVertexUpdator.cc:13
CachingVertex
Definition: CachingVertex.h:22
mps_merge.weight
weight
Definition: mps_merge.py:88
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
CachingVertex::priorVertexState
const VertexState & priorVertexState() const
Definition: CachingVertex.h:138
CachingVertex::vertexState
const VertexState & vertexState() const
Definition: CachingVertex.h:137
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
KalmanVertexUpdator::AlgebraicVectorN
ROOT::Math::SVector< double, N > AlgebraicVectorN
Definition: KalmanVertexUpdator.h:58
CachingVertex::hasPrior
bool hasPrior() const
Definition: CachingVertex.h:153
GlobalErrorBase::matrix
const AlgebraicSymMatrix33 matrix() const
Definition: GlobalErrorBase.h:121
KalmanVertexUpdator::AlgebraicSymMatrixMM
ROOT::Math::SMatrix< double, N - 2, N - 2, ROOT::Math::MatRepSym< double, N - 2 > > AlgebraicSymMatrixMM
Definition: KalmanVertexUpdator.h:66
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
relativeConstraints.error
error
Definition: relativeConstraints.py:53
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
KalmanVertexUpdator::AlgebraicMatrixNM
ROOT::Math::SMatrix< double, N, N - 2, ROOT::Math::MatRepStd< double, N, N - 2 > > AlgebraicMatrixNM
Definition: KalmanVertexUpdator.h:61
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
alignCSCRings.s
s
Definition: alignCSCRings.py:92
GlobalWeight
GlobalErrorBase< double, WeightMatrixTag > GlobalWeight
Definition: GlobalWeight.h:12
Point3DBase< float, GlobalTag >
b
double b
Definition: hdecay.h:118
CachingVertex::totalChiSquared
float totalChiSquared() const
Definition: CachingVertex.h:159
KalmanVertexUpdator::chi2Increment
std::pair< bool, double > chi2Increment(const VertexState &oldVertex, const VertexState &newVertexState, const RefCountedLinearizedTrackState linearizedTrack, float weight) const
Definition: KalmanVertexUpdator.cc:129
KalmanVertexUpdator::AlgebraicMatrixN3
ROOT::Math::SMatrix< double, N, 3, ROOT::Math::MatRepStd< double, N, 3 > > AlgebraicMatrixN3
Definition: KalmanVertexUpdator.h:60
a
double a
Definition: hdecay.h:119
VertexState::weight
GlobalWeight weight() const
Definition: VertexState.h:69
KalmanVertexUpdator::AlgebraicVectorM
ROOT::Math::SVector< double, N - 2 > AlgebraicVectorM
Definition: KalmanVertexUpdator.h:59
helper
Definition: helper.py:1
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
invertPosDefMatrix
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
Definition: invertPosDefMatrix.h:10
CachingVertex::tracks
std::vector< RefCountedVertexTrack > tracks() const
Definition: CachingVertex.h:147
KalmanVertexUpdator::positionUpdate
VertexState positionUpdate(const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
Definition: KalmanVertexUpdator.cc:70
VertexState::weightTimesPosition
AlgebraicVector3 weightTimesPosition() const
Definition: VertexState.h:77
KalmanVertexUpdator::AlgebraicSymMatrixNN
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > AlgebraicSymMatrixNN
Definition: KalmanVertexUpdator.h:63
VertexState
Definition: VertexState.h:13
VertexState::position
GlobalPoint position() const
Definition: VertexState.h:62
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
weight
Definition: weight.py:1