Home | News | Documentation | Download

HepMC to root

Hi,

I have produced a HepMC File (from MC Generator Herwig++).
Now I want to convert it into a root file.
I have HepMC and root 5.18 installed on my notebook .
Do you have any ideas how can I do this?

Thanks!
Gordon

In attachment you can find an example. Do

tar zxvf hepmc.tar.gz
cd test
./go
./writeEvt
./readEvt

You can find the ascii data file (85 MB) at https://root.cern.ch/files/events.hepmc

Rene

hepmc.tar.gz (1.58 KB)

Hi,

thanks for answer.
BTW there is write error (?) in readEvt.cc, line 14 :

tfIle *fi = TFile::Open(“hepmc.root”);

Gordon :smiley:

What do you mean?
Rene

Hi,

I followed your instructions and have produced a root.file.
Unfortunatly the root file is empty…
Do you have any ideas what could be the reason…?

Concerning the “bug” I mentioned:
When I make “tar zxvf hepmc.tar.gz” then I get the readEvt.cc with the line

tfIle *fi = TFile::Open(“hepmc.root”); which crashes with ./go:

readEvt.cc:14: Error: »tfIle« was not defined

Cheers,
Gordon

You must create the file first with writeEvt

Rene

Hi,

when I make “writeEvt” I get the following output:


GenEvent: #0 ID=0 SignalProcessGenVertex Barcode: 0
Entries this event: 1 vertices, 1 particles.
Beam Particles are not defined.
RndmState(0)=
Wgts(0)=
EventScale -1 [energy] alphaQCD=-1 alphaQED=-1
GenParticle Legend
Barcode PDG ID ( Px, Py, Pz, E ) Stat DecayVtx


GenVertex: -1 ID: 0 (X,cT):0
O: 1 10001 99 +1.00e+01,+2.00e+01,+3.00e+01,+4.00e+01 0



Use of HepMC/IO_Ascii is deprecated

IO_Ascii::fill_next_event start key not found setting badbit.


*Tree :T : test *
*Entries : 0 : Total = 942 bytes File Size = 0 *

  •    :          : Tree compression factor =   1.00                       *
    

*Br 0 :event : *
*Entries : 0 : Total Size= 624 bytes One basket in memory *
*Baskets : 0 : Basket Size= 256000 bytes Compression= 1.00 *

After readEvt the root file is still empty

Cheers,
Gordon

well, it looks like they deprectaed the ascii read mode in your version of HepMC.
replace this example by the equivalent with your version, generating one event.
The creation/filling of the ROOT Tree should ve the same.
With my version of hepMC, I get the following output when running writeEvt

code [537] writeEvt


GenEvent: #0 ID=0 SignalProcessGenVertex Barcode: 0
Current Memory Usage: 1 events, 1 vertices, 1 particles.
Entries this event: 1 vertices, 1 particles.
Beam Particles are not defined.
RndmState(0)=
Wgts(0)=
EventScale -1 [energy] alphaQCD=-1 alphaQED=-1
GenParticle Legend
Barcode PDG ID ( Px, Py, Pz, E ) Stat DecayVtx


GenVertex: -1 ID: 0 (X,cT):0
O: 1 10001 99 +1.00e+01,+2.00e+01,+3.00e+01,+4.00e+01 0


Event #1:

Event #101:

Event #201:

Event #301:

Event #401:

Event #501:

Event #601:

Event #701:

Event #801:

Event #901:


*Tree :T : test *
*Entries : 1000 : Total = 144325021 bytes File Size = 49875738 *

  •    :          : Tree compression factor =   2.89                       *
    

*Br 0 :event : *
*Entries : 1000 : Total Size= 144327784 bytes File Size = 49870878 *
*Baskets : 666 : Basket Size= 256000 bytes Compression= 2.89 *

[/code]

Rene

Hi,

actually it was a hepmc file produced with my HepMC…

There is one thing I have to mention:
In the Classes.h I had uncommented the HepMC/ParticleComparison otherwise it crashes with the command ./go:

./Classes.h:10:41: error: HepMC/GenParticleComparison.h: No such file or directory

It would seem this class is not available in my HepMC version…
Which HepMC version do you have?

Cheers,
Gordon

for these tests, I was using HepMC-2.01.08

Rene

I am afraid to report that this code doesn’t compile on Mac OS X with the mentioned 2.01.8 version, which actually doesn’t contain GenParticleComparison.h.
Is there something to be changed to make this hepmc2root converto compile?
Thanks.
Roberto

see HepMC support

Rene

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