# TSpline3 interpolation

**URL:** <https://root-forum.cern.ch/t/tspline3-interpolation/38089>\
**Category:** Newbie\
**Created:** [February 21, 2020, 5:06pm UTC](https://root-forum.cern.ch/t/tspline3-interpolation/38089 "2020-02-21T17:06:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimFulcher](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/timfulcher/32/37354_2.png) [@TimFulcher](https://root-forum.cern.ch/u/TimFulcher)\
**Post date:** [February 21, 2020, 5:06pm UTC](https://root-forum.cern.ch/t/tspline3-interpolation/38089/1 "2020-02-21T17:06:03Z")

</div>

Hi all,

thanks to help on these forums I’m getting close to what I want or need.

I have my code displaying a histogram from root and I’m able to use a cubic spline to fit that histogram (code below).

But now I need to interpolate the cubic spline fit of the histogram. My histogram has 1001 bins and I need 1000001 points in my interpolated fit. Could somebody please throw me some hints of where to start?

When I get that going there’ll be a few more questions but they can wait. Baby steps.

Thanks people and have a good weekend.

Regards

Tim

```auto

        TH1D *h2;
	gDirectory->GetObject("EnergyLoss", h2);

	c1->cd(2);

	h2->Draw();

	TSpline3 *spline = new TSpline3(h2);

	spline->SetLineColor(kRed);
	spline->Draw("SAME");
	
  	h2->GetXaxis()->SetTitle("Depth (m)");
        h2->GetXaxis()->CenterTitle(1); // center the name of the x-axis

	gPad->SetGridx(1);
   	gPad->SetGridy(1);

	gPad->Modified();

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 24, 2020, 8:56am UTC](https://root-forum.cern.ch/t/tspline3-interpolation/38089/2 "2020-02-24T08:56:19Z")

</div>

> [@TimFulcher](#):
>
> I need 1000001 points

TSpline3 has an [Eval](https://root.cern/doc/master/classTSpline3.html#ac4493995dcc46ff6827732b0a2723565) function which can help you to generate these points.

---

<div class="post-metadata">

**Author:** ![TimFulcher](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/timfulcher/32/37354_2.png) [@TimFulcher](https://root-forum.cern.ch/u/TimFulcher)\
**Post date:** [February 25, 2020, 8:03am UTC](https://root-forum.cern.ch/t/tspline3-interpolation/38089/3 "2020-02-25T08:03:05Z")

</div>

Thanks Olivier that worked great and I’m finding my peak.
