CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  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  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  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
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13702
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HLT_FULL_cff.eta2
eta2
Definition: HLT_FULL_cff.py:9542
PtGreater::operator()
bool operator()(const T &i, const T &j)
Definition: SusyDQM.h:45
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
T
long double T
Definition: Basic3DVectorLD.h:48
genVertex_cff.x
x
Definition: genVertex_cff.py:12
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
Min
T Min(T a, T b)
Definition: MathUtil.h:39
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PtGreater
Definition: SusyDQM.h:42