decaylanguage

Package to parse decay files, describe and convert particle decays between digital representations.

https://github.com/scikit-hep/decaylanguage

Science Score: 77.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    8 of 17 committers (47.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.7%) to scientific vocabulary

Keywords

analysis decay decay-files hep hep-ex high-energy-physics particle-physics particles python python3 scikit-hep

Keywords from Contributors

histogram particle pdg pid root root-cern hep-py file-format bigdata energy-system
Last synced: 4 months ago · JSON representation ·

Repository

Package to parse decay files, describe and convert particle decays between digital representations.

Basic Info
Statistics
  • Stars: 42
  • Watchers: 5
  • Forks: 17
  • Open Issues: 4
  • Releases: 0
Topics
analysis decay decay-files hep hep-ex high-energy-physics particle-physics particles python python3 scikit-hep
Created almost 8 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Citation Authors

README.md

DecayLanguage logo

DecayLanguage: describe, manipulate and convert particle decays

Scikit-HEP PyPI Package latest release Conda latest release Supported versions DOI

GitHub Actions Status: CI Code Coverage Documentation Status

Binder demo

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 describe, manipulate and visualize decay chains.

Installation

Just run the following:

bash pip install decaylanguage

You can use a virtual environment through pipenv or with --user if you know what those are. Python 3.9+ supported (see version 0.14 for Python 3.6 support, 0.18 for Python 3.7 and 3.8 support).

Dependencies: (click to expand)

Required and compatibility dependencies will be automatically installed by pip. ### Required dependencies: - [particle](https://github.com/scikit-hep/particle): PDG particle data and identification codes - [NumPy](https://scipy.org/install.html): The numerical library for Python - [pandas](https://pandas.pydata.org/): Tabular data in Python - [attrs](https://github.com/python-attrs/attrs): DataClasses for Python - [plumbum](https://github.com/tomerfiliba/plumbum): Command line tools - [lark](https://github.com/lark-parser/lark): A modern parsing library for Python - [graphviz](https://gitlab.com/graphviz/graphviz/) to render (DOT language) graph descriptions and visualizations of decay chains. ### Python compatibility: - [importlib_resources](http://importlib-resources.readthedocs.io/en/latest/) backport if using Python /< 3.9

Getting started

The Binder demo is an excellent way to get started with DecayLanguage.

This is a quick user guide. For a full API docs, go here (note that it is presently work-in-progress).

What is DecayLanguage?

DecayLanguage is a set of tools for building and transforming particle decays:

  1. It provides tools to parse so-called .dec decay files, and describe, manipulate and visualize the resulting decay chains.

  2. It 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.

Particles

Particles are a key component when dealing with decays. Refer to the particle package for how to deal with particles and Monte Carlo particle identification codes.

Parse decay files

Decay .dec files can be parsed simply with

```python from decaylanguage import DecFileParser

parser = DecFileParser('my-decay-file.dec') parser.parse()

Inspect what decays are defined

parser.listdecaymother_names()

Print decay modes, etc. ...

```

A copy of the main 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:

```python 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 """

dfp = DecFileParser.from_string(s) dfp.parse() ```

Advanced usage

The list of .dec file decay models known to the package can be inspected via

python from decaylanguage.dec import known_decay_models

Say you have to deal with a decay file containing a new model not yet on the list above. Running the parser as usual will result in an error in the model parsing. It is nevertheless easy to deal with this issue; no need to wait for a new release: Just call load_additional_decay_models with the models you'd like to add as arguments before parsing the file:

python dfp = DecFileParser('my_decfile.dec') dfp.load_additional_decay_models("MyModel1", "MyModel2") dfp.parse() ...

This being said, please do submit a pull request to add new models, if you spot missing ones ...

Visualize decay files

The class DecayChainViewer allows the visualization of parsed decay chains:

```python from decaylanguage import DecayChainViewer

Build the (dictionary-like) D*+ decay chain representation setting the

D+ and D0 mesons to stable, to avoid too cluttered an image

d = dfp.builddecaychains('D*+', stable_particles=('D+', 'D0')) DecayChainViewer(d) # works in a notebook ```

DecayChain D*

The actual graph is available as

```python

...

dcv = DecayChainViewer(d) dcv.graph ```

making all graphviz.Digraph class properties and methods available, such as

python dcv.graph.render(filename='mygraph', format='pdf', view=True, cleanup=True)

In the same way, all graphviz.Digraph class attributes are settable upon instantiation of DecayChainViewer:

python dcv = DecayChainViewer(chain, name='TEST', format='pdf')

Universal representation of decay chains

A series of classes and methods have been designed to provide universal representations of particle decay chains of any complexity, and to provide the ability to convert between these representations. Specifically, class- and dictionary-based representations have been implemented.

An example of a class-based representation of a decay chain is the following:

```python

from decaylanguage import DaughtersDict, DecayMode, DecayChain

dm1 = DecayMode(0.0124, 'KS0 pi0', model='PHSP') dm2 = DecayMode(0.692, 'pi+ pi-') dm3 = DecayMode(0.98823, 'gamma gamma') dc = DecayChain('D0', {'D0':dm1, 'KS0':dm2, 'pi0':dm3}) dc K_S0 pi0 (2 sub-decays), BF=0.0124> ```

Decay chains can be visualised with the DecayChainViewer class making use of the dictionary representation dc.to_dict(), which is the simple representation understood by DecayChainViewer, as see above:

python DecayChainViewer(dc.to_dict())

The fact that 2 representations of particle decay chains are provided ensures the following:

  1. Human-readable (class) and computer-efficient (dictionary) alternatives.
  2. Flexibility for parsing, manipulation and storage of decay chain information.

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:

```python 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:

bash python -m decaylanguage -G goofit myinput.opts

Contributors

We hereby acknowledge the contributors that made this project possible (emoji key): <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable -->

Eduardo Rodrigues
Eduardo Rodrigues

🚧 💻 📖
Henry Schreiner
Henry Schreiner

🚧 💻 📖
Yipeng Sun
Yipeng Sun

💻
Chris Burr
Chris Burr

📖
Kilian Lieret
Kilian Lieret

📖
Moritz Bauer
Moritz Bauer

💻
FlorianReiss
FlorianReiss

💻 📖
Adam Morris
Adam Morris

💻
Dazhi Wang
Dazhi Wang

💻
Manuel Franco Sevilla
Manuel Franco Sevilla

💻
Vidya Sagar
Vidya Sagar

💻

This project follows the all-contributors specification.

Acknowledgements

The UK Science and Technology Facilities Council (STFC) and the University of Liverpool provide funding for Eduardo Rodrigues (2020-) to work on this project part-time.

Support for this work was provided by the National Science Foundation cooperative agreement OAC-1450377 (DIANA/HEP) in 2016-2019 and has been provided by OAC-1836650 (IRIS-HEP) since 2019. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.

Owner

  • Name: Scikit-HEP Project
  • Login: scikit-hep
  • Kind: organization
  • Email: scikit-hep-forum@googlegroups.com

A community project for High Energy Physics data analysis in Python

Citation (CITATION.cff)

cff-version: 1.2.0
title: DecayLanguage
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
abstract: "DecayLanguage is a Python library to describe, manipulate and convert particle decays."
authors:
  - family-names: Rodrigues
    given-names: Eduardo
    affiliation: University of Liverpool
    orcid: "https://orcid.org/0000-0003-2846-7625"
  - family-names: Schreiner
    given-names: Henry
    affiliation: Princeton University
    orcid: "https://orcid.org/0000-0002-7833-783X"
doi: 10.5281/zenodo.3257423
repository-code: "https://github.com/scikit-hep/decaylanguage"
keywords:
  - python
  - particle decays
  - decay files
  - scikit-hep
license: "BSD-3-Clause"

GitHub Events

Total
  • Create event: 41
  • Issues event: 1
  • Release event: 2
  • Delete event: 37
  • Issue comment event: 5
  • Push event: 55
  • Pull request review event: 32
  • Pull request event: 72
  • Fork event: 2
Last Year
  • Create event: 41
  • Issues event: 1
  • Release event: 2
  • Delete event: 37
  • Issue comment event: 5
  • Push event: 55
  • Pull request review event: 32
  • Pull request event: 72
  • Fork event: 2

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 520
  • Total Committers: 17
  • Avg Commits per committer: 30.588
  • Development Distribution Score (DDS): 0.567
Past Year
  • Commits: 76
  • Committers: 8
  • Avg Commits per committer: 9.5
  • Development Distribution Score (DDS): 0.421
Top Committers
Name Email Commits
Eduardo Rodrigues e****s@c****h 225
pre-commit-ci[bot] 6****] 151
Henry Fredrick Schreiner h****r@c****h 87
dependabot[bot] 4****] 17
allcontributors[bot] 4****] 10
Henry Schreiner h****i@g****m 9
Henry Schreiner h****i@u****u 4
Moritz Bauer m****b@m****m 3
Adam Morris a****s@c****h 2
FlorianReiss f****s@c****h 2
Henry Schreiner h****n@c****h 2
sourcery-ai[bot] 5****] 2
Chris Burr c****r 2
Kilian Lieret k****t@p****e 1
Lepton c****h@g****m 1
Manuel Franco Sevilla m****a@c****h 1
Yipeng Sun s****p@u****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 12
  • Total pull requests: 324
  • Average time to close issues: 4 months
  • Average time to close pull requests: 1 day
  • Total issue authors: 8
  • Total pull request authors: 10
  • Average comments per issue: 5.08
  • Average comments per pull request: 0.42
  • Merged pull requests: 297
  • Bot issues: 0
  • Bot pull requests: 211
Past Year
  • Issues: 1
  • Pull requests: 59
  • Average time to close issues: N/A
  • Average time to close pull requests: about 24 hours
  • Issue authors: 1
  • Pull request authors: 6
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.12
  • Merged pull requests: 52
  • Bot issues: 0
  • Bot pull requests: 46
Top Authors
Issue Authors
  • eduardo-rodrigues (4)
  • admorris (2)
  • FlorianReiss (1)
  • vvsagar (1)
  • jonas-eschle (1)
  • acampove (1)
  • manuelfs (1)
  • daritter (1)
Pull Request Authors
  • pre-commit-ci[bot] (178)
  • eduardo-rodrigues (72)
  • henryiii (30)
  • dependabot[bot] (30)
  • allcontributors[bot] (12)
  • sognetic (3)
  • FlorianReiss (2)
  • manuelfs (2)
  • admorris (2)
  • vvsagar (1)
Top Labels
Issue Labels
enhancement (6) help wanted (3) good first issue (2) dependencies (1) bug (1)
Pull Request Labels
ci (159) enhancement (40) dependencies (39) release (19) tests (14) doc (11) fix (8) chore (4) github_actions (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 2,822 last-month
  • Total docker downloads: 11
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 6
    (may contain duplicates)
  • Total versions: 68
  • Total maintainers: 3
pypi.org: decaylanguage

A language to describe, manipulate and convert particle decays

  • Versions: 50
  • Dependent Packages: 2
  • Dependent Repositories: 5
  • Downloads: 2,822 Last month
  • Docker Downloads: 11
Rankings
Dependent packages count: 3.2%
Docker downloads count: 4.0%
Dependent repos count: 6.6%
Average: 6.8%
Downloads: 7.2%
Forks count: 9.6%
Stargazers count: 10.2%
Last synced: 4 months ago
conda-forge.org: decaylanguage
  • Versions: 18
  • Dependent Packages: 1
  • Dependent Repositories: 1
Rankings
Dependent repos count: 24.4%
Dependent packages count: 29.0%
Average: 34.7%
Forks count: 41.8%
Stargazers count: 43.5%
Last synced: 4 months ago

Dependencies

.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3 composite
  • pre-commit/action v3.0.0 composite
.github/workflows/wheel.yml actions
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/upload-artifact v3 composite
  • pypa/gh-action-pypi-publish v1.6.4 composite
docs/requirements.txt pypi
  • sphinx >=1.3
  • sphinx-rtd-theme *
pyproject.toml pypi
  • attrs >=19.2
  • deprecated *
  • graphviz >=0.12.0
  • importlib-resources >=2.0;python_version<"3.9"
  • lark >=1.0.0
  • numpy >=1.12
  • pandas >=0.22
  • particle >=0.21.0
  • plumbum >=1.6.9
  • typing-extensions python_version<"3.8"
environment.yml conda
  • attrs >=19.2
  • graphviz >=0.12.0
  • hepunits >=2.2.0
  • jupyterlab >=0.35
  • lark >=1.0.0
  • numpy >=1.12
  • pandas >=0.24
  • particle >=0.22.0
  • pip >=9
  • plumbum >=1.7.0
  • python >=3.7
  • rise