ATLAS Offline Software
VP1Interval.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 ////////////////////////////////////////////////////////////////
7 // //
8 // Inline file for class VP1Interval //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: May 2008 //
12 // //
13 ////////////////////////////////////////////////////////////////
14 
15 inline VP1Interval::VP1Interval()
16  : m_lower(0), m_upper(0), m_openLower(true), m_openUpper(true), m_excludeInterval(false)
17 {
18 }
19 
20 inline void VP1Interval::setOpenLower(bool openLower)
21 {
22  m_openLower = openLower;
23 }
24 
25 inline void VP1Interval::setOpenUpper(bool openUpper)
26 {
27  m_openUpper = openUpper;
28 }
29 
30 inline void VP1Interval::setOpen(bool openLower,bool openUpper)
31 {
32  m_openLower = openLower;
33  m_openUpper = openUpper;
34 }
35 
36 inline void VP1Interval::setLower(const double& lower)
37 {
38  m_lower = lower;
39  testSanity();
40 }
41 
42 inline void VP1Interval::setUpper(const double& upper)
43 {
44  m_upper = upper;
45  testSanity();
46 }
47 
48 inline void VP1Interval::setExcludeInterval(bool excludeInterval)
49 {
50  m_excludeInterval = excludeInterval;
51 }
52 
53 inline void VP1Interval::translate(const double& t)
54 {
55  m_lower += t;
56  m_upper += t;
57  testSanity();
58 }
59 
60 inline double VP1Interval::lower() const
61 {
62  return m_lower;
63 }
64 
65 inline double VP1Interval::upper() const
66 {
67  return m_upper;
68 }
69 
70 inline double VP1Interval::openLower() const
71 {
72  return m_openLower;
73 }
74 
75 inline double VP1Interval::openUpper() const
76 {
77  return m_openUpper;
78 }
79 
80 inline bool VP1Interval::excludeInterval() const
81 {
82  return m_excludeInterval;
83 }
84 
85 inline bool VP1Interval::isEmpty() const
86 {
87  if (m_upper<m_lower)
88  return true;
89  if (m_lower<m_upper)
90  return false;
91  return m_openLower || m_openUpper;
92 }
93 
94 inline bool VP1Interval::noLowerBound() const
95 {
96  return m_lower==-inf();
97 }
98 
99 inline bool VP1Interval::noUpperBound() const
100 {
101  return m_upper==inf();
102 }
103 
104 inline bool VP1Interval::isAllR() const
105 {
106  return noLowerBound() && noUpperBound();
107 }
108 
109 inline bool VP1Interval::isSane() const
110 {
111  return m_lower==m_lower && m_upper==m_upper && m_lower<=m_upper;
112 }
113 
114 inline bool VP1Interval::excludedByLower(const double&x) const
115 {
116  return !noLowerBound() && (m_openLower? x <= m_lower : x < m_lower );
117 }
118 
119 inline bool VP1Interval::excludedByUpper(const double&x) const
120 {
121  return !noUpperBound() && (m_openUpper? x >= m_upper : x > m_upper );
122 }
123 
124 inline bool VP1Interval::contains(const double& x) const
125 {
126  // FIXME: m_excludeInterval is not used now, fix me!
127  //if (m_excludeInterval) {
128  // return ! (!excludedByLower(x) && !excludedByUpper(x));
129  //}
130  return !excludedByLower(x) && !excludedByUpper(x);
131 }
132 
133 
134 inline QString VP1Interval::toString() const
135 {
136  return (m_openLower||noLowerBound()?"]":"[")+QString::number(m_lower)+", "+QString::number(m_upper)+(m_openUpper||noUpperBound()?"[":"]");
137 }
138 
139 inline double VP1Interval::length() const { return m_upper-m_lower; }
140 
141 inline bool VP1Interval::operator==( const VP1Interval & other ) const
142 {
143  if (m_lower!=other.m_lower||m_upper!=other.m_upper)
144  return false;
145  return (m_openLower==other.m_openLower||noLowerBound()) && (m_openUpper==other.m_openUpper||noUpperBound());
146 }