CMS 3D CMS Logo

getBestVertex.h
Go to the documentation of this file.
4 #include <limits>
5 
7 
8 inline Point getBestVertex(reco::Track const& trk,
10  const size_t minNtracks = 2) {
11  Point p_dz(0, 0, -99999);
12  float dzmin = std::numeric_limits<float>::max();
13  for (auto const& vertex : vertices) {
14  size_t tracks = vertex.tracksSize();
15  if (tracks < minNtracks) {
16  continue;
17  }
18  float dz = std::abs(trk.dz(vertex.position()));
19  if (dz < dzmin) {
20  p_dz = vertex.position();
21  dzmin = dz;
22  }
23  }
24 
25  return p_dz;
26 }
27 
30  Point& error,
31  const size_t minNtracks = 2) {
32  Point p_dz(0, 0, -99999);
33  float dzmin = std::numeric_limits<float>::max();
34  for (auto const& vertex : vertices) {
35  size_t tracks = vertex.tracksSize();
36  if (tracks < minNtracks) {
37  continue;
38  }
39  float dz = std::abs(trk.dz(vertex.position()));
40  if (dz < dzmin) {
41  p_dz = vertex.position();
42  error.SetXYZ(vertex.xError(), vertex.yError(), vertex.zError());
43  dzmin = dz;
44  }
45  }
46 
47  return p_dz;
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:28
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:622
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
auto const & tracks
cannot be loose
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
Point getBestVertex(reco::Track const &trk, reco::VertexCollection const &vertices, const size_t minNtracks=2)
Definition: getBestVertex.h:8