Recent Developments in ROOT I/O Support for foreign classes

Slides:



Advertisements
Similar presentations
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Advertisements

File and I/O system calls int open(const char* path, int flags, mode_t modes) int creat(const char *path, mode_t mode) ssize_t read(int fd, void *buf,
ROOT Root Commands and CINT Functions and Fitting (The Tree Viewer)
Operator Overloading Fundamentals
Lecture 3 Feb 4 summary of last week’s topics and review questions (handout) Today’s goals: Chapter 1 overview (sections 1.4 to 1.6) c++ classes constructors,
Blueprint RTAGs1 Coherent Software Framework a Proposal LCG meeting CERN- 11 June Ren é Brun ftp://root.cern.ch/root/blueprint.ppt.
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
More Classes in C++ Bryce Boe 2012/08/20 CS32, Summer 2012 B.
ROOT courses1 The ROOT System A Data Access & Analysis Framework February 2003 Ren é Brun/EP Trees.
CSE 332: C++ templates and generic programming I Motivation for Generic Programming in C++ We’ve looked at procedural programming –Reuse of code by packaging.
Large Data Bases in High Energy Physics Frontiers in Diagnostic Technologies Frascati November 26 Frascati November 26 Rene Brun/CERN.
ROOT An object oriented HEP analysis framework.. Computing in Physics Physics = experimental science =>Experiments (e.g. at CERN) Planning phase Physics.
Learners Support Publications Pointers, Virtual Functions and Polymorphism.
Status of SQL and XML I/O Sergey Linev, GSI, Darmstadt, Germany.
C++ Code Analysis: an Open Architecture for the Verification of Coding Rules Paolo Tonella ITC-irst, Centro per la Ricerca Scientifica e Tecnologica
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
ROOT I/O recent improvements Bottlenecks and Solutions Rene Brun December
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Chep 2006, Mumbai, IndiaPhilippe Canal (FNAL)1 Recent Developments in the ROOT I/O and TTrees CANAL, Philippe (FERMILAB) BRUN, Rene (CERN) FRANK, Markus.
Copyright © Curt Hill Generic Classes Template Classes or Container Classes.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
1 Writing a Good Program 8. Elementary Data Structure.
10/31/2015PHYS 3446 DØ Data Analysis with ROOT Venkat (for Dr.Yu)
Field Support Ideas. Tech-talk, 19 July 2007 Good Afternoon, I have now for the th time explained to some desperate EPICS newbie all the hoops one has.
ROOT Future1 Some views on the ROOT future ROOT Workshop 2001 June 13 FNAL Ren é Brun CERN.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
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.
ROOT Tutorials - Session 51 ROOT Tutorials – Session 5 Dictionary Generation, rootcint, Simple I/O, Hands-on Fons Rademakers.
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.
ENEE150 – 0102 ANDREW GOFFIN Project 4 & Function Pointers.
C++ Lecture 5 Monday, 18 July Chapter 7 Classes, continued l const objects and const member functions l Composition: objects as members of classes.
ROOT Data bases access1 LCG Data base deployment workshop 11 October Ren é Brun CERN.
ROOT courses1 The ROOT System A Data Access & Analysis Framework February 2003 Ren é Brun/EP Input/Output.
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.
ROOT Team Meeting Axel Naumann CERN PH/SFT Crienftlex Extended Version. And also Director’s Cut. Crienftlex.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
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
G.Govi CERN/IT-DB 1GridPP7 June30 - July 2, 2003 Data Storage with the POOL persistency framework Motivation Strategy Storage model Storage operation Summary.
1 Classes struct Public and Private Parts of a struct Class Scope of a Class Overloading Member Functions Class in a Class Static Members of Classes this.
Go4 Workshop J.Adamczewski-Musch, S.Linev Go4 advanced features.
Linked Lists A formal data structure. Linked Lists Collections of data items “lined up in a row” Inserts and deletes can be done anywhere in the list.
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.
1 Chapter 12 Classes and Abstraction. 2 Chapter 12 Topics Meaning of an Abstract Data Type Declaring and Using a class Data Type Using Separate Specification.
Prof. Bhushan Trivedi Director GLS Institute of Computer Technology
Motivation for Generic Programming in C++
Chapter 12 Classes and Abstraction
Definition and Application of Binary Trees
GO! with Microsoft Office 2016
Templates.
GO! with Microsoft Access 2016
Object-Oriented Programming
A Doubly Linked List There’s the need to access a list in reverse order prev next data dnode header 1.
Dynamically Allocated Memory
CS 240 – Lecture 18 Command-line Arguments, Typedef, Union, Bit Fields, Pointers to Functions.
Automated support of STL containers
Chapter 17: Linked Lists.
Persistent Object References in ROOT I/O Status & Proposal
Zooming on ROOT files and Containers
This presentation document has been prepared by Vault Intelligence Limited (“Vault") and is intended for off line demonstration, presentation and educational.
Data Structures & Algorithms
CS410 – Software Engineering Lecture #5: C++ Basics III
Building Blocks of C Programming Language
ENERGY 211 / CME 211 Lecture 8 October 8, 2008.
ROOT Support and Developments at FNAL
14 – Sequential Containers
Presentation transcript:

Recent Developments in ROOT I/O Support for foreign classes LCG meeting CERN- 6 June René Brun ftp://root.cern.ch/root/foreign.ppt Support for foreign classes

Support for foreign classes Evolution of ROOT I/O 1995 Hand-written Streamers Streamers generated via rootcint Support for Class Versions Support for ByteCount Several attempts to introduce automatic class evolution Persistent class Dictionary (StreamerInfo) written to files rootcint modified to generate automatic Streamers can generate code for “DataObjects” classes in a file Support for STL and more complex C++ cases Trees take advantage of the new scheme Can read files without the classes Persistent Reference pointers Support for foreign classes 3.00 3.01 3.02 New 3.03 2002 LCG 6 June Rene Brun Support for foreign classes

Support for foreign classes PSimHit.h #include "LocalTag.h" #include "Point2DBase.h" #include "Point3DBase.h" typedef Point2DBase< float, LocalTag> Local2DPoint; typedef Point3DBase< float, LocalTag> Local3DPoint; // Local points are two-dimensional by default typedef Local3DPoint LocalPoint; #include "LocalPoint.h" #include "LocalVector.h" #include "TObject.h" class DetUnit; class PSimHit : public TObject { public: PSimHit() : theDetUnitId(-1) {} PSimHit( const Local3DPoint& entry, const Local3DPoint& exit, float pabs, float tof, float eloss, int particleType, int detId, unsigned int trackId) : theEntryPoint( entry), theExitPoint(exit), ..... float pabs() const {return thePabs;} float tof() const {return theTof;} float energyLoss() const {return theEnergyLoss;} int particleType() const {return theParticleType;} int detUnitId() const {return theDetUnitId;} unsigned int trackId() const {return theTrackId;} private: // properties Local3DPoint theEntryPoint; // position Local3DPoint theExitPoint; float thePabs; // momentum float theTof; // Time Of Flight float theEnergyLoss; // Energy loss int theParticleType; // association int theDetUnitId; unsigned int theTrackId; ClassDef(PSimHit,1) }; LCG 6 June Rene Brun Support for foreign classes

Support for foreign classes Point3DBase.h #include "PV3DBase.h" #include "Point2DBase.h" #include "Vector3DBase.h" #include ”Rtypes.h" template <class T, class FrameTag> class Point3DBase : public PV3DBase< T, PointTag, FrameTag> { public: typedef PV3DBase< T, PointTag, FrameTag> BaseClass; typedef Vector3DBase< T, FrameTag> VectorType; typedef Basic3DVector<T> BasicVectorType; Point3DBase() {} Point3DBase(const T& x, const T& y, const T& z) : BaseClass(x, y, z) {} ……. ClassDefT(Point3DBase,1) }; ClassDef2T2(Point3DBase,T,FrameTag) LCG 6 June Rene Brun Support for foreign classes

Support for foreign classes Basic3DVector.h #include "Basic2DVector.h" #include <iosfwd> #include <cmath> #include ”Rtypes.h" template < class T> class Basic3DVector { public: // default constructor Basic3DVector() : theX(0), theY(0), theZ(0){} Basic3DVector( const T& x, const T& y, const T& z) : theX(x), theY(y), theZ(z) {} T x() const { return theX;} T y() const { return theY;} T z() const { return theZ;} …... private: T theX; T theY; T theZ; ClassDefT(Basic3DVector,1) }; ClassDefT2(Basic3DVector,T) LCG 6 June Rene Brun Support for foreign classes

Running rootcint on PSimHit.h Building the shared lib rootcint -f Dict.cxx -c PSimHit.h LinkDef.h g++ -fPIC -I$ROOTSYS/include -c Dict.cxx g++ -fPIC -I$ROOTSYS/include -c PSimHit.cxx g++ -shared -g PSimHit.o Dict.o -o libHit.so #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class LocalTag+; #pragma link C++ class PointTag+; #pragma link C++ class VectorTag+; #pragma link C++ class Basic2DVector<float>+; #pragma link C++ class Basic3DVector<float>+; #pragma link C++ class PV2DBase<float, VectorTag, LocalTag>+; #pragma link C++ class PV2DBase<float, PointTag, LocalTag>+; #pragma link C++ class PV3DBase<float, VectorTag, LocalTag>+; #pragma link C++ class PV3DBase<float, PointTag, LocalTag>+; #pragma link C++ class Vector2DBase<float, LocalTag>+; #pragma link C++ class Vector3DBase<float, LocalTag>+; #pragma link C++ class Point2DBase<float, LocalTag>+; #pragma link C++ class Point3DBase<float, LocalTag>+; #pragma link C++ class PSimHit+; Classes used by PSimHit use C++ templates heavily All Template instances must be declared LinkDef.h LCG 6 June Rene Brun Support for foreign classes

Writing CMS PSimHit objects void demo1() { //create a new ROOT file TFile f("demo1.root","recreate"); //Create a PSimHit with the default constructor PSimHit h1; //Write it to the file with the key name hit1 h1.Write("hit1"); //Create a normal PSimHit with the entry and exit point Local3DPoint pentry(1,2,3); Local3DPoint pexit(10,20,30); float pabs = 41; float tof = 1.67e-8; float eloss = 5.78e-3; int pType = 12; int detId = 67; int trackId = 1234; PSimHit h2(pentry,pexit,pabs,tof,eloss,pType,detId,trackId); //Write it to the file with the key name hit2 h2.Write("hit2"); } LCG 6 June Rene Brun Support for foreign classes

Reading CMS PSimHit objects void demo2() { //connect the ROOT file demo1.root in readonly mode TFile *f = new TFile("demo1.root"); //Read hit2 PSimHit *hit = (PSimHit*)f->Get("hit2"); //print some hit members cout <<" X1= "<<hit->entryPoint().x() <<" Y2= "<<hit->exitPoint().y() <<" pabs= "<<hit.pabs()<<endl; delete hit; //Open the ROOT browser and inspect the file new TBrowser; //click on "ROOT files", then "demo1.root", with the //right button, select menu items "Inspect", "DrawClass" //on hit2 } LCG 6 June Rene Brun Support for foreign classes

Support for foreign classes Browsing the file root [0] TFile f("demo1.root") root [1] TBrowser b root [2] f.ls(); root [3] f.Map(); root [4] hit2.Dump(); TFile* demo1.root KEY: PSimHit hit1;1 KEY: PSimHit hit2;1 20011008/091050 At:64 N=86 TFile 20011008/091050 At:150 N=128 KeysList Address = 278 Nbytes = -27 =====G A P=========== 20011008/091050 At:305 N=140 PSimHit 20011008/091050 At:445 N=140 PSimHit 20011008/091050 At:585 N=952 StreamerInfo CX = 2.66 20011008/091050 At:1537 N=64 FreeSegments 20011008/091050 At:1601 N=1 END theEntryPoint ->874a01c position theEntryPoint.theVector ->874a01c theEntryPoint.theVector.theX 1 theEntryPoint.theVector.theY 2 theEntryPoint.theVector.theZ 3 theExitPoint ->874a030 theExitPoint.theVector ->874a030 theExitPoint.theVector.theX 10 theExitPoint.theVector.theY 20 theExitPoint.theVector.theZ 30 thePabs 41 momentum theTof 1.67e-08 Time Of Flight theEnergyLoss 0.00578 Energy loss theParticleType 12 theDetUnitId 67 theTrackId 1234 fUniqueID 0 object unique identifier fBits 50331648 bit field status word The description of all classes in a file is written in one single record when the file is closed StreamerInfo LCG 6 June Rene Brun Support for foreign classes

ClassDef/ClassImp changes We have redesigned the ClassDef/ClassImp facility to drastically reduce the number of macros necessary. We are down to 3 macros for all the situations. The only macro required in now ClassDef. In particular, ClassDefT and all its variation are now obsolete. ClassImp (and templateClassImp for class template) are not compulsory anymore and are now used only to record the location of the implementation file. One future extension will be to allow the registering of more than one implementation file. This upgrade is intended to be backward compatible ... __unless__ you have implemented your own ClassImp type of macro. Note that it requires a complete regeneration of ALL the dictionaries. LCG 6 June Rene Brun Support for foreign classes

Support for foreign classes Point3DBase.h #include "PV3DBase.h" #include "Point2DBase.h" #include "Vector3DBase.h" #include ”Rtypes.h" template <class T, class FrameTag> class Point3DBase : public PV3DBase< T, PointTag, FrameTag> { public: typedef PV3DBase< T, PointTag, FrameTag> BaseClass; typedef Vector3DBase< T, FrameTag> VectorType; typedef Basic3DVector<T> BasicVectorType; Point3DBase() {} Point3DBase(const T& x, const T& y, const T& z) : BaseClass(x, y, z) {} ……. ClassDef(Point3DBase,1) }; LCG 6 June Rene Brun Support for foreign classes

Support for foreign classes Basic3DVector.h #include "Basic2DVector.h" #include <iosfwd> #include <cmath> #include ”Rtypes.h" template < class T> class Basic3DVector { public: // default constructor Basic3DVector() : theX(0), theY(0), theZ(0){} Basic3DVector( const T& x, const T& y, const T& z) : theX(x), theY(y), theZ(z) {} T x() const { return theX;} T y() const { return theY;} T z() const { return theZ;} …... private: T theX; T theY; T theZ; ClassDef(Basic3DVector,1) }; LCG 6 June Rene Brun Support for foreign classes

Support for foreign classes Foreign classes (not instrumented with ROOT includes, ClassDef, etc) can be parsed by a new version of rootcint to produce the necessary code for computing the members offsets. The TStreamerInfo class has also some mods to digest foreign classes. Current implementation using a shadow class Vincenzo (define public private) was also implemented but could not be used with VC++ Victor currently testing a new idea that could simplify the whole process if it works everywhere LCG 6 June Rene Brun Support for foreign classes

Support for foreign classes Point3DBase.h #include "PV3DBase.h" #include "Point2DBase.h" #include "Vector3DBase.h" template <class T, class FrameTag> class Point3DBase : public PV3DBase< T, PointTag, FrameTag> { public: typedef PV3DBase< T, PointTag, FrameTag> BaseClass; typedef Vector3DBase< T, FrameTag> VectorType; typedef Basic3DVector<T> BasicVectorType; Point3DBase() {} Point3DBase(const T& x, const T& y, const T& z) : BaseClass(x, y, z) {} ……. }; LCG 6 June Rene Brun Support for foreign classes

Support for foreign classes Browsing the file root [0] TFile f("demo1.root") root [1] TBrowser b root [2] f.ls(); root [3] f.Map(); root [4] hit2.Dump(); TFile* demo1.root KEY: PSimHit hit1;1 KEY: PSimHit hit2;1 20011008/091050 At:64 N=86 TFile 20011008/091050 At:150 N=128 KeysList Address = 278 Nbytes = -27 =====G A P=========== 20011008/091050 At:305 N=140 PSimHit 20011008/091050 At:445 N=140 PSimHit 20011008/091050 At:585 N=952 StreamerInfo CX = 2.66 20011008/091050 At:1537 N=64 FreeSegments 20011008/091050 At:1601 N=1 END theEntryPoint ->874a01c position theEntryPoint.theVector ->874a01c theEntryPoint.theVector.theX 1 theEntryPoint.theVector.theY 2 theEntryPoint.theVector.theZ 3 theExitPoint ->874a030 theExitPoint.theVector ->874a030 theExitPoint.theVector.theX 10 theExitPoint.theVector.theY 20 theExitPoint.theVector.theZ 30 thePabs 41 momentum theTof 1.67e-08 Time Of Flight theEnergyLoss 0.00578 Energy loss theParticleType 12 theDetUnitId 67 theTrackId 1234 fUniqueID 0 object unique identifier fBits 50331648 bit field status word LCG 6 June Rene Brun Support for foreign classes

STL support for foreign classes Several recent improvements by Victor in rootcint. In particular Victor has added support for all STL containers in foreign classes. Currently the code to support STL is generated in rootcint. We hope to provide native support in TStreamerInfo for vector<myClass> like we do for TClonesArray. LCG 6 June Rene Brun Support for foreign classes