Storing 2D vector [--> vector<vector<...> >] into a TTree

Hi ROOT experts!

I want to store a 2D vector into a ROOT Tree. I tried to find some information about this, but all I found didn’t really help.

This is more or less what I am doing:

  std::vector<std::vector<float> > _parFloatVal = std::vector<std::vector<float> >();
  tree->Branch("pafv",  &_parFloatVal) ;

  for (int i=0; i<10; i++){
    for (int j=0; j<10; j++){
      std::vector<float> floatVec = std::vector<float>();
      floatVec.push_back(2.222); //just an example
      floatVec.push_back(3.333); //just an example
      _parFloatVal.push_back(floatVec);
    }
    tree->Fill();
  }

I also already tried to include at the beginning of my class definition

but this also didn’t work out.

I need to have the code compiled without CINT, but with the normal GCC compiler. Compiling seems to be no problems, at least I get no error messages. But if I check the saved tree after a successful run the branch “pafv” simply doesn’t exist. Currently I am using ROOT 5.18.

Is there anything I do wrongly? How can this be done correctly?

Try: root [0] .x trial.cxx and/or: root [0] .x trial.cxx++ and/or: `root-config --cxx --cflags` -O2 -W -Wall -o trial trial.cxx `root-config --glibs` ./trial and then: root [0] TFile f("trial.root", "READ"); root [1] tree->Print(); root [2] tree->Draw("fltvv");
See also: http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=14990&p=64375#p64375

P.S. If the above compilation command does not work for you, try: g++ `root-config --cflags` -O2 -W -Wall -o trial trial.cxx `root-config --glibs` ./trial
trial.cxx (4.44 KB)