CMS 3D CMS Logo

EgammaRange.h
Go to the documentation of this file.
1 #ifndef EgammaIsolationAlgos_EgammaRange_H
2 #define EgammaIsolationAlgos_EgammaRange_H
3 
8 #include <iostream>
9 #include <utility>
10 #include <algorithm>
11 
12 namespace egammaisolation {
13 
14  template <class T>
15  class EgammaRange : public std::pair<T, T> {
16  public:
18 
19  EgammaRange(const T& aMin, const T& aMax) : std::pair<T, T>(aMin, aMax) {}
20 
21  EgammaRange(const std::pair<T, T>& aPair) : std::pair<T, T>(aPair) {}
22 
23  const T& min() const { return this->first; }
24 
25  const T& max() const { return this->second; }
26 
27  T mean() const { return (this->first + this->second) / 2.; }
28 
29  bool empty() const { return (this->second < this->first); }
30 
31  bool inside(const T& value) const {
32  if (value < this->first || this->second < value)
33  return false;
34  else
35  return true;
36  }
37 
38  void sort() {
39  if (empty())
40  std::swap(this->first, this->second);
41  }
42  };
43 
44 } // namespace egammaisolation
45 
46 template <class T>
47 std::ostream& operator<<(std::ostream& out, const egammaisolation::EgammaRange<T>& r) {
48  return out << "(" << r.min() << "," << r.max() << ")";
49 }
50 
51 #endif
EgammaRange(const std::pair< T, T > &aPair)
Definition: EgammaRange.h:21
const T & max() const
Definition: EgammaRange.h:25
EgammaRange(const T &aMin, const T &aMax)
Definition: EgammaRange.h:19
U second(std::pair< T, U > const &p)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool inside(const T &value) const
Definition: EgammaRange.h:31
Definition: value.py:1
long double T
const T & min() const
Definition: EgammaRange.h:23