HepMC to root

Dear Brun,
I try to downland hepmc.tar.gz file but I don’t get the correct file as you have update.

Can you send me the file please

Due to some bug in the ROOT forum’s software, you need to rename the downloaded file:

mv 6a9faa97d1509fb67280a74565e41a738d8c5fa6.gz hepmc.tar.gz

Dear Rene,
I install and compile HepMC-2.06.09 without any problem and try to run ./go. There are few problems about the old files in Classes.h that do not exist any more. I comment the lines, but then I get a long error. The main part that repeats for different places is:

epMCDict.cxx: In function 'int G__HepMCDict_483_0_25(G__value*, const char*, G__param*, int)':
HepMCDict.cxx:3010:44: error: variable 'HepMC::GenParticleProductionRange xobj' has initializer but incomplete type
HepMCDict.cxx:3010:154: error: invalid use of incomplete type 'class HepMC::GenParticleProductionRange'
In file included from /home/paktinat/HepMC/HepMC-2.06.09/install/include/HepMC/GenEvent.h:127:0,
                 from Classes.h:2,
                 from HepMCDict.h:34,
                 from HepMCDict.cxx:17:
/home/paktinat/HepMC/HepMC-2.06.09/install/include/HepMC/GenVertex.h:37:11: error: forward declaration of 'class HepMC::GenParticleProductionRange'
HepMCDict.cxx:3011:59: error: invalid use of incomplete type 'class HepMC::GenParticleProductionRange'
.....

Since HepMC is built and installed without any error message, I guess the problem is from ‘go’ file. I set up the environment for ROOT 5.32.00.
Can you please help me to fix this issue?
Thanks,
Saeid

I do not know HepMC but if you comment include files that’s not surprising you get errors afterwards. As it was suggested earlier may be you should contact the HepMC support.

Sorry to bother you again,
I managed to run ./go and make writeEvt. If I comment the TTree::Fill command the program works fine. It can even print the events properly, but when TTree::Fill is called it crashes with a long printout.

StreamerInfoAction, class:HepMC::GenEvent, name=m_signal_process_id, fType[0]=23, TStreamerBasicType, bufpos=69, arr=0x1eecdf0, offset=0
WriteBuffer, class:HepMC::GenEvent, name=m_signal_process_id, fType[0]=23, TStreamerBasicType, bufpos=69, arr=0x1eecdf0, offset=8
....
StreamerInfoAction, class:HepMC::GenEvent, name=m_momentum_unit, fType[12]=23, TStreamerBasicType, bufpos=1603, arr=0x1eecdf0, offset=0
WriteBuffer, class:HepMC::GenEvent, name=m_momentum_unit, fType[12]=23, TStreamerBasicType, bufpos=1603, arr=0x1eecdf0, offset=288
TTree::Fill - A:  1542 1 -30000000 -300000000 0 0 0 
.......
#5  0x00007fd61cc13631 in TEmulatedMapProxy::WriteMap(int, TBuffer&) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc472/cms/cmssw/CMSSW_5_3_32/external/slc6_amd64_gcc472/lib/libRIO.so
#6  0x00007fd61cc1394b in TEmulatedMapProxy::Streamer(TBuffer&) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc472/cms/cmssw/CMSSW_5_3_32/external/slc6_amd64_gcc472/lib/libRIO.so
#7  0x00007fd61cc08406 in TCollectionStreamer::Streamer(TBuffer&, void*, int, TClass*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc472/cms/cmssw/CMSSW_5_3_32/external/slc6_amd64_gcc472/lib/libRIO.so
#8  0x00007fd61cc03d39 in TBufferFile::WriteFastArray(void*, TClass const*, int, TMemberStreamer*) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc472/cms/cmssw/CMSSW_5_3_32/external/slc6_amd64_gcc472/lib/libRIO.so
#9  0x00007fd61ccd3cad in int TStreamerInfo::WriteBufferAux<char**>(TBuffer&, char** const&, int, int, int, int) () from /cvmfs/cms.cern.ch/slc6_amd64_gcc472/cms/cmssw/CMSSW_5_3_32/external/slc6_amd64_gcc472/lib/libRIO.so

Thank you in advance for your help.
Saeid

As it seems related to TTree, I guess @pcanal may help you. Note that it would be nice to have a “reproducer” for this problem. It is difficult to understand what’s going wrong with only the few trace back you sent. Also you mentioned you are using ROOT version 5.32. That’s a very old version of ROOT.

test.tar.gz (1.9 KB)

Thank you for your prompt reply. I attach the tar ball of the code here. Regards,
Saeid

Hi again, I update my ROOT to 6.12/06 and change ‘go’ file by adding ‘-std=c++11’ as the compiler argument. I also remove the Cint Cintex and Reflex libraries from the compilation argument.
Now the code gives the same warnings and print outs, but without “segmentation violation”. The size of the root file shows it is filled. When I try to look at it by TBrowser, I see the following warnings and and clicking on the branches, it gives “segmentation violation”.

Warning in <TStreamerInfo::Build>: HepMC::GenEvent::vertex_const_iterator: base class iterator<forward_iterator_tag,HepMC::GenVertex*,long,HepMC::GenVertex**,HepMC::GenVertex*&> has no streamer or dictionary it will not be saved
Warning in <TStreamerInfo::Build>: HepMC::GenEvent::vertex_const_iterator: _Rb_tree_const_iterator<pair<const int,HepMC::GenVertex*> > has no streamer or dictionary, data member "m_map_iterator" will not be saved
Warning in <TStreamerInfo::Build>: HepMC::GenEvent::particle_const_iterator: base class iterator<forward_iterator_tag,HepMC::GenParticle*,long,HepMC::GenParticle**,HepMC::GenParticle*&> has no streamer or dictionary it will not be saved
Warning in <TStreamerInfo::Build>: HepMC::GenEvent::particle_const_iterator: _Rb_tree_const_iterator<pair<const int,HepMC::GenParticle*> > has no streamer or dictionary, data member "m_map_iterator" will not be saved

Thank you in advance for your help.
Saeid

Hello experts,
Could I ask you to make a comment on this issue?
Thanks,
Saeid

When I execute the script “go” i get plenty of errors.

Can you try with ROOT v6?

Hi,
just in case someone needs to solve the same problem, HepMC3
http://hepmc.web.cern.ch/hepmc/
has a ConvertExample utility HepMC->ROOT in examples.
Andrii

Hello experts,
I have produced a HepMC File (from MC Generator Herwig 7.2.2).
Now I want to convert it into a root file.
I have downloaded the hepmc.tar.gz file attached above by Brun. But when I did run ./go, I got the following error

In file included from /tmp/rootcint_CYxQNg.h:3:0,
                 from /tmp/MtXyZc_cint.cxx:1:
./Classes.h:1:10: fatal error: HepMC/SimpleVector.h: No such file or directory
 #include "HepMC/SimpleVector.h"
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Error: external preprocessing failed. :0:
!!!Removing HepMCDict.cxx HepMCDict.h !!!
Error: rootcint: error loading headers...
g++: error: HepMCDict.cxx: No such file or directory
g++: fatal error: no input files
compilation terminated.
g++: error: HepMCDict.o: No such file or directory
g++: error: /home/ehep4/eventGen/HepMC/HepMC3-3.2.4/lib/libHepMC.a: No such file or directory
writeEvt.cc:9:10: fatal error: HepMC/GenEvent.h: No such file or directory
 #include "HepMC/GenEvent.h"
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
gcc: error: libClassesDict.so: No such file or directory

Someone could please help me in this. Thanking you in advance
Regards,
Dibakar

You need to install the development package for HepMC, e.g.: sudo apt-get install libhepmc-dev

Thanks, Wile for the response, I have installed the development package by ( sudo apt-get install libhepmc-dev), But still having the issue. Now the error follows

In file included from /tmp/rootcint_PulLdV.h:3:0,
                 from /tmp/nkm6dk_cint.cxx:1:
./Classes.h:6:10: fatal error: HepMC/ParticleData.h: No such file or directory
 #include "HepMC/ParticleData.h"
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Error: external preprocessing failed. :0:
!!!Removing HepMCDict.cxx HepMCDict.h !!!
Error: rootcint: error loading headers...
g++: error: HepMCDict.cxx: No such file or directory
g++: fatal error: no input files
compilation terminated.
g++: error: HepMCDict.o: No such file or directory
g++: error: /home/ehep4/eventGen/HepMC/HepMC3-3.2.4/lib/libHepMC.a: No such file or directory
writeEvt.cc:12:10: fatal error: HepMC/IO_Ascii.h: No such file or directory
 #include "HepMC/IO_Ascii.h"
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
gcc: error: libClassesDict.so: No such file or directory

Do I need to install any other packages?

It seems to me that the source code present in the hepmc.tar.gz archive (in this thread) is quite outdated (tested with an ancient HepMC 2.01).

There is a slightly “improved” version in the test.tar.gz archive (also in this thread), which may possibly work better with the “libhepmc-dev” package (which provides some old HepMC 2.06 version, I think).

However, I guess the best idea is to follow the advice given here:

Thanks Wile, But now I got this below error. Is this some c++ error or any kind of error in the macro provided here in the tar file?

Error: class,struct,union or type decltype(nullptr) not defined  /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:235:
Error: unrecognized language construct /usr/include/c++/7/bits/atomic_base.h:162:
Error: Symbol default is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:162:
Error: unrecognized language construct /usr/include/c++/7/bits/atomic_base.h:163:
Error: Symbol default is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:163:
Error: Symbol delete is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:164:
Error: Symbol delete is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:165:
Error: unrecognized language construct /usr/include/c++/7/bits/atomic_base.h:166:
Error: Symbol delete is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:166:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:181:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:198:
Error: Invalid type 'constexpr' in declaration of 'bool value' /usr/include/c++/7/type_traits:71:
Error: no such template constexpr bool integral_constant<bool,1> /usr/include/c++/7/type_traits:84:
Error: Symbol value is not defined in current scope  /usr/include/c++/7/type_traits:84:
Error: Invalid type 'constexpr' in declaration of 'bool value' /usr/include/c++/7/type_traits:71:
Error: no such template constexpr bool integral_constant<bool,0> /usr/include/c++/7/type_traits:84:
Error: Symbol value is not defined in current scope  /usr/include/c++/7/type_traits:84:
Error: Symbol integral_constant<bool is not defined in current scope  /usr/include/c++/7/type_traits:93:
Syntax Error: 1> /usr/include/c++/7/type_traits:93:
Error: Symbol integral_constant<bool is not defined in current scope  /usr/include/c++/7/type_traits:93:
Syntax Error: 0> /usr/include/c++/7/type_traits:93:
Error: Template class template not defined /usr/include/c++/7/type_traits:792:
Error: Template class template not defined /usr/include/c++/7/type_traits:840:
Error: Template class template not defined /usr/include/c++/7/type_traits:883:
Error: class,struct,union or type ... not defined  /usr/include/c++/7/type_traits:943:
Internal error: global function template arg type /usr/include/c++/7/type_traits:943:
Error: class,struct,union or type ... not defined  /usr/include/c++/7/type_traits:977:
Internal error: global function template arg type /usr/include/c++/7/type_traits:977:
Error: class,struct,union or type ... not defined  /usr/include/c++/7/type_traits:1094:
Internal error: global function template arg type /usr/include/c++/7/type_traits:1094:
Internal error: global function template arg type /usr/include/c++/7/type_traits:1381:
Error: class,struct,union or type __int128 not defined  /usr/include/c++/7/type_traits:1871:
Error: class,struct,union or type ... not defined  /usr/include/c++/7/type_traits:2187:
Internal error: global function template arg type /usr/include/c++/7/type_traits:2187:
Error: Template class template not defined /usr/include/c++/7/type_traits:2204:
Error: Template class template not defined /usr/include/c++/7/type_traits:2290:
Error: Template class template not defined /usr/include/c++/7/type_traits:2309:
Error: class,struct,union or type ... not defined  /usr/include/c++/7/type_traits:2327:
Internal error: global function template arg type /usr/include/c++/7/type_traits:2327:
Error: class,struct,union or type ... not defined  /usr/include/c++/7/type_traits:2346:
Internal error: global function template arg type /usr/include/c++/7/type_traits:2346:
Error: Template class template not defined /usr/include/c++/7/type_traits:2433:
Error: Template class template not defined /usr/include/c++/7/type_traits:3109:
Error: Symbol bool is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:244:
Error: Function alignof(bool) is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:244:
Error: Invalid type 'constexpr' in declaration of 'int _S_alignment' /usr/include/c++/7/bits/atomic_base.h:244:
Syntax error /usr/include/c++/7/bits/atomic_base.h:246:
Error: unrecognized language construct /usr/include/c++/7/bits/atomic_base.h:246:
Error: unrecognized language construct /usr/include/c++/7/bits/atomic_base.h:249:
Error: Symbol default is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:249:
Error: unrecognized language construct /usr/include/c++/7/bits/atomic_base.h:250:
Error: Symbol default is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:250:
Error: Symbol delete is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:251:
Error: Symbol delete is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:252:
Error: unrecognized language construct /usr/include/c++/7/bits/atomic_base.h:253:
Error: Symbol delete is not defined in current scope  /usr/include/c++/7/bits/atomic_base.h:253:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:380:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:401:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:420:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:462:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:506:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:519:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:529:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:539:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:549:
Error: Redefinition of default argument /usr/include/c++/7/bits/atomic_base.h:559:
Error: abstract class object '__atomic_base<bool> _M_base' declared /usr/include/c++/7/atomic:66:
Error: unrecognized language construct /usr/include/c++/7/atomic:69:
Error: Symbol default is not defined in current scope  /usr/include/c++/7/atomic:69:
Error: unrecognized language construct /usr/include/c++/7/atomic:70:
Error: Symbol default is not defined in current scope  /usr/include/c++/7/atomic:70:
Error: Symbol delete is not defined in current scope  /usr/include/c++/7/atomic:71:
Error: Symbol delete is not defined in current scope  /usr/include/c++/7/atomic:72:
Error: unrecognized language construct /usr/include/c++/7/atomic:73:
Error: Symbol delete is not defined in current scope  /usr/include/c++/7/atomic:73:
Error: Redefinition of default argument /usr/include/c++/7/atomic:107:
Error: Redefinition of default argument /usr/include/c++/7/atomic:115:
Error: Redefinition of default argument /usr/include/c++/7/atomic:124:
Error: Redefinition of default argument /usr/include/c++/7/atomic:144:
Error: Redefinition of default argument /usr/include/c++/7/atomic:164:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Missing one of ' 	
;:=+-)(*&^%$#@!~'"\|][}{/?.>,<' expected at or after line 23221.
Error: Unexpected end of file (G__fgetstream():2) /usr/include/c++/7/atomic:23221:
Error: Unexpected end of file (G__fgetc()) /usr/include/c++/7/atomic:23221:
In file included from HepMCDict.h:32:0,
                 from HepMCDict.cxx:7:
/tmp/rootcint_I9rfGu.h:3:10: fatal error: Classes.h: No such file or directory
 #include <Classes.h>
          ^~~~~~~~~~~
compilation terminated.
gcc: error: HepMCDict.o: No such file or directory
gcc: error: /home/ehep4/eventGen/HepMC/HepMC3-3.2.4/lib/libHepMC.so: No such file or directory
/tmp/ccGEIVEJ.o: In function `main':
/home/ehep4/eventGen/HERWIG/docker/MBfirstRun/test1/writeEvt.cc:36: undefined reference to `HepMC::IO_GenEvent::IO_GenEvent(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::_Ios_Openmode)'
collect2: error: ld returned 1 exit status

Hi @Dibakar.cern ,

The HepMC 2 is not in active development since some years.
Please look at the installation instructions of HEPMC3 here
HepMC / HepMC3 · GitLab and select the installation procedure that fits your goal best.

The “conversion” code is located in the examples/ConvertExample directory.
The code compiles into utility that can be used to convert between different event formats, ROOT TTRee included.

Best regards,

Andrii

1 Like

Thanks, Andrii,
I found the macro in the examples/ConvertExample directory. I have followed the readme-file provided in GitHub and the published paper from HepMC official site. I am a newbie and could not find any supporting documents for run the macro. Could you please give me any link for the documentation?

Regards,
Dibakar

Hi @Dibakar.cern ,

That is not a macro, but couple of C++ sources which one should compile to an executable using the provided cmake files.
The resulting executable (convert_example.exe) then do the job. The compilation process of examples is described in documentation in the Examples section.
The “documentation” of the executable can be seen with with convert_example.exe --help

BEst regards,

Andrii