I have trees with 1D, 2D and 3D vectors of bools, shorts, etc. I have no problem assigning branches and reading them out in PyROOT directly through TTree. However, when I want to utilise the RDataFrame AsNumpy() function, I get errors like:
“RuntimeError: The column named “trace_ch” is of type “ROOT::VecOps::RVec<vector<vector >>”, which is not known to the ROOT interpreter. Please load the corresponding header files or dictionaries.”
I can declare and load the dictionaries in PyROOT, but I wonder if this is really necessary, since reading these values directly from the TTree works without any problem?
RuntimeError: The column named "adc_enabled_channels_ch" is of type "ROOT::VecOps::RVec<vector<bool>>", which is not known to the ROOT interpreter. Please load the corresponding header files or dictionaries.
when I call RDataFrame::AsNumpy().
I also tried to load the dictionaries that my C++ counterpart code generates. The load, but the error is the same.
I show here a small working example of the problem with RDataFrame not accepting dictionaries:
import ROOT
import numpy as np
t = ROOT.TTree("t", "t")
v = ROOT.vector["vector<bool>"](np.array([[True, False]]))
t.Branch("v", v)
t.Fill()
t.Scan()
ROOT.gInterpreter.GenerateDictionary("vector<vector<bool> >", "vector")
r = ROOT.RDataFrame(t)
r.AsNumpy()
output:
Traceback (most recent call last):
File "/tmp/./vector_sample.py", line 19, in <module>
r.AsNumpy()
~~~~~~~~~^^
File "/home/lewhoo/software/root/root/lib/ROOT/_pythonization/_rdataframe.py", line 274, in RDataFrameAsNumpy
raise RuntimeError(
f'The column named "{column}" is of type "{column_type}", which is not known to the ROOT interpreter. Please load the corresponding header files or dictionaries.'
)
RuntimeError: The column named "v" is of type "ROOT::VecOps::RVec<vector<bool>>", which is not known to the ROOT interpreter. Please load the corresponding header files or dictionaries.