Dictionaries needed for RDataFrame(TTree).AsNumpy

Hi,

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?


ROOT Version: heads/master@v6-37-01-6541-g9a9e7697e4
Platform: Fedora 41


Hi,

Yes. At the moment the type safety mechanism of RDF require that.

Cheers,
Danilo

I understand. Still, I have problems with the dictionaries being accepted. For example, I can generate a dictionary for vector<bool>:

ROOT.gInterpreter.GenerateDictionary("vector<vector<bool> >", "vector")

And I will get a complaint:

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.