Writing a 2D array with pyroot

Hello,

According to:

t.Branch('mynum', n, 'mynum/I')
t.Branch('myarray', x, 'myarray[mynum][3]/D')

is not officially supported but “might work”. I guess you’ve tried already and there was no luck?

Another thing you could try is RVec:

https://root.cern/doc/master/classROOT_1_1VecOps_1_1RVec.html

If you look at the python docs in the link above, RVecs can adopt the memory of a numpy array. Once transformed into a (flat) RVec, you could then store it as with a vector branch. When retrieving it from the file, you would be able to retransform it into a numpy array with asarray but you’d also need to reshape it to get the original shape.