BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
Range Class Reference

to specify 1-dim region or range by two floats More...

#include <Range.h>

Public Member Functions

 Range ()
 Constructor.
 
 Range (const Range &)
 Copy constructor.
 
 Range (float low, float high)
 Constructor.
 
virtual float low (void) const
 returns lower limit.
 
virtual float high (void) const
 returns higher limit.
 
virtual float center (void) const
 returns center.
 
virtual float width (void) const
 returns width.
 
virtual float low (float lowIn)
 sets lower limit.
 
virtual float high (float highIn)
 sets higher limit.
 
virtual Rangeset (float low, float high)
 sets range.
 
virtual RangesetByCenter (float center, float width)
 sets range by center and width.
 
Rangeoperator= (const Range &)
 Copy operator.
 
bool operator== (const Range &) const
 returns true if range is the same.
 
bool operator!= (const Range &) const
 returns true if range is different.
 
bool operator& (const Range &) const
 returns true if two are overlaped each other.
 
bool within (const float value) const
 returns true if given value is within a range.
 
bool within2 (const float value) const
 returns true if given value is within a range.
 
bool within (const Range &) const
 returns true if given Range is within(included in) a range.
 
virtual int dump (void) const
 displays debug information.
 

Detailed Description

to specify 1-dim region or range by two floats

Definition at line 19 of file Range.h.

Constructor & Destructor Documentation

◆ Range() [1/3]

Range::Range ( )

Constructor.

Definition at line 16 of file Range.cxx.

16 {
17 _low = -999.;
18 _high = -999.;
19}

◆ Range() [2/3]

Range::Range ( const Range & ib)

Copy constructor.

Definition at line 21 of file Range.cxx.

21 {
22 _low = ib.low();
23 _high = ib.high();
24}
virtual float high(void) const
returns higher limit.
Definition Range.h:116
virtual float low(void) const
returns lower limit.
Definition Range.h:103

◆ Range() [3/3]

Range::Range ( float low,
float high )

Constructor.

Definition at line 26 of file Range.cxx.

26 {
27 if (iHigh > iLow) {
28 _low = iLow;
29 _high = iHigh;
30 }
31 else {
32 _low = iHigh;
33 _high = iLow;
34 }
35}

Member Function Documentation

◆ center()

float Range::center ( void ) const
inlinevirtual

returns center.

Definition at line 129 of file Range.h.

129 {
130 return (_low + _high) / 2.;
131}

Referenced by setByCenter().

◆ dump()

int Range::dump ( void ) const
virtual

displays debug information.

Definition at line 45 of file Range.cxx.

45 {
46 std::cout << _low << "~" << _high;
47 return 0;
48}

◆ high() [1/2]

float Range::high ( float highIn)
inlinevirtual

sets higher limit.

Definition at line 122 of file Range.h.

122 {
123 if (i < _low) i = _low;
124 return _high = i;
125}

◆ high() [2/2]

float Range::high ( void ) const
inlinevirtual

returns higher limit.

Definition at line 116 of file Range.h.

116 {
117 return _high;
118}

Referenced by operator&(), operator=(), operator==(), Range(), and within().

◆ low() [1/2]

float Range::low ( float lowIn)
inlinevirtual

sets lower limit.

Definition at line 109 of file Range.h.

109 {
110 if (i > _high) i = _high;
111 return _low = i;
112}

◆ low() [2/2]

float Range::low ( void ) const
inlinevirtual

returns lower limit.

Definition at line 103 of file Range.h.

103 {
104 return _low;
105}

Referenced by operator&(), operator=(), operator==(), Range(), and within().

◆ operator!=()

bool Range::operator!= ( const Range & a) const
inline

returns true if range is different.

Definition at line 205 of file Range.h.

205 {
206 if ((* this) == a) return false;
207 return true;
208}

◆ operator&()

bool Range::operator& ( const Range & a) const
inline

returns true if two are overlaped each other.

Definition at line 212 of file Range.h.

212 {
213 if (within(a.low())) return true;
214 if (within(a.high())) return true;
215 if (a.within(low())) return true;
216 if (a.within(high())) return true;
217 return false;
218}
bool within(const float value) const
returns true if given value is within a range.
Definition Range.h:171

◆ operator=()

Range & Range::operator= ( const Range & ib)
inline

Copy operator.

Definition at line 163 of file Range.h.

163 {
164 _low = ib.low();
165 _high = ib.high();
166 return * this;
167}

◆ operator==()

bool Range::operator== ( const Range & a) const

returns true if range is the same.

Definition at line 38 of file Range.cxx.

38 {
39 if (_low != a.low()) return false;
40 if (_high != a.high()) return false;
41 return true;
42}

◆ set()

Range & Range::set ( float low,
float high )
inlinevirtual

sets range.

Definition at line 141 of file Range.h.

141 {
142 if (iHigh > iLow) {
143 _low = iLow;
144 _high = iHigh;
145 }
146 else {
147 _low = iHigh;
148 _high = iLow;
149 }
150 return * this;
151}

◆ setByCenter()

Range & Range::setByCenter ( float center,
float width )
inlinevirtual

sets range by center and width.

Definition at line 155 of file Range.h.

155 {
156 _low = center - width;
157 _high = center + width;
158 return * this;
159}
virtual float width(void) const
returns width.
Definition Range.h:135
virtual float center(void) const
returns center.
Definition Range.h:129

◆ width()

float Range::width ( void ) const
inlinevirtual

returns width.

Definition at line 135 of file Range.h.

135 {
136 return (_high - _low);
137}

Referenced by setByCenter().

◆ within() [1/2]

bool Range::within ( const float value) const
inline

returns true if given value is within a range.

Definition at line 171 of file Range.h.

171 {
172 if (_low == -999. && _high == -999.) {
173 return false;
174 }
175 if (_low == -999.) {
176 if (f <= _high) return true;
177 return false;
178 }
179 if (_high == -999.) {
180 if (f >= _low) return true;
181 }
182 if (f >= _low && f <= _high) return true;
183 return false;
184}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")

Referenced by operator&(), and within().

◆ within() [2/2]

bool Range::within ( const Range & a) const
inline

returns true if given Range is within(included in) a range.

Definition at line 222 of file Range.h.

222 {
223 if (within(a.low()) && within(a.high())) return true;
224 return false;
225}

◆ within2()

bool Range::within2 ( const float value) const
inline

returns true if given value is within a range.

Definition at line 188 of file Range.h.

188 {
189 if (_low == -999. && _high == -999.) {
190 return true;
191 }
192 if (_low == -999.) {
193 if (f <= _high) return true;
194 return false;
195 }
196 if (_high == -999.) {
197 if (f >= _low) return true;
198 }
199 if (f >= _low && f <= _high) return true;
200 return false;
201}

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