Integral Error in Signal

The original example uses “pol1(3)” so there are 2 parameters, but you use “pol2(3)” so you have 3 parameters. That means that you need to change “3, 4” into “3, 5” in all relevant places.
In the first macro therein, you also need to add two lines (needed when “fit_with_fixed_background” = “kTRUE”):

    // ...
    f1->FixParameter(4, f1->GetParameter(4)); // this line already exists
    f1->FixParameter(5, f1->GetParameter(5));
    // ...
    f2->FixParameter(4, f2->GetParameter(4)); // this line already exists
    f2->FixParameter(5, f2->GetParameter(5));
    // ...

You can get the integral and error of your “signal + background” directly from your fitted “f1”. For the “signal” alone, you then have “fg”. If you want the “background” alone, then you will need to create another function (using “pol2”) and play the same game as for your “fg”.