fastjet 2.4.5
SortByEt.h
Go to the documentation of this file.
00001 #ifndef __CMS_ITERATIVE_CONE__SORT_BY_ET_H__
00002 #define __CMS_ITERATIVE_CONE__SORT_BY_ET_H__
00003 
00004 #include <limits>
00005 #include <fastjet/internal/base.hh>
00006 
00007 FASTJET_BEGIN_NAMESPACE
00008 
00009 namespace cms{
00010 
00011 // This is the code that deals with the ordering in Et
00012 //
00013 // It comes from the CMSSW file  ???VERSION???
00014 //   CMSSW/PhysicsTools/Utilities/interface/EtComparator.h
00015 // The code has been slightly adapted to ack on PseudoJets 
00016 // rather than the CMS types for 4-vectors
00017 // 
00018 // For completeness, here is a copy of the exact CMS code 
00019 // we've used
00020 //  
00021 //   template <class T>
00022 //   struct NumericSafeGreaterByEt {
00023 //     typedef T first_argument_type;
00024 //     typedef T second_argument_type;
00025 //     bool operator()(const T& a1, const T& a2) {
00026 //       return
00027 //         fabs (a1.et()-a2.et()) > std::numeric_limits<double>::epsilon() ? a1.et() > a2.et() :
00028 //         fabs (a1.px()-a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() > a2.px() :
00029 //         a1.pz() > a2.pz();
00030 //     }
00031 //   };
00032 
00033 template <class T>
00034 struct NumericSafeGreaterByEt {
00035   typedef T first_argument_type;
00036   typedef T second_argument_type;
00037   bool operator()(const T& a1, const T& a2) {
00038     // FastJet::PseudoJet does not provide a direct access to Et2
00039     // Plus, we want it to be computed in the same way as in the CMS
00040     // code (actually the Root code that is used by CMS)
00041     double et1 = a1.Et();
00042     double et2 = a2.Et();
00043 
00044     // now we can come back to the CMS code
00045     return
00046       fabs (et1-et2) > std::numeric_limits<double>::epsilon() ? et1 > et2 :
00047       fabs (a1.px()-a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() > a2.px() :
00048       a1.pz() > a2.pz();
00049   }
00050 };
00051 
00052 }  // namespace cms
00053 
00054 FASTJET_END_NAMESPACE
00055 
00056 
00057 #endif   // __CMS_ITERATIVE_CONE__SORT_BY_ET_H__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines