mu3e software on merlin and macs and whatnot

mu3e offline software

The official documentation at bitbucket is a bit sparse. In the following comments that might be helpful in setting up (offline) mu3e software on linux boxes, the merlin cluster at PSI, and also BSD Unix (MacOS). This webpage provides hints for installing the mu3e software, another webpage provides information on how to obtain results using the software. Before discussing the installation of mu3e software, we describe the usage of the centrally maintained mu3e software on merlin. 
 

 

Usage of mu3e software on merlin using centrally installed s/w components

To install mu3e software on merlin, using centrally installed dependencies, source the following (tcsh/csh setup, you'll have to translate to bash if required)

source /data/experiment/mu3e/code/external/root/root6-22-06/install/bin/thisroot.csh source /data/experiment/mu3e/code/external/geant/geant4.10.07.p04/install/bin/geant4.csh /data/experiment/mu3e/code/external/geant/geant4.10.07.p04/install/bin module use unstable module load gcc/10.3.0 module load boost/1.76.0 module load git/2.37.0 module load cmake/3.23.2 module load cuda/11.2.2 module load eigen module -s load Qt/5.12.10

Make sure that you have a bitbucket account (see below) and then check out the complete mu3e software stack (I think this is the way how things work at the moment)

cd /data/user/$USER # or somewhere else git clone git@bitbucket.org:mu3e/mu3e mu3e-test-dev cd mu3e-test-dev git submodule update --init --recursive

Compile the software

mkdir _build && cd _build cmake -DCMAKE_BUILD_TYPE=Debug .. make -j20

For the subsequent procedures, have a look at this page or search the twiki.

Prerequisites

Before installing mu3e/sw on a linux box, the following dependencies need to be fulfilled: 
 
  • Git/cmake/boost/eigen3/svn(subversion)
     
  • bitbucket account to obtain the mu3e/sw, likely send an email to Nik to add you to the mu3e team.
     This also implies that you should create ssh keys on the local machine that you deposit in bitbucket:
ssh-keygen -t rsa -b 4096 -C "your.email@somewhere.universe"

 

  • An empty pass-phrase (i.e. hitting return, twice) seems OK, the default location ~/.ssh/id_rsa as well. Then go to your bitbucket account settings->Security->ssh keys and add the contents of ~/.ssh/id_rsa.pub into the key field. 
     
  • root Root must be (re)compiled with C++-17 from source. See link (and also below) for how to do this. Trying to work with root not recompiled locally is (most likely) a waste of time.
     
  • Qt5
     
  • Geant4
See below for specific comments on the different platforms (merlin and macos in particular).

If you install/compile any of the above, it is recommended to use the same tools as later on for the mu3e/sw. On merlin, the following will work: 

module use unstable module load gcc/10.1.0 module load boost/1.73.0 module load cmake/3.19.2 module load Qt/5.12.10

merlin and linux

The following was tested on merlin and an OpenSuse 15.1 Leap system (where Qt and Geant4 are located at other places) but should work on other distributions as well.

Fullfilling prerequisites

  • Build Geant (assuming you have qt5 installed somewhere and somehow; on merlin the Qt5 using module is used). Note that (1) this step will disappear once mu3e provides its own Qt5-compiled GEANT4 build,  (2) of course you can leave away the debug and multithreading options to have a faster GEANT4, and (3) you can leave away the VERBOSE=1 flag and have a smaller logfile. 
cd /to/some/scratch/space mkdir g4-build && cd g4-build cmake -DCMAKE_INSTALL_PREFIX=../g4-install \ -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_USE_OPENGL_X11=ON \ -DGEANT4_BUILD_MULTITHREADED=OFF \ -DCMAKE_BUILD_TYPE=Debug \ -DGEANT4_BUILD_CXXSTD=17 \ -DGEANT4_USE_QT=ON \ -DQT_QMAKE_EXECUTABLE=/opt/psi/Programming/Qt/5.12.10/5.12.10/gcc_64/bin/qmake \ /data/experiment/mu3e/code/external/geant/geant4.10.07/ make VERBOSE=1  -j9 >& make.log & make install # test it: cd ../examples/basic/B1 mkdir _build && cd _build cmake .. make -j9 ./exampleB1
Notes:  
(1) if you use a MAC to log into a linux box, you might be getting a window without geometry built. This bug is not resolved as far as I know and is probably the MAC's fault with openGL. It is normally not present when running remotely from another Linux box.
(2) It is essential to compile with C++-17!
(3) bitbucket  claims that Geant and Qt5 are not absolutely required. This is not correct at the moment. You need them. 
(4) If you don't have the GEANT4 source code, get it from CERN.
 
  • Generate ssh keys and deposit them in bitbucket
ssh-keygen -t rsa
and deposit the public file in your bitbucket account (after logging into bitbucket, go to your Settings->Security->SSH Keys, click on 'Add key', and paste the contents of ~/.ssh/id_rsa.pub on your linux box).

Get and install the mu3e software

Setup your environment (this is required because you want to rely on some central software such as root, Qt5, etc)

source /data/experiment/mu3e/code/external/root/root6-22-06/install/bin/thisroot.csh # -- in the following line replace the path to the GEANT4: source /psi/home/langenegger/data/g4-install/bin/geant4.csh /psi/home/langenegger/data/g4-install/bin # -- the following should be consistent with the above settings module use unstable module load gcc/10.1.0 module load boost/1.73.0 module load cmake/3.19.2 module load Qt/5.12.10 setenv  ROOT_DIR "/data/experiment/mu3e/code/external/root/root6-22-06/install" setenv  CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}:/data/experiment/mu3e/code/external/Eigen3/eigen3-3-9:/psi/home/langenegger/data/g4-install" setenv BOOST_ROOT "/opt/psi/Compiler/boost/1.73.0/gcc/10.1.0/" setenv EIGEN3_INCLUDE_DIR /data/experiment/mu3e/code/external/Eigen3/eigen3-3-9 setenv PATH ${PATH}:/opt/psi/Programming/Qt/5.12.10/5.12.10/gcc_64/bin/ setenv LD_LIBRARY_PATH /opt/psi/Programming/Qt/5.12.10/5.12.10/gcc_64/lib:${LD_LIBRARY_PATH}

For bash, you'll have to translate this
(e.g. export BOOST_ROOT="/opt/psi/Compiler/boost/1.73.0/gcc/10.1.0/"). 
In case it were useful, you could use langenegger's GEANT  installation for the time being. 

Dowload the software from bitbucket and checkout a specific branch:

git clone git@bitbucket.org:mu3e/mu3e mu3e-v4.6 cd mu3e-v4.6 git checkout tags/v4.6 git submodule update --init --recursive

Compile

mkdir _build && cd _build cmake [-DCMAKE_BUILD_TYPE=Debug] .. make -j9 >& make.log & # with the trirec event display (works on a linux box, but NOT merlin): cmake -DMU3E_TRIREC_DISPLAY=yes .. make -j9 >& make.log &

 

For the event display on merlin, things are a bit more complicated because the system libraries (/usr/lib64/libgtkmm-3.0.so) are not compatible with gcc/10.1.0. Y0u need to apply a patch 

diff --git a/mu3eTrirec/CMakeLists.txt b/mu3eTrirec/CMakeLists.txt index d6abece..101cc2f 100644 --- a/mu3eTrirec/CMakeLists.txt +++ b/mu3eTrirec/CMakeLists.txt @@ -21,12 +21,19 @@ target_include_directories(mu3eRecLib PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> ) +if(GTKMM_LOCALDIR) + set(CMAKE_LIBRARY_PATH ${GTKMM_LOCALDIR}) + find_library(GTKMMLOCAL cairomm-1.0) +else() + set(GTKMMLOCAL "") +endif() + if(MU3E_TRIREC_DISPLAY) target_compile_definitions(mu3eRecLib PUBLIC MU3E_TRIREC_DISPLAY) find_package(PkgConfig REQUIRED) pkg_check_modules(GTKMM REQUIRED gtkmm-3.0) target_link_libraries(mu3eRecLib PUBLIC - ${GTKMM_LIBRARIES} + ${GTKMMLOCAL} ${GTKMM_LIBRARIES} ) target_include_directories(mu3eRecLib SYSTEM PUBLIC ${GTKMM_INCLUDE_DIRS}

You can apply the patch as follows (from within the _build directory): 

patch ../mu3eTrirec/CMakeLists.txt ~langenegger/mu3e/patches/210706-mu3eTrirec-CMakeLists.patch

and invoke cmake as follows: 

cmake -DMU3E_TRIREC_DISPLAY=yes -DGTKMM_LOCALDIR=/psi/home/langenegger/data/misc/lib ..

For this case, the recommendation is to stay with langenegger's libraries for the time being (installing yourself will imply also get meson and ninja in addition to the s/w you are interested in). 

Then continue building as above (make ...)

Run the mu3e/sw

Running the software should now work

cd ../run mkdir data perl -pi -e "s/setRunNumber 779/setRunNumber 1/" run1.mac ../_build/mu3eSim/mu3eSim --script run1.mac ../_build/mu3eSim/sort/mu3eSort 1 ../_build/mu3eTrirec/mu3eTrirec data/mu3e_sorted_000001.root data/mu3e_trirec_000001.root

BSD UNIX (a.k.a. MacOS)

The following was tested and runs on MacOS Catalina 10.15.7 (but, alas, only with older CLANG versions). The compilation of all components takes a while. Your mileage may vary. If you have constructive feedback, please send it to me via email.  


Note: mu3e (watson) does not compile with CLANG on Big Sur 11.4, mostly because of issues with the templated tuple usage (I think). 

Fullfilling prerequisites

  • download xcode (from the AppStore) and install command-line tools:
xcode-select --install
  • get brew (do this in a bash, and change to one if bash is not your default):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  • get cmake from cmake.org and install it. Get executable into a directory in your path, e.g.
cd /opt/local/bin sudo ln -s sudo ln -s /Applications/CMake.app/Contents/bin/cmake
  • get root from CERN and compile it locally with C++-17 (important!):
cd /usr/local/ sudo git clone --branch v6-24-00 https://github.com/root-project/root.git root-062400_src sudo mkdir root-062400_build sudo mkdir root-062400 cd root-062400_build sudo cmake -DCMAKE_CXX_STANDARD=17 \ -Dminuit2=on -Droofit=on \ -DCMAKE_INSTALL_PREFIX=../root-062400 \ ../root-062400_src sudo cmake --build . -target install -- -j9 sudo make install
 
  • Get and build Qt5 (Geant is not much fun without this):
cd /usr/local sudo git clone https://code.qt.io/qt/qt5.git cd qt5 sudo git checkout 5.15 sudo perl init-repository cd .. sudo mkdir qt5_build cd qt5_build sudo ../qt5/configure -c++std c++17 -developer-build -opensource -nomake tests sudo make -j8 sudo make install [?]
  • Get and build GEANT: 
cmake -DCMAKE_INSTALL_PREFIX=/opt/local/geant4.10.04.p02-withQt-install \ -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_BUILD_CXXSTD=17 \ -DGEANT4_USE_QT=ON \ -DQT_QMAKE_EXECUTABLE=/opt/local/qt/5.15.0/clang_64/bin/qmake \ ../geant4.10.04.p02 make VERBOSE=1 -j9 >& make.log & make install # test it: cd /opt/local/geant4.10.04.p02-withQt-install/share/Geant4-10.7.0/examples/basic/B1 mkdir _build && cd _build cmake .. make -j9 ./exampleB1
  • Get other prerequisites:
brew install svn brew install eigen brew install boost brew install gtkmm3 
  • setup ssh keys:
ssh-keygen -t rsa
and deposit the public file in your bitbucket account (after logging into bitbucket, go to your Settings->Security->SSH Keys, click on 'Add key', and paste the contents of ~/.ssh/id_rsa.pub on your linux box).

 

Compiling

Dowload software from bitbucket and checkout a specific branch:

git clone git@bitbucket.org:mu3e/mu3e mu3e-v4.6_dev cd mu3e-v4.6_dev git submodule init git submodule update --init --recursive git checkout -b v4.6_dev --track remotes/origin/v4.6_dev

Apply patches (until issue is resolved) ???

perl -pi -e "s%eigen3/Eigen/%Eigen/%g" mu3eTools/mu3eMisal/mu3eMisal.cpp mu3eTools/mu3eMisal/src/transformSensors.cpp

Compile

mkdir _build && cd _build cmake [-DCMAKE_BUILD_TYPE=Debug] .. make -j9 >& make.log & cmake -DMU3E_TRIREC_DISPLAY=yes .. make

 

Running the software 

see the Linux section for general running.

For the event display: First create some input file:  

cd ../run && mkdir data perl -pi -e "s/setRunNumber 779/setRunNumber 1/" run1.mac ../_build/mu3eSim/mu3eSim --script run1.mac

Then run the event display:  

../_build/mu3eTrirec/mu3eTrirec -d --input data/mu3e_run_000001.root

CentOS 7

The following was tested on lxplus.cern.ch

lxplus766>cat /etc/os-release NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="http://cern.ch/linux/" BUG_REPORT_URL="http://cern.ch/linux/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"

Because none of the  'default' s/w components are sufficient for either mu3e s/w or the other dependencies, all need to be recompiled with a 'recent' compiler.

Tools

On lxplus I found GCC 9.3.1 (I add /opt/rh/devtoolset-9/root/bin to the front of my PATH) and that worked. The default version of  cmake is pre-historic, therefore I used cmake3 (which is 3.17.5)

The following components were compiled: 

Qt5

git clone https://code.qt.io/qt/qt5.git cd qt5 git checkout 5.15 perl init-repository cd .. mkdir qt5_build cd qt5_build ../qt5/configure -prefix ../Qt5.15.3 -c++std c++17 -developer-build -opensource -nomake tests make -j8 make install

Then add .../Qt5.15.3/bin to your PATH.

GEANT4

wget http://geant4-data.web.cern.ch/geant4-data/releases/source/geant4.10.07.p02.tar.gz tar zxf geant4.10.07.p02.tar.gz mkdir g4-build && cd g4-build cmake3 -DCMAKE_INSTALL_PREFIX=../g4-install -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_BUILD_MULTITHREADED=OFF -DCMAKE_BUILD_TYPE=Debug -DGEANT4_BUILD_CXXSTD=17 -DGEANT4_USE_QT=ON ../geant4.10.07.p02 make VERBOSE=1 -j9 make install

Then source ../g4-install/bin/geant4.csh

ROOT

git clone --branch v6-24-00 https://github.com/root-project/root.git root-062400_src mkdir root-062400_build mkdir root-062400 cd root-062400_build cmake3 -DCMAKE_CXX_STANDARD=17 -Dminuit2=on -Droofit=on -DCMAKE_INSTALL_PREFIX=../root-062400 ../root-062400_src make -j9 make install

Then source ../root-062400/bin/thisroot.csh

eigen

wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz tar zxvf eigen-3.4.0.tar.gz

boost

wget https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_… tar zxf boost_1_77_0.tar.gz cd boost_1_77_0 ./bootstrap.sh --prefix=/afs/cern.ch/user/u/ursl/work/private/mu3e/ ./b2

 

mu3e

You have to provide the location to boost and eigen: 

git clone git@bitbucket.org:mu3e/mu3e mu3e-v4.6_dev cd mu3e-v4.6_dev git submodule init git submodule update --init --recursive git checkout -b v4.6_dev --track remotes/origin/v4.6_dev mkdir _build && cd _build cmake3 -DCMAKE_PREFIX_PATH='/afs/cern.ch/user/u/ursl/work/private/mu3e/eigen-3.4.0/Eigen;/afs/cern.ch/user/u/ursl/work/private/mu3e/boost_1_77_0' [-DCMAKE_BUILD_TYPE=Debug] .. make -j8