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, const size_t minNtracks = 2) {
11 
12  Point p_dz(0,0,-99999);
13  float dzmin = std::numeric_limits<float>::max();
14  for(auto const & vertex : vertices) {
15  size_t tracks = vertex.tracksSize();
16  if (tracks < minNtracks) {
17  continue;
18  }
19  float dz = std::abs(trk.dz(vertex.position()));
20  if(dz < dzmin){
21  p_dz = vertex.position();
22  dzmin = dz;
23  }
24  }
25 
26  return p_dz;
27 
28  }
29 
30  /*
31  Point getBestVertex(reco::Track const & trk,, VertexCollection const & vertices) {
32 
33  // Point p(0,0,-99999);
34  Point p_dz(0,0,-99999);
35  // float bestWeight = 0;
36  float dzmin = 10000;
37  for(auto const & vertex : vertices){
38  // auto w = vertex.trackWeight(track);
39  Point v_pos = vertex.position();
40  // if(w > bestWeight){
41  // p = v_pos;
42  // bestWeight = w;
43  //} else if (0 == bestWeight) {
44  float dz = std::abs(trK.dz(v_pos));
45  if(dz < dzmin){
46  p_dz = v_pos;
47  dzmin = dz;
48  }
49  //}
50  }
51 
52  return (bestWeight > 0) ? p : p_dz;
53 
54  }
55  */
56 }
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:604
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12