I’m having the same trouble as in
[url]Branch with array of variable length
My simplified code is :
from ROOT import MyStruct
s = MyStruct()
t = TTree('skim', 'Skimmed tree')
print s.b0mass, type(s.b0mass)
#s.b0mass = 12.2
Without the comments, it runs OK with the following output:
<Double_t buffer, size 100> <type 'ROOT.PyDoubleBuffer'> |
But if I remove the comment line:
s.b0mass = 12.2
TypeError: bad argument type for built-in operation
which version of ROOT (and which OS)? It works fine for me (SVN trunk on Linux).
I’m using ROOT 5.27/06b (5 November 2010) on lxplus (Linux lxplus427.cern.ch 2.6.18-274.12.1.el5 #1 SMP Wed Nov 30 08:57:58 CET 2011 x86_64 x86_64 x86_64 GNU/Linux )
If I have to use that version of ROOT, what would be the best way to store array of doubles in PyROOT?
seen from the python-side, either an array from module array or any of the numpy editions would be best. What is the use? In particular, will the array pass onto the C++ side, and if yes, how?
Thanks for your reply! In my case, I just use PyROOT to write a TTree sturcture and no need to pass onto the C++ side. I will look into arrays…
okay; note that an array can be used where C++ expects a double* and it can be used in a TTree as well, so that should all be fine. (See also here, section A2.2.)