Unable to get histogram from subdirectory in ROOT 6.06


I think in ROOT 6.06/01 and Python 2.7.6, the function: file.Get('mydir/myhist') is not working anymore, it returns <ROOT.TObject object at 0x(nil)>. Notice that myhist is in subdirectory.

Could you confirm or deny?



I deny :slight_smile: This should work.
Can you post the file on the forum so that we can reproduce the faulty behaviour and exclude typos or file corruptions of some sort?



Ok, so I figured out the reason.
It’s nothing to do with subdirectories, instead it’s about strings and unicodes types.
Basically, it looks like f.Get(hName) function in root no longer accepts type ‘unicode’ for hName

I attach a simple root file.
output.root (6.11 KB)

And here is a code to try:

f = TFile("output.root","open")

hName = u'h2'
# This won't work in root 6.06 (but works in root 5.34):
# newName = 'subDir/'+ hName
# This always works:
newName = str('subDir/'+ hName)

xx = f.Get(newName)
print xx, type(newName)

The reason why I have unicode strings is because I read some names from json file which returns data as u’bla’ string.

I don’t know if the new behaviour was intended or not, but it did give me a headache…