Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:37

0001 #include "DataFormats/RecoCandidate/interface/IsoDepositVetos.h"
0002 #include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h"
0003 
0004 #include <cmath>
0005 #include <iostream>
0006 
0007 using namespace reco::isodeposit;
0008 
0009 bool ConeVeto::veto(double eta, double phi, float value) const {
0010   return (vetoDir_.deltaR2(Direction(eta, phi)) < dR2_);
0011 }
0012 void ConeVeto::centerOn(double eta, double phi) { vetoDir_ = Direction(eta, phi); }
0013 ///////////////////////////////////////////////////////////////////////////

0014 
0015 bool ThresholdVeto::veto(double eta, double phi, float value) const { return (value <= threshold_); }
0016 void ThresholdVeto::centerOn(double eta, double phi) {}
0017 
0018 ///////////////////////////////////////////////////////////////////////////

0019 
0020 bool ThresholdVetoFromTransverse::veto(double eta, double phi, float value) const {
0021   return (value / sin(2 * atan(exp(-eta))) <= threshold_);  // convert Et to E

0022 }
0023 void ThresholdVetoFromTransverse::centerOn(double eta, double phi) {}
0024 
0025 ///////////////////////////////////////////////////////////////////////////

0026 
0027 bool AbsThresholdVeto::veto(double eta, double phi, float value) const { return (fabs(value) <= threshold_); }
0028 void AbsThresholdVeto::centerOn(double eta, double phi) {}
0029 
0030 ///////////////////////////////////////////////////////////////////////////

0031 
0032 bool AbsThresholdVetoFromTransverse::veto(double eta, double phi, float value) const {
0033   return (fabs(value / sin(2 * atan(exp(-eta)))) <= threshold_);  // convert Et to E

0034 }
0035 void AbsThresholdVetoFromTransverse::centerOn(double eta, double phi) {}
0036 
0037 ///////////////////////////////////////////////////////////////////////////

0038 
0039 bool ConeThresholdVeto::veto(double eta, double phi, float value) const {
0040   return (value <= threshold_) || (vetoDir_.deltaR2(Direction(eta, phi)) < dR2_);
0041 }
0042 void ConeThresholdVeto::centerOn(double eta, double phi) { vetoDir_ = Direction(eta, phi); }
0043 
0044 ///////////////////////////////////////////////////////////////////////////

0045 
0046 AngleConeVeto::AngleConeVeto(const math::XYZVectorD& dir, double angle) : vetoDir_(dir.Unit()), cosTheta_(cos(angle)) {}
0047 AngleConeVeto::AngleConeVeto(Direction dir, double angle) : vetoDir_(0, 0, 1), cosTheta_(cos(angle)) {
0048   vetoDir_ = math::RhoEtaPhiVectorD(1, dir.eta(), dir.phi()).Unit();
0049 }
0050 bool AngleConeVeto::veto(double eta, double phi, float value) const {
0051   math::RhoEtaPhiVectorD tmp(1, eta, phi);
0052   return (vetoDir_.Dot(tmp.Unit()) > cosTheta_);
0053 }
0054 void AngleConeVeto::centerOn(double eta, double phi) { vetoDir_ = math::RhoEtaPhiVectorD(1, eta, phi).Unit(); }
0055 
0056 ///////////////////////////////////////////////////////////////////////////

0057 
0058 AngleCone::AngleCone(const math::XYZVectorD& dir, double angle) : coneDir_(dir.Unit()), cosTheta_(cos(angle)) {}
0059 AngleCone::AngleCone(Direction dir, double angle) : coneDir_(0, 0, 1), cosTheta_(cos(angle)) {
0060   coneDir_ = math::RhoEtaPhiVectorD(1, dir.eta(), dir.phi()).Unit();
0061 }
0062 bool AngleCone::veto(double eta, double phi, float value) const {
0063   math::RhoEtaPhiVectorD tmp(1, eta, phi);
0064   return (coneDir_.Dot(tmp.Unit()) < cosTheta_);
0065 }
0066 void AngleCone::centerOn(double eta, double phi) { coneDir_ = math::RhoEtaPhiVectorD(1, eta, phi).Unit(); }
0067 
0068 ///////////////////////////////////////////////////////////////////////////

0069 
0070 RectangularEtaPhiVeto::RectangularEtaPhiVeto(
0071     const math::XYZVectorD& dir, double etaMin, double etaMax, double phiMin, double phiMax)
0072     : vetoDir_(dir.eta(), dir.phi()), etaMin_(etaMin), etaMax_(etaMax), phiMin_(phiMin), phiMax_(phiMax) {}
0073 
0074 RectangularEtaPhiVeto::RectangularEtaPhiVeto(Direction dir, double etaMin, double etaMax, double phiMin, double phiMax)
0075     : vetoDir_(dir.eta(), dir.phi()), etaMin_(etaMin), etaMax_(etaMax), phiMin_(phiMin), phiMax_(phiMax) {}
0076 
0077 bool RectangularEtaPhiVeto::veto(double eta, double phi, float value) const {
0078   //vetoDir_.phi() is already [0,2*M_PI], make sure the vetoDir phi is

0079   //also assuming that the etaMin_ and etaMax_ are set correctly by user

0080   //or possible user only wants a limit in one directions

0081   //so should be able to set phi or eta to something extreme (-100,100) e.g.

0082   double dPhi = phi - vetoDir_.phi();
0083   double dEta = eta - vetoDir_.eta();
0084   while (dPhi < -M_PI)
0085     dPhi += 2 * M_PI;
0086   while (dPhi >= M_PI)
0087     dPhi -= 2 * M_PI;
0088   return (etaMin_ < dEta) && (dEta < etaMax_) && (phiMin_ < dPhi) && (dPhi < phiMax_);
0089 }
0090 
0091 void RectangularEtaPhiVeto::centerOn(double eta, double phi) { vetoDir_ = Direction(eta, phi); }