3D vector seems to be not working with TTree

Hello,

This is inspired by PyROOT and 3D vector, but I might have discovered a more general problem(s) with ROOT TTrees, or I am doing something wrong.

It seems that 3D vectors (tested with floats and doubles) is not properly stored in a TTree:

gInterpreter->GenerateDictionary("vector<vector<vector<Float_t>>>", "vector");

vector<vector<vector<Float_t>>> a;
vector<vector<Float_t>> b;
vector<Float_t> c;

c.push_back(1.);
c.push_back(2.);
c.push_back(3.);
b.push_back(c);
c.clear();
c.push_back(10.);
c.push_back(20.);
c.push_back(30.);
b.push_back(c);
a.push_back(b);

auto f = TFile("test_vec.root", "create");
auto t = TTree("t", "t");
t.Branch("v", &a);
t.Fill();
t.Write();
t.Scan();
cout << a[0][0][0] << endl;
f.Close()

This display only 0 and empty for Scan(). When branch is created for &b (so a 2D vector), Scan displays correct values.

Another problem is, that if I use “float” instead of “Float_t” when generating dictionary, I get this error:

cling::DynamicLibraryManager::loadLibrary(): libflexiblas_netlib.so: cannot open shared object file: No such file or directory


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.26.11
Platform: Fedora 37
Compiler: Not Provided


Maybe @vpadulan can take a look

Since the topic would close tomorrow… Do you think there is any chance on update on this? Or perhaps I should file a bug report?

Sorry for the delay… Maybe @Axel can take a quick look and give some advice

Another problem is, that if I use “float” instead of “Float_t” when generating dictionary, I get this error:
cling::DynamicLibraryManager::loadLibrary(): libflexiblas_netlib.so: cannot open shared object file: No such file or directory

This seems to indicate that your LD_LIBRARY_PATH has a rootmap file indicating that the vector has a dictionary in the library libflexiblas_netlib.so but it is not available.

This display only 0 and empty for Scan(). When branch is created for &b (so a 2D vector), Scan displays correct values

This seems to be a limitation of Scan try with RDataFrame::Display instead.

1 Like

Great, indeed it was a problem with TScan, while 3D vector works both in C++ and in Python (and no strange reference to libflexiblas_netlib.so after recompilation of ROOT). Thanks!

Would there be any chance of fixing TTree::Scan() for this purpose? RDataFrame is quite cumbersome for printing. I am not fluent at it, but to compare 2 columns that include multidimensional vectors, the shortest way to do it that I found is:

root -l 
ROOT::RDataFrame df("tadc", "test.root");
auto b = df.Define("t00", "trace_ch[0][0]").Define("tx0", "trace_0[0]").Display({"t00", "tx0"});
b->Print();

while with a fixed Scan() it would be

root -l test.root
tadc->Scan("trace_ch[0][0]:trace_x[0]");

Two lines instead of four, and those two lines are significantly simpler…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.