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:

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 Types

typedef boost::numeric::interval< double > interval_t

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 boost interval wrapped by a boost 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 uses the Boost class interval but maybe one could use a SEAL class (FML/RangeSet or FML/Bound)

Definition at line 34 of file FilterRange.h.

Member Typedef Documentation

◆ interval_t

typedef boost::numeric::interval<double> FilterRange::interval_t
protected

Definition at line 142 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 170 of file FilterRange.h.

170 :
171 m_range(std::nullopt),
172 m_precision(1e-6)
173{}
double m_precision
Setup the wanted double precision.
std::optional< interval_t > m_range
The boost interval wrapped by a boost optional.

◆ FilterRange() [2/3]

FilterRange::FilterRange ( const FilterRange & range)

Copy constructor:

Public methods:

Copy constructor

Definition at line 26 of file FilterRange.cxx.

26 :
27 m_range( range.m_range ),
28 m_precision( range.m_precision )
29{}

◆ 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 175 of file FilterRange.h.

175 :
177 m_precision(1e-6)
178{
179 if ( min == MINUS_INF() && max == PLUS_INF() ) {
180 //std::cout << ">>> You are giving a NO-OP interval : ]"
181 // << min << "; "
182 // << max << "["
183 // << std::endl
184 // << ">>> De-activating this range for optimization purpose."
185 // << std::endl;
186 m_range = std::nullopt;
187 if ( isActive() ) {
188 std::string error = "ERROR : FilterRange is ACTIVE (Should NOT BE !!)";
189 std::cerr << error << std::endl;
190 throw error;
191 }
192 } else {
193 // Do nothing : everything is allright
194 }
195}
#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...
boost::numeric::interval< double > interval_t
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 199 of file FilterRange.h.

199{}

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 84 of file FilterRange.cxx.

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

◆ getMax()

double FilterRange::getMax ( ) const
inline

Return the maximum value of the range.

Definition at line 232 of file FilterRange.h.

233{
234 return upper();
235}
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 227 of file FilterRange.h.

228{
229 return lower();
230}
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 68 of file FilterRange.cxx.

69{
72 addRange(xMin,xMax);
73}
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 75 of file FilterRange.cxx.

76{
77 m_range = std::nullopt;
78 return;
79}

◆ 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 247 of file FilterRange.h.

248{
249 if ( m_range ) return true;
250 return false;
251}

◆ 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 45 of file FilterRange.cxx.

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

◆ lower()

double FilterRange::lower ( ) const
inline

Return the minimum value of the range.

Definition at line 209 of file FilterRange.h.

210{
211 if ( m_range ) {
212 return m_range->lower();
213 }
214
215 return MINUS_INF();
216}

◆ MINUS_INF()

double FilterRange::MINUS_INF ( ) const
inline

Define -infinity according to specific implementation.

Definition at line 242 of file FilterRange.h.

243{
244 return -FLT_MAX;
245}

◆ operator=()

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

Assignment operator:

Assignment operator.

Definition at line 32 of file FilterRange.cxx.

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

◆ PLUS_INF()

double FilterRange::PLUS_INF ( ) const
inline

Define +infinity according to specific implementation.

Definition at line 237 of file FilterRange.h.

238{
239 return FLT_MAX;
240}

◆ precision()

double FilterRange::precision ( ) const
inline

Return the double precision for the comparaison of doubles.

Definition at line 204 of file FilterRange.h.

205{
206 return m_precision;
207}

◆ setMax()

void FilterRange::setMax ( const double maxValue)
inline

Definition at line 266 of file FilterRange.h.

267{
268 return setRange( getMin(), maxValue );
269}
#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 261 of file FilterRange.h.

262{
263 return setRange( minValue, getMax() );
264}
#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 256 of file FilterRange.h.

257{
258 m_precision = delta;
259}

◆ 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 56 of file FilterRange.cxx.

57{
59 if ( lower == MINUS_INF() && upper == PLUS_INF() ) {
60 m_range = std::nullopt;
61 return;
62 }
63
66}

◆ upper()

double FilterRange::upper ( ) const
inline

Return the maximum value of the range.

Definition at line 218 of file FilterRange.h.

219{
220 if ( m_range ) {
221 return m_range->upper();
222 }
223
224 return PLUS_INF();
225}

Member Data Documentation

◆ m_precision

double FilterRange::m_precision
protected

Setup the wanted double precision.

Default = 1e-6

Definition at line 151 of file FilterRange.h.

◆ m_range

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

The boost interval wrapped by a boost optional.

This is to allow the instantiation of uninitialised ranges

Definition at line 147 of file FilterRange.h.


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