Tips & Tricks
Key generation for SSH
If you do not like to keep having to enter your password, have a look at generating an ssh key here and here.
Generate a key with the command
ssh-keygen. You can choose to leave the password empty.Add the SSH key to the
ssh-agentand create a corresponding public key with the commands:eval $(ssh-agent -s); ssh-add ~/.ssh/id_rsaCopy the public key to the server using:
ssh-copy-id -i ~/.ssh/id_rsa.pub <your user name>@lxlogin.ihep.ac.cnYou will be asked for your IHEP account password.
Try to log in to the server with:
ssh -Y <your user name>@lxlogin.ihep.ac.cnIf all went correctly, you don’t have to enter your password anymore.
Installing ROOT
The BOSS Starter Kit comes with a handy bash script to download and install CERN ROOT6 on a Ubuntu platform. It requires you to have sudo (admin) rights. The script can be run in one go using:
wget https://raw.githubusercontent.com/redeboer/BOSS_StarterKit/master/utilities/InstallCernRoot.sh
sudo bash InstallCernRoot.shFor more information, see the official pages:
You will download around 1 GB of source code.
Visual Studio Code
Visual Studio Code (VSCode) is a popular IDE that is regularly updated, is configurable with easy-to-access json files, and offers a growing number of user-developed extensions. In recent years, it is has become the most widely used editor on the market.
Remote SSH
For working with VSCode on lxlogin, you can use the Remote - SSH extension. This lets you with VSCode work on the server with full functionality, such as using the Source Control Manager and language navigation from any other VSCode extensions you installed. See here for a tutorial on how to connect to a remote SSH server.
There is one thing you need to change in your VSCode settings. Following these instructions, set the following option:
VSCode also recommends settings "remote.SSH.showLoginTerminal": true, but this seems not to be required to get VSCode to run on the IHEP server.
"remote.SSH.useLocalServer": false,VSCode Remote SSH installs some files into your home directory on the server, in a folder called .vscode-server. It is therefore recommended that you set the installation location for the .vscode-server folder to a directory where you always have read-write access. This can be done in VSCode by the setting:
"remote.SSH.serverInstallPath": {
"ihep": "/besfs5/users/<USERNAME>"
},The <USERNAME> needs to be replaced with your clustering account name.
In addition, you may need to set the remote platform to "linux":
"remote.SSH.remotePlatform": {
"lxlogin.ihep.ac.cn": "linux"
},where "lxlogin.ihep.ac.cn" is the name of the host in your SSH Config file.
As an alternative you can move the .vscodefolder and create a symbolic link in your home directory. Do this as follows:
cd ~
mkdir /besfs5/users/$USER/.vscode-server
ln -s /besfs5/users/$USER/.vscode-serverAn existing .vscode-server folder in your home directory can cause Visual Studio Code to get stuck at trying to download the server configuration. The solution is to move the existing .vscode-server folder to the new location:
cd ~
mv -f .vscode-server /besfs5/users/$USER/
ln -s /besfs5/users/$USER/.vscode-serverFor the (rather common) problem of a permission error when trying to move the directory, see here.
Another major advantage of this set-up is that you won’t have problems with data quota when the .vscode-server grows over time.
Compiling
For compiling outside ROOT (that is, not using the ROOT interpreter), you will need to use a compiler like g++. The compiler needs to be told where the libraries for included ROOT header files are located. You can do this using flags that ROOT set during its installation. In case of g++, use:
g++ YourCode.C -I$(root-config --incdir) $(root-config --libs --evelibs --glibs) -o YourBinaryOutput.obash tip
You might like to create an easy command for this. You can do this by adding the following lines to your ~/.bashrc.
function rtcompile () {
g++ "$1"
-I$(root-config --incdir) \
$(root-config --libs --evelibs --glibs) \
-lRooFit -lRooFitCore -lRooStats -lMinuit -o "${1/._/.o}"
}
function rtcompilerun () {
rtcompile "$1"
if [ $? -eq 0 ]; then
./${1/._/.o}
fi
}
function rtdebugcompile () {
g++ "$1"
-I$(root-config --incdir) \
$(root-config --libs --evelibs --glibs) \
-lRooFit -lRooFitCore -lRooStats -lMinuit -fsanitize=address -g -o "${1/.\*/}"
}
export -f rtcompile
export -f rtcompilerun
export -f rtdebugcompileNote the flags added through root-config: there are includes (preceded by option -I) and linked libraries (following that option, and preceding output option -o). Note also that flags have been added for RooFit. For more information about ROOT flags, see this page.
Here, we give three examples of commands, one for compiling only (rtcompile), one for compiling and executing if successful (rtcompilerun), and one for compiling with fsanitize activated (rtdebugcompile). The latter is useful if you want to look for memory leaks etc — only use if you are interested in this, because it will decrease run-time. In addition, there are many issues in root (like TString) that are identified by fsanitize.
Compiling on Windows 10
Although it is highly recommended to on a Linux OS such as Ubuntu or CentOS, there are still -certain advantages of working on Windows. As a developer, that brings problems, however, if you want to start compiling your code.
Since Windows 10, there exists an easy solution: Windows Subsystem for Linux (WSL). In the newest versions can be easily installed from the Windows Store (search for “Ubuntu”). After installing, search for “Ubuntu” in the start menu. This is a bash terminal that has full access to your windows system, but entirely through bash commands.
As such, you have access to convenient commands like apt install, vi, and g++. Best of all is that you can use this to install ROOT. If you are having trouble installing ROOT through bash, have a look at this script (ROOT6).