Hello everydoy,
I am trying to store a matrix into a TTree but I get the follwoing problem with Branch
“Error in TTree::Branch: The pointer specified for matrice is not of a class or type known to ROOT”
This is kind of weired because I can use STL vectors, but not vectors of vectors …
TFile *f = TFile::Open(jetfilename, "RECREATE");
if (!f) {
puts("file non trovato");
exit(0);
}
std::vector<float> vpx;
std::vector<float> vpy;
std::vector<float> vpz;
std::vector<float> vrand;
std::vector<vector<float> > matrix;
// Create a TTree
TTree *t = new TTree("tvec", "Tree with vectors");
t->Branch("vpx", &vpx);
t->Branch("vpy", &vpy);
t->Branch("vpz", &vpz);
t->Branch("vrand", &vrand);
/******* the following addition of a Branch gives the error *****/
t->Branch("matrice", &matrix);
Notice I have the following line of code
gROOT->ProcessLine("#include <vector>");
placed before what the part where I add the branch. This line is crucial to not get a similar error for vector variables such as the vpx used in the above code, but I have no idea how to change it to allow also nested vectors.
[quote]Thanks a lot for answering and suggesting building a dictionary (whatever does it mean).[/quote]Please re-read the User’s Guide which explain what a dictionary is in the context of ROOT, your symptoms indicates that you have not generated the dictionary (or not compiled it or not linked it or not loaded it, all four steps are necessary).
Now I think I know how to use it for the compilation and linking, I hope, but the loading part you are referring to … what you meant? Should I have something in the code? I am getting confused …
thanks for replying
your line seems to do the same of adding the .so to list of files to be used in g++
as in
gcc -o bbar.exe bbar.cpp mylib.so
now it does not complain any longer of the unknown type. never the less it seems the content is not properly understood.
I have to go deeper to see what’s in the file.
For the moment many thanks.
Roberto