Help to get the background right from the function in TF1

Dear friends,

I have been struggling to get the background right for quite some time, but I couldn’t so far.
One method to calculate the background is as it’s written in the code. In this method, we calculate the background from histogram directly.
On the other hand, the ROOT helps us to get the background from a function after fitting. I tried both pol1 and pol2 as the background representation, so I can get the integral from this function.

The problem is both results should give almost similar answers, but the result from function is way off.
I assume I should write an algorithm so the pol2 parameters will be calculated automatically when the total counts are the same as the calculation from histogram instead of trying to change or fix parameters manually by hand one by one until I make the total counts (events) the same in both.

However, I felt overwhelmed. I came to conclusion that the background had to be pol2 in the shape of this photo below. I have tried when the middle bump in the pol2 line is up or down. I tried pol1 as well.

Thanks in advance for any little help.

Maybe your background can be better modeled with an “erfc” function, like in this old post.

Can you tell me why the function gives ZERO for the error of the background? I tried to make sure it was not a double / integer kind of mistake. This happened after I decided to define the functions separately in stead of writing in the TF1 like " TF1 *bg = new TF1(Form(“bg”), “pol2”, xl, xr)".

For complimentary error function or other stuff, I’d like to do it later. Firstly, I want to get this code working properly by comprehending what is wrong. I am aware of all these concepts: error function, complimentary error function, cumulative PDF, PDF, and so on.

FindFittingValues.cpp (7.4 KB)

Co60.txt (3.5 KB)

You fix all background parameters; hence their errors are 0.

I see, I miss that point. Now, I set the parameter limits instead of fixing, it won’t give ZERO for the error.

If I don’t fix them and just initialize them with the same numbers, I get this plot.

However, this picture below is what I want. For now, It’s still over-estimating my background area. I’ll find the way to adjust. This happens only when I fit the parameter.

Why does automatic fitting procedures choose the first plot as a result? Interesting thing is that pol1 is not a good model for the background representation when I compare with another method using the histogram directly. In early days around 1960s, people tend to use pol1.

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