FastJet 3.0.2
SortByEt.h
00001 #ifndef __CMS_ITERATIVE_CONE__SORT_BY_ET_H__
00002 #define __CMS_ITERATIVE_CONE__SORT_BY_ET_H__
00003 
00004 //STARTHEADER
00005 // $Id$
00006 //
00007 // Copyright (c) ????-????, CMS collaboration
00008 // Copyright (c) 2009-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez [for the changes listed below]
00009 //
00010 //----------------------------------------------------------------------
00011 // This file distributed with FastJet has been obtained from the CMS
00012 // collaboration, revision 1.2 of the EtComparator.h file in CMSSW,
00013 // see
00014 //   http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/PhysicsTools/Utilities/interface/EtComparator.h?hideattic=0&revision=1.2&view=markup
00015 //
00016 // Permission has been granted by the CMS collaboration to release it
00017 // in FastJet under the terms of the GNU Public License(v2) (see the
00018 // COPYING file in the main FastJet directory for details).
00019 // Changes from the original file are listed below.
00020 //
00021 // FastJet is free software; you can redistribute it and/or modify
00022 // it under the terms of the GNU General Public License as published by
00023 // the Free Software Foundation; either version 2 of the License, or
00024 // (at your option) any later version.
00025 //
00026 // The algorithms that underlie FastJet have required considerable
00027 // development and are described in hep-ph/0512210. If you use
00028 // FastJet as part of work towards a scientific publication, please
00029 // include a citation to the FastJet paper.
00030 //
00031 // FastJet is distributed in the hope that it will be useful,
00032 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00033 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00034 // GNU General Public License for more details.
00035 //
00036 // You should have received a copy of the GNU General Public License
00037 // along with FastJet. If not, see <http://www.gnu.org/licenses/>.
00038 //----------------------------------------------------------------------
00039 //ENDHEADER
00040 
00041 // List of changes compared to the original CMS code (revision 1.2 of
00042 // EtComparator.h)
00043 //
00044 // 2009-01-06  Gregory Soyez  <soyez@fastjet.fr>
00045 //
00046 //        * Extracted (only) NumericSafeGreaterByEt from the CMS code
00047 //          and adapted it to act on PseudoJet rather than CMS types
00048 //          for 4-momenta
00049 //        * Put the code in a fastjet::cms namespace
00050 
00051 #include <limits>
00052 #include <fastjet/internal/base.hh>
00053 
00054 FASTJET_BEGIN_NAMESPACE
00055 
00056 namespace cms{
00057 
00058 template <class T>
00059 struct NumericSafeGreaterByEt {
00060   typedef T first_argument_type;
00061   typedef T second_argument_type;
00062   bool operator()(const T& a1, const T& a2) {
00063     // FastJet::PseudoJet does not provide a direct access to Et2
00064     // Plus, we want it to be computed in the same way as in the CMS
00065     // code (actually the Root code that is used by CMS)
00066     double et1 = a1.Et();
00067     double et2 = a2.Et();
00068 
00069     // now we can come back to the CMS code
00070     return
00071       fabs (et1-et2) > std::numeric_limits<double>::epsilon() ? et1 > et2 :
00072       fabs (a1.px()-a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() > a2.px() :
00073       a1.pz() > a2.pz();
00074   }
00075 };
00076 
00077 }  // namespace cms
00078 
00079 FASTJET_END_NAMESPACE
00080 
00081 
00082 #endif   // __CMS_ITERATIVE_CONE__SORT_BY_ET_H__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends