Limits.h
Go to the documentation of this file.
1 #ifndef LIMITS__H
2 #define LIMITS__H
3 
4 namespace genie {
5  namespace supernova {
6 
7  template <class T>
8  class Limits: public std::pair<T, T> {
9  public:
10  Limits(const T& v):std::pair<T, T> (v, v) {};
11  Limits(const T& v1, const T& v2):std::pair<T, T> (std::minmax(v1, v2)) {};
12 
13  // Getters
14  const T& Min() const { return this->first; }
15  const T& Max() const { return this->second; }
16  T Range() const { return Max() - Min(); }
17 
18  // Setters
19  void Set(double val1, double val2) {
20  this->first = val1;
21  this->second = val2;
22  }
23  void UpdateMin(T val) { this->first = std::min(this->first , val); }
24  void UpdateMax(T val) { this->second = std::max(this->second, val); }
25  void Update(const Limits<T>& other){
26  UpdateMin(other.Min());
27  UpdateMax(other.Max());
28  }
29  };
30 
31  } // end of namespace supernova
32 } // end of namespace genie
33 #endif
Limits(const T &v)
Definition: Limits.h:10
T max(const caf::Proxy< T > &a, T b)
void Set(double val1, double val2)
Definition: Limits.h:19
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
const T & Min() const
Definition: Limits.h:14
Limits(const T &v1, const T &v2)
Definition: Limits.h:11
void Update(const Limits< T > &other)
Definition: Limits.h:25
An ART module for generating supernova events via GENIE.
const T & Max() const
Definition: Limits.h:15
T Range() const
Definition: Limits.h:16
void UpdateMax(T val)
Definition: Limits.h:24
double T
Definition: Xdiff_gwt.C:5
void UpdateMin(T val)
Definition: Limits.h:23
T min(const caf::Proxy< T > &a, T b)