Problem in accessing vector <vector<float>

Hi Experts,
I am using root-6.04/14 in Ubuntu 14.04 LTS. I am running .C code locally. I have tried to access :

vector<vector<float> >
vector<vector<int> >  

using :

#ifdef __MAKECINT__ 
#pragma link C++ class vector<vector <float> >+;
#pragma link C++ class vector<vector <int> >+;
#end if

In my header file & then I compile my code.C as :

g++ code.C -o test03.exe -I$ROOTSYS/include -L$ROOTSYS/lib `root-config --cflags` `root-config --libs`

& run it, I got errors as :

Error in <TTree::Branch>: The class requested (vector<vector<float> >) for the branch "AK8_SDSJPt" is an instance of an stl collection and does not have a compiled CollectionProxy. Please generate the dictionary for this collection (vector<vector<float> >) to avoid to write corrupted data.
Error in <TTree::Branch>: The class requested (vector<vector<int> >) for the branch "nAK8_SDSJ" is an instance of an stl collection and does not have a compiled CollectionProxy. Please generate the dictionary for this collection (vector<vector<int> >) to avoid to write corrupted data.

To solve it I tried to genetrate the required dictionary with :

gInterpreter->GenerateDictionary("vector<vector<float> >","vector");
gInterpreter->GenerateDictionary("vector<vector<int> >","vector");

This created dictionaries called AutoDict_vector_vector_float____cxx.so and AutoDict_vector_vector_int____cxx.so Then, I am trying to compile the code.C using:

g++ code.C -o test03.exe -I$ROOTSYS/include -L$ROOTSYS/lib `root-config --cflags` `root-config --libs` -L$PWD AutoDict_vector_vector_float____cxx.so AutoDict_vector_vector_int____cxx.so

But I am still having the same error. Please help me to solve it.
Arjun

1 Like

Hi Arjun,

I see two ways out:

  1. You add the lines
gInterpreter->GenerateDictionary("vector<vector<float> >", "vector")
gInterpreter->GenerateDictionary("vector<vector<int> >", "vector")

to your code, before looping on the TTree.

  1. You build once for all the dictionaries and compile them as a shared library which will be autoloaded upon need by ROOT, namely:
  • Take this selection file, LinkDef.h
#include <vector>
#ifdef __ROOTCLING__
#pragma link C++ class vector<vector <float> >+;
#pragma link C++ class vector<vector <int> >+;
#endif
  • Generate the dictionary:
rootcling -v4 -f mydict.cxx  -rmf libmydict.rootmap -rml libmydict.so  LinkDef.h
  • Compile the dictionary as a shared library
g++ -shared -o libmydict.so mydict.cxx `root-config --cflags --libs`

I would go for 2) if your code is stable and not in an explorative phase.
If you are interested, you could also move to ROOT 6.12.06 and have a look to TDataFrame, a tool which is very helpful when it comes to analyse data in trees.

Cheers,
Danilo

1 Like

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