Skip to main content

Generalised graph neural network based fast simulation tool for LHCb.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lhcb_rex-0.1.5.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lhcb_rex-0.1.5-py3-none-any.whl (3.4 MB view details)

Uploaded Python 3

File details

Details for the file lhcb_rex-0.1.5.tar.gz.

File metadata

  • Download URL: lhcb_rex-0.1.5.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for lhcb_rex-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0ac0c6e29e985ebfb4e0ad188f6f81e354a3fcdb83cfb8506b63bbfc652b624d
MD5 4da8e70eaebe7680b473190b699d92b0
BLAKE2b-256 2b692e2d419b47db11f0e6239fdd1eeb05aac49a8627eba9086cb9ea7ece971b

See more details on using hashes here.

File details

Details for the file lhcb_rex-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: lhcb_rex-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for lhcb_rex-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7421e0802f8c687b33853d336314a58defa7b13cd1c2c50762eacc6487ab24ba
MD5 a6fe4542fb97af208e760d95c21a0a27
BLAKE2b-256 6be056a7e117f9173b0420eebee8a6980c7c2cfd20c5a84676760f0cd85fa251

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page