File indexing completed on 2026-09-27 09:14:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef LAGER_CORE_SPLINE_LOADED
0021 #define LAGER_CORE_SPLINE_LOADED
0022
0023 #include <TSpline.h>
0024 #include <lager/core/configuration.hh>
0025 #include <lager/core/interval.hh>
0026
0027 namespace lager {
0028
0029
0030
0031 class spline : public configurable {
0032 public:
0033 spline(const configuration& conf, const string_path& path)
0034 : configurable{conf, path}
0035 , x_{conf().get_vector<double>("x")}
0036 , y_{conf().get_vector<double>("y")}
0037 , spline_{path.str().c_str(), &x_[0], &y_[0], static_cast<int>(x_.size())}
0038 , xrange_{x_.front(), x_.back()} {}
0039
0040 double eval(const double x) const {
0041 if (xrange_.includes(x)) {
0042 return spline_.Eval(x);
0043 } else {
0044 return 0.;
0045 }
0046 }
0047 double operator()(const double x) const { return eval(x); }
0048
0049 private:
0050 std::vector<double> x_;
0051 std::vector<double> y_;
0052 TSpline3 spline_;
0053 interval<double> xrange_;
0054 };
0055 }
0056
0057 #endif