test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GsfVertexTrackCompatibilityEstimator.cc
Go to the documentation of this file.
3 #include <algorithm>
4 using namespace reco;
5 
6 // template <unsigned int N>
7 // struct vT_find
8 // {
9 // typedef typename CachingVertex<N>::RefCountedVertexTrack RefCountedVertexTrack;
10 // bool operator()(const CachingVertex<5> & v, const RefCountedVertexTrack t)
11 // {
12 // //initial tracks
13 // vector<RefCountedVertexTrack> tracks = v.tracks();
14 // vector<RefCountedVertexTrack>::iterator pos
15 // = find_if(tracks.begin(), tracks.end(), VertexTrackEqual(t));
16 // return (pos != tracks.end());
17 // }
18 // };
19 
20 
21 std::pair<bool, double>
23  const RefCountedVertexTrack tr, unsigned int hint) const
24 {
25 //checking if the track passed really belongs to the vertex
26  std::vector<RefCountedVertexTrack> tracks = vertex.tracks();
27  std::vector<RefCountedVertexTrack>::iterator pos
28  = find_if(tracks.begin(), tracks.end(), VertexTrackEqual<5>(tr));
29  if (pos != tracks.end()) {
30  return estimateFittedTrack(vertex,*pos);
31  } else {
32  return estimateNFittedTrack(vertex,tr);
33  }
34 }
35 
36 
37 std::pair<bool, double>
40  unsigned int hint) const
41 {
42  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track,
43  vertex.vertexState());
44  return estimate(vertex, vertexTrack);
45 }
46 
47 
48 std::pair<bool, double>
50  const reco::TransientTrack & track) const
51 {
52 // GlobalPoint linP(vertex.position().x(), vertex.position().z(),vertex.position().z());
53  GlobalPoint linP(Basic3DVector<float> (vertex.position()));
54 
56  lTrackFactory.linearizedTrackState(linP, track);
57  GlobalError err(vertex.covariance());
58  VertexState vState(linP, err);
59  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
60 
61  std::vector<RefCountedVertexTrack> initialTracks(1, vertexTrack);
62  CachingVertex<5> cachingVertex(linP, err, initialTracks,
63  vertex.chi2());
64  // FIXME: this should work also for tracks without a persistent ref.
65 // const TrackTransientTrack* ttt = dynamic_cast<const TrackTransientTrack*>(track.basicTransientTrack());
66 // if ((ttt!=0) &&
67  if (find(vertex.tracks_begin(), vertex.tracks_end(), track.trackBaseRef()) != vertex.tracks_end())
68  {
69  return estimateFittedTrack(cachingVertex, vertexTrack);
70  } else {
71  return estimateNFittedTrack(cachingVertex, vertexTrack);
72  }
73 }
74 
75 
76 
77 // methods to calculate track<-->vertex compatibility
78 // with the track belonging to the vertex
79 
80 std::pair<bool, double>
82  (const CachingVertex<5> & v, const RefCountedVertexTrack track) const
83 {
84  //remove track from the vertex using the vertex updator
85  // Using the update instead of the remove methode, we can specify a weight which
86  // is different than then one which the vertex track has been defined with.
87  if (track->refittedStateAvailable()) return BDpair(true, track->smoothedChi2());
88  throw VertexException
89  ("GsfVertexTrackCompatibilityEstimator::vertex has to be smoothed.");
90 
91 // CachingVertex rVert = updator.remove(v, track);
92 // RefCountedVertexTrack newSmoothedTrack = trackUpdator.update(v, track);
93 // return estimateDifference(v,rVert,newSmoothedTrack);
94 }
95 
96 // method calculating track<-->vertex compatibility
97 //with the track not belonging to vertex
98 std::pair<bool, double>
100  (const CachingVertex<5> & v, const RefCountedVertexTrack track) const
101 {
102  // Using the update instead of the add methode, we can specify a weight which
103  // is different than then one which the vertex track has been defined with.
104  CachingVertex<5> rVert = updator.add(v, track);
105  if (!rVert.isValid()) return BDpair(false,-1.);
106  return BDpair(true, rVert.totalChiSquared()-v.totalChiSquared());
107 }
108 
CachingVertex< 5 >::RefCountedVertexTrack RefCountedVertexTrack
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
TrackBaseRef trackBaseRef() const
Common base class.
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
std::vector< RefCountedVertexTrack > const & tracks() const
Definition: CachingVertex.h:91
virtual BDpair estimate(const CachingVertex< 5 > &vrt, const RefCountedVertexTrack track, unsigned int hint=UINT_MAX) const
float totalChiSquared() const
double chi2() const
chi-squares
Definition: Vertex.h:95
BDpair estimateNFittedTrack(const CachingVertex< 5 > &v, const RefCountedVertexTrack track) const
tuple tracks
Definition: testEve_cfg.py:39
bool isValid() const
Definition: CachingVertex.h:96
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
BDpair estimateFittedTrack(const CachingVertex< 5 > &v, const RefCountedVertexTrack track) const