What is a trick in TChain events reading? I have a very simple script (in the attachment) which works fine with TTree, but not with TChain! Please help!!
Thanks a lot in advance,
Alexander Zvyagin.
b.py (977 Bytes)
What is a trick in TChain events reading? I have a very simple script (in the attachment) which works fine with TTree, but not with TChain! Please help!!
Thanks a lot in advance,
Alexander Zvyagin.
b.py (977 Bytes)
Hi Alexander,
please use ROOT.AddressOf() when passing the event object to SetBranchAddress:tree.SetBranchAddress( 'Event', ROOT.AddressOf( event_ID ) )
The interface specifies ‘void*’, so that is what ends up in the dictionary. However, it really needs ‘void**’. There’s an automatic correction for TTree::SetBranchAddress() on the python side, which does unfortunately not propagate because TChain::SetBranchAddress() is overriding it.
You should also be able to access the event object directly:print tree.Event.run
, which will work for both TTree and TChain.
HTH,
Wim
Hi,
that worked, thanks!
tree.SetBranchAddress( 'Event', ROOT.AddressOf(event_ID) )
I tried myself this only this one (which did not work):
tree.SetBranchAddress( 'Event', ROOT.AddressOf(event_ID,'run') )
The line
print tree.Event.run
(which I also tried to use) prints me None.
Thanks again, I am happy with the solution with ROOT.AddressOf()
Alexander.