00001
00002 #ifndef JETUTIL_JETDISTANCES_H
00003 #define JETUTIL_JETDISTANCES_H
00005 // //
00007
00008 #include <cmath>
00009
00010
00011 namespace jet {
00012 namespace JetDistances {
00013
00014
00015 inline static double fixedPhi(double aPhi)
00016 {
00017 while ( aPhi < -M_PI )
00018 {
00019 aPhi += 2.*M_PI;
00020 }
00021 while ( aPhi > M_PI )
00022 {
00023 aPhi -= 2.*M_PI;
00024 }
00025 return aPhi;
00026 }
00027
00028
00029 template<class PARTICLE>
00030 inline static double deltaEta(const PARTICLE& jet1,
00031 const PARTICLE& jet2)
00032 { return jet1.eta() - jet2.eta(); }
00033
00034 inline static double deltaEta(const double eta1,
00035 const double eta2)
00036 { return (eta1 - eta2); }
00037
00038 template<class PARTICLE>
00039 inline static double deltaPhi(const PARTICLE& jet1,
00040 const PARTICLE& jet2)
00041 {
00042 return fixedPhi(jet1.phi() - jet2.phi());
00043 }
00044
00045
00046 inline static double deltaPhi(const double phi1,
00047 const double phi2)
00048 {
00049 return fixedPhi( phi1 - phi2 );
00050 }
00051
00052
00053 template<class PARTICLE>
00054 inline static double deltaR2(const PARTICLE& jet1,
00055 const PARTICLE& jet2){
00056 return ( deltaEta(jet1,jet2) * deltaEta(jet1,jet2) +
00057 deltaPhi(jet1,jet2) * deltaPhi(jet1,jet2) );
00058 }
00059
00060 inline static double deltaR2(const double eta1, const double phi1,
00061 const double eta2, const double phi2 ) {
00062 return ( deltaEta(eta1,eta2) * deltaEta(eta1,eta2) +
00063 deltaPhi(phi1,phi2) * deltaPhi(phi1,phi2) );
00064 }
00065
00066 template<class PARTICLE>
00067 inline static double deltaR(const PARTICLE& jet1,
00068 const PARTICLE& jet2){
00069 return sqrt( deltaR2(jet1, jet2) );
00070 }
00071
00072 inline static double deltaR(const double eta1, const double phi1,
00073 const double eta2, const double phi2 ) {
00074 return sqrt( deltaR2(eta1, phi1, eta2, phi2) );
00075 }
00076
00077
00078
00079 }
00080
00081 }
00082
00083 #endif