Filling histogram bug

I’m trying to fill a histogram with data from a tree, which has 40 bins and x values from -200 to 200. The bin content at x=10 is the last bin content added to the content which is supposed to be at that bin. The way I am filling the histogram is as follows(t is the tree with branches zPosition and efficiency and hist is the histogram).

for x in xrange(40):
hist.fill(t.zPosition, t.efficiency)

Is there something wrong with how I’m filling the histogram, or a more proper way to do it?



supposing that “t” is your tree, and you want to fill your histogram with the zPosition values weighted according to the efficiency, this would be the right syntax:

for event in t:
hist.fill(event.zPosition, event.efficiency)