File indexing completed on 2024-04-06 12:25:22
0001 #include <cmath>
0002 #include <cassert>
0003
0004 #include "RecoJets/FFTJetAlgorithms/interface/JetToPeakDistance.h"
0005
0006 namespace fftjetcms {
0007 JetToPeakDistance::JetToPeakDistance(const double etaToPhiBandwidthRatio)
0008 : etaBw_(sqrt(etaToPhiBandwidthRatio)), phiBw_(1.0 / etaBw_) {
0009 assert(etaToPhiBandwidthRatio > 0.0);
0010 }
0011
0012 double JetToPeakDistance::operator()(const fftjet::RecombinedJet<VectorLike>& j1, const fftjet::Peak& peak) const {
0013 if (peak.membershipFactor() <= 0.0)
0014
0015 return 2.0e300;
0016
0017 const double deta = (j1.vec().Eta() - peak.eta()) / etaBw_;
0018 double dphi = j1.vec().Phi() - peak.phi();
0019 if (dphi > M_PI)
0020 dphi -= (2.0 * M_PI);
0021 else if (dphi < -M_PI)
0022 dphi += (2.0 * M_PI);
0023 dphi /= phiBw_;
0024 return sqrt(deta * deta + dphi * dphi);
0025 }
0026 }