Introduction
We are considering using a XML-based approach for the STAR geometry
description. One example of work being done in that directions can
be found in our local pages and
GDML
documentation available from CERN
The curent issues in our development are the following:
- The choice of the XML schema
- The choice of the parser technology
- Database interface
Database Interface
An introduction on the subject of interfacing the XML
and the database can be found
here. In addition, there is a
list of relevant database products available.
Database interfaces for XML
There are hundreds of products available, differing in approach (datacentric
versus documentcentric), licensing scheme and language platforms.
Some of the more interesting listed here:
-
MySQL, which has the obvious advantage of being our
RDBMS platform of choice. After version 4.00, it can optionally deliver the query results
as an XML document. The rest of what needs to be done can be achieved via IDREF.
-
ODBC2XML by
Intelligent Systems Research. The product allows one to use an embedded XML Processing Instruction
(PI) to actuate a query on the server, with actual substitution of the result into the XML body.
A big advantge of ODBC2XML is its ability to use a variety if underlying RDBMS, such as Sybase,
Oracle, Microsoft and even Excel spreadsheets.
Further investigation pending, this product might strike the right balance of functionality and
simplicity for our applicaiton. However, it appears that there is no Linux port at this time.
-
Adaptive Server Anywhere
by Sybase. It appears that this version of the server
has the functionality to return the results of a query in XML form, however it is not clear
if the substitution mechanism is automatic (i.e. if additional code needs to be written)
-
Microsoft SQL Server 2000 has
some advanced XML Features.
These include a mapping feature, which is basically a way to specify a schema for the XML
document returned from a query.
-
DBIx::XMLMessage Perl module allows to query an underlying
database using an XML interface, and get results also in XML format
Case study: MySQL
Mapping STARSIM structures onto tables
Let's assume we'll use MySQL as the RDBMS layer. Let's consider pre-extracting the data
from the database and cashing in a XML document, referenced by GDML or other XML-based source
code, for example.
Typically, any detector subsystems in STAR is characterized by tens or hundreds of parameters.
There is an obvious need to structure these data in any implementation. In the existing
STAR geometry description system (Starsim), there are the so-called "structures" (in the software
sense of this word), which are a way to group parameters of a relatively small physicall
part of the detector. For example, there is a structure
describing the numerical data for the beam support in the SVT geometry description, a structure for
the shielding parameters, a structure for the support wheel of the TPC etc.
Preserving this data organization would probably facilitate the transition to the new platform.
One solution is to create database tables under the same names as structures found in our
existing code, with column names matching the names of the data members. A query of these tables
would yield a XML document which would contain the totality of the numerical data for a particular
geometry.
The structures currently used contain a field called version, although the name
can be anything.. It can indeed be
used for versioning, but more often is is used as an index to effectively create an array
of structures, further used in an iterator in the code generating the geometrical model. It is
important then to insure there is no confusion about versioning. The "version" should be
therefore be named isomething else ("index", "layer" etc), and a column "version" created
and used according to its name. For example, if the SVT ladders were shifted between runs, we could
increment the version and insert a few rows (because there are indices) to reflect that.
Here is a crude example. Consider a simplified variant of one of the structures found in the
SVT description (effectively an array of 3 elements):
Fill SCBP ! Cabling
Layer=1 ! Layer
Len =1.85 ! Length
Rmin1=2.1 ! Min radius closer to wafers
Rmin2=3.2 ! Min radius further from wafers
EndFill
*
Fill SCBP ! Cabling
Layer=2 ! Layer
Len =1.85 ! Length
Rmin1=4.1 ! Min radius closer to wafers
Rmin2=5.3 ! Min radius further from wafers
EndFill
*
Fill SCBP ! Cabling
Layer=3 ! Layer
Len =1.85 ! Length
Rmin1=7.2 ! Min radius closer to wafers
Rmin2=9.7 ! Min radius further from wafers
EndFill
Now assume that there was a shift in the position of this part of the SVT, hence
a change in numerical values. A second version of the array needs to be introduced.
In order to implement the database storage of these data,
we can proceed to create a database table with the following contents (the schema
is quite simple and self-explanatory). Note that we normalize out the comment into
a separate table.
Table SCBP
Version | Layer | Len | Rmin1 | Rmin2 |
1 | 1 | 1.85 | 2.1 | 3.2 |
1 | 2 | 1.85 | 4.1 | 5.3 |
1 | 3 | 1.85 | 7.2 | 9.7 |
2 | 1 | 1.87 | 2.2 | 3.3 |
2 | 2 | 1.87 | 4.2 | 5.4 |
2 | 3 | 1.87 | 7.2 | 9.8 |
Table SCBPDOC
Parameter |
Comment |
Layer | Number of the SVT Layer |
Len | Length of the cabling |
Rmin1 | Min radius closer to wafers |
Rmin2 | Min radius further to wafers |
Table SCBPDOC obviously contains two versions corresponding to two surveys as
mentioned above.
Extracting the XML Data
select Layer, Len, Rmin1, Rmin2 from SCBP where Version='2'
Page updated by Maxim Potekhin on 11/05/2004