ATLAS Offline Software
Loading...
Searching...
No Matches
python.PDG Namespace Reference

Functions

 pdgid_to_name (id)
 pdgid_to_root_name (id)
 _fill_dicts ()

Variables

dict pdgid_names = {}
dict root_names = {}
str _pdgtable

Detailed Description

This module contains names for the various PDG particle ID codes.
The names are the same as in EventKernel/PdtPdg.h.

This module also contains a dictionary pdgid_names mapping ID codes
back to printable strings, and a function pdgid_to_name to do this
conversion.  Similarly, root_names and pdgid_to_root_name translate to
strings with root markup.

Function Documentation

◆ _fill_dicts()

python.PDG._fill_dicts ( )
protected

Definition at line 603 of file Event/PyDumper/python/PDG.py.

603def _fill_dicts():
604 pdgid_names.clear()
605 root_names.clear()
606 global _pdgtable # noqa: F824
607 for line in _pdgtable.split ('\n'):
608 line = line.strip()
609 if len(line) == 0 or line[0] == '#':
610 continue
611 ll = line.split('=', 1)
612 if len(ll) < 2:
613 print ('bad line', line)
614 continue
615 mname = ll[0].strip()
616 ll = ll[1].split()
617 if len(ll) < 1:
618 print ('bad line', line)
619 continue
620 id = ll[0]
621 pname = None
622 if len(ll) >= 2 and ll[1] != '!':
623 pname = ll[1]
624 rname = None
625 if len(ll) >= 3 and ll[2] != '!':
626 rname = ll[2]
627 try:
628 id = int(id)
629 except ValueError:
630 id = globals().get(id)
631 if id is None:
632 print ('bad line', line)
633 continue
634
635 if pname is None:
636 pname = mname
637 if rname is None:
638 rname = pname
639
640 globals()[mname] = id
641 if id not in pdgid_names:
642 pdgid_names[id] = pname
643 if id not in root_names:
644 root_names[id] = rname
645 return
646
647# Fill the dictionaries.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ pdgid_to_name()

python.PDG.pdgid_to_name ( id)
Convert a PDG ID to a printable string.

Definition at line 26 of file Event/PyDumper/python/PDG.py.

26def pdgid_to_name (id):
27 """Convert a PDG ID to a printable string.
28 """
29 name = pdgid_names.get(id)
30 if not name:
31 name = str(id)
32 return name
33
34

◆ pdgid_to_root_name()

python.PDG.pdgid_to_root_name ( id)
Convert a PDG ID to a string with root markup.

Definition at line 35 of file Event/PyDumper/python/PDG.py.

35def pdgid_to_root_name (id):
36 """Convert a PDG ID to a string with root markup.
37 """
38 name = root_names.get(id)
39 if not name:
40 name = str(id)
41 return name
42
43
44
45#
46# Table of PDG IDs, associating the ID codes with up to several names.
47# This is formatted as one big string to make it easier to maintain
48# (don't need to quote everything individually).
49# The format of each line is like this:
50#
51# mname = id pname rname
52#
53# An attribute mname will be added to this module with a value of id.
54# These names are intended to match those in PdgPdt.h.
55# pname is a printable name for the entry, and rname is a name
56# with root-style markup. These names will be put into the pdgid_names
57# and root_names dictionaries, respectively. They can be left as `!'
58# if no name is available. pname and rname should not contain spaces.
59# Blank lines or those starting with `#' will be ignored.
60#

Variable Documentation

◆ _pdgtable

str python.PDG._pdgtable
protected

Definition at line 61 of file Event/PyDumper/python/PDG.py.

◆ pdgid_names

dict python.PDG.pdgid_names = {}

Definition at line 20 of file Event/PyDumper/python/PDG.py.

◆ root_names

dict python.PDG.root_names = {}

Definition at line 23 of file Event/PyDumper/python/PDG.py.