CMS 3D CMS Logo

CaloDigiCollectionSorter.h
Go to the documentation of this file.
1 #ifndef CaloDigiCollectionSorter_h
2 #define CaloDigiCollectionSorter_h
3 
13 #include <algorithm>
14 #include <vector>
15 
17 public:
19 
21  template <class T>
23  public:
25 
26  bool operator()(const T &df1, const T &df2) const {
27  // should work for HcalQIESamples & EcalMPGASamples
28  // sort in reverse order, so highest bins come first
29  return (df1[theMaxBin].raw() > df2[theMaxBin].raw());
30  }
31 
32  private:
33  int theMaxBin;
34  };
35 
38  template <class T>
39  std::vector<T> sortedVector(const edm::SortedCollection<T> &input) const {
40  std::vector<T> result;
41  result.reserve(input.size());
42  for (unsigned int i = 0; i < input.size(); ++i) {
43  result.push_back(input[i]);
44  }
45  // now sort
46  std::sort(result.begin(), result.end(), CaloDigiSortByMaxBin<T>(theMaxBin));
47  return result;
48  }
49 
50 private:
51  int theMaxBin;
52 };
53 
54 #endif
std::vector< T > sortedVector(const edm::SortedCollection< T > &input) const
static std::string const input
Definition: EdmProvDump.cc:48
bin
set the eta bin as selection string.
embedded class to be used as a sort predicate
size_type size() const
long double T
bool operator()(const T &df1, const T &df2) const