CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelRecoRange.h
Go to the documentation of this file.
1 #ifndef PixelRecoRange_H
2 #define PixelRecoRange_H
3 
6 #include <ostream>
7 #include <utility>
8 #include <algorithm>
9 
12 
13 template<class T> class PixelRecoRange : public std::pair<T,T> {
14 public:
15 
17 
18  PixelRecoRange(T aMin, T aMax)
19  : std::pair<T,T> (aMin,aMax) { }
20 
21  PixelRecoRange(const std::pair<T,T> & aPair )
22  : std::pair<T,T> (aPair) { }
23 
24  T min() const { return this->first; }
25  T max() const { return this->second; }
26  T mean() const { return 0.5*(this->first+this->second); }
27 
28  bool empty() const { return (this->second < this->first); }
29 
30  bool inside(const T & value) const {
31  return !(value < this->first || this->second < value);
32  }
33 
34  bool hasIntersection( const PixelRecoRange<T> & r) const {
35  return rangesIntersect(*this,r);
36  }
37 
39  return rangeIntersection(*this,r);
40  }
41 
43  if( this->empty()) return r;
44  else if( r.empty()) return *this;
45  else return
47  std::max( max(),r.max())
48  );
49  }
50 
51  void sort() { if (empty() ) std::swap(this->first,this->second); }
52 };
53 
54 template <class T> std::ostream & operator<<(
55  std::ostream& out, const PixelRecoRange<T>& r)
56 {
57  return out << "("<<r.min()<<","<<r.max()<<")";
58 }
59 #endif
PixelRecoRange(const std::pair< T, T > &aPair)
T max() const
PixelRecoRange< T > sum(const PixelRecoRange< T > &r) const
#define min(a, b)
Definition: mlp_lapack.h:161
bool empty() const
T min() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
U second(std::pair< T, U > const &p)
const T & max(const T &a, const T &b)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool rangesIntersect(const Range &a, const Range &b)
bool first
Definition: L1TdeRCT.cc:94
tuple out
Definition: dbtoconf.py:99
T mean() const
bool inside(const T &value) const
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
bool hasIntersection(const PixelRecoRange< T > &r) const
Range rangeIntersection(const Range &a, const Range &b)
PixelRecoRange(T aMin, T aMax)
long double T