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