first of all, the search revealed this related topic:
Since it’s from 2006 I’ve made a new topic.
I have variables stored in my nTuples of the type ‘Object.Property’, sometimes even ‘Object.SubObject.Property’.
Following the example from above thread I should be able to access it via:
[code]chain = TChain(“rootTupleTree/tree”);
chain.Add("nTuple.root"); chain.SetBranchStatus("*", 0); chain.SetBranchStatus("Electron.Energy", 1); chain.SetBranchStatus("run", 1); print chain.GetEntries() for event in chain: print event.run #works fine print event.Electron.Energy
#produces error: ‘TChain’ object has no attribute ‘Electron’
However, if I try to access it’s attribute via
for event in chain:
print event.__getattr__('run') #works fine
print event.__getattr__('Electron.Energy') #this works
Is this indented or is it a missing feature?
Of course it gets complicated if one needs to create an extra layer for such variables, but on the other hand it would make it easy to read ‘objects’ in a ROOT file .