Fitting

Hello.

I know how to fit some histogram by Gaussian. See attachment. But I need to fit that histogram by gauss+pol1 on whole interval. I have no idea how i cat do that.
I tried to define special formula like :

TF1 *f1 = new TF1(“f1”,“gaus+pol1”,26.0,31.0);
f1->SetParameters(?)
f1->fit(“f1”)

After this I need to set parameters for gaus. From Fit Panel method I know that it needs to set parameters only for gauss. Parameters for pol1 will be defined automatically. But I don’t know how i can do that in code.

gauss.pdf (16.2 KB)

Thank you.

root.cern.ch/doc/master/combinedFit_8C.html

TF1 *f1 = new TF1("f1", "gaus(0)+pol1(3)", 26.0, 31.0); f1->SetParNames("height", "mean", "sigma", "intercept", "slope"); f1->SetParameters(10, 28, 0.5, 100, 1); f1->Draw(); // your_histogram_or_graph->Fit("f1", "R");

Thank you very much for your help.