BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/TrkReco/include/TrkReco/Range.h
Go to the documentation of this file.
1//-----------------------------------------------------------fmt version 0.00--
2// $Id: Range.h,v 1.2 2005/09/09 07:47:07 zangsl Exp $
3//-----------------------------------------------------------------------------
4// Header file for Multi-TDC data
5//-----------------------------------------------------------------------------
6// Filename : MultiTDC.h
7// Section : CDC TSF
8// Owner : Yoshi Iwasaki
9// Email : yiwaskai@kekvax.kek.jp
10//-----------------------------------------------------------------------------
11
12#ifndef Range_FLAG_
13#define Range_FLAG_
14
15//
16//...To define band width...
17//
18/// to specify 1-dim region or range by two floats
19class Range {
20
21public:
22 /// Constructor
24
25 /// Copy constructor
26 Range( const Range& );
27
28 /// Constructor
29 Range( float low, float high );
30
31public: // Selectors
32 /// returns lower limit.
33 virtual float low( void ) const;
34
35 /// returns higher limit.
36 virtual float high( void ) const;
37
38 /// returns center.
39 virtual float center( void ) const;
40
41 /// returns width.
42 virtual float width( void ) const;
43
44public: // Modifiers
45 /// sets lower limit.
46 virtual float low( float lowIn );
47
48 /// sets higher limit.
49 virtual float high( float highIn );
50
51 /// sets range.
52 virtual Range& set( float low, float high );
53
54 /// sets range by center and width.
55 virtual Range& setByCenter( float center, float width );
56
57public: // Operators
58 /// Copy operator
59 Range& operator=( const Range& );
60
61 /// returns true if range is the same.
62 bool operator==( const Range& ) const;
63
64 /// returns true if range is different.
65 bool operator!=( const Range& ) const;
66
67 /// returns true if two are overlaped each other.
68 bool operator&( const Range& ) const;
69
70 /// returns true if given value is within a range.
71 bool within( const float value ) const;
72
73 /// returns true if given value is within a range.
74 bool within2( const float value ) const;
75
76 /// returns true if given Range is within(included in) a range.
77 bool within( const Range& ) const;
78
79public: // Common interfaces
80 /// displays debug information.
81 virtual int dump( void ) const;
82
83private:
84 /// Lower limit
85 float _low;
86 /// Higher limit
87 float _high;
88};
89
90//-----------------------------------------------------------------------------
91
92#ifdef TANA_NO_INLINE
93# define inline
94#else
95# undef inline
96# define Range_INLINE_DEFINE_HERE
97#endif
98
99#ifdef Range_INLINE_DEFINE_HERE
100
101inline float Range::low( void ) const { return _low; }
102
103inline float Range::low( float i ) {
104 if ( i > _high ) i = _high;
105 return _low = i;
106}
107
108inline float Range::high( void ) const { return _high; }
109
110inline float Range::high( float i ) {
111 if ( i < _low ) i = _low;
112 return _high = i;
113}
114
115inline float Range::center( void ) const { return ( _low + _high ) / 2.; }
116
117inline float Range::width( void ) const { return ( _high - _low ); }
118
119inline Range& Range::set( float iLow, float iHigh ) {
120 if ( iHigh > iLow )
121 {
122 _low = iLow;
123 _high = iHigh;
124 }
125 else
126 {
127 _low = iHigh;
128 _high = iLow;
129 }
130 return *this;
131}
132
133inline Range& Range::setByCenter( float center, float width ) {
134 _low = center - width;
135 _high = center + width;
136 return *this;
137}
138
139inline Range& Range::operator=( const Range& ib ) {
140 _low = ib.low();
141 _high = ib.high();
142 return *this;
143}
144
145inline bool Range::within( const float f ) const {
146 if ( _low == -999. && _high == -999. ) { return false; }
147 if ( _low == -999. )
148 {
149 if ( f <= _high ) return true;
150 return false;
151 }
152 if ( _high == -999. )
153 {
154 if ( f >= _low ) return true;
155 }
156 if ( f >= _low && f <= _high ) return true;
157 return false;
158}
159
160inline bool Range::within2( const float f ) const {
161 if ( _low == -999. && _high == -999. ) { return true; }
162 if ( _low == -999. )
163 {
164 if ( f <= _high ) return true;
165 return false;
166 }
167 if ( _high == -999. )
168 {
169 if ( f >= _low ) return true;
170 }
171 if ( f >= _low && f <= _high ) return true;
172 return false;
173}
174
175inline bool Range::operator!=( const Range& a ) const {
176 if ( ( *this ) == a ) return false;
177 return true;
178}
179
180inline bool Range::operator&( const Range& a ) const {
181 if ( within( a.low() ) ) return true;
182 if ( within( a.high() ) ) return true;
183 if ( a.within( low() ) ) return true;
184 if ( a.within( high() ) ) return true;
185 return false;
186}
187
188inline bool Range::within( const Range& a ) const {
189 if ( within( a.low() ) && within( a.high() ) ) return true;
190 return false;
191}
192
193#endif
194
195#undef inline
196
197#endif /* Range_FLAG_ */
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
to specify 1-dim region or range by two floats
virtual int dump(void) const
displays debug information.
Range(float low, float high)
Constructor.
virtual float low(void) const
returns lower limit.
virtual float high(void) const
returns higher limit.
virtual Range & set(float low, float high)
sets range.
virtual float width(void) const
returns width.
bool operator!=(const Range &) const
returns true if range is different.
virtual float low(void) const
returns lower limit.
virtual float center(void) const
returns center.
virtual Range & set(float low, float high)
sets range.
Range(const Range &)
Copy constructor.
bool within(const float value) const
returns true if given value is within a range.
virtual float width(void) const
returns width.
virtual float high(void) const
returns higher limit.
virtual Range & setByCenter(float center, float width)
sets range by center and width.
virtual float center(void) const
returns center.
Range()
Constructor.
bool within(const Range &) const
returns true if given Range is within(included in) a range.
virtual Range & setByCenter(float center, float width)
sets range by center and width.
virtual float low(float lowIn)
sets lower limit.
Range & operator=(const Range &)
Copy operator.
bool operator&(const Range &) const
returns true if two are overlaped each other.
bool within2(const float value) const
returns true if given value is within a range.
bool operator==(const Range &) const
returns true if range is the same.
virtual float high(float highIn)
sets higher limit.