ParticleSelector
ParticleSelector
class ParticleSelectorA 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.boolReport whether this selector identifies a particle by name.
Examples
Using the setup in the ParticleSelector class example:
assert hep.ParticleSelector.by_name("e-").is_nameis_pdg
ParticleSelector.is_pdg: builtins.boolReport 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_pdgname
ParticleSelector.name: builtins.strReturn 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.intReturn 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 == 11Methods
| 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.boolCompare 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
TrueParameters
other(object) Selector, particle-name string, or integer PDG code to compare with.
__repr__
ParticleSelector.__repr__() -> builtins.strReturn 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.strFormat 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) -> ParticleSelectorSelect 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) -> ParticleSelectorSelect a particle by its signed PDG code.
Examples
Using the setup in the ParticleSelector class example:
hep.ParticleSelector.by_pdg(11).pdg
11Parameters
pdg(int) Signed PDG code of the particle.