CMS 3D CMS Logo

EgammaRange.h
Go to the documentation of this file.
1 #ifndef EgammaIsolationAlgos_EgammaRange_H
2 #define EgammaIsolationAlgos_EgammaRange_H
3 
8 #include <iostream>
9 #include <utility>
10 #include <algorithm>
11 
12 namespace egammaisolation {
13 
14  template <class T>
15  class EgammaRange : public std::pair<T, T> {
16  public:
18 
19  EgammaRange(const T& aMin, const T& aMax) : std::pair<T, T>(aMin, aMax) {}
20 
21  EgammaRange(const std::pair<T, T>& aPair) : std::pair<T, T>(aPair) {}
22 
23  const T& min() const { return this->first; }
24 
25  const T& max() const { return this->second; }
26 
27  T mean() const { return (this->first + this->second) / 2.; }
28 
29  bool empty() const { return (this->second < this->first); }
30 
31  bool inside(const T& value) const {
32  if (value < this->first || this->second < value)
33  return false;
34  else
35  return true;
36  }
37 
38  void sort() {
39  if (empty())
40  std::swap(this->first, this->second);
41  }
42  };
43 
44 } // namespace egammaisolation
45 
46 template <class T>
47 std::ostream& operator<<(std::ostream& out, const egammaisolation::EgammaRange<T>& r) {
48  return out << "(" << r.min() << "," << r.max() << ")";
49 }
50 
51 #endif
egammaisolation
Definition: EgammaRange.h:12
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
egammaisolation::EgammaRange::EgammaRange
EgammaRange()
Definition: EgammaRange.h:17
dqmdumpme.first
first
Definition: dqmdumpme.py:55
egammaisolation::EgammaRange::min
const T & min() const
Definition: EgammaRange.h:23
egammaisolation::EgammaRange::mean
T mean() const
Definition: EgammaRange.h:27
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
operator<<
std::ostream & operator<<(std::ostream &out, const egammaisolation::EgammaRange< T > &r)
Definition: EgammaRange.h:47
egammaisolation::EgammaRange::sort
void sort()
Definition: EgammaRange.h:38
egammaisolation::EgammaRange::EgammaRange
EgammaRange(const std::pair< T, T > &aPair)
Definition: EgammaRange.h:21
egammaisolation::EgammaRange::empty
bool empty() const
Definition: EgammaRange.h:29
egammaisolation::EgammaRange::EgammaRange
EgammaRange(const T &aMin, const T &aMax)
Definition: EgammaRange.h:19
value
Definition: value.py:1
alignCSCRings.r
r
Definition: alignCSCRings.py:93
std
Definition: JetResolutionObject.h:76
T
long double T
Definition: Basic3DVectorLD.h:48
egammaisolation::EgammaRange::inside
bool inside(const T &value) const
Definition: EgammaRange.h:31
egammaisolation::EgammaRange
Definition: EgammaRange.h:15
egammaisolation::EgammaRange::max
const T & max() const
Definition: EgammaRange.h:25
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31