I define a custom function to fit a list of points and draw its fitting curve on the same canvas as data points. Fitting curve looks good. And then save the canvas into a root file. But when I open the saved root file, I find that the fitting line becomes a straight line at the bottom of the frame. Generally, what’s wrong here? I need to store the function into my root file? Sorry for I am not able to provide a short code to show my problem.
Please indicate which version you are using.
In case you use something older than 4.04/02 or 5.02, try with
a more recent version.
Rene
I think I get to know the problem. Because my fitting function is not pre-defined in root, and I just draw fitting functions on canvas but not store them in the root file. Thus when I open my root file, root doesn’t know what’s my fitting function. What I do now is, transfer fitting function to a histogram and draw and store this histogram like:
TF1 *myfunc;
…
TH1F hmyfunc = (TH1F)myfunc->GetHistogram();
hmyfunc->Draw(“SAME”);
Now it works. But sometimes the histogram looks not smooth since it has a large bin size. How to change such a histogram’s bin size to make it smoother?
Before storing your TF1/TH1 objects, do
myfunc->SetNpx(500); //default is 100
Rene