Loop over subdirectories of a rootfile in pyRoot

Hi,

I have the following structure in a root file containing subdirectories with TH1’s:

rootfile.root
subdir1
h_1
h_2

subdir2
subdir3

I want to normalise all the histograms with a scale factor, is there any clean way to loop over all the subdirectories and histograms without hardcoding in pyRoot? I tried “keys” but it gives only the names of the subdirectories and I couldn’t get the TH1’s.

Thanks!

Hello,
Can you check if the final solution discussed here works for you?

Cheers,
Enric