ATLAS Offline Software
Loading...
Searching...
No Matches
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
24public:
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:
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
75private:
76
77 void testSanity() const;
78
79 double m_lower;
80 double m_upper;
84
85};
86
88
89#endif
int upper(int c)
#define x
double m_upper
Definition VP1Interval.h:80
double lower() const
bool excludedByUpper(const double &x) const
bool isEmpty() const
QString toString() const
bool isSane() const
void setOpenUpper(bool openUpper)
bool isAllR() const
void setExcludeInterval(bool excludeInterval)
bool excludeInterval() const
bool contains(const double &x) const
void setLower(const double &lower)
void setOpenLower(bool openLower)
static double inf()
Definition VP1Interval.h:25
bool noUpperBound() const
double upper() const
bool m_openLower
Definition VP1Interval.h:81
VP1Interval(const double &lower, const double &upper, bool openLower=true, bool openUpper=true, bool excludeRange=false)
bool hasOverlap(const VP1Interval &other) const
void testSanity() const
bool excludedByLower(const double &x) const
bool m_excludeInterval
Definition VP1Interval.h:83
double openLower() const
bool m_openUpper
Definition VP1Interval.h:82
double openUpper() const
void setOpen(bool openLower, bool openUpper)
double m_lower
Definition VP1Interval.h:79
double length() const
bool noLowerBound() const
void set(const double &lower, const double &upper, bool openLower=true, bool openUpper=true, bool excludeRange=false)
bool operator==(const VP1Interval &other) const
void setUpper(const double &upper)
void translate(const double &)