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;}
26 template <
class T>
struct GetPt {
inline double getValue (
const T&
a) {
return a.pt();}};
27 template <
class T>
struct GetEt {
inline double getValue (
const T&
a) {
return a.et();}};
28 template <
class T>
struct GetPtRef {
inline double getValue (
const T&
a) {
return a->pt();}};
29 template <
class T>
struct GetEtRef {
inline double getValue (
const T&
a) {
return a->et();}};
31 template <
class T,
class GetValue>
32 inline void sortGreater (std::vector <T>* container) {
33 std::vector <SortObject> sortable (container->size());
36 for (
unsigned i = 0;
i < container->size();
i++) {
37 sortable[
i].value = getter.getValue ((*container)[
i]);
38 sortable[
i].index =
i;
39 if (sorted && i && so_lt (sortable[i-1], sortable[i])) sorted =
false;
42 std::sort (sortable.begin(), sortable.end(), so_gt);
44 result.reserve(container->size());
45 for (
unsigned i = 0; i < container->size(); i++) {
46 result.push_back ((*container)[sortable[i].
index]);
48 container->swap (result);
53 inline void sortByPt (std::vector <T>* container) {
54 sortGreater <T, GetPt<T> > (container);
58 inline void sortByEt (std::vector <T>* container) {
59 sortGreater <T, GetEt<T> > (container);
64 inline void sortByPtRef (std::vector <T>* container) {
65 sortGreater <T, GetPtRef<T> > (container);
69 inline void sortByEtRef (std::vector <T>* container) {
70 sortGreater <T, GetEtRef<T> > (container);
82 return comp.operator () (*a1, *a2);
92 return comp.operator () (*a1, *a2);
103 return comp.operator () (*a1, *a2);
int operator()(const T &a1, const T &a2)
bool sortByPt(const HepMC::GenParticle *a, const HepMC::GenParticle *b)
PseudoJet result(const PseudoJet &jet) const override
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)