Hi Kevin,
You can use for example the TSpline class. Here is an example:
You can use TSpline::Eval to evaluate the spline at a point x.
{
gROOT->Reset();
c1 = new TCanvas("c1","gerrors2",200,10,700,500);
c1->SetFillColor(42);
c1->SetGrid();
// draw a frame to define the range
TH1F *hr = c1->DrawFrame(-0.4,0,1.2,12);
hr->SetXTitle("X title");
hr->SetYTitle("Y title");
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);
// create first graph
Int_t n1 = 9;
Double_t x1[] = {-0.22, 0.05, 0.25, 0.35, 0.61,0.7,0.85,0.89,0.95};
Double_t y1[] = {1,2.9,5.6,7.4,9.6,8.7,6.3,4.5,2};
Double_t ex1[] = {.05,.1,.07,.07,.05,.06,.07,.08,.05};
Double_t ey1[] = {.8,.7,.6,.5,.4,.5,.6,.7,.8};
gr1 = new TGraphErrors(n1,x1,y1,ex1,ey1);
gr1->SetMarkerColor(kBlue);
gr1->SetMarkerStyle(21);
gr1->Draw("LP");
// use a cubic spline to smooth the graph
TSpline3 *s = new TSpline3("grs",gr1);
s->SetLineColor(kRed);
s->Draw("same");
}
See also class TGraphSmooth
Rene Brun
Kevin Reil wrote:
>
> Hi,
>
> I was wondering if it is possible to Eval a spline fit.
>
> TGraph *gr = new TGraph(100,*x, *y);
> gr->Draw("apl");
>
> The l has made a nice spline fit from x=0 to x=100 for example.
>
> Now, I want to get the value from the spline line at say x=53.2
> Something like:
> gr->FindObject("spline")->Eval(53.2);
>
> Thank you,
> Kevin
>
> -------------------------------------------
> - Kevin Reil -
> - #244A INSCC -
> - http://www.physics.utah.edu/~reil -
> - reil@physics.utah.edu -
> -------------------------------------------
> - And my father dwelt in a tent. -
> -------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:09 MET