XML in LHCb Detector Description Framework Radovan Chytracek
XML in LHCb Detector Description Framework Radovan Chytracek CERN Radovan Chytracek
Detector Description Overview Ü Component of the Gaudi framework Ü Inherits the Gaudi architecture decisions Ü Detector description provides ð Single source of detector data for all clients Ø simulation, reconstruction, analysis, test beam ð It is not detector geometry only! Ø logical detector structure, geometry & positions, materials, mapping electronic channels to detector cells, detector control data needed for reconstruction, calibration and alignment data ð Versioning of all detector data based on event time, run #, etc. Ü Persistency of detector description in XML format ðXML may be stored in files on disk , on the Web or in a DBMS 10/15/2021 Radovan Chytracek 2
Detector Data Store Algorithm Geant 4 Service G 4 Converter Detector Data Service Det. Element 1 Det. Element 2 Transient Detector Store Geant 4 Representation 10/15/2021 Detector Persistency Service Converter Persistent Detector Store Det. Element 1 Det. Element 2 Converter The transient detector store contains a “snapshot” of the detector data valid for the currently processed event Radovan Chytracek 3
Transient Detector Store Root of the store Top level catalogues • Tree-like structure • Items identified by a logical name • Updated on demand • Automatic update when a new event is loaded 10/15/2021 Radovan Chytracek 4
Loading on demand Data. Object Hierarchy * Geometry Info Det. Element Read. Out Association resolved on demand * LVolume Material Solid Calibration Muon. Station Specific detector description questions from algorithms Detector Description 10/15/2021 PVolume Mixture Element Isotope * Solid. Box Geometry Radovan Chytracek * Material 5
Choices made for XML ÜXML DOM is not used ðmemory expensive ðwe don’t write data back to XML (yet) ðwe have already the transient hierarchical object model in Gaudi ÜSAX is the choice for implementation ðeasy to implement and extend ðwe loose structure of XML documents ÜIBM XML 4 C parser 10/15/2021 Radovan Chytracek 6
Numerical Expressions Parser Ü Simple parser for evaluation of expressions Ü Expressions can be composed of ðinteger and floating point numbers Ø 100 | 100. |. 05 | 0. 1| 1. 34 -e 12|-23 ðoperations: +, -, *, /, unary +|-, exponent ^ ðparenthesized expressions: 1. 4 * ( 23. 4 -e 12 / 1. 8 ) Ü Result is always evaluated to double value Ü Operator precedence from left to right: ð[()] [unary +|-] [^] [*|/] [+|-] Ü By default checks for units in expressions 10/15/2021 Radovan Chytracek 7
CLHEP Units Compatibility Ü DTD for XML detector description defines units a la CLHEP Ü Units MUST be used where required ðXML converters assume the use of units ðIn case the units are missing processing stops and an exception is thrown. Ü Use expressions parser where needed with check for units enabled Ü Examples ð 23*&cm; | 12*&volt; | 23. 6*&g; /&cm 3; 10/15/2021 Radovan Chytracek 8
C++ to XML 10/15/2021 Radovan Chytracek 9
DDDB Tag <!ENTITY % elems "detelem | logvol | material"> <!ELEMENT DDDB (catalog | catalogref | %elems; )+> <!ATTLIST DDDB version CDATA "3. 0"> <? xml version="1. 0" encoding="UTF-8"? > <!DOCTYPE DDDB SYSTEM "xmldb. dtd"> <DDDB> <catalog name="dd"> <catalogref href="structure. xml#Structure"/> <catalogref href="materials/materials. xml#Materials"/> <catalogref href="geometry. xml#Geometry"/> </catalog> </DDDB> 10/15/2021 Radovan Chytracek 10
Detector Element Tag <!ENTITY % detelemdata "author? , version, geometryinfo"> <!ENTITY % nmclid "name ID #REQUIRED class. ID CDATA #REQUIRED"> <!ELEMENT detelem (%detelemdata; , detelemref*, specific? )> <!ATTLIST detelem %nmclid; > <? xml version="1. 0" encoding="UTF-8"? > <!DOCTYPE DDDB SYSTEM ". . /xmldb. dtd"> <DDDB> <detelem class. ID="2" name="LHCb"> <author>RCH</author> <version>0. 1</version> <geometryinfo> <lvname="/dd/Geometry/LHCb/lv. LHCb"/> </geometryinfo> <detelemref class. ID="9999" href="Vertex. Rich 1/Vertex/structure. xml#Vertex"/> <detelemref class. ID="2" href="Vertex. Rich 1/structure. xml#Rich 1"/> <detelemref class. ID="2" href="Tracker. Rich 2/Tracker/structure. xml#Tracker"/> <detelemref class. ID="2" href="Tracker. Rich 2/structure. xml#RICH 2"/> <detelemref class. ID="8900" href="Calo. Muon/Calo/structure. xml#Ecal"/> <detelemref class. ID="2" href="Calo. Muon/structure. xml#Muon"/> </detelem> </DDDB> 10/15/2021 Radovan Chytracek 11
Inheritance in XML <!DOCTYPE DDDB SYSTEM "xmldb. dtd" [ <!--Number of stations in Vertex detector--> Definition <!ELEMENT Si. Tank. Radius EMPTY> of the user <!ATTLIST Si. Tank. Radius n CDATA #REQUIRED> XML tags <!ELEMENT Diode. Pitch EMPTY> <!ATTLIST Piode. Pitch n CDATA #REQUIRED> <!ELEMENT Readout. Pitch EMPTY> <!ATTLIST Readout. Pitch n CDATA #REQUIRED> ]> <DDDB> <detelem class. ID="9999" name="Vertex">. . . <geometryinfo> Detector <lvname="/dd/Geometry/lv. Vertex" /> specific <support name="/dd/Structure/LHCb"> <npath value="pv. Vertex_0" /> </support> data </geometryinfo> <detelemref class. ID="2" href="#VStation 01"/> <detelemref class. ID="2" href="#VStation 02"/> <specific> <Si. Tank. Radius n=‘ 17’ /> <Diode. Pitch n=‘ 0. 0025’ /> <Readout. Pitch n=‘ 0. 0050’ /> </specific> </detelem> </DDDB> 10/15/2021 Radovan Chytracek 12
Logical Volume Tag <!ENTITY % solid "(box | cons | sphere | tubs | trd | union | subtraction | intersection)"> <!ELEMENT logvol (%solid; , (physvol | paramphysvol)*)> <!ATTLIST logvol name ID #REQUIRED material CDATA #REQUIRED class. ID CDATA #FIXED "1100"> <? xml version="1. 0" encoding="UTF-8"? > <!DOCTYPE DDDB SYSTEM ". . /xmldb. dtd"> <DDDB> <logvol name="lv. Vertex. Rich 1" material="Vacuum"> <box name="Vertex. Rich 1 Box” size. X="5000*&mm; " size. Y="5000*&mm; " size. Z="5000*&mm; "/> <physvol name="pv. Vertex” logvol="/dd/Geometry/LHCb/Vertex/lv. Vertex"> <pos. XYZ x="0*&mm; " y="0*&mm; " z="-1000*&mm; "/> </physvol> <physvol name="pv. Rich 1” logvol="/dd/Geometry/LHCb/Rich 1/lv. Rich 1"> <pos. XYZ x="0*&mm; " y="0*&mm; " z="2000*&mm; "/> </physvol> </logvol> </DDDB> 10/15/2021 Radovan Chytracek 13
Physical Volume Tags <!ELEMENT physvol ((pos. XYZ|pos. RPhi. Z|pos. RTh. Phi), (rot. XYZ|rot. Axis)? )> <!ATTLIST physvol name ID #REQUIRED logvol CDATA #REQUIRED> Initial position <!ELEMENT paramphysvol (physvol, (pos. XYZ|pos. RPhi. Z|pos. RTh. Phi), (rot. XYZ|rot. Axis))> Parametric Simple Step <!ATTLIST paramphysvol number CDATA #REQUIRED> of the first physical for <logvol name="lv. PVStation" material="Vacuum"> physical volume translation rotation volume <tubs name="pv. Station. Tubs. PV" size. Z="0. 15*&mm; ” copy outer. Radius="60*°ree; " inner. Radius="10*°ree; ” start. Phi. Angle="-1. 5*°ree; " delta. Phi. Angle="181. 5*°ree; "/> <paramphysvol number="6"> <physvol name="wafer. PV" logvol="/dd/Geometry/LHCb/Vertex/lv. Wafer"> <pos. XYZ x="0*&mm; " y="0*&mm; " z="-0. 5*&mm; "/> <rot. XYZ rot. X="0*°ree; " rot. Y="0*°ree; " rot. Z="0*°ree; "/> </physvol> <pos. XYZ x="0*&mm; " y="0*&mm; " z="0*&mm; "/> <rot. XYZ rot. X="0*°ree; " rot. Y="0*°ree; " rot. Z="53. 25*°ree; "/> </paramphysvol> <physvol name="pvwafer. Strange" logvol="/dd/Geometry/LHCb/Vertex/lv. Wafer"> <pos. XYZ x="0*&mm; " y="0*&mm; " z="-1. 5*&mm; "/> <rot. XYZ rot. X="0*°ree; " rot. Y="0*°ree; " rot. Z="0*°ree; "/> </physvol> </logvol> 10/15/2021 Radovan Chytracek 14
Solid Tags <!ENTITY % simplesolid "(box | cons | sphere | tubs | trd)"> <!ELEMENT box ((pos. XYZ | pos. RPhi. Z | pos. RTh. Phi), (rot. XYZ | rot. Axis)? )? > <!ATTLIST box name ID #REQUIRED size. X CDATA #REQUIRED size. Y CDATA #REQUIRED size. Z CDATA #REQUIRED> <!ELEMENT union (%simplesolid; )+> Main <!ATTLIST union name ID #REQUIRED> or reference solid <logvol material="Vacuum" name="lv. Ecal. Outer"> <subtraction name="box. Ecal. Outer"> <box name="box. EOMain” size. Z="432*&mm; " size. X="7933. 44*&mm; " size. Y="6445. 92*&mm; "> <pos. XYZ z="0*&mm; " y="0*&mm; " x="0*&mm; "/> </box> <box name="box. EOSubtracted” size. Z="432*&mm; " size. X="2479. 20*&mm; " size. Y="1983. 36*&mm; "> <pos. XYZ z="0*&mm; " y="0*&mm; " x="0*&mm; "/> </box> </subtraction> Subtracted </logvol> solid placed relative toto the main solid 10/15/2021 Radovan Chytracek 15
Position Tags Cartesian coordinate system <!ELEMENT pos. XYZ EMPTY> <!ATTLIST pos. XYZ x CDATA #REQUIRED y CDATA #REQUIRED z CDATA #REQUIRED> Cylindrical coordinate system <!ELEMENT pos. RPhi. Z EMPTY> <!ATTLIST pos. RPhi. Z r CDATA #REQUIRED phi CDATA #REQUIRED z CDATA #REQUIRED> Spherical coordinate system <!ELEMENT pos. RTh. Phi EMPTY> <!ATTLIST pos. RTh. Phi r CDATA #REQUIRED theta CDATA #REQUIRED phi CDATA #REQUIRED> 10/15/2021 Radovan Chytracek 16
Rotation Tags Rotation around the axes X, Y and Z <!ELEMENT rot. XYZ EMPTY> <!ATTLIST rot. XYZ rot. X CDATA #REQUIRED rot. Y CDATA #REQUIRED rot. Z CDATA #REQUIRED> Rotation using vector and angle <!ELEMENT rot. Axis EMPTY> <!ATTLIST rot. Axis ax. Theta CDATA #REQUIRED ax. Phi CDATA #REQUIRED angle CDATA #REQUIRED> 10/15/2021 Radovan Chytracek 17
Material Tag <!ENTITY % materialdata "a? , z? , n? , density, x 0? , lambda? "> <!ELEMENT fraction (atoms | mass)> <!ELEMENT atoms EMPTY> <!ATTLIST atoms n CDATA #REQUIRED> <!ELEMENT mass EMPTY> <!ATTLIST mass n CDATA #REQUIRED> <!ELEMENT material (%materialdata; , (materialref)*)> <!ATTLIST material %nmclid; form (isotope | element | mixture) #IMPLIED temperature CDATA #IMPLIED pressure CDATA #IMPLIED state (solid | liquid | gas) #IMPLIED > <!ELEMENT a (#PCDATA)> <!ELEMENT z (#PCDATA)> <!ELEMENT n (#PCDATA)> <!ELEMENT density (#PCDATA)> <!ELEMENT x 0 (#PCDATA)> <!ELEMENT lambda (#PCDATA)> 10/15/2021 Radovan Chytracek 18
Material Tag <material name="Bor_10" class. ID="&isotope; "> <a>10. 000*&g; /&mole; </a> <z>5. 000</z> <density>2. 3400*&g; /&cm 3; </density> <x 0>0. 0000 e+00*&cm; </x 0> <lambda>0. 0000 e+00*&cm; </lambda> </material> <material name="Water" class. ID="&mixture; "> <density>1. 0000*&g; /&cm 3; </density> <materialref class. ID="&element; " href="elements. xml#Hydrogen"> <fraction> <atoms n="2"/> </fraction> </materialref> <materialref class. ID="&element; " href="elements. xml#Oxygen"> <fraction> <atoms n="1"/> </fraction> </materialref> </material> 10/15/2021 Radovan Chytracek 19
Conclusions Ü Status ðXML based det. descr. is the integral part of Gaudi Ø Working on NT, Linux Ü Future steps ðVersioning ðPopulation of the XML DDDB from the LHCb detector description based on Geant 3 ðDefine the XML format for conditions Ø calibration, alignment, channel maps, slow control, . . . ðImplement the XML DDDB in the conjunction with a “real” DB (RD 45 Conditions/DB, Oracle, . . . ) 10/15/2021 Radovan Chytracek 20
Geometry Info Tag <geometryinfo> <lvname="/dd/Geometry/lv. Vertex" /> <support name="/dd/Structure/LHCb"> <npath value="pv. Vertex_0" /> </support> </geometryinfo> lv. Vertex pv. VSt 1 pv. VSt 0 lv. LHCb pv. Vertex_0 pv. VSt 1 10/15/2021 lv. Vtx. St Replica path is /pv. Vertex_0 pv. Vertex_1 pv. VSt 0 Replica path is /pv. Vertex_0/pv. Vst 0 Radovan Chytracek 21
XML Converters Model 10/15/2021 Radovan Chytracek 22
XML Conversion XML data XML data XML Parser SAX API XML Converter Transient Store • It can be any XML parser supporting SAX API for C++ • SAX - Simple API for XML 10/15/2021 Radovan Chytracek 23
XML Briefly ÜXML features ÜXML is the ðUser defined tags ðData self described ðHyperlinks ðProperly nested tags forming a tree structure ðData separated from behavior ðW 3 C Recommendation Ø XML 1. 0 ðsubset of SGML Ø 20% complexity Ø 80% flexibility of SGML ðApplication independent data interchange format ÜSafe investment in data and manpower ÜProblems with XML ðincreasing support for XML in the industry ðmaintained outside CERN 10/15/2021 Radovan Chytracek ðC++ to XML mapping ðInheritance ðPerformance ðData Management 24
Persistent Detector Store Ü The Gaudi architecture shields end users from a persistent technology ðAllows co-existence of different persistency technologies Ø technology specific code only on well defined places àservices and converters ðWe don’t know which technologies will be available in 2005 Ü We use XML as our persistent data format ðXML can be stored in files, WWW, database 10/15/2021 Radovan Chytracek 25
- Slides: 25