CMS 3D CMS Logo

KalmanVertexTrackCompatibilityEstimator.cc
Go to the documentation of this file.
4 #include <algorithm>
5 using namespace reco;
6 
7 template <unsigned int N>
9  const CachingVertex<N> &vertex, const RefCountedVertexTrack tr, unsigned int hint) const {
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 }
31 
32 template <unsigned int N>
34  const CachingVertex<N> &vertex, const RefCountedLinearizedTrackState track, unsigned int hint) const {
35  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track, vertex.vertexState());
36  return estimate(vertex, vertexTrack, hint);
37 }
38 
39 template <unsigned int N>
41  const reco::Vertex &vertex, const reco::TransientTrack &track) const {
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 }
61 
62 // methods to calculate track<-->vertex compatibility
63 // with the track belonging to the vertex
64 
65 template <unsigned int N>
68  const RefCountedVertexTrack track) const {
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 }
78 
79 // method calculating track<-->vertex compatibility
80 //with the track not belonging to vertex
81 template <unsigned int N>
84  const RefCountedVertexTrack track) const {
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 }
92 
93 template <unsigned int N>
96  const CachingVertex<N> &less,
97  const RefCountedVertexTrack track) const {
98  BDpair trackRes = helper.trackParameterChi2(track);
99  return BDpair(trackRes.first, trackRes.second + helper.vertexChi2(less, more));
100 }
101 
Definition: helper.py:1
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:73
TrackBaseRef trackBaseRef() const
VertexState const & vertexState() const
BDpair estimate(const CachingVertex< N > &vrt, const RefCountedVertexTrack track, unsigned int hint=UINT_MAX) const override
const std::vector< RefCountedVertexTrack > & tracksRef() const
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:134
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:113
float totalChiSquared() const
double chi2() const
chi-squares
Definition: Vertex.h:102
d
Definition: ztail.py:151
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const override
fixed size matrix
BDpair estimateDifference(const CachingVertex< N > &more, const CachingVertex< N > &less, const RefCountedVertexTrack track) const
bool isValid() const
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:71
BDpair estimateFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const
BDpair estimateNFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const