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

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.

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.

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.

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.

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.

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.

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.

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

Definition at line 59 of file KalmanVertexUpdator.h.

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

Definition at line 58 of file KalmanVertexUpdator.h.

Definition at line 16 of file KalmanVertexUpdator.h.

Definition at line 15 of file KalmanVertexUpdator.h.

Member Function Documentation

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.

References update.

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

57  {
58  float weight = track->weight();
59  return update(oldVertex, track, weight, +1);
60 }
Definition: weight.py:1
CachingVertex< N > update(const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track, float weight, int sign) const
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.

References a, b, hltPixelTracks_cff::chi2, relativeConstraints::error, invertPosDefMatrix(), VertexState::position(), alignCSCRings::s, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by KalmanVertexUpdator< 5 >::clone(), and GsfVertexUpdator::createNewComponent().

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 }
Definition: helper.py:1
T y() const
Definition: PV3DBase.h:60
Definition: weight.py:1
ROOT::Math::SMatrix< double, N, 3, ROOT::Math::MatRepStd< double, N, 3 > > AlgebraicMatrixN3
GlobalPoint position() const
Definition: VertexState.h:62
ROOT::Math::SMatrix< double, N-2, N-2, ROOT::Math::MatRepSym< double, N-2 > > AlgebraicSymMatrixMM
ROOT::Math::SVector< double, N-2 > AlgebraicVectorM
T z() const
Definition: PV3DBase.h:61
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
ROOT::Math::SVector< double, N > AlgebraicVectorN
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
ROOT::Math::SVector< double, 3 > AlgebraicVector3
T x() const
Definition: PV3DBase.h:59
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > AlgebraicSymMatrixNN
ROOT::Math::SMatrix< double, N, N-2, ROOT::Math::MatRepStd< double, N, N-2 > > AlgebraicMatrixNM
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.

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.

References a, b, relativeConstraints::error, invertPosDefMatrix(), GlobalErrorBase< T, ErrorWeightType >::matrix(), alignCSCRings::s, Validation_hcalonly_cfi::sign, VertexState::weight(), and VertexState::weightTimesPosition().

Referenced by KalmanVertexUpdator< 5 >::clone(), GsfVertexUpdator::createNewComponent(), and GsfVertexSmoother::createNewComponent().

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 }
const AlgebraicSymMatrix33 matrix() const
Definition: weight.py:1
ROOT::Math::SMatrix< double, N, 3, ROOT::Math::MatRepStd< double, N, 3 > > AlgebraicMatrixN3
ROOT::Math::SMatrix< double, N-2, N-2, ROOT::Math::MatRepSym< double, N-2 > > AlgebraicSymMatrixMM
AlgebraicVector3 weightTimesPosition() const
Definition: VertexState.h:77
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
GlobalWeight weight() const
Definition: VertexState.h:69
GlobalErrorBase< double, WeightMatrixTag > GlobalWeight
Definition: GlobalWeight.h:12
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
ROOT::Math::SVector< double, 3 > AlgebraicVector3
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > AlgebraicSymMatrixNN
ROOT::Math::SMatrix< double, N, N-2, ROOT::Math::MatRepStd< double, N, N-2 > > AlgebraicMatrixNM
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.

References update.

64  {
65  float weight = track->weight();
66  return update(oldVertex, track, weight, -1);
67 }
Definition: weight.py:1
CachingVertex< N > update(const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track, float weight, int sign) const
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.

References funct::abs(), gather_cfg::cout, spr::find(), CachingVertex< N >::hasPrior(), VertexState::isValid(), CachingVertex< N >::priorVertexState(), Validation_hcalonly_cfi::sign, CachingVertex< N >::totalChiSquared(), HLT_2018_cff::track, CachingVertex< N >::tracks(), CachingVertex< N >::vertexState(), and mps_merge::weight.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), KalmanVertexUpdator< 5 >::clone(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

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 }
std::pair< bool, double > chi2Increment(const VertexState &oldVertex, const VertexState &newVertexState, const RefCountedLinearizedTrackState linearizedTrack, float weight) const
std::vector< RefCountedVertexTrack > tracks() const
Common base class.
VertexState const & vertexState() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
float totalChiSquared() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool hasPrior() const
VertexState positionUpdate(const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
VertexState const & priorVertexState() const
bool isValid() const
Make the ReferenceCountingProxy method to check validity public.
Definition: VertexState.h:93

Member Data Documentation

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

Definition at line 68 of file KalmanVertexUpdator.h.