ATLAS Offline Software
VP1Interval.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Header file for class VP1Interval //
9 // //
10 // Description: Convenience class describing interval. //
11 // //
12 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
13 // Initial version: May 2008 //
14 // //
16 
17 #ifndef VP1INTERVAL_H
18 #define VP1INTERVAL_H
19 
20 #include <QString>
21 #include <limits>
22 
23 class VP1Interval {
24 public:
25  static double inf() { return std::numeric_limits<double>::infinity(); }
26 
27  VP1Interval(const double& lower,const double& upper, bool openLower=true, bool openUpper=true, bool excludeRange=false);
28  VP1Interval();//]0,0[
30 
31  //Set:
32  void setOpenLower(bool openLower);
33  void setOpenUpper(bool openUpper);
34  void setOpen(bool openLower,bool openUpper);
35  void setLower(const double& lower);
36  void setUpper(const double& upper);
37  void setExcludeInterval(bool excludeInterval); // TODO: so far used only by contains(double). If needed, extend it to other 'contains' methods.
38  void set(const double& lower,const double& upper, bool openLower=true, bool openUpper=true, bool excludeRange=false);
39  void translate(const double&);
40 
41  //Get:
42  double lower() const;
43  double upper() const;
44  double openLower() const;
45  double openUpper() const;
46  bool excludeInterval() const;
47  QString toString() const;
48  double length() const;
49 
50  //Query:
51  bool contains(const double& x) const;
52  bool contains(const VP1Interval& other) const;
53  bool hasOverlap(const VP1Interval& other) const;//If at least one point is in common.
54  // VP1Interval intersection(const VP1Interval& other) const;//mathematical intersection.
55 
56  //Periodic variables (e.g. angles with period=2pi):
57  bool contains(const double& x, const double& period ) const;
58  bool hasOverlap(const VP1Interval& other, const double& period ) const;
59 
60  bool isSane() const;
61  bool isEmpty() const;
62  bool isAllR() const;
63 
64  bool noLowerBound() const;
65  bool noUpperBound() const;
66  bool excludedByLower(const double&x) const;
67  bool excludedByUpper(const double&x) const;
68 
69  //Comparisons:
70  bool operator == ( const VP1Interval & other ) const;
71 
72  //Fixme: Add intersections with other intervals, and comparison operators!
73  //Fixme: also add stuff for angular intervals (i.e. those periodic in 2pi)
74 
75 private:
76 
77  void testSanity() const;
78 
79  double m_lower;
80  double m_upper;
84 
85 };
86 
87 #include "VP1Base/VP1Interval.icc"
88 
89 #endif
python.AtlRunQueryAMI.period
period
Definition: AtlRunQueryAMI.py:225
VP1Interval::isSane
bool isSane() const
VP1Interval::VP1Interval
VP1Interval()
VP1Interval::setExcludeInterval
void setExcludeInterval(bool excludeInterval)
VP1Interval::length
double length() const
VP1Interval.icc
VP1Interval::upper
double upper() const
VP1Interval::operator==
bool operator==(const VP1Interval &other) const
VP1Interval::~VP1Interval
~VP1Interval()
Definition: VP1Interval.h:29
x
#define x
VP1Interval::excludeInterval
bool excludeInterval() const
VP1Interval::setOpenLower
void setOpenLower(bool openLower)
VP1Interval::m_lower
double m_lower
Definition: VP1Interval.h:79
VP1Interval::m_upper
double m_upper
Definition: VP1Interval.h:80
VP1Interval::lower
double lower() const
VP1Interval::excludedByUpper
bool excludedByUpper(const double &x) const
VP1Interval::m_excludeInterval
bool m_excludeInterval
Definition: VP1Interval.h:83
VP1Interval::inf
static double inf()
Definition: VP1Interval.h:25
VP1Interval::m_openUpper
bool m_openUpper
Definition: VP1Interval.h:82
VP1Interval::m_openLower
bool m_openLower
Definition: VP1Interval.h:81
VP1Interval::isEmpty
bool isEmpty() const
VP1Interval::contains
bool contains(const double &x) const
VP1Interval::openLower
double openLower() const
VP1Interval::toString
QString toString() const
VP1Interval::noUpperBound
bool noUpperBound() const
VP1Interval::setOpenUpper
void setOpenUpper(bool openUpper)
VP1Interval::testSanity
void testSanity() const
Definition: VP1Interval.cxx:38
VP1Interval::set
void set(const double &lower, const double &upper, bool openLower=true, bool openUpper=true, bool excludeRange=false)
Definition: VP1Interval.cxx:27
VP1Interval
Definition: VP1Interval.h:23
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
VP1Interval::setUpper
void setUpper(const double &upper)
VP1Interval::isAllR
bool isAllR() const
VP1Interval::translate
void translate(const double &)
VP1Interval::hasOverlap
bool hasOverlap(const VP1Interval &other) const
Definition: VP1Interval.cxx:45
VP1Interval::openUpper
double openUpper() const
VP1Interval::setOpen
void setOpen(bool openLower, bool openUpper)
VP1Interval::excludedByLower
bool excludedByLower(const double &x) const
VP1Interval::setLower
void setLower(const double &lower)
VP1Interval::noLowerBound
bool noLowerBound() const