In addition to what Lorenzo pointed out, it’s important to note that for arbitrary functions, there can be many roots (i.e., many values fox X where F(x) = 0). This means you want to use TF1::GetX() carefully.
Hello, I have a similar question. I have a histogram with a cluster of data points. How would I extract the x and y values in order to get an equation for a line y = mx + b ?? Thanks in advance
I am not sure I have understood your question. You have an histogram and what do you want to do ? A fit to a y = a* x + b function and extract the a and b parameters ?
Or do you want the y (bin contents) and x ( bin center) values of the histograms ?
What I meant to say is, I have a 1D histogram, I want to fit 2 lines with eqn y = mx + b over 2 different y-ranges (vertical axis).
i.e If I have 2 points from y = 0 to y = 100, I want to fit a line through those points. And if I have 2 points from y = 200 to y = 300, I want to fit another through those points as well.
I cannot think of another way to do this as TF1 only takes in an x-range (horizontal axis)?
Hi,
If you know the y value exactly, you can loop on the bins to find it. Otherwise you can try to use something like
TH1::FindFirstBinAbove or TH1::FindLastBinAbove