CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoMuon/MuonIsolation/interface/Range.h

Go to the documentation of this file.
00001 #ifndef MuonIsolation_Range_H
00002 #define MuonIsolation_Range_H
00003 
00008 #include <iostream>
00009 #include <utility>
00010 #include <algorithm>
00011 
00012 namespace muonisolation {
00013 
00014 template<class T> class Range : public std::pair<T,T> {
00015 public:
00016 
00017   Range() { }
00018 
00019   Range(const T & aMin, const T & aMax) : std::pair<T,T> (aMin,aMax) { }
00020 
00021   Range(const std::pair<T,T> & aPair ) : std::pair<T,T> (aPair) { }  
00022 
00023   const T & min() const { return this->first; }
00024 
00025   const T & max() const { return this->second; }
00026 
00027   T mean() const { return (this->first+this->second)/2.; }
00028 
00029   bool empty() const { return (this->second < this->first); }
00030 
00031   bool inside(const T & value) const {
00032     if (value < this->first || this->second < value)  return false; else  return true;
00033   }
00034 
00035   void sort() { if (empty() ) std::swap(this->first,this->second); }
00036 };
00037 
00038 }
00039 
00040 template <class T> std::ostream & operator<<( std::ostream& out, const muonisolation::Range<T>& r) 
00041 { return out << "("<<r.min()<<","<<r.max()<<")"; }
00042 
00043 #endif