Introduction to ROOT Summer Students Lecture 21 July

  • Slides: 38
Download presentation
Introduction to ROOT Summer Students Lecture 21 July 2004 René. Brun@cern. ch ftp: //root.

Introduction to ROOT Summer Students Lecture 21 July 2004 René. Brun@cern. ch ftp: //root. cern. ch/root/Summer. Students 2004. ppt Introduction to ROOT 1

ROOT in a nutshell n n n n An efficient data storage and access

ROOT in a nutshell n n n n An efficient data storage and access system designed to support structured data sets in very large distributed data bases (Petabytes). A query system to extract information from these distributed data sets. The query system is able to use transparently parallel systems on the GRID (PROOF). A scientific visualisation system with 2 -D and 3 -D graphics. An advanced Graphical User Interface A C++ interpreter allowing calls to user defined classes. An Open Source Project Introduction to ROOT 2

ROOT: An Open Source Project n n The project is developed as a collaboration

ROOT: An Open Source Project n n The project is developed as a collaboration between : Full time developers: n n n n 6 1 1 people full time at CERN key developer at Fermi. Lab key developer in Japan (Agilent Technologies) key developer at MIT mathematician at CERN sponsored by a US Finance Company Many contributors spending a substantial fraction of their time in specific areas (> 50). Key developers in large experiments using ROOT as a framework. Several thousand users given feedback and a very long list of small contributions. Introduction to ROOT 3

The ROOT Project ROOT 4. 0 functionality ROOT 3. 0 LHC Large Hadron Collider

The ROOT Project ROOT 4. 0 functionality ROOT 3. 0 LHC Large Hadron Collider ROOT 2. 0 RHIC, FNAL/RUN II, Babar, KEK ROOT 1. 0 ROOT 0. 5 1995 LEP, HERA, SPS 2000 2005 Introduction to ROOT 4

The ROOT web pages http: //root. cern. ch q. General Information and News q.

The ROOT web pages http: //root. cern. ch q. General Information and News q. Download source and binaries q. Howto & tutorials q. User Guide & Reference Guides q. Roottalk Digest & Forum Introduction to ROOT 5

Batch/Interactive models Need experiment framework +widely available tools Batch Production Simulation reconstruction Interactive batch

Batch/Interactive models Need experiment framework +widely available tools Batch Production Simulation reconstruction Interactive batch model Introduction to ROOT Need only widely available tools Interactive Chaotic analysis 6

Data Volume & Processing Time Using technology available in 2004 100 MB 1 GB

Data Volume & Processing Time Using technology available in 2004 100 MB 1 GB 100 GB 1 TB 100 TB 1 PB ROOT 1 Processor P IV 2. 4 GHz 2004 : Time for one query using 10 per cent of data 1” 10” 1’ 10’ 1 h 10 h 1 day 1 month batch Interactive PROOF 10 Processors 1” 10 days 1” 10” 1’ 10’ 1 h 10 h 1 day 1” 10” 1’ 10’ 1 h 10 h PROOF 100 Processors 1” 1” 1 day PROOF/GLite 1000 Processors 1’ 10’ Introduction to ROOT 1 h 10 h 7

Data Volume & Processing Time Using technology available in 2010 100 MB 1 GB

Data Volume & Processing Time Using technology available in 2010 100 MB 1 GB 100 GB 1 TB 100 TB 1 PB ROOT 1 Processor XXXXX 2010 : Time for one query using 10 per cent of data 1” 10 days. Interactive 1” 1’ 10’ 1 h 10 h 1 day batch PROOF 10 Processors 1” 1” 1” 10” 1’ 10’ 1 h 10 h 1 day 1” 1” 10” 1’ 10’ 1 h 10 h PROOF 100 Processors 1” 1” PROOF/GLite 1000 Processors 1’ Introduction to ROOT 10’ 1 h 8

ROOT Library Structure n n n ROOT libraries are a layered structure The CORE

ROOT Library Structure n n n 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 9

The Libraries n n n Introduction to ROOT Over 1000 classes 1250, 000 lines

The Libraries n n n Introduction to ROOT Over 1000 classes 1250, 000 lines of code CORE (12 Mbytes) CINT (3 Mbytes) Green libraries linked on demand via plug-in manager (only a subset shown) 10

ROOT: a Framework and a Library n n User classes This is the normal

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

A Data Analysis & Visualisation tool Introduction to ROOT 12

A Data Analysis & Visualisation tool Introduction to ROOT 12

Graphics : 1, 2, 3 -D functions n Introduction to ROOT 13

Graphics : 1, 2, 3 -D functions n Introduction to ROOT 13

Full Late. X support on screen and postscript Formula or diagrams can be edited

Full Late. X support on screen and postscript Formula or diagrams can be edited with the mouse TCurly. Arc TCurly. Line TWavy. Line and other building blocks for Feynmann diagrams Introduction to ROOT 14

Alice 3 million nodes Introduction to ROOT 15

Alice 3 million nodes Introduction to ROOT 15

ROOT + RDBMS Model ROOT files histograms Oracle My. SQL Event Store Calibrations Run/File

ROOT + RDBMS Model ROOT files histograms Oracle My. SQL Event Store Calibrations Run/File Catalog Trees Geometries Introduction to ROOT 16

ROOT I/O : An Example Program Writing demoh. C TFile f(“example. root”, ”new”); TH

ROOT I/O : An Example Program Writing demoh. C TFile f(“example. root”, ”new”); TH 1 F h(“h”, ”My histogram”, 100, -3, 3); h. Fill. Random(“gaus”, 5000); h. Write(); Program Reading TFile f(“example. root”); demohr. C TH 1 F *h = (TH 1 F*)f. Get(“h”): h->Draw(); f. Map(); 20010831/171903 20010831/171941 20010831/171946 At: 64 At: 154 At: 607 At: 2971 At: 3067 At: 3123 N=90 N=453 N=2364 N=96 N=56 N=1 TFile TH 1 F Streamer. Info Keys. List Free. Segments END CX = 2. 09 3. 25 Introduction to ROOT 17

A Root file pippa. root with two levels of directories Introduction to ROOT Objects

A Root file pippa. root with two levels of directories Introduction to ROOT Objects in directory /pippa/DM/CJ eg: /pippa/DM/CJ/h 15 18

Memory <--> Tree Each Node is a branch in the Tree Memory 0 T.

Memory <--> Tree Each Node is a branch in the Tree Memory 0 T. Get. Entry(6) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 T. Fill() T Introduction to ROOT 19

Tree example Event (write) void demoe(int nevents) { //load shared lib with the Event

Tree example Event (write) void demoe(int nevents) { //load shared lib with the Event class g. System->Load("$ROOTSYS/test/lib. Event"); //create a new ROOT file TFile f("demoe. root", ”new"); All the examples can be executed with CINT or the compiler root >. x demoe. C++ //Create a ROOT Tree with one single top level branch int split = 99; //try also split=1 and split=0 int bufsize = 16000; Event *event = new Event; TTree T("T", "Event demo tree"); T. Branch("event", "Event", &event, bufsize, split); //Build Event in a loop and fill the Tree for (int i=0; i<nevents; i++) { event->Build(i); T. Fill(); } T. Print(); T. Write(); //Print Tree statistics //Write Tree header to the file } Introduction to ROOT 20

Tree example Event (read 1) void demoer() { //load shared lib with the Event

Tree example Event (read 1) void demoer() { //load shared lib with the Event class g. System->Load("$ROOTSYS/test/lib. Event"); //connect ROOT file TFile *f = new TFile("demoe. root"); //Read Tree header and set top branch address Event *event = 0; TTree *T = (TTree*)f->Get("T"); T->Set. Branch. Address("event", &event); //Loop on events and fill an histogram TH 1 F *h = new TH 1 F("hntrack", "Number of tracks", 100, 580, 620); int nevents = (int)T->Get. Entries(); for (int i=0; i<nevents; i++) { T->Get. Entry(i); Rebuild the full event h->Fill(event->Get. Ntrack()); in memory } h->Draw(); } Introduction to ROOT 21

8 leaves of branch Electrons A double-click to histogram the leaf 8 Branches of

8 leaves of branch Electrons A double-click to histogram the leaf 8 Branches of T Introduction to ROOT 22

The Tree Viewer & Analyzer A very powerful class supporting complex cuts, event lists,

The Tree Viewer & Analyzer A very powerful class supporting complex cuts, event lists, 1 -d, 2 -d, 3 -d views parallelism Introduction to ROOT 23

Tree Friends 01 23 45 67 89 10 11 12 13 14 15 16

Tree Friends 01 23 45 67 89 10 11 12 13 14 15 16 17 18 0 1 2 3 4 5 6 7 8 Entry # 8 01 23 45 67 89 10 11 12 13 14 15 16 17 18 Public User read Write Introduction to ROOT 24

Tree Friends Analysis group protected Collaboration-wide public read user private Processing time independent of

Tree Friends Analysis group protected Collaboration-wide public read user private Processing time independent of the number of friends unlike table joins in RDBMS x Root > TFile f 1(“tree 1. root”); Root > tree. Add. Friend(“tree 2”, “tree 2. root”) Root > tree. Add. Friend(“tree 3”, “tree 3. root”); Root > tree. Draw(“x: a”, ”k<c”); Root > tree. Draw(“x: tree 2. x”, ”sqrt(p)<b”); Introduction to ROOT 25

GRID: Interactive Analysis Case 1 n n n Data transfer to user’s laptop Optional

GRID: Interactive Analysis Case 1 n n n Data transfer to user’s laptop Optional Run/File catalog Optional GRID software Optional run/File Catalog Analysis scripts are interpreted or compiled on the local machine Trees Remote file server eg rootd Trees Introduction to ROOT 26

GRID: Interactive Analysis Case 2 n n n Remote data processing Optional Run/File catalog

GRID: Interactive Analysis Case 2 n n n Remote data processing Optional Run/File catalog Optional GRID software Optional run/File Catalog Analysis scripts are interpreted or compiled on the remote machine Trees Commands, scripts histograms Remote data analyzer eg proofd Introduction to ROOT Trees 27

GRID: Interactive Analysis Case 3 n n n Remote data processing Run/File catalog Full

GRID: Interactive Analysis Case 3 n n n Remote data processing Run/File catalog Full GRID software Analysis scripts are interpreted or compiled on the remote master(s) Run/File Catalog slave Commands, scripts Histograms, trees Remote data analyzer eg proofd slave Introduction to ROOT Trees Trees 28

Trends Summary More and more GRID oriented data analysis More and more experiment-independent software

Trends Summary More and more GRID oriented data analysis More and more experiment-independent software Parallelism on the GRID Batch/Interactive Access to Catalogs Efficient Access to large and structured event collections Histogram Ntuple viewers Data Presenters Interaction with user & experiment classes Introduction to ROOT Resource Brokers Process migration Progress Monitors Proxies/caches Virtual data sets 29

Google: a good model Make it simple Simple interface Available everywhere Hidden Parallelism Distributed

Google: a good model Make it simple Simple interface Available everywhere Hidden Parallelism Distributed DB Don’t know a priori the data location Fast Introduction to ROOT 30

Playing with ROOT on lxplus n Set the environment variables n n Copy the

Playing with ROOT on lxplus n Set the environment variables n n Copy the ROOT tutorials n n setenv ROOTSYS /afs/cern. ch/sw/root/v 4. 00. 08/rh 73_gcc 32/root setenv LD_LIBRARY_PATH $ROOTSYS/lib: $LD_LIBRARY_PATH setenv PATH $ROOTSYS/bin: $PATH cd $HOME cp $ROOTSYS/tutorials. cd tutorials Run ROOT n root Introduction to ROOT 31

Playing with ROOT on a PC n n n Import a binary tar file

Playing with ROOT on a PC n n n Import a binary tar file from: n http: //root. cern. ch/root/Version 400. html n Eg: Intel x 86 Linux for Redhat 7. 3 and gcc 3. 2, version 4. 00/08 Untar the file in your home directory n cd $HOME n tar zxvf root_v 4. 00. 08. Linux. RH 7. 3. gcc 32. tar. gz Set the environment variables n n Go to the ROOT tutorials n n setenv ROOTSYS $HOME/root setenv LD_LIBRARY_PATH $ROOTSYS/lib: $LD_LIBRARY_PATH setenv PATH $ROOTSYS/bin: $PATH cd $HOME cp $ROOTSYS/tutorials. cd tutorials Run ROOT n root Introduction to ROOT 32

My first session root [0] 344+76. 8 (const double)4. 20800000010 e+002 root [1] float

My first session root [0] 344+76. 8 (const double)4. 20800000010 e+002 root [1] float x=89. 7; root [2] float y=567. 8; root [3] x+sqrt(y) (double)1. 13528550991510710 e+002 root [4] float z = x+2*sqrt(y/6); root [5] z (float)1. 09155929565429690 e+002 root [6]. q root See file $HOME/. root_hist root [0] try up and down arrows Introduction to ROOT 33

My second session root [0]. x session 2. C for N=100000, sum= 45908. 6

My second session root [0]. x session 2. C for N=100000, sum= 45908. 6 root [1] sum (double)4. 59085828512453370 e+004 Root [2] r. Rndm() (Double_t)8. 29029321670533560 e-001 root [3]. q session 2. C { int N = 100000; TRandom r; double sum = 0; for (int i=0; i<N; i++) { sum += sin(r. Rndm()); } printf("for N=%d, sum= %gn", N, sum); unnamed macro executes in global scope } Introduction to ROOT 34

My third session root [0]. x session 3. C for N=100000, sum= 45908. 6

My third session root [0]. x session 3. C for N=100000, sum= 45908. 6 root [1] sum Error: Symbol sum is not defined in current scope *** Interpreter error recovered *** Root [2]. x session 3. C(1000) for N=1000, sum= 460. 311 root [3]. q session 3. C Named macro Normal C++ scope rules void session 3 (int N=100000) { TRandom r; double sum = 0; for (int i=0; i<N; i++) { sum += sin(r. Rndm()); } printf("for N=%d, sum= %gn", N, sum); } Introduction to ROOT 35

My third session with ACLIC root [0] g. ROOT->Time(); root [1]. x session 4.

My third session with ACLIC root [0] g. ROOT->Time(); root [1]. x session 4. C(10000000) for N=10000000, sum= 4. 59765 e+006 Real time 0: 06, CP time 6. 890 root [2]. x session 4. C+(10000000) for N=10000000, sum= 4. 59765 e+006 Real time 0: 09, CP time 1. 062 root [3] session 4(10000000) for N=10000000, sum= 4. 59765 e+006 Real time 0: 01, CP time 1. 052 root [4]. q File session 4. C Automatically compiled and linked by the native compiler. Must be C++ compliant session 4. C #include “TRandom. h” void session 4 (int N) { TRandom r; double sum = 0; for (int i=0; i<N; i++) { sum += sin(r. Rndm()); } printf("for N=%d, sum= %gn", N, sum); } Introduction to ROOT 36

Macros with more than one function root [0]. x session 5. C >session 5.

Macros with more than one function root [0]. x session 5. C >session 5. log root [1]. q root [0]. L session 5. C root [1] session 5(100); >session 5. log root [2] session 5 b(3) sum(0) = 0 sum(1) = 1 sum(2) = 3 root [3]. q. x session 5. C executes the function session 5 in session 5. C use g. ROOT->Process. Line to execute a macro from a macro or from compiled code session 5. C void session 5(int N=100) { session 5 a(N); session 5 b(N); g. ROOT->Process. Line(“. x session 4. C+(1000)”); } void session 5 a(int N) { for (int i=0; i<N; i++) { printf("sqrt(%d) = %gn", i, sqrt(i)); } } void session 5 b(int N) { double sum = 0; for (int i=0; i<N; i++) { sum += i; printf("sum(%d) = %gn", i, sum); } } Introduction to ROOT 37

Interactive Demo You can import the tar file with all demos from ftp: //root.

Interactive Demo You can import the tar file with all demos from ftp: //root. cern. ch/root/Summer. Students 2004. tar. gz root summershow. C You can find more demos, examples, tests at $ROOTSYS/tutorials $ROOTSYS/test/Root. Shower Introduction to ROOT 38