ATLAS Offline Software
Loading...
Searching...
No Matches
VP1Interval Class Reference

#include <VP1Interval.h>

Collaboration diagram for VP1Interval:

Public Member Functions

 VP1Interval (const double &lower, const double &upper, bool openLower=true, bool openUpper=true, bool excludeRange=false)
 VP1Interval ()
 ~VP1Interval ()
void setOpenLower (bool openLower)
void setOpenUpper (bool openUpper)
void setOpen (bool openLower, bool openUpper)
void setLower (const double &lower)
void setUpper (const double &upper)
void setExcludeInterval (bool excludeInterval)
void set (const double &lower, const double &upper, bool openLower=true, bool openUpper=true, bool excludeRange=false)
void translate (const double &)
double lower () const
double upper () const
double openLower () const
double openUpper () const
bool excludeInterval () const
QString toString () const
double length () const
bool contains (const double &x) const
bool contains (const VP1Interval &other) const
bool hasOverlap (const VP1Interval &other) const
bool contains (const double &x, const double &period) const
bool hasOverlap (const VP1Interval &other, const double &period) const
bool isSane () const
bool isEmpty () const
bool isAllR () const
bool noLowerBound () const
bool noUpperBound () const
bool excludedByLower (const double &x) const
bool excludedByUpper (const double &x) const
bool operator== (const VP1Interval &other) const

Static Public Member Functions

static double inf ()

Private Member Functions

void testSanity () const

Private Attributes

double m_lower
double m_upper
bool m_openLower
bool m_openUpper
bool m_excludeInterval

Detailed Description

Definition at line 23 of file VP1Interval.h.

Constructor & Destructor Documentation

◆ VP1Interval() [1/2]

VP1Interval::VP1Interval ( const double & lower,
const double & upper,
bool openLower = true,
bool openUpper = true,
bool excludeRange = false )

Definition at line 20 of file VP1Interval.cxx.

22{
23 testSanity();
24}
double m_upper
Definition VP1Interval.h:80
double lower() const
bool excludeInterval() const
double upper() const
bool m_openLower
Definition VP1Interval.h:81
void testSanity() const
bool m_excludeInterval
Definition VP1Interval.h:83
double openLower() const
bool m_openUpper
Definition VP1Interval.h:82
double openUpper() const
double m_lower
Definition VP1Interval.h:79

◆ VP1Interval() [2/2]

VP1Interval::VP1Interval ( )

◆ ~VP1Interval()

VP1Interval::~VP1Interval ( )
inline

Definition at line 29 of file VP1Interval.h.

29{};

Member Function Documentation

◆ contains() [1/3]

bool VP1Interval::contains ( const double & x) const

◆ contains() [2/3]

bool VP1Interval::contains ( const double & x,
const double & period ) const

Definition at line 90 of file VP1Interval.cxx.

91{
92 if (isEmpty())
93 return false;
94
95 if (period<=0)
96 return period==0;
97
98 if (length()>=period)
99 return true;
100
101 //Translate x a number of periods, so that x is in
102 //[lower,lower+period[, and compare:
103 return contains(x+period*ceil((m_lower-x)/period));
104}
#define x
bool isEmpty() const
bool contains(const double &x) const
double length() const

◆ contains() [3/3]

bool VP1Interval::contains ( const VP1Interval & other) const

Definition at line 61 of file VP1Interval.cxx.

62{
63 if (!noLowerBound()) {
64 if (other.m_lower<m_lower)
65 return false;
66 if (other.m_lower==m_lower&&!other.m_openLower&&m_openLower)
67 return false;
68 }
69 if (!noUpperBound()) {
70 if (other.m_upper>m_upper)
71 return false;
72 if (other.m_upper==m_upper&&!other.m_openUpper&&m_openUpper)
73 return false;
74 }
75 return true;
76}
bool noUpperBound() const
bool noLowerBound() const

◆ excludedByLower()

bool VP1Interval::excludedByLower ( const double & x) const

◆ excludedByUpper()

bool VP1Interval::excludedByUpper ( const double & x) const

◆ excludeInterval()

bool VP1Interval::excludeInterval ( ) const

◆ hasOverlap() [1/2]

bool VP1Interval::hasOverlap ( const VP1Interval & other) const

Definition at line 45 of file VP1Interval.cxx.

46{
47 if (isEmpty()||other.isEmpty())
48 return false;
49 if (isAllR()||other.isAllR())
50 return true;
51 if (m_upper<other.m_lower||other.m_upper<m_lower)
52 return false;
53 if (m_upper==other.m_lower)
54 return !other.openLower() && !openUpper();
55 if (other.m_upper==m_lower)
56 return !openLower() && !other.openUpper();
57 return true;
58}
bool isAllR() const

◆ hasOverlap() [2/2]

bool VP1Interval::hasOverlap ( const VP1Interval & other,
const double & period ) const

Definition at line 108 of file VP1Interval.cxx.

109{
110 if (isEmpty()||other.isEmpty())
111 return false;
112 if (period<=0)
113 return period==0;
114 if (length()>=period||other.length()>=period)
115 return true;
116 //Translate the other interval so that it's lower value is in
117 //[lower,lower+period[, and then compare (both the interval and the
118 //interval translated -period are necessary):
119 const double t(period*ceil((m_lower-other.m_lower)/period));
120 const double a(other.m_lower+t), b(other.m_upper+t);
121 if (hasOverlap(VP1Interval(a,b,other.m_openLower,other.m_openUpper)))
122 return true;
123 return hasOverlap(VP1Interval(a-period,b-period,other.m_openLower,other.m_openUpper));
124}
static Double_t a
bool hasOverlap(const VP1Interval &other) const

◆ inf()

double VP1Interval::inf ( )
inlinestatic

Definition at line 25 of file VP1Interval.h.

25{ return std::numeric_limits<double>::infinity(); }

◆ isAllR()

bool VP1Interval::isAllR ( ) const

◆ isEmpty()

bool VP1Interval::isEmpty ( ) const

◆ isSane()

bool VP1Interval::isSane ( ) const

◆ length()

double VP1Interval::length ( ) const

◆ lower()

double VP1Interval::lower ( ) const

◆ noLowerBound()

bool VP1Interval::noLowerBound ( ) const

◆ noUpperBound()

bool VP1Interval::noUpperBound ( ) const

◆ openLower()

double VP1Interval::openLower ( ) const

◆ openUpper()

double VP1Interval::openUpper ( ) const

◆ operator==()

bool VP1Interval::operator== ( const VP1Interval & other) const

◆ set()

void VP1Interval::set ( const double & lower,
const double & upper,
bool openLower = true,
bool openUpper = true,
bool excludeRange = false )

Definition at line 27 of file VP1Interval.cxx.

◆ setExcludeInterval()

void VP1Interval::setExcludeInterval ( bool excludeInterval)

◆ setLower()

void VP1Interval::setLower ( const double & lower)

◆ setOpen()

void VP1Interval::setOpen ( bool openLower,
bool openUpper )

◆ setOpenLower()

void VP1Interval::setOpenLower ( bool openLower)

◆ setOpenUpper()

void VP1Interval::setOpenUpper ( bool openUpper)

◆ setUpper()

void VP1Interval::setUpper ( const double & upper)

◆ testSanity()

void VP1Interval::testSanity ( ) const
private

Definition at line 38 of file VP1Interval.cxx.

39{
40 if (!isSane())
41 VP1Msg::messageDebug("WARNING: VP1Interval is not sane: "+toString());
42}
QString toString() const
bool isSane() const
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39

◆ toString()

QString VP1Interval::toString ( ) const

◆ translate()

void VP1Interval::translate ( const double & )

◆ upper()

double VP1Interval::upper ( ) const

Member Data Documentation

◆ m_excludeInterval

bool VP1Interval::m_excludeInterval
private

Definition at line 83 of file VP1Interval.h.

◆ m_lower

double VP1Interval::m_lower
private

Definition at line 79 of file VP1Interval.h.

◆ m_openLower

bool VP1Interval::m_openLower
private

Definition at line 81 of file VP1Interval.h.

◆ m_openUpper

bool VP1Interval::m_openUpper
private

Definition at line 82 of file VP1Interval.h.

◆ m_upper

double VP1Interval::m_upper
private

Definition at line 80 of file VP1Interval.h.


The documentation for this class was generated from the following files: