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>
10  bool operator()(const T& i, const T& j) {
11  return (i.pt() > j.pt());
12  }
13 };
14 
15 class EtGreater {
16 public:
17  template <typename T>
18  bool operator()(const T& i, const T& j) {
19  return (i.et() > j.et());
20  }
21 };
22 
23 class JetUtil {
24 public:
25  static double Phi_0_2pi(double x) {
26  while (x >= 2 * M_PI)
27  x -= 2 * M_PI;
28  while (x < 0.)
29  x += 2 * M_PI;
30  return x;
31  }
32 
33  static double Phi_mpi_pi(double x) {
34  while (x >= M_PI)
35  x -= 2 * M_PI;
36  while (x < -M_PI)
37  x += 2 * M_PI;
38  return x;
39  }
40 
41  static double dPhi(double phi1, double phi2) {
42  phi1 = Phi_0_2pi(phi1);
43  phi2 = Phi_0_2pi(phi2);
44  return Phi_mpi_pi(phi1 - phi2);
45  }
46 
47  static double radius(double eta1, double phi1, double eta2, double phi2) {
48  const double TWOPI = 2.0 * M_PI;
49 
50  phi1 = Phi_0_2pi(phi1);
51  phi2 = Phi_0_2pi(phi2);
52 
53  double dphi = Phi_0_2pi(phi1 - phi2);
54  dphi = std::min(dphi, TWOPI - dphi);
55  double deta = eta1 - eta2;
56 
57  return sqrt(deta * deta + dphi * dphi);
58  }
59 
60  template <typename T1, typename T2>
61  static double radius(const T1& t1, const T2& t2) {
62  return radius(t1->eta(), t1->phi(), t2->eta(), t2->phi());
63  }
64 };
65 #endif
bool operator()(const T &i, const T &j)
Definition: JetUtil.h:18
static double radius(double eta1, double phi1, double eta2, double phi2)
Definition: JetUtil.h:47
T sqrt(T t)
Definition: SSEVec.h:23
#define TWOPI
static double Phi_mpi_pi(double x)
Definition: JetUtil.h:33
#define M_PI
static double radius(const T1 &t1, const T2 &t2)
Definition: JetUtil.h:61
static double dPhi(double phi1, double phi2)
Definition: JetUtil.h:41
long double T
bool operator()(const T &i, const T &j)
Definition: JetUtil.h:10
static double Phi_0_2pi(double x)
Definition: JetUtil.h:25