Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Jacob's collection of useful tutorials and tips | ||||||||
Line: 140 to 140 | ||||||||
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. | ||||||||
Line: 170 to 170 | ||||||||
Then 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 which was designed to build colour palettes for information maps. You can of course use it to build nice colour palettes for your own 2D plots or 1D distributions when you have lots of related curves. There are a lot of options to play with there, but the most important ones are to select the type of data you're plotting (sequential in the case of 2D plots) and select how many colours you need. Look at the TColour::SetCreateGradientTable function for more information on creating custom palettes. | |||||||
Changed: | ||||||||
< < | * http://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/ | |||||||
> > | Enjoy! | |||||||
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Jacob's collection of useful tutorials and tips | ||||||||
Line: 6 to 6 | ||||||||
How to mount your pphome on your personal laptop/computer at RHUL | ||||||||
Changed: | ||||||||
< < | 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. | |||||||
> > | 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. | ||||||||
Line: 40 to 38 | ||||||||
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. | ||||||||
Changed: | ||||||||
< < | 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: | |||||||
> > | 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/jblanco | ||||||||
Line: 153 to 149 | ||||||||
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 | ||||||||
Added: | ||||||||
> > | 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. So here is a simple way of getting these sort of canvases drawn. One might be tempted to create a canvas and then call TCanvas::Divide, but this will produce two pads that have margins and its a mess. Instead you want to create the pads yourself. First lets make the canvas and the top pad.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 :-( | |||||||
Added: | ||||||||
> > | 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 plots Then 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. | |||||||
Added: | ||||||||
> > | Enjoy! | |||||||
Making beautiful 2D plotsIf 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.* | ||||||||
Line: 162 to 185 | ||||||||
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 | ||||||||
Changed: | ||||||||
< < | root [0] foo->Draw("colz") | |||||||
> > | root [0] foo->Draw("colz") | |||||||
Added: | ||||||||
> > | ||||||||
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(1) | |||||||
Added: | ||||||||
> > | ||||||||
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: | ||||||||
Line: 173 to 196 | ||||||||
To make the gradient even smoother you can also add something like the following: | ||||||||
Changed: | ||||||||
< < | void set_plot_style() | |||||||
> > | void set_plot_style() | |||||||
{ const Int_t NRGBs = 5; const Int_t NCont = 255; | ||||||||
Line: 193 to 215 | ||||||||
Enjoy! * http://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/ \ No newline at end of file | ||||||||
Added: | ||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
Jacob's collection of useful tutorials and tipsComputing at PP RHUL |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Jacob's collection of useful tutorials and tips | ||||||||
Line: 55 to 55 | ||||||||
How to mount your pphome on your personal laptop/computer OUTSIDE of RHUL | ||||||||
Deleted: | ||||||||
< < | 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. | ||||||||
Changed: | ||||||||
< < | Depending on your distributions you will have to use a different package manager to install sshfs, for Ubuntu just run: | |||||||
> > | 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 sshfs | ||||||||
Changed: | ||||||||
< < | Now create a new directory where your pphome will be mounted and run the appropriate sshfs command: | |||||||
> > | On Mac OS X For OS X it's a little more complicated, you'll have to install MacFUSE from here, once you've installed it, make sure you go into the preference pane and check "Show Beta Versions" and click update. Once you've done that you download the pre-compiled SSHFS binary (for Leopard but works in SL), extract it and copy the binary to /usr/local/bin. Make sure you close and re-open your terminal. To mount your pphome 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 |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Jacob's collection of useful tutorials and tips | ||||||||
Line: 149 to 149 | ||||||||
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 | ||||||||
Added: | ||||||||
> > |
Making beautiful 2D plotsIf 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 commandroot [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); gStyle->SetNumberContours(NCont); }This should make your 2D plots much nicer to look at and easier to read. Enjoy! * http://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/ | |||||||
\ No newline at end of file |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Jacob's collection of useful tutorials and tips | ||||||||
Line: 9 to 9 | ||||||||
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. | ||||||||
Changed: | ||||||||
< < | N.B. You need to be within PP network, either via the wired network or the Stella wireless network. There is a way to use an ssh-tunnel to mount your pphome outside of the network using the command sshfs. | |||||||
> > | 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. | ||||||||
Line: 30 to 30 | ||||||||
File: `/home/jblanco/' Size: 59 Blocks: 8 IO Block: 4096 directory Device: 24h/36d Inode: 3 Links: 29 | ||||||||
Changed: | ||||||||
< < | Access: (0755/drwxr-xr-x) Uid: ( 10249/ jblanco) Gid: ( 120/ hep2) | |||||||
> > | 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 | ||||||||
Changed: | ||||||||
< < | Note the UID number in the output. Make sure to use YOUR UID when following the above tutorials. I hope I don't need to say this but, DO NOT use MY UID. | |||||||
> > | 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. | ||||||||
Line: 53 to 53 | ||||||||
Enjoy your new found productivity boost. | ||||||||
Added: | ||||||||
> > | How to mount your pphome on your personal laptop/computer OUTSIDE of RHULNote: 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 sshfsNow 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/jblancoReplacing jblanco with your home directory name and typing the password when prompted. BOOM! you have access from the outside | |||||||
ROOT TutorialsCompiling ROOT in Ubuntu |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
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. There is a way to use an ssh-tunnel to mount your pphome outside of the network using the command sshfs. 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: ( 10249/ 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. I hope I don't need to say this but, DO NOT use 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 on NFS shares for Ubuntu, but the information should be relevant to most distros. Enjoy your new found productivity boost. 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 |