CMS 3D CMS Logo

JetUtilMC.h
Go to the documentation of this file.
1 #ifndef JETUTILMC_H
2 #define JETUTILMC_H
3 
4 #include <cmath>
5 #include <TMath.h>
6 namespace {
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  inline double Phi_0_2pi(double x) {
16  while (x >= 2 * M_PI)
17  x -= 2 * M_PI;
18  while (x < 0.)
19  x += 2 * M_PI;
20  return x;
21  }
22 
23  inline double Phi_mpi_pi(double x) {
24  while (x >= M_PI)
25  x -= 2 * M_PI;
26  while (x < -M_PI)
27  x += 2 * M_PI;
28  return x;
29  }
30 
31  inline double dPhi(double phi1, double phi2) {
32  phi1 = Phi_0_2pi(phi1);
33  phi2 = Phi_0_2pi(phi2);
34  return Phi_mpi_pi(phi1 - phi2);
35  }
36 
37  inline double radius(double eta1, double phi1, double eta2, double phi2) {
38  const double TWOPI = 2.0 * M_PI;
39 
40  phi1 = Phi_0_2pi(phi1);
41  phi2 = Phi_0_2pi(phi2);
42 
43  double dphi = Phi_0_2pi(phi1 - phi2);
44  dphi = TMath::Min(dphi, TWOPI - dphi);
45  double deta = eta1 - eta2;
46 
47  return sqrt(deta * deta + dphi * dphi);
48  }
49 
50  template <typename T1, typename T2>
51  double radius(const T1& t1, const T2& t2) {
52  return radius(t1->eta(), t1->phi(), t2->eta(), t2->phi());
53  }
54 } // namespace
55 
56 #endif
T sqrt(T t)
Definition: SSEVec.h:19
#define TWOPI
#define M_PI
float x
long double T
bool operator()(const T &i, const T &j)
Definition: SusyDQM.h:45