Trees: New Developments1 Trees: New Developments Folders and Tasks ROOT Workshop 2001 June 13 FNAL Ren é Brun CERN

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Introduction to C Programming
H.G.Essel: Go4 - J. Adamczewski, M. Al-Turany, D. Bertini, H.G.Essel, S.Linev CHEP 2004 Go4 v2.8 Analysis Design.
1 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
Feature requests for Case Manager By Spar Nord Bank A/S IBM Insight 2014 Spar Nord Bank A/S1.
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
Chapter 9 Subprogram Control Consider program as a tree- –Each parent calls (transfers control to) child –Parent resumes when child completes –Copy rule.
ISBN Chapter 10 Implementing Subprograms.
VBA Modules, Functions, Variables, and Constants
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. ETC - 1 What comes next? Recursion (Chapter 15) Recursive Data Structures.
1 Chapter 7 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Guide To UNIX Using Linux Third Edition
CHEP ' 2003David Chamont (CMS - LLR)1 Twelve Ways to Build CMS Crossings from Root Files Benefits and deficiencies of Root trees and clones when : - NOT.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
C++ fundamentals.
FunctionsFunctions Systems Programming Concepts. Functions   Simple Function Example   Function Prototype and Declaration   Math Library Functions.
ROOT courses1 The ROOT System A Data Access & Analysis Framework February 2003 Ren é Brun/EP Trees.
Large Data Bases in High Energy Physics Frontiers in Diagnostic Technologies Frascati November 26 Frascati November 26 Rene Brun/CERN.
1 Web Based Programming Section 6 James King 12 August 2003.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Reusable Code For Your Appx Processes Presented By: Gary Rogers.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
2 Preliminaries Options for implementing an ADT List Array has a fixed size Data must be shifted during insertions and deletions Linked list is able to.
1 Web-Enabled Decision Support Systems Objects and Procedures Don McLaughlin IE 423 Design of Decision Support Systems (304)
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Applets Chapter 17.  Java’s big splash onto the scene came in the mid 90’s. The people at Sun Microsystems had managed to work java programs into Web.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
1 MT258 Computer Programming and Problem Solving Unit 7.
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 7 PL/SQL Packages.
SE: CHAPTER 7 Writing The Program
Sharda University P. K. Mishra (Asst.Prof) Department of Computer Science & Technology Subject Name: Programming Using C Sub Code: CSE-106 Programming.
Recursive Functions Creating Hierarchical Reports Date: 9/30/2008 Dan McCreary President Dan McCreary & Associates (952) M.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
ROOT for Data Analysis1 Intel discussion meeting CERN 5 Oct 2003 Ren é Brun CERN Distributed Data Analysis.
ISBN Chapter 10 Implementing Subprograms.
STAR Event data storage and management in STAR V. Perevoztchikov Brookhaven National Laboratory,USA.
Chapter Three The UNIX Editors.
Persistent Object References in ROOT1 Persistent Object References in ROOT I/O Status & Proposal CMS-ROOT meeting CERN- November 27 Ren é Brun ftp://root.cern.ch/root/refs.ppt.
Apr. 8, 2002Calibration Database Browser Workshop1 Database Access Using D0OM H. Greenlee Calibration Database Browser Workshop Apr. 8, 2002.
H.G.Essel: Go4 - J. Adamczewski, M. Al-Turany, D. Bertini, H.G.Essel, S.Linev CHEP 2003 GSI Online Offline Object Oriented Go4.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
ROOT Tutorials - Session 51 ROOT Tutorials – Session 5 Dictionary Generation, rootcint, Simple I/O, Hands-on Fons Rademakers.
STAR Schema Evolution Implementation in ROOT I/O V. Perevoztchikov Brookhaven National Laboratory,USA.
PROOF and ALICE Analysis Facilities Arsen Hayrapetyan Yerevan Physics Institute, CERN.
9/28/2005Philippe Canal, ROOT Workshop TTree / SQL Philippe Canal (FNAL) 2005 Root Workshop.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
ISBN Chapter 10 Implementing Subprograms.
S.Linev: Go4 - J.Adamczewski, H.G.Essel, S.Linev ROOT 2005 New development in Go4.
October 10-12, 1 AliRoot: I/O organisation ROOT in the ALICE experiment I/O Structure Run-Time Data-Exchange.
ROOT-CORE Team 1 Philippe Canal Markus Frank I/O Basic I/O, RDBMS interfaces, Trees.
Joe Foster 1 This talk extends the one I gave in 2006 called Visualizing Data with ROOT. –
Oracle9i Developer: PL/SQL Programming Chapter 6 PL/SQL Packages.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
HYDRA Framework. Setup of software environment Setup of software environment Using the documentation Using the documentation How to compile a program.
Persistent Object References in ROOT1 Persistent Object References in ROOT I/O Status & Proposal LCG meeting CERN- 5 June Ren é Brun ftp://root.cern.ch/root/longrefs.ppt.
Module 11: File Structure
Lecture 22 Inheritance Richard Gesick.
Recent Developments in ROOT I/O Support for foreign classes
Structure Charts Agenda: What are Structure Charts
Persistent Object References in ROOT I/O Status & Proposal
Prof. Arfaoui. COM390 Chapter 7
Presentation transcript:

Trees: New Developments1 Trees: New Developments Folders and Tasks ROOT Workshop 2001 June 13 FNAL Ren é Brun CERN

ROOT2001 Rene BrunTrees: New Developments2 Trees before 3.01 TTree TBranch TBranchObject TBranchClones TChain Many limitations in split mode Only simple classes in TClonesArray Original classes required for TBranchObject

ROOT2001 Rene BrunTrees: New Developments3 Trees in version 3.01 TTree TBranch TBranchObject TBranchClones TBranchElement TChain TFriendElement This new class replaces TBranchObject & TBranchClones Many more cases supported Tree Friends A fundamental addition

ROOT2001 Rene BrunTrees: New Developments4 Self-describing files Dictionary for persistent classes written to the file. ROOT files can be read by foreign readers (JAS) Support for Backward and Forward compatibility Files created in 2001 must be readable in 2015 Classes (data objects) for all objects in a file can be regenerated via TFile::MakeProject Root >TFile f(“demo.root”); Root > f.MakeProject(“dir”,”*”,”new++”);

ROOT2001 Rene BrunTrees: New Developments5 Create a TTree Object A tree is a list of branches. The TTree Constructor: Tree Name (e.g. "myTree") Tree Title TTree *tree = new TTree("T","A ROOT tree"); TTree T2(“T2”,”/Event/Tracks”);

ROOT2001 Rene BrunTrees: New Developments6 Adding a Branch Branch name Class name Address of the pointer to the Object (descendant of TObject) Buffer size (default = 32,000) Split level (default = 1) Event *event = new Event(); myTree->Branch(”eBranch","Event",&event,64000,1);

ROOT2001 Rene BrunTrees: New Developments7 Splitting a Branch Setting the split level (default = 1) Split level = 0Split level = 1 Example : int splitlevel = 2; tree->Branch("EvBr","Event",&ev,64000,splitlevel);

ROOT2001 Rene BrunTrees: New Developments8 Adding Branches with a List of Variables Branch name Address: the address of the first item of a structure. Leaflist: all variable names and types Order the variables according to their size Example TBranch *b = tree->Branch ("Ev_Branch",&event, "ntrack/I:nseg:nvtex:flag/i:temp/F");

ROOT2001 Rene BrunTrees: New Developments9 Adding Branches with a TClonesArray Branch name Address of a pointer to a TClonesArray Buffer size Split level (default = 1) Example: tree->Branch( ”tracks",&Track,64000,1); tree->Branch( ”tracks",”TClonesArray”,&Track,64000,1);

ROOT2001 Rene BrunTrees: New Developments10 Chains of Trees A TChain is a collection of Trees. Same semantics for TChains and TTrees root >.x h1chain.C root > chain.Process(“h1analysis.C”) root > chain.Process(“h1analysis.C+”) void h1chain() { //creates a TChain to be used by the h1analysis.C class //the symbol H1 must point to a directory where the H1 data sets //have been installed TChain chain("h42"); chain.Add("$H1/dstarmb.root"); chain.Add("$H1/dstarp1a.root"); chain.Add("$H1/dstarp1b.root"); chain.Add("$H1/dstarp2.root"); } h1chain.C

ROOT2001 Rene BrunTrees: New Developments11 Tree Friends Root > TFile f1(“tree1.root”); Root > tree.AddFriend(“tree2”,“tree2.root”) Root > tree.AddFriend(“tree3”,“tree3.root”); Root > tree.Draw(“x:a”,”k<c”); Root > tree.Draw(“x:tree2.x”,”sqrt(p)<b”); x Processing time independent of the number of friends unlike table joins in RDBMS

ROOT2001 Rene BrunTrees: New Developments12 Trees and Folders A complete Tree can be generated automatically from an existing Folder structure One Branch can be generated from a Folder A Folder structure can be automatically rebuilt from a Tree file

ROOT2001 Rene BrunTrees: New Developments13 The Tree Viewer & Analyzer A very powerful class supporting complex cuts, event lists, 1-d,2-d, 3-d views parallelism

ROOT2001 Rene BrunTrees: New Developments14 New TTreeFormula The class TTreeFormula has been extended to process the new TBranchElement class. Thanks Philippe Canal. Can access data members in an object hierarchy in split and/or non-split modes support multiple levels of calls to member functions in split or/and no-split modes. Support complex classes in TClonesArray Examples

ROOT2001 Rene BrunTrees: New Developments15 New TTreeFormula Event *event = 0; TTree T(“T”); T.Branch(“event”,”Event”,&event,32000,2);

ROOT2001 Rene BrunTrees: New Developments16 New TTreeFormula

ROOT2001 Rene BrunTrees: New Developments17 New TTreeFormula

ROOT2001 Rene BrunTrees: New Developments18 New TTreeFormula

ROOT2001 Rene BrunTrees: New Developments19 read/query Trees without the classes

ROOT2001 Rene BrunTrees: New Developments20 read/query Trees without the classes

ROOT2001 Rene BrunTrees: New Developments21 Automatic Code Generators Data sets can be analyzed by the same classes used to store the data. However, one must be able to read the data without these original classes. The classes may not be available after some time. Root provides two utilities to generate a class skeleton to read the data, still preserving the attribute names, types and the structure. TTree::MakeClass TTree::MakeSelector This point is important. You can always analyze a data set even if you have lost the class(es) that generated this data set

ROOT2001 Rene BrunTrees: New Developments22 TTree::MakeClass tree.MakeClass(“myClass”); generates two files: myClass.h and myClass.C myClass.h contains the class declaration and member functions code that is selection invariant. myClass.C contains an example of empty loop where one can insert the analysis code Usage: root >.L myClass.C or.L myClass.C++ root > myClass xx; root > xx.Loop(); Use the interpreter Use the native compiler The file myClass.C is automatically compiled and linked !!

ROOT2001 Rene BrunTrees: New Developments23 TTree::MakeSelector tree.MakeSelector(“myClass”); generates two files: myClass.h and myClass.C that can work in a parallel system like PROOF. The event loop is not under user control. myClass.h contains the class declaration and member functions code that is selection invariant. myClass.C contains the skeleton of 4 functions: Begin, ProcessCut, ProcessFill, Terminate. Usage: root > tree.Process(“myClass.C”); root > chain.Process(“myClass.C++”); Macro is automatically compiled and linked

ROOT2001 Rene BrunTrees: New Developments24 Folders: in a nutshell The class TFolder has been in ROOT since quite some time. A Folder structure can be used as a white board facility to minimize dependencies between classes via the Folder naming scheme User classes/collections in Folders facilitate the documentation and inspection. Trees can be generated automatically from Folders.

ROOT2001 Rene BrunTrees: New Developments25 Some analogy with the past At the beginning of computing, communication via Subroutine arguments: No global state Labelled Common Blocks ZEBRA/BOS solved at least 2 problems Dynamic structures Communication between modules only via the ZEBRA store. Eg, banks from a simulation program could be read in a reconstruction program Experience with a large variety of C++ applications indicates a “common-block like” approach.

ROOT2001 Rene BrunTrees: New Developments26 Why Folders ? This diagram shows a system without folders. The objects have pointers to each other to access each other's data. Pointers are an efficient way to share data between classes. However, a direct pointer creates a direct coupling between classes. This design can become a very tangled web of dependencies in a system with a large number of classes.

ROOT2001 Rene BrunTrees: New Developments27 Why Folders ? In the diagram below, a reference to the data is in the folder and the consumers refer to the folder rather than each other to access the data. The naming and search service provided by the ROOT folders hierarchy provides an alternative. It loosely couples the classes and greatly enhances I/O operations. In this way, folders separate the data from the algorithms and greatly improve the modularity of an application by minimizing the class dependencies.

ROOT2001 Rene BrunTrees: New Developments28 Posting Data to a Folder (Producer) No changes required in user class structure. Build a folder structure with: TFolder::AddFolder(TFolder *) Post objects or collections to a Folder with: TFolder::Add(TObject*) A TFolder can contain other folders or any TObject descendents. In general, users will not post a single object to a folder, they will store a collection or multiple collections in a folder. For example, to add an array to a folder: TObjArray *array; run_mc->Add(array);

ROOT2001 Rene BrunTrees: New Developments29 Reading Data from a Folder (Consumer) One can search for a folder or an object in a folder using the TROOT::FindObjectAny method. FindObjectAny analyzes the string passed as its argument and searches in the hierarchy until it finds an object or folder matching the name. With FindObjectAny, you can give the full path name, or the name of the folder. If only the name of the folder is given, it will return the first instance of that name. conf = (TFolder*)gROOT- >FindObjectAny("/aliroot/Run/Configuration"); or conf = (TFolder*)gROOT->FindObjectAny("Configuration"); A string-based search is time consuming. If the retrieved object is used frequently or inside a loop, you should save a pointer to the object as a class data member. Use the naming service only in the initialization of the consumer class.

ROOT2001 Rene BrunTrees: New Developments30 Example: Alice folders A ROOT Tree can be automatically generated from the folder, eg: TTree T(“T”,”/Event”); T.Fill(); T.Show(); This statement generates a Tree with 325 branches

ROOT2001 Rene BrunTrees: New Developments31 Tasks In the same way that Folders can be used to organize the data, one can use the class TTask to organize a hierarchy of algorithms. Tasks can be organized into a hierarchical tree of tasks and displayed in the browser. The TTask class is the base class from which the subtasks are derived. To give a task functionality, you need to subclass the TTask class and override the Exec method. Each TTask derived class may contain other TTasks that can be executed recursively, such that a complex program can be dynamically built and executed by invoking the services of the top level task or one of its subtasks. TTask *run = new MyRun("run","Process one run"); TTask *event = new MyEvent("event","Process one event"); Use the TTask::Add method to add a subtask to an existing TTask. To execute a TTask, you call the ExecuteTask method. ExecuteTask will recursively call: -TTask::Exec method of the derived class -TTask::ExecuteTasks to execute for each task the list of its subtasks.

ROOT2001 Rene BrunTrees: New Developments32 Execute and Debug Tasks If the top level task is added to the list of ROOT browse-able objects, the tree of tasks can be visualized by the ROOT browser. To add it to the browser, get the list of browse-able objects first and add it to the collection. gROOT->GetListOfBrowsables()->Add(aliroot,"aliroot"); The browser can be used to start a task, set break points at the beginning of a task or when the task has completed. At a breakpoint, data structures generated by the execution up this point may be inspected asynchronously and then the execution can be resumed by selecting the "Continue" function of a task. A Task may be active or inactive (controlled by TTask::SetActive). When a task is inactive, its sub tasks are not executed. A Task tree may be made persistent, saving the status of all the tasks.

ROOT2001 Rene BrunTrees: New Developments33 Tasks

ROOT2001 Rene BrunTrees: New Developments34 Folders/Tasks Summary Folders minimize coupling between classes Folders are browsable. Good for documentation and code reviews. Trees generated from folders Tasks are browsable. Good for documentation and code reviews. Tasks help in understanding a program hierarchy Tasks encourage common behaviors