Table of Contents
2021 July 28
Background
cdms1, cdms2, and cdms3 had been running on Scientific Linux 5, but IT wants to upgrade all computers to CentOS. cdms2 is now running on CentOS, but the K100 Geant4 simulation that Anthony wrote can't run on the CentOS machine, at least not using the standard instructions.
One possible problem is that the Geant4 installation built using SL5 may not work on the CentOS machine. Below are notes about how I got a new Geant4 installation on the CentOS machine.
If you are cloning from gitlab while sudo in spa-u-cdmssoft, the ssh key is connect to Zach's account and the passcode is '[redacted]'.
Installing Geant4 on CentOS
I had trouble getting Geant4 to install with CentOS, but I got help from Tom Eichlersmith in the CMS group. Here are the steps I followed:
ssh cdms2 sudo -u spa-u-cdmssoft -s cd /local/cdms
You need to be the sudo user to install software in the standard location we use for this, /local/cdms. You need to be in the spa-cdmssoft group for permission to do this.
Below are from instructions from Tom:
wget https://github.com/Geant4/geant4/archive/refs/tags/v10.7.2.tar.gz tar -xvf v10.7.2.tar.gz
This downloaded and unpacked a new version of Geant4.
Next is to create and source an environment file that Tom wrote. This uses the CERN cvmfs system. This gives specific control over the version of gcc and cmake that get used when you try to compile the Geant4 code. Here is a copy of the file: geant4-centos-env.sh. Then we source this file:
source geant4-centos-env.sh
Then the following lines to configure and do the Geant4 build:
cmake -DGEANT4_INSTALL_DATA=ON -DCMAKE_INSTALL_PREFIX=geant4-10.7.2-install -DGEANT4_USE_GDML=ON -DXercesC_ROOT=${XERCESDIR} -B geant4-10.7.2-build -S geant4-10.7.2/
cmake --build geant4-10.7.2-build --target install -- -j4
It takes a long time to compile everything, but this worked without an error. It creates the directory /local/cdms/geant4-10.7.2-install
Finally, following Tom's instructions, I modified the environment file to include two more lines that point to the new geant4 install directory. According to Tom, this should be sourced before any sim install that uses this new Geant4.
Getting visualization to work with the Geant4 installation
After installing Geant4 and the K100 simulation using Tom's instructions, we found that none of the visualization commands in the macros worked, although the simulation worked otherwise (produced output files). That's because Tom used an installation that assumed large batch job simulations, with no graphics package installed.
He suggested the following steps to add visualization to the existing Geant4 build. First, go to /local/cdms and set things up:
ssh cdms2 sudo -u spa-u-cdmssoft -s cd /local/cdms source geant4-centos-env.sh
Then these lines should theoretically add OPENGL visualization to our existing Geant4:
cmake -B build -S geant4-10.7.2/ -DGEANT4_USE_OPENGL_X11=ON cmake --build geant4-10.7.2-build --target install -- -j4
I tried the above and it finished without errors. But the visualization lines in the macros still didn't work. I tried reinstalling k100Sim, but it still didn't work. Tom said that if the above doesn't work, to try something else…
Visualization, second attempt
The other thing Tom said to try to get visualization to work was to redo the original Geant4 build with an additional option in the cmake command:
ssh cdms2 sudo -u spa-u-cdmssoft -s cd /local/cdms source geant4-centos-env.sh
cmake -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_INSTALL_DATA=ON -DCMAKE_INSTALL_PREFIX=geant4-10.7.2-install -DGEANT4_USE_GDML=ON -DXercesC_ROOT=${XERCESDIR} -B geant4-10.7.2-build -S geant4-10.7.2/
cmake --build geant4-10.7.2-build --target install -- -j4
Installing k100Sim on CentOS
First attempt at this failed. I followed Anthony's instructions, using a clone of the k100sim source that I put in my home directory.
cd mkdir test_simcode cd test_simcode git clone /data/giacdms1/villaa/repositories/k100Sim
Then I made a build folder in my home directory and navigated to it:
cd mkdir testbuildcdms2_tom cd testbuildcdms2_tom
I sourced the cvmfs file from Tom:
source /local/cdms/geant4-centos-env.sh
Then I followed Anthony's instructions (modified to point to the new Geant install) to compile the code:
cmake -DGeant4_DIR=/local/cdms/geant4-10.7.2-install/lib64/Geant4-10.7.2/ ../test_simcode/k100Sim make
But I got an error:
[fritts@spa-cdms2 ~/testbuildcdms2_tom]: make
Scanning dependencies of target k100Sim
[ 5%] Building CXX object CMakeFiles/k100Sim.dir/k100Sim.cc.o
In file included from /home/fritts/test_simcode/k100Sim/include/Shielding_ComptonsUpdate.hh:72,
from /home/fritts/test_simcode/k100Sim/k100Sim.cc:41:
/home/fritts/test_simcode/k100Sim/include/Shielding_ComptonsUpdate.icc:75:10: fatal error: G4DataQuestionaire.hh: No such file or directory
#include "G4DataQuestionaire.hh"
^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Modifying the k100Sim source code
Googling “G4DataQuestionaire.hh” I found someone else working on CentOS had the same error and was told that that file had been retired from later Geant and that you should be able to remove it from the sim code. I navigated to the sim code and found where this file is referenced:
cd cd test_simcode/k100Sim/ gedit include/Shielding_ComptonsUpdate.icc &
In this file I commented out the three lines that mention “G4DataQuestionaire.hh”. Then I repeated the install instructions:
cd cd testbuildcdms2_tom source /local/cdms/geant4-centos-env.sh cmake -DGeant4_DIR=/local/cdms/geant4-10.7.2-install/lib64/Geant4-10.7.2/ ../test_simcode/k100Sim make
This time it finished without errors.
Failed attempt to run the sim on CentOS
BUT: running the sim failed, throwing an error I've seen many times before:
[fritts@spa-cdms2 ~/testbuildcdms2_tom]: ./k100Sim macros/pubeTest.mac ./k100Sim: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
Second attempt
2020-07-29
Tom Eichlersmith was able to successfully compile and run the K100 sim, so I tried repeating his steps. The steps below are a bit modified from Anthony's original.
ssh cdms2 cd /export/scratch/users/fritts git clone /data/giacdms1/villaa/repositories/k100Sim cd k100Sim source /local/cdms/geant4-centos-env.sh cmake -B build -S . -DROOT_INCLUDE_DIR=$(root-config --incdir) cmake --build build ./build/k100Sim macros/pubeTest.mac
However when I tried this I got the libpcre.so.0 error again. Which made it clear that something in my .bashrc was screwing things up. I tried deleting everything from my .bashrc, and the code actually ran!
However there was an error: it didn't recognize the command “/vis/scene/create” in the macro. Tom suggests that probably that command has been retired from Geant4 too and that we need to look up an alternative. When I comment out all of the visualization lines the macro runs to completion.
Tom concluded that a line in my .bashrc that points to a specific installation of Root is causing the error.
Working instructions
Assuming:
- you have already cloned the k100Sim source code and you are in the directory that k100Sim is in,
- you've edited the code as mentioned above,
- you have nothing in your .bashrc
Then these steps should work for compiling the k100Sim:
mkdir k100SimBuild cd k100SimBuild source /local/cdms/geant4-centos-env.sh cmake -S . -DROOT_INCLUDE_DIR=$(root-config --incdir) ../k100Sim cmake --build .