1 #ifndef JetAlgorithms_JetAlgoHelper_h 2 #define JetAlgorithms_JetAlgoHelper_h 23 inline bool so_lt(
const SortObject&
a,
const SortObject&
b) {
return a.value <
b.value; }
24 inline bool so_gt(
const SortObject&
a,
const SortObject&
b) {
return a.value >
b.value; }
28 inline double getValue(
const T&
a) {
return a.pt(); }
32 inline double getValue(
const T&
a) {
return a.et(); }
36 inline double getValue(
const T&
a) {
return a->pt(); }
40 inline double getValue(
const T&
a) {
return a->et(); }
43 template <
class T,
class GetValue>
44 inline void sortGreater(std::vector<T>* container) {
45 std::vector<SortObject> sortable(container->size());
48 for (
unsigned i = 0;
i < container->size();
i++) {
49 sortable[
i].value = getter.getValue((*container)[
i]);
50 sortable[
i].index =
i;
51 if (sorted &&
i && so_lt(sortable[
i - 1], sortable[
i]))
55 std::sort(sortable.begin(), sortable.end(), so_gt);
57 result.reserve(container->size());
58 for (
unsigned i = 0;
i < container->size();
i++) {
66 inline void sortByPt(std::vector<T>* container) {
67 sortGreater<T, GetPt<T> >(container);
71 inline void sortByEt(std::vector<T>* container) {
72 sortGreater<T, GetEt<T> >(container);
76 inline void sortByPtRef(std::vector<T>* container) {
77 sortGreater<T, GetPtRef<T> >(container);
81 inline void sortByEtRef(std::vector<T>* container) {
82 sortGreater<T, GetEtRef<T> >(container);
96 return comp.operator()(*a1, *
a2);
108 return comp.operator()(*a1, *
a2);
121 return comp.operator()(*a1, *
a2);
PseudoJet result(const PseudoJet &jet) const override
int operator()(const T &a1, const T &a2)
bool sortByPt(const HepMC::GenParticle *a, const HepMC::GenParticle *b)
bool sortByPtRef(const T lhs, const T rhs)
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)