CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PtComparator.h
Go to the documentation of this file.
1 #ifndef CommonTools_Utils_PtComparator_h
2 #define CommonTools_Utils_PtComparator_h
3 
16 template <typename T>
17 struct LessByPt {
20  bool operator()(const T& t1, const T& t2) const { return t1.pt() < t2.pt(); }
21 };
22 
23 template <typename T>
24 struct GreaterByPt {
27  bool operator()(const T& t1, const T& t2) const { return t1.pt() > t2.pt(); }
28 };
29 
30 #include <limits>
31 #include <cmath>
32 
33 template <class T>
37  bool operator()(const T& a1, const T& a2) {
38  return fabs(a1.pt() - a2.pt()) > std::numeric_limits<double>::epsilon() ? a1.pt() < a2.pt()
39  : fabs(a1.px() - a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() < a2.px()
40  : a1.pz() < a2.pz();
41  }
42 };
43 
44 template <class T>
48  bool operator()(const T& a1, const T& a2) {
49  return fabs(a1.pt() - a2.pt()) > std::numeric_limits<double>::epsilon() ? a1.pt() > a2.pt()
50  : fabs(a1.px() - a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() > a2.px()
51  : a1.pz() > a2.pz();
52  }
53 };
54 
55 #endif
bool operator()(const T &a1, const T &a2)
Definition: PtComparator.h:37
bool operator()(const T &t1, const T &t2) const
Definition: PtComparator.h:27
T first_argument_type
Definition: PtComparator.h:18
bool operator()(const T &a1, const T &a2)
Definition: PtComparator.h:48
T second_argument_type
Definition: PtComparator.h:26
T first_argument_type
Definition: PtComparator.h:25
T second_argument_type
Definition: PtComparator.h:19
long double T
bool operator()(const T &t1, const T &t2) const
Definition: PtComparator.h:20