CMS 3D CMS Logo

PixelRecoRange.h

Go to the documentation of this file.
00001 #ifndef PixelRecoRange_H
00002 #define PixelRecoRange_H
00003 
00006 #include <iostream>
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(const T & aMin, const 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   const T & min() const { return this->first; }
00025   const T & max() const { return this->second; }
00026   T mean() const { return (this->first+this->second)/2.; }
00027 
00028   bool empty() const { return (this->second < this->first); }
00029 
00030   bool inside(const T & value) const {
00031     if (value < this->first || this->second < value)  return false; else  return true;
00032   }
00033 
00034   bool hasIntersection( const PixelRecoRange<T> & r) const {
00035     return rangesIntersect(*this,r); 
00036   }
00037 
00038   PixelRecoRange<T> intersection( 
00039       const PixelRecoRange<T> & r) const {
00040     return rangeIntersection(*this,r); 
00041   }
00042 
00043   PixelRecoRange<T> sum(const PixelRecoRange<T> & r) const {
00044    if( this->empty()) return r;
00045    else if( r.empty()) return *this;
00046    else return 
00047        PixelRecoRange( 
00048          (min() < r.min()) ? min() : r.min(), 
00049          (max() < r.max()) ? r.max() : max()); 
00050   }
00051 
00052   void sort() { if (empty() ) std::swap(this->first,this->second); }
00053 };
00054 
00055 template <class T> std::ostream & operator<<( 
00056      std::ostream& out, const PixelRecoRange<T>& r) 
00057 {
00058   return out << "("<<r.min()<<","<<r.max()<<")";
00059 }
00060 #endif

Generated on Tue Jun 9 17:45:51 2009 for CMSSW by  doxygen 1.5.4