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 
5 namespace {
6 
7  using Point = math::XYZPoint;
8 
9 
10  Point getBestVertex(reco::Track const & trk, reco::VertexCollection const & vertices) {
11 
12  Point p_dz(0,0,-99999);
13  float dzmin = std::numeric_limits<float>::max();
14  for(auto const & vertex : vertices) {
15  float dz = std::abs(trk.dz(vertex.position()));
16  if(dz < dzmin){
17  p_dz = vertex.position();
18  dzmin = dz;
19  }
20  }
21 
22  return p_dz;
23 
24  }
25 
26  /*
27  Point getBestVertex(reco::Track const & trk,, VertexCollection const & vertices) {
28 
29  // Point p(0,0,-99999);
30  Point p_dz(0,0,-99999);
31  // float bestWeight = 0;
32  float dzmin = 10000;
33  for(auto const & vertex : vertices){
34  // auto w = vertex.trackWeight(track);
35  Point v_pos = vertex.position();
36  // if(w > bestWeight){
37  // p = v_pos;
38  // bestWeight = w;
39  //} else if (0 == bestWeight) {
40  float dz = std::abs(trK.dz(v_pos));
41  if(dz < dzmin){
42  p_dz = v_pos;
43  dzmin = dz;
44  }
45  //}
46  }
47 
48  return (bestWeight > 0) ? p : p_dz;
49 
50  }
51  */
52 }
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
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:596
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12