CMS 3D CMS Logo

HcalObjectAddons.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_HcalObjectAddons
2 #define CondFormats_HcalObjects_HcalObjectAddons
3 
4 #include <vector>
5 #include <algorithm>
6 
7 // functions with common forms
8 namespace HcalObjectAddons {
9  template <class Item, class Less>
10  const Item* findByT(const Item* target, const std::vector<const Item*>& itemsByT) {
11  Less less;
12  auto item = std::lower_bound(itemsByT.begin(), itemsByT.end(), target, less);
13  if (item == itemsByT.end() || !less.equal(*item, target)) {
14  return nullptr;
15  }
16  return *item;
17  }
18 
19  //sorting
20  template <class Item, class Less>
21  static void sortByT(const std::vector<Item>& items, std::vector<const Item*>& itemsByT) {
22  itemsByT.clear();
23  itemsByT.reserve(items.size());
24  Less less;
25  for (const auto& i : items) {
26  if (less.good(i))
27  itemsByT.push_back(&i);
28  }
29  std::sort(itemsByT.begin(), itemsByT.end(), less);
30  }
31 
32 } // namespace HcalObjectAddons
33 
34 #endif
mps_fire.i
i
Definition: mps_fire.py:428
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
HcalObjectAddons::findByT
const Item * findByT(const Item *target, const std::vector< const Item * > &itemsByT)
Definition: HcalObjectAddons.h:10
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
HcalObjectAddons
Definition: HcalObjectAddons.h:8
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
HcalObjectAddons::sortByT
static void sortByT(const std::vector< Item > &items, std::vector< const Item * > &itemsByT)
Definition: HcalObjectAddons.h:21