A-A-Abdelhamid / LLP_Sleptons_RPV_SUSY

Here you can find MadGraph5 cards, diagrams, logs, plots, and code used in the project
2 stars 1 forks source link

For my own reference: getting muons with pt <= 20 GeV #3

Closed A-A-Abdelhamid closed 1 year ago

A-A-Abdelhamid commented 1 year ago

This is the code used to get muons with pt<= 20 GeV:

import matplotlib.pyplot as plt
import numpy as np
import pyhepmc as hep
import pyhepmc.io as ihep
import pyhepmc.view as vhep
import uproot
import ROOT
from collections import Counter

hepmc_file = "tag_1_pythia8_events.hepmc"

muons = []

with hep.open(hepmc_file) as f:
    # Loop over events in the file
    for event in f:
      for particle in event.particles:
        momentum =particle.momentum
        pt = momentum.pt()
        #All final status muons
        if particle.status == 1 and abs(particle.pid) == 13 and pt <=20:
          muons.append((particle.pid, particle.id, event.event_number))

print(muons)
A-A-Abdelhamid commented 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
A-A-Abdelhamid commented 1 year ago

event2493

A-A-Abdelhamid commented 1 year ago

Screenshot 2023-07-19 10 42 35 AM