CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
KalmanVertexTrackCompatibilityEstimator.cc
Go to the documentation of this file.
4 #include <algorithm>
5 using namespace reco;
6 
7 
8 template <unsigned int N>
11  const RefCountedVertexTrack tr,
12  unsigned int hint) const
13 {
14 //checking if the track passed really belongs to the vertex
15 
16  const std::vector<RefCountedVertexTrack> &tracks = vertex.tracksRef();
17 
18  if ( tracks.size()==0)
19  return estimateNFittedTrack(vertex,tr);
20 
21  if (hint<tracks.size() ) {
22  VertexTrackEqual<N> d(tr);
23  if ( d(tracks[hint]))
24  return estimateFittedTrack(vertex,tracks[hint]);
25  }
26 
27  typename std::vector<RefCountedVertexTrack>::const_iterator pos
28  = find_if(tracks.begin(), tracks.end(), VertexTrackEqual<N>(tr));
29  if(pos != tracks.end()) {
30  return estimateFittedTrack(vertex,*pos);
31  } else {
32  return estimateNFittedTrack(vertex,tr);
33  }
34 }
35 
36 
37 template <unsigned int N>
41  unsigned int hint) const
42 {
43  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track,
44  vertex.vertexState());
45  return estimate(vertex, vertexTrack,hint);
46 }
47 
48 
49 template <unsigned int N>
52  const reco::TransientTrack & track) const
53 {
54 // GlobalPoint linP(vertex.position().x(), vertex.position().z(),vertex.position().z());
55  GlobalPoint linP(Basic3DVector<float> (vertex.position()));
56 
57  LinearizedTrackStateFactory lTrackFactory;
59  lTrackFactory.linearizedTrackState(linP, track);
60  GlobalError err(vertex.covariance());
61  VertexState vState(linP, err);
62  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
63 
64  std::vector<RefCountedVertexTrack> initialTracks(1, vertexTrack);
65  CachingVertex<N> cachingVertex(linP, err, initialTracks,
66  vertex.chi2());
67  // FIXME: this should work also for tracks without a persistent ref.
68 // return estimateNFittedTrack(cachingVertex, vertexTrack);
69  if (find(vertex.tracks_begin(), vertex.tracks_end(), track.trackBaseRef()) != vertex.tracks_end())
70  {
71  return estimateFittedTrack(cachingVertex, vertexTrack);
72  } else {
73  return estimateNFittedTrack(cachingVertex, vertexTrack);
74  }
75 }
76 
77 
78 
79 // methods to calculate track<-->vertex compatibility
80 // with the track belonging to the vertex
81 
82 template <unsigned int N>
85  (const CachingVertex<N> & v, const RefCountedVertexTrack track) const
86 {
87  //remove track from the vertex using the vertex updator
88  // Using the update instead of the remove methode, we can specify a weight which
89  // is different than then one which the vertex track has been defined with.
90  //CachingVertex rVert = updator.remove(v, track);
91  RefCountedVertexTrack newSmoothedTrack = trackUpdator.update(v, track);
92 // std::cout << newSmoothedTrack->smoothedChi2()<<" "<<estimateDifference(v,rVert,newSmoothedTrack)<<std::endl;
93 // return estimateDifference(v,rVert,newSmoothedTrack);
94  return BDpair(true, newSmoothedTrack->smoothedChi2());
95 }
96 
97 // method calculating track<-->vertex compatibility
98 //with the track not belonging to vertex
99 template <unsigned int N>
102  (const CachingVertex<N> & v, const RefCountedVertexTrack track) const
103 {
104  // Using the update instead of the add methode, we can specify a weight which
105  // is different than then one which the vertex track has been defined with.
106  CachingVertex<N> rVert = updator.add(v, track);
107  if (!rVert.isValid()) return BDpair(false,-1.);
108  return BDpair(true, rVert.totalChiSquared()-v.totalChiSquared());
109 }
110 
111 
112 
113 template <unsigned int N>
116  (const CachingVertex<N> & more, const CachingVertex<N> & less,
117  const RefCountedVertexTrack track) const
118 {
119  BDpair trackRes = helper.trackParameterChi2(track);
120  return BDpair(trackRes.first, trackRes.second + helper.vertexChi2(less, more)) ;
121 }
122 
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
TrackBaseRef trackBaseRef() const
VertexState const & vertexState() const
Definition: CachingVertex.h:85
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:123
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const Point & position() const
position
Definition: Vertex.h:106
virtual BDpair estimate(const CachingVertex< N > &vrt, const RefCountedVertexTrack track, unsigned int hint=UINT_MAX) const
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const
float totalChiSquared() const
double chi2() const
chi-squares
Definition: Vertex.h:95
VertexTrack< N >::RefCountedLinearizedTrackState RefCountedLinearizedTrackState
tuple tracks
Definition: testEve_cfg.py:39
std::vector< RefCountedVertexTrack > const & tracksRef() const
Definition: CachingVertex.h:92
BDpair estimateDifference(const CachingVertex< N > &more, const CachingVertex< N > &less, const RefCountedVertexTrack track) const
bool isValid() const
Definition: CachingVertex.h:96
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
BDpair estimateFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const
BDpair estimateNFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const