So I have a TGraph of about 60 points. And they are quite unsmooth in the region of my interest. I want to now get a smooth representation of this set of points. They are particularly unsmooth from x=20 to 50 say.
I tried gr->Draw(“ac”) and it only connects the dots; i.e., my scattered points.
So I tried Splining it as:
TSpline3 *spline3 = new TSpline3(“Test”,gr);
This still follows exactly my scattered points.
How do I get TSpline or even some other method to draw a smooth curve through my points?
Can I ask TSpline to use more than 60 points? Perhaps 60*10 points or something like that for a smoother plot?
Here’s the code: I am also attaching the a gif of what the tgraph and the tspline look like when I run this code. I want the tgraph points to be connected via a smooth parabola, not in a un-smooth curve like it is doing now.
I see there’s some smoothening done, but not to the level I want it. Also I tried using TF1, but there are several different functions here so it is not trivial. Plus, this is just for representation, so I would like to get a parabolic fit without having to go through a complex TFit.
TCanvas *cc2 = new TCanvas(“cc2”,“cc2”,100,100,400,400);
TSpline3 *spline4 = new TSpline3(“Test1”,filMomTruth);
//the next I think is the same as above, as it takes the individual points of the TGraph
TSpline3 *spline3 = new TSpline3(“Test”,filMomTruth->GetX(),filMomTruth->GetY(),filMomTruth->GetN());
If you run the following few lines of code on your data set you will see that the smoothing is correct. You have data points extremely close in x,y and smoothing has to go through all the points.
The alternative is to fit with a function of your choice.