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) const
12 {
13 //checking if the track passed really belongs to the vertex
14  std::vector<RefCountedVertexTrack> tracks = vertex.tracks();
15  typename std::vector<RefCountedVertexTrack>::iterator pos
16  = find_if(tracks.begin(), tracks.end(), VertexTrackEqual<N>(tr));
17  if(pos != tracks.end()) {
18  return estimateFittedTrack(vertex,*pos);
19  } else {
20  return estimateNFittedTrack(vertex,tr);
21  }
22 }
23 
24 
25 template <unsigned int N>
28  const RefCountedLinearizedTrackState track) const
29 {
30  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track,
31  vertex.vertexState());
32  return estimate(vertex, vertexTrack);
33 }
34 
35 
36 template <unsigned int N>
39  const reco::TransientTrack & track) const
40 {
41 // GlobalPoint linP(vertex.position().x(), vertex.position().z(),vertex.position().z());
42  GlobalPoint linP(Basic3DVector<float> (vertex.position()));
43 
44  LinearizedTrackStateFactory lTrackFactory;
46  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,
53  vertex.chi2());
54  // FIXME: this should work also for tracks without a persistent ref.
55 // return estimateNFittedTrack(cachingVertex, vertexTrack);
56  if (find(vertex.tracks_begin(), vertex.tracks_end(), track.trackBaseRef()) != vertex.tracks_end())
57  {
58  return estimateFittedTrack(cachingVertex, vertexTrack);
59  } else {
60  return estimateNFittedTrack(cachingVertex, vertexTrack);
61  }
62 }
63 
64 
65 
66 // methods to calculate track<-->vertex compatibility
67 // with the track belonging to the vertex
68 
69 template <unsigned int N>
72  (const CachingVertex<N> & v, const RefCountedVertexTrack track) const
73 {
74  //remove track from the vertex using the vertex updator
75  // Using the update instead of the remove methode, we can specify a weight which
76  // is different than then one which the vertex track has been defined with.
77  //CachingVertex rVert = updator.remove(v, track);
78  RefCountedVertexTrack newSmoothedTrack = trackUpdator.update(v, track);
79 // std::cout << newSmoothedTrack->smoothedChi2()<<" "<<estimateDifference(v,rVert,newSmoothedTrack)<<std::endl;
80 // return estimateDifference(v,rVert,newSmoothedTrack);
81  return BDpair(true, newSmoothedTrack->smoothedChi2());
82 }
83 
84 // method calculating track<-->vertex compatibility
85 //with the track not belonging to vertex
86 template <unsigned int N>
89  (const CachingVertex<N> & v, const RefCountedVertexTrack track) const
90 {
91  // Using the update instead of the add methode, we can specify a weight which
92  // is different than then one which the vertex track has been defined with.
93  CachingVertex<N> rVert = updator.add(v, track);
94  if (!rVert.isValid()) return BDpair(false,-1.);
95  return BDpair(true, rVert.totalChiSquared()-v.totalChiSquared());
96 }
97 
98 
99 
100 template <unsigned int N>
103  (const CachingVertex<N> & more, const CachingVertex<N> & less,
104  const RefCountedVertexTrack track) const
105 {
106  BDpair trackRes = helper.trackParameterChi2(track);
107  return BDpair(trackRes.first, trackRes.second + helper.vertexChi2(less, more)) ;
108 }
109 
std::vector< RefCountedVertexTrack > tracks() const
Definition: CachingVertex.h:91
VertexState vertexState() const
Definition: CachingVertex.h:85
virtual BDpair estimate(const CachingVertex< N > &vrt, const RefCountedVertexTrack track) const
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:45
TrackBaseRef trackBaseRef() const
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:110
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:93
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const
float totalChiSquared() const
Definition: CachingVertex.h:99
double chi2() const
chi-squares
Definition: Vertex.h:82
tuple tracks
Definition: testEve_cfg.py:39
BDpair estimateDifference(const CachingVertex< N > &more, const CachingVertex< N > &less, const RefCountedVertexTrack track) const
bool isValid() const
Definition: CachingVertex.h:95
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:40
BDpair estimateFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const
mathSSE::Vec4< T > v
BDpair estimateNFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const