# ROOT

This is an update on my previous post about installing root.

In this post I’ll go over how to install CERN’s ROOT data analysis framework. ROOT is very handy when trying to make plots and it is used by nuclear physicists, particle physicists and even some astronomers to store, view and report data. The installation process is fairly simple and there are a few things that you can learn about how your operating system and programming in the process of installing ROOT.

## Dependencies

Fist thing to do it to install ROOT is to get the proper dependencies. Dependencies are the underlying programs a computer needs in order to build new programs. One of the most important ones we will need to install ROOT is GCC (GNU Compiler Collection). As the name might imply GCC is the collection of programs which are used to make the C/C++, Objective-C, Fortan and other code compile so that it can be run on your computer. In order to install this and some other useful tools on OS X you can use the Xcode command line tools. In order to install ROOT you don’t need the full version of Xcode, just a small portion of the tools which can be installed by opening a terminal and typing:

xcode-select --install


For Ubuntu we will install GCC as well as a few other dependencies needed for graphical displays. Instead of using Xcode on Ubuntu though we will use a package manager which is a program made to track and install programs and dependencies needed for your linux comptuer. On Ubuntu the default package manager can be used with the apt-get command in a terminal.

sudo apt-get install git cmake dpkg-dev python-dev make g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev


To enable all the features of ROOT you can also install the optional dependencies.

sudo apt-get install gfortran libssl-dev libpcre3-dev xlibmesa-glu-dev libglew1.5-dev libftgl-dev libmysqlclient-dev libfftw3-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev libxml2-dev libkrb5-dev libgsl0-dev libqt4-dev


Once you have all the dependencies the next steps will be to download the ROOT source files and build them install them. We will download ROOT from the github page but you can also download the source files from the ROOT web page and extract the files if you like. First we will change directories (cd) into our install location.

cd /usr/local/


sudo git clone --depth 1 https://github.com/root-mirror/root.git


We used the sudo (super user do) command in order to install dependencies as well as to download into this folder. That is because unix systems like linux and OS X need different permissions to do different tasks or to access certain files or folders. By putting the sudo command and putting in your password you are asking the computer to allow you to be the admin and do specific tasks. However we don’t always want to be the admin when we are using ROOT so we will need to change the folder permissions back to you. You can do this with the chown command, replacing username and groupname with your user name.

sudo chown -R username:groupname root


Or with command line magic, just copy and paste:

sudo chown -R $(whoami):$(id -g -n $(whoami)) root  ## Building ROOT The new way involves using another program called cmake. If you want to build ROOT this way you’ll have to make sure cmake is installed and then run the following, again changing the 2 to the number of cores you have: cd root mkdir compile cd compile cmake -Dpython=ON -Droofit=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/root .. make -j$(nproc)
sudo make install


## Installing ROOT

Now we must let the computer know how to run ROOT and you can do this by using the source file.

cd /usr/local/root
source bin/thisroot.sh


Now you should be able to run the interactive ROOT session with command root in this terminal, but if you open a new terminal you’ll notice you won’t be able to run ROOT. To solve this we’ll have to either source ROOT in every new terminal, or have the computer automatically source ROOT when you open a new terminal. To do this you need to edit your bashrc file, on linux you can use nano ~/.bashrc and on OS X nano ~/.bash_profile and add to the end of the file:

#CERN ROOT
export ROOTSYS=/usr/local/root
export PATH=$ROOTSYS/bin:$PATH
export PYTHONDIR=$ROOTSYS export LD_LIBRARY_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$ROOTSYS/bindings/pyroot:$LD_LIBRARY_PATH export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH:$ROOTSYS/bindings/pyroot


Now you should be able to open a new terminal and type root to make sure everything is working. To check if ROOT is also installed for python properly you can run an interactive session and try to import ROOT:

import ROOT


If there are no import errors then ROOT should work for any C/C++ or python project on your system.

# CMS Open Data, $X \rightarrow \mu \mu$

For my project I used the CMS Open Data platform to get experimental data of proton proton collisions at $7\,TeV$. I used a set of scripts from GitHub and modified them slightly to read the data and output results for decays to two $\mu$ (DiMuonFilter). For each event the energy and momentum for each $\mu$ was saved as well as the charge of each and the mass of the particle the $\mu$ decayed from. In the end I was able to collect around 3 million individual events.

# $Z^0$ Decays

To find $Z^0$ decays I first made sure that the decays conserved charge so that $Z^0 \rightarrow \mu^+ \mu^-$. After the initial charge cut I was left with roughly 2 million neutral decays. I looked at the mass histogram in the range above $40\,GeV$ to find the $Z^0$ peak around $91\,GeV$. I then fit a polynomial background with a Gaussian peak around $91\,GeV$ on the data and used this to subtract away the background to find the $Z^0$ peak. I cut the data around around the mass peak and then looked at different energy and momentum distributions of the decaying $Z^0$.

## Scatter Matrix

The quickest way to find interesting distributions is by looking at the matrix of the scatter plots from different combinations of the energy and momentum directions. The two plots that stick out the most initially are the $Z^0$ Energy versus $Z^0$ Pz and $Z^0$ Energy versus $Z^0$ Pt so I investigated them more.

## $Z^0$ Energy versus $Z^0$ Pz

With the color map it is easy to see that most of the $Z^0$ have close to 0 momentum in the direction of the beam and that they are produced at energies close to $90\,GeV$. This is characteristic of a symmetric beam collider like the LHC where particles are created close to the center of the lab frame. By looking at the projection along the Z momentum axis it’s clear to see this large peak of $Pz \approx 0$. There is a large peak around 0 with a very small distribution at larger momentums.

## $Z^0$ Energy versus $Z^0$ Pt

Another interesting distribution is the $Z^0$ Energy versus $Z^0$ transverse momentum. This graph also shows that a large amount of the $Z^0$ have $Pz \approx 0$. Looking at the projection along Pt confirms this. Combining the results from the two investigations and looking at the $Z^0$ Pz versus $Z^0$ Pt shows that most of the $Z^0$ have $Ptotal \approx 0$ meaning that many of the $Z^0$ are created close to rest in the lab frame. This means that they will decay very quickly and that the decaying particles will have opposite momentums as they leave the center of the detector region. This could be helpful in creating a true background subtraction to find $Z^0$ for this experiment by only selecting decays which come from the close to the center of the detector and have $Ptotal \approx 0$ within detector resolutions.

# $\Upsilon$ Decays

The next region I looked at was the region between $6 - 14\,GeV$ where the $\Upsilon$ can be found. Again I looked at the mass histogram and fit a polynomial background with a Gaussian peak this time around $9.45\,GeV$. The $\chi^2$ for this distribution is much larger than in the $Z^0$ case because there are two peaks which are not initially fit but the Gaussian or the polynomial. I again subtracted the polynomial background to get the larger peak seen in green. And then after subtracting the background and the larger of the three peaks I tried to fit the smaller peaks but the simple Gaussian fit method lumped the two remaining peaks together making it hard to distinguish between the two.

## Scatter Matrix

Again to find interesting distributions I looked at the matrix of the scatter plots and looked at the $\Upsilon$ Energy versus $\Upsilon$ Pz and $\Upsilon$ Energy versus $\Upsilon$ Pt.

## $\Upsilon$ Energy versus $\Upsilon$ Pz

This distribution is slightly different then the $Z^0$ distribution. There is a larger range in the Z momentum distribution opposed to the large peak around 0 for the $Z^0$. This can also be seen in the wide distribution seen on the Pz projection. However it is hard to tell whether this is due to something physical with the $\Upsilon$ production or if this is due to the background. A better investigation into the backgrounds in this region could help to clear up the the particle identification process.

## $\Upsilon$ Energy versus $\Upsilon$ Pt

When first looking at the $\Upsilon$ Energy versus $\Upsilon$ Pt distribution one can see that there are a lot of events around the low energy, low momentum region. In closer instigation in this region there seems to be two bands appearing. The first band follows an arc with a slope close to one while the other is a wider and shallower band continuing in the low $Pt \approx 5\,GeV$ region.

With higher statistics this could become interesting to use this either for background subtraction or to look at the properties of high transverse momentum $\Upsilon$ versus low transverse momentum $\Upsilon$.

# The Final Countdown

#Countdown

A lot of times I end up starting a command in one terminal and then want to do something after that command finishes in another window. I’ve been using the bash sleep command to do this but recently I’ve wanted to know how long was left in the countdown. So I made a simple C++ program to do show the time left and added some little things like colors and a progress bar just for fun.

All the code can be found on my github and easily built on both Linux and OS X with a simple make command.

# ROOT

For an update go to my new post.

In this post I’ll go over how to install CERN’s ROOT data analysis framework. ROOT is very handy when trying to make plots and it is used by nuclear physicists, particle physicists and even some astronomers to store, view and report data. The installation process is fairly simple and there are a few things that you can learn about how your operating system and programming in the process of installing ROOT.

## Dependencies

Fist thing to do it to install ROOT is to get the proper dependencies. Dependencies are the underlying programs a computer needs in order to build new programs. One of the most important ones we will need to install ROOT is GCC (GNU Compiler Collection). As the name might imply GCC is the collection of programs which are used to make the C/C++, Objective-C, Fortan and other code compile so that it can be run on your computer. In order to install this and some other useful tools on OS X you can use the Xcode command line tools. In order to install ROOT you don’t need the full version of Xcode, just a small portion of the tools which can be installed by opening a terminal and typing:

xcode-select --install


For Ubuntu we will install GCC as well as a few other dependencies needed for graphical displays. Instead of using Xcode on Ubuntu though we will use a package manager which is a program made to track and install programs and dependencies needed for your linux comptuer. On Ubuntu the default package manager can be used with the apt-get command in a terminal.

sudo apt-get install git dpkg-dev make g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev


To enable all the features of ROOT you can also install the optional dependencies.

sudo apt-get install gfortran libssl-dev libpcre3-dev xlibmesa-glu-dev libglew1.5-dev libftgl-dev libmysqlclient-dev libfftw3-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python-dev libxml2-dev libkrb5-dev libgsl0-dev libqt4-dev


Once you have all the dependencies the next steps will be to download the ROOT source files and build them install them. We will download ROOT from the github page but you can also download the source files from the ROOT web page and extract the files if you like. First we will change directories (cd) into our install location.

cd /usr/local/


sudo git clone https://github.com/root-mirror/root.git


We used the sudo (super user do) command in order to install dependencies as well as to download into this folder. That is because unix systems like linux and OS X need different permissions to do different tasks or to access certain files or folders. By putting the sudo command and putting in your password you are asking the computer to allow you to be the admin and do specific tasks. However we don’t always want to be the admin when we are using ROOT so we will need to change the folder permissions back to you. You can do this with the chown command, replacing username with your user name.

sudo chown -R username:groupname root


Or with command line magic:

sudo chown -R $(whoami):$(id -g -n $(whoami)) root  ## Building ROOT There are two ways to build ROOT the old way using a configure file and make, and the new method for ROOT 6 using cmake and make. ### Old way Using the configure script is easy just go into the root directory we just downloaded and run ./configure. After the configure script has run it will create a makefile which can be run to build ROOT. after the -j option you can change the 2 the number or cores you have on your computer and make will build ROOT using all of your processing cores. cd root ./configure --all make -j2  ### New way The new way involves using another program called cmake. If you want to build ROOT this way you’ll have to make sure cmake is installed and then run the following, again changing the 2 to the number of cores you have: cd root/build cmake --all -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/root .. make -j2 sudo make install  As of now both of these ways will work and the only difference you will see is that cmake has a lot prettier output, however in future versions of ROOT the old way may not work. ## Installing ROOT Now we must let the computer know how to run ROOT and you can do this by using the source file. cd /usr/local/root source bin/thisroot.sh  Now you should be able to run the interactive ROOT session with command root in this terminal, but if you open a new terminal you’ll notice you won’t be able to run ROOT. To solve this we’ll have to either source ROOT in every new terminal, or have the computer automatically source ROOT when you open a new terminal. To do this you need to edit your bashrc file, on linux you can use nano ~/.bashrc and on OS X nano ~/.bash_profile and add to the end of the file: #CERN ROOT export ROOTSYS=/usr/local/root export PATH=$ROOTSYS/bin:$PATH export PYTHONDIR=$ROOTSYS
export LD_LIBRARY_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$ROOTSYS/bindings/pyroot:$LD_LIBRARY_PATH
export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH:\$ROOTSYS/bindings/pyroot


Now you should be able to open a new terminal and type root to make sure everything is working. To check if ROOT is also installed for python properly you can run an interactive session and try to import ROOT:

import ROOT


If there are no import errors then ROOT should work for any C/C++ or python project on your system.

# Connecting to the FreeNAS server

The FreeNAS server consists of three, 4TB drives in a ZFS filesystem which is similar to a raid 5 setup. This gives a total useable storage size of around 7TB and allows for redundancy with one drive able to fail and data still recoverable. I will go though some basic steps of how to use the share and set it to backup your home folder on linux.

• Make sure you have an account on the FreeNAS server
• I will be able to setup your account on the server if you’re in the research group
• Make sure you can connect to the server
• In our case the server has two IP addresses on the network 172.21.139.214 and 172.21.139.168
• To check if you can connect:
ping -c 3 172.21.139.214

• Now make sure you have the required packeges to mount network drives
• cifs or nfs should work but I will be using cifs for the tutorial. To change to nfs just replace any part that says cifs with nfs.
sudo apt-get install cifs-utils smbfs

• Make a credentials file in your home directory
• This file is going to store your username and password so we’re going to make sure it has the proper security so that it is not readable by everyone.
• Make a file called .smbcredentials in your home folder ~/.
• Place this in the file replacing name with the username you setup on the FreeNAS server and **** with the password.
username=name

• Change the owner and permissions on the credentials file.
sudo chown root .smbcredentials
sudo chmod 600 .smbcredentials

• Now make a folder to mount the FreeNAS server to. Replace username with the username on your system. If you don’t know you can check it with the whoami command.
sudo mkdir /mnt/FreeNAS

• Find your user id and group id using the id command. In most cases if you were the first user on the system they both should be 1000 but it’s still a good idea to check.
uid=1000(username) gid=1000(username) .....

• As the root user edit /etc/fstab and add this line to the end of the file. Make sure to replace user with your username and userid and groupid with the id’s found in the pervious step.
//172.21.139.168/backups /mnt/FreeNAS cifs credentials=/home/user/.smbcredentials,isocharset=utf8,sec=ntml,uid=userid,gid=groupid 0 0 0

• Now check to see if eveything mounts correctly:
sudo mount -a


Now your computer should have the FreeNAS server mounted as a drive on your computer in the folder /mnt/FreeNAS you should be able to look into that directory and find a directory with your name where you can place anything you would like to backup. The next step will be to setup an automatic backup using rsync.

• Create a file called backup.sh and place the following inside of it making sure to change the username and ShareName to your match your name.
• At a minimum you should exclude .ssh and .smbcredentials since these contain sensative information.
• Make sure to add any other folders that may include sensative information.
• This storage is mainly for your personal files so it is advised to exclude any folder with large amounts of raw data which is backed up in other locations.
#!/bin/bash

sudo mv backup.sh /usr/local/sbin/

0 8,9,10,11,12,13,14,15,16,17,18,19 * * * /usr/local/sbin/backup.sh