Hi, I’m wondering how I can create an array of functions in python using root. I want to something like this:
for i in range(tothist.GetXaxis().GetNbins()):
temp1 = ROOT.TF1(“f1”,“function([0],[1],[2],[3]”,-40,40)
temp1.SetParameter(0,a)
temp1.SetParameter(1,b)
temp1.SetParameter(2,c)
temp1.SetParameter(3,tothist.GetBinContent(i))
array[i] = temp1
How can this be done? Using numpy, it wont accept as it is not a number nor a string.
array = []
for i in range(tothist.GetXaxis().GetNbins()):
array.append(ROOT.TF1(“f1”,“function([0],[1],[2],[3])”,-40,40))
array[-1].SetParameter(0, a)
...
Any reason why you need one function per point? Why not make a single function that iterates on the whole vector if you want the sum of all values at the end? I don’t know an easy way to create a TF1 out of a vector of TF1s.
Actually I only need the sum of the functions to get one function, so that might be a better suggestion. I’m new to programming, so I figured the other way would be the easiest to accomplish this. However I’m not quite sure how this needs to be done.