CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoVertex/VertexTools/src/VertexCompatibleWithBeam.cc

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