HepMC to root

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