How to read a 2D vector in root file


I have a skimmed D3PD root file and I just MakeClass to analyze the data.

In this root file I have some vector of float vector branches like:

The question is how to access these branches in the source file. I have tried two methods:

Float_t eta = trig_EF_trigmuonef_track_MS_eta->at(i).at(j);


vector<float> tmp;
tmp = trig_EF_trigmuonef_track_MS_eta->at(i);
Float_t eta = tmp[j];

It gives me the same error:
Error: Can’t call vector<vector<float,allocator >,allocator<vector<float,allocator > > >::at(i) in current scope TagProbe.C:23:
Possible candidates are…
(in vector<vector<float,allocator >,allocator<vector<float,allocator > > >)
*** Interpreter error recovered ***

I’d be really appreciated if someone knows how to access to these branches.


In the beginning of your macro, try to add: if (!(gInterpreter->IsLoaded("vector"))) gInterpreter->ProcessLine("#include <vector>"); gSystem->Exec("rm -f AutoDict*vector*vector*float*"); gInterpreter->GenerateDictionary("vector<vector<float> >", "vector");
For “std::vector<std::vector >” see [url]Storing 2D vector [--> vector<vector<...> >] into a TTree
For “std::vector<std::vectorstd::string >” see [url]Problem in getting the vector < vector <string> > branch

Thanks very much!