First Name Timothy
Last Name Brooks
Loginname puap062
Wikiname TimBrooks
Titles Mr


Skype ID

Department BL4S

Organization CERN

Location 4 R-021
Region Geneva
Country Switzerland
Status Update

Information ?

Edit personal data

Tim Brooks

Third Year PhD Student - Supervised by Glen Cowan

My Links


My Research

See my research page in the ATLAS web. Currently working on top-quark background estimation in supersymmetry selections. Investigating boosted decision trees for characterization of top events. ATLAS SUSY points:

  • SU4 = { m_{0} = 200, m_{1/2} = 160, A_{0} = -400, tan \beta = 10, sign \mu = + }

Programming Tips

Command line-fu

The command line is very powerful: There are a few tools to learn that do very simple jobs, but piping their output to each other allows you to get things done without scripting. Here's an example for downloading specific files in a dataset.
dq2-ls -f $dataset | cut -f 2 | grep root | tr "\\n" "," | xargs -i dq2-get -f {} $dataset
The dq2-ls -f command gives me a list of all files in a dataset in a pretty format. I just want filenames, which happens to be the 2nd column. The cut command slices out columns of text in its input. The -f switch counts whitespace delimited fields. I then decide to select lines contating root filenames; grep does this nicely. Unfortunatly dq2-get isn't very clever, and can't pick filenames from stdin. It doesn't need to though, as we can massage the command line arguments and use xargs to pipe them to dq2-get. First off, we need to turn the newline separated filenames into a comma separated list. This is exactly what tr (translate) does. The -i switch tells xargs to replace {} with arguments from stdin. So dq2-get sees the -f switch (to pick individual files in a dataset) followed by the filenames we selected with grep, separated by commas, followed by the dataset name.

Of course, all that's kind of long to type, so you might want a script for that anyway. wink

Bash Basics

It's handy to have a /bin folder in your home area. This can be added to your path in your bash start script: export PATH=~/bin:$PATH
Placing scripts here can make mindless tasks much easier.
e.g. To rename a bunch of files that are called xxxthisxxx to xxxthatxxx, I have a bash script called mvls that is run like: mvls this that and changes every file in the pwd that contains 'this' in the name to have 'that' instead.
Here's the script

for file in *;do
newfile=$(echo $file | sed s/$1/$2/g)
test "$file" != "$newfile" && mv "$file" $newfile

JaxoDraw needs to be run in it's home directory for axoDraw.sty else it can't export to .eps
A quick script switches the wd, and returns it to how it was:

export jaxodrawdir=/scratch0/brooks/tools/JaxoDraw-2.0-1/
export OWD=$PWD
cd $jaxodrawdir
java -jar ${jaxodrawdir}jaxodraw-2.0-1.jar
cd $OWD


Basic script

import user 
import ROOT
import PyCintex
import AthenaROOTAccess.transientTree

# a bit less ugly ROOT style...

f = ROOT.TFile.Open('/scratch0/brooks/MC09/mc09_7TeV.105200.T1_McAtNlo_Jimmy.recon.AOD.e510_s765_s767_r1205_tid123042_00/AOD.123042._000001.pool.root.1')
tt = AthenaROOTAccess.transientTree.makeTree(f)

Save this as something like and run it using python -i

Batching plots

Here's a quick bit of code to make a plot and save it straight to a file without making a window.
ROOT.gROOT.SetBatch(True)                  # Switch to batch mode
c1=ROOT.TCanvas( 'c1', 'Plot', 640, 480 )  # Make a canvas of size 640x480                                    # Set the output canvas (lets us have several going at once)
tt.Draw("ElectronAODCollection.phi()")     # Draw the phi distribution of electrons in the AOD
c1.Print("plot.png")                       # Save the canvas as an image file (ROOT uses the extension given)

Some things to play around with

  • from PyAnalysisUtils import PDG Lets you use PDG. instead of remembering pdgIds. Cool feature -> PDG.root_names[-PDG.nu_mu] returns a string with the ROOT syntax for an anti-muon-neutrino.
  • import AthenaCommon.SystemOfUnits as Units Gives you a Units object with most units in the ATLAS base units. e.g. Units.TeV = 1000000.0
  • ROOT.gROOT.SetBatch(True) Switches Root to batch mode.


Installing Root

The easiest method is if your distro has a root package. These don't seem to be kept very up-to-date, but I think Root is stable enough to use older versions for most features. On Ubuntu, there is a package called root-system so you can simply run:
sudo apt-get install root-system
This dumps the root binarys into /usr/bin and the libraries into /usr/lib/root, but I think the relevant paths get set up for you in the installation, so you needn't worry about the 'Setting up root' section below.

Installing Root from source

The Root source code can be downloaded from There are a few packages you will need on your system; on ubuntu 9.10, I needed libx11-dev, libxft-dev, libxpm-dev and libxext-dev. All the requirements the root page recommends can be had using:
sudo apt-get install make g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev
Once that's done; untar the root package move the unzipped folder somewhere (e.g. /opt/root). Then, in the root folder, run ./configure --prefix=/opt/root then make (or, if you want; make -j n where n is the number of cores in your machine). This should leave you with a working root install, then set up your env variables to use it:

Setting up root

To use root you need to add the environment variable $ROOTSYS and append locations to $PATH and $LD_LIBRARY_PATH. A good way to do this is add the following to your ~/.bash_profile:

export ROOTSYS=/usr/local/root/v5.22.00/slc5.gcc3.4/root
export PATH=${PATH}:${ROOTSYS}/bin

Where /usr/local/root/v5.22.00/slc5.gcc3.4/root is the path of the current stable build of root (ie. check this is correct! /usr/local/root/v5.22.00/slc5.gcc3.4/root is ok for machines at RHUL)

For example; here are my .bashrc and .bash_profile.

Setting the plot style to plain

In your home directory, make a file called .rootrc containing the following line:
Rint.Logon: ~/rootlogon.C
Next make that file and paste in the following code:
  gStyle->SetCanvasBorderMode(0); // turn off canvas borders
  cout << "******************************" << endl; 
  cout << "* Welcome to ROOT v" << gROOT->GetVersion() << " *" << endl; 
  cout << "******************************" << endl; 
  cout << endl;
This switches off the toner wasting gray backgrounds on plots and the bizarre yellow borders.

Adding Legends to Plots

leg = new TLegend(0.6,0.7,0.89,0.89);
leg->AddEntry(hist_A, "Sample A","f");
leg->AddEntry(hist_B, "Sample B","f");
AddEntry takes the histogram handle, a title for that histogram, and an option that is either "f" for boxes or "l" for lines.
SetFillStyle(0) makes the legends background transparent and adds a border. Alternatively, you can SetFillColor(kWhite) for a white background with no border. (Make sure you don't lose any datapoints behind it!)

Setting up an Axis

h->GetXaxis()->SetNdivisions(105) -Sets tick number. Format is minor ticks per major one * 100 + major ticks in the axis, i.e. to divide into 13 major ticks with 5 minors each; use 500 + 13 = 513.

Getting reasonable colour palettes

To get a colour palette (for 2D plots etc.) that goes from red to blue, set;

Adding multiple files with hadd

hadd usage:

Usage: hadd [-f] [-T] targetfile source1 [source2 source3 ...]
This program will add histograms from a list of root files and write them
to a target root file. The target file is newly created and must not 
exist, or if -f ("force") is given, must not be one of the source files.
Supply at least two source files for this to make sense... ;-)
If the first argument is -T, Trees are not merged
When -the -f option is specified, one can also specify the compression
level of the target file. By default the compression level is 1, but
if "-f0" is specified, the target file will not be compressed.
if "-f6" is specified, the compression level 6 will be used.
if Target and source files have different compression levels
 a slower method is used


In booking a tree the option Boost_AdaBoostBeta (Default=1) is "The ADA boost parameter that sets the effect of every boost step on the event weights"


  • In TMVA Manual,

ATLAS Software Links

ATLAS software information in the wiki: Good tutorial on running PowHeg for ATLAS.

Packages of note

  • Generators/EvgenJobTranforms
  • Generators/EvgenATLAS.JobOptions - Set of standard JobOptions for many processes of importance. Standardized such that samples can be merged with production sets.

Computing resources

Application servers are listed here: Application servers. For external use, linappserv1 acts as a gateway to the network, and is reasonably fast. Internally, linappserv0 is the fastest machine we have. linappserv3 & 4 are usually quiet, so good for running jobs that may take some time to complete. 1, 3, & 4 use 'Linux based on Scientific Linux CERN SLC release 4.8 (Beryllium)' while linappserv0 uses 'Linux based on Scientific Linux CERN SLC release 5.4 (Boron)'. All machine names can be accessed locally (e.g. ssh user@linappserv0) and those accessable outside can be found as (e.g. ssh

The faraday cluster is controlled via linappserv0. Instructions for using the cluster are here: How to use the cluster. The cluster can be used for ATLAS production. See my event generation page.

Physics WebpagesRHUL WebpagesCampus Connect • Royal Holloway, University of London, Egham, Surrey TW20 0EX; Tel/Fax +44 (0)1784 434455/437520

Topic revision: r55 - 13 Mar 2015 - TimBrooks

This site is powered by the TWiki collaboration platformCopyright © 2008-2017 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