/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
CommonTools/Utils/interface/PtComparator.h
55 строк
2 KB
Shahzad Malik Muzaffar
[RECONSTRUCTION] apply code-format
08 июн 2021, 21:43
08 июн 2021, 21:43
6a5dc2e
Код
Авторство
О чём код?
#ifndef CommonTools_Utils_PtComparator_h #define CommonTools_Utils_PtComparator_h /** \class PtComparator * * compare by pt * * \author Luca Lista, INFN * numeric safe implementation by Fedor Ratnikov, FNAL * * \version $Revision: 1.4 $ * * $Id: PtComparator.h,v 1.4 2007/04/23 20:54:26 llista Exp $ * */ template <typename T> struct LessByPt { typedef T first_argument_type; typedef T second_argument_type; bool operator()(const T& t1, const T& t2) const { return t1.pt() < t2.pt(); } }; template <typename T> struct GreaterByPt { typedef T first_argument_type; typedef T second_argument_type; bool operator()(const T& t1, const T& t2) const { return t1.pt() > t2.pt(); } }; #include <limits> #include <cmath> template <class T> struct NumericSafeLessByPt { typedef T first_argument_type; typedef T second_argument_type; bool operator()(const T& a1, const T& a2) { return fabs(a1.pt() - a2.pt()) > std::numeric_limits<double>::epsilon() ? a1.pt() < a2.pt() : fabs(a1.px() - a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() < a2.px() : a1.pz() < a2.pz(); } }; template <class T> struct NumericSafeGreaterByPt { typedef T first_argument_type; typedef T second_argument_type; bool operator()(const T& a1, const T& a2) { return fabs(a1.pt() - a2.pt()) > std::numeric_limits<double>::epsilon() ? a1.pt() > a2.pt() : fabs(a1.px() - a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() > a2.px() : a1.pz() > a2.pz(); } }; #endif