Save vector of maps in TTree


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.

My ROOT version is 5.14/00, gcc version is 3.2.2

Can anybody explain me what I’m doing wrong?


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 };


Thank you, Philippe.
Your corrections were helpful. Now I can write and read the vector of maps… but still I get the same warning:

Attached is the revised code with vector< map<UInt_t, Float_t> > object added.
testmap.tar.gz (1.65 KB)


There is no vector in the example you sent me. I suspect you did not generate the dictionary for it…


I have added the new tarball in my post above.
(here: )

I do generate the dictionary:


This should be fixed shortly in the CVS repository. Note that it seems that it did not affect the actually I/O operation.