FastJet 3.0.2
|
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 // 2011-10-06 Gregory Soyez <soyez@fastjet.fr> 00017 // 00018 // * put the code in the fastjet::d0runi namespace 00019 00020 #include <cmath> 00021 #include <cerrno> 00022 #include <fastjet/internal/base.hh> 00023 00024 FASTJET_BEGIN_NAMESPACE 00025 00026 //using namespace std; 00027 00028 namespace d0runi{ 00029 namespace inline_maths { 00030 00031 const double PI = fabs(acos(-1.)); 00032 00033 const double TWOPI = 2*PI; 00034 00035 00036 inline double sqr(double a) { 00037 return a*a; 00038 } 00039 00040 00041 00042 inline double min(double a, double b) { 00043 return (a < b) ? a : b; 00044 } 00045 00046 00047 00048 inline double delta_phi(double phi1, double phi2) { 00049 double dphi = min( double(fabs(phi1-phi2)), double(2.*PI-fabs(phi1-phi2)) ); 00050 return (phi1 < phi2) ? -dphi : dphi; 00051 } 00052 00053 00054 00055 inline double phi(double px, double py) { 00056 return atan2(py, px); 00057 } 00058 00059 00060 00061 inline double y(double E, double pz) { 00062 errno=0; 00063 double y; 00064 //cout << "inline_maths: "; 00065 if (fabs(E-pz) == 0.) { 00066 // cout << "Error in header mathe.h: division by 0 in function y!" << " p=" << p << " pz=" << pz << endl; 00067 // exit(721); 00068 errno=721; 00069 y = 99999.; 00070 } 00071 else { 00072 y = 0.5*log((E+pz)/(E-pz)); 00073 } 00074 //cout << "y: E=" << E << " pz=" << pz << " y=" << y << endl; 00075 return y; 00076 } 00077 00078 00079 00080 00081 inline double eta(double p, double pz) { 00082 errno=0; 00083 double eta; 00084 //cout << "inline_maths: "; 00085 if (fabs(p-pz) == 0.) { 00086 // cout << "Error in header mathe.h: division by 0 in function eta!" << " p=" << p << " pz=" << pz << endl; 00087 // exit(721); 00088 errno=721; 00089 eta = 99999.; 00090 } 00091 else { 00092 eta = 0.5*log((p+pz)/(p-pz)); 00093 } 00094 //cout << "eta: p=" << p << " pz=" << pz << " eta=" << eta << endl; 00095 return eta; 00096 } 00097 00098 00099 00100 00101 inline double eta(double px, double py, double pz) { 00102 errno=0; 00103 double eta; 00104 //cout << "inline_maths: "; 00105 double p = sqrt(px*px+py*py+pz*pz); 00106 if (fabs(p-pz) == 0.) { 00107 // cout << "Error in header mathe.h: division by 0 in function eta!" << " p=" << p << " pz=" << pz << endl; 00108 // exit(721); 00109 errno=721; 00110 eta = 99999.; 00111 } 00112 else { 00113 eta = 0.5*log((p+pz)/(p-pz)); 00114 } 00115 //cout << "eta: p=" << p << " pz=" << pz << " eta=" << eta << endl; 00116 return eta; 00117 } 00118 00119 00120 00121 inline double eta(double theta) { 00122 double eta = -log(tan(theta/2.)); 00123 00124 return eta; 00125 } 00126 00127 00128 inline double theta(double eta) { 00129 double theta = 2.*atan(exp(-eta)); 00130 00131 return theta; 00132 } 00133 00134 inline double theta(double px, double py, double pz) { 00135 double Eta = eta(px, py, pz); 00136 double theta = 2.*atan(exp(-Eta)); 00137 00138 return theta; 00139 } 00140 00141 00142 00143 } //end usename inline_maths 00144 } //end usename d0runi 00145 00146 FASTJET_END_NAMESPACE 00147 00148 00149 #endif