Persistency Author Youhei Morita Category Requirements p Geant

  • Slides: 21
Download presentation
Persistency Author: Youhei Morita

Persistency Author: Youhei Morita

Category Requirements p Geant 4 Persistency makes run, event, hits, digits and geometry information

Category Requirements p Geant 4 Persistency makes run, event, hits, digits and geometry information be persistent, to be read back later by user programs p Geant 4 shall make use of industrial standard ODMG C++ binding and Hep. ODBMS as persistency interface p Kernel part of Geant 4 should not be affected by the choice of persistency mechanism (Geant 4 should be able to run with or without persistency mechanism)

What is “object persistency” ? p Persistent object lives beyond an application process, may

What is “object persistency” ? p Persistent object lives beyond an application process, may be accessed by other processes. p When an object is “deactivated”, state of the object are stored into the database system. Once “activated”, the state information of the object is read back from the database.

What is ODMG ? p Object Database Management Group a non-profit consortium of vendors

What is ODMG ? p Object Database Management Group a non-profit consortium of vendors and interested parties who collaborate to develop and promote standards for object database management systems (ODBMS). http: //www. odmg. org/ p ODBMS Standard Documents ODMG 2. 0 released in 1997 F Object Model F Object Definition Language F Object Query Language F Language Bindings to C++, Small. Talk, Java

C++ Binding of ODMG p Design persistent class using ODL (Object Definition Language) class

C++ Binding of ODMG p Design persistent class using ODL (Object Definition Language) class G 4 PEvent : public Hep. Pers. Obj { public: persistent-capable base class G 4 PEvent(); : private: G 4 Pint event. ID; persistent-capable type : } p Compile ODL files (schema) to schema metadata, C++ header files, wrapper C++ source code. ex. Objectivity/DB: ooddlx preprocessor processes *. ddl files into *. hh, *_ref. hh, *_ddl. cc files, and stores schema metadata into a federated database file.

What is Hep. ODBMS ? p C++ class library that provides a simplified and

What is Hep. ODBMS ? p C++ class library that provides a simplified and consistent interface to underlying ODMG-compliant Object Database Management System p Current implementation is based on Objectivity/DB p Goals: l l an insulation layer to minimize dependencies on a given database vendor or release. high level base classes that encapsulate features such as clustering and locking strategies, database session transaction control, event collections, selection predicates, tag. DB access and calibration whilst not introducing any significant performance or storage overhead. p See Also: http: //wwwinfo. cern. ch/asd/lhc++/Hep. ODBMS/user-guide/H 1 Introduction. html

Persistency in Geant 4 p “Parallel World” approach Data members of transient and persistent

Persistency in Geant 4 p “Parallel World” approach Data members of transient and persistent objects are copied by Store( ) and Retrieve( ) Store( ) Retrieve( ) G 4 kernel objects have corresponding “P” objects in G 4 Persistency G 4 Run G 4 PRun G 4 Event G 4 PEvent G 4 Hit G 4 PHit : : Inherits from Hep. Pers. Obj in Hep. ODBMS

Persistency in Geant 4 (2) p Top Level Class Diagram G 4 Run. Manager

Persistency in Geant 4 (2) p Top Level Class Diagram G 4 Run. Manager G 4 UImessenger G 4 VPersistency. Manager G 4 Persistency. Messenger G 4 Persistency. Manager G 4 Transaction. Manager Transient G 4 objects are “stored” by G 4 Run. Manager through abstract interface of G 4 VPersistency. Manager. Database file names are given via G 4 Perrsistency. Messenger. Interface to Hep. ODBMS transactions are “wrapped” at G 4 Transaction. Manager. Data member copy of transient and persistent objects are handled by G 4 Persistent. Event. Man, G 4 Persistent. Hit. Man, etc. G 4 Persistent. Sub. Man G 4 Persistent. Sub. Db. Man Hep. Db. Application G 4 Persistent. Event. Man

How to design your own persistent objects in ODBMS p Design persistent-capable classes p

How to design your own persistent objects in ODBMS p Design persistent-capable classes p Design the object clustering p Design the access patterns p Design the transaction scenario

How to design your own persistent objects in ODBMS: Design persistent-capable classes p Create

How to design your own persistent objects in ODBMS: Design persistent-capable classes p Create ODL (DDL) files (similar to C++ header files) p Inherit “persistency” from Hep. Pers. Obj p Use ODMG persistent basic types such as d_Double, d_Float l In Geant 4, basic types are cast into G 4 Pint, G 4 Pdoulbe etc in G 4 Persistent. Types. hh p Use Hep. Ref() macro as smart pointers of persistent objects in run time Hep. Ref(G 4 PEvent) an. Evt; an. Evt = new G 4 PEvent(…. ); p Use d_Ref<> template for embedded persistent association in ODL class G 4 PEvent : public Hep. Pers. Obj { … d_Ref<G 4 PPrimary. Vertex> the. Primary. Vertex; … } p Use d_Varray<> template for variable length array

How to design your own persistent objects in ODBMS: Design persistent-capable classes - G

How to design your own persistent objects in ODBMS: Design persistent-capable classes - G 4 PEvent. ddl Inherit persistency from class G 4 PEvent persistent base class : public Hep. Pers. Obj Smart pointers to other { persistent public: objects in run time G 4 PEvent(); G 4 PEvent(const G 4 Event *evt, Hep. Ref(G 4 PHCof. This. Event) p. HC, Hep. Ref(G 4 PDCof. This. Event) p. DC); ~G 4 PEvent(); private: Persistent G 4 Pint event. ID; base types d_Ref<G 4 PPrimary. Vertex> the. Primary. Vertex; G 4 Pint number. Of. Primary. Vertex; Embedded association d_Ref<G 4 PHCof. This. Event> HC; to other d_Ref<G 4 PDCof. This. Event> DC; persistent objects public: void Set. Event. ID(const G 4 Event *evt); inline G 4 int Get. Event. ID() const { return event. ID; } inline void Add. Primary. Vertex(Hep. Ref(G 4 PPrimary. Vertex) a. Primary. Vertex) {…} inline G 4 int Get. Number. Of. Primary. Vertex() const { return number. Of. Primary. Vertex; } …<skipped>. . . };

How to design your own persistent objects in ODBMS: Design the object clustering p

How to design your own persistent objects in ODBMS: Design the object clustering p Organize a group of classes which will be accessed simultaneously l l Use “new” operator with clustering directive: e. g. . Hep. Clustering. Hint Use “new” operator with neighboring object a. Vertex will be stored near n e. g. . In the constructor of G 4 PEvent: : G 4 PEvent(. . . ) …. a. Vertex = new (oo. This()) G 4 PPrimary. Vertex(…); …. this G 4 PEvent object example. FD G 4 PEvent G 4 PPrimary. Vertex G 4 PPrimary. Particle Boot file FDDB System Runs Events Geometry

How to design your own persistent objects in ODBMS: Design the access patterns p

How to design your own persistent objects in ODBMS: Design the access patterns p Decide the primary object(s) to be picked up from the database p Make a loop of iteration for the primary object oo. Itr(G 4 PEvent) pevent_iterator; pevent_iterator. scan(container); while (pevent_iterator. next()) { // loop for all G 4 PEvent’s in this container… int evt_id = pevent_iterator->Get. Event. ID(); . . . } Iterator for G 4 PEvent Using the Iterator Using the (1 st) G 4 PEvent p Follow the association for the related objects for ( int i = 0; i < n_pvertex; i++ ) // Loop for all primary vertex in this event { Hep. Ref(G 4 PPrimary. Vertex) pvertex = pevent_iterator->Get. Primary. Vertex(i); cout << " No. of particle in the primary vertex: " << pvertex->Get. Number. Of. Particle() << G 4 endl; Returns a smart pointer of } the G 4 PPrimary. Vertex

How to design your own persistent objects in ODBMS: Design the transaction scenario p

How to design your own persistent objects in ODBMS: Design the transaction scenario p Access to any persistent objects should be a part of “transaction” l l l Hep. Db. Application: : Init() Hep. Db. Application: : start. Read() Hep. Db. Application: : start. Update() Hep. Db. Application: : commit() Hep. Db. Application: : abort() p Hep. ODBMS with Objectivity/DB has a choice of selecting “database” and “container” l l Hep. Db. Application: : db(db. Name) Hep. Db. Application: : container(container. Name)

How to design your own persistent objects in ODBMS: Design the transaction scenario -

How to design your own persistent objects in ODBMS: Design the transaction scenario - read. DB. cpp Hep. Db. Application* db. App = new Hep. Db. Application(name); …. . . db. App->Init(); db. App->start. Read(); Hep. Database. Ref my. Db = db. App->db("Events"); Hep. Container. Ref cont = db. App->container("Event. Container"); // initialise the db session // start a read transaction // select “Events” database // select “Event. Container” container oo. Itr(G 4 PEvent) pevent_iterator; // initialize iterator for G 4 PEvent pevent_iterator. scan(cont); while (pevent_iterator. next()) // Loop for all G 4 PEvent { int evt_id = pevent_iterator->Get. Event. ID(); // access this G 4 PEvent int n_pvertex = pevent_iterator->Get. Number. Of. Primary. Vertex(); …. . . } // End of loop over events db. App->commit(); // finish this read transaction

Persistent Objects in “Events” Database

Persistent Objects in “Events” Database

Example Database Configuration $OO_FD_BOOT example. FD example. Schema Boot file FDDB System Runs Events

Example Database Configuration $OO_FD_BOOT example. FD example. Schema Boot file FDDB System Runs Events Geometry read. DB System “gmake newfd” Lock Server oodump Persistent Ex 01/02 FDDB hits 2 digits oocheckls oolockserver ookillls

How to build G 4 Persistent Libraries p Define variables l l $G 4

How to build G 4 Persistent Libraries p Define variables l l $G 4 USE_HEPODBMS = 1 $G 4 EXAMPLE_FDID p Define Hep. ODBMS variables l l $HEP_ODBMS_DIR $HEP_ODBMS_INCLUDES p Include Hep. ODBMS and Objectivity library path into $LD_LIBRARY_PATH p Setup Objectivity variables (e. g. . on CERN AFS) l l source /afs/cern. ch/rd 45/objectivity/objyenv. csh. /afs/cern. ch/rd 45/objectivity/objyenv. sh (csh) (bsh) p Check and start “Lock Server” p Type “gmake” in $G 4 INSTALL/source p See $G 4 INSTALL/examples/extended/persistency/Persistent. Ex 01/README for more detail (see also the release note for version information)

Geant 4 examples illustrating persistency features Extended examples l Persistent. Ex 01: Make persistent

Geant 4 examples illustrating persistency features Extended examples l Persistent. Ex 01: Make persistent Run/Event/Geometry objects n n n l read. DB: standalone Hep. ODBMS example to read objects create. Tag: standalone example to create Hep. ODBMS tag read. Tag: standalone example to read Hep. ODBMS tag Persistent. Ex 02: Make user defined persistent Hits objects n n n read. DB: standalone Hep. ODBMS example to read objects create. Tag: standalone example to create Hep. ODBMS tag read. Tag: standalone example to read Hep. ODBMS tag

If you want to learn more. . . p User's Guide: For Application Developers

If you want to learn more. . . p User's Guide: For Application Developers http: //wwwinfo. cern. ch/asd/geant 4/G 4 Users. Documents/Users. Guides/ For. Application. Developer/html/index. html p Hep. ODBMS User Guide http: //wwwinfo. cern. ch/asd/lhc++/Hep. ODBMS/user-guide/ho. html p Objectivity/DB Support at CERN http: //wwwinfo. cern. ch/asd/lhc++/Objectivity/index. html p CERN/IT Data. Base Group http: //wwwinfo. cern. ch/db/ p The Object Database Standard: ODMG 2. 0 Edited by R. G. G. Cattell, D. K. Barry, Morgan Kaufmann Publishers, Inc. ISBN 1 -55860 -463 -4

Whom to contact about Geant 4 Persistency Category Coordinator Youhei Morita (KEK) - Youhei.

Whom to contact about Geant 4 Persistency Category Coordinator Youhei Morita (KEK) - Youhei. Morita@kek. jp Hep. ODBMS and Objectivity/DB issues CERN/IT Data. Base Group - Objectivity. Support@cern. ch