The ROOT framework 1: Introduction

Slides:



Advertisements
Similar presentations
C++ Language Fundamentals. 2 Contents 1. Introduction to C++ 2. Basic syntax rules 3. Declaring and using variables.
Advertisements

H.G.Essel: Go4 - J. Adamczewski, M. Al-Turany, D. Bertini, H.G.Essel, S.Linev CHEP 2004 Go4 v2.8 Analysis Design.
Joe Foster Visualizing Data with ROOT Joe Foster University of Manchester.
ROOT Root Commands and CINT Functions and Fitting (The Tree Viewer)
ROOT TOOLKIT (I) Técnicas Fundamentales de Simulación, Reconstrucción y Análisis de Datos en Física Experimental de Partículas Isidro González Caballero.
Postgraduate Computing Lectures Applications I: Analysis Tools 1 Applications: Analysis Tools Analysis Tools –Used to extract Physics from reconstructed.
Postgraduate Computing Lectures ROOT 1 What is ROOT? Tool and a Framework for OO Data Analysis As a Tool –Enter commands to display and manipulate data.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
Guide To UNIX Using Linux Third Edition
Prof. R. Willingale Department of Physics and Astronomy 2nd Year C+R 2 nd Year C and R Workshop Part of module PA2930 – 2.5 credits Venue: Computer terminal.
Sept 11, 2003ROOT Day1, Suzanne Panacek39 ROOT An object oriented HEP analysis framework. Day 1.
ROOT An object oriented HEP analysis framework.. Computing in Physics Physics = experimental science =>Experiments (e.g. at CERN) Planning phase Physics.
Using ROOT classes from Python ROOT Workshop October 2002 P. Mato / CERN.
JAS3 + AIDA LC Simulations Workshop SLAC 19 th May 2003.
Alice off-line meeting Alberto Colla Cern, October 3, 2005 AliEn How-To Alice off-line meeting Cern, October 3, 2005 Alberto Colla (Alice off-line Calibration.
V0.05 ROOT 102 ROOT is an object oriented HEP analysis framework.
09-Jun-2005J. Adamczewski1 C++ course 2005 The ROOT framework 2.
Hans-Peter Plag October 16, 2014 Session 3 Programming Languages Data Types and Variables Expressions and Operators Flow Control.
21-Apr-2005J. Adamczewski1 DVEE C++ course 2005 The ROOT framework 1: Introduction.
THttpServer class Sergey Linev (GSI). Some history Development was inspired by JSRootIO why not achieve similar functionality with online ROOT application?
By Noorez Kassam Welcome to JNI. Why use JNI ? 1. You already have significantly large and tricky code written in another language and you would rather.
Hans-Peter Plag November 6, 2014 Session 4 (Programming Languages) (Data Types and Variables) Expressions and Operators Flow Control.
ROOT Tutorial An object oriented HEP data analysis framework Presented by Dimitri Bourilkov University of Florida UltraLight Workshop, June 2005, FIU,
10/31/2015PHYS 3446 DØ Data Analysis with ROOT Venkat (for Dr.Yu)
THttpServer for ROOT Bertrand Bellenot, CERN Sergey Linev, GSI Darmstadt
CLIP Command Line InterPreter for a subset of C++.
Introduction to ROOT Practical Part Jan Fiete Grosse-Oetringhaus, CERN PH/ALICE Summer Student Lectures th July.
ROOT’s graphics on iOS. ROOT’s graphics (general scheme):
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
ROOT What & Why? ROOT Status ROOT Application ROOT Install ROOT Example ROOT References Introduction to March 13, 2003 Dae Jung CHEP.
Go4 v3 - J.Adamczewski, H.G.Essel, S.Linev IT/EE Palaver Go4 version 3.
H.G.Essel: Go4 - J. Adamczewski, M. Al-Turany, D. Bertini, H.G.Essel, S.Linev CHEP 2003 GSI Online Offline Object Oriented Go4.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
ROOT Tutorials - Session 51 ROOT Tutorials – Session 5 Dictionary Generation, rootcint, Simple I/O, Hands-on Fons Rademakers.
Paul Scherrer Institut 5232 Villigen PSI ROME / / Matthias Schneebeli ROME Collaboration Meeting in Pisa Presented by Matthias Schneebeli.
GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GGO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4GO4G.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Overloading operators C++ incorporates the option to use standard operators to perform operations with.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
CINT & Reflex – The Future CINT’s Future Layout Reflex API Work In Progress: Use Reflex to store dictionary data Smaller memory footprint First step to.
S.Linev: Go4 - J.Adamczewski, H.G.Essel, S.Linev ROOT 2005 New development in Go4.
1 G4UIRoot Isidro González ALICE ROOT /10/2002.
Go4 Workshop J.Adamczewski-Musch, S.Linev Go4 advanced features.
ROOT: Functions & Fitting Harinder Singh Bawa California State University Fresno.
Joe Foster 1 This talk extends the one I gave in 2006 called Visualizing Data with ROOT. –
2001 ROOT Workshop The Summary. Content Most Requested Request already satisfied Build and Distribution Web Page Information and Documentation.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
HYDRA Framework. Setup of software environment Setup of software environment Using the documentation Using the documentation How to compile a program.
V0.02 The ROOT Collection Classes. V Collection Classes Group of related objects TObjects or descendants from TObject Abstract base class TCollection.
ROOT – úvodní přednáška a cvičení Jiří Chudoba,
ROOT Event Recording system
Go4 v2.2 Status & Overview CHEP 2003
Applications Active Web Documents Active Web Documents.
Before You Begin Nahla Abuel-ola /WIT.
Introduction to ROOT Practical Part
Distributed object monitoring for ROOT analyses with Go4 v.3
Polymorphism.
C-language Lecture By B.S.S.Tejesh, S.Neeraja Asst.Prof.
CSC113: Computer Programming (Theory = 03, Lab = 01)
Chapter 3 Software Interfaces.
ROOT Class Day 1 An Object Oriented Data Analysis Framework
Go4 CHEP 2001 Multithreaded Inter-Task Communication with ROOT -
Java Programming Language
Exploring the Power of EPDM Tasks - Working with and Developing Tasks in EPDM By: Marc Young XLM Solutions
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
Accomplishing Executables
Introduction to ROOT (2/2) Practical Part
ROOT Support and Developments at FNAL
Analysis Organization: Go4 Analysis Steps and TTask
SPL – PS1 Introduction to C++.
Static Binding Static binding chooses the function in the class of the base class pointer, ignoring any versions in the class of the object actually.
Presentation transcript:

The ROOT framework 1: Introduction J. Adamczewski DVEE C++ course 2005 21-Apr-2005 J. Adamczewski

Schedule of part 1 ROOT system overview The ROOT C++ interpreter CINT CINT and ROOT GUI for interactive work C++ as script language CINT runtime compiler ACLiC Compiled C++ with ROOT libraries (ROOT framework as class hierarchy) ROOT system overview The ROOT C++ interpreter CINT Using the ROOT GUI: TBrowser, TCanvas Example script: hsimple.C TObject, TNamed and ROOT object collections TFile and TDirectory classes The histogram classes TH1X examples 21-Apr-2005 J. Adamczewski

The ROOT system C++ based framework for (high energy-) physics (developed at CERN by R.Brun et al. since 1997) C++ as script language with interpreter CINT GUI for interactive visualization (TCanvas, TBrowser,...) I/O and analysis of large amount of data (TFile, TTree,...) Histograming, plotting, fits (TH1x, TGraph, TF1,...) Physics and mathematics (TMatrix, TLorentzVector, TMath,..) Object organisation (TCollection, TDirectory, TFolder,...) Parallel analysis via network (TProof) ... see http://root.cern.ch for further info! 21-Apr-2005 J. Adamczewski

Getting started (at GSI linux) . rootlogin [version] e.g. : > . rootlogin 403-04 > . rootlogin dev > . rootlogin see http://root.gsi.de for available versions 21-Apr-2005 J. Adamczewski

The C++ interpreter CINT Written by Masa Goto in C Standalone (non root) version available Incorporated in ROOT Applied for: Interactive command line Macro execution (language: C++ with extras); may compile macro at runtime (ACLiC feature) Generates object introspection metadata („dictionary“) when compiling ROOT 21-Apr-2005 J. Adamczewski

CINT command line CINT native commands start with “.” .? list all the CINT commands .x [filename] load [filename] and execute function [filename] e.g.: root[1] .x plot.C(“go4asf”) .L [filename] load [filename] e.g. root[2] .L plot.C .! [shellcmd] execute shell command e.g. root[3] .! ls –al 21-Apr-2005 J. Adamczewski

CINT command line (cont.) 2. Expression evaluation (advanced calculator): root[3] 3*4 (int)12 3. C++ Syntax (almost; see below...): root [0] TBrowser *b = new TBrowser() or root [0] TBrowser *b = new TBrowser(); Leave off final semicolon to see the return value of the command. root [0] 23+5 // show return value (int)28 root [1] 23+5; // no return value root [2] 21-Apr-2005 J. Adamczewski

CINT: differences to compiled C++ Declaration can be omitted f = new TFile("Example.root"); Member access: "." and "->“ both possible f.ls() or f->ls() Local object is not deleted when leaving scope { TString s(“test”); cout << s.Data()<<endl; // OK } cout << s.Data()<< endl; // only in CINT! 21-Apr-2005 J. Adamczewski

CINT: differences to compiled C++ (cont. ) Unknown variables are automatically initialized by searching the object of that name in gROOT. TH1F *smallHisto = new TH1F ("small","fPx”,100,100,-5,5); small->Draw(); Implicitely the following is done (as correct for compiled code): TH1F* small=dynamic_cast<TH1F*> (gROOT->FindObject("small")); ROOT object name C++ variable name 21-Apr-2005 J. Adamczewski

Using ROOT classes interactively root [] TF1 f1(“function1","sin(x)/x",0,10); root [] f1.Draw(); // pure C++ or root [] function1.Draw(); //cint reference by root name root [] f1.Eval(1.2456789) ... root [] f1.Derivative(2.3) .. root [] f1.Integral(0,3) root [] .q See ROOT class documentation for existing methods! http://root.cern.ch/root/html/TF1.html Start root create function object draw it Pointers available by name example 21-Apr-2005 J. Adamczewski

Root GUI: TCanvas After draw function, show menus of TCanvas Object properties on RMB menu ROOT inspector graphical GED editor 21-Apr-2005 J. Adamczewski

Root GUI: TBrowser show objects in memory folder overview menus Example: open file from browser, plot something New canvas with subpads: discuss middle mouse selection logic example: histogram rebin/ projection 21-Apr-2005 J. Adamczewski

Global ROOT objects (some examples) gROOT (session object singleton, class TROOT) TObject* ob=gROOT->FindObject(“hpx”); // get known object by root name TSeqCollection* list= gROOT->GetListOfFiles(); // access to collections of registered objects gROOT->SetBatch(kTRUE); // switch to non graphic mode gSystem (operating system interface, class TSystem) gSystem->Load(“libGo4UserAnalysis.so”); // load external library (for CINT) gSystem->Exec(“rm –rf *.root”); // call shell command (from compiled code) gDirectory (current root directory, class TDirectory) cout <<gDirectory->GetName()<< endl; gPad (currently selected draw pad, class TPad) gPad->Clear(); 21-Apr-2005 J. Adamczewski

Unnamed scripts Example hsimple.C (from ROOT tutorials): http://root.cern.ch/root/html/examples/hsimple.C.html used ROOT classes: TFile: root file handle object TCanvas: Window to draw graphics TH1F, TH2F, TProfile: histogram classes TNtuple: ntuple of values (simple TTree) TRandom (global gRandom): random generator TBenchmark (global gBenchmark): ) Show code of hsimple execute it 21-Apr-2005 J. Adamczewski

Named scripts Examples (from Go4 distribution): http://www-linux.gsi.de/~go4/download/cppworkshop/convertfile.C.html http://www-linux.gsi.de/~go4/download/cppworkshop/plothistos.C root root [] .L convertfile.C // load once root [] convertfile(“r113.root“); // call function root [] convertfile(“r114.root“); // call again root [] .x plothistos(“histograms.root“,200,700,1); // execute with parameters script must contain one function with same name as scriptfile script function may have arguments script may contain also other functions / subroutines script may contain class definitions objects in scope of named scripts are deleted after leaving script, objects in scope of unnamed scripts remain available! Show code of hsimple execute it 21-Apr-2005 J. Adamczewski

Automatic Compiler of Libraries for CINT (ACLiC) >root root [] .x plothistos.C(“test_AS“,0,2000,1) execute script in interpreter root [] .x plothistos.C+(“test_AS“,0,2000,1) compile script into library plothistos.C.so in background, then execute function (note: only recompile if plothistos.C or plothistos.h have changed since last compile) root [] .x plothistos.C++(“test_AS“,0,2000,1) compile library in any case before execution root [] .L convertfile.C+ compile script and load library, but do not execute root [] convertfile(“testASF“); // will execute loaded function Show code of hsimple execute it 21-Apr-2005 J. Adamczewski

Compiled code using ROOT Makefile to build library and executable convertfile: http://www-linux.gsi.de/~go4/download/cppworkshop/Makefile.html Main executable: http://www-linux.gsi.de/~go4/download/cppworkshop/main.cxx.html required in addition to convertfile.C and convertfile.h make all ... convertfile test_AS 21-Apr-2005 J. Adamczewski

C++ differences CINT interpreted ACLiC Compiled code ROOT class declarations are known implicitely NOTE: include all non-ROOT classes! ROOT classes require to include declarations, too e.g. #include „TH1.h“ ROOT class definitions are known implicitely Automatic linking against ROOT libs and the generated library ROOT classes require to link against respective libraries when building executable Makefile No function declaration needed Declare function before use „CINT C++“ (s.a.) Compiler C++ 21-Apr-2005 J. Adamczewski

TObject: ROOT top base class defines interface of fundamental virtual methods: Draw(), Print(), Dump(), GetName(), Clear(), Compare(), Streamer(), Clone(), Write(),... base type for root collections TObject* ob= new TH1F(“hpx“,“title“,2048,0,2047); TList* list=new TList; list->Add(ob); TObject* ob2=list->FindObject(“hpx“); IO (via TObject::Streamer()): ob->Write(); ob->Clone(); runtime class introspection: TClass* cl=ob->Class(); // full info on methods and datamembers in memory if(ob->InheritsFrom(“TH1“))... // check type Base class with standard services (introspection, streamer) Base type for root collections Idea of collections, example: loop with iterator 21-Apr-2005 J. Adamczewski

TH1: example of class hierarchy base classes Show class inheritance diagram since TObject Discuss virtual functions: Draw(), Print(), etc. Example: Histogram of different types in a ROOT collection, draw with iterator and over collection::draw dynamic_cast discussion with example subclasses “inherits from”, “implements” 21-Apr-2005 J. Adamczewski

Class hierarchy: some facts Subclass objects are of parent class type: a TH1D histogram „is a“ TObject Subclasses have all members /methods of parent classes TH1D* his=new TH1D(“hpx“,“example“,100,0,10); cout <<“histogram name:“ << his->GetName()<<endl; TH1D uses name property of TNamed Subclasses may redefine virtual methods: TObject::Print() overridden by TH1::Print() TObject* ob=new TH2I(“map“, “example“, 50, 0, 1000, 50, 0, 1000); ob->Print(); // C++ automatically calls TH2I::Print(); Show class inheritance diagram since TObject Discuss virtual functions: Draw(), Print(), etc. Example: Histogram of different types in a ROOT collection, draw with iterator and over collection::draw dynamic_cast discussion with example 21-Apr-2005 J. Adamczewski

Exercises Understand examples hsimple.C, plothistos.C (see ROOT classes Reference Guide at http://root.cern.ch) Write a ROOT script asciread(const char* filename) with following tasks: read in x,y,z values from an ascii file linewise. fill histograms for x, y, x:y and x:y:z from these values and draw them in one TCanvas that is divided into TPads fill TTree (TNtuple) with values x:y:z and write this into a TFile Example input file: http://www-linux.gsi.de/~go4/download/cppworkshop/input.dat Show code of hsimple execute it 21-Apr-2005 J. Adamczewski