CMS 3D CMS Logo

JetUtilMC.h

Go to the documentation of this file.
00001 #ifndef JET_MYJET_H
00002 #define JET_MYJET_H
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 double Phi_0_2pi(double x) {
00014   while (x >= 2*M_PI) x -= 2*M_PI;
00015   while (x <     0.)  x += 2*M_PI;
00016   return x;
00017 }
00018 
00019 double Phi_mpi_pi(double x) {
00020    while (x >= M_PI) x -= 2*M_PI;
00021    while (x < -M_PI) x += 2*M_PI;
00022    return x;
00023 }
00024 
00025 double dPhi(double phi1,double phi2){
00026    phi1=Phi_0_2pi(phi1);
00027    phi2=Phi_0_2pi(phi2);
00028    return Phi_mpi_pi(phi1-phi2);
00029 }
00030 
00031 double radius(double eta1, double phi1,double eta2, double phi2){
00032  
00033   const double TWOPI= 2.0*M_PI;
00034  
00035   phi1=Phi_0_2pi(phi1);
00036   phi2=Phi_0_2pi(phi2);
00037 
00038   double dphi=Phi_0_2pi(phi1-phi2);
00039   dphi = TMath::Min(dphi,TWOPI-dphi);
00040   double deta = eta1-eta2;
00041 
00042   return sqrt(deta*deta+dphi*dphi);
00043 }
00044 
00045 template <typename T1,typename T2> double radius(const T1&  t1,const T2& t2){
00046   return radius(t1->eta(),t1->phi(),t2->eta(),t2->phi());
00047 }
00048 
00049 #endif

Generated on Tue Jun 9 17:39:34 2009 for CMSSW by  doxygen 1.5.4