CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoJets/FFTJetAlgorithms/src/JetToPeakDistance.cc

Go to the documentation of this file.
00001 #include <cmath>
00002 #include <cassert>
00003 
00004 #include "RecoJets/FFTJetAlgorithms/interface/JetToPeakDistance.h"
00005 
00006 namespace fftjetcms {
00007     JetToPeakDistance::JetToPeakDistance(const double etaToPhiBandwidthRatio)
00008         : etaBw_(sqrt(etaToPhiBandwidthRatio)),
00009           phiBw_(1.0/etaBw_)
00010     {
00011         assert(etaToPhiBandwidthRatio > 0.0);
00012     }
00013 
00014     double JetToPeakDistance::operator()(
00015         const fftjet::RecombinedJet<VectorLike>& j1,
00016         const fftjet::Peak& peak) const
00017     {
00018         if (peak.membershipFactor() <= 0.0)
00019             // This peak essentially does not exist...
00020             return 2.0e300;
00021 
00022         const double deta = (j1.vec().Eta() - peak.eta())/etaBw_;
00023         double dphi = j1.vec().Phi() - peak.phi();
00024         if (dphi > M_PI)
00025             dphi -= (2.0*M_PI);
00026         else if (dphi < -M_PI)
00027             dphi += (2.0*M_PI);
00028         dphi /= phiBw_;
00029         return sqrt(deta*deta + dphi*dphi);
00030     }
00031 }