Issues when trying to store nested STL vectors (3 dimensions) in TTree

Hi everyone,

when trying to store a vector<vector<vector<Float_t> > > into a TTree according to the example code attached to this post (run via $ root -l run_example.cpp), entries are not properly stored. To be more precise, the vectors stored seem to correspond to arrays with dimensions [10][5][1] (according to TTree::Scan) while the code should result in [10][5][10]. 2D nested vector I/O works fine. According to this thread, I/O with 3D nested vectors should be possible, so I would like to ask if there is something wrong with the way I try to store the nested vectors or if there is something else to consider.

run_example.cpp (143 Bytes)
mk_nested.cpp (1.3 KB)

ROOT Version: 6.14/02 (from tag v6-14-02)
Platform: Ubuntu 16.04.5 LTS
Compiler: ACLiC / g++ (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609

The data is correctly stored:

root [0] 
Attaching file nested_example.root as _file0...
(TFile *) 0x7fbe52c00060
root [1] gInterpreter->GenerateDictionary("vector<vector<vector<Float_t> > >");
root [2] vector<vector<vector<Float_t> > > *ptr = nullptr;
root [3] tree->SetBranchAddress("nested",&ptr)
(int) 0
root [4] tree->GetEntry(0)
(int) 2250
root [5] ptr->size()
(unsigned long) 10
root [6] ptr->back().size()
(unsigned long) 5
root [7] ptr->back().back().size()
(unsigned long) 10

However TTree::Scan does not handle this case well.

Thanks, my mistake (unsuccessfully tried TTree::Draw and TTree:Scan without trying to access the data directly). I suppose that there is no way to make TTree::Draw work with nested vectors of dimension 3 or larger yet?

That is correct. And instead we are going to offer this feature via RDataFrame.

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