test
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 
19 template<class U>
21  std::pair<T,T> (other.min(),other.max()) { }
22 
23 
24  PixelRecoRange(T aMin, T aMax)
25  : std::pair<T,T> (aMin,aMax) { }
26 
27  PixelRecoRange(const std::pair<T,T> & aPair )
28  : std::pair<T,T> (aPair) { }
29 
30  T min() const { return this->first; }
31  T max() const { return this->second; }
32  T mean() const { return T(0.5)*(this->first+this->second); }
33 
34  bool empty() const { return (this->second < this->first); }
35 
36  bool inside(const T & value) const {
37  return !(value < this->first || this->second < value);
38  }
39 
40  bool hasIntersection( const PixelRecoRange<T> & r) const {
41  return rangesIntersect(*this,r);
42  }
43 
45  return rangeIntersection(*this,r);
46  }
47 
49  if( this->empty()) return r;
50  else if( r.empty()) return *this;
51  else return
53  std::max( max(),r.max())
54  );
55  }
56 
57  void sort() { if (empty() ) std::swap(this->first,this->second); }
58 };
59 
60 template <class T> std::ostream & operator<<(
61  std::ostream& out, const PixelRecoRange<T>& r)
62 {
63  return out << "("<<r.min()<<","<<r.max()<<")";
64 }
65 #endif
PixelRecoRange(const std::pair< T, T > &aPair)
T max() const
PixelRecoRange< T > sum(const PixelRecoRange< T > &r) const
bool empty() const
T min() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
PixelRecoRange(PixelRecoRange< U > other)
U second(std::pair< T, U > const &p)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool rangesIntersect(const Range &a, const Range &b)
T min(T a, T b)
Definition: MathUtil.h:58
bool first
Definition: L1TdeRCT.cc:75
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