Problem using std::map and "second()" in TREE

Dear ROOTers,

I am filling a class to a ROOT Tree that is circular. It is written into a TMapFile, under linux using root 5.24.00b self compiled libraries with 64 bit architecture.
The class, that contains a std::map

class MachineDataEvent { public: MachineDataEvent() {} ~MachineDataEvent(){} public: typedef std::map<std::string,double> EpicsDataMap; const EpicsDataMap& EpicsData()const {return _epicsdata;} EpicsDataMap& EpicsData() {return _epicsdata;} private: EpicsDataMap _epicsdata;//a map ClassDefNV(MachineDataEvent,1) //A Container };
is stored in a branch without splitting.

To compile the code I am using the following LinkDef.h

#include <map> #include <string> #ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class map<std::string,double>; #pragma link C++ defined_in "machine_event.h"; #pragma link C++ class MachineDataEvent; #endif The dictionary is created using the following line

I am now trying to read the map values from a root session (rootn.exe) using the following code in a interpreted macro

EpicsDataMap::iterator ito; entries=(Int_t)T->GetEntries(); for(Int_t entry=0;entry<entries;entry++) { T->GetEntry(entry); printf("mach %i\n",MachineEventBranch->EpicsData().size()); for( ito=MachineEventBranch->EpicsData().begin(); ito!=MachineEventBranch->EpicsData().end();ito++) { std::cout << (*ito).first << " is " << (*ito).second << std::endl; } }
root does not give any kind of error. The standard out shows only reasonable value for “first” but the value of “second” is always zero where it was non zero in the original map.
Also all the other member functions like begin(), end(), size() are returning what is expected.

Do you have any idea of what the problem could be?

Thank you!
Best Regards,


could you compile the reading part (e.g. with Aclic, doing .x macro.C+ instead of .x macro.C)? Does it still fail to print reasonable values for “second”?

Cheers, Axel.

Hi Axel,

thanks for the suggestion. Yes I could compile the macro using ACLIC without problem. But the output doesn’t change. Meaning I still get only zeros where I know that there are non zero values in the original map.

Should there be any problem using a std::map<std::string, double> in a tree?

Thank you,


Did you try with a linkdef containing:#pragma link C++ class MachineDataEvent+; If you did, then there is a problem we are not spotting, could you send a complete running example?

[quote]Should there be any problem using a std::map<std::string, double> in a tree? [/quote]No there should not be.