Title: Geometry Description Markup Language Geometry Data Exchange Format
1GeometryDescriptionMarkupLanguageGeometry
Data Exchange Format
- This presentation will probably involve audience
discussion, which will create action items. Use
PowerPoint to keep track of these action items
during your presentation - In Slide Show, click on the right mouse button
- Select Meeting Minder
- Select the Action Items tab
- Type in action items as they come up
- Click OK to dismiss this box
- This will automatically create an Action Item
slide at the end of your presentation with your
points entered.
- Radovan Chytracek
- CERN IT/API Geant4
2Why another markup language?
- XML is recently spreading quickly in HEP
- Detector description is one of the mainstream
areas - The driving forces behind are to
- remove the data and parameters from source code
- re-use the data among geometry hungry
applications - enable visualization outside batch applications
(debugging) - enable easy modification and view of the data
- However collaborations speak different XML
- XML based geometry data exchange is
science-fiction - Software packages do exist, but
- cant process all the dialects
- each collaboration has its own software
- redundant functionality, wasting of manpower
- Data binding is usually complex to implement
- tight binding to a specific object model
3GDML Is
- A markup language for geometry description
- and geometry data exchange
- Human understandable
- one can easily imagine a geometry being described
- Modular and extensible
- thanks to XML Schema
- clients can choose what to process from it
- user extensions foreseen
- Simple data binding
- designed with the aim to support more than one
framework or application - bi-directional
4Its not
- A procedural or scripting language
- describes geometry data
- Dependent on a concrete data model
- but tries to be complete enough to capture all
the information needed by GDML clients - Exposing a data behavior
- no hidden logic or encoded information which
might introduce ambiguity in GDML interpretation
and creates side effects or forces hacks in the
GDML clients - Have its clones or dialects
- GDML should ideally be extendible and modular so
GDML clients can choose the subset they need and
a level of conformance
5GDML 1.0 Components Clients
Geant4 GDML Reader/ Writer
Gaudi XML/GDML Conversion Service
Open Scientist
ROOT
JAS WIRED
Utilities visualization attributes 2D drawing
primitives
Structure volumes placements replicas
Boolean Solids union subtraction intersection
Materials isotopes elements mixtures
BREP Solids Polyhedron B-spline...
CSG Solids box sphere cone ...
Core identifiers references transformations expres
sions units
6GDML 1.0 Example
lt?xml version"1.0" encoding"UTF-8"?gtltgdml
xmlnsgdmlhttp//cern.ch/2001/Schemas/GDML
xmlnsxsihttp//www.w3.org/2001/XMLSchema-instanc
e xsinoNamespaceSchemaLocation"gdml_1.0.xs
d"gtltdefinegt ltconstant name"PI" value"3.14"/gt
ltexpression name"TWOPI"gt2PIlt/expressiongt
ltposition name"center" x"0.0" y"0.0" z"0.0"/gt
ltposition name"shiftbyx" x"20"/gt ltrotation
name"identity" x"0.0" y"0.0" z"0.0"/gt
ltrotation name"rotatebyx"/gtlt/definegt ltmaterialsgt
ltisotope Z"1.0" N"1" state"unknown"
name"i1"gt ltD type"density" unit"g/cm3"
value"1.0"/gt ltatom type"A" value"1.0"
unit"g/mol"/gt lt/isotopegt ltelement name"el1"
Z"0.0" N"2" state"unknown"gt ltD value"0.0"
unit"g/cm3" type"density"/gt ltatom type"A"
unit"g/mol" value"2."/gt lt/elementgt ltelement
name"el2" Z"0.0" N"3" state"unknown"gt ltD
type"density" value"0.0" unit"g/cm3"/gt
ltfraction ref"i1" n"0.3"/gt ltfraction ref"i2"
n"0.7"/gt lt/elementgt ltmaterial name"m1"gt ltD
type"density" unit"g/cm3" value"0.0"/gt
ltatom type"A" unit"g/mol" value"0.0"/gt
lt/materialgt ltmaterial name"m3"gt ltD
value"1.0"/gt ltcomposite n"3" ref"el1"/gt
ltcomposite ref"el2" n"2"/gt lt/materialgt
ltmaterial name"m2"gt ltD value"2.3"/gt
ltfraction n"0.2" ref"el1"/gt ltfraction n"0.2"
ref"el2"/gt ltfraction n"0.2" ref"el3"/gt
ltfraction n"0.4" ref"m1"/gt lt/materialgtlt/mater
ialsgtltsolidsgt ltbox lunit"mm" aunit"radian"
name"b1" x"0.0" y"0.0" z"0.0"/gt ltcone
lunit"mm" aunit"radian" name"c1" z"0.0"
rmin1"0.0" rmin2"0.0 rmax1"0.0"
rmax2"0.0" startphi"0.0" deltaphi"0.0"/gt
ltunion lunit"mm" aunit"radian" name"u1"gt
ltfirst ref"b1"/gt ltsecond refc1"/gt
ltpositionref ref"shiftbyx"/gt ltrotationref
ref"identity"/gt lt/uniongtlt/solidsgtltstructuregt
ltvolume name"v1"gt ltmaterialref ref"el1"/gt
ltsolidref ref"b1"/gt lt/volumegtlt/structuregtltsetup
name"unit1" version"1.0"gt ltworld ref"v1"/gt
lt/setupgtlt/gdmlgt
7GDML 1.0 Status Features
- GDML Schema 1.0 beta fixes
- Numerical expressions
- units, constants, quantities, positions,
rotations - references (local)
- Materials
- isotopes, elements, composite materials
mixtures - Complete set of CSG Boolean solids
- CSG Constructive Solid Geometry
- box, cone, sphere, tube,
- union, subtraction, intersection
- Structural definition
- volume, placement(single)
- Versioned geometry setups
8GDML Processing
- GDML does not come only as a specification
- It was designed hand in hand with its processing
model - Along with the schema the processing architecture
for GDML has been defined - Goals
- easy application binding
- low maintenance costs during GDML evolution
- high degree of reusability
9Processing Architecture
- Defines the processing components and the way
they cooperate - XML engine (SAX/DOM)
- XML Schema/DTD Handlers (object producers)
- Application subscribers (object consumers)
- XML engine
- is the dispatcher or distributor
- only this component sees the real XML elements
- Handlers
- perform low-level XML processing
- produce XML data in ready-to-use object form
- usually one handler per XML element
10Processing Architecture (2)
- Subscribers
- the only place where application binding is done
- make the bridge between XML and application
- consume GDML data in form of objects
- produce the application data objects
- APPLICATION DEVELOPERS NEED TO WRITE ONLY THE
CODE FOR SUBSCRIBERS
11Processing Steps
pre-4
Expressions Evaluator
Application binding (Subscribers)
XML Schema/DTD Handlers
4
Application
3
2
XML Engine
1
GDML
12Subscriber Example
include "SAXSubscriber.hh include
"SAXComponentFactory.hh include
"GDMLProcessor.hh include "GDMLExpressionEvaluat
or.hh include "GDMLConstant.hh include
ltiostreamgt class GDMLConstantSubscriber
virtual public SAXSubscriber public virtual
const SAXComponentObject Build() const return
this GDMLConstantSubscriber() Subscribe(
"constant" ) virtual GDMLConstantSubscriber(
) virtual void Activate( const SAXObject
object ) if( object ! 0 ) try
const GDMLConstant obj dynamic_castltconst
GDMLConstantgt(object)
GDMLProcessorGetInstance()-gtGetEvaluator()-gtRegi
sterConstant( obj ) catch(...)
stdcerr ltlt "GOT INTO BAD_CAST TROUBLE OR
SOMETHING!" ltlt stdendl
DECLARE_SUBSCRIBER_FACTORY(GDMLConstantSubsc
riber)
13Processor Status
- Proof-of-concept prototype of GDML/DTD Processor
- standard CERN RedHat Linux 6.1, EGCS 1.1.2
- XML parser Apache Xerces-C 1.4 stable
- performs SAX based parsing in DTD validating mode
- G4GDMLReader proof-of-concept prototype
- uses latest CLHEP expressions evaluator
- GDML Schema 1.0 based processor being implemented
- Apache XML parser Xerces-C 1.7.0 latest snapshot
- GDML Schema 1.0 based G4GDMLReader in progress
- GDML Core Materials ready
- GDML Schema 1.0 based G4GDMLWriter will follow
soon - foreseen hand-written GDML streamers
- proof-of-concept of complete bi-directional GDML
data binding - THE OLD XML ENGINE COMPLETELY RE-USED!
- Roughly 2400 l.o.c. out of almost 7000
- minor changes required due to the XML Schema (5
lines)
14Next Steps
- GDML Specification Guide
- First extensions
- volume replicas, advanced placements, BREP solids
- Generative GDML Schema processor
- generating C code for GDML Schema components
and handlers - actually the major part of the processors code
- possible use for GDML streamers (not yet clear)
- work in progress
- Input/Output GDML driver for Gbuilder
- interactive geometry design using GDML format
- STEP/XML lt-gt GDML?
15Conclusions
- Using XML Schema was not easy to start with
- however captures quite well data structure in an
OO way - pays back when writing XML to C serialization
code - The application binding is really light
- contributes only by the 10 of the whole code
written for the proof-of-concept prototype - about 700 lines of Geant4 specific code
- Generative approach will make the task even
lighter
16Info
- The GDML Web site is at
- http//cern.ch/gdml
- The GDML Schema 1.0 is at
- http//cern.ch/gdml/schema