Here is an example code:
from ROOT import TFile, TTree
import numpy as np
f = TFile('example.root', 'recreate')
t = TTree('mytree', 'example tree')
x = np.zeros((2,3))
t.Branch('myarray', x, 'myarray[2][3]/D')
nentries = 25
for i in range(nentries):
x = np.array([[1+i, 2.+i, 3.+i], [4.+i, 5.+i, 6.+i]])
#print(x)
t.Fill()
f.Write()
f.Close()
I got expected root file when uncommenting “print(x)” (up plot), but got wrong root file when “print(x)” is commented (down plot).
_ROOT Version:_root_v6.26.06
Platform: MAC OS 12.5.1
Compiler: Not Provided