First Step of Linux and ROOT
Last updated on September 18, 2026
Lesson 0 install root and software on your compute
If you get the THU’s computer cluster account, use following commands to get into.
$ ssh -XY -p 48571 -o ServerAliveInterval=5 yourname@hepthu.comYou can also run code on your pc if you have installed root, it’s up to you.
homebrew Click this link to go to the Homebrew page, follow the instructions to install Homebrew on your Mac. Homebrew is a software package manager that allows you to download many applications on your Mac!
After finishing the installation, paste the following command in a macOS terminal to install CERN ROOT software: $ brew install root. This way, you can also install applications like firefox which you can’t find in the App Store.
Additionally, $ indicates a shell command, so drop the $ sign when you copy the command.
Lesson 1 base commands for Linux
Some simple commands you can have a try!
1 | |
Vim editor
1 | |
you will use the next commands from time to time
vi somefile -> press i into edit mode -> do something ->esc exit edit mode -> :wq
Some tricks that can help you:
Press the TAB key to automatically complete some of your commands, such as file names. Pressing it twice will show you the available commands/file names you can input.
Press ↑ to retrieve previous commands.
Lesson 2: Basic ROOT exercises
Enter the ROOT environment:
$ root
Use root [0] .q to exit ROOT.
ROOT can interpret commands one line at a time.
You can also interpret commands while entering them, or compile and run a macro file with root yourprogram.C.
For example, enter the following commands in ROOT to create an empty histogram:TH1F* graph=new TH1F("name","title",200,2.97,3.03);graph->Draw();
An empty histogram is not very interesting, so use Fill to add data
You can also create a macro file to hold a longer program.
Get start!
$ vi test.C
//push i to enter the insert mode//
1 | |
//push ESC to end the insert mode//
:wq //save and exit
$ root test.C //run your code

///successful!///
.q //exit the program
Let’s add something into your graph!
1 | |

Wow! now you can use root to do some simple fit works. but we usually use RooFit to do more complex job! So, ready for more programs!
These are only basic fits. Many parameters cannot be defined freely, while RooFit provides more professional and flexible fitting functions.
Lesson 2 Gaussian fitting using RooFit
1 | |

One function can look a little lonely. We can use RooAddPdf to combine two functions.
RooRealVar fsig(“fsig”,”fsig”,0.2,0,1.);
//model(x) = fsig*gaus(x) + (1-fsig)*chev(x)
RooAddPdf model(“fsig”,”fsig”,RooArgList(gaus,chev),fsig);
1 | |

The example above is a one-dimensional fit. In many analyses we study two different components, which requires a two-dimensional fit. A two-dimensional fit does not simply add two PDFs; it uses products, which can be understood as the probability that two components occur together. For an x event with probabilities p(x) and q(x), and a y event with probabilities p(y) and q(y), there are four possible combinations. Their probabilities include p(x)*p(y), the probability that x and y occur together. We therefore build four probability functions for the different combinations.
Note: The default random seed is 0. A seed is usually based on the current time so that each run produces different data, but a fixed seed is convenient for debugging. With seed 0, a program like this produces the same data every time. You can set the seed with RooRandom::randomGenerator()->SetSeed(seed) or with gRandom->SetSeed(seed). The first controls RooFit’s random generator; the second controls ROOT’s global random generator and can also cover uses outside RooFit. Use gRandom->GetSeed() to inspect the current seed.
1 | |
Lesson 3 2D fitting
The following section shows two two-dimensional fits.
1 | |


1 | |

Lesson 3+ Pull Plot
To evaluate how well the fit describes the data, inspect the pull distribution. It straightens the fitted curve and shows the distance of each data point from the curve. The pull plot for xframe is shown below.
1 | |

