1 / 77

Introduction to ROOT

Introduction to ROOT. Summer Students Lecture 16 July 2003 Ren é Brun CERN/EP/SFT. http://root.cern.ch. What is ROOT?. The ROOT system is an Object Oriented framework for large scale data handling applications Written in C++ Provides, among others, An efficient hierarchical OO database

rromeo
Download Presentation

Introduction to ROOT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to ROOT Summer Students Lecture 16 July 2003 René Brun CERN/EP/SFT http://root.cern.ch Introduction to ROOT

  2. What is ROOT? • The ROOT system is an Object Oriented framework for large scale data handling applications • Written in C++ • Provides, among others, • An efficient hierarchical OO database • A C++ interpreter • Advanced statistical analysis (multi dimensional histogramming, fitting, minimization and cluster finding algorithms) • Visualization tools • And much, much more • The user interacts with ROOT via a graphical user interface, the command line or batch scripts • The command and scripting language is C++, thanks to the embedded CINT C++ interpreter and large scripts can be compiled and dynamically loaded Introduction to ROOT

  3. The ROOT Project ROOT X.0 functionality ROOT 3.0 LHC Large Hadron Collider ROOT 2.0 RHIC, FNAL/RUN II, Babar,KEK ROOT 1.0 LEP,HERA,SPS ROOT 0.5 1995 2000 2005 Introduction to ROOT

  4. The ALICE detector(1100 physicists) Introduction to ROOT

  5. A collision in CMS Introduction to ROOT

  6. From the desktop to the GRID Online/Offline Farms Local/remote Storage Desktop New data analysis tools must be able to use in parallel remote CPUS, storage elements and networks in a transparent way for a user at a desktop GRID Introduction to ROOT

  7. ROOT Library Structure • ROOT libraries are a layered structure • The CORE classes are always required (support for RTTI, basic I/O and interpreter) • The optional libraries (you load only what you use) Separation between data objects and the high level classes acting on these objects. Example, a batch job uses only the histogram library, no need to link histogram painter library. • Shared libraries reduce the application link time • Shared libraries reduce the application size • ROOT shared libraries can be used with other class libraries Introduction to ROOT

  8. The Libraries • Over 700 classes • 950,000 lines of code • CORE (10 Mbytes) • CINT (3 Mbytes) • Green libraries linked on demand via plug-in manager (only a subset shown) Introduction to ROOT

  9. ROOT: a Framework and a Library • User classes • User can define new classes interactively • Either using calling API or sub-classing API • These classes can inherit from ROOT classes • Dynamic linking • Interpreted code can call compiled code • Compiled code can call interpreted code • Macros can be dynamically compiled & linked This is the normal operation mode Interesting feature for GUIs & event displays Script Compiler root > .x file.C++ Introduction to ROOT

  10. Dynamic Linking • A Shared Library can be linked dynamically to a running executable module • either via explicit loading,- or automatically via plug-in manager Experiment libraries A Shared Library facilitates the development and maintenance phases User libraries General libraries Application Executable Module Introduction to ROOT

  11. Plug-in Manager Exp Shared libs User Shared lib Exp Shared libs Exp Shared libs Basic Services, GUI, Math.. General Utility Shared lib Plug-in manager I/O manager I/O manager Interpreter Object Dictionary Introduction to ROOT

  12. CINT Interpreter Introduction to ROOT

  13. Command Line Options • > root -/? • Usage: root [-l] [-b] [-n] [-q] [file1.C ... fileN.C] • Options: • -b : run in batch mode without graphics • -n : do not execute logon and logoff macros as specified in .rootrc • -q : exit after processing command line macro files • -l : do not show splash screen Introduction to ROOT

  14. CINT • CINT is a C and C++ interpreter • Written by Masaharu Goto and available under an Open Source license • It implements about 95% of ANSI C and 90% of ANSI C++ • It is robust and complete enough to interpret itself (90000 lines of C, 5000 lines of C++) • Has good debugging facilities • Has a byte code compiler • In many cases it is faster than tcl, perl and python Introduction to ROOT

  15. CINT in ROOT • CINT is used in ROOT: • As command line interpreter • As script interpreter • To generate class dictionaries • To generate function/method calling stubs • The command line, script and programming language become the same • Large scripts can be compiled for optimal performance Introduction to ROOT

  16. Introduction to ROOT

  17. Scripts • Un-named Script • Start with "{" and end with "}" • All variables are in the global scope • No class definitions • No function declarations • No parameters • Named Script • C++ functions • Scope rules follow standard C++ • Function with the same name as the file is executed with a .x Parameters Class definitions (derived from a compiled class at your own risk) Introduction to ROOT

  18. Scripts Examples • Un-named Macro:hello.C { cout << "Hello" << endl; } • Named Macro:say.C void say(char * what = "Hello") { cout << what << endl; } • Executing the Named Macro root [3].x say.C Hello root [4].x say.C("Hi there") Hi there Introduction to ROOT

  19. The Object Dictionary Object Dictionary Data dictionary Functions dictionary Inspectors Browsers I/O Interpreted scripts GUI Command line Compiled code Introduction to ROOT

  20. Providing Interactive Access • To provide interactive access to your classes from CINT you only need to generate a dictionary for your classes • No other instrumentation is needed Introduction to ROOT

  21. rootcint –f MyDict.cxx –c MyClass.h MyDict.h MyDict.cxx compile and link libMyClass.so Generating a Dictionary MyClass.h MyClass.cxx Introduction to ROOT

  22. Graphics & GUI Introduction to ROOT

  23. Gui/Graphics strategy User/Root GUI and Graphics classes Applications see only Abstract Interfaces High level pad graphics TVirtualPad Low level screen graphics and GUI TVirtualX TPad TGWin32 TGQt TG?? TGX11 TGWin32GDK Introduction to ROOT

  24. TPad: main graphics container Root > TLine line(.1,.9,.6,.6) Root > line.Draw() Root > TText text(.5,.2,”Hello”) Root > text.Draw() Hello The Draw function adds the object to the list of primitives of the current pad. If no pad exists, a pad is automatically created with a default range [0,1]. When the pad needs to be drawn or redrawn, the object Paint function is called. Only objects deriving from TObject may be drawn in a pad Root Objects or User objects Introduction to ROOT

  25. Canvas pixmaps Need Help? Scroll bars 1200x800 600x400 Introduction to ROOT

  26. Saving a pad/canvas • A pad/canvas may be saved in many formats using the GUI menu or via TPad::SaveAs • canvas.C : a C++ script is automatically generated. The canvas may be generated again via .x canvas.C • canvas.ps(eps) Postscript or encapsulated ps • canvas.svg : scalable vector graphics • canvas.gif • canvas.root: keep objects in a compressed and portable format. Introduction to ROOT

  27. Full LateXsupport on screen and postscript latex3.C Formula or diagrams can be edited with the mouse Feynman.C TCurlyArc TCurlyLine TWavyLine and other building blocks for Feynmann diagrams Introduction to ROOT

  28. Graphs TGraphErrors(n,x,y,ex,ey) TGraph(n,x,y) gerrors2.C TCutG(n,x,y) TMultiGraph TGraphAsymmErrors(n,x,y,exl,exh,eyl,eyh) Introduction to ROOT

  29. Graphs zdemo.C Introduction to ROOT

  30. The Histogram Package Introduction to ROOT

  31. The Histogram Classes • Structure 1-Dim 2-Dim 3-Dim Introduction to ROOT

  32. Histograms Introduction to ROOT

  33. Peak Finder + Deconvolutions TSpectrum Introduction to ROOT

  34. Fitting TMinuit TFumili TFitter TVirtualFitter TH1::Fit bin chisquare bin likelihood TTree::Fit unbinned likelihood TGraph::Fit unbinned chisquare User Introduction to ROOT

  35. Fitting histograms • Histograms (1-D,2-D,3-D and Profiles) can be fitted with a user specified function via TH1::Fit. Two Fitting algorithms are supported: Chisquare method and Log Likelihood • The user functions may be of the following types: • standard functions: gaus, landau, expo, poln • combination of standard functions; poln + gaus • A C++ interpreted function or a C++ precompiled function • An option is provided to compute the integral of the function bin by bin instead of simply compute the function value at the center of the bin. • When an histogram is fitted, the resulting function with its parameters is added to the list of functions of this histogram. If the histogram is made persistent, the list of associated functions is also persistent. • One can retrieve the function/fit parameters with calls such as: • Double_t chi2 = myfunc->GetChisquare(); • Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter • Double_t err0 = myfunc->GetParError(0); //error on first parameter Introduction to ROOT

  36. Fitting Example Introduction to ROOT

  37. Random Numbers and Histograms • TH1::FillRandom can be used to randomly fill an histogram using • the contents of an existing TF1 analytic function • another histogram (for all dimensions). • For example the following two statements create and fill an histogram 10000 times with a default gaussian distribution of mean 0 and sigma 1: • TH1F h1("h1","histo from a gaussian",100,-3,3); • h1.FillRandom("gaus",10000); • TH1::GetRandom can be used to return a random number distributed according the contents of an histogram. Introduction to ROOT

  38. 1-D drawing Options Any object in the canvas is clickable and editable Introduction to ROOT

  39. Introduction to ROOT

  40. 2-D drawing options Introduction to ROOT

  41. 2-D drawing options Introduction to ROOT

  42. 2-D drawing Options All these plots can be rotated with the mouse Introduction to ROOT

  43. 2-D drawing Options Same output on the screen and with vector Postscript Introduction to ROOT

  44. Filling with string variables Introduction to ROOT

  45. 3-D Graphics • Basic primitives • TPolyLine3D, TPolyMarker3D, THelix, TMarker3DBox,TAxis3D • Geant primitives • Support for all Geant3 volumes + a few new volume types • TBRIK,TCONE,TCONS,TCTUB,TELTU,TGTRA,THYPE,TPARA,TPCON, TPGON,TSPHE,TTUBE,TTUBS,TTRAP,TTRD1,TTRD2,TXTRU • Geometry package • Rendering with: • TPad • X3D (very fast. Unix only. Good on networks) • OpenGL • OpenInventor (new addition in 3.01) Introduction to ROOT

  46. Some detectors in ROOT geometry Introduction to ROOT

  47. Alice 3 million nodes Introduction to ROOT

  48. Graphics : 1,2,3-D functions FittingDemo.C surfaces.C TF3 f3(“f3”,”sin(x*x+y*y+z*z-36)”,-2,2,-2,2,-2,2); f3->Draw(); Introduction to ROOT

  49. GUI User example Example of GUI based on ROOT tools Each element is clickable Introduction to ROOT

  50. GUI Examples Introduction to ROOT

More Related