|
META TOPICPARENT |
name="JacobBlanco" |
Jacob's collection of useful tutorials and tips |
| 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 ~]$ 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 |
| 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 ~]$ 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 |
> > | [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 |
> > | [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 |
> > | [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 |
> > | [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 ROOTSYS=/usr/local/root |
| export PATH=$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_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 ~]$ . ~/.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  |
|
> > | Run ROOT in batch mode to speed up processing
For 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.
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 attached
So 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. |