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
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
GreaterByPt
Definition: PtComparator.h:24
NumericSafeGreaterByPt::second_argument_type
T second_argument_type
Definition: PtComparator.h:48
GreaterByPt::operator()
bool operator()(const T &t1, const T &t2) const
Definition: PtComparator.h:27
GreaterByPt::second_argument_type
T second_argument_type
Definition: PtComparator.h:26
geometryDiff.epsilon
int epsilon
Definition: geometryDiff.py:26
testProducerWithPsetDescEmpty_cfi.a2
a2
Definition: testProducerWithPsetDescEmpty_cfi.py:35
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
NumericSafeGreaterByPt
Definition: PtComparator.h:46
LessByPt::second_argument_type
T second_argument_type
Definition: PtComparator.h:19
NumericSafeGreaterByPt::operator()
bool operator()(const T &a1, const T &a2)
Definition: PtComparator.h:49
NumericSafeLessByPt::first_argument_type
T first_argument_type
Definition: PtComparator.h:35
NumericSafeLessByPt
Definition: PtComparator.h:34
NumericSafeLessByPt::second_argument_type
T second_argument_type
Definition: PtComparator.h:36
NumericSafeLessByPt::operator()
bool operator()(const T &a1, const T &a2)
Definition: PtComparator.h:37
LessByPt::first_argument_type
T first_argument_type
Definition: PtComparator.h:18
T
long double T
Definition: Basic3DVectorLD.h:48
GreaterByPt::first_argument_type
T first_argument_type
Definition: PtComparator.h:25
NumericSafeGreaterByPt::first_argument_type
T first_argument_type
Definition: PtComparator.h:47
LessByPt::operator()
bool operator()(const T &t1, const T &t2) const
Definition: PtComparator.h:20
LessByPt
Definition: PtComparator.h:17