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
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
mps_fire.i
i
Definition: mps_fire.py:428
min
T min(T a, T b)
Definition: MathUtil.h:58
DDAxes::x
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
JetUtil::Phi_mpi_pi
static double Phi_mpi_pi(double x)
Definition: JetUtil.h:33
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HLT_FULL_cff.eta2
eta2
Definition: HLT_FULL_cff.py:9542
JetUtil::dPhi
static double dPhi(double phi1, double phi2)
Definition: JetUtil.h:41
PtGreater::operator()
bool operator()(const T &i, const T &j)
Definition: JetUtil.h:10
JetUtil::radius
static double radius(double eta1, double phi1, double eta2, double phi2)
Definition: JetUtil.h:47
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9541
TWOPI
#define TWOPI
Definition: DQMSourcePi0.cc:36
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
EtGreater
Definition: JetUtil.h:15
JetUtil::Phi_0_2pi
static double Phi_0_2pi(double x)
Definition: JetUtil.h:25
T
long double T
Definition: Basic3DVectorLD.h:48
EtGreater::operator()
bool operator()(const T &i, const T &j)
Definition: JetUtil.h:18
JetUtil
Definition: JetUtil.h:23
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PtGreater
Definition: SusyDQM.h:42
JetUtil::radius
static double radius(const T1 &t1, const T2 &t2)
Definition: JetUtil.h:61