CMS 3D CMS Logo

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>
14 class PixelRecoRange : public std::pair<T, T> {
15 public:
17 
18  template <class U>
20 
21  PixelRecoRange(T aMin, T aMax) : std::pair<T, T>(aMin, aMax) {}
22 
23  PixelRecoRange(const std::pair<T, T>& aPair) : std::pair<T, T>(aPair) {}
24 
25  T min() const { return this->first; }
26  T max() const { return this->second; }
27  T mean() const { return T(0.5) * (this->first + this->second); }
28 
29  bool empty() const { return (this->second < this->first); }
30 
32  std::swap(this->second, this->first);
33  return *this;
34  }
35 
36  bool inside(const T& value) const { return !((value < this->first) | (this->second < value)); }
37 
38  bool hasIntersection(const PixelRecoRange<T>& r) const { return rangesIntersect(*this, r); }
39 
41 
43  if (this->empty())
44  return r;
45  else if (r.empty())
46  return *this;
47  else
48  return PixelRecoRange(std::min(min(), r.min()), std::max(max(), r.max()));
49  }
50 
52  if (empty())
53  std::swap(this->first, this->second);
54  return *this;
55  }
56 };
57 
58 template <class T>
59 std::ostream& operator<<(std::ostream& out, const PixelRecoRange<T>& r) {
60  return out << "(" << r.min() << "," << r.max() << ")";
61 }
62 #endif
PixelRecoRange::hasIntersection
bool hasIntersection(const PixelRecoRange< T > &r) const
Definition: PixelRecoRange.h:38
PixelRecoRange::PixelRecoRange
PixelRecoRange()
Definition: PixelRecoRange.h:16
operator<<
std::ostream & operator<<(std::ostream &out, const PixelRecoRange< T > &r)
Definition: PixelRecoRange.h:59
PixelRecoRange::PixelRecoRange
PixelRecoRange(T aMin, T aMax)
Definition: PixelRecoRange.h:21
min
T min(T a, T b)
Definition: MathUtil.h:58
PixelRecoRange::mean
T mean() const
Definition: PixelRecoRange.h:27
PixelRecoRange::PixelRecoRange
PixelRecoRange(const std::pair< T, T > &aPair)
Definition: PixelRecoRange.h:23
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
PixelRecoRange::empty
bool empty() const
Definition: PixelRecoRange.h:29
PixelRecoRange::min
T min() const
Definition: PixelRecoRange.h:25
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
PixelRecoRange::swap
PixelRecoRange< T > & swap()
Definition: PixelRecoRange.h:31
PixelRecoRange::max
T max() const
Definition: PixelRecoRange.h:26
rangeIntersection.h
trackingPlots.other
other
Definition: trackingPlots.py:1464
PixelRecoRange::intersection
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
Definition: PixelRecoRange.h:40
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
PixelRecoRange
Definition: InnerDeltaPhi.h:15
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PixelRecoRange::PixelRecoRange
PixelRecoRange(PixelRecoRange< U > other)
Definition: PixelRecoRange.h:19
value
Definition: value.py:1
PixelRecoRange::sum
PixelRecoRange< T > sum(const PixelRecoRange< T > &r) const
Definition: PixelRecoRange.h:42
alignCSCRings.r
r
Definition: alignCSCRings.py:93
rangeIntersection
Range rangeIntersection(const Range &a, const Range &b)
Definition: rangeIntersection.h:16
std
Definition: JetResolutionObject.h:76
T
long double T
Definition: Basic3DVectorLD.h:48
PixelRecoRange::sort
PixelRecoRange< T > & sort()
Definition: PixelRecoRange.h:51
rangesIntersect
bool rangesIntersect(const Range &a, const Range &b)
Definition: rangesIntersect.h:14
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
PixelRecoRange::inside
bool inside(const T &value) const
Definition: PixelRecoRange.h:36
rangesIntersect.h