00001 #include "RecoVertex/VertexTools/interface/VertexCompatibleWithBeam.h" 00002 #include "DataFormats/GeometryVector/interface/GlobalPoint.h" 00003 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h" 00004 #include "RecoVertex/VertexTools/interface/VertexDistance.h" 00005 #include "RecoVertex/VertexPrimitives/interface/ConvertError.h" 00006 00007 using namespace reco; 00008 00009 VertexCompatibleWithBeam::VertexCompatibleWithBeam(const VertexDistance & d, 00010 float cut) 00011 : theDistance(d.clone()), theCut(cut) 00012 { 00013 BeamSpot beamSpot; 00014 theBeam = VertexState(beamSpot); 00015 } 00016 00017 VertexCompatibleWithBeam::VertexCompatibleWithBeam(const VertexDistance & d, 00018 float cut, const BeamSpot & beamSpot) 00019 : theDistance(d.clone()), theCut(cut), theBeam(beamSpot){} 00020 00021 00022 VertexCompatibleWithBeam::VertexCompatibleWithBeam( 00023 const VertexCompatibleWithBeam & other) : 00024 theDistance((*other.theDistance).clone()), 00025 theCut(other.theCut), theBeam(other.theBeam) {} 00026 00027 00028 VertexCompatibleWithBeam::~VertexCompatibleWithBeam() { 00029 delete theDistance; 00030 } 00031 00032 00033 VertexCompatibleWithBeam & 00034 VertexCompatibleWithBeam::operator=(const VertexCompatibleWithBeam & other) 00035 { 00036 if (this == &other) return *this; 00037 00038 theDistance = (*other.theDistance).clone(); 00039 theCut = other.theCut; 00040 theBeam = other.theBeam; 00041 return *this; 00042 } 00043 00044 void VertexCompatibleWithBeam::setBeamSpot(const BeamSpot & beamSpot){ 00045 theBeam = VertexState(beamSpot); 00046 } 00047 00048 bool VertexCompatibleWithBeam::operator()(const reco::Vertex & v) const 00049 { 00050 GlobalPoint p(Basic3DVector<float> (v.position())); 00051 VertexState vs(p, RecoVertex::convertError(v.covariance())); 00052 return (theDistance->distance(vs, theBeam).value() < theCut); 00053 } 00054 00055 00056 float VertexCompatibleWithBeam::distanceToBeam(const reco::Vertex & v) const 00057 { 00058 GlobalPoint p(Basic3DVector<float> (v.position())); 00059 VertexState vs(p, RecoVertex::convertError(v.covariance())); 00060 return theDistance->distance(vs, theBeam).value(); 00061 } 00062 00063 00064 float VertexCompatibleWithBeam::distanceToBeam(const reco::Vertex & v, const VertexState & bs) const 00065 { 00066 GlobalPoint p(Basic3DVector<float> (v.position())); 00067 VertexState vs(p, RecoVertex::convertError(v.covariance())); 00068 return theDistance->distance(vs, bs).value(); 00069 } 00070 00071 00072 bool VertexCompatibleWithBeam::operator()(const reco::Vertex & v, const VertexState & bs) const 00073 { 00074 GlobalPoint p(Basic3DVector<float> (v.position())); 00075 VertexState vs(p, RecoVertex::convertError(v.covariance())); 00076 return (theDistance->distance(vs, bs).value() < theCut); 00077 } 00078 00079