Std::map in TTree with MakeClass

Hi, all.

I’m putting a std::map<std::string, int> into a TTree. I’m now trying to use this map by using MakeClass on the tree that contains the map.

But I’m not able to get the string value from the map. MakeClass seems to just grab the branches for the “first” and “second” pieces of the map separately and put them into arrays. I can look at the int values this way (second) but the strings don’t show up. I know the strings are in there because I can histogram them.

Is there any way I can simply assign a branch address in the MakeClass class for the map directly? I’ve tried something like:

map<std::string, int> *theMap; TBranch *b_theMap; fChain->SetBranchAddress("theMap", theMap, &b_theMap);

But I get a segfault.

Anybody know how to do this? Thanks.


The skeleton produced by MakeClass by default does not support any object. To be able to read std::map obejct, you need to comment out the statement SetMakeClass(1) … this will also means that you need to read al the objects via their complete form (and not their decomposed form as is the default in the skeleton produced by MakeClass).