Fill Branch from Vector of Vectors

Is it possible to create a branch from a vector of vectors? I tried

std::vector<std::vector<float>> myVector;
...
myTree->Branch("myVector", &myVector);
std::vector<float> test;
test.push_back(1.);
myVector.push_back(test);
 myTree->Fill();
myVector.clear();

The code ran without complaint, but myTree did not have the branch myVector. Did I do something wrong? Or is this only possible with flat vectors?

Thanks in advance!

Hi,

You would need to generate first the dictionary for the required class (std::vector<std::vector>).
You can do this by using first ACLIC and then you can run your code.
Here is the fixed macro:

#include <vector>
#include <TTree.h>

// line needed to generate the dictionary
#pragma link C++ class std::vector<std::vector<float>>+;

void test()  {
auto myVector = new std::vector<std::vector<float>>;
auto myTree = new TTree("t","t");
myTree->Branch("myVector", "std::vector<std::vector<float>>", &myVector);
std::vector<float> test;
test.push_back(1.);
myVector->push_back(test);
myTree->Fill();
myVector->clear();

myTree->Print();

}

And you need first to run ACLIC:

root> .L test.C+
root> test() 

Thank you!!