CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoEgamma/EgammaIsolationAlgos/interface/EgammaRange.h

Go to the documentation of this file.
00001 #ifndef EgammaIsolationAlgos_EgammaRange_H
00002 #define EgammaIsolationAlgos_EgammaRange_H
00003 
00008 #include <iostream>
00009 #include <utility>
00010 #include <algorithm>
00011 
00012 namespace egammaisolation {
00013 
00014 template<class T> class EgammaRange : public std::pair<T,T> {
00015 public:
00016 
00017   EgammaRange() { }
00018 
00019   EgammaRange(const T & aMin, const T & aMax) : std::pair<T,T> (aMin,aMax) { }
00020 
00021   EgammaRange(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 egammaisolation::EgammaRange<T>& r) 
00041 { return out << "("<<r.min()<<","<<r.max()<<")"; }
00042 
00043 #endif