CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
KalmanVertexTrackCompatibilityEstimator< N > Class Template Reference

#include <KalmanVertexTrackCompatibilityEstimator.h>

Inheritance diagram for KalmanVertexTrackCompatibilityEstimator< N >:
VertexTrackCompatibilityEstimator< N >

Public Types

typedef std::pair< bool, double > BDpair
 
typedef VertexTrack< N >
::RefCountedLinearizedTrackState 
RefCountedLinearizedTrackState
 
typedef VertexTrack< N >
::RefCountedRefittedTrackState 
RefCountedRefittedTrackState
 
typedef CachingVertex< N >
::RefCountedVertexTrack 
RefCountedVertexTrack
 
- Public Types inherited from VertexTrackCompatibilityEstimator< N >
typedef std::pair< bool, double > BDpair
 
typedef VertexTrack< N >
::RefCountedLinearizedTrackState 
RefCountedLinearizedTrackState
 
typedef CachingVertex< N >
::RefCountedVertexTrack 
RefCountedVertexTrack
 

Public Member Functions

KalmanVertexTrackCompatibilityEstimator
< N > * 
clone () const override
 
BDpair estimate (const CachingVertex< N > &vrt, const RefCountedVertexTrack track, unsigned int hint=UINT_MAX) const override
 
BDpair estimate (const CachingVertex< N > &v, const RefCountedLinearizedTrackState track, unsigned int hint=UINT_MAX) const override
 
BDpair estimate (const reco::Vertex &vertex, const reco::TransientTrack &track) const override
 
 KalmanVertexTrackCompatibilityEstimator ()
 
 ~KalmanVertexTrackCompatibilityEstimator () override
 
- Public Member Functions inherited from VertexTrackCompatibilityEstimator< N >
 VertexTrackCompatibilityEstimator ()
 
virtual ~VertexTrackCompatibilityEstimator ()
 

Private Member Functions

BDpair estimateDifference (const CachingVertex< N > &more, const CachingVertex< N > &less, const RefCountedVertexTrack track) const
 
BDpair estimateFittedTrack (const CachingVertex< N > &v, const RefCountedVertexTrack track) const
 
BDpair estimateNFittedTrack (const CachingVertex< N > &v, const RefCountedVertexTrack track) const
 

Private Attributes

KVFHelper< Nhelper
 
KalmanVertexTrackUpdator< NtrackUpdator
 
KalmanVertexUpdator< Nupdator
 
VertexTrackFactory< NvTrackFactory
 

Detailed Description

template<unsigned int N>
class KalmanVertexTrackCompatibilityEstimator< N >

Calculates the compatiblity of a track with respect to a vertex using the Kalman filter algorithms. The compatibility is computed from the squared standardized residuals between the track and the vertex. If track and vertex errors are Gaussian and correct, this quantity is distributed as chi**2(ndf=2)). Can be used to identify outlying tracks.

Definition at line 24 of file KalmanVertexTrackCompatibilityEstimator.h.

Member Typedef Documentation

template<unsigned int N>
typedef std::pair<bool, double> KalmanVertexTrackCompatibilityEstimator< N >::BDpair

Definition at line 29 of file KalmanVertexTrackCompatibilityEstimator.h.

Definition at line 27 of file KalmanVertexTrackCompatibilityEstimator.h.

Definition at line 28 of file KalmanVertexTrackCompatibilityEstimator.h.

Definition at line 26 of file KalmanVertexTrackCompatibilityEstimator.h.

Constructor & Destructor Documentation

template<unsigned int N>
KalmanVertexTrackCompatibilityEstimator< N >::~KalmanVertexTrackCompatibilityEstimator ( )
inlineoverride

Definition at line 33 of file KalmanVertexTrackCompatibilityEstimator.h.

33 {}

Member Function Documentation

template<unsigned int N>
KalmanVertexTrackCompatibilityEstimator<N>* KalmanVertexTrackCompatibilityEstimator< N >::clone ( ) const
inlineoverridevirtual
template<unsigned int N>
KalmanVertexTrackCompatibilityEstimator< N >::BDpair KalmanVertexTrackCompatibilityEstimator< N >::estimate ( const CachingVertex< N > &  vrt,
const RefCountedVertexTrack  track,
unsigned int  hint = UINT_MAX 
) const
overridevirtual

Track-to-vertex compatibility. The track weight is taken into account.

Parameters
trackThe track for which the chi**2 has to be estimated.
vThe vertex against which the chi**2 has to be estimated.
Returns
The chi**2.

Implements VertexTrackCompatibilityEstimator< N >.

Definition at line 8 of file KalmanVertexTrackCompatibilityEstimator.cc.

References ztail::d, tracks, and CachingVertex< N >::tracksRef().

Referenced by MultiVertexFitter::updateWeights().

9  {
10  //checking if the track passed really belongs to the vertex
11 
12  const std::vector<RefCountedVertexTrack> &tracks = vertex.tracksRef();
13 
14  if (tracks.empty())
15  return estimateNFittedTrack(vertex, tr);
16 
17  if (hint < tracks.size()) {
19  if (d(tracks[hint]))
20  return estimateFittedTrack(vertex, tracks[hint]);
21  }
22 
23  typename std::vector<RefCountedVertexTrack>::const_iterator pos =
24  find_if(tracks.begin(), tracks.end(), VertexTrackEqual<N>(tr));
25  if (pos != tracks.end()) {
26  return estimateFittedTrack(vertex, *pos);
27  } else {
28  return estimateNFittedTrack(vertex, tr);
29  }
30 }
auto const & tracks
cannot be loose
tuple d
Definition: ztail.py:151
BDpair estimateFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const
BDpair estimateNFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const
template<unsigned int N>
KalmanVertexTrackCompatibilityEstimator< N >::BDpair KalmanVertexTrackCompatibilityEstimator< N >::estimate ( const CachingVertex< N > &  v,
const RefCountedLinearizedTrackState  track,
unsigned int  hint = UINT_MAX 
) const
overridevirtual

Methods giving back the compatibility estimation

Implements VertexTrackCompatibilityEstimator< N >.

Definition at line 33 of file KalmanVertexTrackCompatibilityEstimator.cc.

References CachingVertex< N >::vertexState().

34  {
35  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track, vertex.vertexState());
36  return estimate(vertex, vertexTrack, hint);
37 }
BDpair estimate(const CachingVertex< N > &vrt, const RefCountedVertexTrack track, unsigned int hint=UINT_MAX) const override
CachingVertex< N >::RefCountedVertexTrack RefCountedVertexTrack
template<unsigned int N>
KalmanVertexTrackCompatibilityEstimator< N >::BDpair KalmanVertexTrackCompatibilityEstimator< N >::estimate ( const reco::Vertex vertex,
const reco::TransientTrack track 
) const
overridevirtual

Implements VertexTrackCompatibilityEstimator< N >.

Definition at line 40 of file KalmanVertexTrackCompatibilityEstimator.cc.

References reco::Vertex::chi2(), reco::Vertex::covariance(), submitPVValidationJobs::err, spr::find(), LinearizedTrackStateFactory::linearizedTrackState(), reco::Vertex::position(), reco::TransientTrack::trackBaseRef(), reco::Vertex::tracks_begin(), and reco::Vertex::tracks_end().

41  {
42  // GlobalPoint linP(vertex.position().x(), vertex.position().z(),vertex.position().z());
44 
45  LinearizedTrackStateFactory lTrackFactory;
46  RefCountedLinearizedTrackState linTrack = lTrackFactory.linearizedTrackState(linP, track);
47  GlobalError err(vertex.covariance());
48  VertexState vState(linP, err);
49  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
50 
51  std::vector<RefCountedVertexTrack> initialTracks(1, vertexTrack);
52  CachingVertex<N> cachingVertex(linP, err, initialTracks, vertex.chi2());
53  // FIXME: this should work also for tracks without a persistent ref.
54  // return estimateNFittedTrack(cachingVertex, vertexTrack);
55  if (find(vertex.tracks_begin(), vertex.tracks_end(), track.trackBaseRef()) != vertex.tracks_end()) {
56  return estimateFittedTrack(cachingVertex, vertexTrack);
57  } else {
58  return estimateNFittedTrack(cachingVertex, vertexTrack);
59  }
60 }
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const override
TrackBaseRef trackBaseRef() const
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:148
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const Point & position() const
position
Definition: Vertex.h:127
double chi2() const
chi-squares
Definition: Vertex.h:116
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.h:110
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.h:108
VertexTrack< N >::RefCountedLinearizedTrackState RefCountedLinearizedTrackState
CachingVertex< N >::RefCountedVertexTrack RefCountedVertexTrack
BDpair estimateFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const
BDpair estimateNFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const
template<unsigned int N>
KalmanVertexTrackCompatibilityEstimator< N >::BDpair KalmanVertexTrackCompatibilityEstimator< N >::estimateDifference ( const CachingVertex< N > &  more,
const CachingVertex< N > &  less,
const RefCountedVertexTrack  track 
) const
private

Definition at line 95 of file KalmanVertexTrackCompatibilityEstimator.cc.

97  {
98  BDpair trackRes = helper.trackParameterChi2(track);
99  return BDpair(trackRes.first, trackRes.second + helper.vertexChi2(less, more));
100 }
template<unsigned int N>
KalmanVertexTrackCompatibilityEstimator< N >::BDpair KalmanVertexTrackCompatibilityEstimator< N >::estimateFittedTrack ( const CachingVertex< N > &  v,
const RefCountedVertexTrack  track 
) const
private

Definition at line 67 of file KalmanVertexTrackCompatibilityEstimator.cc.

68  {
69  //remove track from the vertex using the vertex updator
70  // Using the update instead of the remove methode, we can specify a weight which
71  // is different than then one which the vertex track has been defined with.
72  //CachingVertex rVert = updator.remove(v, track);
73  RefCountedVertexTrack newSmoothedTrack = trackUpdator.update(v, track);
74  // std::cout << newSmoothedTrack->smoothedChi2()<<" "<<estimateDifference(v,rVert,newSmoothedTrack)<<std::endl;
75  // return estimateDifference(v,rVert,newSmoothedTrack);
76  return BDpair(true, newSmoothedTrack->smoothedChi2());
77 }
CachingVertex< N >::RefCountedVertexTrack RefCountedVertexTrack
template<unsigned int N>
KalmanVertexTrackCompatibilityEstimator< N >::BDpair KalmanVertexTrackCompatibilityEstimator< N >::estimateNFittedTrack ( const CachingVertex< N > &  v,
const RefCountedVertexTrack  track 
) const
private

Definition at line 83 of file KalmanVertexTrackCompatibilityEstimator.cc.

References CachingVertex< N >::isValid(), CachingVertex< N >::totalChiSquared(), and HLT_FULL_cff::updator.

84  {
85  // Using the update instead of the add methode, we can specify a weight which
86  // is different than then one which the vertex track has been defined with.
87  CachingVertex<N> rVert = updator.add(v, track);
88  if (!rVert.isValid())
89  return BDpair(false, -1.);
90  return BDpair(true, rVert.totalChiSquared() - v.totalChiSquared());
91 }
float totalChiSquared() const
bool isValid() const

Member Data Documentation

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

Definition at line 66 of file KalmanVertexTrackCompatibilityEstimator.h.

template<unsigned int N>
KalmanVertexTrackUpdator<N> KalmanVertexTrackCompatibilityEstimator< N >::trackUpdator
private

Definition at line 64 of file KalmanVertexTrackCompatibilityEstimator.h.

template<unsigned int N>
KalmanVertexUpdator<N> KalmanVertexTrackCompatibilityEstimator< N >::updator
private

Definition at line 63 of file KalmanVertexTrackCompatibilityEstimator.h.

template<unsigned int N>
VertexTrackFactory<N> KalmanVertexTrackCompatibilityEstimator< N >::vTrackFactory
private

Definition at line 65 of file KalmanVertexTrackCompatibilityEstimator.h.