/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
RecoMuon/MuonIsolation/interface/Range.h
51 строка
1 KB
Cms Build
Clang-Format
03 июн 2019, 06:38
03 июн 2019, 06:38
906af8e
Код
Авторство
О чём код?
#ifndef MuonIsolation_Range_H #define MuonIsolation_Range_H /** \class muonisolation::Range * Define a range [aMin,aMax] */ #include <iostream> #include <utility> #include <algorithm> namespace muonisolation { template <class T> class Range : public std::pair<T, T> { public: Range() {} Range(const T& aMin, const T& aMax) : std::pair<T, T>(aMin, aMax) {} Range(const std::pair<T, T>& aPair) : std::pair<T, T>(aPair) {} const T& min() const { return this->first; } const T& max() const { return this->second; } T mean() const { return (this->first + this->second) / 2.; } bool empty() const { return (this->second < this->first); } bool inside(const T& value) const { if (value < this->first || this->second < value) return false; else return true; } void sort() { if (empty()) std::swap(this->first, this->second); } }; } // namespace muonisolation template <class T> std::ostream& operator<<(std::ostream& out, const muonisolation::Range<T>& r) { return out << "(" << r.min() << "," << r.max() << ")"; } #endif