CMS 3D CMS Logo

Typedefs | Functions
getBestVertex.h File Reference
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include <limits>

Go to the source code of this file.

Typedefs

using Point = math::XYZPoint
 

Functions

Point getBestVertex (reco::Track const &trk, reco::VertexCollection const &vertices, const size_t minNtracks=2)
 
Point getBestVertex_withError (reco::Track const &trk, reco::VertexCollection const &vertices, Point &error, const size_t minNtracks=2)
 

Typedef Documentation

◆ Point

Definition at line 6 of file getBestVertex.h.

Function Documentation

◆ getBestVertex()

Point getBestVertex ( reco::Track const &  trk,
reco::VertexCollection const &  vertices,
const size_t  minNtracks = 2 
)
inline

Definition at line 8 of file getBestVertex.h.

References funct::abs(), PVValHelper::dz, reco::TrackBase::dz(), WZElectronSkims53X_cff::max, DiMuonV_cfg::tracks, bphysicsOniaDQM_cfi::vertex, and AlignmentTracksFromVertexSelector_cfi::vertices.

Referenced by TrackingNtuple::fillTracks().

10  {
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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Structure Point Contains parameters of Gaussian fits to DMRs.

◆ getBestVertex_withError()

Point getBestVertex_withError ( reco::Track const &  trk,
reco::VertexCollection const &  vertices,
Point error,
const size_t  minNtracks = 2 
)
inline

Definition at line 28 of file getBestVertex.h.

References funct::abs(), PVValHelper::dz, reco::TrackBase::dz(), relativeConstraints::error, WZElectronSkims53X_cff::max, DiMuonV_cfg::tracks, bphysicsOniaDQM_cfi::vertex, and AlignmentTracksFromVertexSelector_cfi::vertices.

31  {
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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Structure Point Contains parameters of Gaussian fits to DMRs.