Accessing interpolated values of a "smoothed" grap

I have generated a histogram and a smoothed version of it using TGraphSmooth(). I would like to now retrieve interpolated values of this smoothed graph. In other words, I give the graph an x value and I get out the corresponding y value, or I give the graph a ya value and I get out the corresponding x value. I’ve tried using TGraph::Eval() to do this, but I always receive interpreter errors.

Here is my code:
{

TFile *f_in = new TFile("./root_data_files/Remap_0091.root");

TH1F h = (TH1F)f_in->Get(“h_lg44”);

Int_t hbins = h->GetNbinsX();
Int_t hmin = h->GetBinCenter(1);
Int_t hmax = h->GetBinCenter(hbins+1);
Int_t ch_per_bin = (hmax-hmin)/hbins;

Float_t x[hbins];
Float_t y[hbins];

Int_t i;
for(i=0; i<hbins; ++i)
{
x[i] = i*ch_per_bin+hmin;
y[i] = h->GetBinContent(i+1);
}//END of i for loop

TGraph *g_points = new TGraph(hbins,x,y);
g_points->SetMarkerStyle(8);
g_points->SetMarkerSize(0.5);

// TCanvas *canvas = new TCanvas(“canvas”,“Smoothing”,0,0,700,500);
// canvas->ToggleEventStatus();
// g_points->Draw(“AP”);
// h->Draw();

TGraphSmooth *gs = new TGraphSmooth(“normal”);

TGraph g_smooth = new TGraph();
g_smooth = (TGraph
)gs->SmoothSuper(g_points,"",0,0);
g_smooth->SetLineColor(4);
g_smooth->SetLineWidth(2);
// g_smooth->Draw(“PC”);

g_smooth->Eval(1000,0,"");
}

see TGraph::Eval
root.cern.ch/root/html402/TGraph … Graph:Eval

Rene

root.cern.ch/root/html402/TGraph … Graph:Eval

The above webpage was the first place I looked and is where I found out about the Eval() function. I am confused about the TSpline parameter, and I’ve been unable to find any RootTalk discussions on Eval(). The solution may be simple, but I’ve tried many things to get the script to run without success. Could you humor me with a simple example that works?

Thanks,
Brent

Dear Brent

TGraphSmooth has a method that allows you to get the y-value for every x,
it is called TGraphSmooth::Approx().

Please look at macro “approx.C” in the tutorials for an example.
A detailed explanation of approx() can be found at:
stat.ethz.ch/R-manual/R-patched/ … oxfun.html

Best regards
Christian