Closed A-A-Abdelhamid closed 1 year ago
import pyhepmc
from pyhepmc.view import savefig
filename = "tag_1_pythia8_events.hepmc"
# pyhepmc.open can read most HepMC formats using auto-detection
with pyhepmc.open(filename) as f:
# Loop over events in the file
for i, event in enumerate(f):
# Save a plot of the event
if event.event_number == 2493:
savefig(event, f"event{i}.svg")
savefig(event, f"event{i}.png")
savefig(event, f"event{i}.pdf")
for particle in event.particles:
if particle.id ==1261 and particle.pid==-13:
ver=particle.production_vertex
print(ver)
print(particle.parents)
print(particle.momentum)
print(event.event_number)
print(particle)
print(particle.momentum.pt())
print(particle.momentum.t)
print(particle.momentum.e)
GenVertex(FourVector(-0.0353, 0.123, -0.321, 0.458))
[GenParticle(FourVector(-0.621, 2.16, -5.65, 8.05), mass=5.27925, pid=521, status=2)]
FourVector(-0.715, -0.73, -2, 2.25)
2493
GenParticle(FourVector(-0.715, -0.73, -2, 2.25), mass=0.10566, pid=-13, status=1)
1.022190104761387
2.250687436210443
2.250687436210443
This is the code used to get muons with pt<= 20 GeV: