Skip to content
Snippets Groups Projects

fanjie/run3_Lb2LcDKpi

Closed Fanjie Meng requested to merge fanjie/run3_Lb2LcDKpi into master
1 unresolved thread
6 files
+ 716
0
Compare changes
  • Side-by-side
  • Inline
Files
6
import pandas as pd
import numpy as np
particle_dict = {"Lambda_b0": {"abbr": "Lb", "type": "toplevel", "daughters":[]},
"Xi_b-": {"abbr": "Xibm", "type": "toplevel", "daughters":[]},
"Xi_b0": {"abbr": "Xib0", "type": "toplevel", "daughters":[]},
"B0": {"abbr": "B0", "type": "toplevel", "daughters":[]},
"B+": {"abbr": "Bp", "type": "toplevel", "daughters":[]},
"B-": {"abbr": "Bm", "type": "toplevel", "daughters":[]},
"B_s0": {"abbr": "Bs", "type": "toplevel", "daughters":[]},
"J/psi(1S)": {"abbr": "Jpsi", "type": "composite", "daughters": ["mu+", "mu-"]},
"psi(2S)": {"abbr": "psi2S", "type": "composite", "daughters": ["mu+", "mu-"]},
"phi(1020)": {"abbr": "phi", "type": "composite", "daughters": ["K+", "K-"]},
"Lambda0": {"abbr": "Lambda", "type": "composite", "daughters": ["p+", "pi-"]},
"Lambda~0": {"abbr": "Lambda", "type": "composite", "daughters": ["p~-", "pi+"]},
"mu+": {"abbr": "mup", "type": "basic", "daughters":[]},
"mu-": {"abbr": "mum", "type": "basic", "daughters":[]},
"e+": {"abbr": "ep", "type": "basic", "daughters":[]},
"e-": {"abbr": "em", "type": "basic", "daughters":[]},
"pi+": {"abbr": "Pip", "type": "basic", "daughters":[]},
"pi-": {"abbr": "Pim", "type": "basic", "daughters":[]},
"K+": {"abbr": "Kp", "type": "basic", "daughters":[]},
"K-": {"abbr": "Km", "type": "basic", "daughters":[]},
"p+": {"abbr": "Pp", "type": "basic", "daughters":[]},
"p~-": {"abbr": "Pm", "type": "basic", "daughters":[]},
}
particle_df = pd.DataFrame(particle_dict).T
def descriptor(particles, cc=False):
decay_descriptor = f"{particles[0]} ->"
for particle in particles[1:]:
decay_descriptor += f" {particle}"
if cc: decay_descriptor = f"[{decay_descriptor}]cc"
return decay_descriptor
def decay_branches(mother, daughters, decay_descriptor):
psi_pos = 0
phi_pos = 0
Lambda_pos = 0
Pm_pos = Pp_pos = 0
Km_pos = Kp_pos = 0
Pim_pos = Pip_pos = 0
mum_pos = mup_pos = 0
em_pos = ep_pos = 0
#if decay_descriptor[0] == "[" or decay_descriptor[-3:] == "]cc":
if "cc" in decay_descriptor[-5:]:
branch_descriptor = decay_descriptor[:-2] + "CC"
else: branch_descriptor = decay_descriptor
#if "J/psi(1S)" in decay_descriptor:
# branch_descriptor = branch_descriptor.replace("J/psi(1S)", "(J/psi(1S) -> mu+ mu-)")
#if "psi(2S)" in decay_descriptor:
# branch_descriptor = branch_descriptor.replace("psi(2S)", "(psi(2S) -> mu+ mu-)")
#if "Lambda0" in decay_descriptor:
# branch_descriptor = branch_descriptor.replace("Lambda0", "(Lambda0 -> p+ pi-)")
#if "Lambda~0" in decay_descriptor:
# branch_descriptor = branch_descriptor.replace("Lambda~0", "(Lambda~0 -> p~- pi+)")
for comp_par in particle_df.query("type=='composite'").index:
if comp_par in decay_descriptor:
#branch_descriptor = branch_descriptor.replace(comp_par, comp_par + "->" + " ".join(particle_df["daughters"][comp_par]))
branch_descriptor = branch_descriptor.replace(comp_par, f'({comp_par} -> {" ".join(particle_df["daughters"][comp_par])})')
branches = {mother: branch_descriptor}
for daughter in daughters:
if "psi" in daughter:
true_pos = branch_descriptor.rfind("(", 0, branch_descriptor.find("psi", psi_pos))
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
psi_pos = branch_descriptor.find("psi", psi_pos) + len("psi(nS)")
if "phi" in daughter:
true_pos = branch_descriptor.rfind("(", 0, branch_descriptor.find("phi", phi_pos))
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
phi_pos = branch_descriptor.find("phi", phi_pos) + len("phi(1020)")
if "Lambda" in daughter:
true_pos = branch_descriptor.rfind("(", 0, branch_descriptor.find("Lambda", Lambda_pos))
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
Lambda_pos = branch_descriptor.find("Lambda", Lambda_pos) + len("Lambda~0")
if "Pp" in daughter:
true_pos = branch_descriptor.find("p+", Pp_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
Pp_pos = true_pos + len("p+")
if "Pm" in daughter:
true_pos = branch_descriptor.find("p~-", Pm_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
Pm_pos = true_pos + len("p~-")
if "Kp" in daughter:
true_pos = branch_descriptor.find("K+", Kp_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
Kp_pos = true_pos + len("K+")
if "Km" in daughter:
true_pos = branch_descriptor.find("K-", Km_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
Km_pos = true_pos + len("K-")
if "Pip" in daughter or "Hp" in daughter:
true_pos = branch_descriptor.find("pi+", Pip_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
Pip_pos = true_pos + len("pi+")
if "Pim" in daughter or "Hm" in daughter:
true_pos = branch_descriptor.find("pi-", Pim_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
Pim_pos = true_pos + len("pi-")
if "mup" in daughter:
true_pos = branch_descriptor.find("mu+", mup_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
mup_pos = true_pos + len("mu+")
if "mum" in daughter:
true_pos = branch_descriptor.find("mu-", mum_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
mum_pos = true_pos + len("mu-")
if "ep" in daughter:
true_pos = branch_descriptor.find("e+", ep_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
ep_pos = true_pos + len("e+")
if "em" in daughter:
true_pos = branch_descriptor.find("e-", em_pos)
branches.update({daughter: branch_descriptor[:true_pos]+"^"+branch_descriptor[true_pos:]})
em_pos = true_pos + len("e-")
return branches
def all_particles(particles):
all_pars = []
for particle in particles:
all_pars += ( [ particle ] + particle_df["daughters"][particle])
return all_pars
#print(all_particles(["B_s0","J/psi(1S)", "p+", "p~-"]))
def default_names(particles):
names = []
for particle in particles:
abbr = particle_df["abbr"][ particle ]
names.append( abbr )
names += [f"{daughter_abbr}_{abbr}" for daughter_abbr in particle_df["abbr"][particle_df["daughters"][particle]]]
return names
def default_branches(particles, cc=False):
names = default_names(particles)
return decay_branches(names[0], names[1:], descriptor(particles, cc))
branches = default_branches( ["B+","J/psi(1S)", "phi(1020)", "K+"], True)
print(branches)
#branches = decay_branches("Bs", ["Jpsi", "Pp", "Pm", "mup", "mum"], "[B_s0 -> J/psi(1S) p+ p~-]cc")
#print(branches)
#branches = default_names( ["B_s0","J/psi(1S)", "p+", "p~-"])
#print(descriptor(["Lambda_b0", "J/psi(1S)", "p+", "K-"], True))
Loading