CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTracker/TkMSParametrization/interface/PixelRecoRange.h

Go to the documentation of this file.
00001 #ifndef PixelRecoRange_H
00002 #define PixelRecoRange_H
00003 
00006 #include <ostream>
00007 #include <utility>
00008 #include <algorithm>
00009 
00010 #include "TrackingTools/DetLayers/interface/rangesIntersect.h"
00011 #include "RecoTracker/TkMSParametrization/interface/rangeIntersection.h"
00012 
00013 template<class T> class PixelRecoRange : public std::pair<T,T> {
00014 public:
00015 
00016   PixelRecoRange() { }
00017 
00018   PixelRecoRange(T  aMin, T aMax) 
00019       : std::pair<T,T> (aMin,aMax) { }
00020 
00021   PixelRecoRange(const std::pair<T,T> & aPair ) 
00022       : std::pair<T,T> (aPair) { }  
00023 
00024   T min() const { return this->first; }
00025   T max() const { return this->second; }
00026   T mean() const { return 0.5*(this->first+this->second); }
00027 
00028   bool empty() const { return (this->second < this->first); }
00029 
00030   bool inside(const T & value) const {
00031     return !(value < this->first || this->second < value);
00032   }
00033 
00034   bool hasIntersection( const PixelRecoRange<T> & r) const {
00035     return rangesIntersect(*this,r); 
00036   }
00037 
00038   PixelRecoRange<T> intersection( const PixelRecoRange<T> & r) const {
00039     return rangeIntersection(*this,r); 
00040   }
00041 
00042   PixelRecoRange<T> sum(const PixelRecoRange<T> & r) const {
00043    if( this->empty()) return r;
00044    else if( r.empty()) return *this;
00045    else return 
00046           PixelRecoRange(std::min( min(),r.min()),
00047                          std::max( max(),r.max())
00048                         ); 
00049   }
00050 
00051   void sort() { if (empty() ) std::swap(this->first,this->second); }
00052 };
00053 
00054 template <class T> std::ostream & operator<<( 
00055      std::ostream& out, const PixelRecoRange<T>& r) 
00056 {
00057   return out << "("<<r.min()<<","<<r.max()<<")";
00058 }
00059 #endif