00001 #include "DataFormats/RecoCandidate/interface/IsoDepositVetos.h"
00002 #include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h"
00003
00004 #include <cmath>
00005 #include <iostream>
00006
00007 using namespace reco::isodeposit;
00008
00009 bool ConeVeto::veto(double eta, double phi, float value) const {
00010 return ( vetoDir_.deltaR2(Direction(eta,phi)) < dR2_ );
00011 }
00012 void ConeVeto::centerOn(double eta, double phi) {
00013 vetoDir_ = Direction(eta,phi);
00014 }
00016
00017 bool ThresholdVeto::veto(double eta, double phi, float value) const {
00018 return (value <= threshold_);
00019 }
00020 void ThresholdVeto::centerOn(double eta, double phi) { }
00021
00023
00024 bool ThresholdVetoFromTransverse::veto(double eta, double phi, float value) const {
00025 return ( value/sin(2*atan(exp(-eta))) <= threshold_);
00026 }
00027 void ThresholdVetoFromTransverse::centerOn(double eta, double phi) { }
00028
00030
00031 bool AbsThresholdVeto::veto(double eta, double phi, float value) const {
00032 return ( fabs(value) <= threshold_);
00033 }
00034 void AbsThresholdVeto::centerOn(double eta, double phi) { }
00035
00037
00038 bool AbsThresholdVetoFromTransverse::veto(double eta, double phi, float value) const {
00039 return ( fabs(value/sin(2*atan(exp(-eta)))) <= threshold_);
00040 }
00041 void AbsThresholdVetoFromTransverse::centerOn(double eta, double phi) { }
00042
00044
00045 bool ConeThresholdVeto::veto(double eta, double phi, float value) const {
00046 return (value <= threshold_) || ( vetoDir_.deltaR2(Direction(eta,phi)) < dR2_ );
00047 }
00048 void ConeThresholdVeto::centerOn(double eta, double phi) {
00049 vetoDir_ = Direction(eta,phi);
00050 }
00051
00053
00054 AngleConeVeto::AngleConeVeto(math::XYZVectorD dir, double angle) : vetoDir_(dir.Unit()), cosTheta_(cos(angle)) {
00055 }
00056 AngleConeVeto::AngleConeVeto(Direction dir, double angle) : vetoDir_(0,0,1), cosTheta_(cos(angle)) {
00057 vetoDir_ = math::RhoEtaPhiVectorD(1, dir.eta(), dir.phi()).Unit();
00058 }
00059 bool AngleConeVeto::veto(double eta, double phi, float value) const {
00060 math::RhoEtaPhiVectorD tmp(1, eta, phi);
00061 return ( vetoDir_.Dot(tmp.Unit()) > cosTheta_ );
00062 }
00063 void AngleConeVeto::centerOn(double eta, double phi) {
00064 vetoDir_ = math::RhoEtaPhiVectorD(1, eta, phi).Unit();
00065 }
00066
00068
00069 AngleCone::AngleCone(math::XYZVectorD dir, double angle) : coneDir_(dir.Unit()), cosTheta_(cos(angle)) {
00070 }
00071 AngleCone::AngleCone(Direction dir, double angle) : coneDir_(0,0,1), cosTheta_(cos(angle)) {
00072 coneDir_ = math::RhoEtaPhiVectorD(1, dir.eta(), dir.phi()).Unit();
00073 }
00074 bool AngleCone::veto(double eta, double phi, float value) const {
00075 math::RhoEtaPhiVectorD tmp(1, eta, phi);
00076 return ( coneDir_.Dot(tmp.Unit()) < cosTheta_ );
00077 }
00078 void AngleCone::centerOn(double eta, double phi) {
00079 coneDir_ = math::RhoEtaPhiVectorD(1, eta, phi).Unit();
00080 }
00081
00083
00084 RectangularEtaPhiVeto::RectangularEtaPhiVeto(math::XYZVectorD dir, double etaMin, double etaMax, double phiMin, double phiMax) :
00085 vetoDir_(dir.eta(),dir.phi()), etaMin_(etaMin), etaMax_(etaMax), phiMin_(phiMin), phiMax_(phiMax) {
00086 }
00087
00088 RectangularEtaPhiVeto::RectangularEtaPhiVeto(Direction dir, double etaMin, double etaMax, double phiMin, double phiMax) :
00089 vetoDir_(dir.eta(),dir.phi()), etaMin_(etaMin), etaMax_(etaMax), phiMin_(phiMin), phiMax_(phiMax) {
00090 }
00091
00092 bool RectangularEtaPhiVeto::veto(double eta, double phi, float value) const {
00093
00094
00095
00096
00097 double dPhi = phi - vetoDir_.phi();
00098 double dEta = eta - vetoDir_.eta();
00099 while( dPhi < -M_PI ) dPhi += 2*M_PI;
00100 while( dPhi >= M_PI ) dPhi -= 2*M_PI;
00101 return (etaMin_ < dEta) && (dEta < etaMax_) &&
00102 (phiMin_ < dPhi) && (dPhi < phiMax_);
00103 }
00104
00105 void RectangularEtaPhiVeto::centerOn(double eta, double phi) {
00106 vetoDir_ = Direction(eta,phi);
00107 }