FastJet 3.0.1
inline_maths.h
00001 #ifndef INLINE_MATHS
00002 #define INLINE_MATHS
00003 
00004 // History of changes in FastJet compared tothe original version of
00005 // inline_math.h
00006 //
00007 // 2009-01-17  Gregory Soyez  <soyez@fastjet.fr>
00008 //
00009 //        * put the code in the fastjet::d0 namespace
00010 
00011 #include <cerrno>
00012 
00013 #include <fastjet/internal/base.hh>
00014 
00015 FASTJET_BEGIN_NAMESPACE
00016 
00017 namespace d0{
00018 
00019 namespace inline_maths {
00020 
00021 const double PI = fabs(acos(-1.));
00022 
00023 const double TWOPI = 2*PI;
00024 
00025 
00026 inline double sqr(double a) {
00027   return a*a;
00028 }
00029 
00030 
00031 
00032 inline double min(double a, double b) {
00033   return (a < b) ? a : b;
00034 }
00035 
00036 
00037 
00038 inline double delta_phi(double phi1, double phi2) {
00039   return min( double(fabs(phi1-phi2)), double(2.*PI-fabs(phi1-phi2)) );
00040 }
00041 
00042 
00043 
00044 inline double phi(double px, double py) {
00045   return atan2(py, px);
00046 }
00047 
00048 
00049 
00050 inline double y(double E, double pz) {
00051   errno=0;
00052   double y;
00053   //cout << "inline_maths: ";
00054   if (fabs(E-pz) == 0.) {
00055     //    cout << "Error in header mathe.h: division by 0 in function eta!" <<  " p=" << p << " pz=" << pz << endl;
00056     //  exit(721);
00057     errno=721;
00058     y = 99999.;
00059   }
00060   else {
00061     y = 0.5*log((E+pz)/(E-pz));
00062   }
00063   //cout << "y: E=" << E << " pz=" << pz << " y=" << y << endl;
00064   return y;
00065 }
00066 
00067 
00068 } //end usename inline_maths
00069 
00070 
00071 }  // namespace d0
00072 
00073 FASTJET_END_NAMESPACE
00074 
00075 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends