inline_maths.h
Go to the documentation of this file.00001 #ifndef INLINE_MATHS
00002 #define INLINE_MATHS
00003
00004 #include <cerrno>
00005
00006 #include <fastjet/internal/base.hh>
00007
00008 FASTJET_BEGIN_NAMESPACE
00009
00010 namespace d0{
00011
00012 namespace inline_maths {
00013
00014 const double PI = fabs(acos(-1.));
00015
00016 const double TWOPI = 2*PI;
00017
00018
00019 inline double sqr(double a) {
00020 return a*a;
00021 }
00022
00023
00024
00025 inline double min(double a, double b) {
00026 return (a < b) ? a : b;
00027 }
00028
00029
00030
00031 inline double delta_phi(double phi1, double phi2) {
00032 return min( double(fabs(phi1-phi2)), double(2.*PI-fabs(phi1-phi2)) );
00033 }
00034
00035
00036
00037 inline double phi(double px, double py) {
00038 return atan2(py, px);
00039 }
00040
00041
00042
00043 inline double y(double E, double pz) {
00044 errno=0;
00045 double y;
00046
00047 if (fabs(E-pz) == 0.) {
00048
00049
00050 errno=721;
00051 y = 99999.;
00052 }
00053 else {
00054 y = 0.5*log((E+pz)/(E-pz));
00055 }
00056
00057 return y;
00058 }
00059
00060
00061 }
00062
00063
00064 }
00065
00066 FASTJET_END_NAMESPACE
00067
00068 #endif