Belle II Software  release-05-01-25
compare_evtpdl.py
1 #!/usr/bin/env python3
2 # requires `pip3 install --user particle`
3 from particle import Particle, ParticleNotFound
4 from particle.particle.particle import InvalidParticle
5 import pdg
6 from math import isclose
7 import basf2
8 
9 pdg.load(basf2.find_file("data/framework/particledb/evt.pdl"))
10 
11 not_found = []
12 all_pdgcodes = set()
13 
14 for p in pdg.search():
15  try:
16  pdg = Particle.from_pdgid(p.PdgCode())
17  names = ["mass", "width", "lifetime", "charge"]
18  current = [p.Mass(), p.Width(), p.Lifetime(), p.Charge()/3]
19  nominal = [pdg.mass/1e3 if pdg.mass is not None else 0,
20  pdg.width/1e3 if pdg.width is not None else 0,
21  pdg.lifetime/1e9 if pdg.lifetime is not None and pdg.width > 0 else 0,
22  pdg.charge]
23  for n, a, b in zip(names, current, nominal):
24  if not isclose(a, b, rel_tol=0.05, abs_tol=1e-12):
25  print(f"{p.GetName()} difference in {n}: {a} != {b}")
26  except (ParticleNotFound, InvalidParticle):
27  not_found.append(p)
28 
29  all_pdgcodes.add(p.PdgCode())
30 
31 print("Not found in PDG table:", ", ".join(p.GetName() for p in not_found))
32 print("Found in PDG table but not evt.pdl:", ", ".join(p.name for p in Particle.findall(lambda p: p.pdgid not in all_pdgcodes)))
pdg.load
def load(filename)
Definition: pdg.py:109
pdg.search
def search(name=None, min_mass=None, max_mass=None, name_regex=False, include_width=False)
Definition: pdg.py:155