{"id":24081,"library":"mt2","title":"mt2 - Stransverse Mass Computation as a NumPy UFunc","description":"mt2 provides a fast, numerically stable computation of the stransverse mass (M_T2) as a NumPy universal function (ufunc). It is commonly used in high-energy physics for SUSY searches and dilepton event analysis. Current version: 1.3.1, with release cadence approximately every 3-4 months. Requires Python >=3.9.","status":"active","version":"1.3.1","language":"python","source_language":"en","source_url":"https://github.com/tpgillam/mt2","tags":["physics","high-energy-physics","numpy","ufunc","stransverse-mass"],"install":[{"cmd":"pip install mt2","lang":"bash","label":"PyPI"},{"cmd":"conda install -c conda-forge mt2","lang":"bash","label":"conda"}],"dependencies":[{"reason":"Core dependency for ufunc and array operations.","package":"numpy","optional":false}],"imports":[{"note":"No submodule or deprecated import path exists. Direct import works.","symbol":"mt2","correct":"import mt2"}],"quickstart":{"code":"import numpy as np\nimport mt2\n\n# Define transverse momenta and masses\npa = np.array([100.0, 50.0, 0.0])  # (px, py, m) for visible particle a\npb = np.array([80.0, -30.0, 0.0]) # (px, py, m) for visible particle b\npt_miss = np.array([20.0, 10.0])  # missing transverse momentum (px, py)\nm_invis = 0.0  # mass of the invisible particle\n\n# Compute M_T2\nresult = mt2.mt2(pa, pb, pt_miss, m_invis)\nprint(f\"M_T2 = {result:.2f}\")","lang":"python","description":"Compute the stransverse mass for a single event."},"warnings":[{"fix":"Upgrade to mt2>=1.2.1 and ensure numpy is compatible (numpy>=1.23,<2.1 recommended).","message":"In v1.2.1, numpy 2.0 compatibility was fixed. Older versions (pre-1.2.1) may fail with numpy 2.0.","severity":"breaking","affected_versions":"<1.2.1"},{"fix":"Use standard `import mt2`. If you relied on internal paths, adjust imports accordingly.","message":"In v1.2.2, the Python source code was moved to src/mt2 to avoid import confusion. Direct imports from the old location (e.g., import mt2 as before) still work, but any references to internal modules may break.","severity":"breaking","affected_versions":">=1.2.2"},{"fix":"Use keyword arguments or check the new signature: mt2(pa, pb, pt_miss, m_invis, ...).","message":"In v1.2.0, the function signature changed: the argument order was updated for consistency. Old code using positional arguments may break.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Ensure pt_miss is a 1D array of length 2. Use e.g. np.array([px, py]).","message":"The `pt_miss` vector must have exactly 2 elements (px, py). Providing a 3-element vector (e.g., (px, py, m)) will cause an error.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to >=1.3.0 or explicitly clip negative masses to zero before passing to mt2.","message":"Negative masses in input are clipped to zero in v1.3.0 and later. In earlier versions, negative masses might produce undefined results or errors.","severity":"gotcha","affected_versions":"<1.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install mt2` or `conda install -c conda-forge mt2`.","cause":"The package is not installed or installed in an incorrect environment.","error":"ModuleNotFoundError: No module named 'mt2'"},{"fix":"Upgrade mt2 to >=1.2.1 and ensure numpy is compatible: `pip install 'mt2>=1.2.1'`.","cause":"A version mismatch between numpy and mt2 (e.g., numpy 2.0.0 with mt2 <1.2.1).","error":"ImportError: numpy.core.multiarray failed to import"},{"fix":"Reshape inputs to have consistent leading dimensions, ensuring pa, pb, pt_miss are all 1D arrays of same length or broadcastable.","cause":"Input arrays have incompatible shapes. mt2 expects either scalar or 1D arrays of same length or broadcastable shapes.","error":"ValueError: operands could not be broadcast together with shapes"},{"fix":"Check shapes: pa.shape == (3,), pb.shape == (3,), pt_miss.shape == (2,). For arrays, ensure last dimension is correct.","cause":"pa or pb must have exactly 3 elements (px, py, m) and pt_miss exactly 2 elements (px, py). This error arises from wrong shape.","error":"AssertionError: Invalid input dimensions"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}