Fork me on GitHub

Opened 3 years ago

Closed 3 years ago

#1498 closed Enhancement (fixed)

interface to hepmc3

Reported by: lumeng Owned by:
Priority: minor Milestone:
Component: Delphes code Version: Delphes 3
Keywords: Cc:

Description

Dear experts,

I'm trying to interface pythia8 output to Delphes-3.4.2, the pythia8 is interfaced with hepmc323, it seems the format of hepmc323 doesn't fit to Delphes-3.4.2, do i understand correctly, if yes, which version of hepmc3 is compatible with Delphes-3.4.2?

Cheers,
Meng

Change History (5)

comment:1 by Bob Truijen, 3 years ago

Dear Delphes experts,

I'm experiencing the same problem as Meng mentioned. When trying to put hepmc3 event files from Pythia8 in Delphes-3.4.2, I get the error: invalid event format. Do you know how to fix this issue?

Kind regards,

Bob

comment:2 by Pavel Demin, 3 years ago

I think that the easiest solution at the moment is to convert HepMC3 to HepMC2.

It can be done with the following Python code:

import sys

from pyHepMC3 import HepMC3 as hm

if len(sys.argv) != 3:
  print(" Usage: converter.py input_file output_file")
  sys.exit(1)

reader3 = hm.ReaderAscii(sys.argv[1])
if reader3.failed():
  sys.exit(1)

writer2 = hm.WriterAsciiHepMC2(sys.argv[2])
if writer2.failed():
  sys.exit(2)

event = hm.GenEvent()
reader3.read_event(event)

while not reader3.failed():
  writer2.write_event(event)
  event.clear()
  reader3.read_event(event)

writer2.close()
reader3.close()
Last edited 3 years ago by Pavel Demin (previous) (diff)

in reply to:  2 comment:3 by Bob Truijen, 3 years ago

Thanks for the response. Indeed, switching to HepMC2 works fine.

Cheers,

Bob

Replying to pavel:

I think that the easiest solution at the moment is to convert HepMC3 to HepMC2.

It can be done with the following Python code:

import sys

from pyHepMC3 import HepMC3 as hm

if len(sys.argv) != 3:
  print(" Usage: converter.py input_file output_file")
  sys.exit(1)

reader3 = hm.ReaderAscii(sys.argv[1])
if reader3.failed():
  sys.exit(1)

writer2 = hm.WriterAsciiHepMC2(sys.argv[2])
if writer2.failed():
  sys.exit(2)

event = hm.GenEvent()
reader3.read_event(event)

while not reader3.failed():
  writer2.write_event(event)
  event.clear()
  reader3.read_event(event)

writer2.close()
reader3.close()

comment:4 by Pavel Demin, 3 years ago

The new release (3.5.0) contains the DelphesHepMC3 command that can read HepMC3 files.

comment:5 by Pavel Demin, 3 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.