CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloDigiCollectionSorter.h
Go to the documentation of this file.
1 #ifndef CaloDigiCollectionSorter_h
2 #define CaloDigiCollectionSorter_h
3 
12 #include <vector>
13 #include <algorithm>
15 
16 
18 public:
20 
22  template<class T>
24  public:
26 
27  bool operator()(const T & df1, const T & df2) const {
28  // should work for HcalQIESamples & EcalMPGASamples
29  // sort in reverse order, so highest bins come first
30  return (df1[theMaxBin].raw() > df2[theMaxBin].raw());
31  }
32 
33  private:
34  int theMaxBin;
35  };
36 
39  template<class T>
40  std::vector<T> sortedVector(const edm::SortedCollection<T> & input) const {
41  std::vector<T> result;
42  result.reserve(input.size());
43  for(unsigned int i = 0; i < input.size() ; ++i)
44  {
45  result.push_back(input[i]);
46  }
47  // now sort
48  std::sort(result.begin(), result.end(), CaloDigiSortByMaxBin<T>(theMaxBin));
49  return result;
50  }
51 
52 private:
53  int theMaxBin;
54 };
55 
56 #endif
57 
int i
Definition: DBlmapReader.cc:9
std::vector< T > sortedVector(const edm::SortedCollection< T > &input) const
tuple result
Definition: query.py:137
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