CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoJets/FFTJetAlgorithms/src/JetConvergenceDistance.cc

Go to the documentation of this file.
00001 #include <cmath>
00002 #include <cassert>
00003 
00004 #include "RecoJets/FFTJetAlgorithms/interface/JetConvergenceDistance.h"
00005 
00006 namespace fftjetcms {
00007     JetConvergenceDistance::JetConvergenceDistance(
00008         const double etaToPhiBandwidthRatio,
00009         const double relativePtBandwidth)
00010         : etaBw_(sqrt(etaToPhiBandwidthRatio)),
00011           phiBw_(1.0/etaBw_),
00012           ptBw_(relativePtBandwidth)
00013     {
00014         assert(etaToPhiBandwidthRatio > 0.0);
00015         assert(relativePtBandwidth > 0.0);
00016     }
00017 
00018     double JetConvergenceDistance::operator()(
00019         const fftjet::RecombinedJet<VectorLike>& j1,
00020         const fftjet::RecombinedJet<VectorLike>& j2) const
00021     {
00022         const double deta = (j1.vec().Eta() - j2.vec().Eta())/etaBw_;
00023         double dphi = j1.vec().Phi() - j2.vec().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         const double mag1 = j1.magnitude();
00030         const double mag2 = j2.magnitude();
00031         double dmag = 0.0;
00032         if (mag1 > 0.0 || mag2 > 0.0)
00033             dmag = 2.0*(mag1 - mag2)/(mag1 + mag2)/ptBw_;
00034         return sqrt(deta*deta + dphi*dphi + dmag*dmag);
00035     }
00036 }