TTree.Fill() crashes when using HepMC::GenEvent, Dict prb?

I am trying to generate a TTree with a HepMC::GenEvent branch in my application. However it crashes with “Program received signal SIGBUS, Bus error”
0x00007ffff4a78701 in TEmulatedMapProxy::WriteMap(int, TBuffer&) () from /opt/root/lib/root/
This is a standalone application so I created a dictionary with

rootcint -f  HepMCDict.cxx -c -I$(HEPMC_PATH)/include/  $(HEPMC_PATH)/include/HepMC/*.h hepmc_linkdef.h
$(CC) $(CXXFLAGS) -I$(HEPMC_PATH)/include/ $(ROOTFLAGS) -L$(HEPMC_PATH)/lib/ -lHepMC  -shared -o HepMCDict.cxx

where ROOTFLAGS=$(root-config --cflags), and linked this into my application.
Then in my code I set the branch with

  HepMC::GenEvent *m_myEvent=new HepMC::GenEvent();
  TTree* m_myTree=new TTree("hepMCTree","A simple tree containing HepMC::GenEvent's. load to use");

Then I construct m_myEvent and the code crashes when I call m_myTree->Fill();
I checked m_myEvent and it is a valid HepMC::GenEvent. I also tried adding the branch with


without any change
I attached the hepmc_linkdef file. I tried it with and without “using namespace HepMC;” as well as with and without #include statements.

I am using root version 5.30. and according the posts and the example in this forum, it should work.

Can somebody tell me if I am making a mistake in dictionary generation or somewhere else?

hepmc_linkdef.h (2.06 KB)

[quote]0x00007ffff4a78701 in TEmulatedMapProxy::WriteMap(int, TBuffer&) () from [/quote]The fact that it use s the emulatedMapProxy indicates that somehow it is missing at least the dictionary for one of the std::map used in HepMC. I think that there is now a supported (by HepMC) way of generating the dictionary (i.e. at the very least an official linkdef file), did you start from that?

Did you compile, link and load the result of rootcint.cxx?


Hi Philippe,

I couldn’t be able to find official HepMC linkdef file. I saw it mentioned but it seems that it is not there yet. I am using HepMC-2.06.05 and it doesn’t seem to contain any linkdef file. Just to be sure I did another search on the internet and failed to find anything again. A grep -ir "#pragma " in source folder also doesn’t return anything. Do you know where can I find it?

I do

rootcint -f  HepMCDict.cxx -c -I$(HEPMC_PATH)/include/  $(HEPMC_PATH)/include/HepMC/*.h hepmc_linkdef.h

which creates HepMCDict.cxx and HepMCDict.h files. I compile them with

$(CC) $(CXXFLAGS) -I$(HEPMC_PATH)/include/ $(ROOTFLAGS) -L$(HEPMC_PATH)/lib/ -lHepMC  -shared -o HepMCDict.cxx

creating and then I link it with my program. Isn’t that the correct approach?

I added pragma statements for all std:map types and std::pair types that are used in the HepMC sources to linkdef file and it is still failing with

#0  0x00007ffff4a78701 in TEmulatedMapProxy::WriteMap(int, TBuffer&) () from /opt/root/lib/root/

I attached the uploaded linkdef file. Do you have any idea why could this be happening? If needed I can provide a stack trace, unfortunately without debug symbols.

hepmc_linkdef.h (2.83 KB)

Actually I noticed a strange problem. My first call to TTree->Fill() seems to work. It is crashing in the second call.

Hi Sami,

CINT is sometimes peculiar about the naming of std classes. In this particular
case, in order to get the right dictionary, you need:

#ifdef CINT
typedef long size_type; // make sure size_type is defined

#pragma link C++ class std::map<string,size_type>+;

where the string class is mentioned without its std::

With those 2 modification I am able to run your example without a problem.