diff --git a/interface/RooSpline1D.h b/interface/RooSpline1D.h index f8b3d28bda7a1..b4584375eaea8 100644 --- a/interface/RooSpline1D.h +++ b/interface/RooSpline1D.h @@ -19,6 +19,7 @@ class RooSpline1D : public RooAbsReal { public: RooSpline1D() : interp_(0) {} + RooSpline1D(const char *name, const char *title, RooAbsReal &xvar, const char *path, const unsigned short xcol, const unsigned short ycol, const unsigned short skipLines=0, const char *algo="CSPLINE") ; RooSpline1D(const char *name, const char *title, RooAbsReal &xvar, unsigned int npoints, const double *xvals, const double *yvals, const char *algo="CSPLINE") ; RooSpline1D(const char *name, const char *title, RooAbsReal &xar, unsigned int npoints, const float *xvals, const float *yvals, const char *algo="CSPLINE") ; ~RooSpline1D() ; diff --git a/src/RooSpline1D.cc b/src/RooSpline1D.cc index 23f74adc1dbfc..f0483eea7ffbc 100644 --- a/src/RooSpline1D.cc +++ b/src/RooSpline1D.cc @@ -2,6 +2,34 @@ #include +#include +#include + +RooSpline1D::RooSpline1D(const char *name, const char *title, RooAbsReal &xvar, const char *path, const unsigned short xcol, const unsigned short ycol, const unsigned short skipLines, const char *algo) : + RooAbsReal(name,title), + xvar_("xvar","Variable", this, xvar), + x_(), y_(), type_(algo), + interp_(0) +{ + std::ifstream file( path, std::ios::in); + std::string line; + + for(int lineno=0; std::getline(file, line); lineno++){ + if(lineno begin(ss), end; + std::vector tokens(begin, end); + + x_.push_back(atof(tokens[xcol].c_str())); + y_.push_back(atof(tokens[ycol].c_str())); + +// std::cout << lineno << ": " << line << std::endl; + } + + file.close(); +} + + RooSpline1D::RooSpline1D(const char *name, const char *title, RooAbsReal &xvar, unsigned int npoints, const double *xvals, const double *yvals, const char *algo) : RooAbsReal(name,title), xvar_("xvar","Variable", this, xvar),