{"id":17646757,"url":"https://github.com/tpgillam/mt2","last_synced_at":"2026-04-02T02:00:44.962Z","repository":{"id":53014749,"uuid":"337537250","full_name":"tpgillam/mt2","owner":"tpgillam","description":"Stransverse mass computation, compatible with numpy.","archived":false,"fork":false,"pushed_at":"2026-03-02T12:13:41.000Z","size":426,"stargazers_count":4,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-02T16:12:52.816Z","etag":null,"topics":["high-energy-physics","numpy","physics","python"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tpgillam.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-02-09T21:10:13.000Z","updated_at":"2026-03-02T12:13:45.000Z","dependencies_parsed_at":"2025-03-03T19:21:27.048Z","dependency_job_id":"5100ad9e-a21a-41a1-9576-589b36aac0a7","html_url":"https://github.com/tpgillam/mt2","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/tpgillam/mt2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpgillam%2Fmt2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpgillam%2Fmt2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpgillam%2Fmt2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpgillam%2Fmt2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tpgillam","download_url":"https://codeload.github.com/tpgillam/mt2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpgillam%2Fmt2/sbom","scorecard":{"id":410436,"data":{"date":"2025-08-11","repo":{"name":"github.com/tpgillam/mt2","commit":"57348dcfc06cbc0d22beea2faa60c2e4897b0a54"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.7,"checks":[{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":2,"reason":"3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:87: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:88: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:90: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:111: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:116: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:68: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:69: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:78: update your workflow using https://app.stepsecurity.io/secureworkflow/tpgillam/mt2/ci.yml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   5 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":1,"reason":"branch protection is not maximal on development and all release branches","details":["Warn: 'allow deletion' enabled on branch 'main'","Info: 'force pushes' disabled on branch 'main'","Warn: 'branch protection settings apply to administrators' is disabled on branch 'main'","Info: 'stale review dismissal' is required to merge on branch 'main'","Warn: required approving review count is 1 on branch 'main'","Warn: codeowners review is not required on branch 'main'","Warn: 'last push approval' is disabled on branch 'main'","Info: 'up-to-date branches' is required to merge on branch 'main'","Info: status check found to merge onto on branch 'main'","Info: PRs are required in order to make changes on branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T22:34:25.490Z","repository_id":53014749,"created_at":"2025-08-18T22:34:25.490Z","updated_at":"2025-08-18T22:34:25.490Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["high-energy-physics","numpy","physics","python"],"created_at":"2024-10-23T11:07:00.792Z","updated_at":"2026-04-02T02:00:44.954Z","avatar_url":"https://github.com/tpgillam.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"===\nmt2\n===\n\n.. image:: https://img.shields.io/pypi/v/mt2.svg\n        :target: https://pypi.python.org/pypi/mt2\n\n.. image:: https://img.shields.io/pypi/pyversions/mt2.svg\n        :target: https://pypi.python.org/pypi/mt2\n\n\nThis package may be used to evaluate MT2 in all its variants.\nThis includes both symmetric and asymmetric MT2.\nMT2 is also known as the \"stransverse mass\".\n\nThis package provides an interface to the bisection algorithm of http://arxiv.org/abs/1411.4312, via an implementation detailed below.\nThe variable MT2 itself is described `here \u003chttp://arxiv.org/abs/hep-ph/9906349\u003e`__.\nRelated information may be found in papers relating to MT2 linked from `here \u003chttps://www.hep.phy.cam.ac.uk/~lester/mt2/index.html\u003e`__.\n\nGetting started\n---------------\n\nInstall from `PyPI \u003chttps://pypi.org/project/mt2/\u003e`__ with e.g. pip:\n\n.. code-block:: bash\n\n    pip install mt2\n\nOne can then compute MT2 as follows; here for the \"symmetric\" case, where both invisible particles have the same mass:\n\n.. code-block:: python\n\n    from mt2 import mt2\n\n    # The units of all quantities are the same, e.g. GeV\n    val = mt2(\n        100, 410, 20,  # Visible 1: mass, px, py\n        150, -210, -300,  # Visible 2: mass, px, py\n        -200, 280,  # Missing transverse momentum: x, y\n        100, 100)  # Invisible 1 mass, invisible 2 mass\n    print(\"Expected mT2 = 412.628.  Computed mT2 = \", val)\n\nmt2 is also `available on conda-forge \u003chttps://github.com/conda-forge/mt2-feedstock\u003e`__. \n\nExamples\n--------\n\nVectorisation\n*************\n\nThe ``mt2`` function supports broadcasting over its arguments if they are array-like.\nFor example, one could scan over a grid of invisible particle masses like so:\n\n.. code-block:: python\n\n    n1 = 20\n    n2 = 20\n    mass_1 = numpy.linspace(10, 200, n1).reshape((-1, 1))\n    mass_2 = numpy.linspace(10, 200, n2).reshape((1, -1))\n\n    # `val` has shape (n1, n2)\n    val = mt2(\n        100, 410, 20,  # Visible 1: mass, px, py\n        150, -210, -300,  # Visible 2: mass, px, py\n        -200, 280,  # Missing transverse momentum: x, y\n        mass_1, mass_2)  # Invisible 1 mass, invisible 2 mass\n\nNote on performance\n^^^^^^^^^^^^^^^^^^^\n\nWith `full precision`, the main reason to use vectorisation as above is convenience.\nThe time spent in the C++ MT2 calculation is somewhat larger than the overhead introduced by a Python ``for`` loop.\nVectorising can give a runtime reduction of ⪅30% in this case.\n\n`However`, the benefit can be more significant when using a lower precision.\nThis corresponds to a larger value for the ``desired_precision_on_mt2`` argument.\nThis is because less time is spent in C++, so proportionally the Python overhead of a ``for`` loop is more significant.\n\nToy MC\n******\n\nA fun example using a toy Monte-Carlo simulation can be viewed in `this notebook \u003chttps://github.com/tpgillam/mt2/blob/master/examples/mc.ipynb\u003e`__\n\nOther notes\n-----------\n\nFor further information, see the documentation:\n\n.. code-block:: python\n\n    help(mt2)\n\nAlso exported is ``mt2_ufunc``.\nThis is the raw implementation as a `numpy ufunc \u003chttps://numpy.org/doc/stable/reference/ufuncs.html\u003e`_.\nUsage is the same as for ``mt2``, but it supports some additional arguments, like ``where``.\nThe reader should refer to the numpy documentation for a description of these.\n\nImplementation\n**************\n\nThe underlying implementation of the Lester-Nachman algorithm used in this package is by Rupert Tombs, found in ``src/mt2_bisect.h``.\nIt provides results consistent with the implementation provided with http://arxiv.org/abs/1411.4312, but is 3x to 4x faster.\nNote that this does *not* implement the \"deci-sectioning\" described in the paper, since it is found to provide a more significant performance penalty in the majority of cases.\nOur version is also scale invariant, and is suitable for large ranges of input magnitude.\n\nThe legacy implementation, as it appears on arXiv, is also wrapped and exposed as ``mt2_arxiv`` for those that wish to independently cross-check the re-implementation.\nIf you find any discrepancies, please file a bug report!\n**We strongly encourage all users to use the primary** ``mt2`` **method, due to the higher performance and scale invariance.**\n\nPerformance\n***********\n\nThe default installation method via pip uses a precompiled wheel for your platform.\nIf you wish to compile from source for your platform, you could instead install like so:\n\n.. code-block:: bash\n\n    pip install mt2 --no-binary :all:\n\nSince this can allow use of newer compilers, and code more optimised for your architecture, this can give a `small` speedup.\nOn the author's computer, there was 1% runtime reduction as measured with ``examples/benchmark.py``.\n\n\nLicense\n-------\n\nPlease cite:\n\n* http://arxiv.org/abs/hep-ph/9906349, if you use MT2 in an academic paper, and\n* http://arxiv.org/abs/1411.4312 if you use this particular calculator.\n\nAll files in this repository are released under the MIT license.\n\n\nOther implementations\n---------------------\n\nA list of alternative implementations of the MT2 calculation can be found here:\n\nhttps://www.hep.phy.cam.ac.uk/~lester/mt2/#Alternatives\n\nIn Python, the other wrapper of the same algorithm known to the authors is by Nikolai Hartmann, here: https://gitlab.cern.ch/nihartma/pymt2\n\n\nAuthors\n-------\n* @kesterlester: Original C++ implementation of mT2.\n* @rupt: Current C++ implementation used in this package.\n* @tpgillam: Python packaging\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpgillam%2Fmt2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftpgillam%2Fmt2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpgillam%2Fmt2/lists"}