ROOT Course Vincenzo Vitale, Dip. Fisica and INFN Roma 2
Introduction This is a basic introduction to ROOT. The purpose of the course is to provide a starting knowledge and some practical experiences on ROOT. This material is based on the ROOT documentation and other ROOT tutorials. LEGO strategy: use what you have or find what you need. Comparison of different ROOT experiences might be useful 2
OUTLINE What is ROOT Before ROOT: PAW ROOT and LHC What ROOT can do for you Some ROOT users Open Source Project ROOT modes Exercise: command line, GUI 3
What is ROOT ROOT is an object-oriented software package developed by CERN.(*) It was originally designed for particle physics data analysis and contains several features specific to this field. But it is also commonly used in other applications such as astronomy and data mining. * from Wikipedia 4
What is ROOT Development was initiated by René Brun and Fons Rademakers in 1994. ROOT is written in C++ 5
Before ROOT: PAW PAW widely used in particle physics Composed: HBOOK, ZEBRA, KUIP, COMIS, SIGMA Data analysis with NTUPLE (tables) Simple and Efficient No way to insert more complex structures Difficult to extend Expensive to maintain Too many different languages:fortran, KUIP, SIGMA 6
ROOT goals Support full data analysis chain Complete objects Object hierarchies Histogramming Fitting Visualization Only one language : C++ Better maintainable: OOP Extensible: OO framework tech. 7
Differences from PAW Regular grammar (C++) on command line Single language (compiled and interpreted) Object Oriented (use your class in the interpreter) Advanced Interactive User Interface Well Documented code. HTML class descriptions for every class. Object I/O including Schema Evolution 3-D interfaces with OpenGL and X3D. 8
ROOT and LHC The Large Hadron Collider's experiments will collect several tens of Petabytes of data per year. (1 Petabyte = 1000 Terabytes, compare with your PC harddisk) LHC data will be analyzed with ROOT. Then ROOT focus is on high performances, because of the amount of data C++ provides modularity and performances 9
What ROOT can do for you histogramming and graphing to visualize and analyze distributions and functions, curve fitting (regression analysis) and minimization of functionals, statistics tools used for data analysis, matrix algebra, four-vector computations, as used in high energy physics, standard mathematical functions, multivariate data analysis, e.g. using Neural Networks, image manipulation, used e.g. to analyze astronomical pictures, access to distributed data (in the context of the Grid) distributed computing, to parallelize data analyses, persistence and serialization of objects, which can cope with changes in class definitions of persistent data, access to databases, 3D visualizations (geometry) creating files in various graphics formats, like PostScript, JPEG, SVG, interfacing Python and Ruby code in both directions, interfacing Monte Carlo event generators... 10
Examples Histograms 11
Examples Data visualization and analysis 12
Examples Graphics in 2 and 3 dim 13
Examples Graphics in 2 and 3 dim 14
Examples LATEX support 15
Examples ALICE central Pb-Pb simulated event 16
Examples Astrophysical data handling 17
some ROOT users BaBar CDF COMPASS DZero H1 MINOS PHENIX PHOBOS STAR ZEUS CRESST... ALICE ATLAS CMS LHCb NOνA PANDA GLAST MAGIC PAMELA ICECUBE H.E.S.S. Milagro (experiment) Pierre Auger Observatory VERITAS... 18
Open Source Project Developed as a collaboration: CERN, FermiLAB, Japan, MIT, others Thousand of users giving feedback, comments and other contributions Open Source Project, source is available under GPL license 3/4 major releases a year Annual workshop Let users become developers 19
Distribution ROOT is FREELY available at http://root.cern.ch/ ROOT is well maintained All the new releases and patches are available Large documentation and forums 20
ROOT modes Interactive Session (ROOT command line interface) Macro (Script Processor) Compiled executables Scripting languages C++ is the language for all the operating modes 21
Exercise 1 2 hours will be dedicated to exercises Log on...(address given by voice for security) User: glast Temporary password: nopass > bash or Download binaries from ROOT page on your laptop Set ROOTSYS, PATH and LD_LIBRARY_PATH environment variables 22
Exercise 1 Start ROOT Quit ROOT Output on screen Run a minimal macro > root root [ ].q 23
Exercise 1 Output on screen root [] 35 + 89.3 root [] float x = 45.6 root [] float y = 56.2 + sqrt(x); root [] float z = x+y; root [] x root [] y root [] z root [] cout << hallo world << endl; 24
CINT Extensions to C++ 1. Declaration can be omitted f = new TFile("Example.root") 2. "." notation rather than "->" f.ls() 3. Search for an object by its name TH1F *smallhisto = new TH1F("small","fPx 100",100,-5,5); small->draw(); Warning: These will not work in compiled code! 25
CINT Commands [expression] evaluates the expression.files show loaded source files.class [name] show class definition.g prints all objects in the root session.ls ls on current directory.pwd list the current directory, canvas, and style. 26
Exercise 1 Run a minimal macro root [].x macro1.c Void macro1() { cout << this is a ROOT macro << endl; } Histogram macro root [].x histo2.c 27
Open a File Open a file for reading root [] TFile f( example.root ) Listing the file content root [].x f.ls Or use TBrowser root [] TBrowser t 28
The Editor Panel The Editor Panel Adding Error bars Changing colors Styles 29
Color and Error Bars Colors root [] main->setfillcolor(9) Error Bars root [] main->draw( e1 same ) Fit root [] main->fit( gaus ) 30
The Editor Panel Sliders Rebining 31
Fitting, Coloring, and Zooming Adding a gaussian fit Coloring the histogram Zooming/unzooming 32
Basic Navigation by Clicking Left Click select the object drag the object resize the object Right Click context menu class::name methods Middle Click activate canvas pop pads freezes event status bar 33
Dividing the Canvas Create a new Canvas Divide it in 2 Draw two histograms 34
1-D Drawing Options Any object in the canvas is clickable and editable 35