Adding a vector of vectors to a tree

Hello to the root community! This is my first post.

I know this question has been asked before, but I didn’t understand the answers I found on the forum. I would like to add a vector<vector> to a tree with something like the following code:


vector<vector> vec_of_vecs;
TBranch* myBranch = myTree->Branch(“vector of vectors”, &vec_of_vecs);

myBranch->Fill();

but of course this fails on “myBranch->Fill()” at runtime, I suppose because myTree->Branch(…) returns a null pointer because it doesn’t know what a vector<vector> is;

From reading other posts I gather that I need to generate a dictionary (I don’t know what that is) so that this will work. I am using Visual Studios 2008 to do my coding. Could someone please explain in excruciating detail what the dictionary is, how and where I would generate it in my program, and where how I would use it in Visual Studios?

I’m afraid my lack of knowledge about C++ is what is preventing me from understanding the answers given in previous responses to this exact same question. I don’t understand the precompiler statements etc.

I greatly appreciate any help that anyone can give.

Thank you very much,
–John

[quote]From reading other posts I gather that I need to generate a dictionary (I don’t know what that is) so that this will work. Could someone please explain in excruciating detail what the dictionary is[/quote]See the User’s Guide chapter on ‘adding a class’: root.cern.ch/drupal/content/users-guide.

The short answer is that you need to add a custom rule to your visual studio project with generate a source file that will be compile as part of your library (I do no use visual studio and do not know the specific on how to do this). The custom rule need to execute something likerootcint -f mylibraryDict.cxx -c myheader1.h myheader2.h myLibraryLinkDef.hwhere myLibraryDict.cxx is the generated source file. ‘myheader1.h’ and ‘myheader2.h’ are your header file and myLibraryLinkDef.h is a file containing something like:#ifdef __MAKECINT__ #pragma link C++ class MyClass1+; #pragma link C++ class MyClass2+; #pragma link C++ vector<vector<Int_t> >+; #endif

Cheers,
Philippe.