1 #ifndef RecoVertex_PrimaryVertexProducer_WeightedMeanFitter_h 2 #define RecoVertex_PrimaryVertexProducer_WeightedMeanFitter_h 21 double ox = iclus.
vx();
22 double oy = iclus.
vy();
23 double oz = iclus.
vz();
25 double vx = iclus.
px();
26 double vy = iclus.
py();
27 double vz = iclus.
pz();
29 double opx =
vertex.x() - ox;
30 double opy =
vertex.y() - oy;
31 double opz =
vertex.z() - oz;
34 double t = (
vx * opx +
vy * opy +
vz * opz) / (vnorm2);
37 return std::pair<GlobalPoint, double>(
43 std::vector<reco::TransientTrack> iclus) {
44 float x = 0., y = 0., z = 0.;
45 float s_wx = 0., s_wz = 0.;
46 float s2_wx = 0., s2_wz = 0.;
47 float wx = 0., wz = 0.,
chi2 = 0.;
59 x +=
p.first.x() * wx;
60 y +=
p.first.y() * wx;
61 z +=
p.first.z() * wz;
67 if (s_wx == 0. || s_wz == 0.) {
68 edm::LogWarning(
"WeightedMeanFitter") <<
"Vertex fitting failed at beginning\n";
76 float old_x, old_y, old_z;
86 while ((niter++) < 2) {
99 for (
unsigned int i = 0;
i < (
unsigned int)
points.size();
i++) {
117 x += wx *
p.first.x();
118 y += wx *
p.first.y();
119 z += wz *
p.first.z();
128 if (s_wx == 0. || s_wz == 0.) {
130 <<
"Vertex fitting failed, either all tracks are outliers or they have a very large error\n";
169 std::vector<reco::TransientTrack> iclus,
171 float x = 0., y = 0., z = 0.;
172 float s_wx = 0., s_wz = 0.;
173 float s2_wx = 0., s2_wz = 0.;
174 float wx = 0., wz = 0.,
chi2 = 0.;
175 float wy = 0., s_wy = 0., s2_wy = 0.;
192 x +=
p.first.x() * wx;
193 y +=
p.first.y() * wy;
194 z +=
p.first.z() * wz;
201 if (s_wx == 0. || s_wy == 0. || s_wz == 0.) {
202 edm::LogWarning(
"WeightedMeanFitter") <<
"Vertex fitting failed at beginning\n";
216 float old_x, old_y, old_z;
227 while ((niter++) < 2) {
244 for (
unsigned int i = 0;
i < (
unsigned int)
points.size();
i++) {
264 x += wx *
p.first.x();
265 y += wy *
p.first.y();
266 z += wz *
p.first.z();
277 if (s_wx == 0. || s_wy == 0. || s_wz == 0.) {
279 <<
"Vertex fitting failed, either all tracks are outliers or they have a very large error\n";
327 std::vector<std::vector<reco::TransientTrack>>::const_iterator iclus) {
328 float x = 0, y = 0, z = 0, s_wx = 0, s_wy = 0, s_wz = 0, wx = 0, wy = 0, wz = 0,
chi2 = 0;
332 err(0, 0) =
err(1, 1) =
err(2, 2) / 100.;
341 x +=
p.first.x() * wx;
342 y +=
p.first.y() * wx;
343 z +=
p.first.z() * wz;
349 if (s_wx == 0. || s_wz == 0.) {
350 edm::LogWarning(
"WeightedMeanFitter") <<
"Vertex fitting failed at beginning\n";
358 float old_x, old_y, old_z;
365 float s_err_x = 0., s_err_y = 0., s_err_z = 0.;
384 wy = wx * wx +
err_y;
385 wx = wx * wx +
err_x;
389 wz = wz * wz +
err_z;
391 xpull =
std::pow((
p.first.x() - old_x), 2) / wx;
392 xpull +=
std::pow((
p.first.y() - old_y), 2) / wy;
393 xpull +=
std::pow((
p.first.z() - old_z), 2) / wz;
405 x += wx *
p.first.x();
406 y += wy *
p.first.y();
407 z += wz *
p.first.z();
413 s_err_x += wx *
pow(
p.first.x() - old_x, 2);
414 s_err_y += wy *
pow(
p.first.y() - old_y, 2);
415 s_err_z += wz *
pow(
p.first.z() - old_z, 2);
417 if (s_wx == 0. || s_wy == 0. || s_wz == 0.) {
419 <<
"Vertex fitting failed, either all tracks are outliers or they have a very large error\n";
426 err_x = s_err_x / s_wx;
427 err_y = s_err_y / s_wy;
428 err_z = s_err_z / s_wz;
double vx() const
x coordinate of the reference point on track
double px() const
x coordinate of momentum vector
constexpr float corr_x_bs
Global3DPoint GlobalPoint
double py() const
y coordinate of momentum vector
U second(std::pair< T, U > const &p)
TransientVertex weightedMeanOutlierRejectionVarianceAsError(const std::vector< std::pair< GlobalPoint, GlobalPoint >> &points, std::vector< std::vector< reco::TransientTrack >>::const_iterator iclus)
double vz() const
z coordinate of the reference point on track
constexpr float precision
TransientVertex weightedMeanOutlierRejectionBeamSpot(const std::vector< std::pair< GlobalPoint, GlobalPoint >> &points, std::vector< reco::TransientTrack > iclus, const reco::BeamSpot &beamSpot)
Abs< T >::type abs(const T &t)
constexpr int maxIterations
double pz() const
z coordinate of momentum vector
std::pair< GlobalPoint, double > nearestPoint(const GlobalPoint &vertex, reco::Track iclus)
double vy() const
y coordinate of the reference point on track
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
Log< level::Warning, false > LogWarning
TransientVertex weightedMeanOutlierRejection(const std::vector< std::pair< GlobalPoint, GlobalPoint >> &points, std::vector< reco::TransientTrack > iclus)
constexpr float startError