Geant4 Geometry Objects Persistency using ROOT

Slides:



Advertisements
Similar presentations
. Virtual Classes & Polymorphism. Example (revisited) u We want to implement a graphics system u We plan to have lists of shape. Each shape should be.
Advertisements

Simulation Project Major achievements (past 6 months 2007)
Plab 2003 Lecture 41 C++ - Classes. Plab 2003 Lecture 42 Motivating Example Goal: Graphics package Handle drawing of different shapes Maintain list of.
Witek Pokorski, Radovan Chytracek, Jeremy McCormick, Giovanni Santin
SEAL V1 Status 12 February 2003 P. Mato / CERN Shared Environment for Applications at LHC.
Chapter 9 Defining New Types. Objectives Explore the use of member functions when creating a struct. Introduce some of the concepts behind object-oriented.
CINT & Reflex: New Reflection Data Structures Masa(haru) Goto Agilent Philippe Canal Fermilab/CD Stefan Roiser, Axel Naumann PH/SFT.
Defining New Types Lecture 21 Hartmut Kaiser
W. Pokorski - EP/SFT Simulation Project1 GDML - recent developments Witek Pokorski
W. Pokorski - CERN Simulation Project1 Python binding for Geant4 toolkit using Reflex/PyROOT tool Witek Pokorski EuroPython 2006, CERN, Geneva
CHEP /21/03 Detector Description Framework in LHCb Sébastien Ponce CERN.
LC Software Workshop, May 2009, CERN P. Mato /CERN.
Lesson 6 – Libraries & APIs Libraries & APIs. Objective: We will explore how to take advantage of the huge number of pre-made classes provided with Java.
CHEP /21/03 Detector Description Framework in LHCb Sébastien Ponce CERN.
K. Harrison CERN, 3rd March 2004 GANGA CONTRIBUTIONS TO ADA RELEASE IN MAY - Outline of Ganga project - Python support for AJDL - LCG analysis service.
CINT & Reflex – The Future CINT’s Future Layout Reflex API Work In Progress: Use Reflex to store dictionary data Smaller memory footprint First step to.
GDML “Geometry Description Markup Language” by Daniele Francesco Kruse University of Rome “Tor Vergata” European Organization for Nuclear Research.
1 G4UIRoot Isidro González ALICE ROOT /10/2002.
- GDML - ROOT I/O for Geant4 - General Suggestions SFT Program of Work Meeting Witek Pokorski 03/03/2010.
GEANT4 Geometry Status & Plans
Modularization of Geant4 Dynamic loading of modules Configurable build using CMake Pere Mato Witek Pokorski
CERN, 7 November 2011 Anton Pytel Slovak Technical University TRIP FROM GENERATORS TO GEOMETRIES.
LHCb Software Week 25/11/99 Gonzalo Gracia Abril 1 r Status of Geant4 in LHCb. r Ideas on how to populate the LHCb Detector Description Data Base (LHCb.
ROOT / Reflex ‘07+ Stefan Roiser Missed last team meeting b/c.
Ben Lloyd 1 New Developments in GDML and in Generator Services Ben Lloyd University of the West of England, Bristol, UK
Product Training Program
Pointer to an Object Can define a pointer to an object:
Procedural and Object-Oriented Programming
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Pointers and Linked Lists
Memory Management with Classes
Pointers and Linked Lists
Copy Constructor / Destructors Stacks and Queues
CS 215 Final Review Ismail abumuhfouz Fall 2014.
UNIT – I Linked Lists.
Complex Geometry Visualization TOol
European Organization for Nuclear Research
CS Data Structures Chapter 8 Lists Mehmet H Gunes
A C++ generic model for the GLAST Geometric Description
Review: Two Programming Paradigms
classes and objects review
Introduction to Classes
STACKS AND QUEUES UNIT 2 DS THROUGH C++.
Lists in Lisp and Scheme
HEP detector description supporting the full experiment life cycle
This pointer, Dynamic memory allocation, Constructors and Destructor
The Bag and Sequence Classes with Linked Lists
CISC/CMPE320 - Prof. McLeod
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Hash table another data structure for implementing a map or a set
Circular Buffers, Linked Lists
Introduction to Classes
OOP Paradigms There are four main aspects of Object-Orientated Programming Inheritance Polymorphism Abstraction Encapsulation We’ve seen Encapsulation.
Defining New Types Lecture 22 Hartmut Kaiser
Various News From Detector Description
Dr. Bhargavi Dept of CS CHRIST
Classes and Objects.
CMSC 202 Trees.
Chapter 11 - Templates Outline Introduction Function Templates Overloading Function Templates Class Templates Class.
Geant4 Workshop 02 October 2002, CERN Hajime Yoshida
Simulation Framework Subproject cern
Structured Types (9-12-2) Structured types allow composite attributes of E-R diagrams to be represented directly. Unnamed row types can also be used in.
Chapter 11 - Templates Outline Introduction Function Templates Overloading Function Templates Class Templates Class.
Use of GEANT4 in CMS The OSCAR Project
ENERGY 211 / CME 211 Lecture 8 October 8, 2008.
Chapter 11 - Templates Outline Introduction Function Templates Overloading Function Templates Class Templates Class.
四時讀書樂 (春) ~ 翁森 山光照檻水繞廊,舞雩歸詠春風香。 好鳥枝頭亦朋友,落花水面皆文章。 蹉跎莫遣韶光老,人生唯有讀書好。
Lecture 20: Representing Data Elements
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

Geant4 Geometry Objects Persistency using ROOT Witek Pokorski 13.07.2005 W. Pokorski - EP/SFT Simulation Project

Outline Underlying idea Overall approach Technical issues Practical case Conclusion W. Pokorski - EP/SFT Simulation Project

Underlying idea essential part of any Geant4 simulation application: geometry description probably constitutes the main part of 'data' which needs to be loaded in case of complex geometries can take essential part of the initialization time Geant4 does not come with any persistency mechanism for the geometry objects the Geant4 geometry tree has to be 'rebuilt' each time Geant4 geometries are often created by converting from experiment-specific models which makes then 'non-exportable' our goal: provide way of quick saving and reading back the G4 geometry in/from a (binary) file would nicely extend the functionality of the toolkit W. Pokorski - EP/SFT Simulation Project

Some remark... this is a different use-case from GDML, where universality of the format was top-priority GDML allows interchanging geometries between different models (Geant4, ROOT, etc) it's 'flavor-free', no application-specific binding GDML can also be used for implementing geometry ROOT persistency for Geant4 allows saving Geant4 geometry (G4 objects) and reading it back into a Geant4 application one could still use it to interchange geometries between different Geant4 applications save LHCb geometry in Gauss and then load it into any other G4 application to run tests of visualize it would make Geant4 applications less 'geometry-bound', extend the spectrum of their usage W. Pokorski - EP/SFT Simulation Project

Overall approach use lcgdict tool to create Reflex dictionary for the Geant4 classes fully non-intrusive can by fully automated (all done in Makefile) requires only selection.xml file with list of classes Cintex tool allows to convert Reflex dictionary information into CINT data structure Cintex will not be needed once CINT is able to interact directly with Reflex dictionaries use ROOT I/O to save the geometry tree into .root file create a simple wrapper class containing pointer to top volume call WriteObject method for that object ROOT I/O saves all the geometry tree by following the pointers W. Pokorski - EP/SFT Simulation Project

Technical Issues (1/3) ROOT I/O requires all the (persistent) classes to have default constructors they are used to allocate memory when reading back the objects they need to initialize all the pointers (non-null pointers are considered by ROOT I/O as valid ones and are not overwritten) most of the Geant4 geometry classes do not have default constructors... default constructors can be added to Geant4, but should never be called from the users' code constructors in Geant4 perform different kinds of registration which are not possible in the default case W. Pokorski - EP/SFT Simulation Project

Technical Issues (2/3) variable length arrays of objects are not (yet) supported by ROOT I/O Geant4 uses quite often arrays of non-fundamental types only solution for the moment: move to std::vector variable length arrays of fundamental types are supported but header files need to be instrumented double* x; //[N] could be moved to the selection files (lcgdict) in the future needs to be added in the class definition W. Pokorski - EP/SFT Simulation Project

Technical Issues (3/3) a few specific issues struct with members being pointers should have default constructor initializing the pointers typedef struct {...} MyStruct; should be replaced by struct MyStruct {...}; lcgdict fails to produce a sensible name for the destructor for anonymous struct MyClass** should be replaced by std::vector<MyClass*> ** is ambiguous from the point of view of persistency; it can be a pointer to an array or an array of pointers W. Pokorski - EP/SFT Simulation Project

Practical case - writing we have our Geant4 geometry (say LHCb) in memory and we want to save it in .root file we call a simple 'GeoWriter' tool which: creates a 'wrapper' object containing *TopVolume and pointers to materials and elements static tables calls WriteObject ROOT I/O method trivial implementation no any 'scanning' of the geometry tree needed ROOT traverses all the geometry tree and stores it only needed thing is to export the pointer to the top volume G4 application initialization Geometry construction *TopVolume *MaterialsTable *ElementsTable etc... WriteObject ROOT I/O W. Pokorski - EP/SFT Simulation Project

Practical case - reading only binding to ROOT in DetectorConstruction class the Geant4 'main' does not see the loading of the geometry using ROOT I/O 'standard' DetectorConstruction replaced by ROOTDetConstr. G4VUserDetectorConstruction::Construct() returns pointer to the top volume ROOTDetectorConstruction as a simple 'plug-in' one just needs to instantiate it from the 'main' G4 application initialization GetObject(...) ROOT I/O Construct() Geometry construction G4VPhysicalVolume* etc... W. Pokorski - EP/SFT Simulation Project

Remark on Python interfacing once the dictionary for Geant4 classes is there, Python binding comes for free PyLCGDict/PyReflex/PyROOT allows to interact with any Geant4 as well as ROOT class from Python Python ideal to glue different 'worlds' (Geant4, ROOT, GDML, etc) together see http://lcgapp.cern.ch/project/simu/framework/PYGEANT4/pyg4.html for simple examples saving/loading G4 geometry using ROOT I/O even trivial from Python prompt modularization of 'reader/writer' more natural less explicit binding W. Pokorski - EP/SFT Simulation Project

Final remarks simplest case discussed here - only geometry (and materials) stored in ROOT file next steps (if needed) could include saving optimization information (voxels?), material cuts tables, etc necessary changes in G4 implemented (on my local disk....) and tested for LHCb entire LHCb geometry & materials file ~220kB writing and reading back time - less than 2 seconds http://lcgapp.cern.ch/project/simu/framework/G4ROOT/g4root.html (working document) W. Pokorski - EP/SFT Simulation Project

Conclusions dictionary for Geant4 classes is an essential element both from the point of view of persistency as well as interactivity proposal: generate (and store on AFS) Reflex dictionary for every new Geant4 release geometry objects persistency using ROOT comes (almost) for free would be a very nice additional functionality for the toolkit proposal: release LCG-internal version of Geant4 with all the necessary changes (and the dictionary) to allow users to give it a try once the dictionary is there, Python interfacing comes (fully) for free with PyLCGDict/PyReflex/PyROOT another argument in favor of releasing the dictionary Python environment perfect for Plug&Play W. Pokorski - EP/SFT Simulation Project