Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Jacob's collection of useful tutorials and tipsComputing at PP RHULHow to mount your pphome on your personal laptop/computer at RHULThis 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![]() ![]() [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 +0100Note 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: nfs://134.219.108.207/pptank/home/jblancoand 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 ![]() ![]() How to mount your pphome on your personal laptop/computer OUTSIDE of RHULMake sure that you can ssh into linappservX successfully, because we are going to use and ssh-tunnel to mount your pphome. Now you need to get SSHFS, depending on your os follow the appropriate bit. The mounting instructions are the same for both Linux and OS X. I didn't include Windows since a) you should use SMB (not sure you can from the outside) and b) SSHFS requires installing Cygwin under Windows. On Linux 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 sshfsOn Mac OS X For OS X it's a little more complicated, you'll have to install MacFUSE from here ![]() ![]() [User@Machine ~] mkdir /Some/Directory [User@Machine ~] sshfs jblanco@linappservX.pp.rhul.ac.uk:/home/jblancoReplacing jblanco with your home directory name and typing the password when prompted. BOOM! you have access from the outside ROOT TutorialsCompiling ROOT in UbuntuDownload 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 rootWe 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 ~]$ ./configureThis 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*-devN.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 --helpto 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 ~]$ makeThis 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 ~/.bashrcand 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 export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATHOf 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 installThis 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 ![]() Run ROOT in batch mode to speed up processingFor ages I found the fact that ROOT has to draw histograms or other graphics before you can manipulate certain elements of it such as the axis of a TH1. Drawing to screen is an expensive operation and takes a LONG time especially if you're SSH-ing into the machine you're working on. There is a way to avoid all of this and speed up processing immensly without loosing any features at all. Run ROOT in batch mode by specifying the -b flag when you call your macro: root -b 'YourScript.cxx("variable1")' This will run your script, produce plots and even save them to file as you would normally but simply without drawing them to the screen. As far as I can tell your macro will function just as before except for being a lot faster. This is really useful if you don't really need to look at the plots as things are running. Of course if you're debugging things remove the flag to stare the plots right in the eyes. | ||||||||
Changed: | ||||||||
< < | Additional Tip: I also add the -q flag when running to force ROOT to quit once the macro has run allowing you to do other stuff in your bash script. | |||||||
> > | Additional Tip: I also add the -q flag when running to force ROOT to quit once the macro has run allowing you to do other stuff in your bash script. | |||||||
Making Data vs MC-style plots with SF plot attachedSo we've seen these sort of plots everywhere and they are cool (in a PP ROOT plotting sort of way. Stockholm-syndrome much?). They are however a little tricky to get right. Learning the anatomy of a TCanvas is painful and even when you think you know what you're doing, you really don't. You'll have something that looks like that plot below, note that the X-axis of the top plot is behind the bottom plot, so you need to make sure that both top and bottom plot have the same range for things to make sense.![]() TCanvas* canvas = new TCanvas( "SomeName", "SomeTitle", 900, 700 ); TPad top_pad("top_pad", "top_pad",0,0.4, 1.0, 1.0); top_pad.Draw(); top_pad.cd(); top_pad.SetBottomMargin(0);You just created a pad of a certain size in the canvas and set the bottom margin of that pad to zero, that way the SF plot that will be going in the bottom pad is flush with the top pad. After this portion of code then go ahead and draw whatever you want on the top pad, including things like histograms and legends. Next we'll create the bottom pad making sure things are flush with the top pad content: canvas->cd(); // This line is REALLY important otherwise you'll draw a subpad in the top pad :-( TPad bottom_pad("bottom_pad", "bottom_pad", 0, 0.03, 1.0, 0.4); bottom_pad.Draw(); bottom_pad.cd(); bottom_pad.SetTopMargin(0); bottom_pad.SetGrid(1,1); // Optional: Enable gridlines on plotsThen draw whatever you need on the bottom pad, save the canvas to a root file or output as EPS/PNG/PDF for slides and notes. Enjoy! | ||||||||
Changed: | ||||||||
< < | Making beautiful 2D plots | |||||||
> > | Update: Making beautiful 2D plots | |||||||
Changed: | ||||||||
< < | 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.* | |||||||
> > | Edit: After I've written this tutorial I learned a lot about what makes a colour palette effective in conveying information and how the human brain perceives colour. While the mechanism for setting the palette still works well, the palette of colours I used is terrible. Not only do the colours used not convey much information, the palette can also misrepresent the data. Below is the updated tutorial. | |||||||
Changed: | ||||||||
< < | 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. | |||||||
> > | If you've ever made 2D plots in ROOT using the colz command you know how ugly the colours are. In this tutorial I will be using a fake 2D histogram called foo. This tutorial will be written in C++ however this can be easily ported to Python if you want to. | |||||||
Changed: | ||||||||
< < | So normally to plot foo with a colour gradient one uses the following command | |||||||
> > | Normally to plot a TH2 histogram 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: | ||||||||
Changed: | ||||||||
< < | root [0] gStyle->SetPalette(1) | |||||||
> > | root [0] gStyle->SetPalette(53) | |||||||
Changed: | ||||||||
< < | 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. | |||||||
> > | This will force plots to be drawn with a dark body radiator palette that goes from black through red and then white. The intensity of the colour and saturation convey much more information, darker colours represent lower values and brighter colours represent higher values. | |||||||
To make the gradient even smoother you can also add something like the following: | ||||||||
Deleted: | ||||||||
< < | ||||||||
void set_plot_style() { | ||||||||
Changed: | ||||||||
< < | const Int_t NRGBs = 5; | |||||||
> > | gStyle->SetPalette(53); | |||||||
const Int_t NCont = 255; | ||||||||
Deleted: | ||||||||
< < | 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); | |||||||
gStyle->SetNumberContours(NCont); } This should make your 2D plots much nicer to look at and easier to read. | ||||||||
Changed: | ||||||||
< < | Enjoy! | |||||||
> > | Check out the ColourBrewer tool![]() | |||||||
Changed: | ||||||||
< < | * http://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/![]() | |||||||
> > | Enjoy! | |||||||
|