Skip to main content

Rex Banner

Rex

Rex offers a fast emulation of the LHCb detector simulation. From truth level kinematics to reconstructed quantities and all commonly used reconstruction quality variables.

Table of Contents

About

A full description of the tool can be found in this 📖 arXiv preprint.

📖 pypi | 📖 Project Docs | 💬 Mattermost Chat | 📬 Developer Email

Installation

On lxplus

Set some environment variables

export REX_DIR=/afs/cern.ch/work/X/XXXXXXX/Rex_install
export REX_WEIGHT_DIR=$REX_DIR  # note without this variable set weights default to ~/.cache/lhcb_rex/
export RAPIDSIM_ROOT=$REX_DIR/RapidSim

Make package install directory

mkdir $REX_DIR

Install RapidSim

source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh LCG_105 x86_64-el9-gcc11-opt
cd $REX_DIR && git clone git@github.com:gcowan/RapidSim.git && cd RapidSim && mkdir build && cd build && cmake .. && make -j4 && cd $REX_DIR

for full use of the package we also need an EVTGEN install evtgen.hepforge.

export EVTGEN_ROOT=....

Create new localised python environment and install lhcb_rex

export UV_CACHE_DIR=$REX_DIR/.uv-cache # overwrite UV cache directory, default is ~/.cache/uv but quota is small here
uv venv --python 3.9
source $REX_DIR/.venv/bin/activate
uv pip install lhcb_rex

remove any reference to /cvmfs/ from PYTHONPATH (had problemes with cross-contamination)

export PYTHONPATH=$(echo "$PYTHONPATH" | tr ':' '\n' | grep -v "/cvmfs/sft.cern.ch" | paste -sd ':' -)

Check install has succeeded

python -c "import lhcb_rex"

or

python -c 'import lhcb_rex; lhcb_rex.run(events=1000,decay="Bs0 -> mu+ mu-",naming_scheme="MOTHER -> DAUGHTER1 DAUGHTER2",decay_models="PHSP -> NA NA",workingDir="./Bs_mumu",)'

the above took ~10 mins on lxplus, woefully slow. It took about 50 seconds (including all initialisation time) on cpu at my university cluster, 20 seconds on GPU node (mostly configuration time).

Create ~/rex_setup.sh to configure environment next time, something like this

export REX_DIR=/afs/cern.ch/work/X/XXXXXXX/Rex_install
export REX_WEIGHT_DIR=$REX_DIR
export RAPIDSIM_ROOT=~/RapidSim
source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh LCG_105 x86_64-el9-gcc11-opt
export PYTHONPATH=$(echo "$PYTHONPATH" | tr ':' '\n' | grep -v "/cvmfs/sft.cern.ch" | paste -sd ':' -)
source $REX_DIR/.venv/bin/activate

then on login

source ~/rex_setup.sh

Note, if you want progress bars printed whilst RapidSim runs you need to install this patch

cd $RAPIDSIM_ROOT
git apply <(curl -L https://raw.githubusercontent.com/alexmarshallbristol/Rex-image/refs/heads/master/print_n.patch)
cd build
make

Usage

Examples below

Click to see an example
import lhcb_rex

lhcb_rex.run(
    events=1000,
    decay="Bs0 -> mu+ mu-",
    naming_scheme="MOTHER -> DAUGHTER1 DAUGHTER2",
    decay_models="PHSP -> NA NA",
    workingDir="./Bs_mumu",
)

Installation for development

git clone
uv sync
uv run pip install -e .

📬 Have questions? Reach out at alex.marshall@bristol.ac.uk

Notes for me

/dice/users/am13743/fast_vertex_quality/graveyard/ /dice/users/am13743/fast_vertex_quality/checkpoints/

Relevant tags/checkpoints:

  • 21_03_2025 - Plotting for paper draft
rm -rf dist/
uv build
uv publish
uv run pip install --no-deps --upgrade --force-reinstall -e . # to update the version number as in pyproject.toml

Metadata

Release files for lhcb-rex 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lhcb-rex 0.1.5
File Size Uploaded
lhcb_rex-0.1.5.tar.gz 3.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for lhcb-rex 0.1.5
File Interpreter ABI Platform
lhcb_rex-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 MB

Release files / lhcb_rex-0.1.5.tar.gz

Download URL lhcb_rex-0.1.5.tar.gz
Size 3.4 MB
Tags Source
SHA-256 checksum
How to use checksums
0ac0c6e29e985ebfb4e0ad188f6f81e354a3fcdb83cfb8506b63bbfc652b624d
BLAKE2b-256 checksum
How to use checksums
2b692e2d419b47db11f0e6239fdd1eeb05aac49a8627eba9086cb9ea7ece971b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Release files / lhcb_rex-0.1.5-py3-none-any.whl

Download URL lhcb_rex-0.1.5-py3-none-any.whl
Size 3.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7421e0802f8c687b33853d336314a58defa7b13cd1c2c50762eacc6487ab24ba
BLAKE2b-256 checksum
How to use checksums
6be056a7e117f9173b0420eebee8a6980c7c2cfd20c5a84676760f0cd85fa251
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page