00001 // @(#)root/mathcore:$Id: BinPoint.h 24482 2008-06-23 15:33:08Z moneta $ 00002 // Author: L. Moneta Wed Aug 30 11:10:03 2006 00003 00004 /********************************************************************** 00005 * * 00006 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT * 00007 * * 00008 * * 00009 **********************************************************************/ 00010 00011 // Header file for class BinPoint 00012 00013 #ifndef ROOT_Fit_BinPoint 00014 #define ROOT_Fit_BinPoint 00015 00016 00017 00018 00019 namespace ROOT { 00020 00021 namespace Fit { 00022 00023 00024 class DataRange; 00025 00026 /** 00027 Obsolete class, no more in use. 00028 class describing the point with bins ( x coordinates, y and error on y ) 00029 but not error in X . For the Error in x one should use onother class 00030 00031 00032 */ 00033 class BinPoint { 00034 00035 public: 00036 00037 00038 //typedef std::vector<double> CoordData; 00039 00040 00041 /** 00042 Constructor 00043 */ 00044 explicit BinPoint (unsigned int n = 1) : 00045 fDim(n), 00046 fCoords(0 ), 00047 fCoordErr( 0), 00048 fValue(0), 00049 fError(1), 00050 fInvError(1) 00051 {} 00052 00053 // /** 00054 // constructor from a vector of coordinates, y value and y error 00055 // */ 00056 // BinPoint (const std::vector<double> & x, double y, double ey = 1) : 00057 // fCoords(x), 00058 // fValue(y), 00059 // fInvError( ey!= 0 ? 1.0/ey : 0 ) 00060 // { } 00061 00062 // template <class Iterator> 00063 // BinPoint (const Iterator begin, const Iterator end, double y, double ey = 1) : 00064 // fCoords(begin,end), 00065 // fValue(y), 00066 // fInvError( ey!= 0. ? 1.0/ey : 1. ) 00067 // { } 00068 00069 void Set(const double * x, double value, double invErr) { 00070 fCoords = x; 00071 fValue = value; 00072 fInvError = invErr; 00073 } 00074 00075 void Set(const double * x, double value, const double * ex, double err) { 00076 fCoords = x; 00077 fValue = value; 00078 fCoordErr = ex; 00079 fError = err; 00080 } 00081 00082 00083 /** 00084 Destructor (no operations) 00085 */ 00086 ~BinPoint () {} 00087 00088 // use default copy constructor and assignment 00089 00090 00091 // accessors 00092 00093 /** 00094 return pointer to coordinates 00095 */ 00096 //const double * Coords() const { return &fCoords.front(); } 00097 00098 /** 00099 return vector of coordinates 00100 */ 00101 const double * Coords() const { return fCoords; } 00102 00103 /** 00104 return the value (bin height in case of an histogram) 00105 */ 00106 double Value() const { return fValue; } 00107 00108 /** 00109 return the error on the value 00110 */ 00111 double Error() const { 00112 //return fInvError != 0 ? 1.0/fInvError : 0; 00113 return fError; 00114 } 00115 00116 /** 00117 return the inverse of error on the value 00118 */ 00119 double InvError() const { return fInvError; } 00120 00121 /** 00122 get the dimension (dimension of the cooordinates) 00123 */ 00124 unsigned int NDim() const { return fDim; } 00125 00126 /** 00127 check if a Point is inside the given range 00128 */ 00129 bool IsInRange( const DataRange & range) const; 00130 00131 private: 00132 00133 unsigned int fDim; 00134 //double fCoords[N]; 00135 const double * fCoords; 00136 const double * fCoordErr; 00137 00138 double fValue; 00139 // better to store the inverse of the error (is more efficient) 00140 double fError; 00141 double fInvError; 00142 00143 00144 }; 00145 00146 } // end namespace Fit 00147 00148 } // end namespace ROOT 00149 00150 // #ifndef ROOT_Fit_DataRange 00151 // #include "Fit/DataRange.h" 00152 // #endif 00153 // #include <cassert> 00154 00155 // namespace ROOT { 00156 00157 // namespace Fit { 00158 00159 // template<unsigned int N> 00160 // bool BinPoint<N>::IsInRange(const DataRange & range) const 00161 // { 00162 // // check if given point is inside the given range 00163 00164 // // need to check that datarange size is same as point size 00165 // if (range.NDim() == 0) return true; // (range is empty is equivalent to (-inf, + inf) 00166 // // in case not zero dimension must be equal to the coordinates 00167 // assert( kSize == range.NDim() ); 00168 // for (unsigned int i = 0; i < kSize; ++i) { 00169 // if ( ! range.IsInside( fCoords[i] ) ) return false; 00170 // } 00171 // return true; 00172 // } 00173 00174 // } // end namespace Fit 00175 00176 // } // end namespace ROOT 00177 00178 00179 00180 #endif /* ROOT_Fit_BinPoint */