Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:20

0001 #include "RecoVertex/VertexTools/interface/VertexCompatibleWithBeam.h"
0002 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0003 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
0004 #include "RecoVertex/VertexTools/interface/VertexDistance.h"
0005 
0006 using namespace reco;
0007 
0008 VertexCompatibleWithBeam::VertexCompatibleWithBeam(const VertexDistance& d, float cut)
0009     : theDistance(d.clone()), theCut(cut) {
0010   BeamSpot beamSpot;
0011   theBeam = VertexState(beamSpot);
0012 }
0013 
0014 VertexCompatibleWithBeam::VertexCompatibleWithBeam(const VertexDistance& d, float cut, const BeamSpot& beamSpot)
0015     : theDistance(d.clone()), theCut(cut), theBeam(beamSpot) {}
0016 
0017 VertexCompatibleWithBeam::VertexCompatibleWithBeam(const VertexCompatibleWithBeam& other)
0018     : theDistance((*other.theDistance).clone()), theCut(other.theCut), theBeam(other.theBeam) {}
0019 
0020 VertexCompatibleWithBeam::~VertexCompatibleWithBeam() { delete theDistance; }
0021 
0022 VertexCompatibleWithBeam& VertexCompatibleWithBeam::operator=(const VertexCompatibleWithBeam& other) {
0023   if (this == &other)
0024     return *this;
0025 
0026   theDistance = (*other.theDistance).clone();
0027   theCut = other.theCut;
0028   theBeam = other.theBeam;
0029   return *this;
0030 }
0031 
0032 void VertexCompatibleWithBeam::setBeamSpot(const BeamSpot& beamSpot) { theBeam = VertexState(beamSpot); }
0033 
0034 bool VertexCompatibleWithBeam::operator()(const reco::Vertex& v) const {
0035   GlobalPoint p(Basic3DVector<float>(v.position()));
0036   VertexState vs(p, GlobalError(v.covariance()));
0037   return (theDistance->distance(vs, theBeam).value() < theCut);
0038 }
0039 
0040 float VertexCompatibleWithBeam::distanceToBeam(const reco::Vertex& v) const {
0041   GlobalPoint p(Basic3DVector<float>(v.position()));
0042   VertexState vs(p, GlobalError(v.covariance()));
0043   return theDistance->distance(vs, theBeam).value();
0044 }
0045 
0046 float VertexCompatibleWithBeam::distanceToBeam(const reco::Vertex& v, const VertexState& bs) const {
0047   GlobalPoint p(Basic3DVector<float>(v.position()));
0048   VertexState vs(p, GlobalError(v.covariance()));
0049   return theDistance->distance(vs, bs).value();
0050 }
0051 
0052 bool VertexCompatibleWithBeam::operator()(const reco::Vertex& v, const VertexState& bs) const {
0053   GlobalPoint p(Basic3DVector<float>(v.position()));
0054   VertexState vs(p, GlobalError(v.covariance()));
0055   return (theDistance->distance(vs, bs).value() < theCut);
0056 }