ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Base
src
VP1Interval.cxx
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
// Implementation of class VP1Interval //
9
// //
10
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11
// Initial version: May 2008 //
12
// //
14
15
#include "
VP1Base/VP1Interval.h
"
16
#include "
VP1Base/VP1Msg.h
"
17
#include <cmath>
18
19
//____________________________________________________________________
20
VP1Interval::VP1Interval
(
const
double
&
lower
,
const
double
&
upper
,
bool
openLower
,
bool
openUpper
,
bool
excludeInterval
)
21
:
m_lower
(
lower
),
m_upper
(
upper
),
m_openLower
(
openLower
),
m_openUpper
(
openUpper
),
m_excludeInterval
(
excludeInterval
)
22
{
23
testSanity
();
24
}
25
26
//____________________________________________________________________
27
void
VP1Interval::set
(
const
double
&
lower
,
const
double
&
upper
,
bool
openLower
,
bool
openUpper
,
bool
excludeInterval
)
28
{
29
m_lower
=
lower
;
30
m_upper
=
upper
;
31
m_openLower
=
openLower
;
32
m_openUpper
=
openUpper
;
33
m_excludeInterval
=
excludeInterval
;
34
testSanity
();
35
}
36
37
//____________________________________________________________________
38
void
VP1Interval::testSanity
()
const
39
{
40
if
(!
isSane
())
41
VP1Msg::messageDebug
(
"WARNING: VP1Interval is not sane: "
+
toString
());
42
}
43
44
//____________________________________________________________________
45
bool
VP1Interval::hasOverlap
(
const
VP1Interval
& other)
const
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
}
59
60
//____________________________________________________________________
61
bool
VP1Interval::contains
(
const
VP1Interval
& other)
const
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
}
77
78
79
/*bool VP1Interval::contains(const double& x) const
80
{
81
VP1Msg::messageDebug("m_excludeInterval: "+QString::number(m_excludeInterval));
82
if (m_excludeInterval) {
83
return ! (!excludedByLower(x) && !excludedByUpper(x));
84
}
85
return !excludedByLower(x) && !excludedByUpper(x);
86
}
87
*/
88
89
//____________________________________________________________________
90
bool
VP1Interval::contains
(
const
double
&
x
,
const
double
& period )
const
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
}
105
106
107
//____________________________________________________________________
108
bool
VP1Interval::hasOverlap
(
const
VP1Interval
& other,
const
double
& period )
const
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
}
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
x
#define x
VP1Interval.h
VP1Msg.h
VP1Interval::m_upper
double m_upper
Definition
VP1Interval.h:80
VP1Interval::lower
double lower() const
VP1Interval::isEmpty
bool isEmpty() const
VP1Interval::toString
QString toString() const
VP1Interval::isSane
bool isSane() const
VP1Interval::isAllR
bool isAllR() const
VP1Interval::excludeInterval
bool excludeInterval() const
VP1Interval::contains
bool contains(const double &x) const
VP1Interval::VP1Interval
VP1Interval()
VP1Interval::noUpperBound
bool noUpperBound() const
VP1Interval::upper
double upper() const
VP1Interval::m_openLower
bool m_openLower
Definition
VP1Interval.h:81
VP1Interval::VP1Interval
VP1Interval(const double &lower, const double &upper, bool openLower=true, bool openUpper=true, bool excludeRange=false)
Definition
VP1Interval.cxx:20
VP1Interval::hasOverlap
bool hasOverlap(const VP1Interval &other) const
Definition
VP1Interval.cxx:45
VP1Interval::testSanity
void testSanity() const
Definition
VP1Interval.cxx:38
VP1Interval::m_excludeInterval
bool m_excludeInterval
Definition
VP1Interval.h:83
VP1Interval::openLower
double openLower() const
VP1Interval::m_openUpper
bool m_openUpper
Definition
VP1Interval.h:82
VP1Interval::openUpper
double openUpper() const
VP1Interval::m_lower
double m_lower
Definition
VP1Interval.h:79
VP1Interval::length
double length() const
VP1Interval::noLowerBound
bool noLowerBound() const
VP1Interval::set
void set(const double &lower, const double &upper, bool openLower=true, bool openUpper=true, bool excludeRange=false)
Definition
VP1Interval.cxx:27
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition
VP1Msg.cxx:39
Generated on
for ATLAS Offline Software by
1.17.0