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> bool operator () (const T& i, const T& j) {
10  return (i.pt() > j.pt());
11  }
12 };
13 
14 double Phi_0_2pi(double x) {
15  while (x >= 2*M_PI) x -= 2*M_PI;
16  while (x < 0.) x += 2*M_PI;
17  return x;
18 }
19 
20 double Phi_mpi_pi(double x) {
21  while (x >= M_PI) x -= 2*M_PI;
22  while (x < -M_PI) x += 2*M_PI;
23  return x;
24 }
25 
26 inline double dPhi(double phi1,double phi2){
27  phi1=Phi_0_2pi(phi1);
28  phi2=Phi_0_2pi(phi2);
29  return Phi_mpi_pi(phi1-phi2);
30 }
31 
32 double radius(double eta1, double phi1,double eta2, double phi2){
33 
34  const double TWOPI= 2.0*M_PI;
35 
36  phi1=Phi_0_2pi(phi1);
37  phi2=Phi_0_2pi(phi2);
38 
39  double dphi=Phi_0_2pi(phi1-phi2);
40  dphi = TMath::Min(dphi,TWOPI-dphi);
41  double deta = eta1-eta2;
42 
43  return sqrt(deta*deta+dphi*dphi);
44 }
45 
46 template <typename T1,typename T2> double radius(const T1& t1,const T2& t2){
47  return radius(t1->eta(),t1->phi(),t2->eta(),t2->phi());
48 }
49 }
50 
51 #endif
T Min(T a, T b)
Definition: MathUtil.h:39
T sqrt(T t)
Definition: SSEVec.h:18
#define TWOPI
Definition: DQMSourcePi0.cc:37
#define M_PI
long double T
bool operator()(const T &i, const T &j)
Definition: SusyDQM.h:46