test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Range.h
Go to the documentation of this file.
1 #ifndef MuonIsolation_Range_H
2 #define MuonIsolation_Range_H
3 
8 #include <iostream>
9 #include <utility>
10 #include <algorithm>
11 
12 namespace muonisolation {
13 
14 template<class T> class Range : public std::pair<T,T> {
15 public:
16 
17  Range() { }
18 
19  Range(const T & aMin, const T & aMax) : std::pair<T,T> (aMin,aMax) { }
20 
21  Range(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 muonisolation::Range<T>& r)
41 { return out << "("<<r.min()<<","<<r.max()<<")"; }
42 
43 #endif
const T & max() const
Definition: Range.h:25
U second(std::pair< T, U > const &p)
Range(const T &aMin, const T &aMax)
Definition: Range.h:19
T mean() const
Definition: Range.h:27
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool empty() const
Definition: Range.h:29
const T & min() const
Definition: Range.h:23
Range(const std::pair< T, T > &aPair)
Definition: Range.h:21
bool inside(const T &value) const
Definition: Range.h:31
long double T