Jacob's collection of useful tutorials and tips

Computing at PP RHUL

How to mount your pphome on your personal laptop/computer at RHUL

This is a particularly useful tip if you, like myself, want to edit files from your local machine running the latest version of emacs. More often then not the version available on linappserv is either outdated or simply too vanilla for you. I run Aquamacs on my MacBook which has several customizations specific to OS X and the Mac.

N.B. You need to be within PP network, either via the wired network or the Stella wireless network. Check below for instructions on how to mount your pphome from outside of the network.

There are two ways to mount your pphome folder to a local directory depending on whether you're on a UNIX-type or a Windows-type enviornment. Since I'm using OS X I'll focus on mounting using NFS, keep in mind that this also works on Linux operating systems as well.

The first step is to make sure that your UID is synced between our Linux environment and your personal machine.

!!SUPER IMPORTANT!!: Keep in mind that this process is potentially dangerous and should be done with care, you may literally lock yourself out of your own home folder so please back-up everything you hold dear before proceeding, and whatever happens you CANNOT hold me accountable.

Now that we have the disclaimer out of the way, let's get to it. If you don't know how to change your UID there are several tutorials for both Linux and OS X. I can only vouch for the OS X tutorial since I used it myself, the Linux one however seems fairly good as well. So if you're using Linux you need this tutorial and if you're on a Mac follow this tutorial. Keep in mind that for both you need to figure out your current UID and the UID you want to change to. To get the second one, log into linappserv using your account and perform the following command:

[jblanco@linappserv0 ~]$ stat ~/

This should produce the following:

  File: `/home/jblanco/'
  Size: 59           Blocks: 8          IO Block: 4096   directory
Device: 24h/36d   Inode: 3           Links: 29
Access: (0755/drwxr-xr-x)  Uid: ( 1234/ jblanco)   Gid: (  120/    hep2)
Access: 2011-05-25 14:23:02.212553501 +0100
Modify: 2011-05-25 14:14:14.746438370 +0100
Change: 2011-05-25 14:14:14.746438370 +0100

Note the UID number in the output. Make sure to use YOUR UID when following the above tutorials. Before you ask, no that's NOT my UID.

Once you have changed your UID and made sure that all the appropriate ownerships have been changed and directories have been renamed we can proceed to mount the NFS share.

On Mac OS X this can be easily accomplished from Disk Utility.app. First of all create a new mount directory either through the terminal or Finder. Now, in your dock click on Applications->Utilities->Disk Utility, here select File->NFS Mounts... A new window should open with an empty list, select the + sign to add a new mount. The address should be of the following form, making sure you replace jblanco with your Linux username:


and the mount point should point to the directory that you just created. Select Verify, you should barely see the confirmation message if all is well.

On Linux It can be a bit trickier and what method you use depends on what's available for your distro, the safest bet is to edit your fstab file, this contains the information for all mounted drives. As always be careful before doing anything that might break your installation, your machine or yourself. Here is a link to a wiki page on NFS shares for Ubuntu, but the information should be relevant to most distros.

Enjoy your new found productivity boost. smile

How to mount your pphome on your personal laptop/computer OUTSIDE of RHUL

Note: The following tutorial applies to both Mac OS X and Linux, however it requires SSHFS and I haven't been able to get SSHFS to work under OS X since it has a strange implementation of FUSE and requires some minor hacking. Once I've got this running on Mac OSX I will update this tutorial.

Make sure that you can ssh into linappservX successfully, because we are going to use and ssh-tunnel to mount your pphome.

Depending on your distributions you will have to use a different package manager to install sshfs, for Ubuntu just run:

[User@Machine ~] sudo apt-get install sshfs
Now create a new directory where your pphome will be mounted and run the appropriate sshfs command:
[User@Machine ~] mkdir /Some/Directory
[User@Machine ~] sshfs jblanco@linappservX.pp.rhul.ac.uk:/home/jblanco

Replacing jblanco with your home directory name and typing the password when prompted.

BOOM! you have access from the outside

ROOT Tutorials

Compiling ROOT in Ubuntu

Download the relevant source file from the ROOT website to your desktop. In this tutorial I'm using version 5.26 but this should apply to any recent release.

First open up a terminal and run the following commands:

[User@Machine ~]$ mkdir root-build
[User@Machine ~]$ cp ~/Desktop/root_v5.26.00.source.tar.gz ~/root-build
[User@Machine ~]$ cd ~/root-build
[User@Machine ~]$ tar -xvf root_v5.26.00.source.tar.gz
[User@Machine ~]$ cd root

We just created a new directory in your Home directory, then extracted the source files there. To keep things organized I place sources in a dedicated directory inside my home.

Now we need to download some extra packages to resolve dependencies. Depending on what extra functionality you need, you might want to download/compile other packages. Thankfully aptitude, the package manager bundled with Ubuntu, will help you download all the packages you need and a few that you may not but which add extra functionality.

In the terminal run the following commands to download the necessary packages and configure your build of ROOT:

[User@Machine ~]$ sudo aptitude build-dep root-system
[User@Machine ~]$ ./configure

This will make sure that you have everything you need to compile ROOT. If at any point you're told that some library is missing, note the name of the library and install it by running:

[User@Machine ~]$ sudo apt-get install *NAME OF PACKAGE*-dev

N.B. Packages ending in -devel will appear in the Ubuntu repo's as *NAME*-dev. The suffix -devel is part of the convention used in Red Hat and its variants like SLC4/5. If the package you need is missing, try googling around for the package name to find the equivalent, hopefully the build-dep command will provide you with all you need.

If you have any special configuration requirements such as Pythia interface or Python support make sure that the relevant libraries are present, you can run the command:

[User@Machine ~]$ ./configure --help

to check if you need to define paths to any libraries or include files. If all has gone well with configuring, simply compile ROOT by running:

[User@Machine ~]$ make

This should begin compiling ROOT for you, now I can't stress this enough, compiling could take A LONG TIME so don't worry.

Now we need to set a couple of environmental variables. In the terminal again,

[User@Machine ~]$ sudo gedit ~/.bashrc

and add the following lines to your bashrc file to configure where ROOT will be installed to:

export ROOTSYS=/usr/local/root
export PATH=$ROOTSYS/bin:$PATH

Of course if you want to install it to any other location make sure you change the ROOTSYS path above.

Re-source your bash configuration file and install:

[User@Machine ~]$ . ~/.bashrc
[User@Machine ~]$ make install

This should copy all files needed to the ROOTSYS folder you specified in your bash configuration. This should let you run ROOT in the normal way.

Enjoy smile

Making beautiful 2D plots

If you've ever made 2D plots in ROOT using the colz command you know how ugly the colours are. If you have no idea what I'm talking about look at the plot on the left, here I'm gonna show you how to turn that into the plot on the right.*

In this tutorial I will be using a fake 2D histogram called foo. This tutorial will be written in the language of C++ however this can be easily ported to Python if you want to.

So normally to plot foo with a colour gradient one uses the following command

root [0] foo->Draw("colz")
This will use the hideous black, pink, bright green and grey palette. To change this behaviour, before running the draw command, run:
root [0] gStyle->SetPalette(1)
This will force the use of the more familiar IR-type gradient for your plots. Remember that if you like this, you can always add this to your global style definition.

To make the gradient even smoother you can also add something like the following:

void set_plot_style()
    const Int_t NRGBs = 5;
    const Int_t NCont = 255;

    Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
    Double_t red[NRGBs]   = { 0.00, 0.00, 0.87, 1.00, 0.51 };
    Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
    Double_t blue[NRGBs]  = { 0.51, 1.00, 0.12, 0.00, 0.00 };
    TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);

This should make your 2D plots much nicer to look at and easier to read.


* http://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/

This topic: PP/Public > TWikiUsers > JacoboBlanco > JacobBlancoTutorials
Topic revision: r3 - 30 May 2011 - JacoboBlanco
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding RHUL Physics Department TWiki? Send feedback