1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef CommonTools_Utils_EtComparator_h
#define CommonTools_Utils_EtComparator_h
/** \class EtComparator
*
* compare by Et
*
* \author Luca Lista, INFN
*
* \version $Revision: 1.2 $
*
* $Id: EtComparator.h,v 1.2 2007/04/23 20:41:01 llista Exp $
*
*/
template <typename T>
struct LessByEt {
typedef T first_argument_type;
typedef T second_argument_type;
bool operator()(const T& t1, const T& t2) const { return t1.et() < t2.et(); }
};
template <typename T>
struct GreaterByEt {
typedef T first_argument_type;
typedef T second_argument_type;
bool operator()(const T& t1, const T& t2) const { return t1.et() > t2.et(); }
};
#include <limits>
#include <cmath>
template <class T>
struct NumericSafeLessByEt {
typedef T first_argument_type;
typedef T second_argument_type;
bool operator()(const T& a1, const T& a2) {
return fabs(a1.et() - a2.et()) > std::numeric_limits<double>::epsilon() ? a1.et() < a2.et()
: fabs(a1.px() - a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() < a2.px()
: a1.pz() < a2.pz();
}
};
template <class T>
struct NumericSafeGreaterByEt {
typedef T first_argument_type;
typedef T second_argument_type;
bool operator()(const T& a1, const T& a2) {
return fabs(a1.et() - a2.et()) > std::numeric_limits<double>::epsilon() ? a1.et() > a2.et()
: fabs(a1.px() - a2.px()) > std::numeric_limits<double>::epsilon() ? a1.px() > a2.px()
: a1.pz() > a2.pz();
}
};
#endif
|