test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
std::pair< bool, double > chi2Increment (const VertexState &oldVertex, const VertexState &newVertexState, const RefCountedLinearizedTrackState linearizedTrack, float weight) const
 
VertexUpdator< N > * clone () const
 
VertexState positionUpdate (const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
 
CachingVertex< Nremove (const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track) const
 
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, N
AlgebraicVectorN
 

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 68 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 66 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 67 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 71 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 72 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 69 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 70 of file KalmanVertexUpdator.h.

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

Definition at line 65 of file KalmanVertexUpdator.h.

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

Definition at line 64 of file KalmanVertexUpdator.h.

Definition at line 18 of file KalmanVertexUpdator.h.

Definition at line 17 of file KalmanVertexUpdator.h.

Member Function Documentation

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

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

Definition at line 57 of file KalmanVertexUpdator.cc.

References update, and puppiForMET_cff::weight.

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

59 {
60  float weight = track->weight();
61  return update(oldVertex,track,weight,+1);
62 }
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 137 of file KalmanVertexUpdator.cc.

References a, b, beam_dqm_sourceclient-live_cfg::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 GsfVertexUpdator::createNewComponent().

141 {
142  int error;
143  GlobalPoint newVertexPosition = newVertexState.position();
144 
145  if (!linearizedTrack->isValid())
146  return std::pair <bool, double> ( false, -1. );
147 
148  AlgebraicVector3 newVertexPositionV;
149  newVertexPositionV(0) = newVertexPosition.x();
150  newVertexPositionV(1) = newVertexPosition.y();
151  newVertexPositionV(2) = newVertexPosition.z();
152 
153  const AlgebraicMatrixN3 & a = linearizedTrack->positionJacobian();
154  const AlgebraicMatrixNM & b = linearizedTrack->momentumJacobian();
155 
156  AlgebraicVectorN trackParameters =
157  linearizedTrack->predictedStateParameters();
158 
159  AlgebraicSymMatrixNN trackParametersWeight =
160  linearizedTrack->predictedStateWeight(error);
161  if(error!=0) {
162  edm::LogWarning("KalmanVertexUpdator") << "predictedState error matrix inversion failed. An invalid vertex will be returned.";
163  return std::pair <bool, double> (false, -1.);
164  }
165 
166  AlgebraicSymMatrixMM s = ROOT::Math::SimilarityT(b,trackParametersWeight);
167  if (!invertPosDefMatrix(s)) {
168  edm::LogWarning("KalmanVertexUpdator") << "S matrix inversion failed. An invalid vertex will be returned.";
169  return std::pair <bool, double> (false, -1.);
170  }
171 
172  const AlgebraicVectorN & theResidual = linearizedTrack->constantTerm();
173  AlgebraicVectorN vv = trackParameters - theResidual - a*newVertexPositionV;
174  AlgebraicVectorM newTrackMomentumP = s * ROOT::Math::Transpose(b) * trackParametersWeight * vv;
175 
176 
177 // AlgebraicVectorN rtp = ( theResidual + a * newVertexPositionV + b * newTrackMomentumP);
178 
179  AlgebraicVectorN parameterResiduals = vv - b * newTrackMomentumP;
180  linearizedTrack->checkParameters(parameterResiduals);
181 
182  double chi2 = weight * ROOT::Math::Similarity(parameterResiduals, trackParametersWeight);
183 
184 // chi2 += vertexPositionChi2(oldVertex, newVertexPosition);
185  chi2 += helper.vertexChi2(oldVertex, newVertexState);
186 
187  return std::pair <bool, double> (true, chi2);
188 }
ROOT::Math::SMatrix< double, N, N-2, ROOT::Math::MatRepStd< double, N, N-2 > > AlgebraicMatrixNM
ROOT::Math::SVector< double, N > AlgebraicVectorN
ROOT::Math::SMatrix< double, N, 3, ROOT::Math::MatRepStd< double, N, 3 > > AlgebraicMatrixN3
T y() const
Definition: PV3DBase.h:63
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > AlgebraicSymMatrixNN
ROOT::Math::SMatrix< double, N-2, N-2, ROOT::Math::MatRepSym< double, N-2 > > AlgebraicSymMatrixMM
GlobalPoint position() const
Definition: VertexState.h:50
T z() const
Definition: PV3DBase.h:64
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
ROOT::Math::SVector< double, 3 > AlgebraicVector3
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
T x() const
Definition: PV3DBase.h:62
ROOT::Math::SVector< double, N-2 > AlgebraicVectorM
template<unsigned int N>
VertexUpdator<N>* KalmanVertexUpdator< N >::clone ( void  ) const
inlinevirtual

Clone method

Implements VertexUpdator< N >.

Definition at line 40 of file KalmanVertexUpdator.h.

41  {
42  return new KalmanVertexUpdator(* this);
43  }
template<unsigned int N>
VertexState KalmanVertexUpdator< N >::positionUpdate ( const VertexState oldVertex,
const RefCountedLinearizedTrackState  linearizedTrack,
const float  weight,
int  sign 
) const

Definition at line 75 of file KalmanVertexUpdator.cc.

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

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

78 {
79  int error;
80 
81  if (!linearizedTrack->isValid())
82  return VertexState();
83 
84  const AlgebraicMatrixN3 & a = linearizedTrack->positionJacobian();
85  const AlgebraicMatrixNM & b = linearizedTrack->momentumJacobian();
86 
87 // AlgebraicVectorN trackParameters =
88 // linearizedTrack->predictedStateParameters();
89 
90  AlgebraicSymMatrixNN trackParametersWeight =
91  linearizedTrack->predictedStateWeight(error);
92  if(error != 0) {
93  edm::LogWarning("KalmanVertexUpdator") << "predictedState error matrix inversion failed. An invalid vertex will be returned.";
94  return VertexState();
95  }
96 
97 
98  // Jacobians
99  // edm::LogInfo("RecoVertex/KalmanVertexUpdator")
100  // << "Now updating position" << "\n";
101 
102  //vertex information
103 // AlgebraicSymMatrix33 oldVertexWeight = oldVertex.weight().matrix_new();
104  AlgebraicSymMatrixMM s = ROOT::Math::SimilarityT(b,trackParametersWeight);
105  if (!invertPosDefMatrix(s)) {
106  edm::LogWarning("KalmanVertexUpdator") << "S matrix inversion failed. An invalid vertex will be returned.";
107  return VertexState();
108  }
109 
110  AlgebraicSymMatrixNN gB = trackParametersWeight -
111  ROOT::Math::Similarity(trackParametersWeight, ROOT::Math::Similarity(b,s));
112 
113 // Getting the new covariance matrix of the vertex.
114 
115  AlgebraicSymMatrix33 newVertexWeight = oldVertex.weight().matrix_new()
116  + (weight * sign) * ROOT::Math::SimilarityT(a,gB);
117  // edm::LogInfo("RecoVertex/KalmanVertexUpdator")
118  // << "weight matrix" << newVertexWeight << "\n";
119 
120 
121  AlgebraicVector3 newSwr = oldVertex.weightTimesPosition()
122  + (weight * sign) * ( (ROOT::Math::Transpose(a) * gB) *
123  ( linearizedTrack->predictedStateParameters() - linearizedTrack->constantTerm()) );
124  // edm::LogInfo("RecoVertex/KalmanVertexUpdator")
125  // << "weighttimespos" << newSwr << "\n";
126 
127  VertexState newpos (newSwr, GlobalWeight(newVertexWeight), 1.0);
128 
129  // edm::LogInfo("RecoVertex/KalmanVertexUpdator")
130  // << "pos" << newpos.position() << "\n";
131 
132  return newpos;
133 }
ROOT::Math::SMatrix< double, N, N-2, ROOT::Math::MatRepStd< double, N, N-2 > > AlgebraicMatrixNM
double sign(double x)
ROOT::Math::SMatrix< double, N, 3, ROOT::Math::MatRepStd< double, N, 3 > > AlgebraicMatrixN3
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > AlgebraicSymMatrixNN
ROOT::Math::SMatrix< double, N-2, N-2, ROOT::Math::MatRepSym< double, N-2 > > AlgebraicSymMatrixMM
const AlgebraicSymMatrix33 & matrix_new() const
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
AlgebraicVector3 weightTimesPosition() const
Definition: VertexState.h:65
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
GlobalErrorBase< double, WeightMatrixTag > GlobalWeight
Definition: GlobalWeight.h:13
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
template<unsigned int N>
CachingVertex< N > KalmanVertexUpdator< N >::remove ( const CachingVertex< N > &  oldVertex,
const RefCountedVertexTrack  track 
) const

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

Definition at line 65 of file KalmanVertexUpdator.cc.

References update, and puppiForMET_cff::weight.

67 {
68  float weight = track->weight();
69  return update(oldVertex,track,weight,-1);
70 }
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(), jetcorrextractor::sign(), CachingVertex< N >::totalChiSquared(), CachingVertex< N >::tracks(), CachingVertex< N >::vertexState(), and puppiForMET_cff::weight.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), 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().

15 {
16  if(abs(sign) != 1) throw VertexException
17  ("KalmanVertexUpdator::abs(sign) not equal to 1");
18 
19  VertexState newVertexState = positionUpdate(oldVertex.vertexState(),
20  track->linearizedTrack(), weight, sign);
21  if (!newVertexState.isValid()) return CachingVertex<N>();
22 
23  float chi1 = oldVertex.totalChiSquared();
24  std::pair <bool, double> chi2P = chi2Increment(oldVertex.vertexState(), newVertexState,
25  track->linearizedTrack() , weight );
26  if (!chi2P.first) return CachingVertex<N>(); // return invalid vertex
27 
28  chi1 +=sign * chi2P.second;
29 
30 //adding or removing track from the CachingVertex::VertexTracks
31  std::vector<RefCountedVertexTrack> newVertexTracks = oldVertex.tracks();
32 
33  if (sign > 0) {
34  newVertexTracks.push_back(track);
35  }else{
36 
37  typename std::vector<RefCountedVertexTrack>::iterator pos
38  = find(newVertexTracks.begin(), newVertexTracks.end(), track);
39  if (pos != newVertexTracks.end()) {
40  newVertexTracks.erase(pos);
41  } else {
42  std::cout<<"KalmanVertexUpdator::Unable to find requested track in the current vertex"<<std::endl;
43  throw VertexException("KalmanVertexUpdator::Unable to find requested track in the current vertex");
44  }
45  }
46 
47  if (oldVertex.hasPrior()) {
48  return CachingVertex<N>( oldVertex.priorVertexState(),
49  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
Common base class.
VertexState const & vertexState() const
Definition: CachingVertex.h:85
double sign(double x)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< RefCountedVertexTrack > const & tracks() const
Definition: CachingVertex.h:91
float totalChiSquared() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool hasPrior() const
Definition: CachingVertex.h:95
VertexState positionUpdate(const VertexState &oldVertex, const RefCountedLinearizedTrackState linearizedTrack, const float weight, int sign) const
VertexState const & priorVertexState() const
Definition: CachingVertex.h:86
bool isValid() const
Make the ReferenceCountingProxy method to check validity public.
Definition: VertexState.h:88
tuple cout
Definition: gather_cfg.py:145

Member Data Documentation

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

Definition at line 74 of file KalmanVertexUpdator.h.