Hello everybody. Please don’t flame me if this in answered somewhere else, but I have been searching and trying for a few days now with no luck.
So let me give you the facts:
I am using Root 5.18 on ubuntu 8.04. I try to stick with the recommended stable release because I need to produce portable code.
I am developing something in C++ that uses the ROOT libraries for display, histogramming and output (TNtuples and now trying TTree).
So, I have a loop in the code that loops through a requested number of events.
Each event, produces many things, one of which is a vector of doubles: std::vector vec;
I want to make everything as simple as possible, so for other things I have 2-3 ntuples of variables that I fill per event.
I now want to create a TTree, independently of the other ntuples (i dont care about creating beautifully structured or efficient root files for the time being), that will hold (per event) the above vector.
As i see it, most likely, a leaf will be created for each event (Right or Wrong??)
For that, i do:
//Statistics.h
...
TTree *zTree;
...
//Statistics.cxx
...
zTree = new TTree("anDistr","Tree to hold the Zijk");
...
//and later at some point, code to write on the rootfile
//Reconstruction.cxx
std::vector<double> *vec = trigger.getZijk();
statistics->zTree->Branch("vec","vector<double>",&vec);
So. When i compile, everything is fine. TO be honest, I tried multiple ways to use Branch(), to find the way that works.
When I run, i get the error
[quote]Error in TTree::Branch: The class requested (vector) for the branch “vec” refer to an stl collection and do not have a compiled CollectionProxy. Please generate the dictionary for this class (vector)
[/quote]
I then created a dictionary like:
//loader.C
#include <vector>
#ifdef __MAKECINT__
#pragma link C++ class vector<double>+;
#endif
I compile it with ACLiC, and the .so file is created. I get the warning about already linked class and I ignore it. Actualy, the warning gave me the idea to use the full stl name in Branch() instead of the template “vector” -> “vector<double,allocator >” with no luck.
And since I don’t do anything with the so file, the same errors appear: need for a dictionary, no TTree in the rootfile.
Do i have to link the .so somehow? And will this make my code less portable?
Please remember that I am referring to C++ compiled code.
Finally, if someone has a better way to solve my problem (storing a set of doubles PER event), please help.
Once again sorry for the long post.