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