A language to describe particle decays, and tools to work with them.
Project description
[![DecayLanguage](https://raw.githubusercontent.com/scikit-hep/decaylanguage/master/images/DecayLanguage.png)](http://decaylanguage.readthedocs.io/en/latest/)
DecayLanguage implements a language to describe and convert particle decays between digital representations, effectively making it possible to interoperate several fitting programs. Particular interest is given to programs dedicated to amplitude analyses.
DecayLanguage provides tools to parse so-called .dec decay files, and manipulate and visualize decay chains.
Installation
Just run the following:
pip install decaylanguage
You can use a virtual environment through pipenv or with --user
if you know
what those are. Python 2.7 and 3.4+ are supported.
Dependencies: (click to expand)
Required and compatibility dependencies will be automatically installed by pip.
Required dependencies:
- particle: PDG particle data and identification codes
- Numpy: The numerical library for Python
- pandas: Tabular data in Python
- attrs: DataClasses for Python
- plumbum: Command line tools
- lark-parser: A modern parsing library for Python
Python compatibility:
- six: Compatibility library
- pathlib2 backport if using Python 2.7
- enum34 backport if using Python /< 3.5
- importlib_resources backport if using Python /< 3.7
Recommended dependencies:
Usage
This is a quick user guide. For a full API docs, go here.
DecayLanguage
is a set of tools for building and transforming particle
decays. The parts are:
Particles
Particles are a key component when dealing with decays. Refer to the particle package for how to deal with particles and PDG identification codes.
Decay files
Decay .dec files can be parsed simply with
from decaylanguage import DecFileParser
parser = DecFileParser('my-decay-file.dec')
parser.parse()
# Inspect what decays are defined
parser.list_decay_mother_names()
# Print decay modes, etc. ...
A copy of the master DECAY.DEC file used by the LHCb experiment is provided here for convenience.
The DecFileParser
class implements a series of methods giving access to all
information stored in decay files: the decays themselves, particle name aliases,
definitions of charge-conjugate particles, variable and Pythia-specific
definitions, etc.
It can be handy to parse from a multi-line string rather than a file:
s = """Decay pi0
0.988228297 gamma gamma PHSP;
0.011738247 e+ e- gamma PI0_DALITZ;
0.000033392 e+ e+ e- e- PHSP;
0.000000065 e+ e- PHSP;
Enddecay
"""
parser = DecFileParser.from_string(s)
parser.parse()
The class DecayChainViewer
allows the visualization of parsed decay chains:
from decaylanguage import DecayChainViewer
# Build the D*+ decay chain representation setting the D+ and D0 mesons to stable,
# to avoid too cluttered an image
d = parser.build_decay_chains('D*+', stable_particles=['D+', 'D0'])
DecayChainViewer(d) # works in a notebook
The actual graph is available as
# ...
dcv = DecayChainViewer(d)
dcv.graph
making all pydot.Dot
class properties and methods available, such as
dcv.graph.write_pdf('mygraph.pdf')
In the same way, all pydot.Dot
class attributes are settable
upon instantiation of DecayChainViewer
:
dcv = DecayChainViewer(chain, graph_name='TEST', rankdir='TB')
Decay modeling
The most common way to create a decay chain is to read in an AmpGen style syntax from a file or a string. You can use:
from decaylanguage.modeling import AmplitudeChain
lines, parameters, constants, states = AmplitudeChain.read_ampgen(text='''
EventType D0 K- pi+ pi+ pi-
D0[D]{K*(892)bar0{K-,pi+},rho(770)0{pi+,pi-}} 0 1 0.1 0 1 0.1
K(1460)bar-_mass 0 1460 1
K(1460)bar-_width 0 250 1
a(1)(1260)+::Spline::Min 0.18412
a(1)(1260)+::Spline::Max 1.86869
a(1)(1260)+::Spline::N 34
''')
Here, lines
will be a list of AmplitudeChain lines (pretty print supported in Jupyter notebooks),
parameters
will be a table of parameters (ranged parameters not yet supported),
constants
will be a table of constants,
and states
will be the list of known states (EventType).
Converters
You can output to a format (currently only GooFit supported, feel free to make a PR to add more). Use a subclass of DecayChain, in this case, GooFitChain. To use the GooFit output, type from the shell:
python -m decaylanguage -G goofit myinput.opts
Acknowledgements
DecayLanguage is free software released under a BSD 3-Clause License. It was originally developed by Henry Schreiner.
Changelog
Version 0.5.0 (2019-10-11)
- Universal representation of decay chains:
- Class
DecayChain
introduced. - Classes
DaughtersDict
andDecayMode
enhanced.
- Class
- Changes in API:
DecFileParser.build_decay_chain()
renamed toDecFileParser.build_decay_chains()
.
- Package dependent on
Particle
package version 0.6.
Version 0.4.0 (2019-09-02)
- Package dependent on
Particle
version 0.6.0. Otherwise identical to version 0.3.2.
Version 0.3.2 (2019-08-29)
- Parsing of decay files (aka .dec files):
DecFileParser
class extended to understand JETSET definitions.
- Visualisation of decay chains:
DecayChainViewer
class simplified and improved.- Decay chain DOT graphs now display HTML particle names.
- More tests.
Version 0.3.1 (2019-07-18)
- Parsing of decay files (aka .dec files):
- Update to latest LHCb DECAY.DEC file.
- Visualisation of decay chains:
DecayChainViewer
class made more robust.- Better tests.
- Miscellaneous:
- Demo notebook updated.
- README updated with latest package functionality.
- Python wheels generation added.
- Zenodo DOI badge added to README.
Version 0.3.0 (2019-06-26)
- Decays modelling:
- Updates to Mint related particle data files.
- Parsing of decay files (aka .dec files):
- Lark parser files added, for
.dec
decay files. DecFileParser
class introduced, with documentation and test suite.- Various
.dec
test decay files added.
- Lark parser files added, for
- Visualisation of decay chains:
DecayChainViewer
class introduced, with documentation and test suite.
- Universal representation of decay chains:
- First "building block" classes
DaughtersDict
andDecayMode
introduced, with documentation and test suite.
- First "building block" classes
- Package dependencies:
- Package made dependent on Scikit-HEP's
Particle
package. - Redundant code removed.
- Package made dependent on Scikit-HEP's
- Continuous integration:
- CI with Azure pipelines introduced.
- CI with Travis and AppVeyor removed.
- Miscellaneous:
- Demo notebook added, with a launcher for Binder.
- Copyright statements added to repository files.
- General clean-up and minor bug fixes.
Version 0.2.0 (2018-08-02)
- First release as part of Scikit-HEP.
- Using new data package with
importlib_resources
(orimportlib.resources
on Python 3.7). - Better docs and examples.
- Some method renaming.
- Generalized converter script.
Version 0.1.0 (2018-03-13)
- First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file decaylanguage-0.5.0.tar.gz
.
File metadata
- Download URL: decaylanguage-0.5.0.tar.gz
- Upload date:
- Size: 617.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2608649630b0c6c23ad6e4f0b187a619386a0073bade89a872965e4cb7949b53 |
|
MD5 | 1f93389c5796c325ef53710067e2e26e |
|
BLAKE2b-256 | 9a7d597475ba7821b137d65f5f670d08335b3704a6c756bd9fa6e3f48915cde4 |
File details
Details for the file decaylanguage-0.5.0-py2.py3-none-any.whl
.
File metadata
- Download URL: decaylanguage-0.5.0-py2.py3-none-any.whl
- Upload date:
- Size: 269.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ebdaa5c3c3db0b02c44dbae590b26b145cf57fabeec137865a24cc79958086d |
|
MD5 | 9d3c55a451504c5c285fefaf15f2ff59 |
|
BLAKE2b-256 | 468341dd9505c5e05eeb7499e25707711e6ecf870fa85435a1fc5b79e0af2d11 |