Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:07

0001 #include "PhysicsTools/PatUtils/interface/VertexAssociationSelector.h"
0002 //#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
0003 //#include "DataFormats/TrackReco/interface/Track.h"
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     // D = sqrt( DZ^2 + DY^2) => sigma^2(D) = d D/d X_i * cov(X_i, X_j) * d D/d X_j =>
0027     // d D / d X_i = DX_i / D
0028     // D > sigmaR * sigma(D)   if and only if D^4 > sigmaR^2 * DX_i DX_j cov(X_i,X_j)
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     if (conf_.sigmas3d > 0) {
0037         // same as above, but 3D
0038          AlgebraicVector3 dist(c.vx() - vtx.x(), c.vy() - vtx.y(), c.vz() - vtx.z());
0039         double D2 = dist[0]*dist[0] + dist[1]*dist[1] + dist[2]*dist[2];
0040         double DcovD = ROOT::Math::Similarity(dist, vtx.error());
0041         if ( D2*D2 > DcovD * (conf_.sigmas3d*conf_.sigmas3d) ) return false;
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   // if ((conf_.sigmas3d > 0) && ( vass.signif3d()           > conf_.sigmas3d)) return false;
0060   return true;
0061 }