TSpline5 interpolation

Dear All,

I am trying to interpolate a function using

TSpline5 *s = new TSpline5("grs",gr1); 

but the interpolation does not fit with the data

TSpline5 *s = new TSpline5("grs",gr1); 
s->SetLineColor(kRed);
s->Draw("same");

I have attached the plot with the interpolation function
is there any better interpolation function?
TS5.pdf (85.3 KB)


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,

I think it is very difficult to interpolate your data, since they are varying a lot. It is also true that the plot is in log scale so it is not easy to judge. It will depend on how many data points you have where you have all those peaks.

We have also interpolations routines in MathMore, based on GSL, you can look at
https://root.cern.ch/doc/master/group__Interpolation.html

Best regards

Lorenzo

thank you for your answer.
I have too many points but the peaks are very sharp.
the interpolation function you posted, I could not run it,
the output is that the math libraries don’t work.
and i am not familiar with the GLS libraries
do you have an Idea how to use the interpolation code?? please
regards

Hi

Can you please upload your data points or just the TGraph object you have used in the figure above and I can provide you an example on how to use the GSL based code.
Otherwise your can find examples also here,

Lorenzo

herein is the code and the data file.

test.txt (209.4 KB) histogram1.c (2.5 KB)

thanks in advance

HI,

Thank you for your code. The problem is due to the low number of points used to draw the spline. (by default is 100).
If you increase it by calling for example TSpline::SetNpx(10000) you will increase it .
I attach a new version of your code where I use also the ROOT::Math::Interpolator class. In this case you can specify directly the points you want to evaluate your interpolation.

Lorenzo

histogram1.C (3.2 KB)

Hello,
Thank you for help and collaboration, this is very useful.
Yes. “TSpline::SetNpx(10000)” solved the problem.

and thank you for the modification, on my root version “Math/Interpolation” class is not installed in my root version.
for this I need to reinstall root from scratch.

It is not needed to reinstall from scratch. You need only to re-configure ROOT with the option -mathmore=ON and being sure to have a GSL version installed in your system. If GSL is not found, you need to download and install it, but it is a simple and straightforward procedure. If you need help for this please let me know.
Best regards

Lorenzo

Dear Lorenzo,
I am using a ROOT6 binary version downloaded from the ROOT site.
Is there a way to add the mathmore ?

Hi,

Mathmore should be in the binary distribution. Which version are you using ? It is possible you are using an old ROOT version, that was shipped without the library.
In that case the easier is to update, if you can, to a newer version of ROOT, otherwise you cannot add package to an existing binary distributions

Lorenzo

Sorry, yes, mathmore is there, I am using binary root6.18/04, but I don’t have GSL,
so can not run your histogram1.C.
Since I don’t have the root password of the PC, I can install the GSL only in my home directory.
Could you please tell, how can I force the binary root to use the GSL from my home directory?

What do you get from:
ldd ${ROOTSYS}/lib/*.so|grep -i gsl

[smbat@localhost ~]$ ldd ${ROOTSYS}/lib/*so|grep -i gsl
        libgsl.so.0 => not found
        libgslcblas.so.0 => not found
        libgsl.so.0 => not found
        libgslcblas.so.0 => not found
        libgsl.so.0 => not found
        libgslcblas.so.0 => not found
        libgsl.so.0 => not found
        libgslcblas.so.0 => not found
ldd: warning: you do not have execution permission for `/home/smbat/Downloads/root/lib/libtbbmalloc_proxy.so'
ldd: warning: you do not have execution permission for `/home/smbat/Downloads/root/lib/libtbbmalloc.so'
ldd: warning: you do not have execution permission for `/home/smbat/Downloads/root/lib/libtbb.so'
ldd: warning: you do not have execution permission for `/home/smbat/Downloads/root/lib/libvdt.so'
................................................
..............................................

I guess the best idea would be to ask the “administrator” of your PC to install the missing operating system provided / default “libgsl” package (it aill automatically install “libgslcblas”, too).

Actually, you should ask them to install all “missing” system packages:
ldd ${ROOTSYS}/lib/*.so | grep "found" | sort -u

Thanks a lot, after installation of the “libgsl” I can run the histogram1.C.
Could you please explain, why I need to install other packages given by
ldd ${ROOTSYS}/lib/*.so | grep "found" | sort -u

Strictly speaking, you need to install only these that you want to use. My standard advice is to install all, in case you will want to try some ROOT’s feature in future.

OK, thank you very much!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.