Piecewise function fitting: ranges not respected in the fit of the sum of two functions

I’m trying to use the sum of TF1’s to do a fit with a piecewise function on ROOT Cern. Here is the important part of the code.

    TCanvas *cvi = new TCanvas("V(i)","V(i)",200,10,600,400);
    TGraphErrors *gvi = new TGraphErrors(27,i,V,si,sV);
    TF1 *vi1 = new TF1("vi1","[0]*log(x*[1]+1)");

    TF1 *vi2 = new TF1("vi2","[0]*x+[1]",0.005,0.012);

    TF1 *vitot = new TF1("vi1+vi2","vi1+vi2");

The fitting with vi1 and vi2 are fine, but, as you see, vi2 has a range, therefore the fit with vtot should be the function

enter image description here

Nevertheless the programm does not respect the range I gave for vi2 when it does the fit vitot. That is, it does the fit vitot as if I gave no range at all.

How can I force ROOT to fit vtot taking into account the range I gave for vi2?

I cannot set a range directly on vitot because it would fit only that part of data, while I’m trying to fit all the data with different functions.

I already gave the option “R” in the fits, as you see, but that does not seem enough.

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