Basic ROOT Tutorial Collaboration Meeting Jun2019: Difference between revisions
No edit summary |
|||
Line 13: | Line 13: | ||
For more information: https://root.cern.ch/ | For more information: https://root.cern.ch/ | ||
==The Basics== | |||
ROOT uses a C++ interpreter, you can use it on command line, no need to use ";" at the end of every line. | |||
Some basic commands: | |||
*".q" - quits ROOT | |||
* ".?" - displays special commands | |||
* ".x Example.C" - executes the macro in Example | |||
* ".L Example.C" - Loads Example and the associated classes within | |||
== What is a TTree? == | == What is a TTree? == | ||
Line 25: | Line 35: | ||
===Exercise 1: Open the and look at content with a TBrowser=== | ===Exercise 1: Open the and look at content with a TBrowser=== | ||
*Once you have downloaded and installed root, open a new terminal. | *Once you have downloaded and installed root, open a new terminal. | ||
*Type "root" - this will open up root (you should see the root logo flash up and you are then in the root environment) | *Type "root" - this will open up root in interactive mode (you should see the root logo flash up and you are then in the root environment) | ||
*Open up the file by typing: | *Open up the file by typing: | ||
<br /> | <br /> |
Revision as of 17:50, 29 May 2019
Tutorial Session Goal
In this Tutorial you will learn the basics of ROOT. The final aim being to learn how to analyze TTree data produced by the Mu2e Offline software.
Session Prerequisites and Advance Preparation
As this is a basic introduction, few prerequisites are necessary, however, it would be beneficial if attendees:
- Take a look at [1].
- Download and install from this page to your machine.
ROOT: An introduction
ROOT is a modular scientific software toolkit used extensive in High Energy and Particle Physics. ROOT provides a platform for data processing, statistical analyses, visualisation and data storage.
ROOT is an object-orientated framework predominately written in c++.
For more information: https://root.cern.ch/
The Basics
ROOT uses a C++ interpreter, you can use it on command line, no need to use ";" at the end of every line.
Some basic commands:
- ".q" - quits ROOT
- ".?" - displays special commands
- ".x Example.C" - executes the macro in Example
- ".L Example.C" - Loads Example and the associated classes within
What is a TTree?
TTrees are used through out particle physics as data containers. They can be form both input and output files in a ROOT macro.
Exercises
The majority of the session time should be spent performing exercises, which you link or embed in the session page.
For these exericses please download this .root file .....
Exercise 1: Open the and look at content with a TBrowser
- Once you have downloaded and installed root, open a new terminal.
- Type "root" - this will open up root in interactive mode (you should see the root logo flash up and you are then in the root environment)
- Open up the file by typing:
- "TFile::Open("$FullPathToFile/FileName.root")"
This file will contain the TTree, this is a data container used by root and by the Mu2e Offline software.
- View the contents of the File by typing:
- ".ls"
You should see a list of the contents of the file.
- You can open a TBrowser using the following in the command line:
- new TBrowser()
A GUI browser should appear which lists files in your current directory. You should see the .root file. You can select the file. You will see the TTree and various associated TBranches. Select one - a histogram should appear.
Exercise 2: Use TTree::Scan from command line
- Exercise 3: TBrowser to project histograms
- Exercise 4: Write a macro to project histograms
- Exercise 5: Use compiled code to project histograms
You are Encourage to prefer macros or compiled code over projecting the using ROOT for analysis.
- Exercise 6a: Saving the histograms to a file (.root)
- Exercise 6b: Saving the histogram as .png, pdf ....
- Exercise 7: Chaining multiple input files together
- Extension Tasks - for those already familiar with the ROOT Basics please familiarise from above but once this is done you can skip to these tasks:
.....