{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: MacOS", "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: C++", "Programming Language :: Cython", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering", "Topic :: Software Development" ], "description": ".. -*- mode: rst -*-\n\nnumpythia: The interface between PYTHIA and NumPy\n=================================================\n\n.. image:: https://img.shields.io/pypi/v/numpythia.svg\n :target: https://pypi.python.org/pypi/numpythia\n\n.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1471492.svg\n :target: https://doi.org/10.5281/zenodo.1471492\n\n.. image:: https://travis-ci.org/scikit-hep/numpythia.svg?branch=master\n :target: https://travis-ci.org/scikit-hep/numpythia\n\n.. image:: https://coveralls.io/repos/github/scikit-hep/numpythia/badge.svg?branch=master\n :target: https://coveralls.io/github/scikit-hep/numpythia?branch=master\n\nnumpythia provides an interface between `PYTHIA\n`_ and `NumPy\n`_ allowing you to generate events as NumPy arrays of\nparticle four-momenta. By default numpythia only depends on NumPy and builds\ninternal copies of the PYTHIA and `HepMC `_\nsource code.\n\nStandalone Installation\n-----------------------\n\nTo simply use the built-in PYTHIA and HepMC::\n\n pip install -v numpythia\n\nAnd you're good to go!\n\nSupport for building against an external PYTHIA is on the wishlist.\n\nStrict dependencies\n-------------------\n\n- `Python `__ (2.7+, 3.4+)\n- `Numpy `__\n- `six `__\n- Only for the development version (from github): `Cython `__\n\nGetting started\n---------------\n\n.. code-block:: python\n\n >>> from numpythia import Pythia, hepmc_write, hepmc_read\n >>> from numpythia import STATUS, HAS_END_VERTEX, ABS_PDG_ID\n >>> from numpythia.testcmnd import get_cmnd\n >>> from numpy.testing import assert_array_equal\n\n >>> pythia = Pythia(get_cmnd('w'), random_state=1)\n\n >>> selection = ((STATUS == 1) & ~HAS_END_VERTEX &\n (ABS_PDG_ID != 12) & (ABS_PDG_ID != 14) & (ABS_PDG_ID != 16))\n\n >>> # generate events while writing to ascii hepmc\n >>> for event in hepmc_write('events.hepmc', pythia(events=1)):\n >>> array1 = event.all(selection)\n\n >>> # read the same event back from ascii hepmc\n >>> for event in hepmc_read('events.hepmc'):\n >>> array2 = event.all(selection)\n\n >>> assert_array_equal(array1, array2)\n True\n\nThe dtype of any array of particle information is:\n\n.. code-block:: python\n\n np.dtype([('E', 'f8'), ('px', 'f8'), ('py', 'f8'), ('pz', 'f8'), ('pt', 'f8'),\n ('mass', 'f8'), ('rap', 'f8'), ('eta', 'f8'), ('theta', 'f8'),\n ('phi', 'f8'), ('prodx', 'f8'), ('prody', 'f8'), ('prodz', 'f8'),\n ('prodt', 'f8'), ('pdgid', 'i4'), ('status', 'i4')])\n\nAlso see `pyjet `_ for jet clustering.\n\nTutorial\n--------\n\nSetting PYTHIA\n~~~~~~~~~~~~~~\n\nPYTHIA settings can be passed in one of three ways: through the `**kwargs` arguments of the constructor `Pythia(..., **kwargs)`:\n\n.. code-block:: python\n\n >>> pythia = Pythia(..., Beams_eCM=13000.)\n\nOr as a dictionary:\n\n.. code-block:: python\n\n >>> pythia = Pythia(..., params={'Beams:eCM': 13000.})\n\nOr via a Python command file:\n\n.. code-block:: python\n\n >>> pythia = Pythia(config='path/to/config.cmd')\n\nThe full list of settings can be found on the `PYTHIA homepage `_.\n\nNote that the \":\" in settings names is replaced by a \"_\" if using `kwargs`.\n`kwargs` take precedence over `params` and they both take precedence over `config`.\nExample config files can be found under the `numpythia.testcmnd` directory.\n\nGenerate events\n~~~~~~~~~~~~~~~\n\nTo generate events do\n\n.. code-block:: python\n\n >>> events = pythia(events=100)\n >>> events\n \n\nwhere **events** is a generator of ``GenEvent`` containing all the generated particles.\n\nGenerated particles can be accessed through the ``all``, ``first`` and ``last``\nmethods which have two optional arguments ``selection`` and ``return_hepmc``.\nSelection is a filter or a combination of filters with bitwise operations (as\nshown in the *getting started* example) applied on the particles in the event.\nThe available filters are\n\n.. code-block:: python\n\n STATUS, PDG_ID, ABS_PDG_ID, HAS_END_VERTEX, HAS_PRODUCTION_VERTEX,\n HAS_SAME_PDG_ID_DAUGHTER, IS_STABLE, IS_BEAM\n\n``return_hepmc`` is by default set to ``False`` when using ``all``:\n\n.. code-block:: python\n\n >>> for e in events:\n >>> array = e.all(selection)\n\nreturns an array of particles, with the dtype described above. ``return_hepmc`` is\nby default set to ``True`` for ``first`` and ``last``:\n\n.. code-block:: python\n\n >>> for e in events:\n >>> gen_part_f = e.first(selection)\n >>> gen_part_l = e.last(selection)\n\nreturns a ``GenParticle``.\n\nGenerated particle\n~~~~~~~~~~~~~~~~~~\n\n``GenParticle`` is the numpythia interface of\n`HepMC::GenParticle `_,\nand has the following attributes\n\n.. code-block:: python\n\n pid, status, e, px, py, pz, pt, eta, phi, mass, theta, rap\n\n``GenParticle`` also has the following methods ``parents``, ``children``, ``ancestors``,\n``descendants`` and ``siblings`` both with the two optional arguments ``selection``\nand ``return_hepmc`` described before. For instance:\n\n.. code-block:: python\n\n >>> for e in events:\n >>> w = e.last((ABS_PDG_ID == 24) & HAS_END_VERTEX))\n >>> w.children()\n array([(240.60708981, 115.76101664, 126.16766767, -169.03439984, 171.22760682, 0.5, -0.87228439, -0.87228739, 2.34974894, 0.82838703, 0., 0., 0., 0., 3, 23),\n ( 52.59241372, 9.21296404, 50.77873929, -10.01763001, 51.60774235, 1.5, -0.19283178, -0.19291222, 1.76252302, 1.39131523, 0., 0., 0., 0., -4, 23)],\n dtype=[('E', '