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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#ifndef Surface_GeometricSorting_h
#define Surface_GeometricSorting_h
#include <functional>
#include <DataFormats/GeometryVector/interface/Phi.h>
namespace geomsort {
/** \class ExtractR
*
* functor to sort in R using precomputed_value_sort.
* Can be used for any object with a member position().
*
* Use:
*
* precomputed_value_sort(v.begin(), v.end(), ExtractR<Surface>());
*
* \author N. Amapane - CERN
*/
template <class T, class Scalar = typename T::Scalar>
struct ExtractR {
typedef Scalar result_type;
Scalar operator()(const T* p) const { return p->position().perp(); }
Scalar operator()(const T& p) const { return p.position().perp(); }
};
/** \class ExtractPhi
*
* functor to sort in phi (from -pi to pi) using precomputed_value_sort.
* Can be used for any object with a member position().
*
* Note that sorting in phi is done within the phi range of
* (-pi, pi]. It may NOT be what you expect if the elements cluster around
* the pi discontinuity.
*
* Use:
*
* precomputed_value_sort(v.begin(), v.end(), ExtractPhi<Surface>());
*
* \author N. Amapane - CERN
*/
template <class T, class Scalar = typename T::Scalar>
struct ExtractPhi {
typedef Geom::Phi<Scalar> result_type;
Geom::Phi<Scalar> operator()(const T* p) const { return p->position().phi(); }
Geom::Phi<Scalar> operator()(const T& p) const { return p.position().phi(); }
};
/** \class ExtractZ
*
* functor to sort in Z using precomputed_value_sort.
* Can be used for any object with a member position().
*
* Use:
*
* precomputed_value_sort(v.begin(), v.end(), ExtractZ<Surface>());
*
* \author N. Amapane - CERN
*/
template <class T, class Scalar = typename T::Scalar>
struct ExtractZ {
typedef Scalar result_type;
Scalar operator()(const T* p) const { return p->position().z(); }
Scalar operator()(const T& p) const { return p.position().z(); }
};
/** \class ExtractAbsZ
*
* functor to sort in |Z| using precomputed_value_sort.
* Can be used for any object with a member position().
*
* Use:
*
* precomputed_value_sort(v.begin(), v.end(), ExtractAbsZ<Surface>());
*
* \author N. Amapane - CERN
*/
template <class T, class Scalar = typename T::Scalar>
struct ExtractAbsZ {
typedef Scalar result_type;
Scalar operator()(const T* p) const { return fabs(p->position().z()); }
Scalar operator()(const T& p) const { return fabs(p.position().z()); }
};
} // namespace geomsort
#endif
|