Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:22

0001 #include <cmath>
0002 #include <cassert>
0003 
0004 #include "RecoJets/FFTJetAlgorithms/interface/JetConvergenceDistance.h"
0005 
0006 namespace fftjetcms {
0007   JetConvergenceDistance::JetConvergenceDistance(const double etaToPhiBandwidthRatio, const double relativePtBandwidth)
0008       : etaBw_(sqrt(etaToPhiBandwidthRatio)), phiBw_(1.0 / etaBw_), ptBw_(relativePtBandwidth) {
0009     assert(etaToPhiBandwidthRatio > 0.0);
0010     assert(relativePtBandwidth > 0.0);
0011   }
0012 
0013   double JetConvergenceDistance::operator()(const fftjet::RecombinedJet<VectorLike>& j1,
0014                                             const fftjet::RecombinedJet<VectorLike>& j2) const {
0015     const double deta = (j1.vec().Eta() - j2.vec().Eta()) / etaBw_;
0016     double dphi = j1.vec().Phi() - j2.vec().Phi();
0017     if (dphi > M_PI)
0018       dphi -= (2.0 * M_PI);
0019     else if (dphi < -M_PI)
0020       dphi += (2.0 * M_PI);
0021     dphi /= phiBw_;
0022     const double mag1 = j1.magnitude();
0023     const double mag2 = j2.magnitude();
0024     double dmag = 0.0;
0025     if (mag1 > 0.0 || mag2 > 0.0)
0026       dmag = 2.0 * (mag1 - mag2) / (mag1 + mag2) / ptBw_;
0027     return sqrt(deta * deta + dphi * dphi + dmag * dmag);
0028   }
0029 }  // namespace fftjetcms