I’m trying to save the following construction in TTee:
As far as I understand, I need to generate a dictionary for this class, so I put
#pragma link C++ class pair<UInt_t, Float_t>;
#pragma link C++ class map<UInt_t, Float_t>;
#pragma link C++ class vector< map <UInt_t, Float_t> >
in LinkDef.h
The program successfully compiles, but when I’m writting the .root file, I get the following message:
[quote]Warning in TStreamerSTL::TStreamerSTL: For vector<map<UInt_t,Float_t> > we could not find any information about the type unsigned int,float> > >[/quote] and cannot access the elements of this vector.
At the same time, if I save by the save way vector in a .root tree, everything works fine.
Maybe the dictionary you generated was not loaded in your processed?
Did you link against it? If you did, then I will need a complete example reproducing the issue.
I have realized that I am not even able to save std::map in a .root file. Attached ([color=darkred]removed, see below[/color]) is a simple example. Type make to compile it and ./testmap to run it. The program fills a tree in a .root file, and then reads it. The text output shows that there is no problem to save and read an std::pair object, but there is a problem with std::map object (I can’t read the values of fMap). Maybe I’m doing something wrong?
You main issue is the line:TTree::SetBranchStyle(2);The branch style support are 0 and 1. Anything else revert to 0 which does not support STL containers.
Also in your linkdef file I recommend to request the ‘new’ I/O style by appending a ‘+’ to the class name:
#pragma link C++ class pair<UInt_t, Float_t>+;
#pragma link C++ class map<UInt_t, Float_t>+;
#pragma link C++ class A+;
Lastly you have:ClassDef(A,0); // class A
};A class version of ‘0’ indicates that you do no intent to save those object. You should replace is with ClassDef(A,1); // class A
};