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

FilterRange implements the range (ie: [min, max]) the filters will use to take their filtering decisions. More...

#include <FilterRange.h>

Inheritance diagram for FilterRange:
Collaboration diagram for FilterRange:

Classes

class  interval_t

Public Member Functions

 FilterRange ()
 Default constructor: it sets the minimum value to -infinity and the maximum value to +infinity.
 FilterRange (const FilterRange &range)
 Copy constructor:
 FilterRange (const double min, const double max)
 Constructor with parameters:
virtual ~FilterRange ()
 Destructor:
FilterRangeoperator= (const FilterRange &obj)
 Assignment operator:
double precision () const
 Return the double precision for the comparaison of doubles.
double lower () const
 Return the minimum value of the range.
double upper () const
 Return the maximum value of the range.
double getMin () const
 Return the minimum value of the range.
double getMax () const
 Return the maximum value of the range.
double PLUS_INF () const
 Define +infinity according to specific implementation.
double MINUS_INF () const
 Define -infinity according to specific implementation.
bool isInRange (const double point) const
 return Return true if the point is in range : min <= point <= max
bool isActive () const
 return Return true if the range is active (optimize parsing of multiple ranges and returning the final decision)
void setPrecision (const double delta)
void setRange (const double lower, const double upper)
 Non-const methods:
void setMin (const double minValue)
void setMax (const double maxValue)
void include (const double xMin, const double xMax)
 Add [xMin, xMax] interval to existing set of valid ranges.
void includeAll ()
 Set full range (from MINUS_INF to PLUS_INF ).

Protected Member Functions

void addRange (double xMin, double xMax)
 add a new range [xmin,xmax] deleting previous ranges full contained

Protected Attributes

std::optional< interval_tm_range
 The interval wrapped by a std::optional.
double m_precision
 Setup the wanted double precision.

Detailed Description

FilterRange implements the range (ie: [min, max]) the filters will use to take their filtering decisions.

Internally it stores just the lower and upper bounds.

Definition at line 22 of file FilterRange.h.

Constructor & Destructor Documentation

◆ FilterRange() [1/3]

FilterRange::FilterRange ( )
inline

Default constructor: it sets the minimum value to -infinity and the maximum value to +infinity.

Inline methods:

Constructors

Definition at line 166 of file FilterRange.h.

166 :
167 m_range(std::nullopt),
168 m_precision(1e-6)
169{}
double m_precision
Setup the wanted double precision.
std::optional< interval_t > m_range
The interval wrapped by a std::optional.

◆ FilterRange() [2/3]

FilterRange::FilterRange ( const FilterRange & range)

Copy constructor:

Public methods:

Copy constructor

Definition at line 23 of file FilterRange.cxx.

23 :
24 m_range( range.m_range ),
25 m_precision( range.m_precision )
26{}

◆ FilterRange() [3/3]

FilterRange::FilterRange ( const double min,
const double max )
inline

Constructor with parameters:

Parameters
min: the minimum value of the range
max: the maximum value of the range

Definition at line 171 of file FilterRange.h.

171 :
173 m_precision(1e-6)
174{
175 if ( min == MINUS_INF() && max == PLUS_INF() ) {
176 //std::cout << ">>> You are giving a NO-OP interval : ]"
177 // << min << "; "
178 // << max << "["
179 // << std::endl
180 // << ">>> De-activating this range for optimization purpose."
181 // << std::endl;
182 m_range = std::nullopt;
183 if ( isActive() ) {
184 std::string error = "ERROR : FilterRange is ACTIVE (Should NOT BE !!)";
185 std::cerr << error << std::endl;
186 throw error;
187 }
188 } else {
189 // Do nothing : everything is allright
190 }
191}
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
bool isActive() const
return Return true if the range is active (optimize parsing of multiple ranges and returning the fina...
double MINUS_INF() const
Define -infinity according to specific implementation.
double PLUS_INF() const
Define +infinity according to specific implementation.

◆ ~FilterRange()

FilterRange::~FilterRange ( )
inlinevirtual

Destructor:

Definition at line 195 of file FilterRange.h.

195{}

Member Function Documentation

◆ addRange()

void FilterRange::addRange ( double xMin,
double xMax )
protected

add a new range [xmin,xmax] deleting previous ranges full contained

Special case where one adds a no-op interval

Definition at line 81 of file FilterRange.cxx.

82{
84 if ( xMin == MINUS_INF() && xMax == PLUS_INF() ) {
85 m_range = std::nullopt;
86 return;
87 }
88
89 m_range = interval_t( xMin, xMax );
90}

◆ getMax()

double FilterRange::getMax ( ) const
inline

Return the maximum value of the range.

Definition at line 228 of file FilterRange.h.

229{
230 return upper();
231}
double upper() const
Return the maximum value of the range.

◆ getMin()

double FilterRange::getMin ( ) const
inline

Return the minimum value of the range.

Definition at line 223 of file FilterRange.h.

224{
225 return lower();
226}
double lower() const
Return the minimum value of the range.

◆ include()

void FilterRange::include ( const double xMin,
const double xMax )

Add [xMin, xMax] interval to existing set of valid ranges.

Parameters
xMin- lower bound of a new valid range
xMax- upper bound of a new valid range

Reset the whole range : this is temporary, just to mimic FML::RangeSet API

Definition at line 65 of file FilterRange.cxx.

66{
69 addRange(xMin,xMax);
70}
void addRange(double xMin, double xMax)
add a new range [xmin,xmax] deleting previous ranges full contained

◆ includeAll()

void FilterRange::includeAll ( )

Set full range (from MINUS_INF to PLUS_INF ).

Definition at line 72 of file FilterRange.cxx.

73{
74 m_range = std::nullopt;
75 return;
76}

◆ isActive()

bool FilterRange::isActive ( ) const
inline

return Return true if the range is active (optimize parsing of multiple ranges and returning the final decision)

Definition at line 243 of file FilterRange.h.

244{
245 if ( m_range ) return true;
246 return false;
247}

◆ isInRange()

bool FilterRange::isInRange ( const double point) const

return Return true if the point is in range : min <= point <= max

Const methods:

Definition at line 42 of file FilterRange.cxx.

43{
44 // check if point is in range
45 if ( ( ( lower() - point ) <= +m_precision ) &&
46 ( ( upper() - point ) >= -m_precision ) ) return true;
47 return false;
48}

◆ lower()

double FilterRange::lower ( ) const
inline

Return the minimum value of the range.

Definition at line 205 of file FilterRange.h.

206{
207 if ( m_range ) {
208 return m_range->lower();
209 }
210
211 return MINUS_INF();
212}

◆ MINUS_INF()

double FilterRange::MINUS_INF ( ) const
inline

Define -infinity according to specific implementation.

Definition at line 238 of file FilterRange.h.

239{
240 return -FLT_MAX;
241}

◆ operator=()

FilterRange & FilterRange::operator= ( const FilterRange & obj)

Assignment operator:

Assignment operator.

Definition at line 29 of file FilterRange.cxx.

30{
31 if ( this != &range ) {
32 m_range = interval_t( range.lower(), range.upper() );
33 m_precision = range.m_precision;
34 }
35
36 return *this;
37}

◆ PLUS_INF()

double FilterRange::PLUS_INF ( ) const
inline

Define +infinity according to specific implementation.

Definition at line 233 of file FilterRange.h.

234{
235 return FLT_MAX;
236}

◆ precision()

double FilterRange::precision ( ) const
inline

Return the double precision for the comparaison of doubles.

Definition at line 200 of file FilterRange.h.

201{
202 return m_precision;
203}

◆ setMax()

void FilterRange::setMax ( const double maxValue)
inline

Definition at line 262 of file FilterRange.h.

263{
264 return setRange( getMin(), maxValue );
265}
#define maxValue(current, test)
double getMin() const
Return the minimum value of the range.
void setRange(const double lower, const double upper)
Non-const methods:

◆ setMin()

void FilterRange::setMin ( const double minValue)
inline

Definition at line 257 of file FilterRange.h.

258{
259 return setRange( minValue, getMax() );
260}
#define minValue(current, test)
double getMax() const
Return the maximum value of the range.

◆ setPrecision()

void FilterRange::setPrecision ( const double delta)
inline

Definition at line 252 of file FilterRange.h.

253{
254 m_precision = delta;
255}

◆ setRange()

void FilterRange::setRange ( const double lower,
const double upper )

Non-const methods:

Special case where one adds a no-op interval

Now handle the normal cases

Definition at line 53 of file FilterRange.cxx.

54{
56 if ( lower == MINUS_INF() && upper == PLUS_INF() ) {
57 m_range = std::nullopt;
58 return;
59 }
60
63}

◆ upper()

double FilterRange::upper ( ) const
inline

Return the maximum value of the range.

Definition at line 214 of file FilterRange.h.

215{
216 if ( m_range ) {
217 return m_range->upper();
218 }
219
220 return PLUS_INF();
221}

Member Data Documentation

◆ m_precision

double FilterRange::m_precision
protected

Setup the wanted double precision.

Default = 1e-6

Definition at line 147 of file FilterRange.h.

◆ m_range

std::optional<interval_t> FilterRange::m_range
protected

The interval wrapped by a std::optional.

This is to allow the instantiation of uninitialised ranges

Definition at line 143 of file FilterRange.h.


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