00001 #ifndef __NEW_HISTOGRAM1D_H
00002 #define __NEW_HISTOGRAM1D_H
00003
00004 #include "generic_spline1d.h"
00005 #include "parametermap.h"
00006 #include "tnt_array1d.h"
00007
00008 using namespace std;
00009
00010
00011
00012
00013 class CHistogram1d: public CGenericSpline1d{
00014
00015 public:
00016
00017 bool fixed_width_bins;
00018
00020 CHistogram1d(int _l=0, int _m=0, bool r=true, int N=1, double _xmin=0., double _xmax=1.):
00021 CGenericSpline1d(_l,_m,r,N,_xmin,_xmax,0), fixed_width_bins(false)
00022 {Array1D<double>tmp(N+1,0.);knots=tmp;min_deriv=-1;max_deriv=0;}
00023
00025 CHistogram1d(const CHistogram1d& h):
00026 CGenericSpline1d(h), fixed_width_bins(h.fixed_width_bins){}
00027
00028
00029 bool Read(const parameterMap& m);
00030 bool Write(parameterMap& m);
00031
00032
00033 void CopyState(const CHistogram1d& a)
00034 {CGenericSpline1d::CopyState(a); fixed_width_bins=a.fixed_width_bins;}
00035
00036
00037 double getValue(double r) const {return data[whatBin(r)];}
00038 double getError(double r) const {return uncert[whatBin(r)];}
00039 double basisFunction(double x, int i, int jderiv=0) const;
00040
00041
00042 void setFixedWidthBins(double dx, double xoffset);
00043 bool inThisBin(int i, double xx) const;
00044 int whatBin(double x, bool graceful=true) const;
00045 double binWidth(int i) const{return knots[i+1]-knots[i];}
00046 double leftBinEdge(int i) const{return knots[i];}
00047 double rightBinEdge(int i) const{return knots[i]+binWidth(i);}
00048 double midBin(int i) const{return knots[i]+binWidth(i)/2.;}
00049
00050
00051 double getLeftSupport(int i) const{return leftBinEdge(i);}
00052 double getRightSupport(int i) const{return rightBinEdge(i);}
00053
00055 bool setDefaultKnots( void );
00056 };
00057
00058
00059 #endif