ParticleSelector

Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.

ParticleSelector

class ParticleSelector

A model-independent way to identify an external particle.

Selectors may use a UFO particle name or a signed PDG code, making process definitions convenient while deferring validation to a concrete model.

Examples

from symbolica.community import hepkit as hep
electron = hep.ParticleSelector.by_pdg(11)
positron = hep.ParticleSelector.by_name("e+")

Attributes

Name Description
is_name Report whether this selector identifies a particle by name.
is_pdg Report whether this selector identifies a particle by PDG code.
name Return the selected particle name
pdg Return the selected PDG code

is_name

ParticleSelector.is_name: builtins.bool

Report whether this selector identifies a particle by name.

Examples

Using the setup in the ParticleSelector class example:

assert hep.ParticleSelector.by_name("e-").is_name

is_pdg

ParticleSelector.is_pdg: builtins.bool

Report whether this selector identifies a particle by PDG code.

Examples

Using the setup in the ParticleSelector class example:

assert hep.ParticleSelector.by_pdg(11).is_pdg

name

ParticleSelector.name: builtins.str

Return the selected particle name.

Raises :class:TypeError for a PDG selector. Use :attr:is_name to distinguish the selector variants before accessing their payloads.

Examples

Using the setup in the ParticleSelector class example:

assert hep.ParticleSelector.by_name("e-").name == "e-"

pdg

ParticleSelector.pdg: builtins.int

Return the selected PDG code.

Raises :class:TypeError for a name selector. Use :attr:is_pdg to distinguish the selector variants before accessing their payloads.

Examples

Using the setup in the ParticleSelector class example:

assert hep.ParticleSelector.by_pdg(11).pdg == 11

Methods

Name Description
__eq__ Compare with another selector, a particle name, or a PDG code.
__repr__ Return a constructor-style representation of the selector.
__str__ Format the selector as its particle name or signed PDG code.
by_name Select a particle by its model name.
by_pdg Select a particle by its signed PDG code.

__eq__

ParticleSelector.__eq__(other: typing.Any) -> builtins.bool

Compare with another selector, a particle name, or a PDG code.

Examples

Using the setup in the ParticleSelector class example:

hep.ParticleSelector.by_pdg(11) == 11
True

Parameters

  • other (object) Selector, particle-name string, or integer PDG code to compare with.

__repr__

ParticleSelector.__repr__() -> builtins.str

Return a constructor-style representation of the selector.

Examples

Using the setup in the ParticleSelector class example:

print(hep.ParticleSelector.by_pdg(11))  # electron selector in a process

__str__

ParticleSelector.__str__() -> builtins.str

Format the selector as its particle name or signed PDG code.

Examples

Using the setup in the ParticleSelector class example:

str(hep.ParticleSelector.by_pdg(11))
'11'

by_name

ParticleSelector.by_name(name: builtins.str) -> ParticleSelector

Select a particle by its model name.

Examples

Using the setup in the ParticleSelector class example:

hep.ParticleSelector.by_name("e-").name
'e-'

Parameters

  • name (str) Particle name as it appears in the model.

by_pdg

ParticleSelector.by_pdg(pdg: builtins.int) -> ParticleSelector

Select a particle by its signed PDG code.

Examples

Using the setup in the ParticleSelector class example:

hep.ParticleSelector.by_pdg(11).pdg
11

Parameters

  • pdg (int) Signed PDG code of the particle.