CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetUtilMC.h
Go to the documentation of this file.
1 #ifndef JETUTILMC_H
2 #define JETUTILMC_H
3 
4 #include <cmath>
5 namespace {
6 class PtGreater {
7  public:
8  template <typename T> bool operator () (const T& i, const T& j) {
9  return (i.pt() > j.pt());
10  }
11 };
12 
13 double Phi_0_2pi(double x) {
14  while (x >= 2*M_PI) x -= 2*M_PI;
15  while (x < 0.) x += 2*M_PI;
16  return x;
17 }
18 
19 double Phi_mpi_pi(double x) {
20  while (x >= M_PI) x -= 2*M_PI;
21  while (x < -M_PI) x += 2*M_PI;
22  return x;
23 }
24 
25 inline double dPhi(double phi1,double phi2){
26  phi1=Phi_0_2pi(phi1);
27  phi2=Phi_0_2pi(phi2);
28  return Phi_mpi_pi(phi1-phi2);
29 }
30 
31 double radius(double eta1, double phi1,double eta2, double phi2){
32 
33  const double TWOPI= 2.0*M_PI;
34 
35  phi1=Phi_0_2pi(phi1);
36  phi2=Phi_0_2pi(phi2);
37 
38  double dphi=Phi_0_2pi(phi1-phi2);
39  dphi = TMath::Min(dphi,TWOPI-dphi);
40  double deta = eta1-eta2;
41 
42  return sqrt(deta*deta+dphi*dphi);
43 }
44 
45 template <typename T1,typename T2> double radius(const T1& t1,const T2& t2){
46  return radius(t1->eta(),t1->phi(),t2->eta(),t2->phi());
47 }
48 }
49 
50 #endif
int i
Definition: DBlmapReader.cc:9
#define TWOPI
EgammaCoreTools.
double Phi_mpi_pi(double x)
Definition: JetUtil.h:24
double Phi_0_2pi(double x)
Definition: JetUtil.h:18
T Min(T a, T b)
Definition: MathUtil.h:39
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
#define M_PI
Definition: DDAxes.h:10
long double T
bool operator()(const T &i, const T &j)
Definition: SusyDQM.h:45