Greetings,
I am curious to know how to implement a TSplinePoly3 or TSplinePoly5 on a TGraph.
I see no documentation or examples of how this can be done.
I have found the ROOT support message [url]Splines in ROOT which back in 2008 is was known there was poor documentation and that documentation was to be had.
The embedded macro below creates a TGraph, splines the graph, evaluates the spline and fills a histogram. I am just curious to know if a TSplinePoly5/5 would do a better job.
Thanks in advance
#include "TGraphAsymmErrors.h"
// 2.2 - 2.22
void plot47()
{
double p7694_d47x1y1_xval[] = { -0.84, -0.75, -0.65, -0.55, -0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75 };
double p7694_d47x1y1_xerrminus[] = { 0.040000000000000036, 0.050000000000000044, 0.04999999999999993, 0.04999999999999993, 0.04999999999999999, 0.050000000000000044, 0.04999999999999999, 0.05000000000000002, 0.05, 0.05, 0.04999999999999999, 0.04999999999999999, 0.04999999999999999, 0.04999999999999999, 0.050000000000000044, 0.050000000000000044, 0.050000000000000044 };
double p7694_d47x1y1_xerrplus[] = { 0.039999999999999925, 0.050000000000000044, 0.050000000000000044, 0.050000000000000044, 0.04999999999999999, 0.04999999999999999, 0.04999999999999999, 0.04999999999999999, 0.05, 0.05, 0.05000000000000002, 0.04999999999999999, 0.050000000000000044, 0.04999999999999999, 0.04999999999999993, 0.04999999999999993, 0.050000000000000044 };
double p7694_d47x1y1_yval[] = { 0.0324, 0.0374, 0.0276, 0.0233, 0.0173, 0.0122, 0.0122, 0.0169, 0.0277, 0.0333, 0.0359, 0.0375, 0.0439, 0.0625, 0.093, 0.132, 0.1634 };
double p7694_d47x1y1_yerrminus[] = { 0.005, 0.00291, 0.00185, 0.00166, 0.00139, 0.00102, 9.7E-4, 0.00117, 0.00178, 0.00205, 0.00215, 0.00217, 0.00258, 0.00386, 0.005, 0.0069, 0.0093 };
double p7694_d47x1y1_yerrplus[] = { 0.005, 0.00291, 0.00185, 0.00166, 0.00139, 0.00102, 9.7E-4, 0.00117, 0.00178, 0.00205, 0.00215, 0.00217, 0.00258, 0.00386, 0.005, 0.0069, 0.0093 };
double p7694_d47x1y1_ystatminus[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double p7694_d47x1y1_ystatplus[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
int p7694_d47x1y1_numpoints = 17;
TGraphAsymmErrors *p7694_d47x1y1 = new TGraphAsymmErrors(p7694_d47x1y1_numpoints, p7694_d47x1y1_xval, p7694_d47x1y1_yval, p7694_d47x1y1_xerrminus, p7694_d47x1y1_xerrplus, p7694_d47x1y1_yerrminus, p7694_d47x1y1_yerrplus);
p7694_d47x1y1->SetName("trial2");
p7694_d47x1y1->SetTitle("trial"); ///HepData/7694/d47x1y1
p7694_d47x1y1->Draw("AP");
TSpline5 *s3 = new TSpline5("s3",p7694_d47x1y1);
s3->Draw("same");
//interpolX = s3->Eval(x);
TH1D *example = new TH1D("example","try this",201,-1,1);
example->Sumw2();
int hold = 1;
for (double j = -1.; j<1; j = j +0.01) {
double bin_content = s3->Eval(double(j));
if(bin_content < 0.0){bin_content = 0.0;}
cout<<bin_content<<endl;
example->SetBinContent(hold,bin_content);
//example->SetBinError(hold,sqrt(s3->Eval(double(j/10.))));
hold++;
}
TCanvas *canf = new TCanvas("canf","canf");
canf->cd();
example->Draw("ep");
}