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> class EgammaRange : public std::pair<T,T> {
15 public:
16 
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) return false; else return true;
33  }
34 
35  void sort() { if (empty() ) std::swap(this->first,this->second); }
36 };
37 
38 }
39 
40 template <class T> std::ostream & operator<<( std::ostream& out, const egammaisolation::EgammaRange<T>& r)
41 { return out << "("<<r.min()<<","<<r.max()<<")"; }
42 
43 #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