I am having an unusual problem and I am not understanding why my macro does not work. I am using python 2.6 and ROOT 5.32.00.
I have attached a sample macro that is a very simple recreation of the problem (testPlots.py) and the output (test.pdf). The problem is that when I clone a histogram in the loop and try to print it to the pad, it only works in one of the pads (i.e. the bottom left pad should not be blank). When I Draw the original histogram (i.e. uncomment the only commented line in the macro), it appears in both pads.
Any thoughts would be appreciated.
test.pdf (21.7 KB)
testPlots.py (1.53 KB)
I think it’s because you are re-using “rb” on the python side. Though they have different names on the ROOT side, the Python reference-counting system thinks that 1_base has no references to it, so it cleans it up. If you go through the loop manually, you see that the 1_base is actually drawn first, then 2_base is drawn as 1_base disappears. If you try to do this manually in IPython both actually stay, because IPython keeps internal references to previously returned values.
Anyways, here’s a fix:
rbs =  # Somewhere to keep track of rbs.
for i in range(0,2):
pad = pads[i]
pad = pads[i+2]
rb = ratiobase.Clone(str(i+2)+"_base")
rbs.append(rb) # Stick it in the container.
I had forgotten about that little subtlety in python.