python - Declaring a TTree Branch in PyRoot -


i trying define root ttree using python , give tbranch. sounds reasonable, right? tried:

from root import * myvar = int() mytree = ttree('mytree', 'mytree') tree.branch('myvar', addressof(myvar), 'myvar/i') exit(0) 

and crashes error:

valueerror: invalid argument addressof(). 

i suspected perhaps argument of addressof() needs root type int_t, didn't think python data types needed made explicit--and furthermore couldn't figure out how force data type of of int int_t. finally, if same exact thing except replace 'int' 'tstring' , '/i' '/s', things not crash. suggestion appreciated.

you need use different data type "myvar". because of way data gets used internally in root.

from root import * array import array myvar = array( 'i', [ 0 ] ) mytree = ttree('mytree', 'mytree') mytree.branch('myvar', myvar, 'myvar/i') exit(0) 

this should work , gets rid of crash example see e.g. web page more information: http://wlav.web.cern.ch/wlav/pyroot/tpytree.html


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -