/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/TrkReco/TrkReco-00-08-59-patch4-slc6tag/TrkReco/Range.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------fmt version 0.00--
00002 // $Id: Range.h,v 1.2 2005/09/09 07:47:07 zangsl Exp $
00003 //-----------------------------------------------------------------------------
00004 // Header file for Multi-TDC data
00005 //-----------------------------------------------------------------------------
00006 // Filename : MultiTDC.h
00007 // Section  : CDC TSF
00008 // Owner    : Yoshi Iwasaki
00009 // Email    : yiwaskai@kekvax.kek.jp
00010 //-----------------------------------------------------------------------------
00011 
00012 #ifndef Range_FLAG_
00013 #define Range_FLAG_
00014 
00015 //
00016 //...To define band width...
00017 //
00019 class Range {
00020 
00021   public:
00023     Range();
00024 
00026     Range(const Range &);
00027 
00029     Range(float low, float high);
00030 
00031   public:// Selectors
00033     virtual float low(void) const;
00034 
00036     virtual float high(void) const;
00037 
00039     virtual float center(void) const;
00040 
00042     virtual float width(void) const;
00043 
00044   public:// Modifiers
00046     virtual float low(float lowIn);
00047 
00049     virtual float high(float highIn);
00050 
00052     virtual Range & set(float low, float high);
00053 
00055     virtual Range & setByCenter(float center, float width);
00056 
00057   public:// Operators
00059     Range & operator = (const Range &);
00060 
00062     bool operator == (const Range &) const;
00063 
00065     bool operator != (const Range &) const;
00066 
00068     bool operator & (const Range &) const;
00069 
00071     bool within(const float value) const;
00072 
00074     bool within2(const float value) const;
00075 
00077     bool within(const Range &) const;
00078 
00079   public:// Common interfaces
00081     virtual int dump(void) const;
00082 
00083   private:
00085     float _low;
00087     float _high;
00088 };
00089 
00090 //-----------------------------------------------------------------------------
00091 
00092 #ifdef TANA_NO_INLINE
00093 #define inline
00094 #else
00095 #undef inline
00096 #define Range_INLINE_DEFINE_HERE
00097 #endif
00098 
00099 #ifdef Range_INLINE_DEFINE_HERE
00100 
00101 inline
00102 float
00103 Range::low(void) const {
00104     return _low;
00105 }
00106 
00107 inline
00108 float
00109 Range::low(float i) {
00110     if (i > _high) i = _high;
00111     return _low = i;
00112 }
00113 
00114 inline
00115 float
00116 Range::high(void) const {
00117     return _high;
00118 }
00119 
00120 inline
00121 float
00122 Range::high(float i) {
00123     if (i < _low) i = _low;
00124     return _high = i;
00125 }
00126 
00127 inline
00128 float
00129 Range::center(void) const {
00130     return (_low + _high) / 2.;
00131 }
00132 
00133 inline
00134 float
00135 Range::width(void) const {
00136     return (_high - _low);
00137 }
00138 
00139 inline
00140 Range &
00141 Range::set(float iLow, float iHigh) {
00142     if (iHigh > iLow) {
00143         _low = iLow;
00144         _high = iHigh;
00145     }
00146     else {
00147         _low = iHigh;
00148         _high = iLow;
00149     }
00150     return * this;
00151 }
00152 
00153 inline
00154 Range &
00155 Range::setByCenter(float center, float width) {
00156     _low = center - width;
00157     _high = center + width;
00158     return * this;
00159 }
00160 
00161 inline
00162 Range &
00163 Range::operator = (const Range & ib) {
00164     _low = ib.low();
00165     _high = ib.high();
00166     return * this;
00167 }
00168 
00169 inline
00170 bool
00171 Range::within(const float f) const{
00172     if (_low == -999. && _high == -999.) {
00173         return false;
00174     }
00175     if (_low == -999.) {
00176         if (f <= _high) return true;
00177         return false;
00178     }
00179     if (_high == -999.) {
00180         if (f >= _low) return true;
00181     }
00182     if (f >= _low && f <= _high) return true;
00183     return false;
00184 }
00185 
00186 inline
00187 bool
00188 Range::within2(const float f) const{
00189     if (_low == -999. && _high == -999.) {
00190         return true;
00191     }
00192     if (_low == -999.) {
00193         if (f <= _high) return true;
00194         return false;
00195     }
00196     if (_high == -999.) {
00197         if (f >= _low) return true;
00198     }
00199     if (f >= _low && f <= _high) return true;
00200     return false;
00201 }
00202 
00203 inline
00204 bool
00205 Range::operator != (const Range & a) const {
00206     if ((* this) == a) return false;
00207     return true;
00208 }
00209 
00210 inline
00211 bool
00212 Range::operator & (const Range & a) const {
00213     if (within(a.low())) return true;
00214     if (within(a.high())) return true;
00215     if (a.within(low())) return true;
00216     if (a.within(high())) return true;
00217     return false;
00218 }
00219 
00220 inline
00221 bool
00222 Range::within(const Range & a) const {
00223     if (within(a.low()) && within(a.high())) return true;
00224     return false;
00225 }
00226 
00227 #endif
00228 
00229 #undef inline
00230 
00231 #endif /* Range_FLAG_ */
00232 

Generated on Tue Nov 29 23:14:17 2016 for BOSS_7.0.2 by  doxygen 1.4.7