CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoJets/JetAnalyzers/interface/JetUtil.h

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