fastjet 2.4.5
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   //cout << "inline_maths: ";
00047   if (fabs(E-pz) == 0.) {
00048     //    cout << "Error in header mathe.h: division by 0 in function eta!" <<  " p=" << p << " pz=" << pz << endl;
00049     //  exit(721);
00050     errno=721;
00051     y = 99999.;
00052   }
00053   else {
00054     y = 0.5*log((E+pz)/(E-pz));
00055   }
00056   //cout << "y: E=" << E << " pz=" << pz << " y=" << y << endl;
00057   return y;
00058 }
00059 
00060 
00061 } //end usename inline_maths
00062 
00063 
00064 }  // namespace d0
00065 
00066 FASTJET_END_NAMESPACE
00067 
00068 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines