CMS 3D CMS Logo

JetUtil.h
Go to the documentation of this file.
1 #ifndef JET_JETUTIL_H
2 #define JET_JETUTIL_H 1
3 
4 #include <cmath>
5 #include <algorithm>
6 
7 class PtGreater {
8  public:
9  template <typename T> bool operator () (const T& i, const T& j) {
10  return (i.pt() > j.pt());
11  }
12 };
13 
14 class EtGreater {
15  public:
16  template <typename T> bool operator () (const T& i, const T& j) {
17  return (i.et() > j.et());
18  }
19 };
20 
21 class JetUtil{
22  public:
23 
24 static double Phi_0_2pi(double x) {
25  while (x >= 2*M_PI) x -= 2*M_PI;
26  while (x < 0.) x += 2*M_PI;
27  return x;
28 }
29 
30 static double Phi_mpi_pi(double x) {
31  while (x >= M_PI) x -= 2*M_PI;
32  while (x < -M_PI) x += 2*M_PI;
33  return x;
34 }
35 
36 static double dPhi(double phi1,double phi2){
37  phi1=Phi_0_2pi(phi1);
38  phi2=Phi_0_2pi(phi2);
39  return Phi_mpi_pi(phi1-phi2);
40 }
41 
42 static double radius(double eta1, double phi1,double eta2, double phi2){
43 
44  const double TWOPI= 2.0*M_PI;
45 
46  phi1=Phi_0_2pi(phi1);
47  phi2=Phi_0_2pi(phi2);
48 
49  double dphi=Phi_0_2pi(phi1-phi2);
50  dphi = std::min(dphi,TWOPI-dphi);
51  double deta = eta1-eta2;
52 
53  return sqrt(deta*deta+dphi*dphi);
54 }
55 
56 template <typename T1,typename T2> static double radius(const T1& t1,const T2& t2){
57  return radius(t1->eta(),t1->phi(),t2->eta(),t2->phi());
58 }
59 };
60 #endif
static double radius(double eta1, double phi1, double eta2, double phi2)
Definition: JetUtil.h:42
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
T sqrt(T t)
Definition: SSEVec.h:18
#define TWOPI
EgammaCoreTools.
Definition: DQMSourcePi0.cc:40
static double Phi_mpi_pi(double x)
Definition: JetUtil.h:30
T min(T a, T b)
Definition: MathUtil.h:58
#define M_PI
static double radius(const T1 &t1, const T2 &t2)
Definition: JetUtil.h:56
static double dPhi(double phi1, double phi2)
Definition: JetUtil.h:36
long double T
bool operator()(const T &i, const T &j)
Definition: SusyDQM.h:46
static double Phi_0_2pi(double x)
Definition: JetUtil.h:24