This is the guide for the ROOT Course exercise session C. The exercises cover the following areas:
Session C is an example of an analysis using real physics data.
ROOT is a C++ framework; it is not only written in C++, it also uses C++ as the scripting language. To use ROOT effectively you will need to know the basics of C++. The User's Guide chapter 6 "A Little C++", explains the basic concepts.
In addition, there is a "C++ Guide for ROOT Users" at:
http://www-root.fnal.gov/root/CPlusPlus/index.html
To install ROOT on your own machine see
Appendix A in the ROOT User's Guide, or the ROOT website:
http://root.cern.ch/root/Availability.html
Make sure you correctly set the ROOTSYS, PATH and LD_LIBRARY_PATH environment variables.
The files needed for the exercises can be found either in $ROOTSYS/tutorials or in ftp://root.cern.ch/ftp/exercises.tar.gz.
To start a ROOT session:
> root
To exit at any time:
root[] .q
To run a script:
root [] .x <scriptname.C>
In this session you will:
· Study an example analysis from DESY
· Learn about the TTree::MakeSelector method to automatically create a class that loops over each entry in a tree.
· Save and retrieve a canvas to and from a ROOT file
· Compute the integral of a histogram
· Compute the integral of a function within a range
The data are taken from the DESY H1 micro-DSTs. Copy the file dstarmb.root from: ftp://root.cern.ch/root/h1analysis/ to your $HOME/tutorials
directory
The example data
file is in your directory $H1/dstarmb.root.
Example Script from TTree::MakeSelector
First, you need to understand how the TTree::MakeSelector
method creates a class that loops over the entries in the TTree. Please read the Chapter 12
"Example
Analysis" in the User's Guide "Example
Analysis" pg.218.
Change directory to $HOME/tutorials, the directory you copied in the last session. Now open the script $HOME/tutorials/h1analysis.C and read the comments.
The script shows how to use a class (the skeleton has been automatically generated by the TTree::MakeSelector method) to loop on the files, perform some cuts and fill two histograms with some physics quantities.
Start a root session and open the file $H1/dstarmb.root.
root[] TFile f("$H1/dstarmb.root");
Using the TBrowser, display some of the variables in the TTree
named h42.
root[] new TBrowser();
Execute the script h1analysis.C on the h42 tree.
root[] h42->Process("h1analysis.C")
Saving and Retrieving a Canvas
Save the canvas with the dm_d histogram as a ROOT file
("c1.root") with the File:Save as canvas.root menu option. Start a new
session. Read the saved ROOT
file.
root[] .q
root
root[] TFile f("c1.root")
root[] c1->Draw()
Computing Integrals
Get a pointer to the Dstar histogram named “hdmd”.
Get a pointer to the fitted function “f5”.
Compute hint = the histogram bin integral.
Compute fint = the f5 integral where the function is positive (0.139 – 0.17).
Use the TH1 and TF1 class description web page to find the right method to calculate the integral for each object.
http://root.cern.ch/root/html/TF1.html
Question C1: What is the value of ratio = fint/hint?
Extras
Question C2: Fit the histogram hfs from the file Fits.root with a sinus function and draw the fit parameters (final look)
Question C3: Fit the histogram fsomme from the file Fits.root with the sum of a 2nd degree polynomial, of a gaussian and of an exponential. Draw the result of fitting with the sum as well as each of the indivial functions. (final look)
Question C4: Fit the histogram fSignalFond from the file Fits.root with the sum of a background and a signal Draw the histogram with the global fit and the 2 individual functions and with a legend for each of the functions. (final look)
Background(x) = ( Ax / (1 + exp[ (x-B) / C ] )
Signal(x) = if x <= x0 then A*exp ( -0.5 * ( (x-x0)/sigG )^2 ) if x > x0 then A*exp ( -0.5 * ( (x-x0)/sigD )^2 )