CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
getBestVertex.h
Go to the documentation of this file.
3 #include <limits>
4 
6 
7  inline
8  Point getBestVertex(reco::Track const & trk, reco::VertexCollection const & vertices, const size_t minNtracks = 2) {
9 
10  Point p_dz(0,0,-99999);
11  float dzmin = std::numeric_limits<float>::max();
12  for(auto const & vertex : vertices) {
13  size_t tracks = vertex.tracksSize();
14  if (tracks < minNtracks) {
15  continue;
16  }
17  float dz = std::abs(trk.dz(vertex.position()));
18  if(dz < dzmin){
19  p_dz = vertex.position();
20  dzmin = dz;
21  }
22  }
23 
24  return p_dz;
25 
26  }
27 
28  inline
29  Point getBestVertex_withError(reco::Track const & trk, reco::VertexCollection const & vertices, Point& error, const size_t minNtracks = 2) {
30 
31  Point p_dz(0,0,-99999);
32  float dzmin = std::numeric_limits<float>::max();
33  for(auto const & vertex : vertices) {
34  size_t tracks = vertex.tracksSize();
35  if (tracks < minNtracks) {
36  continue;
37  }
38  float dz = std::abs(trk.dz(vertex.position()));
39  if(dz < dzmin){
40  p_dz = vertex.position();
41  error.SetXYZ(vertex.xError(),vertex.yError(),vertex.zError());
42  dzmin = dz;
43  }
44  }
45 
46  return p_dz;
47 
48  }
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
Point getBestVertex_withError(reco::Track const &trk, reco::VertexCollection const &vertices, Point &error, const size_t minNtracks=2)
Definition: getBestVertex.h:29
math::XYZPoint Point
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:604
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Point getBestVertex(reco::Track const &trk, reco::VertexCollection const &vertices, const size_t minNtracks=2)
Definition: getBestVertex.h:8