### Henry Schreiner and Eduardo Rodrigues¶

Some of the demos assume you have run python -m pip install particle. The demos use Python 3, though the package also supports Python 2 for now. You can view the demo here or run it here on Binder.

## Demo 1: Command line usage¶

There are two modules in Particle:

• PDGID - Find out as much as possible from the PDG ID number. No table lookup.
• Particle - Loads PDG data tables and implements search and manipulations / display.

### General usage¶

In [ ]:
!python -m particle -h

In [ ]:
!python -m particle --version


### PDGID¶

In [ ]:
!python -m particle pdgid 211


### Particle¶

In [ ]:
!python -m particle search 211

In [ ]:
!python -m particle search "pi+"

In [ ]:
!python -m particle search "pi(1400)+"


#### Bonus feature: ZipApp¶

We also have released a new ZipApp version - one file that runs on any computer with Python, no other dependencies! Find it attached to releases starting with version 0.4.4.

Example:

./particle.pyz search gamma


All dependencies (including the two backports) are installed inside the ZipApp, and the data lookup is handled in a zip-safe way inside particle. Python 3 is used to make the zipapp, but including the backports makes it work on Python 2 as well.

The command line mode could be enhanced to make it a useful tool in bash scripts! Stay tuned...

## Demo 2: Python usage¶

### PDGID¶

Let's start with PDGID again.

In [ ]:
from particle import PDGID, Particle, Charge

In [ ]:
p = PDGID(211)
p

In [ ]:
print(p.info())


#### Literals¶

Particle has literals, as well; these are dynamically generated on import for both PDGID and Particle classes!

In [ ]:
import particle.pdgid.literals as pdgid_literals

In [ ]:
pdgid_literals.phi_1020


### Particle¶

There are lots of ways to create a particle:

#### From PDGID¶

In [ ]:
Particle.from_pdgid(211)


#### Literals¶

In [ ]:
import particle.literals as particle_literals

In [ ]:
particle_literals.phi_1020


#### Searching¶

The most powerful method: find (or findall).

In [ ]:
Particle.find("phi(1020)")


You can specify search terms as keywords - any particle property:

In [ ]:
Particle.find(latex_name=r"\phi(1020)")


Some properties have enums available. For example, you can directly check the numeric charge:

In [ ]:
Particle.findall("pi", charge=-1)


Or you can use the enum (for charge, this is 3 times the charge, hence the name three_charge)

In [ ]:
Particle.findall("pi", three_charge=Charge.p)


Or use a lambda function for the ultimate in generality! For example, to find all the neutral particles with a bottom quark between 5.2 and 5.3 GeV:

In [ ]:
from hepunits import GeV, s  # Units are good. Use them.

In [ ]:
Particle.findall(
lambda p: p.pdgid.has_bottom and p.charge == 0 and 5.2 * GeV < p.mass < 5.3 * GeV
)


Another lambda function example: You can use the width or the lifetime:

In [ ]:
Particle.findall(lambda p: p.lifetime > 1000 * s)


If you want infinite lifetime, you could just use the keyword search instead:

In [ ]:
Particle.findall(lifetime=float("inf"))


### Display¶

Nice display in Jupyter notebooks, as well as str and repr support:

In [ ]:
p = particle_literals.D_0
p

In [ ]:
print(p)

In [ ]:
print(repr(p))


Full descriptions:

In [ ]:
print(p.describe())


You may find LaTeX or HTML to be more useful in your program, both are supported:

In [ ]:
print(p.latex_name, p.html_name)


It is easy to get hold of the whole list of particle (instances) as a list:

In [ ]:
all_particles = Particle.all()
print('The package "DB" contains {} particles:'.format(len(all_particles)))
all_particles


And it is just as easy to rather get a list of PDG IDs (as ints):

In [ ]:
[int(p.pdgid) for p in all_particles]


### Properties¶

You can do things to particles, like invert them:

In [ ]:
~p


There are a plethora of properties you can access:

In [ ]:
p.spin_type


You can quickly access the PDGID of a particle:

In [ ]:
p.pdgid


• Extend or replace the default table in Particle
Now let's look at one of the users of Particle: the DecayLanguage package!