CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/PhysicsTools/PatUtils/src/VertexAssociationSelector.cc

Go to the documentation of this file.
00001 #include "PhysicsTools/PatUtils/interface/VertexAssociationSelector.h"
00002 //#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00003 //#include "DataFormats/TrackReco/interface/Track.h"
00004 #include <cmath>
00005 
00006 pat::VertexAssociationSelector::VertexAssociationSelector(const Config & conf) : 
00007     conf_(conf) 
00008 {
00009 }
00010 
00011 pat::VertexAssociation
00012 pat::VertexAssociationSelector::simpleAssociation(const reco::Candidate &c, const reco::VertexRef &vtx) const {    
00013     pat::VertexAssociation ret(vtx);
00014     ret.setDistances(c.vertex(), vtx->position(), vtx->error());
00015     return ret;
00016 }
00017 
00018 
00019 bool
00020 pat::VertexAssociationSelector::operator()(const reco::Candidate &c, const reco::Vertex &vtx) const {    
00021     using std::abs;
00022     using std::sqrt;
00023 
00024     if ((conf_.dZ > 0)      && !( std::abs(c.vz() - vtx.z())                > conf_.dZ    )) return false;
00025     if ((conf_.sigmasZ > 0) && !( std::abs(c.vz() - vtx.z())                > conf_.sigmasZ * vtx.zError())) return false;
00026     if ((conf_.dR > 0)      && !( (c.vertex() - vtx.position()).Rho() > conf_.dR    )) return false;
00027     if ( conf_.sigmasR > 0) {
00028         // D = sqrt( DZ^2 + DY^2) => sigma^2(D) = d D/d X_i * cov(X_i, X_j) * d D/d X_j =>
00029         // d D / d X_i = DX_i / D
00030         // D > sigmaR * sigma(D)   if and only if D^4 > sigmaR^2 * DX_i DX_j cov(X_i,X_j)
00031         AlgebraicVector3 dist(c.vx() - vtx.x(), c.vy() - vtx.y(), 0);
00032         double D2 = dist[0]*dist[0] + dist[1]*dist[1];
00033         double DcovD = ROOT::Math::Similarity(dist, vtx.error());
00034         if ( D2*D2 > DcovD * (conf_.sigmasR*conf_.sigmasR) ) return false;
00035     }
00036     /*
00037     if (conf_.sigmas3d > 0) {
00038         // same as above, but 3D
00039          AlgebraicVector3 dist(c.vx() - vtx.x(), c.vy() - vtx.y(), c.vz() - vtx.z());
00040         double D2 = dist[0]*dist[0] + dist[1]*dist[1] + dist[2]*dist[2];
00041         double DcovD = ROOT::Math::Similarity(dist, vtx.error());
00042         if ( D2*D2 > DcovD * (conf_.sigmas3d*conf_.sigmas3d) ) return false;
00043     }
00044     */
00045 
00046     return true;
00047 }
00048 
00049 bool
00050 pat::VertexAssociationSelector::operator()(const pat::VertexAssociation &vass) const {    
00051     if (vass.isNull()) return false;
00052     if ((conf_.dZ > 0)       && ( vass.dz().value()         > conf_.dZ      )) return false;
00053     if ((conf_.sigmasZ > 0)  && ( vass.dz().significance()  > conf_.sigmasZ )) return false;
00054     if ((conf_.dZ > 0)       && ( vass.dr().value()         > conf_.dR      )) return false;
00055     if ((conf_.sigmasZ > 0)  && ( vass.dr().significance()  > conf_.sigmasR )) return false;
00056     // if ((conf_.sigmas3d > 0) && ( vass.signif3d()           > conf_.sigmas3d)) return false;
00057     return true;
00058 }