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< N > add (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< N > remove (const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track) const
 
CachingVertex< N > update (const CachingVertex< N > &oldVertex, const RefCountedVertexTrack track, float weight, int sign) const
 
- Public Member Functions inherited from VertexUpdator< N >
virtual CachingVertex< N > add (const CachingVertex< N > &v, const typename CachingVertex< N >::RefCountedVertexTrack t) const =0
 
virtual CachingVertex< N > remove (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< N > helper
 

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 56 of file KalmanVertexUpdator.cc.

References update, and CommonMethods::weight().

Referenced by GsfVertexUpdator::add().

58 {
59  float weight = track->weight();
60  return update(oldVertex,track,weight,+1);
61 }
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, ExpressReco_HICollisions_FallBack::chi2, error, VertexState::position(), asciidump::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  error = ! s.Invert();
168  if(error!=0) {
169  edm::LogWarning("KalmanVertexUpdator") << "S matrix inversion failed. An invalid vertex will be returned.";
170  return std::pair <bool, double> (false, -1.);
171  }
172 
173  const AlgebraicVectorN & theResidual = linearizedTrack->constantTerm();
174  AlgebraicVectorM newTrackMomentumP = s * ROOT::Math::Transpose(b) * trackParametersWeight *
175  (trackParameters - theResidual - a*newVertexPositionV);
176 
177 
178 // AlgebraicVectorN rtp = ( theResidual + a * newVertexPositionV + b * newTrackMomentumP);
179 
180  AlgebraicVectorN parameterResiduals = trackParameters -
181  ( theResidual + a * newVertexPositionV + b * newTrackMomentumP);
182  linearizedTrack->checkParameters(parameterResiduals);
183 
184  double chi2 = weight * ROOT::Math::Similarity(parameterResiduals, trackParametersWeight);
185 
186 // chi2 += vertexPositionChi2(oldVertex, newVertexPosition);
187  chi2 += helper.vertexChi2(oldVertex, newVertexState);
188 
189  return std::pair <bool, double> (true, chi2);
190 }
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:57
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:29
T z() const
Definition: PV3DBase.h:58
ROOT::Math::SVector< double, 3 > AlgebraicVector3
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
string s
Definition: asciidump.py:422
T x() const
Definition: PV3DBase.h:56
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 74 of file KalmanVertexUpdator.cc.

References a, b, error, GlobalErrorBase< T, ErrorWeightType >::matrix_new(), asciidump::s, VertexState::weight(), and VertexState::weightTimesPosition().

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

77 {
78  int error;
79 
80  if (!linearizedTrack->isValid())
81  return VertexState();
82 
83  const AlgebraicMatrixN3 & a = linearizedTrack->positionJacobian();
84  const AlgebraicMatrixNM & b = linearizedTrack->momentumJacobian();
85 
86 // AlgebraicVectorN trackParameters =
87 // linearizedTrack->predictedStateParameters();
88 
89  AlgebraicSymMatrixNN trackParametersWeight =
90  linearizedTrack->predictedStateWeight(error);
91  if(error != 0) {
92  edm::LogWarning("KalmanVertexUpdator") << "predictedState error matrix inversion failed. An invalid vertex will be returned.";
93  return VertexState();
94  }
95 
96 
97  // Jacobians
98  // edm::LogInfo("RecoVertex/KalmanVertexUpdator")
99  // << "Now updating position" << "\n";
100 
101  //vertex information
102 // AlgebraicSymMatrix33 oldVertexWeight = oldVertex.weight().matrix_new();
103  AlgebraicSymMatrixMM s = ROOT::Math::SimilarityT(b,trackParametersWeight);
104  error = ! s.Invert();
105  if(error != 0) {
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 =
122  oldVertex.weightTimesPosition() + 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
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:44
ROOT::Math::SVector< double, 3 > AlgebraicVector3
GlobalWeight weight() const
Definition: VertexState.h:39
GlobalErrorBase< double, WeightMatrixTag > GlobalWeight
Definition: GlobalWeight.h:13
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
string s
Definition: asciidump.py:422
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 64 of file KalmanVertexUpdator.cc.

References update, and CommonMethods::weight().

66 {
67  float weight = track->weight();
68  return update(oldVertex,track,weight,-1);
69 }
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 12 of file KalmanVertexUpdator.cc.

References abs, gather_cfg::cout, spr::find(), CachingVertex< N >::hasPrior(), VertexState::isValid(), pos, CachingVertex< N >::priorVertexState(), CachingVertex< N >::totalChiSquared(), ExpressReco_HICollisions_FallBack::track, CachingVertex< N >::tracks(), CachingVertex< N >::vertexState(), and CommonMethods::weight().

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

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

Member Data Documentation

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

Definition at line 74 of file KalmanVertexUpdator.h.