Skip to content

Commit

Permalink
no interactive plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariana Vivas authored and Mariana Vivas committed Nov 4, 2024
1 parent a76da69 commit 33ff70e
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions utils_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

def get_darklight_plot(plot,theme):
if theme and theme.get("base") == "dark":
return f"images/interactive/lepton_{plot}_dark.html"
return f"images/lepton_{plot}_dark.png"
else:
return f"images/interactive/lepton_{plot}_light.html"
return f"images/lepton_{plot}_light.png"

def load_mc_data():
# Load MC mass and weights from pickle files
Expand Down Expand Up @@ -122,27 +122,14 @@ def lepton_charge_cut(lep_charge, n_leptons, cut):

def invariant_mass(pt, eta, phi, E, n_leptons):
p4 = vector.zip({"pt": pt, "eta": eta, "phi": phi, "E": E})
try:
if n_leptons == 2:
mass = (p4[:, 0] + p4[:, 1]).M
elif n_leptons == 3:
mass = (p4[:, 0] + p4[:, 1] + p4[:, 2]).M
elif n_leptons == 4:
mass = (p4[:, 0] + p4[:, 1] + p4[:, 2] + p4[:, 3]).M
elif n_leptons == 5:
mass = (p4[:, 0] + p4[:, 1] + p4[:, 2] + p4[:, 3]+ + p4[:, 4]).M

except IndexError as e:
# If there is an index error, print the event causing the issue
st.write(f"IndexError: {str(e)}")
st.write("Event causing the error:")
st.write("pt:", pt)
st.write("eta:", eta)
st.write("phi:", phi)
st.write("E:", E)
st.write(f"Number of leptons expected: {n_leptons}")
st.write(f"Lepton count in this event: {ak.num(pt)}")
raise # Re-raise the exception so it still halts execution
if n_leptons == 2:
mass = (p4[:, 0] + p4[:, 1]).M
elif n_leptons == 3:
mass = (p4[:, 0] + p4[:, 1] + p4[:, 2]).M
elif n_leptons == 4:
mass = (p4[:, 0] + p4[:, 1] + p4[:, 2] + p4[:, 3]).M
elif n_leptons == 5:
mass = (p4[:, 0] + p4[:, 1] + p4[:, 2] + p4[:, 3]+ + p4[:, 4]).M

return mass

Expand Down

0 comments on commit 33ff70e

Please sign in to comment.