File indexing completed on 2024-04-06 12:24:07
0001 #include "PhysicsTools/PatUtils/interface/VertexAssociationSelector.h"
0002
0003
0004 #include <cmath>
0005
0006 pat::VertexAssociationSelector::VertexAssociationSelector(const Config &conf) : conf_(conf) {}
0007
0008 pat::VertexAssociation pat::VertexAssociationSelector::simpleAssociation(const reco::Candidate &c,
0009 const reco::VertexRef &vtx) const {
0010 pat::VertexAssociation ret(vtx);
0011 ret.setDistances(c.vertex(), vtx->position(), vtx->error());
0012 return ret;
0013 }
0014
0015 bool pat::VertexAssociationSelector::operator()(const reco::Candidate &c, const reco::Vertex &vtx) const {
0016 using std::abs;
0017 using std::sqrt;
0018
0019 if ((conf_.dZ > 0) && !(std::abs(c.vz() - vtx.z()) > conf_.dZ))
0020 return false;
0021 if ((conf_.sigmasZ > 0) && !(std::abs(c.vz() - vtx.z()) > conf_.sigmasZ * vtx.zError()))
0022 return false;
0023 if ((conf_.dR > 0) && !((c.vertex() - vtx.position()).Rho() > conf_.dR))
0024 return false;
0025 if (conf_.sigmasR > 0) {
0026
0027
0028
0029 AlgebraicVector3 dist(c.vx() - vtx.x(), c.vy() - vtx.y(), 0);
0030 double D2 = dist[0] * dist[0] + dist[1] * dist[1];
0031 double DcovD = ROOT::Math::Similarity(dist, vtx.error());
0032 if (D2 * D2 > DcovD * (conf_.sigmasR * conf_.sigmasR))
0033 return false;
0034 }
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 return true;
0046 }
0047
0048 bool pat::VertexAssociationSelector::operator()(const pat::VertexAssociation &vass) const {
0049 if (vass.isNull())
0050 return false;
0051 if ((conf_.dZ > 0) && (vass.dz().value() > conf_.dZ))
0052 return false;
0053 if ((conf_.sigmasZ > 0) && (vass.dz().significance() > conf_.sigmasZ))
0054 return false;
0055 if ((conf_.dZ > 0) && (vass.dr().value() > conf_.dR))
0056 return false;
0057 if ((conf_.sigmasZ > 0) && (vass.dr().significance() > conf_.sigmasR))
0058 return false;
0059
0060 return true;
0061 }