Histogram Empty: Only One Entry: Histogram from Pre-Defined Function Failing

Hello,

I am trying to create a histogram using Python and ROOT. I wrote my code in python. At the beginning of my code, I opened a file that contains several hundred lines of data and read the data in it and did some calculation on that file and called the result theta. Theta was calculated for each data line in the file. Now, I want to create a histogram with my pre-defined function theta. I create my histogram object using root and by writing

histo = ROOT.TH1F("histo", "My histogram", 10, 0, 100)

histo.SetDirectory(0) 

Then, I fill my histogram with my pre-defined function and draw the histogram

histo.Fill(theta)
histo.Draw()

However, this only gives me a blank histogram and only one entry in my histogram. I do not understand why since the above code is inside my for loop that calculated my theta for each line. Does anyone know how I can fix this?

If I create a histogram through a user defined function by using TF1

fu = ROOT.TF1("f1", theta, 0, 10)

, I just get the error that the object doesn’t have the attribute Fill.

Thanks

I believe that’s answered in Creating Histogram Using ROOT from Python ?