BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/TrkReco/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 : [email protected]
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
21 public:
22 /// Constructor
23 Range();
24
25 /// Copy constructor
26 Range(const Range &);
27
28 /// Constructor
29 Range(float low, float high);
30
31 public:// 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
44 public:// 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
57 public:// 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
79 public:// Common interfaces
80 /// displays debug information.
81 virtual int dump(void) const;
82
83 private:
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
102float
103Range::low(void) const {
104 return _low;
105}
106
107inline
108float
109Range::low(float i) {
110 if (i > _high) i = _high;
111 return _low = i;
112}
113
114inline
115float
116Range::high(void) const {
117 return _high;
118}
119
120inline
121float
122Range::high(float i) {
123 if (i < _low) i = _low;
124 return _high = i;
125}
126
127inline
128float
129Range::center(void) const {
130 return (_low + _high) / 2.;
131}
132
133inline
134float
135Range::width(void) const {
136 return (_high - _low);
137}
138
139inline
140Range &
141Range::set(float iLow, float iHigh) {
142 if (iHigh > iLow) {
143 _low = iLow;
144 _high = iHigh;
145 }
146 else {
147 _low = iHigh;
148 _high = iLow;
149 }
150 return * this;
151}
152
153inline
154Range &
155Range::setByCenter(float center, float width) {
156 _low = center - width;
157 _high = center + width;
158 return * this;
159}
160
161inline
162Range &
164 _low = ib.low();
165 _high = ib.high();
166 return * this;
167}
168
169inline
170bool
171Range::within(const float f) const{
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}
185
186inline
187bool
188Range::within2(const float f) const{
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}
202
203inline
204bool
205Range::operator != (const Range & a) const {
206 if ((* this) == a) return false;
207 return true;
208}
209
210inline
211bool
212Range::operator & (const Range & a) const {
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}
219
220inline
221bool
222Range::within(const Range & a) const {
223 if (within(a.low()) && within(a.high())) return true;
224 return false;
225}
226
227#endif
228
229#undef inline
230
231#endif /* Range_FLAG_ */
232
to specify 1-dim region or range by two floats
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.
bool within(const float value) const
returns true if given value is within a range.
Range()
Constructor.
Definition: Range.cxx:16
virtual Range & setByCenter(float center, float width)
sets range by center and width.
virtual int dump(void) const
displays debug information.
Definition: Range.cxx:45
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.
Definition: Range.cxx:38
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")