You are on page 1of 10

ROOT

Data bases access

LCG Data base deployment workshop


11 October

René Brun
CERN

ROOT Data bases access 1


File types & Access in 4.04/xx
user
Local
File
TFile
X.xml TKey/TTree
TStreamerInfo TSQLServer
TSQLRow
TSQLResult
http rootd/xrootd
Oracle
MySQL
Local Dcache Castor
PgSQL
File
X.root RFIO Chirp SapDb

Rene Brun ROOT Data bases access 2


File types & Access in 5.04/xx
user
Local
File
TFile TTreeSQL
X.xml TKey/TTree
TStreamerInfo TSQLServer
TSQLRow
TSQLResult
http rootd/xrootd
Oracle
MySQL
Local Dcache Castor
PgSQL
File
X.root RFIO Chirp SapDb

Rene Brun ROOT Data bases access 3


New RDBMS interface: Goals
 Access any RDBMS tables from TTree::Draw

 Create a TTree in split mode


  creating a RDBMS table and filling it.
 The table can be processed by SQL directly.
 The interface uses the normal I/O engine
 including support for Automatic Schema Evolution.

Rene Brun ROOT Data bases access 4


TTree with SQL database back-
end
 Uploaded in CVS repository of first version of TTreeSQL
 support the TTree containing branches created using a leaf list (eg. hsimple.C).

ntuple->Branch("main",&mytest,"px/D:py/F:pz:random:i/I:c/B");
ntuple->Branch("string",(void*)str,"str/C");

 Add an interface to read the proper TTree object depending on the


backend
 Something like TTree::Open using the Plugin Manager
 Extend TTreeSQL to support TBranchElement
 Implement proper schema evolution support
 The main design problem is how to save/retrieve the TProcessID/TStreamerInfo.
 One possibility is to use the same mechanism currently in use in TXMLFile

Rene Brun ROOT Data bases access 5


TTreeSQL Syntax
 Currently:
 ROOT:
TFile *file = new TFile("simple.root","RECREATE");
TTree *tree; file->GetObject(“ntuple”,tree);

 MySQL:
TSQLServer*dbserver = TSQLServer::Connect("mysql://…”,db,user,passwd);
TTree *tree = new TTreeSQL(dbserver,"rootDev","ntuple");

 Coming:
TTree *tree = TTree::Open(“root:/simple.root/ntuple”);


TTree *tree = TTree::Open(“mysql://host../rootDev/ntuple”);

Rene Brun ROOT Data bases access 6


TTreeSQL Optimization
 On a simple test with a local MySQL database:
 Reading is 5x slower than with ROOT I/O
 Writing is functional but requires significant optimization of the
code.
 Current implementation of the SQL
communication (text oriented) could be greatly
improved.
 Could use some expertise in MySQL and odbc (to reinvigorate
RDBC)

Rene Brun ROOT Data bases access 7


Support for TBranchElement
 Will add the creation of auxiliary tables
 table of TStreamerInfos
 Will add support for ‘blob’ data field to support
unsplit object.
op
 Will need support for ‘collection’ w ork
sh

T
 either by using additional ‘linked’ tables RO
O
e
 either by using ‘blob’ data field th
re
fo
be
lan
P

Rene Brun ROOT Data bases access 8


CBM Analysis
Geometry Root files
Virtual MC MCPoints, Hits,
Manager
ROOT Digits, Tracks

IO Manager Oracle
GeoInterface Run Manager

RunTime Configuration,
Module DataBase Parameters,
Magnetic Primary Geometry
Field Generator

Detector
Tasks EVGEN Root files
Configuration,
Parameters,
Geometry
Delta digitizers Tracking

Rene Brun ROOT Data bases access 9


Reading Parameters: Oracle
 gSystem->Load ( "libOra" );
 CbmRunAna * fRun = new CbmRunAna();
 CbmRuntimeDb* rtdb=fRun->GetRuntimeDb();
 CbmParOraIo* ora=new CbmParOraIo();
 ora->open();
 rtdb->setFirstInput(ora);
 CbmGenericParOraIo* genio=
 (CbmGenericParOraIo*)(ora-
>getDetParIo("CbmGenericParIo"));
 CbmParTest* par=(CbmParTest*)(rtdb->getContainer("CbmParTest"));

 genio->readFromLoadingTable(par,RunId);
 par->print();
 par->printParams();

Rene Brun ROOT Data bases access 10

You might also like