Belle II Software light-2406-ragdoll
compare_evtpdl.py
1#!/usr/bin/env python3
2
3
10
11# requires `pip3 install --user particle`
12
13from particle import Particle, ParticleNotFound
14from particle.particle.particle import InvalidParticle
15import pdg
16from math import isclose
17import basf2
18
19pdg.load(basf2.find_file("data/framework/particledb/evt.pdl"))
20
21not_found = []
22all_pdgcodes = set()
23
24for 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
41print("Not found in PDG table:", ", ".join(p.GetName() for p in not_found))
42print("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:180
def load(filename)
Definition: pdg.py:122