Diana Software
QIntervalSet.hh
Go to the documentation of this file.
1 
9 #ifndef _Q_INTERVAL_SET_HH_
10 #define _Q_INTERVAL_SET_HH_
11 
12 #include <list>
13 #include "QMatrix.hh"
14 #include "QInterval.hh"
15 #include "QObject.hh"
16 
18 
19 class QIntervalSet : public QObject {
20  public:
22  QIntervalSet();
23 
25  QIntervalSet(const double min, const double max);
26 
28  void Clear();
29 
31  virtual ~QIntervalSet() {};
32 
34  void CloseGapsSmallerThan(const double smallestAllowedGap);
35 
38  bool Consolidate();
39 
41  bool Contains(const double value) const;
42 
44  const std::list<QInterval>& GetIntervals() const {return fIntervals;}
45 
48 
50  double GetMax() const
51  {return !fIntervals.empty() ? fIntervals.back().GetMax() : 0;}
52 
54  double GetMin() const
55  {return !fIntervals.empty() ? fIntervals.front().GetMin() : 0;}
56 
58  void Insert(const double min, const double max)
59  {QInterval interval(min, max); Insert(interval);}
60 
62  void Insert(QInterval interval);
63 
65  double Length() const;
66 
68  void RemoveIntervalsShorterThan(const double minimumLength);
69 
71  void SetLowerBound(const double lowerBound);
72 
74  void SetUpperBound(const double upperBound);
75 
77  size_t Size() const {return fIntervals.size();}
78 
80  void Dump(std::ostream &o) const;
81 
82  protected:
84  std::list<QInterval> fIntervals;
85 
88 
91 
93  double fLowerBound;
94 
96  double fUpperBound;
97 
99 };
100 
102 
103 #endif
double max
Definition: CheckOF.C:53
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
double min(const Diana::QVector &v)
Definition: QVector.cc:878
Collection of disjoint intervals of real numbers.
Definition: QIntervalSet.hh:19
void RemoveIntervalsShorterThan(const double minimumLength)
Remove intervals shorter than minimumLength.
const std::list< QInterval > & GetIntervals() const
Get the list storing the intervals.
Definition: QIntervalSet.hh:44
std::list< QInterval > fIntervals
Intervals in the set.
Definition: QIntervalSet.hh:84
double Length() const
Get total length of all intervals in the set.
virtual ~QIntervalSet()
Destructor.
Definition: QIntervalSet.hh:31
void CloseGapsSmallerThan(const double smallestAllowedGap)
Close gaps smaller than smallestAllowedGap.
Definition: QIntervalSet.cc:31
void Dump(std::ostream &o) const
Dump the intervals to a stream.
void SetLowerBound(const double lowerBound)
Set lower bound on the contents of the set.
QIntervalSet()
Default constructor.
Definition: QIntervalSet.cc:10
QMatrix GetMatrix()
Get matrix containing the intervals.
double fUpperBound
Upper bound on the contents of the set.
Definition: QIntervalSet.hh:96
double GetMax() const
Get maximum of all intervals in the set.
Definition: QIntervalSet.hh:50
size_t Size() const
Get number of intervals in the set.
Definition: QIntervalSet.hh:77
void Insert(const double min, const double max)
Add interval to the set.
Definition: QIntervalSet.hh:58
void Clear()
Clear()
Definition: QIntervalSet.cc:22
bool Contains(const double value) const
Return whether the interval set contains a value.
Definition: QIntervalSet.cc:98
double GetMin() const
Get minimum of all intervals in the set.
Definition: QIntervalSet.hh:54
void SetUpperBound(const double upperBound)
Set upper bound on the contents of the set.
bool Consolidate()
Consolidate overlapped intervals.
Definition: QIntervalSet.cc:69
bool fIsLowerBoundSet
Whether or not a lower bound is set.
Definition: QIntervalSet.hh:87
bool fIsUpperBoundSet
Whether or not an upper bound is set.
Definition: QIntervalSet.hh:90
double fLowerBound
Lower bound on the contents of the set.
Definition: QIntervalSet.hh:93
QObjectDef(QIntervalSet, 1)
Interval of real numbers.
Definition: QInterval.hh:17
Interface for matrices in Diana analysis.
Definition: QMatrix.hh:24
base class for objects handled by QEvent and QGlobalDataManager.
Definition: QObject.hh:76