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.

Slides:



Advertisements
Similar presentations
SYMBOL TABLES &CODE GENERATION FOR EXECUTABLES. SYMBOL TABLES Compilers that produce an executable (or the representation of an executable in object module.
Advertisements

CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
Chapter 10 C Structures, Unions, Bit Manipulations and Enumerations Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc.
C Language.
C Structures and Memory Allocation There is no class in C, but we may still want non- homogenous structures –So, we use the struct construct struct for.
Chapter 7 Process Environment Chien-Chung Shen CIS, UD
ECE 353: Lab C Pointers and Structs. Basics A pointer holds an address to some variable Notation: – Dereferencing operator: * int *x is a declaration.
6/10/2015C++ for Java Programmers1 Pointers and References Timothy Budd.
LEARNING OBJECTIVES Index files.
Memory Management (II)
Introduction to Kernel
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Session 1 CS-240 Data Structures Binghamton University Dick Steflik.
Unix Process Environment. main Function A C program starts execution with a function called main. The prototype for the main function is: int main (int.
CS100A, Fall 1997, Lectures 221 CS100A, Fall 1997 Lecture 22, Tuesday 18 November Introduction To C Goal: Acquire a reading knowledge of basic C. Concepts:
OOP Spring 2006 – Recitation 31 Object Oriented Programming Spring 2006 Recitation 3.
ROOT courses1 The ROOT System A Data Access & Analysis Framework February 2003 Ren é Brun/EP Trees.
Data Structures in the Kernel Sarah Diesburg COP 5641.
XML I/O in ROOT S. Linev, R. Brun, H.G. Essel CHEP 2004.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
Status of SQL and XML I/O Sergey Linev, GSI, Darmstadt, Germany.
University of Calgary – CPSC 441. C PROGRAM  Collection of functions  One function “main()” is called by the operating system as the starting function.
Recap, Test 1 prep, Composition and Inheritance. Dates Test 1 – 12 th of March Assignment 1 – 20 th of March.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Copyright  Hannu Laine C++-programming Part 3 Hannu Laine.
CSC 2400 Computer Systems I Lecture 5 Pointers and Arrays.
Chep 2006, Mumbai, IndiaPhilippe Canal (FNAL)1 Recent Developments in the ROOT I/O and TTrees CANAL, Philippe (FERMILAB) BRUN, Rene (CERN) FRANK, Markus.
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
FLEX Fast Lexical Analyzer EECS Introduction Flex is a lexical analysis (scanner) generator. Flex is provided with a user input file or Standard.
CS4432: Database Systems II Record Representation 1.
UNIX Files File organization and a few primitives.
ROOT I/O for SQL databases Sergey Linev, GSI, Germany.
Higher Order Tries Key = Social Security Number.   9 decimal digits. 10-way trie (order 10 trie) Height
Pointers. What is pointer l Everything stored in a computer program has a memory address. This is especially true of variables. char c=‘y’; int i=2; According.
Using of XML for object store S. Linev, GSI Using of XML for object store. S.Linev2 Content XML and existing packages XML and existing packages.
ROOT Tutorials - Session 51 ROOT Tutorials – Session 5 Dictionary Generation, rootcint, Simple I/O, Hands-on Fons Rademakers.
5-1 Embedded Systems C Programming Language Review and Dissection III Lecture 5.
ROOT Progress Report1 ROOT Workshop 2001 FNAL June 13 Ren é Brun CERN
STAR Schema Evolution Implementation in ROOT I/O V. Perevoztchikov Brookhaven National Laboratory,USA.
CS415 C++ Programming Takamitsu Kawai x4212 G11 CERC building WV Virtual Environments Lab West Virginia University.
ROOT courses1 The ROOT System A Data Access & Analysis Framework February 2003 Ren é Brun/EP Input/Output.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 4 is due Nov. 20 (next Friday). After today you should know everything you need for assignment.
C LANGUAGE Characteristics of C · Small size
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
9/28/2005Philippe Canal, ROOT Workshop TTree / SQL Philippe Canal (FNAL) 2005 Root Workshop.
March, PROOF - Parallel ROOT Facility Maarten Ballintijn Bring the KB to the PB not the PB to the KB.
Alberto Colla - CERN ALICE off-line week 1 Alberto Colla ALICE off-line week Cern, May 31, 2005 Table of contents: ● Summary of requirements ● Description.
ROOT Team Meeting Axel Naumann CERN PH/SFT Crienftlex Extended Version. And also Director’s Cut. Crienftlex.
ROOT Workshop M.Frank LHCb/CERN Improvements in the I/O Area (*)  General I/O related improvements  Tree related issues  Plans (*) I present.
Trees: New Developments1 Trees: New Developments Folders and Tasks ROOT Workshop 2001 June 13 FNAL Ren é Brun CERN
C is a high level language (HLL)
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
Process Related System Calls By Neha Hulkoti & Kavya Bhat.
CMSC 202 Lesson 26 Miscellaneous Topics. Warmup Decide which of the following are legal statements: int a = 7; const int b = 6; int * const p1 = & a;
Chapter 7 Process Environment Chien-Chung Shen CIS/UD
POOL Based CMS Framework Bill Tanenbaum US-CMS/Fermilab 04/June/2003.
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.
Introduction to Kernel
Higher Order Tries Key = Social Security Number.
CS212: Object Oriented Analysis and Design
Memberwise Assignment / Initialization
null, true, and false are also reserved.
Interfaces.
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
Recent Developments in ROOT I/O Support for foreign classes
Persistent Object References in ROOT I/O Status & Proposal
Zooming on ROOT files and Containers
SPL – PS1 Introduction to C++.
Presentation transcript:

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

CMS 27 Nov Rene BrunPersistent Object References in ROOT2 Plan of talk Persistent C++ pointers Using TRef & TRefArray Action on Demand Combining TRef & Action on Demand Proposal for changes & extensions

CMS 27 Nov Rene BrunPersistent Object References in ROOT3 Normal Streaming mode References using C++ pointers A TBuffer b; A.Streamer(b) Only one copy of each object in the graph saved to buffer

CMS 27 Nov Rene BrunPersistent Object References in ROOT4 Normal Streaming mode References using C++ pointers TBuffer b1; A.Streamer(b1) TBuffer b2; B.Streamer(b2) B A Objects in red are in b1 and b2 C++ pointer

CMS 27 Nov Rene BrunPersistent Object References in ROOT5 Normal Streaming mode References using TRef pointers TBuffer b1; A.Streamer(b1) TBuffer b2; B.Streamer(b2) B Objects in blue are only in b1 C++ pointer TRef A Bz z Set pointer to z with: TRef Bz = z; Get pointer to z with: z = Bz.GetObject()

CMS 27 Nov Rene BrunPersistent Object References in ROOT6 Setting a TRef pointer Assuming obj = pointer to a TObject* TRef ref = obj; TRef is itself a TObject Its fUniqueID is set to obj - gSystem The obj kIsReferenced bit is set (fBits of obj) Get pointer obj with obj = ref.GetObject() returns fUniqueID + gSystem Class TRef : public TObject { TProcessID *fPID; //!pointer to process id Class TObject { unsigned int fBits; unsigned int fUniqueID;

CMS 27 Nov Rene BrunPersistent Object References in ROOT7 Writing TRefs to a buffer A TRef is written by TRef::Streamer Writes uid(8 bytes) + pid(4 bytes) 12 bytes in non compressed mode 2.4 bytes in compressed mode 1 (default) uid = object unique identifier default uid = pointer - gSystem (see proposal) pid = Process identifier Each process has a unique pid (TProcessID) A file contains the pids of all processes that have written objects to it.

CMS 27 Nov Rene BrunPersistent Object References in ROOT8 Writing Referenced objects A referenced object is written by obj->Streamer This Streamer at some point calls its TObject::Streamer In TObject::Streamer, if the kIsReferenced bit is set in fBits, the following additional info is also written: uid (8 bytes) = obj - gSystem pid (4 bytes) = TProcessID of current process A Referenced object may be written multiple times in the same file as the TRef or in other files

CMS 27 Nov Rene BrunPersistent Object References in ROOT9 Reading Referenced objects A referenced object is read by obj->Streamer This Streamer at some point calls its TObject::Streamer In TObject::Streamer, if the kIsReferenced bit is set in fBits, the following additional info is also read: uid (8 bytes) = obj - gSystem pid (4 bytes) = TProcessID of current process the fUniqueID is set to uid The pair (uid,obj) is added to the TExMap of the TProcessID corresponding to pid When obj is deleted, its pair (uid,obj) is also removed from the TProcessID TExMap.

CMS 27 Nov Rene BrunPersistent Object References in ROOT10 Reading TRefs from a buffer A TRef object is read by TRef::Streamer The pair uid,pid is read the fUniqueID of TRef is set to uid The transient pointer fPID is set to the TProcessID corresponding to pid via a direct access table in the gROOT object The bit 1 of fBits is set

CMS 27 Nov Rene BrunPersistent Object References in ROOT11 Using a TRef To get a pointer to the referenced object, do: Myclass *obj = (Myclass*)ref.GetObject() GetObject fBits[1] =0Returns obj = fUniqueID + gSystem =1 NO Set fBits[1]=0 return obj YESexecid = fBits[8/8] execid = 0 YES return null NO Execute TExec with execid Obj = 0 YES fPID = 0 or fPID>GetObjectWithUniqueID() = 0

CMS 27 Nov Rene BrunPersistent Object References in ROOT12 TRef example: Event.h class Event : public TObject { private: char fType[20]; //event type char *fEventName; //run+event number in character format int fNtrack; //Number of tracks int fNseg; //Number of track segments int fNvertex; int fMeasures[10]; float fMatrix[4][4]; float *fClosestDistance; //[fNvertex] EventHeader fEvtHdr; TClonesArray *fTracks; //->array with all tracks TRefArray *fHighPt; //array of High Pt tracks only TRefArray *fMuons; //array of Muon tracks only TRef fLastTrack; //reference pointer to last track TRef fWebHistogram; //EXEC:GetWebHistogram TH1F *fH; //-> public:... TH1F *GetHistogram() const {return fH;} TH1F *GetWebHistogram(Bool_t reload=kFALSE) const { return (TH1F*)fWebHistogram.GetObject(reload);}

CMS 27 Nov Rene BrunPersistent Object References in ROOT13 TRef & Action on Demand When the keyword “EXEC:” is found in the comments of the data member as in: TRef fWebHistogram; //EXEC:GetWebHistogram The information in the comment field is kept in the dictionary. Execid is saved in TStreamerElement When the TRef object is read, the execid is stored in the fBits on one byte (from TStreamerElement). When TRef::GetObject is called, TObjArray *lexecs = gROOT->GetListOfExecs(); TExec *exec = (TExec*)lexecs[execid]; exec->Exec(); fWebHistogram.GetObject() executes the action GetWebHistogram Action on Demand is Persistent

CMS 27 Nov Rene BrunPersistent Object References in ROOT14 What a TExec can do TExec is a CORE ROOT class that can be used to execute: a call to a compiled or interpreted function example: Exec:LoadHits() an interpreted script example: Exec:GetWebHistogram If GetWebHistogram is not a function (compiled or interpreted), then TExec::Exec will try to execute the script GetWebHistogram.C void GetWebHistogram(){ // example of script called from an Action on Demand when a TRef object // is dereferenced. See Event.h, member fWebHistogram const char *URL = " printf("GetWebHistogram from URL: %s\n",URL); TFile *f= TFile::Open(URL); f->cd("DM/CJ"); TH1 *h6 = (TH1*)gDirectory->Get("h6"); h6->SetDirectory(0); delete f; gROOT->SetSelectedPrimitive(h6); }

CMS 27 Nov Rene BrunPersistent Object References in ROOT15 A Working Example { gSystem.Load("libEvent"); TFile f("Event.root"); Event *event=0; T.SetBranchAddress("event",&event); T.GetEntry(45); event->GetWebHistogram()->Draw(); } void GetWebHistogram(){ // example of script called from an Action on Demand when a TRef object // is dereferenced. See Event.h, member fWebHistogram const char *URL = " printf("GetWebHistogram from URL: %s\n",URL); TFile *f= TFile::Open(URL); f->cd("DM/CJ"); TH1 *h6 = (TH1*)gDirectory->Get("h6"); h6->SetDirectory(0); delete f; gROOT->SetSelectedPrimitive(h6); } Action.C GetWebHistogram.C Root >.x Action.C

CMS 27 Nov Rene BrunPersistent Object References in ROOT16 Status with Persistent pointers C++ persistent pointers In all versions of ROOT since day1 TRef, TRefArray implemented in dev version 3.02/00 TRef with Action on Demand implemented in 3.02/05 (this week) TRef simplification & extensions see proposal

CMS 27 Nov Rene BrunPersistent Object References in ROOT17 Simplification Instead of storing obj-gSystem as unique id for a given process id, I propose to store the object number within a process. This is a trivial change to the current scheme in dev. Many advantages: simpler to manage no TExMap, but a simple TObjArray with direct access for each TProcessID One could imagine a very simple object catalog in the RDBMS Disadvantages; Require a table of pointers in the process writing the objects This problem could be solved by an Wipe_Event function

CMS 27 Nov Rene BrunPersistent Object References in ROOT18 Setting a TRef pointer Assuming obj = pointer to a TObject* TRef ref = obj; TRef is itself a TObject If the obj::kIsReferenced bit is not yet set, the obj::fUniqueID is set to the CurrentNumber+1 and obj::kIsReferenced is set to 1. Its fUniqueID is set to obj::fUniqueID CurrentNumber is managed by TProcessID fObjs[CurrentNumber] is set to obj in fPID Class TRef : public TObject { TProcessID *fPID; //!pointer to process id Class TObject { unsigned int fBits; unsigned int fUniqueID;

CMS 27 Nov Rene BrunPersistent Object References in ROOT19 Writing TRefs to a buffer A TRef is written by TRef::Streamer Writes uid(4 instead of 8 bytes) + pid(4 bytes) uid = object unique identifier uid = ref::fUniqueID = obj::fUniqueID = current object nr pid = Process identifier Each process has a unique pid (TProcessID) A file contains the pids of all processes that have written objects to it.

CMS 27 Nov Rene BrunPersistent Object References in ROOT20 Writing Referenced objects A referenced object is written by obj->Streamer This Streamer at some point calls its TObject::Streamer In TObject::Streamer, if the kIsReferenced bit is set in fBits, the following additional info is also written: uid (8 bytes) = obj - gSystem already in obj::fUniqueID pid (4 bytes) = TProcessID of current process A Referenced object may be written multiple times in the same file as the TRef or in other files

CMS 27 Nov Rene BrunPersistent Object References in ROOT21 Reading Referenced objects A referenced object is read by obj->Streamer This Streamer at some point calls its TObject::Streamer In TObject::Streamer, if the kIsReferenced bit is set in fBits, the following additional info is also read: uid (8 bytes) = obj - gSystem pid (4 bytes) = TProcessID of current process In TProcessID::fObjs fObjs[fUniqueID] = obj When obj is deleted, fObjs[fUniqueID] = 0;

CMS 27 Nov Rene BrunPersistent Object References in ROOT22 Reading TRefs from a buffer A TRef object is read by TRef::Streamer The pair uid,pid is read the fUniqueID of TRef is set to uid The transient pointer fPID is set to the TProcessID corresponding to pid via a direct access table in the gROOT object The bit 1 of fBits is set