It seems the leaf names are confusing to PyROOT. You can access the field by doing so:
import ROOT
f = ROOT.TFile.Open("DEC_12pythia8_Geant4_1_0.5_ID_0.root");
print(f.cbmsim.__getattr__('MCTrack.fPdgCode'))
Your loop then becomes
for events in f.cbmsim:
for e in events:
do_stuff(e.__getattr__('MCTrack.fPdgCode'))
PyRoot normally handles this for you, but when the branch name contains a period (’.’), python get confused. A look up of x.y.z normally resolves to ‘find attribute z on y; which in turn is an attribute on x’. To get the, in this case correct, lookup of ‘find attribute y.z on x’ we need to use the __getattr__
function.
Cheers,
Kim