Go to the documentation of this file.00001 #ifndef JET_JETUTIL_H
00002 #define JET_JETUTIL_H 1
00003
00004 #include <cmath>
00005
00006 class PtGreater {
00007 public:
00008 template <typename T> bool operator () (const T& i, const T& j) {
00009 return (i.pt() > j.pt());
00010 }
00011 };
00012
00013 class EtGreater {
00014 public:
00015 template <typename T> bool operator () (const T& i, const T& j) {
00016 return (i.et() > j.et());
00017 }
00018 };
00019
00020 class JetUtil{
00021 public:
00022
00023 static double Phi_0_2pi(double x) {
00024 while (x >= 2*M_PI) x -= 2*M_PI;
00025 while (x < 0.) x += 2*M_PI;
00026 return x;
00027 }
00028
00029 static double Phi_mpi_pi(double x) {
00030 while (x >= M_PI) x -= 2*M_PI;
00031 while (x < -M_PI) x += 2*M_PI;
00032 return x;
00033 }
00034
00035 static double dPhi(double phi1,double phi2){
00036 phi1=Phi_0_2pi(phi1);
00037 phi2=Phi_0_2pi(phi2);
00038 return Phi_mpi_pi(phi1-phi2);
00039 }
00040
00041 static double radius(double eta1, double phi1,double eta2, double phi2){
00042
00043 const double TWOPI= 2.0*M_PI;
00044
00045 phi1=Phi_0_2pi(phi1);
00046 phi2=Phi_0_2pi(phi2);
00047
00048 double dphi=Phi_0_2pi(phi1-phi2);
00049 dphi = TMath::Min(dphi,TWOPI-dphi);
00050 double deta = eta1-eta2;
00051
00052 return sqrt(deta*deta+dphi*dphi);
00053 }
00054
00055 template <typename T1,typename T2> static double radius(const T1& t1,const T2& t2){
00056 return radius(t1->eta(),t1->phi(),t2->eta(),t2->phi());
00057 }
00058 };
00059 #endif