Physics

Debian set up for hep-ph computing

This is a note of my setting-up a Debian computer for high-energy physics (phenomenology) computing.

Debian configuration

sshd

As usual, configure sshd with publickey-based authorization.

/etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $

# only important changes; snipped everything else

LoginGraceTime 10s
PermitRootLogin no
StrictModes yes

PubkeyAuthentication yes

PasswordAuthentication no
PermitEmptyPasswords no

AcceptEnv LANG LC_*

python (with pyenv)

$ sudo apt-get install gcc make libssl-dev libbz2-dev libreadline-dev libsqlite3-dev zlib1g-dev
$ curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
$ export PYTHON_CONFIGURE_OPTS="--enable-framework"  # should be in .zshenv etc.
$ pyenv install 2.7.14
$ pyenv install 3.6.4

Environmental variables are: (cf. misho104/dotfiles)

.zprofile
# python
export PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
eval "$(pyenv init -)"
export PYENV_VERSION=
export PYTHON_CONFIGURE_OPTS="--enable-shared" # to build .so (for CERN/ROOT-python)

CERN/ROOT with py2 and py3

This time I decided not to install root on /usr/local, but use a local directory.

$ export HEP_DIR=$HOME/HEPcodes  # should be in .zshenv
$ mkdir $HEP_DIR; cd $HEP_DIR
$ wget https://root.cern.ch/download/root_v6.12.04.source.tar.gz
$ tar zxvf root_v6.12.04.source.tar.gz

$ # for py2
$ mkdir root-py2
$ cd root-py2
$ pyenv local 2.7.14
$ find `python-config --prefix`/lib/libpython*.so   | head -1 | read LIB
$ find `python-config --prefix`/include/**/Python.h | head -1 | read HEADER
$ dirname $HEADER | read INC
$ cmake ../root-6.12.04 -Dminuit2=on -DPYTHON_INCLUDE_DIR=$INC -DPYTHON_LIBRARY=$LIB
$ make -j8
$ cd ..

$ # for py3
$ mkdir root-py3
$ cd root-py3
$ pyenv local 3.6.4
$ find `python-config --prefix`/lib/libpython*.so   | head -1 | read LIB
$ find `python-config --prefix`/include/**/Python.h | head -1 | read HEADER
$ dirname $HEADER | read INC
$ cmake ../root-6.12.04 -Dminuit2=on -DPYTHON_INCLUDE_DIR=$INC -DPYTHON_LIBRARY=$LIB
$ make -j8
$ cd ..

$ ln -s root-py2 root  # to use python2-based root

with the environmental variables

.zprofile
export HEP_DIR=$HOME/HEPcodes
export ROOTSYS=$HEP_DIR/root

if [ ! -z $ROOTSYS ] && [ -d $ROOTSYS ]; then
  export PATH=$ROOTSYS/bin:$PATH
  export ROOTLIB=`root-config --libdir`
  export LD_LIBRARY_PATH=$ROOTLIB:$LD_LIBRARY_PATH
  export PYTHONPATH=$ROOTSYS/lib:${PYTHONPATH:-}
fi

I hope I do not have to switch many times... or I should prepare a command such as

function foobar(){
  [[ `python -V` =~ 'Python 3' ]] && v=3 || v=2
  @rm $ROOTSYS
  ln -s $HEP_DIR/root-py$v $ROOTSYS
}