CMS 3D CMS Logo

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()
39  ? a1.pt() < a2.pt()
40  : fabs(a1.px() - a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() < a2.px()
41  : a1.pz() < a2.pz();
42  }
43 };
44 
45 template <class T>
49  bool operator()(const T& a1, const T& a2) {
50  return fabs(a1.pt() - a2.pt()) > std::numeric_limits<double>::epsilon()
51  ? a1.pt() > a2.pt()
52  : fabs(a1.px() - a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() > a2.px()
53  : a1.pz() > a2.pz();
54  }
55 };
56 
57 #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:49
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