FastJet 3.0.6
JetDistances.hh
00001 //----------------------------------------------------------------------
00002 // This file distributed with FastJet has been obtained from SpartyJet
00003 // v2.20.0 by Pierre-Antoine Delsart, Kurtis L. Geerlings, Joey
00004 // Huston, Brian T. Martin and Chris Vermilion
00005 // For details, see http://www.pa.msu.edu/~huston/SpartyJet/
00006 //                  http://projects.hepforge.org/spartyjet/
00007 //
00008 // Changes from the original file are listed below.
00009 //----------------------------------------------------------------------
00010 
00011 // History of changes from the original JetDistance.hh file in
00012 // SpartyJet v2.20
00013 //  
00014 // 2009-01-15  Gregory Soyez  <soyez@fastjet.fr>
00015 // 
00016 //        * put the code in the fastjet::atlas namespace
00017 
00018 #ifndef JETUTIL_JETDISTANCES_H
00019 #define JETUTIL_JETDISTANCES_H
00020 
00021 
00022 #include "Jet.hh"
00023 
00024 #include <cmath>
00025 
00026 #include <fastjet/internal/base.hh>
00027 
00028 FASTJET_BEGIN_NAMESPACE
00029 
00030 namespace atlas { 
00031 
00032 struct JetDistances {
00033 
00034 
00035   // distance in eta
00036   inline static double deltaEta(const Jet& jet1, const Jet& jet2)
00037   { return jet1.eta() - jet2.eta(); }
00038   inline static double deltaEta(const Jet* jet1,
00039                                 const Jet* jet2)
00040   { return jet1->eta() - jet2->eta(); }
00041   inline static double deltaEta(const double eta1,
00042                                 const double eta2)
00043   { return (eta1 - eta2); }
00044 
00045 
00046 
00047   inline static double deltaPhi(const Jet& jet1, 
00048                                 const Jet& jet2)
00049   { 
00050     return fixedPhi(jet1.phi() - jet2.phi());
00051   }
00052   inline static double deltaPhi(const Jet* jet1,
00053                                 const Jet* jet2)
00054   { 
00055     return fixedPhi(jet1->phi()-jet2->phi());
00056   }
00057   inline static double deltaPhi(const double phi1,
00058                                 const double phi2)
00059   { 
00060     return fixedPhi( phi1 - phi2 );
00061   }
00062 
00063 
00064   // distance in (eta,phi)
00065   inline static double deltaR(const Jet& jet1, 
00066                               const Jet& jet2)
00067   { return sqrt( deltaEta(jet1,jet2) * deltaEta(jet1,jet2) + 
00068                  deltaPhi(jet1,jet2) * deltaPhi(jet1,jet2) ); }
00069   inline static double deltaR(const Jet* jet1,
00070                               const Jet* jet2)
00071   { return sqrt( deltaEta(jet1,jet2) * deltaEta(jet1,jet2) +
00072                  deltaPhi(jet1,jet2) * deltaPhi(jet1,jet2) ); }
00073   
00074   inline static double deltaR(const double eta1, const double phi1,
00075                               const double eta2, const double phi2 )
00076   { return sqrt( deltaEta(eta1,eta2) * deltaEta(eta1,eta2) +
00077                  deltaPhi(phi1,phi2) * deltaPhi(phi1,phi2) ); }
00078   
00079 
00080   
00081   // phi convention enforcement
00082   inline static double fixedPhi(double aPhi)
00083   {
00084     while ( aPhi < -M_PI )
00085       {
00086         aPhi += 2.*M_PI;
00087       }
00088     while ( aPhi > M_PI )
00089       {
00090         aPhi -= 2.*M_PI;
00091       }
00092     return aPhi;
00093   }
00094 
00095 };
00096 
00097 }  // namespace atlas
00098 
00099 FASTJET_END_NAMESPACE
00100 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends