Problem in fitting histogram in root

Dear Experts,

I am trying fit a histogram by using exponential function in root. It is giving error as below.

Processing macro_fit.cc…
Limitation: Function can not be defined in a command line or a tempfile
You need to write it in a source file macro_fit.cc:20:
*** Interpreter error recovered ***
root [1]

I am attaching the macro. Please have a look on it and help me to solve it.

Thanks,
Deepakmacro_fit.cc (1.7 KB)

Remove the very first line (containing “{”).
Add:

#include <TChain.h>
#include <TF1.h>
#include <TCut.h>

Hi Coyote,

Yes, It’s working. Many thanks. The fitted plot is coming like as attached. If you see, left side of the histogram is not properly fitted.I want to fit it properly. Could you please tell me how to do it?

Thanks,
Deepak

Try: h_mm->Fit(fSpectrum, "L"); // "L" or "WL"

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