Hi,
I’m trying to
- define two TF1 in two different but adjacent ranges (the function is the same, but the parameters will get different values in the two ranges)
- sum the two TF1s
- fit a TH1 with the sum function
h = ROOT.TH1F(title1, title2, bins, minb, maxb)
for i in range(0, len(array)):
h.Fill(array[i])
...
ff = ROOT.TF1("ff", "[0]*pow(1 -(1-[2])*(1./(3-[2]))*(x-[3])*(x-[3])*[1], 1./(1-[2]))", 0, 1, 3)
ff2 = ROOT.TF1("ff2", "[0]*pow(1 -(1-[2])*(1./(3-[2]))*(x-[3])*(x-[3])*[1], 1./(1-[2]))", 1, 2, 3)
fftotal = ROOT.TF1("fftotal", ff+ff2,0,2,6)
...
h.Fit(fftotal,"M+","",min_fit,max_fit)
However, it seems that I cannot sum the two functions in this way, since I get an error.
TypeError: unsupported operand type(s) for +: 'TF1' and 'TF1'
Using the following variation did not work:
fftotal = ROOT.TF1("fftotal", "ff+ff2",0,2,6)
What is the correct way to do so?
Thank you and kind regards,
Lorenzo