ATLAS Exotics + SUSY Workshop 2020 pyhf
Tutorial¶
Welcome!¶
Welcome to the pyhf
tutorial given at the ATLAS Exotics + SUSY Workshop 2020!
We’ll first point you towards our documentation website (scikit-hep.org/pyhf/) and recommend that you visit it for much more detailed explanations and examples.
Let’s dive right in.
We won’t review the full pedagogy of HistFactory
, so instead we’ll point you to
the pyhf
talk at SciPy 2020.
Instead, let’s move to looking at the pyhf
API right away.
Installation¶
Make a Virtual Environment¶
$ python3 -m venv pyhf-tutorial
$ source pyhf-tutorial/bin/activate
(pyhf-tutorial) $ python -m pip install -U pip setuptools wheel
First we need to set up the ‘views’ with the right paths to ensure we use the correct pip
$ export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
$ source $ATLAS_LOCAL_ROOT_BASE/user/atlasLocalSetup.sh
$ lsetup "views LCG_96bpython3 x86_64-centos7-gcc8-opt"
$ export PYTHONPATH=/cvmfs/sft.cern.ch/lcg/views/LCG_96bpython3/x86_64-centos7-gcc8-opt/python:/cvmfs/sft.cern.ch/lcg/views/LCG_96bpython3/x86_64-centos7-gcc8-opt/lib
Then we can go ahead and create the virtual environment
$ python3 -m venv pyhf-tutorial
$ source pyhf-tutorial/bin/activate
(pyhf-tutorial) $ python -m pip install -U pip setuptools wheel
First we need to set up the ‘views’ with the right paths to ensure we use the correct pip
$ export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
$ source $ATLAS_LOCAL_ROOT_BASE/user/atlasLocalSetup.sh
$ lsetup "views LCG_96bpython3 x86_64-slc6-gcc8-opt"
$ export PYTHONPATH=/cvmfs/sft.cern.ch/lcg/views/LCG_96bpython3/x86_64-slc6-gcc8-opt/python:/cvmfs/sft.cern.ch/lcg/views/LCG_96bpython3/x86_64-slc6-gcc8-opt/lib
Then we can go ahead and create the virtual environment
$ python3 -m venv pyhf-tutorial
$ source pyhf-tutorial/bin/activate
(pyhf-tutorial) $ python -m pip install -U pip setuptools wheel
Once you have a virtual environment set up, you can use source pyhf-tutorial/bin/activate
to get back into it again. Note the prefix (pyhf-tutorial) $
on your command line, which indicates that you’re inside a virtual environment named ‘pyhf-tutorial’.
Getting pyhf¶
If you haven’t already, make a new Python 3 virtual environment and then install pyhf
from either PyPI with pip
(pyhf-tutorial) $ python -m pip install pyhf
or Conda-forge
(pyhf-tutorial) $ conda config --add channels conda-forge
(pyhf-tutorial) $ conda install pyhf
Installation Extras¶
If you’re installing from PyPI, you can also install with some of the “extras” that will be useful for doing typical HEP analysis workflows with pyhf
.
(pyhf-tutorial) $ python -m pip install pyhf[xmlio]
The ‘xmlio’ extra additionally installs uproot
to read ROOT
files.
(pyhf-tutorial) $ python -m pip install pyhf[torch,tensorflow]
The ‘torch’ extra installs pytorch
and the ‘tensorflow’ extra installs tensorflow
.
(pyhf-tutorial) $ python -m pip install pyhf[minuit]
The ‘minuit’ extra installs iminuit
.
See our installation docs for more information about installation options.
Dependencies for this tutorial¶
To get all the dependencies needed for this tutorial you can just install from the included requirements.txt
in the top level binder/
directory of the source repository
(pyhf-tutorial) $ python -m pip install -r binder/requirements.txt
Statistics References¶
For more information about some of the theoretical topics covered with pyhf
, see Kyle Cranmer’s Statistics and Data Science book.
Questions and Further Information on pyhf
¶
For more information on pyhf
please check the documentation website.
Additionally, if you have a question about the use of pyhf
not covered in the documentation, please ask a question on Stack Overflow with the [pyhf]
tag, which the pyhf
dev team watches.
If you believe you have found a bug in pyhf
, please report it in the GitHub Issues.
If you’re interested in getting updates from the pyhf
dev team and release announcements you can join the pyhf-announcements
mailing list (through Google Groups).