1 #ifndef JetAlgorithms_JetAlgoHelper_h 2 #define JetAlgorithms_JetAlgoHelper_h 21 inline bool so_lt (
const SortObject&
a,
const SortObject&
b) {
return a.value < b.value;}
22 inline bool so_gt (
const SortObject&
a,
const SortObject&
b) {
return a.value > b.value;}
24 template <
class T>
struct GetPt {
inline double getValue (
const T&
a) {
return a.pt();}};
25 template <
class T>
struct GetEt {
inline double getValue (
const T&
a) {
return a.et();}};
26 template <
class T>
struct GetPtRef {
inline double getValue (
const T&
a) {
return a->pt();}};
27 template <
class T>
struct GetEtRef {
inline double getValue (
const T&
a) {
return a->et();}};
29 template <
class T,
class GetValue>
30 inline void sortGreater (std::vector <T>* container) {
31 std::vector <SortObject> sortable (container->size());
34 for (
unsigned i = 0;
i < container->size();
i++) {
35 sortable[
i].value = getter.getValue ((*container)[
i]);
36 sortable[
i].index =
i;
37 if (sorted && i && so_lt (sortable[i-1], sortable[i])) sorted =
false;
40 std::sort (sortable.begin(), sortable.end(), so_gt);
42 result.reserve(container->size());
43 for (
unsigned i = 0; i < container->size(); i++) {
44 result.push_back ((*container)[sortable[i].
index]);
46 container->swap (result);
51 inline void sortByPt (std::vector <T>* container) {
52 sortGreater <T, GetPt<T> > (container);
56 inline void sortByEt (std::vector <T>* container) {
57 sortGreater <T, GetEt<T> > (container);
62 inline void sortByPtRef (std::vector <T>* container) {
63 sortGreater <T, GetPtRef<T> > (container);
67 inline void sortByEtRef (std::vector <T>* container) {
68 sortGreater <T, GetEtRef<T> > (container);
80 return comp.operator () (*a1, *a2);
90 return comp.operator () (*a1, *a2);
101 return comp.operator () (*a1, *a2);
int operator()(const T &a1, const T &a2)
bool sortByPt(const HepMC::GenParticle *a, const HepMC::GenParticle *b)
virtual PseudoJet result(const PseudoJet &jet) const
int operator()(const T *a1, const T *a2)
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
int operator()(const T &a1, const T &a2)