You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there! Thanks for creating this easy-to-install alternative to building HepMC3.
I'm currently trying to use fill_genevent_from_hepevt to fill a blank GenEvent with some particles (I'm using numpythia to generate some events to be written to a HepMC3 file for Delphes usage, but I want to do some filtering before writing since HepMC3 files are very large and I'm not interested in most of the particles in each event).
However, I can't seem to get the filling of the GenEvent to work. Here's a minimal working example demonstrating the issue:
import numpy as np
import pyhepmc_ng as hep
evt = hep.GenEvent()
evt.clear()
print(evt) # Check how things look after calling "clear".
# Get some dummy data -- here, just a single particle.
event_number = 1
p = np.array([1.,1.,1.,4.]).reshape(1,-1)
m = np.array([1.])
v = np.array([1.,1.,1.,0.]).reshape(1,-1)
pid = np.array([5])
parents = np.array([1,1]).reshape(1,-1)
status = np.array([1])
hep.fill_genevent_from_hepevt(evt,
event_number = event_number,
p = p,
m = m,
v = v,
pid = pid,
parents = parents,
status = status
)
print(evt) # See if anything changed.
And this is what I get as output:
GenEvent: #0
Momentum units: GEV Position units: MM
Entries in this event: 0 vertices, 0 particles, 0 weights.
Position offset: 0, 0, 0, 0
GenParticle Legend
ID PDG ID ( px, py, pz, E ) Stat ProdVtx
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
GenEvent: #1
Momentum units: GEV Position units: MM
Entries in this event: 0 vertices, 0 particles, 0 weights.
Position offset: 0, 0, 0, 0
GenParticle Legend
ID PDG ID ( px, py, pz, E ) Stat ProdVtx
________________________________________________________________________
________________________________________________________________________
It looks like I am modifying the event_number (trying different numbers works as well), but there doesn't appear to be any information on the particle that I've tried to add.
I think the issue might lie with HEPEVT.to_genevent(), which is called at the end of fill_genevent_from_hepevt, as I tried calling this on a HEPEVT that I created (mimicking the global buffer) and similarly didn't see any particles added to the GenEvent I passed as an argument.
I see that GenEvent has methods for explicitly adding particles and vertices, which might let me circumvent this issue for now, but it would certainly be nice to have a vectorized approach instead of adding them on the Python side of things one-by-one (I also see that there is a 2nd unused version of fill_genevent_from_hepevt that does not call HEPEVT.to_genevent).
The text was updated successfully, but these errors were encountered:
Hi, this seems to be a bug that was introduced at some point in HepMC3. I am currently preparing a new version with the latest HepMC3 where this issue is fixed.
Hi there! Thanks for creating this easy-to-install alternative to building HepMC3.
I'm currently trying to use
fill_genevent_from_hepevt
to fill a blankGenEvent
with some particles (I'm using numpythia to generate some events to be written to a HepMC3 file for Delphes usage, but I want to do some filtering before writing since HepMC3 files are very large and I'm not interested in most of the particles in each event).However, I can't seem to get the filling of the
GenEvent
to work. Here's a minimal working example demonstrating the issue:And this is what I get as output:
It looks like I am modifying the
event_number
(trying different numbers works as well), but there doesn't appear to be any information on the particle that I've tried to add.I think the issue might lie with
HEPEVT.to_genevent()
, which is called at the end offill_genevent_from_hepevt
, as I tried calling this on aHEPEVT
that I created (mimicking the global buffer) and similarly didn't see any particles added to theGenEvent
I passed as an argument.I see that
GenEvent
has methods for explicitly adding particles and vertices, which might let me circumvent this issue for now, but it would certainly be nice to have a vectorized approach instead of adding them on the Python side of things one-by-one (I also see that there is a 2nd unused version offill_genevent_from_hepevt
that does not callHEPEVT.to_genevent
).The text was updated successfully, but these errors were encountered: